Bug 1308363 - Remove GONK specific code from gfx/. r=jrmuizel,sotaro
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 27 Oct 2016 13:17:10 +1300
changeset 362537 d1b64926c64c3f93e054c6089b43e5ae26510a38
parent 362536 8b07f481251c7c1aa8911e5f53f26d0c71f14dfc
child 362538 58220cbd66045f85c22d8c830973643dab017810
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, sotaro
bugs1308363
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1308363 - Remove GONK specific code from gfx/. r=jrmuizel,sotaro
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
gfx/2d/DrawTargetRecording.cpp
gfx/2d/Logging.h
gfx/2d/moz.build
gfx/gl/GLBlitHelper.cpp
gfx/gl/GLBlitHelper.h
gfx/gl/GLContextProviderEGL.cpp
gfx/gl/GLLibraryEGL.cpp
gfx/gl/GLScreenBuffer.cpp
gfx/gl/SharedSurfaceGralloc.cpp
gfx/gl/SharedSurfaceGralloc.h
gfx/gl/moz.build
gfx/layers/Compositor.cpp
gfx/layers/Compositor.h
gfx/layers/GrallocImages.cpp
gfx/layers/GrallocImages.h
gfx/layers/ImageContainer.cpp
gfx/layers/ImageContainer.h
gfx/layers/LayerScope.cpp
gfx/layers/LayersLogging.cpp
gfx/layers/LayersTypes.cpp
gfx/layers/LayersTypes.h
gfx/layers/RotatedBuffer.cpp
gfx/layers/TiledLayerBuffer.h
gfx/layers/basic/GrallocTextureHostBasic.cpp
gfx/layers/basic/GrallocTextureHostBasic.h
gfx/layers/basic/TextureHostBasic.cpp
gfx/layers/client/CanvasClient.cpp
gfx/layers/client/ClientLayerManager.cpp
gfx/layers/client/ClientTiledPaintedLayer.cpp
gfx/layers/client/ImageClient.cpp
gfx/layers/client/TextureClient.cpp
gfx/layers/client/TextureClient.h
gfx/layers/client/TextureClientSharedSurface.cpp
gfx/layers/client/TextureClientSharedSurface.h
gfx/layers/client/TiledContentClient.cpp
gfx/layers/composite/ImageHost.cpp
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/composite/LayerManagerComposite.h
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/composite/TiledContentHost.h
gfx/layers/ipc/CompositableForwarder.h
gfx/layers/ipc/CompositableTransactionParent.cpp
gfx/layers/ipc/CompositorBench.cpp
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/ipc/CompositorBridgeParent.h
gfx/layers/ipc/FenceUtils.cpp
gfx/layers/ipc/GonkNativeHandle.h
gfx/layers/ipc/GonkNativeHandleUtils.h
gfx/layers/ipc/ISurfaceAllocator.h
gfx/layers/ipc/ImageBridgeChild.cpp
gfx/layers/ipc/ImageBridgeChild.h
gfx/layers/ipc/ImageBridgeParent.cpp
gfx/layers/ipc/LayerTransactionParent.cpp
gfx/layers/ipc/LayersSurfaces.ipdlh
gfx/layers/ipc/PSharedBufferManager.ipdl
gfx/layers/ipc/ShadowLayerUtils.h
gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
gfx/layers/ipc/ShadowLayerUtilsGralloc.h
gfx/layers/ipc/ShadowLayers.cpp
gfx/layers/ipc/ShadowLayers.h
gfx/layers/ipc/SharedBufferManagerChild.cpp
gfx/layers/ipc/SharedBufferManagerChild.h
gfx/layers/ipc/SharedBufferManagerParent.cpp
gfx/layers/ipc/SharedBufferManagerParent.h
gfx/layers/moz.build
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/CompositorOGL.h
gfx/layers/opengl/GrallocTextureClient.cpp
gfx/layers/opengl/GrallocTextureClient.h
gfx/layers/opengl/GrallocTextureHost.cpp
gfx/layers/opengl/GrallocTextureHost.h
gfx/layers/opengl/TextureHostOGL.cpp
gfx/skia/moz.build
gfx/thebes/gfxAndroidPlatform.cpp
gfx/thebes/gfxAndroidPlatform.h
gfx/thebes/gfxFT2FontList.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/moz.build
xpcom/build/XPCOMInit.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -46,17 +46,16 @@
 #include "mozilla/ipc/ProcessChild.h"
 #include "mozilla/ipc/PSendStreamChild.h"
 #include "mozilla/ipc/TestShellChild.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
 #include "mozilla/layers/APZChild.h"
 #include "mozilla/layers/CompositorBridgeChild.h"
 #include "mozilla/layers/ContentProcessController.h"
 #include "mozilla/layers/ImageBridgeChild.h"
-#include "mozilla/layers/SharedBufferManagerChild.h"
 #include "mozilla/layout/RenderFrameChild.h"
 #include "mozilla/net/NeckoChild.h"
 #include "mozilla/plugins/PluginInstanceParent.h"
 #include "mozilla/plugins/PluginModuleParent.h"
 #include "mozilla/widget/WidgetMessageUtils.h"
 #include "nsBaseDragService.h"
 #include "mozilla/media/MediaChild.h"
 #include "mozilla/BasePrincipal.h"
@@ -1209,23 +1208,16 @@ ContentChild::RecvReinitRendering(Endpoi
   for (const auto& tabChild : tabs) {
     if (tabChild->LayersId()) {
       tabChild->ReinitRendering();
     }
   }
   return true;
 }
 
-PSharedBufferManagerChild*
-ContentChild::AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
-                                              base::ProcessId aOtherProcess)
-{
-  return SharedBufferManagerChild::StartUpInChildProcess(aTransport, aOtherProcess);
-}
-
 PBackgroundChild*
 ContentChild::AllocPBackgroundChild(Transport* aTransport,
                                     ProcessId aOtherProcess)
 {
   return BackgroundChild::Alloc(aTransport, aOtherProcess);
 }
 
 PProcessHangMonitorChild*
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -168,20 +168,16 @@ public:
     Endpoint<PVRManagerChild>&& aVRBridge) override;
 
   bool
   RecvReinitRendering(
     Endpoint<PCompositorBridgeChild>&& aCompositor,
     Endpoint<PImageBridgeChild>&& aImageBridge,
     Endpoint<PVRManagerChild>&& aVRBridge) override;
 
-  PSharedBufferManagerChild*
-  AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
-                                  base::ProcessId aOtherProcess) override;
-
   PProcessHangMonitorChild*
   AllocPProcessHangMonitorChild(Transport* aTransport,
                                 ProcessId aOtherProcess) override;
 
   virtual bool RecvSetProcessSandbox(const MaybeFileDesc& aBroker) override;
 
   PBackgroundChild*
   AllocPBackgroundChild(Transport* aTransport, ProcessId aOtherProcess)
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -80,17 +80,16 @@
 #include "mozilla/ipc/PSendStreamParent.h"
 #include "mozilla/ipc/TestShellParent.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
 #include "mozilla/layers/PAPZParent.h"
 #include "mozilla/layers/CompositorThread.h"
 #include "mozilla/layers/ImageBridgeParent.h"
 #include "mozilla/layers/LayerTreeOwnerTracker.h"
-#include "mozilla/layers/SharedBufferManagerParent.h"
 #include "mozilla/layout/RenderFrameParent.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/media/MediaParent.h"
 #include "mozilla/Move.h"
 #include "mozilla/net/NeckoParent.h"
 #include "mozilla/plugins/PluginBridge.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ProcessHangMonitor.h"
@@ -2209,20 +2208,16 @@ ContentParent::InitInternal(ProcessPrior
 
       Unused << SendInitRendering(
         Move(compositor),
         Move(imageBridge),
         Move(vrBridge));
 
       gpm->AddListener(this);
     }
-#ifdef MOZ_WIDGET_GONK
-    DebugOnly<bool> opened = PSharedBufferManager::Open(this);
-    MOZ_ASSERT(opened);
-#endif
   }
 
   if (gAppData) {
     // Sending all information to content process.
     Unused << SendAppInit();
   }
 
   nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
@@ -2842,23 +2837,16 @@ ContentParent::AllocPBackgroundParent(Tr
 PProcessHangMonitorParent*
 ContentParent::AllocPProcessHangMonitorParent(Transport* aTransport,
                                               ProcessId aOtherProcess)
 {
   mHangMonitorActor = CreateHangMonitorParent(this, aTransport, aOtherProcess);
   return mHangMonitorActor;
 }
 
-PSharedBufferManagerParent*
-ContentParent::AllocPSharedBufferManagerParent(mozilla::ipc::Transport* aTransport,
-                                                base::ProcessId aOtherProcess)
-{
-  return SharedBufferManagerParent::Create(aTransport, aOtherProcess);
-}
-
 bool
 ContentParent::RecvGetProcessAttributes(ContentParentId* aCpId,
                                         bool* aIsForApp, bool* aIsForBrowser)
 {
   *aCpId = mChildID;
   *aIsForApp = IsForApp();
   *aIsForBrowser = mIsForBrowser;
 
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -62,17 +62,16 @@ class URIParams;
 class TestShellParent;
 } // namespace ipc
 
 namespace jsipc {
 class PJavaScriptParent;
 } // namespace jsipc
 
 namespace layers {
-class PSharedBufferManagerParent;
 struct TextureFactoryIdentifier;
 } // namespace layers
 
 namespace layout {
 class PRenderFrameParent;
 } // namespace layout
 
 namespace dom {
@@ -697,20 +696,16 @@ private:
   static bool AllocateLayerTreeId(ContentParent* aContent,
                                   TabParent* aTopLevel, const TabId& aTabId,
                                   uint64_t* aId);
 
   PGMPServiceParent*
   AllocPGMPServiceParent(mozilla::ipc::Transport* aTransport,
                          base::ProcessId aOtherProcess) override;
 
-  PSharedBufferManagerParent*
-  AllocPSharedBufferManagerParent(mozilla::ipc::Transport* aTranport,
-                                   base::ProcessId aOtherProcess) override;
-
   PBackgroundParent*
   AllocPBackgroundParent(Transport* aTransport, ProcessId aOtherProcess)
                          override;
 
   PProcessHangMonitorParent*
   AllocPProcessHangMonitorParent(Transport* aTransport,
                                  ProcessId aOtherProcess) override;
 
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -36,17 +36,16 @@ include protocol PGMPContent;
 include protocol PGMPService;
 include protocol PPluginModule;
 include protocol PGMP;
 include protocol PPrinting;
 include protocol PSendStream;
 include protocol POfflineCacheUpdate;
 include protocol PRenderFrame;
 include protocol PScreenManager;
-include protocol PSharedBufferManager;
 include protocol PSpeechSynthesis;
 include protocol PStorage;
 include protocol PTelephony;
 include protocol PTestShell;
 include protocol PJavaScript;
 include protocol PRemoteSpellcheckEngine;
 include protocol PWebBrowserPersistDocument;
 include protocol PWebrtcGlobal;
@@ -339,17 +338,16 @@ struct BlobURLRegistrationData
     Principal principal;
 };
 
 nested(upto inside_cpow) sync protocol PContent
 {
     parent spawns PPluginModule;
 
     parent opens PProcessHangMonitor;
-    parent opens PSharedBufferManager;
     parent opens PGMPService;
     child opens PBackground;
 
     manages PBlob;
     manages PBluetooth;
     manages PBrowser;
     manages PContentPermissionRequest;
     manages PCrashReporter;
--- a/gfx/2d/DrawTargetRecording.cpp
+++ b/gfx/2d/DrawTargetRecording.cpp
@@ -367,36 +367,31 @@ struct RecordingFontUserData
   RefPtr<DrawEventRecorderPrivate> recorder;
 };
 
 void RecordingFontUserDataDestroyFunc(void *aUserData)
 {
   RecordingFontUserData *userData =
     static_cast<RecordingFontUserData*>(aUserData);
 
-  // TODO support font in b2g recordings
-#ifndef MOZ_WIDGET_GONK
   userData->recorder->RecordEvent(RecordedScaledFontDestruction(userData->refPtr));
-#endif
 
   delete userData;
 }
 
 void
 DrawTargetRecording::FillGlyphs(ScaledFont *aFont,
                                 const GlyphBuffer &aBuffer,
                                 const Pattern &aPattern,
                                 const DrawOptions &aOptions,
                                 const GlyphRenderingOptions *aRenderingOptions)
 {
   EnsurePatternDependenciesStored(aPattern);
 
   if (!aFont->GetUserData(reinterpret_cast<UserDataKey*>(mRecorder.get()))) {
-  // TODO support font in b2g recordings
-#ifndef MOZ_WIDGET_GONK
     RecordedFontData fontData(aFont);
     RecordedFontDetails fontDetails;
     if (fontData.GetFontDetails(fontDetails)) {
       // Try to serialise the whole font, just in case this is a web font that
       // is not present on the system.
       if (!mRecorder->HasStoredFontData(fontDetails.fontDataKey)) {
         mRecorder->RecordEvent(fontData);
         mRecorder->AddStoredFontData(fontDetails.fontDataKey);
@@ -407,28 +402,24 @@ DrawTargetRecording::FillGlyphs(ScaledFo
       // the system on the other side.
       RecordedFontDescriptor fontDesc(aFont);
       if (fontDesc.IsValid()) {
         mRecorder->RecordEvent(fontDesc);
       } else {
         gfxWarning() << "DrawTargetRecording::FillGlyphs failed to serialise ScaledFont";
       }
     }
-#endif
     RecordingFontUserData *userData = new RecordingFontUserData;
     userData->refPtr = aFont;
     userData->recorder = mRecorder;
     aFont->AddUserData(reinterpret_cast<UserDataKey*>(mRecorder.get()), userData, 
                        &RecordingFontUserDataDestroyFunc);
   }
 
-  // TODO support font in b2g recordings
-#ifndef MOZ_WIDGET_GONK
   mRecorder->RecordEvent(RecordedFillGlyphs(this, aFont, aPattern, aOptions, aBuffer.mGlyphs, aBuffer.mNumGlyphs));
-#endif
   mFinalDT->FillGlyphs(aFont, aBuffer, aPattern, aOptions, aRenderingOptions);
 }
 
 void
 DrawTargetRecording::Mask(const Pattern &aSource,
                           const Pattern &aMask,
                           const DrawOptions &aOptions)
 {
--- a/gfx/2d/Logging.h
+++ b/gfx/2d/Logging.h
@@ -11,17 +11,17 @@
 #include <stdio.h>
 #include <vector>
 
 #ifdef MOZ_LOGGING
 #include "mozilla/Logging.h"
 #endif
 #include "mozilla/Tuple.h"
 
-#if defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_ANDROID)
+#if defined(MOZ_WIDGET_ANDROID)
 #include "nsDebug.h"
 #endif
 #include "Point.h"
 #include "BaseRect.h"
 #include "Matrix.h"
 #include "LoggingConstants.h"
 
 #if defined(MOZ_LOGGING)
@@ -135,17 +135,17 @@ enum class LogReason : int {
 
 struct BasicLogger
 {
   // For efficiency, this method exists and copies the logic of the
   // OutputMessage below.  If making any changes here, also make it
   // in the appropriate places in that method.
   static bool ShouldOutputMessage(int aLevel) {
     if (LoggingPrefs::sGfxLogLevel >= aLevel) {
-#if defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_ANDROID)
+#if defined(MOZ_WIDGET_ANDROID)
       return true;
 #else
 #if defined(MOZ_LOGGING)
       if (MOZ_LOG_TEST(GetGFX2DLog(), PRLogLevelForLevel(aLevel))) {
         return true;
       } else
 #endif
       if ((LoggingPrefs::sGfxLogLevel >= LOG_DEBUG_PRLOG) ||
@@ -168,17 +168,17 @@ struct BasicLogger
     // is in the build, but disabled, we will printf if the preferences
     // requires us to log something (see sGfxLogLevel for the special
     // treatment of LOG_DEBUG and LOG_DEBUG_PRLOG)
     //
     // If making any logic changes to this method, you should probably
     // make the corresponding change in the ShouldOutputMessage method
     // above.
     if (LoggingPrefs::sGfxLogLevel >= aLevel) {
-#if defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_ANDROID)
+#if defined(MOZ_WIDGET_ANDROID)
       printf_stderr("%s%s", aString.c_str(), aNoNewline ? "" : "\n");
 #else
 #if defined(MOZ_LOGGING)
       if (MOZ_LOG_TEST(GetGFX2DLog(), PRLogLevelForLevel(aLevel))) {
         PR_LogPrint("%s%s", aString.c_str(), aNoNewline ? "" : "\n");
       } else
 #endif
       if ((LoggingPrefs::sGfxLogLevel >= LOG_DEBUG_PRLOG) ||
--- a/gfx/2d/moz.build
+++ b/gfx/2d/moz.build
@@ -202,22 +202,22 @@ if CONFIG['CPU_ARCH'] == 'arm' and CONFI
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 for var in ('USE_CAIRO', 'MOZ2D_HAS_MOZ_CAIRO'):
     DEFINES[var] = True
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'gonk'):
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3'):
     DEFINES['MOZ_ENABLE_FREETYPE'] = True
 
 CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'gonk'):
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3'):
     CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
 
 LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
 
 if CONFIG['MOZ_ENABLE_SKIA']:
     LOCAL_INCLUDES += [
         '/gfx/skia/skia/include/private',
         '/gfx/skia/skia/src/core',
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -10,21 +10,16 @@
 #include "GLScreenBuffer.h"
 #include "ScopedGLHelpers.h"
 #include "mozilla/Preferences.h"
 #include "ImageContainer.h"
 #include "HeapCopyOfStackArray.h"
 #include "mozilla/gfx/Matrix.h"
 #include "mozilla/UniquePtr.h"
 
-#ifdef MOZ_WIDGET_GONK
-#include "GrallocImages.h"
-#include "GLLibraryEGL.h"
-#endif
-
 #ifdef MOZ_WIDGET_ANDROID
 #include "AndroidSurfaceTexture.h"
 #include "GLImages.h"
 #include "GLLibraryEGL.h"
 #endif
 
 #ifdef XP_MACOSX
 #include "MacIOSurfaceImage.h"
@@ -147,17 +142,17 @@ GLBlitHelper::InitTexQuadProgram(BlitTyp
         varying vec2 vTexCoord;                                       \n\
                                                                       \n\
         void main(void)                                               \n\
         {                                                             \n\
             gl_FragColor = texture2DRect(uTexUnit,                    \n\
                                          vTexCoord * uTexCoordMult);  \n\
         }                                                             \n\
     ";
-#ifdef ANDROID /* MOZ_WIDGET_ANDROID || MOZ_WIDGET_GONK */
+#ifdef ANDROID /* MOZ_WIDGET_ANDROID */
     const char kTexExternalBlit_FragShaderSource[] = "\
         #version 100                                                    \n\
         #extension GL_OES_EGL_image_external : require                  \n\
         #ifdef GL_FRAGMENT_PRECISION_HIGH                               \n\
             precision highp float;                                      \n\
         #else                                                           \n\
             precision mediump float;                                    \n\
         #endif                                                          \n\
@@ -679,48 +674,16 @@ GLBlitHelper::BindAndUploadEGLImage(EGLI
         mGL->fTexParameteri(target, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_NEAREST);
         mGL->fTexParameteri(target, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_NEAREST);
     } else {
         mGL->fBindTexture(target, mSrcTexEGL);
     }
     mGL->fEGLImageTargetTexture2D(target, image);
 }
 
-#ifdef MOZ_WIDGET_GONK
-
-bool
-GLBlitHelper::BlitGrallocImage(layers::GrallocImage* grallocImage)
-{
-    ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
-    mGL->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
-
-    EGLint attrs[] = {
-        LOCAL_EGL_IMAGE_PRESERVED, LOCAL_EGL_TRUE,
-        LOCAL_EGL_NONE, LOCAL_EGL_NONE
-    };
-    EGLImage image = sEGLLibrary.fCreateImage(sEGLLibrary.Display(),
-                                              EGL_NO_CONTEXT,
-                                              LOCAL_EGL_NATIVE_BUFFER_ANDROID,
-                                              grallocImage->GetNativeBuffer(), attrs);
-    if (image == EGL_NO_IMAGE)
-        return false;
-
-    int oldBinding = 0;
-    mGL->fGetIntegerv(LOCAL_GL_TEXTURE_BINDING_EXTERNAL_OES, &oldBinding);
-
-    BindAndUploadEGLImage(image, LOCAL_GL_TEXTURE_EXTERNAL_OES);
-
-    mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
-
-    sEGLLibrary.fDestroyImage(sEGLLibrary.Display(), image);
-    mGL->fBindTexture(LOCAL_GL_TEXTURE_EXTERNAL_OES, oldBinding);
-    return true;
-}
-#endif
-
 #ifdef MOZ_WIDGET_ANDROID
 
 #define ATTACH_WAIT_MS 50
 
 bool
 GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage)
 {
     AndroidSurfaceTexture* surfaceTexture = stImage->GetSurfaceTexture();
@@ -868,23 +831,16 @@ GLBlitHelper::BlitImageToFramebuffer(lay
     OriginPos srcOrigin;
 
     switch (srcImage->GetFormat()) {
     case ImageFormat::PLANAR_YCBCR:
         type = ConvertPlanarYCbCr;
         srcOrigin = OriginPos::TopLeft;
         break;
 
-#ifdef MOZ_WIDGET_GONK
-    case ImageFormat::GRALLOC_PLANAR_YCBCR:
-        type = ConvertGralloc;
-        srcOrigin = OriginPos::TopLeft;
-        break;
-#endif
-
 #ifdef MOZ_WIDGET_ANDROID
     case ImageFormat::SURFACE_TEXTURE:
         type = ConvertSurfaceTexture;
         srcOrigin = srcImage->AsSurfaceTextureImage()->GetOriginPos();
         break;
 
     case ImageFormat::EGLIMAGE:
         type = ConvertEGLImage;
@@ -910,21 +866,16 @@ GLBlitHelper::BlitImageToFramebuffer(lay
     const bool needsYFlip = (srcOrigin != destOrigin);
     mGL->fUniform1f(mYFlipLoc, needsYFlip ? (float)1.0 : (float)0.0);
 
     ScopedBindFramebuffer boundFB(mGL, destFB);
     mGL->fColorMask(LOCAL_GL_TRUE, LOCAL_GL_TRUE, LOCAL_GL_TRUE, LOCAL_GL_TRUE);
     mGL->fViewport(0, 0, destSize.width, destSize.height);
 
     switch (type) {
-#ifdef MOZ_WIDGET_GONK
-    case ConvertGralloc:
-        return BlitGrallocImage(static_cast<layers::GrallocImage*>(srcImage));
-#endif
-
     case ConvertPlanarYCbCr: {
             const auto saved = mGL->GetIntAs<GLint>(LOCAL_GL_UNPACK_ALIGNMENT);
             mGL->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 1);
             const auto ret = BlitPlanarYCbCrImage(static_cast<PlanarYCbCrImage*>(srcImage));
             mGL->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, saved);
             return ret;
         }
 
--- a/gfx/gl/GLBlitHelper.h
+++ b/gfx/gl/GLBlitHelper.h
@@ -102,19 +102,16 @@ class GLBlitHelper final
     void SetBlitFramebufferForDestTexture(GLuint aTexture);
 
     bool UseTexQuadProgram(BlitType target, const gfx::IntSize& srcSize);
     bool InitTexQuadProgram(BlitType target = BlitTex2D);
     void DeleteTexBlitProgram();
     void BindAndUploadYUVTexture(Channel which, uint32_t width, uint32_t height, void* data, bool allocation);
     void BindAndUploadEGLImage(EGLImage image, GLuint target);
 
-#ifdef MOZ_WIDGET_GONK
-    bool BlitGrallocImage(layers::GrallocImage* grallocImage);
-#endif
     bool BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage);
 #ifdef MOZ_WIDGET_ANDROID
     // Blit onto the current FB.
     bool BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage);
     bool BlitEGLImageImage(layers::EGLImageImage* eglImage);
 #endif
 #ifdef XP_MACOSX
     bool BlitMacIOSurfaceImage(layers::MacIOSurfaceImage* ioImage);
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -11,37 +11,24 @@
     #define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))
 #endif
 
 #ifdef MOZ_WIDGET_ANDROID
     #define GET_JAVA_SURFACE(aWidget) (aWidget->GetNativeData(NS_JAVA_SURFACE))
 #endif
 
 #if defined(XP_UNIX)
-    #ifdef MOZ_WIDGET_GONK
-        #include "libdisplay/GonkDisplay.h"
-        #include "nsWindow.h"
-        #include "nsScreenManagerGonk.h"
-    #endif
-
     #ifdef MOZ_WIDGET_ANDROID
         #include <android/native_window.h>
         #include <android/native_window_jni.h>
     #endif
 
     #ifdef ANDROID
         #include <android/log.h>
         #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
-
-        #ifdef MOZ_WIDGET_GONK
-            #include "cutils/properties.h"
-            #include <ui/GraphicBuffer.h>
-
-            using namespace android;
-        #endif
     #endif
 
     #define GLES2_LIB "libGLESv2.so"
     #define GLES2_LIB2 "libGLESv2.so.2"
 
 #elif defined(XP_WIN)
     #include "nsIFile.h"
 
@@ -232,27 +219,16 @@ GLContextEGL::~GLContextEGL()
 
 #ifdef DEBUG
     printf_stderr("Destroying context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
 #endif
 
     sEGLLibrary.fDestroyContext(EGL_DISPLAY(), mContext);
     sEGLLibrary.UnsetCachedCurrentContext();
 
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION < 17
-    if (!mIsOffscreen) {
-      // In ICS, SurfaceFlinger's DisplayHardware::fini() does not destroy the EGLSurface associated with the
-      // native framebuffer. Destroying it causes crashes in the ICS emulator
-      // EGL implementation, specifically because the egl_window_surface_t dtor
-      // calls nativeWindow->cancelBuffer and FramebufferNativeWindow does not initialize
-      // the cancelBuffer function pointer, see bug 986836
-      return;
-    }
-#endif
-
     mozilla::gl::DestroySurface(mSurface);
 }
 
 bool
 GLContextEGL::Init()
 {
 #if defined(ANDROID)
     // We can't use LoadApitraceLibrary here because the GLContext
@@ -432,22 +408,16 @@ GLContextEGL::SetupLookupFunction()
 
 bool
 GLContextEGL::SwapBuffers()
 {
     EGLSurface surface = mSurfaceOverride != EGL_NO_SURFACE
                           ? mSurfaceOverride
                           : mSurface;
     if (surface) {
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION < 17
-        if (!mIsOffscreen) {
-            // eglSwapBuffers() is called by hwcomposer.
-            return true;
-        }
-#endif
         return sEGLLibrary.fSwapBuffers(EGL_DISPLAY(), surface);
     } else {
         return false;
     }
 }
 
 // hold a reference to the given surface
 // for the lifetime of this context.
@@ -628,19 +598,16 @@ static const EGLint kEGLConfigAttribsRGB
 
 static const EGLint kEGLConfigAttribsRGBA32[] = {
     LOCAL_EGL_SURFACE_TYPE,    LOCAL_EGL_WINDOW_BIT,
     LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
     LOCAL_EGL_RED_SIZE,        8,
     LOCAL_EGL_GREEN_SIZE,      8,
     LOCAL_EGL_BLUE_SIZE,       8,
     LOCAL_EGL_ALPHA_SIZE,      8,
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-    LOCAL_EGL_FRAMEBUFFER_TARGET_ANDROID, LOCAL_EGL_TRUE,
-#endif
     EGL_ATTRIBS_LIST_SAFE_TERMINATION_WORKING_AROUND_BUGS
 };
 
 static bool
 CreateConfig(EGLConfig* aConfig, int32_t depth, nsIWidget* aWidget)
 {
     EGLConfig configs[64];
     const EGLint* attribs;
@@ -662,39 +629,16 @@ CreateConfig(EGLConfig* aConfig, int32_t
     }
 
     if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(), attribs,
                                    configs, ncfg, &ncfg) ||
         ncfg < 1) {
         return false;
     }
 
-#ifdef MOZ_WIDGET_GONK
-    // On gonk, it's important to select a configuration with the
-    // the correct order as well as bits per channel.
-    // EGL_NATIVE_VISUAL_ID gives us the Android pixel format which
-    // is an enum that tells us both order and bits per channel.
-    // For example -
-    //  HAL_PIXEL_FORMAT_RGBX_8888
-    //  HAL_PIXEL_FORMAT_BGRA_8888
-    //  HAL_PIXEL_FORMAT_RGB_565
-    nsWindow* window = static_cast<nsWindow*>(aWidget);
-    for (int j = 0; j < ncfg; ++j) {
-        EGLConfig config = configs[j];
-        EGLint format;
-        if (sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config,
-                                         LOCAL_EGL_NATIVE_VISUAL_ID, &format) &&
-            format == window->GetScreen()->GetSurfaceFormat())
-        {
-            *aConfig = config;
-            return true;
-        }
-    }
-#endif
-
     for (int j = 0; j < ncfg; ++j) {
         EGLConfig config = configs[j];
         EGLint r, g, b, a;
         if (sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config,
                                          LOCAL_EGL_RED_SIZE, &r) &&
             sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config,
                                          LOCAL_EGL_GREEN_SIZE, &g) &&
             sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config,
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -426,21 +426,16 @@ GLLibraryEGL::EnsureInitialized(bool for
           { "_Z35eglQueryStringImplementationANDROIDPvi", nullptr } },
         { nullptr, { nullptr } }
     };
 
     // Do not warn about the failure to load this - see bug 1092191
     Unused << GLLibraryLoader::LoadSymbols(mEGLLibrary, &optionalSymbols[0],
                                            nullptr, nullptr, false);
 
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
-    MOZ_RELEASE_ASSERT(mSymbols.fQueryStringImplementationANDROID,
-                       "GFX: Couldn't find eglQueryStringImplementationANDROID");
-#endif
-
     InitClientExtensions();
 
     const auto lookupFunction =
         (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress;
 
     // Client exts are ready. (But not display exts!)
     if (IsExtensionSupported(ANGLE_platform_angle_d3d)) {
         GLLibraryLoader::SymLoadStruct d3dSymbols[] = {
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -19,21 +19,16 @@
 #include "mozilla/layers/TextureClientSharedSurface.h"
 
 #ifdef XP_WIN
 #include "SharedSurfaceANGLE.h"         // for SurfaceFactory_ANGLEShareHandle
 #include "SharedSurfaceD3D11Interop.h"  // for SurfaceFactory_D3D11Interop
 #include "mozilla/gfx/DeviceManagerDx.h"
 #endif
 
-#ifdef MOZ_WIDGET_GONK
-#include "SharedSurfaceGralloc.h"
-#include "nsXULAppAPI.h"
-#endif
-
 #ifdef XP_MACOSX
 #include "SharedSurfaceIO.h"
 #endif
 
 #ifdef GL_PROVIDER_GLX
 #include "GLXLibrary.h"
 #include "SharedSurfaceGLX.h"
 #endif
@@ -84,18 +79,16 @@ GLScreenBuffer::CreateFactory(GLContext*
                               const layers::TextureFlags& flags)
 {
     UniquePtr<SurfaceFactory> factory = nullptr;
     if (!gfxPrefs::WebGLForceLayersReadback()) {
         switch (backend) {
             case mozilla::layers::LayersBackend::LAYERS_OPENGL: {
 #if defined(XP_MACOSX)
                 factory = SurfaceFactory_IOSurface::Create(gl, caps, ipcChannel, flags);
-#elif defined(MOZ_WIDGET_GONK)
-                factory = MakeUnique<SurfaceFactory_Gralloc>(gl, caps, ipcChannel, flags);
 #elif defined(GL_PROVIDER_GLX)
                 if (sGLXLibrary.UseTextureFromPixmap())
                   factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags);
 #elif defined(MOZ_WIDGET_UIKIT)
                 factory = MakeUnique<SurfaceFactory_GLTexture>(mGLContext, caps, ipcChannel, mFlags);
 #else
                 if (gl->GetContextType() == GLContextType::EGL) {
                     if (XRE_IsParentProcess()) {
deleted file mode 100644
--- a/gfx/gl/SharedSurfaceGralloc.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "mozilla/Preferences.h"
-#include "mozilla/UniquePtr.h"
-
-#include "SharedSurfaceGralloc.h"
-
-#include "GLContext.h"
-#include "SharedSurface.h"
-#include "GLLibraryEGL.h"
-#include "mozilla/layers/GrallocTextureClient.h"
-#include "mozilla/layers/ShadowLayers.h"
-
-#include "ui/GraphicBuffer.h"
-#include "../layers/ipc/ShadowLayers.h"
-#include "ScopedGLHelpers.h"
-
-#include "gfxPlatform.h"
-#include "gfxPrefs.h"
-
-#define DEBUG_GRALLOC
-#ifdef DEBUG_GRALLOC
-#define DEBUG_PRINT(...) do { printf_stderr(__VA_ARGS__); } while (0)
-#else
-#define DEBUG_PRINT(...) do { } while (0)
-#endif
-
-namespace mozilla {
-namespace gl {
-
-using namespace mozilla::layers;
-using namespace android;
-
-SurfaceFactory_Gralloc::SurfaceFactory_Gralloc(GLContext* prodGL, const SurfaceCaps& caps,
-                                               const RefPtr<layers::LayersIPCChannel>& allocator,
-                                               const layers::TextureFlags& flags)
-    : SurfaceFactory(SharedSurfaceType::Gralloc, prodGL, caps, allocator, flags)
-{
-    MOZ_ASSERT(mAllocator);
-}
-
-/*static*/ UniquePtr<SharedSurface_Gralloc>
-SharedSurface_Gralloc::Create(GLContext* prodGL,
-                              const GLFormats& formats,
-                              const gfx::IntSize& size,
-                              bool hasAlpha,
-                              layers::TextureFlags flags,
-                              LayersIPCChannel* allocator)
-{
-    GLLibraryEGL* egl = &sEGLLibrary;
-    MOZ_ASSERT(egl);
-
-    UniquePtr<SharedSurface_Gralloc> ret;
-
-    DEBUG_PRINT("SharedSurface_Gralloc::Create -------\n");
-
-    if (!HasExtensions(egl, prodGL))
-        return Move(ret);
-
-    gfxContentType type = hasAlpha ? gfxContentType::COLOR_ALPHA
-                                   : gfxContentType::COLOR;
-
-    GrallocTextureData* texData = GrallocTextureData::CreateForGLRendering(
-        size, gfxPlatform::GetPlatform()->Optimal2DFormatForContent(type), allocator
-    );
-
-    if (!texData) {
-        return Move(ret);
-    }
-
-    RefPtr<TextureClient> grallocTC = new TextureClient(texData, flags, allocator);
-
-    sp<GraphicBuffer> buffer = texData->GetGraphicBuffer();
-
-    EGLDisplay display = egl->Display();
-    EGLClientBuffer clientBuffer = buffer->getNativeBuffer();
-    EGLint attrs[] = {
-        LOCAL_EGL_NONE, LOCAL_EGL_NONE
-    };
-    EGLImage image = egl->fCreateImage(display,
-                                       EGL_NO_CONTEXT,
-                                       LOCAL_EGL_NATIVE_BUFFER_ANDROID,
-                                       clientBuffer, attrs);
-    if (!image) {
-        return Move(ret);
-    }
-
-    prodGL->MakeCurrent();
-    GLuint prodTex = 0;
-    prodGL->fGenTextures(1, &prodTex);
-    ScopedBindTexture autoTex(prodGL, prodTex);
-
-    prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
-    prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
-    prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
-    prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
-
-    prodGL->fEGLImageTargetTexture2D(LOCAL_GL_TEXTURE_2D, image);
-
-    egl->fDestroyImage(display, image);
-
-    ret.reset( new SharedSurface_Gralloc(prodGL, size, hasAlpha, egl,
-                                         allocator, grallocTC,
-                                         prodTex) );
-
-    DEBUG_PRINT("SharedSurface_Gralloc::Create: success -- surface %p,"
-                " GraphicBuffer %p.\n",
-                ret.get(), buffer.get());
-
-    return Move(ret);
-}
-
-
-SharedSurface_Gralloc::SharedSurface_Gralloc(GLContext* prodGL,
-                                             const gfx::IntSize& size,
-                                             bool hasAlpha,
-                                             GLLibraryEGL* egl,
-                                             layers::LayersIPCChannel* allocator,
-                                             layers::TextureClient* textureClient,
-                                             GLuint prodTex)
-    : SharedSurface(SharedSurfaceType::Gralloc,
-                    AttachmentType::GLTexture,
-                    prodGL,
-                    size,
-                    hasAlpha,
-                    true)
-    , mEGL(egl)
-    , mSync(0)
-    , mAllocator(allocator)
-    , mTextureClient(textureClient)
-    , mProdTex(prodTex)
-{
-}
-
-bool
-SharedSurface_Gralloc::HasExtensions(GLLibraryEGL* egl, GLContext* gl)
-{
-    return egl->HasKHRImageBase() &&
-           gl->IsExtensionSupported(GLContext::OES_EGL_image);
-}
-
-SharedSurface_Gralloc::~SharedSurface_Gralloc()
-{
-    DEBUG_PRINT("[SharedSurface_Gralloc %p] destroyed\n", this);
-
-    if (!mGL || !mGL->MakeCurrent())
-        return;
-
-    mGL->fDeleteTextures(1, &mProdTex);
-
-    if (mSync) {
-        MOZ_ALWAYS_TRUE( mEGL->fDestroySync(mEGL->Display(), mSync) );
-        mSync = 0;
-    }
-}
-
-void
-SharedSurface_Gralloc::ProducerReleaseImpl()
-{
-    if (mSync) {
-        MOZ_ALWAYS_TRUE( mEGL->fDestroySync(mEGL->Display(), mSync) );
-        mSync = 0;
-    }
-
-    bool disableSyncFence = false;
-    // Disable sync fence on AdrenoTM200.
-    // AdrenoTM200's sync fence does not work correctly. See Bug 1022205.
-    if (mGL->Renderer() == GLRenderer::AdrenoTM200) {
-        disableSyncFence = true;
-    }
-
-    // When Android native fences are available, try
-    // them first since they're more likely to work.
-    // Android native fences are also likely to perform better.
-    if (!disableSyncFence &&
-        mEGL->IsExtensionSupported(GLLibraryEGL::ANDROID_native_fence_sync))
-    {
-        mGL->MakeCurrent();
-        EGLSync sync = mEGL->fCreateSync(mEGL->Display(),
-                                         LOCAL_EGL_SYNC_NATIVE_FENCE_ANDROID,
-                                         nullptr);
-        if (sync) {
-            mGL->fFlush();
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-            int fenceFd = mEGL->fDupNativeFenceFDANDROID(mEGL->Display(), sync);
-            if (fenceFd != -1) {
-                mEGL->fDestroySync(mEGL->Display(), sync);
-                mTextureClient->SetAcquireFenceHandle(FenceHandle(new FenceHandle::FdObj(fenceFd)));
-            } else {
-                mSync = sync;
-            }
-#else
-            mSync = sync;
-#endif
-            return;
-        }
-    }
-
-    if (!disableSyncFence &&
-        mEGL->IsExtensionSupported(GLLibraryEGL::KHR_fence_sync))
-    {
-        mGL->MakeCurrent();
-        mSync = mEGL->fCreateSync(mEGL->Display(),
-                                  LOCAL_EGL_SYNC_FENCE,
-                                  nullptr);
-        if (mSync) {
-            mGL->fFlush();
-            return;
-        }
-    }
-
-    // We should be able to rely on genlock write locks/read locks.
-    // But they're broken on some configs, and even a glFinish doesn't
-    // work.  glReadPixels seems to, though.
-    if (gfxPrefs::GrallocFenceWithReadPixels()) {
-        mGL->MakeCurrent();
-        UniquePtr<char[]> buf = MakeUnique<char[]>(4);
-        mGL->fReadPixels(0, 0, 1, 1, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE, buf.get());
-    }
-}
-
-void
-SharedSurface_Gralloc::WaitForBufferOwnership()
-{
-    mTextureClient->WaitForBufferOwnership();
-}
-
-bool
-SharedSurface_Gralloc::ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor)
-{
-    mTextureClient->mWorkaroundAnnoyingSharedSurfaceOwnershipIssues = true;
-    return mTextureClient->ToSurfaceDescriptor(*out_descriptor);
-}
-
-bool
-SharedSurface_Gralloc::ReadbackBySharedHandle(gfx::DataSourceSurface* out_surface)
-{
-    MOZ_ASSERT(out_surface);
-    sp<GraphicBuffer> buffer = static_cast<GrallocTextureData*>(
-        mTextureClient->GetInternalData()
-    )->GetGraphicBuffer();
-
-    const uint8_t* grallocData = nullptr;
-    auto result = buffer->lock(
-        GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_NEVER,
-        const_cast<void**>(reinterpret_cast<const void**>(&grallocData))
-    );
-
-    if (result == BAD_VALUE) {
-        return false;
-    }
-
-    gfx::DataSourceSurface::ScopedMap map(out_surface, gfx::DataSourceSurface::WRITE);
-    if (!map.IsMapped()) {
-        buffer->unlock();
-        return false;
-    }
-
-    uint32_t stride = buffer->getStride() * android::bytesPerPixel(buffer->getPixelFormat());
-    uint32_t height = buffer->getHeight();
-    uint32_t width = buffer->getWidth();
-    for (uint32_t i = 0; i < height; i++) {
-        memcpy(map.GetData() + i * map.GetStride(),
-               grallocData + i * stride, width * 4);
-    }
-
-    buffer->unlock();
-
-    android::PixelFormat srcFormat = buffer->getPixelFormat();
-    MOZ_ASSERT(srcFormat == PIXEL_FORMAT_RGBA_8888 ||
-               srcFormat == PIXEL_FORMAT_BGRA_8888 ||
-               srcFormat == PIXEL_FORMAT_RGBX_8888);
-    bool isSrcRGB = srcFormat == PIXEL_FORMAT_RGBA_8888 ||
-                    srcFormat == PIXEL_FORMAT_RGBX_8888;
-
-    gfx::SurfaceFormat destFormat = out_surface->GetFormat();
-    MOZ_ASSERT(destFormat == gfx::SurfaceFormat::R8G8B8X8 ||
-               destFormat == gfx::SurfaceFormat::R8G8B8A8 ||
-               destFormat == gfx::SurfaceFormat::B8G8R8X8 ||
-               destFormat == gfx::SurfaceFormat::B8G8R8A8);
-    bool isDestRGB = destFormat == gfx::SurfaceFormat::R8G8B8X8 ||
-                     destFormat == gfx::SurfaceFormat::R8G8B8A8;
-
-    if (isSrcRGB != isDestRGB) {
-        SwapRAndBComponents(out_surface);
-    }
-    return true;
-}
-
-} // namespace gl
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/gl/SharedSurfaceGralloc.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef SHARED_SURFACE_GRALLOC_H_
-#define SHARED_SURFACE_GRALLOC_H_
-
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/LayersSurfaces.h"
-#include "SharedSurface.h"
-
-namespace mozilla {
-namespace layers {
-class LayersIPCChannel;
-class TextureClient;
-}
-
-namespace gl {
-class GLContext;
-class GLLibraryEGL;
-
-class SharedSurface_Gralloc
-    : public SharedSurface
-{
-public:
-    static UniquePtr<SharedSurface_Gralloc> Create(GLContext* prodGL,
-                                                   const GLFormats& formats,
-                                                   const gfx::IntSize& size,
-                                                   bool hasAlpha,
-                                                   layers::TextureFlags flags,
-                                                   layers::LayersIPCChannel* allocator);
-
-    static SharedSurface_Gralloc* Cast(SharedSurface* surf) {
-        MOZ_ASSERT(surf->mType == SharedSurfaceType::Gralloc);
-
-        return (SharedSurface_Gralloc*)surf;
-    }
-
-protected:
-    GLLibraryEGL* const mEGL;
-    EGLSync mSync;
-    RefPtr<layers::LayersIPCChannel> mAllocator;
-    RefPtr<layers::TextureClient> mTextureClient;
-    const GLuint mProdTex;
-
-    SharedSurface_Gralloc(GLContext* prodGL,
-                          const gfx::IntSize& size,
-                          bool hasAlpha,
-                          GLLibraryEGL* egl,
-                          layers::LayersIPCChannel* allocator,
-                          layers::TextureClient* textureClient,
-                          GLuint prodTex);
-
-    static bool HasExtensions(GLLibraryEGL* egl, GLContext* gl);
-
-public:
-    virtual ~SharedSurface_Gralloc();
-
-    virtual void ProducerAcquireImpl() override {}
-    virtual void ProducerReleaseImpl() override;
-
-    virtual void WaitForBufferOwnership() override;
-
-    virtual void LockProdImpl() override {}
-    virtual void UnlockProdImpl() override {}
-
-    virtual GLuint ProdTexture() override {
-        return mProdTex;
-    }
-
-    layers::TextureClient* GetTextureClient() {
-        return mTextureClient;
-    }
-
-    virtual bool ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor) override;
-
-    virtual bool ReadbackBySharedHandle(gfx::DataSourceSurface* out_surface) override;
-};
-
-class SurfaceFactory_Gralloc
-    : public SurfaceFactory
-{
-public:
-    SurfaceFactory_Gralloc(GLContext* prodGL, const SurfaceCaps& caps,
-                           const RefPtr<layers::LayersIPCChannel>& allocator,
-                           const layers::TextureFlags& flags);
-
-    virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) override {
-        bool hasAlpha = mReadCaps.alpha;
-
-        UniquePtr<SharedSurface> ret;
-        if (mAllocator) {
-            ret = SharedSurface_Gralloc::Create(mGL, mFormats, size, hasAlpha,
-                                                mFlags, mAllocator);
-        }
-        return Move(ret);
-    }
-};
-
-} /* namespace gl */
-} /* namespace mozilla */
-
-#endif /* SHARED_SURFACE_GRALLOC_H_ */
--- a/gfx/gl/moz.build
+++ b/gfx/gl/moz.build
@@ -14,18 +14,16 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'ui
     gl_provider = 'EAGL'
 elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
     if CONFIG['MOZ_EGL_XRENDER_COMPOSITE']:
         gl_provider = 'EGL'
     else:
         gl_provider = 'GLX'
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     gl_provider = 'EGL'
-elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    gl_provider = 'EGL'
 
 if CONFIG['MOZ_GL_PROVIDER']:
     gl_provider = CONFIG['MOZ_GL_PROVIDER']
 
 EXPORTS += [
     'AndroidSurfaceTexture.h',
     'DecomposeIntoNoRepeatTriangles.h',
     'EGLUtils.h',
@@ -79,22 +77,16 @@ if CONFIG['MOZ_ENABLE_SKIA_GPU']:
     EXPORTS += ['SkiaGLGlue.h']
     SOURCES += [
         'SkiaGLGlue.cpp',
     ]
     if CONFIG['CLANG_CXX']:
         # Suppress warnings from Skia header files.
         SOURCES['SkiaGLGlue.cpp'].flags += ['-Wno-implicit-fallthrough']
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    UNIFIED_SOURCES += ['SharedSurfaceGralloc.cpp']
-    EXPORTS += ['SharedSurfaceGralloc.h']
-    LOCAL_INCLUDES += ['/widget/gonk']
-    LOCAL_INCLUDES += ['%' + '%s/%s' % (CONFIG['ANDROID_SOURCE'], 'hardware/libhardware/include')]
-
 if gl_provider == 'CGL':
     # These files include Mac headers that are unfriendly to unified builds
     SOURCES += [
         "GLContextProviderCGL.mm",
     ]
     EXPORTS += [
         'GLContextCGL.h',
         'SharedSurfaceIO.h',
--- a/gfx/layers/Compositor.cpp
+++ b/gfx/layers/Compositor.cpp
@@ -9,23 +9,16 @@
 #include "mozilla/layers/Effects.h"     // for Effect, EffectChain, etc
 #include "mozilla/layers/TextureClient.h"
 #include "mozilla/layers/TextureHost.h"
 #include "mozilla/layers/CompositorThread.h"
 #include "mozilla/mozalloc.h"           // for operator delete, etc
 #include "gfx2DGlue.h"
 #include "nsAppRunner.h"
 
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-#include "libdisplay/GonkDisplay.h"     // for GonkDisplay
-#include <ui/Fence.h>
-#include "nsWindow.h"
-#include "nsScreenManagerGonk.h"
-#endif
-
 namespace mozilla {
 
 namespace layers {
 
 Compositor::Compositor(widget::CompositorWidget* aWidget,
                       CompositorBridgeParent* aParent)
   : mCompositorID(0)
   , mDiagnosticTypes(DiagnosticTypes::NO_DIAGNOSTIC)
@@ -602,53 +595,21 @@ Compositor::SetInvalid()
 }
 
 bool
 Compositor::IsValid() const
 {
   return !!mParent;
 }
 
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-void
-Compositor::SetDispAcquireFence(Layer* aLayer)
-{
-  // OpenGL does not provide ReleaseFence for rendering.
-  // Instead use DispAcquireFence as layer buffer's ReleaseFence
-  // to prevent flickering and tearing.
-  // DispAcquireFence is DisplaySurface's AcquireFence.
-  // AcquireFence will be signaled when a buffer's content is available.
-  // See Bug 974152.
-  if (!aLayer || !mWidget) {
-    return;
-  }
-  nsWindow* window = static_cast<nsWindow*>(mWidget->RealWidget());
-  RefPtr<FenceHandle::FdObj> fence = new FenceHandle::FdObj(
-      window->GetScreen()->GetPrevDispAcquireFd());
-  mReleaseFenceHandle.Merge(FenceHandle(fence));
-}
-
-FenceHandle
-Compositor::GetReleaseFence()
-{
-  if (!mReleaseFenceHandle.IsValid()) {
-    return FenceHandle();
-  }
-
-  RefPtr<FenceHandle::FdObj> fdObj = mReleaseFenceHandle.GetDupFdObj();
-  return FenceHandle(fdObj);
-}
-
-#else
 void
 Compositor::SetDispAcquireFence(Layer* aLayer)
 {
 }
 
 FenceHandle
 Compositor::GetReleaseFence()
 {
   return FenceHandle();
 }
-#endif
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -678,20 +678,16 @@ protected:
 
   RefPtr<gfx::DrawTarget> mTarget;
   gfx::IntRect mTargetBounds;
 
   widget::CompositorWidget* mWidget;
 
   bool mIsDestroyed;
 
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-  FenceHandle mReleaseFenceHandle;
-#endif
-
   gfx::Color mClearColor;
   gfx::Color mDefaultClearColor;
 
 private:
   static LayersBackend sBackend;
 
 };
 
deleted file mode 100644
--- a/gfx/layers/GrallocImages.cpp
+++ /dev/null
@@ -1,478 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "GrallocImages.h"
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for int8_t, uint8_t, uint32_t, etc
-#include "nsDebug.h"                    // for NS_WARNING, NS_PRECONDITION
-#include "mozilla/layers/ImageBridgeChild.h"
-#include "mozilla/layers/GrallocTextureClient.h"
-#include "gfx2DGlue.h"
-#include "YCbCrUtils.h"                 // for YCbCr conversions
-
-#include <ColorConverter.h>
-#include <OMX_IVCommon.h>
-
-
-using namespace mozilla::ipc;
-using namespace android;
-
-#define ALIGN(x, align) ((x + align - 1) & ~(align - 1))
-
-namespace mozilla {
-namespace layers {
-
-int32_t GrallocImage::sColorIdMap[] = {
-    HAL_PIXEL_FORMAT_YCbCr_420_P, OMX_COLOR_FormatYUV420Planar,
-    HAL_PIXEL_FORMAT_YCbCr_422_P, OMX_COLOR_FormatYUV422Planar,
-    HAL_PIXEL_FORMAT_YCbCr_420_SP, OMX_COLOR_FormatYUV420SemiPlanar,
-    HAL_PIXEL_FORMAT_YCrCb_420_SP, -1,
-    HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO, -1,
-    HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED, HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED,
-    HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS, HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS,
-    HAL_PIXEL_FORMAT_YV12, OMX_COLOR_FormatYUV420Planar,
-    HAL_PIXEL_FORMAT_RGBA_8888, -1,
-    0, 0
-};
-
-struct GraphicBufferAutoUnlock {
-  android::sp<GraphicBuffer> mGraphicBuffer;
-
-  GraphicBufferAutoUnlock(android::sp<GraphicBuffer>& aGraphicBuffer)
-    : mGraphicBuffer(aGraphicBuffer) { }
-
-  ~GraphicBufferAutoUnlock() { mGraphicBuffer->unlock(); }
-};
-
-GrallocImage::GrallocImage()
-  : RecyclingPlanarYCbCrImage(nullptr)
-{
-  mFormat = ImageFormat::GRALLOC_PLANAR_YCBCR;
-}
-
-GrallocImage::~GrallocImage()
-{
-}
-
-bool
-GrallocImage::SetData(const Data& aData)
-{
-  MOZ_ASSERT(!mTextureClient, "TextureClient is already set");
-  NS_PRECONDITION(aData.mYSize.width % 2 == 0, "Image should have even width");
-  NS_PRECONDITION(aData.mYSize.height % 2 == 0, "Image should have even height");
-  NS_PRECONDITION(aData.mYStride % 16 == 0, "Image should have stride of multiple of 16 pixels");
-
-  mData = aData;
-  mSize = aData.mPicSize;
-
-  if (gfxPlatform::GetPlatform()->IsInGonkEmulator()) {
-    // Emulator does not support HAL_PIXEL_FORMAT_YV12.
-    return false;
-  }
-
-  RefPtr<LayersIPCChannel> allocator = ImageBridgeChild::GetSingleton();
-  GrallocTextureData* texData = GrallocTextureData::Create(mData.mYSize, HAL_PIXEL_FORMAT_YV12,
-                                                           gfx::BackendType::NONE,
-                                                           GraphicBuffer::USAGE_SW_READ_OFTEN |
-                                                             GraphicBuffer::USAGE_SW_WRITE_OFTEN |
-                                                             GraphicBuffer::USAGE_HW_TEXTURE,
-                                                           allocator
-  );
-
-  if (!texData) {
-    return false;
-  }
-
-  mTextureClient = new TextureClient(texData, TextureFlags::DEFAULT, allocator);
-  sp<GraphicBuffer> graphicBuffer = texData->GetGraphicBuffer();
-
-  void* vaddr;
-  if (graphicBuffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
-                          &vaddr) != OK) {
-    return false;
-  }
-
-  uint8_t* yChannel = static_cast<uint8_t*>(vaddr);
-  gfx::IntSize ySize = aData.mYSize;
-  int32_t yStride = graphicBuffer->getStride();
-
-  uint8_t* vChannel = yChannel + (yStride * ySize.height);
-  gfx::IntSize uvSize = gfx::IntSize(ySize.width / 2,
-                                 ySize.height / 2);
-  // Align to 16 bytes boundary
-  int32_t uvStride = ((yStride / 2) + 15) & ~0x0F;
-  uint8_t* uChannel = vChannel + (uvStride * uvSize.height);
-
-  // Memory outside of the image width may not writable. If the stride
-  // equals to the image width then we can use only one copy.
-  if (yStride == mData.mYStride &&
-      yStride == ySize.width) {
-    memcpy(yChannel, mData.mYChannel, yStride * ySize.height);
-  } else {
-    for (int i = 0; i < ySize.height; i++) {
-      memcpy(yChannel + i * yStride,
-             mData.mYChannel + i * mData.mYStride,
-             ySize.width);
-    }
-  }
-  if (uvStride == mData.mCbCrStride &&
-      uvStride == uvSize.width) {
-    memcpy(uChannel, mData.mCbChannel, uvStride * uvSize.height);
-    memcpy(vChannel, mData.mCrChannel, uvStride * uvSize.height);
-  } else {
-    for (int i = 0; i < uvSize.height; i++) {
-      memcpy(uChannel + i * uvStride,
-             mData.mCbChannel + i * mData.mCbCrStride,
-             uvSize.width);
-      memcpy(vChannel + i * uvStride,
-             mData.mCrChannel + i * mData.mCbCrStride,
-             uvSize.width);
-    }
-  }
-  graphicBuffer->unlock();
-  // Initialze the channels' addresses.
-  // Do not cache the addresses when gralloc buffer is not locked.
-  // gralloc hal could map gralloc buffer only when the buffer is locked,
-  // though some gralloc hals implementation maps it when it is allocated.
-  mData.mYChannel     = nullptr;
-  mData.mCrChannel    = nullptr;
-  mData.mCbChannel    = nullptr;
-  return true;
-}
-
-void
-GrallocImage::AdoptData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize)
-{
-  mTextureClient = aGraphicBuffer;
-  mSize = aSize;
-}
-
-/**
- * Converts YVU420 semi planar frames to RGB565, possibly taking different
- * stride values.
- * Needed because the Android ColorConverter class assumes that the Y and UV
- * channels have equal stride.
- */
-static void
-ConvertYVU420SPToRGB565(void *aYData, uint32_t aYStride,
-                        void *aUData, void *aVData, uint32_t aUVStride,
-                        void *aOut,
-                        uint32_t aWidth, uint32_t aHeight)
-{
-  uint8_t *y = (uint8_t*)aYData;
-  bool isCbCr;
-  int8_t *uv;
-
-  if (aUData < aVData) {
-    // The color format is YCbCr
-    isCbCr = true;
-    uv = (int8_t*)aUData;
-  } else {
-    // The color format is YCrCb
-    isCbCr = false;
-    uv = (int8_t*)aVData;
-  }
-
-  uint16_t *rgb = (uint16_t*)aOut;
-
-  for (size_t i = 0; i < aHeight; i++) {
-    for (size_t j = 0; j < aWidth; j++) {
-      int8_t d, e;
-
-      if (isCbCr) {
-        d = uv[j & ~1] - 128;
-        e = uv[j | 1] - 128;
-      } else {
-        d = uv[j | 1] - 128;
-        e = uv[j & ~1] - 128;
-      }
-
-      // Constants taken from https://en.wikipedia.org/wiki/YUV
-      int32_t r = (298 * y[j] + 409 * e + 128) >> 11;
-      int32_t g = (298 * y[j] - 100 * d - 208 * e + 128) >> 10;
-      int32_t b = (298 * y[j] + 516 * d + 128) >> 11;
-
-      r = r > 0x1f ? 0x1f : r < 0 ? 0 : r;
-      g = g > 0x3f ? 0x3f : g < 0 ? 0 : g;
-      b = b > 0x1f ? 0x1f : b < 0 ? 0 : b;
-
-      *rgb++ = (uint16_t)(r << 11 | g << 5 | b);
-    }
-
-    y += aYStride;
-    if (i % 2) {
-      uv += aUVStride;
-    }
-  }
-}
-
-/**
- * Converts the format of vendor-specific YVU420(planar and semi-planar)
- * with the help of GraphicBuffer::lockYCbCr. In this way, we can convert
- * the YUV color format without awaring actual definition/enumeration
- * of vendor formats.
- */
-static status_t
-ConvertVendorYUVFormatToRGB565(android::sp<GraphicBuffer>& aBuffer,
-                               gfx::DataSourceSurface *aSurface,
-                               gfx::DataSourceSurface::MappedSurface *aMappedSurface)
-{
-  status_t rv = BAD_VALUE;
-
-#if ANDROID_VERSION >= 18
-  android_ycbcr ycbcr;
-
-  // Check if the vendor provides explicit addresses of Y/Cb/Cr buffer from lockYCbCr
-  rv = aBuffer->lockYCbCr(android::GraphicBuffer::USAGE_SW_READ_OFTEN, &ycbcr);
-
-  if (rv != OK) {
-    NS_WARNING("Couldn't lock graphic buffer using lockYCbCr()");
-    return rv;
-  }
-
-  GraphicBufferAutoUnlock unlock(aBuffer);
-
-  uint32_t width = aSurface->GetSize().width;
-  uint32_t height = aSurface->GetSize().height;
-
-  if (ycbcr.chroma_step == 2) {
-    // From the system/core/include/system/graphics.h
-    // @chroma_step is the distance in bytes from one chroma pixel value to
-    // the next.  This is 2 bytes for semiplanar (because chroma values are
-    // interleaved and each chroma value is one byte) and 1 for planar.
-    ConvertYVU420SPToRGB565(ycbcr.y, ycbcr.ystride,
-                            ycbcr.cb, ycbcr.cr, ycbcr.cstride,
-                            aMappedSurface->mData,
-                            width, height);
-  } else {
-    layers::PlanarYCbCrData ycbcrData;
-    ycbcrData.mYChannel     = static_cast<uint8_t*>(ycbcr.y);
-    ycbcrData.mYStride      = ycbcr.ystride;
-    ycbcrData.mYSize        = aSurface->GetSize();
-    ycbcrData.mCbChannel    = static_cast<uint8_t*>(ycbcr.cb);
-    ycbcrData.mCrChannel    = static_cast<uint8_t*>(ycbcr.cr);
-    ycbcrData.mCbCrStride   = ycbcr.cstride;
-    ycbcrData.mCbCrSize     = aSurface->GetSize() / 2;
-    ycbcrData.mPicSize      = aSurface->GetSize();
-
-    gfx::ConvertYCbCrToRGB(ycbcrData,
-                           aSurface->GetFormat(),
-                           aSurface->GetSize(),
-                           aMappedSurface->mData,
-                           aMappedSurface->mStride);
-  }
-#endif
-
-  return rv;
-}
-
-static status_t
-ConvertOmxYUVFormatToRGB565(android::sp<GraphicBuffer>& aBuffer,
-                            gfx::DataSourceSurface *aSurface,
-                            gfx::DataSourceSurface::MappedSurface *aMappedSurface,
-                            const layers::PlanarYCbCrData& aYcbcrData)
-{
-  uint32_t omxFormat =
-    GrallocImage::GetOmxFormat(aBuffer->getPixelFormat());
-  if (!omxFormat) {
-    NS_WARNING("Unknown color format");
-    return BAD_VALUE;
-  }
-
-  status_t rv;
-  uint8_t *buffer;
-
-  rv = aBuffer->lock(android::GraphicBuffer::USAGE_SW_READ_OFTEN,
-                     reinterpret_cast<void **>(&buffer));
-  if (rv != OK) {
-    NS_WARNING("Couldn't lock graphic buffer");
-    return BAD_VALUE;
-  }
-
-  GraphicBufferAutoUnlock unlock(aBuffer);
-
-  uint32_t format = aBuffer->getPixelFormat();
-  uint32_t width = aSurface->GetSize().width;
-  uint32_t height = aSurface->GetSize().height;
-  uint32_t stride = aBuffer->getStride();
-
-  if (format == GrallocImage::HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO) {
-    // The Adreno hardware decoder aligns image dimensions to a multiple of 32,
-    // so we have to account for that here
-    uint32_t alignedWidth = ALIGN(width, 32);
-    uint32_t alignedHeight = ALIGN(height, 32);
-    uint32_t uvOffset = ALIGN(alignedHeight * alignedWidth, 4096);
-    uint32_t uvStride = 2 * ALIGN(width / 2, 32);
-    ConvertYVU420SPToRGB565(buffer, alignedWidth,
-                            buffer + uvOffset + 1,
-                            buffer + uvOffset,
-                            uvStride,
-                            aMappedSurface->mData,
-                            width, height);
-    return OK;
-  }
-
-  if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP) {
-    uint32_t uvOffset = height * stride;
-    ConvertYVU420SPToRGB565(buffer, stride,
-                            buffer + uvOffset + 1,
-                            buffer + uvOffset,
-                            stride,
-                            aMappedSurface->mData,
-                            width, height);
-    return OK;
-  }
-
-  if (format == HAL_PIXEL_FORMAT_YV12) {
-    // Depend on platforms, it is possible for HW decoder to output YV12 format.
-    // It means the mData won't be configured during the SetData API because the
-    // yuv data has already stored in GraphicBuffer. Here we try to confgiure the
-    // mData if it doesn't contain valid configuration.
-    layers::PlanarYCbCrData ycbcrData = aYcbcrData;
-    if (!ycbcrData.mYChannel) {
-      ycbcrData.mYChannel     = buffer;
-      ycbcrData.mYSkip        = 0;
-      ycbcrData.mYStride      = aBuffer->getStride();
-      ycbcrData.mYSize        = aSurface->GetSize();
-      ycbcrData.mCbSkip       = 0;
-      ycbcrData.mCbCrSize     = aSurface->GetSize() / 2;
-      ycbcrData.mPicSize      = aSurface->GetSize();
-      ycbcrData.mCrChannel    = buffer + ycbcrData.mYStride * aBuffer->getHeight();
-      ycbcrData.mCrSkip       = 0;
-      // Align to 16 bytes boundary
-      ycbcrData.mCbCrStride   = ALIGN(ycbcrData.mYStride / 2, 16);
-      ycbcrData.mCbChannel    = ycbcrData.mCrChannel + (ycbcrData.mCbCrStride * aBuffer->getHeight() / 2);
-    } else {
-      // Update channels' address.
-      // Gralloc buffer could map gralloc buffer only when the buffer is locked.
-      ycbcrData.mYChannel     = buffer;
-      ycbcrData.mCrChannel    = buffer + ycbcrData.mYStride * aBuffer->getHeight();
-      ycbcrData.mCbChannel    = ycbcrData.mCrChannel + (ycbcrData.mCbCrStride * aBuffer->getHeight() / 2);
-    }
-    gfx::ConvertYCbCrToRGB(ycbcrData,
-                           aSurface->GetFormat(),
-                           aSurface->GetSize(),
-                           aMappedSurface->mData,
-                           aMappedSurface->mStride);
-    return OK;
-  }
-
-  if (format == HAL_PIXEL_FORMAT_RGBA_8888) {
-    uint32_t* src = (uint32_t*)(buffer);
-    uint16_t* dest = (uint16_t*)(aMappedSurface->mData);
-
-    // Convert RGBA8888 to RGB565
-    for (size_t i = 0; i < width * height; i++) {
-      uint32_t r = ((*src >> 0 ) & 0xFF);
-      uint32_t g = ((*src >> 8 ) & 0xFF);
-      uint32_t b = ((*src >> 16) & 0xFF);
-      *dest++ = ((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3) << 0);
-      src++;
-    }
-    return OK;
-  }
-
-  android::ColorConverter colorConverter((OMX_COLOR_FORMATTYPE)omxFormat,
-                                         OMX_COLOR_Format16bitRGB565);
-  if (!colorConverter.isValid()) {
-    NS_WARNING("Invalid color conversion");
-    return BAD_VALUE;
-  }
-
-  uint32_t pixelStride = aMappedSurface->mStride/gfx::BytesPerPixel(gfx::SurfaceFormat::R5G6B5_UINT16);
-  rv = colorConverter.convert(buffer, width, height,
-                              0, 0, width - 1, height - 1 /* source crop */,
-                              aMappedSurface->mData, pixelStride, height,
-                              0, 0, width - 1, height - 1 /* dest crop */);
-  if (rv) {
-    NS_WARNING("OMX color conversion failed");
-    return BAD_VALUE;
-  }
-
-  return OK;
-}
-
-already_AddRefed<gfx::DataSourceSurface>
-GetDataSourceSurfaceFrom(android::sp<android::GraphicBuffer>& aGraphicBuffer,
-                         gfx::IntSize aSize,
-                         const layers::PlanarYCbCrData& aYcbcrData)
-{
-  MOZ_ASSERT(aGraphicBuffer.get());
-
-  RefPtr<gfx::DataSourceSurface> surface =
-    gfx::Factory::CreateDataSourceSurface(aSize, gfx::SurfaceFormat::R5G6B5_UINT16);
-  if (NS_WARN_IF(!surface)) {
-    return nullptr;
-  }
-
-  gfx::DataSourceSurface::MappedSurface mappedSurface;
-  if (!surface->Map(gfx::DataSourceSurface::WRITE, &mappedSurface)) {
-    NS_WARNING("Could not map DataSourceSurface");
-    return nullptr;
-  }
-
-  int32_t rv;
-  rv = ConvertOmxYUVFormatToRGB565(aGraphicBuffer, surface, &mappedSurface, aYcbcrData);
-  if (rv == OK) {
-    surface->Unmap();
-    return surface.forget();
-  }
-
-  rv = ConvertVendorYUVFormatToRGB565(aGraphicBuffer, surface, &mappedSurface);
-  surface->Unmap();
-  if (rv != OK) {
-    NS_WARNING("Unknown color format");
-    return nullptr;
-  }
-
-  return surface.forget();
-}
-
-already_AddRefed<gfx::SourceSurface>
-GrallocImage::GetAsSourceSurface()
-{
-  if (!mTextureClient) {
-    return nullptr;
-  }
-
-  android::sp<GraphicBuffer> graphicBuffer = GetGraphicBuffer();
-
-  RefPtr<gfx::DataSourceSurface> surface =
-    GetDataSourceSurfaceFrom(graphicBuffer, mSize, mData);
-
-  return surface.forget();
-}
-
-android::sp<android::GraphicBuffer>
-GrallocImage::GetGraphicBuffer() const
-{
-  if (!mTextureClient) {
-    return nullptr;
-  }
-  return static_cast<GrallocTextureData*>(mTextureClient->GetInternalData())->GetGraphicBuffer();
-}
-
-void*
-GrallocImage::GetNativeBuffer()
-{
-  if (!mTextureClient) {
-    return nullptr;
-  }
-  android::sp<android::GraphicBuffer> graphicBuffer = GetGraphicBuffer();
-  if (!graphicBuffer.get()) {
-    return nullptr;
-  }
-  return graphicBuffer->getNativeBuffer();
-}
-
-TextureClient*
-GrallocImage::GetTextureClient(KnowsCompositor* aForwarder)
-{
-  return mTextureClient;
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/GrallocImages.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef GRALLOCIMAGES_H
-#define GRALLOCIMAGES_H
-
-#ifdef MOZ_WIDGET_GONK
-
-#include "ImageLayers.h"
-#include "ImageContainer.h"
-#include "mozilla/gfx/Point.h"
-#include "mozilla/layers/AtomicRefCountedWithFinalize.h"
-#include "mozilla/layers/FenceUtils.h"
-#include "mozilla/layers/LayersSurfaces.h"
-
-#include <ui/GraphicBuffer.h>
-
-namespace mozilla {
-namespace layers {
-
-class TextureClient;
-
-already_AddRefed<gfx::DataSourceSurface>
-GetDataSourceSurfaceFrom(android::sp<android::GraphicBuffer>& aGraphicBuffer,
-                         gfx::IntSize aSize,
-                         const layers::PlanarYCbCrData& aYcbcrData);
-
-/**
- * The YUV format supported by Android HAL
- *
- * 4:2:0 - CbCr width and height is half that of Y.
- *
- * This format assumes
- * - an even width
- * - an even height
- * - a horizontal stride multiple of 16 pixels
- * - a vertical stride equal to the height
- *
- * y_size = stride * height
- * c_size = ALIGN(stride/2, 16) * height/2
- * size = y_size + c_size * 2
- * cr_offset = y_size
- * cb_offset = y_size + c_size
- *
- * The Image that is rendered is the picture region defined by
- * mPicX, mPicY and mPicSize. The size of the rendered image is
- * mPicSize, not mYSize or mCbCrSize.
- */
-class GrallocImage : public RecyclingPlanarYCbCrImage
-{
-  typedef PlanarYCbCrData Data;
-  static int32_t sColorIdMap[];
-public:
-  GrallocImage();
-
-  virtual ~GrallocImage();
-
-  /**
-   * This makes a copy of the data buffers, in order to support functioning
-   * in all different layer managers.
-   */
-  virtual bool SetData(const Data& aData);
-
-  using RecyclingPlanarYCbCrImage::AdoptData;
-  /**
-   *  Share the SurfaceDescriptor without making the copy, in order
-   *  to support functioning in all different layer managers.
-   */
-  void AdoptData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize);
-
-  // From [android 4.0.4]/hardware/msm7k/libgralloc-qsd8k/gralloc_priv.h
-  enum {
-    /* OEM specific HAL formats */
-    HAL_PIXEL_FORMAT_YCbCr_422_P            = 0x102,
-    HAL_PIXEL_FORMAT_YCbCr_420_P            = 0x103,
-    HAL_PIXEL_FORMAT_YCbCr_420_SP           = 0x109,
-    HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO    = 0x10A,
-    HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED     = 0x7FA30C03,
-    HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS     = 0x7FA30C04,
-  };
-
-  enum {
-    GRALLOC_SW_UAGE = android::GraphicBuffer::USAGE_SOFTWARE_MASK,
-  };
-
-  virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
-
-  android::sp<android::GraphicBuffer> GetGraphicBuffer() const;
-
-  void* GetNativeBuffer();
-
-  virtual bool IsValid() { return !!mTextureClient; }
-
-  virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
-
-  virtual GrallocImage* AsGrallocImage() override
-  {
-    return this;
-  }
-
-  virtual uint8_t* GetBuffer()
-  {
-    return static_cast<uint8_t*>(GetNativeBuffer());
-  }
-
-  int GetUsage()
-  {
-    return (static_cast<ANativeWindowBuffer*>(GetNativeBuffer()))->usage;
-  }
-
-  static int GetOmxFormat(int aFormat)
-  {
-    uint32_t omxFormat = 0;
-
-    for (int i = 0; sColorIdMap[i]; i += 2) {
-      if (sColorIdMap[i] == aFormat) {
-        omxFormat = sColorIdMap[i + 1];
-        break;
-      }
-    }
-
-    return omxFormat;
-  }
-
-private:
-  RefPtr<TextureClient> mTextureClient;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif
-
-#endif /* GRALLOCIMAGES_H */
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -19,19 +19,16 @@
 #include "mozilla/layers/ImageContainerChild.h"
 #include "mozilla/layers/LayersMessages.h"
 #include "mozilla/layers/SharedPlanarYCbCrImage.h"
 #include "mozilla/layers/SharedRGBImage.h"
 #include "mozilla/layers/TextureClientRecycleAllocator.h"
 #include "mozilla/gfx/gfxVars.h"
 #include "nsISupportsUtils.h"           // for NS_IF_ADDREF
 #include "YCbCrUtils.h"                 // for YCbCr conversions
-#ifdef MOZ_WIDGET_GONK
-#include "GrallocImages.h"
-#endif
 #include "gfx2DGlue.h"
 #include "mozilla/gfx/2D.h"
 
 #ifdef XP_MACOSX
 #include "mozilla/gfx/QuartzSupport.h"
 #endif
 
 #ifdef XP_WIN
@@ -173,28 +170,16 @@ ImageContainer::CreateSharedRGBImage()
 {
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   if (!mImageClient || !mImageClient->AsImageClientSingle()) {
     return nullptr;
   }
   return new SharedRGBImage(mImageClient);
 }
 
-#ifdef MOZ_WIDGET_GONK
-RefPtr<OverlayImage>
-ImageContainer::CreateOverlayImage()
-{
-  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-  if (!mImageClient || !mImageClient->AsImageClientSingle()) {
-    return nullptr;
-  }
-  return new OverlayImage();
-}
-#endif
-
 void
 ImageContainer::SetCurrentImageInternal(const nsTArray<NonOwningImage>& aImages)
 {
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   mGenerationCounter = ++sGenerationCounter;
 
   if (!aImages.IsEmpty()) {
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -147,17 +147,16 @@ namespace layers {
 class ImageClient;
 class ImageCompositeNotification;
 class ImageContainerChild;
 class PImageContainerChild;
 class SharedPlanarYCbCrImage;
 class PlanarYCbCrImage;
 class TextureClient;
 class KnowsCompositor;
-class GrallocImage;
 class NVImage;
 
 struct ImageBackendData
 {
   virtual ~ImageBackendData() {}
 
 protected:
   ImageBackendData() {}
@@ -166,18 +165,16 @@ protected:
 /* Forward declarations for Image derivatives. */
 class GLImage;
 class EGLImageImage;
 class SharedRGBImage;
 #ifdef MOZ_WIDGET_ANDROID
 class SurfaceTextureImage;
 #elif defined(XP_MACOSX)
 class MacIOSurfaceImage;
-#elif defined(MOZ_WIDGET_GONK)
-class OverlayImage;
 #endif
 
 /**
  * A class representing a buffer of pixel data. The data can be in one
  * of various formats including YCbCr.
  * 
  * Create an image using an ImageContainer. Fill the image with data, and
  * then call ImageContainer::SetImage to display it. An image must not be
@@ -210,21 +207,16 @@ public:
   { return mBackendData[aBackend]; }
   void SetBackendData(LayersBackend aBackend, ImageBackendData* aData)
   { mBackendData[aBackend] = aData; }
 
   int32_t GetSerial() { return mSerial; }
 
   virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() = 0;
 
-  virtual GrallocImage* AsGrallocImage()
-  {
-    return nullptr;
-  }
-
   virtual bool IsValid() { return true; }
 
   virtual uint8_t* GetBuffer() { return nullptr; }
 
   /**
    * For use with the TextureForwarder only (so that the later can
    * synchronize the TextureClient with the TextureHost).
    */
@@ -380,20 +372,16 @@ public:
   typedef uint32_t FrameID;
   typedef uint32_t ProducerID;
 
   RefPtr<PlanarYCbCrImage> CreatePlanarYCbCrImage();
 
   // Factory methods for shared image types.
   RefPtr<SharedRGBImage> CreateSharedRGBImage();
 
-#ifdef MOZ_WIDGET_GONK
-  RefPtr<OverlayImage> CreateOverlayImage();
-#endif
-
   struct NonOwningImage {
     explicit NonOwningImage(Image* aImage = nullptr,
                             TimeStamp aTimeStamp = TimeStamp(),
                             FrameID aFrameID = 0,
                             ProducerID aProducerID = 0)
       : mImage(aImage), mTimeStamp(aTimeStamp), mFrameID(aFrameID),
         mProducerID(aProducerID) {}
     Image* mImage;
@@ -904,60 +892,12 @@ public:
 
 private:
   gfx::IntSize mSize;
   nsCountedRef<nsOwningThreadSourceSurfaceRef> mSourceSurface;
   nsDataHashtable<nsUint32HashKey, RefPtr<TextureClient> >  mTextureClients;
   TextureFlags mTextureFlags;
 };
 
-#ifdef MOZ_WIDGET_GONK
-class OverlayImage : public Image {
-  /**
-   * OverlayImage is a special Image type that does not hold any buffer.
-   * It only hold an Id as identifier to the real content of the Image.
-   * Therefore, OverlayImage must be handled by some specialized hardware(e.g. HWC) 
-   * to show its content.
-   */
-public:
-  struct Data {
-    int32_t mOverlayId;
-    gfx::IntSize mSize;
-  };
-
-  struct SidebandStreamData {
-    GonkNativeHandle mStream;
-    gfx::IntSize mSize;
-  };
-
-  OverlayImage() : Image(nullptr, ImageFormat::OVERLAY_IMAGE) { mOverlayId = INVALID_OVERLAY; }
-
-  void SetData(const Data& aData)
-  {
-    mOverlayId = aData.mOverlayId;
-    mSize = aData.mSize;
-    mSidebandStream = GonkNativeHandle();
-  }
-
-  void SetData(const SidebandStreamData& aData)
-  {
-    mSidebandStream = aData.mStream;
-    mSize = aData.mSize;
-    mOverlayId = INVALID_OVERLAY;
-  }
-
-  already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; } ;
-  int32_t GetOverlayId() { return mOverlayId; }
-  GonkNativeHandle& GetSidebandStream() { return mSidebandStream; }
-
-  gfx::IntSize GetSize() { return mSize; }
-
-private:
-  int32_t mOverlayId;
-  GonkNativeHandle mSidebandStream;
-  gfx::IntSize mSize;
-};
-#endif
-
 } // namespace layers
 } // namespace mozilla
 
 #endif
--- a/gfx/layers/LayerScope.cpp
+++ b/gfx/layers/LayerScope.cpp
@@ -456,111 +456,16 @@ public:
 
         return WriteToStream(packet);
     }
 
 protected:
     int64_t mFrameStamp;
 };
 
-#ifdef MOZ_WIDGET_GONK
-// B2G optimization.
-class DebugGLGraphicBuffer final: public DebugGLData {
-public:
-    DebugGLGraphicBuffer(void *layerRef,
-                         GLenum target,
-                         GLuint name,
-                         const LayerRenderState &aState,
-                         bool aIsMask,
-                         UniquePtr<Packet> aPacket)
-        : DebugGLData(Packet::TEXTURE),
-          mLayerRef(reinterpret_cast<uint64_t>(layerRef)),
-          mTarget(target),
-          mName(name),
-          mState(aState),
-          mIsMask(aIsMask),
-          mPacket(Move(aPacket))
-    {
-    }
-
-    virtual bool Write() override {
-        return WriteToStream(*mPacket);
-    }
-
-    bool TryPack(bool packData) {
-        android::sp<android::GraphicBuffer> buffer = mState.mSurface;
-        MOZ_ASSERT(buffer.get());
-
-        mPacket->set_type(mDataType);
-        TexturePacket* tp = mPacket->mutable_texture();
-        tp->set_layerref(mLayerRef);
-        tp->set_name(mName);
-        tp->set_target(mTarget);
-        tp->set_ismask(mIsMask);
-
-        int pFormat = buffer->getPixelFormat();
-        if (HAL_PIXEL_FORMAT_RGBA_8888 != pFormat &&
-            HAL_PIXEL_FORMAT_RGBX_8888 != pFormat) {
-            return false;
-        }
-
-        int32_t stride = buffer->getStride() * 4;
-        int32_t height = buffer->getHeight();
-        int32_t width = buffer->getWidth();
-        int32_t sourceSize = stride * height;
-        if (sourceSize <= 0) {
-            return false;
-        }
-
-        uint32_t dFormat = mState.FormatRBSwapped() ?
-                           LOCAL_GL_BGRA : LOCAL_GL_RGBA;
-        tp->set_dataformat(dFormat);
-        tp->set_dataformat((1 << 16 | tp->dataformat()));
-        tp->set_width(width);
-        tp->set_height(height);
-        tp->set_stride(stride);
-
-        if (packData) {
-            uint8_t* grallocData = nullptr;
-            if (BAD_VALUE == buffer->lock(GRALLOC_USAGE_SW_READ_OFTEN |
-                                           GRALLOC_USAGE_SW_WRITE_NEVER,
-                                           reinterpret_cast<void**>(&grallocData)))
-            {
-                return false;
-            }
-            // Do not return before buffer->unlock();
-            auto compressedData =
-                 MakeUnique<char[]>(LZ4::maxCompressedSize(sourceSize));
-            int compressedSize = LZ4::compress((char*)grallocData,
-                                               sourceSize,
-                                               compressedData.get());
-
-            if (compressedSize > 0) {
-                tp->set_data(compressedData.get(), compressedSize);
-            } else {
-                buffer->unlock();
-                return false;
-             }
-
-            buffer->unlock();
-        }
-
-        return true;
-    }
-
-private:
-    uint64_t mLayerRef;
-    GLenum mTarget;
-    GLuint mName;
-    const LayerRenderState &mState;
-    bool mIsMask;
-    UniquePtr<Packet> mPacket;
-};
-#endif
-
 class DebugGLTextureData final: public DebugGLData {
 public:
     DebugGLTextureData(GLContext* cx,
                        void* layerRef,
                        GLenum target,
                        GLuint name,
                        DataSourceSurface* img,
                        bool aIsMask,
@@ -942,23 +847,16 @@ private:
                           int aWidth,
                           int aHeight);
     static void SendTextureSource(GLContext* aGLContext,
                                   void* aLayerRef,
                                   TextureSourceOGL* aSource,
                                   bool aFlipY,
                                   bool aIsMask,
                                   UniquePtr<Packet> aPacket);
-#ifdef MOZ_WIDGET_GONK
-    static bool SendGraphicBuffer(GLContext* aGLContext,
-                                  void* aLayerRef,
-                                  TextureSourceOGL* aSource,
-                                  const TexturedEffect* aEffect,
-                                  bool aIsMask);
-#endif
     static void SetAndSendTexture(GLContext* aGLContext,
                                   void* aLayerRef,
                                   TextureSourceOGL* aSource,
                                   const TexturedEffect* aEffect);
     static void SendTexturedEffect(GLContext* aGLContext,
                                    void* aLayerRef,
                                    const TexturedEffect* aEffect);
     static void SendMaskEffect(GLContext* aGLContext,
@@ -1105,61 +1003,16 @@ SenderHelper::SendTextureSource(GLContex
         new DebugGLTextureData(aGLContext, aLayerRef, textureTarget,
                                texID, img, aIsMask, Move(aPacket)));
 
     sSentTextureIds.push_back(texID);
     gLayerScopeManager.CurrentSession().mTexIDs.push_back(texID);
 
 }
 
-#ifdef MOZ_WIDGET_GONK
-bool
-SenderHelper::SendGraphicBuffer(GLContext* aGLContext,
-                                void* aLayerRef,
-                                TextureSourceOGL* aSource,
-                                const TexturedEffect* aEffect,
-                                bool aIsMask) {
-    GLuint texID = GetTextureID(aGLContext, aSource);
-    if (HasTextureIdBeenSent(texID)) {
-        return false;
-    }
-    if (!aEffect->mState.mSurface.get()) {
-        return false;
-    }
-
-    // Expose packet creation here, so we could dump primary texture effect attributes.
-    auto packet = MakeUnique<layerscope::Packet>();
-    layerscope::TexturePacket* texturePacket = packet->mutable_texture();
-    texturePacket->set_mpremultiplied(aEffect->mPremultiplied);
-    DumpFilter(texturePacket, aEffect->mSamplingFilter);
-    DumpRect(texturePacket->mutable_mtexturecoords(), aEffect->mTextureCoords);
-
-    GLenum target = aSource->GetTextureTarget();
-    mozilla::UniquePtr<DebugGLGraphicBuffer> package =
-        MakeUnique<DebugGLGraphicBuffer>(aLayerRef, target, texID, aEffect->mState, aIsMask, Move(packet));
-
-    // The texure content in this TexureHost is not altered,
-    // we don't need to send it again.
-    bool changed = gLayerScopeManager.GetContentMonitor()->IsChangedOrNew(
-        aEffect->mState.mTexture);
-    if (!package->TryPack(changed)) {
-        return false;
-    }
-
-    // Transfer ownership to SocketManager.
-    gLayerScopeManager.GetSocketManager()->AppendDebugData(package.release());
-    sSentTextureIds.push_back(texID);
-
-    gLayerScopeManager.CurrentSession().mTexIDs.push_back(texID);
-
-    gLayerScopeManager.GetContentMonitor()->ClearChangedHost(aEffect->mState.mTexture);
-    return true;
-}
-#endif
-
 void
 SenderHelper::SetAndSendTexture(GLContext* aGLContext,
                                 void* aLayerRef,
                                 TextureSourceOGL* aSource,
                                 const TexturedEffect* aEffect)
 {
     // Expose packet creation here, so we could dump primary texture effect attributes.
     auto packet = MakeUnique<layerscope::Packet>();
@@ -1175,22 +1028,16 @@ SenderHelper::SendTexturedEffect(GLConte
                                  void* aLayerRef,
                                  const TexturedEffect* aEffect)
 {
     TextureSourceOGL* source = aEffect->mTexture->AsSourceOGL();
     if (!source) {
         return;
     }
 
-#ifdef MOZ_WIDGET_GONK
-    if (SendGraphicBuffer(aGLContext, aLayerRef, source, aEffect, false)) {
-        return;
-    }
-#endif
-
     // Fallback texture sending path.
     SetAndSendTexture(aGLContext, aLayerRef, source, aEffect);
 }
 
 void
 SenderHelper::SendMaskEffect(GLContext* aGLContext,
                                  void* aLayerRef,
                                  const EffectMask* aEffect)
--- a/gfx/layers/LayersLogging.cpp
+++ b/gfx/layers/LayersLogging.cpp
@@ -361,18 +361,16 @@ AppendToString(std::stringstream& aStrea
                const char* pfx, const char* sfx)
 {
   aStream << pfx;
   switch (format) {
   case ImageFormat::PLANAR_YCBCR:
     aStream << "ImageFormat::PLANAR_YCBCR"; break;
   case ImageFormat::GRALLOC_PLANAR_YCBCR:
     aStream << "ImageFormat::GRALLOC_PLANAR_YCBCR"; break;
-  case ImageFormat::GONK_CAMERA_IMAGE:
-    aStream << "ImageFormat::GONK_CAMERA_IMAGE"; break;
   case ImageFormat::SHARED_RGB:
     aStream << "ImageFormat::SHARED_RGB"; break;
   case ImageFormat::CAIRO_SURFACE:
     aStream << "ImageFormat::CAIRO_SURFACE"; break;
   case ImageFormat::MAC_IOSURFACE:
     aStream << "ImageFormat::MAC_IOSURFACE"; break;
   case ImageFormat::SURFACE_TEXTURE:
     aStream << "ImageFormat::SURFACE_TEXTURE"; break;
--- a/gfx/layers/LayersTypes.cpp
+++ b/gfx/layers/LayersTypes.cpp
@@ -1,58 +1,29 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "LayersTypes.h"
 
-#ifdef MOZ_WIDGET_GONK
-#include <ui/GraphicBuffer.h>
-#endif
-
 namespace mozilla {
 namespace layers {
 
 LayerRenderState::LayerRenderState()
   : mFlags(LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT)
   , mHasOwnOffset(false)
-#ifdef MOZ_WIDGET_GONK
-  , mSurface(nullptr)
-  , mOverlayId(INVALID_OVERLAY)
-  , mTexture(nullptr)
-#endif
 {
 }
 
 LayerRenderState::LayerRenderState(const LayerRenderState& aOther)
   : mFlags(aOther.mFlags)
   , mHasOwnOffset(aOther.mHasOwnOffset)
   , mOffset(aOther.mOffset)
-#ifdef MOZ_WIDGET_GONK
-  , mSurface(aOther.mSurface)
-  , mOverlayId(aOther.mOverlayId)
-  , mSize(aOther.mSize)
-  , mTexture(aOther.mTexture)
-#endif
 {
 }
 
 LayerRenderState::~LayerRenderState()
 {
 }
 
-#ifdef MOZ_WIDGET_GONK
-LayerRenderState::LayerRenderState(android::GraphicBuffer* aSurface,
-                                   const gfx::IntSize& aSize,
-                                   LayerRenderStateFlags aFlags,
-                                   TextureHost* aTexture)
-  : mFlags(aFlags)
-  , mHasOwnOffset(false)
-  , mSurface(aSurface)
-  , mOverlayId(INVALID_OVERLAY)
-  , mSize(aSize)
-  , mTexture(aTexture)
-{}
-#endif
-
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/LayersTypes.h
+++ b/gfx/layers/LayersTypes.h
@@ -3,21 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_LAYERSTYPES_H
 #define GFX_LAYERSTYPES_H
 
 #include <stdint.h>                     // for uint32_t
 
-#ifdef MOZ_WIDGET_GONK
-#include <utils/RefBase.h>
-#include "mozilla/layers/GonkNativeHandle.h"
-#endif
-
 #include "Units.h"
 #include "mozilla/gfx/Point.h"          // for IntPoint
 #include "mozilla/TypedEnumBits.h"
 #include "nsRegion.h"
 
 #include <stdio.h>            // FILE
 #include "mozilla/Logging.h"            // for PR_LOG
 
@@ -81,80 +76,37 @@ enum class LayerRenderStateFlags : int8_
   FORMAT_RB_SWAP = 1 << 2,
   // We record opaqueness here alongside the actual surface we're going to
   // render. This avoids confusion when a layer might return different kinds
   // of surfaces over time (e.g. video frames).
   OPAQUE = 1 << 3
 };
 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(LayerRenderStateFlags)
 
-// The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include
-// android::sp unless we have to.
 struct LayerRenderState {
   // Constructors and destructor are defined in LayersTypes.cpp so we don't
   // have to pull in a definition for GraphicBuffer.h here. In KK at least,
   // that results in nasty pollution such as libui's hardware.h #defining
   // 'version_major' and 'version_minor' which conflict with Theora's codec.c...
   LayerRenderState();
   LayerRenderState(const LayerRenderState& aOther);
   ~LayerRenderState();
 
-#ifdef MOZ_WIDGET_GONK
-  LayerRenderState(android::GraphicBuffer* aSurface,
-                   const gfx::IntSize& aSize,
-                   LayerRenderStateFlags aFlags,
-                   TextureHost* aTexture);
-
-  bool OriginBottomLeft() const
-  { return bool(mFlags & LayerRenderStateFlags::ORIGIN_BOTTOM_LEFT); }
-
-  bool BufferRotated() const
-  { return bool(mFlags & LayerRenderStateFlags::BUFFER_ROTATION); }
-
-  bool FormatRBSwapped() const
-  { return bool(mFlags & LayerRenderStateFlags::FORMAT_RB_SWAP); }
-
-  void SetOverlayId(const int32_t& aId)
-  { mOverlayId = aId; }
-
-  void SetSidebandStream(const GonkNativeHandle& aStream)
-  {
-    mSidebandStream = aStream;
-  }
-
-  android::GraphicBuffer* GetGrallocBuffer() const
-  { return mSurface.get(); }
-
-  const GonkNativeHandle& GetSidebandStream()
-  { return mSidebandStream; }
-#endif
-
   void SetOffset(const nsIntPoint& aOffset)
   {
     mOffset = aOffset;
     mHasOwnOffset = true;
   }
 
   // see LayerRenderStateFlags
   LayerRenderStateFlags mFlags;
   // true if mOffset is applicable
   bool mHasOwnOffset;
   // the location of the layer's origin on mSurface
   nsIntPoint mOffset;
-  // The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include
-  // android::sp unless we have to.
-#ifdef MOZ_WIDGET_GONK
-  // surface to render
-  android::sp<android::GraphicBuffer> mSurface;
-  int32_t mOverlayId;
-  // size of mSurface
-  gfx::IntSize mSize;
-  TextureHost* mTexture;
-  GonkNativeHandle mSidebandStream;
-#endif
 };
 
 enum class ScaleMode : int8_t {
   SCALE_NONE,
   STRETCH,
   SENTINEL
 // Unimplemented - PRESERVE_ASPECT_RATIO_CONTAIN
 };
--- a/gfx/layers/RotatedBuffer.cpp
+++ b/gfx/layers/RotatedBuffer.cpp
@@ -401,30 +401,16 @@ ComputeBufferRect(const IntRect& aReques
 {
   IntRect rect(aRequestedRect);
   // Set a minimum width to guarantee a minimum size of buffers we
   // allocate (and work around problems on some platforms with smaller
   // dimensions).  64 is the magic number needed to work around the
   // rendering glitch, and guarantees image rows can be SIMD'd for
   // even r5g6b5 surfaces pretty much everywhere.
   rect.width = std::max(aRequestedRect.width, 64);
-#ifdef MOZ_WIDGET_GONK
-  // Set a minumum height to guarantee a minumum height of buffers we
-  // allocate. Some GL implementations fail to render gralloc textures
-  // with a height 9px-16px. It happens on Adreno 200. Adreno 320 does not
-  // have this problem. 32 is choosed as alignment of gralloc buffers.
-  // See Bug 873937.
-  // Increase the height only when the requested height is more than 0.
-  // See Bug 895976.
-  // XXX it might be better to disable it on the gpu that does not have
-  // the height problem.
-  if (rect.height > 0) {
-    rect.height = std::max(aRequestedRect.height, 32);
-  }
-#endif
   return rect;
 }
 
 void
 RotatedContentBuffer::FlushBuffers()
 {
   if (mDTBuffer) {
     mDTBuffer->Flush();
@@ -475,17 +461,17 @@ RotatedContentBuffer::BeginPaint(Painted
         destBufferRect = neededRegion.GetBounds();
       }
     } else {
       // We won't be reusing the buffer.  Compute a new rect.
       destBufferRect = ComputeBufferRect(neededRegion.GetBounds());
     }
 
     if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
-#if defined(MOZ_GFX_OPTIMIZE_MOBILE) || defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_GFX_OPTIMIZE_MOBILE)
       mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
 #else
       if (!aLayer->GetParent() ||
           !aLayer->GetParent()->SupportsComponentAlphaChildren() ||
           !aLayer->AsShadowableLayer() ||
           !aLayer->AsShadowableLayer()->HasShadow()) {
         mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
       } else {
--- a/gfx/layers/TiledLayerBuffer.h
+++ b/gfx/layers/TiledLayerBuffer.h
@@ -17,20 +17,16 @@
 #include "mozilla/gfx/Logging.h"        // for gfxCriticalError
 #include "mozilla/layers/LayersTypes.h" // for TextureDumpMode
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsPoint.h"                    // for nsIntPoint
 #include "nsRect.h"                     // for mozilla::gfx::IntRect
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nsTArray.h"                   // for nsTArray
 
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-#include <ui/Fence.h>
-#endif
-
 namespace mozilla {
 
 struct TileUnit {};
 template<> struct IsPixel<TileUnit> : mozilla::TrueType {};
 
 namespace layers {
 
 // You can enable all the TILING_LOG print statements by
deleted file mode 100644
--- a/gfx/layers/basic/GrallocTextureHostBasic.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "GrallocTextureHostBasic.h"
-#include "GrallocImages.h"  // for GetDataSourceSurfaceFrom()
-#include "mozilla/layers/SharedBufferManagerParent.h"
-
-#if ANDROID_VERSION >= 17
-#include <ui/Fence.h>
-#endif
-
-namespace mozilla {
-namespace layers {
-
-static gfx::SurfaceFormat
-HalFormatToSurfaceFormat(int aHalFormat, TextureFlags aFlags)
-{
-  bool swapRB = bool(aFlags & TextureFlags::RB_SWAPPED);
-  switch (aHalFormat) {
-  case android::PIXEL_FORMAT_BGRA_8888:
-    return swapRB ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8A8;
-  case android::PIXEL_FORMAT_RGBA_8888:
-    return swapRB ? gfx::SurfaceFormat::B8G8R8A8 : gfx::SurfaceFormat::R8G8B8A8;
-  case android::PIXEL_FORMAT_RGBX_8888:
-    return swapRB ? gfx::SurfaceFormat::B8G8R8X8 : gfx::SurfaceFormat::R8G8B8X8;
-  case android::PIXEL_FORMAT_RGB_565:
-    return gfx::SurfaceFormat::R5G6B5_UINT16;
-  case HAL_PIXEL_FORMAT_YCbCr_422_SP:
-  case HAL_PIXEL_FORMAT_YCrCb_420_SP:
-  case HAL_PIXEL_FORMAT_YCbCr_422_I:
-  case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
-  case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
-  case HAL_PIXEL_FORMAT_YV12:
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-  case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
-#endif
-      // Needs convert to RGB565
-      return gfx::SurfaceFormat::R5G6B5_UINT16;
-  default:
-    if (aHalFormat >= 0x100 && aHalFormat <= 0x1FF) {
-      // Reserved range for HAL specific formats.
-      // Needs convert to RGB565
-      return gfx::SurfaceFormat::R5G6B5_UINT16;
-    } else {
-      MOZ_CRASH("GFX: Unhandled HAL pixel format");
-      return gfx::SurfaceFormat::UNKNOWN; // not reached
-    }
-  }
-}
-
-static bool
-NeedsConvertFromYUVtoRGB565(int aHalFormat)
-{
-  switch (aHalFormat) {
-  case android::PIXEL_FORMAT_BGRA_8888:
-  case android::PIXEL_FORMAT_RGBA_8888:
-  case android::PIXEL_FORMAT_RGBX_8888:
-  case android::PIXEL_FORMAT_RGB_565:
-    return false;
-  case HAL_PIXEL_FORMAT_YCbCr_422_SP:
-  case HAL_PIXEL_FORMAT_YCrCb_420_SP:
-  case HAL_PIXEL_FORMAT_YCbCr_422_I:
-  case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
-  case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
-  case HAL_PIXEL_FORMAT_YV12:
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-  case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
-#endif
-      return true;
-  default:
-    if (aHalFormat >= 0x100 && aHalFormat <= 0x1FF) {
-      // Reserved range for HAL specific formats.
-      return true;
-    } else {
-      MOZ_CRASH("GFX: Unhandled HAL pixel format YUV");
-      return false; // not reached
-    }
-  }
-}
-
-GrallocTextureHostBasic::GrallocTextureHostBasic(
-  TextureFlags aFlags,
-  const SurfaceDescriptorGralloc& aDescriptor)
-  : TextureHost(aFlags)
-  , mGrallocHandle(aDescriptor)
-  , mSize(0, 0)
-  , mCropSize(0, 0)
-  , mFormat(gfx::SurfaceFormat::UNKNOWN)
-  , mIsOpaque(aDescriptor.isOpaque())
-{
-  android::GraphicBuffer* grallocBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
-  MOZ_ASSERT(grallocBuffer);
-
-  if (grallocBuffer) {
-    mFormat =
-      HalFormatToSurfaceFormat(grallocBuffer->getPixelFormat(),
-                               aFlags & TextureFlags::RB_SWAPPED);
-    mSize = gfx::IntSize(grallocBuffer->getWidth(), grallocBuffer->getHeight());
-    mCropSize = mSize;
-  } else {
-    printf_stderr("gralloc buffer is nullptr\n");
-  }
-}
-
-bool
-GrallocTextureHostBasic::Lock()
-{
-  if (!mCompositor || !IsValid()) {
-    return false;
-  }
-
-  if (mTextureSource) {
-    return true;
-  }
-
-  android::sp<android::GraphicBuffer> graphicBuffer =
-    GetGraphicBufferFromDesc(mGrallocHandle);
-  MOZ_ASSERT(graphicBuffer.get());
-
-  RefPtr<gfx::DataSourceSurface> surf;
-  if (NeedsConvertFromYUVtoRGB565(graphicBuffer->getPixelFormat())) {
-    PlanarYCbCrData ycbcrData;
-    surf = GetDataSourceSurfaceFrom(graphicBuffer,
-                                    mCropSize,
-                                    ycbcrData);
-  } else {
-    uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN;
-    int32_t rv = graphicBuffer->lock(usage,
-                                     reinterpret_cast<void**>(&mMappedBuffer));
-    if (rv) {
-      mMappedBuffer = nullptr;
-      NS_WARNING("Couldn't lock graphic buffer");
-      return false;
-    }
-    surf = gfx::Factory::CreateWrappingDataSourceSurface(
-             mMappedBuffer,
-             graphicBuffer->getStride() * gfx::BytesPerPixel(mFormat),
-             mCropSize,
-             mFormat);
-  }
-  if (surf) {
-    mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
-    mTextureSource->Update(surf, nullptr);
-    return true;
-  }
-  mMappedBuffer = nullptr;
-  return false;
-}
-
-bool
-GrallocTextureHostBasic::IsValid() const
-{
-  android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
-  return graphicBuffer != nullptr;
-}
-
-bool
-GrallocTextureHostBasic::BindTextureSource(CompositableTextureSourceRef& aTexture)
-{
-  aTexture = mTextureSource;
-  return !!aTexture;
-}
-
-void
-GrallocTextureHostBasic::UnbindTextureSource()
-{
-  TextureHost::UnbindTextureSource();
-  ClearTextureSource();
-}
-
-void
-GrallocTextureHostBasic::ClearTextureSource()
-{
-  mTextureSource = nullptr;
-  if (mMappedBuffer) {
-    android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
-    MOZ_ASSERT(graphicBuffer);
-    mMappedBuffer = nullptr;
-    graphicBuffer->unlock();
-  }
-}
-
-void
-GrallocTextureHostBasic::SetCompositor(Compositor* aCompositor)
-{
-  BasicCompositor* compositor = AssertBasicCompositor(aCompositor);
-  if (!compositor) {
-    return;
-  }
-
-  mCompositor = compositor;
-  if (mTextureSource) {
-    mTextureSource->SetCompositor(compositor);
-  }
-}
-
-Compositor*
-GrallocTextureHostBasic::GetCompositor()
-{
-  return mCompositor;
-}
-
-gfx::SurfaceFormat
-GrallocTextureHostBasic::GetFormat() const {
-  return mFormat;
-}
-
-void
-GrallocTextureHostBasic::WaitAcquireFenceHandleSyncComplete()
-{
-  if (!mAcquireFenceHandle.IsValid()) {
-    return;
-  }
-
-#if ANDROID_VERSION >= 17
-  RefPtr<FenceHandle::FdObj> fdObj = mAcquireFenceHandle.GetAndResetFdObj();
-  android::sp<android::Fence> fence(
-    new android::Fence(fdObj->GetAndResetFd()));
-
-  // Wait fece complete with timeout.
-  // If a source of the fence becomes invalid because of error,
-  // fene complete is not signaled. See Bug 1061435.
-  int rv = fence->wait(400 /*400 msec*/);
-  if (rv != android::OK) {
-    NS_ERROR("failed to wait fence complete");
-  }
-#endif
-}
-
-void
-GrallocTextureHostBasic::SetCropRect(nsIntRect aCropRect)
-{
-  MOZ_ASSERT(aCropRect.TopLeft() == gfx::IntPoint(0, 0));
-  MOZ_ASSERT(!aCropRect.IsEmpty());
-  MOZ_ASSERT(aCropRect.width <= mSize.width);
-  MOZ_ASSERT(aCropRect.height <= mSize.height);
-
-  gfx::IntSize cropSize(aCropRect.width, aCropRect.height);
-  if (mCropSize == cropSize) {
-    return;
-  }
-
-  mCropSize = cropSize;
-  ClearTextureSource();
-}
-
-void
-GrallocTextureHostBasic::DeallocateSharedData()
-{
-  ClearTextureSource();
-
-  if (mGrallocHandle.buffer().type() != MaybeMagicGrallocBufferHandle::Tnull_t) {
-    MaybeMagicGrallocBufferHandle handle = mGrallocHandle.buffer();
-    base::ProcessId owner;
-    if (handle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef) {
-      owner = handle.get_GrallocBufferRef().mOwner;
-    }
-    else {
-      owner = handle.get_MagicGrallocBufferHandle().mRef.mOwner;
-    }
-
-    SharedBufferManagerParent::DropGrallocBuffer(owner, mGrallocHandle);
-  }
-}
-
-void
-GrallocTextureHostBasic::ForgetSharedData()
-{
-  ClearTextureSource();
-}
-
-void
-GrallocTextureHostBasic::DeallocateDeviceData()
-{
-  ClearTextureSource();
-}
-
-LayerRenderState
-GrallocTextureHostBasic::GetRenderState()
-{
-  android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
-
-  if (graphicBuffer) {
-    LayerRenderStateFlags flags = LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT;
-    if (mIsOpaque) {
-      flags |= LayerRenderStateFlags::OPAQUE;
-    }
-    if (mFlags & TextureFlags::ORIGIN_BOTTOM_LEFT) {
-      flags |= LayerRenderStateFlags::ORIGIN_BOTTOM_LEFT;
-    }
-    if (mFlags & TextureFlags::RB_SWAPPED) {
-      flags |= LayerRenderStateFlags::FORMAT_RB_SWAP;
-    }
-    return LayerRenderState(graphicBuffer,
-                            mCropSize,
-                            flags,
-                            this);
-  }
-
-  return LayerRenderState();
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/basic/GrallocTextureHostBasic.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef MOZILLA_GFX_GRALLOCTEXTUREHOST_BASIC_H
-#define MOZILLA_GFX_GRALLOCTEXTUREHOST_BASIC_H
-
-#include "mozilla/layers/BasicCompositor.h"
-#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
-#include "mozilla/layers/TextureHostBasic.h"
-
-namespace mozilla {
-namespace layers {
-
-class BasicCompositor;
-
-/**
- * A TextureHost for shared gralloc
- *
- * Most of the logic actually happens in GrallocTextureSourceBasic.
- */
-class GrallocTextureHostBasic : public TextureHost
-{
-public:
-  GrallocTextureHostBasic(TextureFlags aFlags,
-                          const SurfaceDescriptorGralloc& aDescriptor);
-
-  virtual void SetCompositor(Compositor* aCompositor) override;
-
-  virtual Compositor* GetCompositor() override;
-
-  virtual bool Lock() override;
-
-  virtual gfx::SurfaceFormat GetFormat() const override;
-
-  virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
-
-  virtual void UnbindTextureSource() override;
-
-  virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override
-  {
-    return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING)
-  }
-
-  virtual void WaitAcquireFenceHandleSyncComplete() override;
-
-  virtual gfx::IntSize GetSize() const override { return mCropSize; }
-
-  virtual void SetCropRect(nsIntRect aCropRect) override;
-
-  virtual void DeallocateSharedData() override;
-
-  virtual void ForgetSharedData() override;
-
-  virtual void DeallocateDeviceData() override;
-
-  virtual LayerRenderState GetRenderState() override;
-
-  bool IsValid() const;
-
-  void ClearTextureSource();
-
-#ifdef MOZ_LAYERS_HAVE_LOG
-  virtual const char* Name() override { return "GrallocTextureHostBasic"; }
-#endif
-
-protected:
-  RefPtr<BasicCompositor> mCompositor;
-  RefPtr<DataTextureSource> mTextureSource;
-  SurfaceDescriptorGralloc mGrallocHandle;
-  // gralloc buffer size.
-  gfx::IntSize mSize;
-  // Size reported by TextureClient, can be different in some cases (video?),
-  // used by LayerRenderState.
-  gfx::IntSize mCropSize;
-  gfx::SurfaceFormat mFormat;
-  bool mIsOpaque;
-  /**
-   * Points to a mapped gralloc buffer when TextureSource is valid.
-   */
-  uint8_t* mMappedBuffer;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif // MOZILLA_GFX_GRALLOCTEXTUREHOST_BASIC_H
--- a/gfx/layers/basic/TextureHostBasic.cpp
+++ b/gfx/layers/basic/TextureHostBasic.cpp
@@ -2,19 +2,16 @@
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "TextureHostBasic.h"
 #ifdef XP_MACOSX
 #include "MacIOSurfaceTextureHostBasic.h"
 #endif
-#ifdef MOZ_WIDGET_GONK
-#include "GrallocTextureHostBasic.h"
-#endif
 
 using namespace mozilla::gl;
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 already_AddRefed<TextureHost>
@@ -24,20 +21,13 @@ CreateTextureHostBasic(const SurfaceDesc
 {
 #ifdef XP_MACOSX
   if (aDesc.type() == SurfaceDescriptor::TSurfaceDescriptorMacIOSurface) {
     const SurfaceDescriptorMacIOSurface& desc =
       aDesc.get_SurfaceDescriptorMacIOSurface();
     return MakeAndAddRef<MacIOSurfaceTextureHostBasic>(aFlags, desc);
   }
 #endif
-#ifdef MOZ_WIDGET_GONK
-  if (aDesc.type() == SurfaceDescriptor::TSurfaceDescriptorGralloc) {
-      const SurfaceDescriptorGralloc& desc =
-        aDesc.get_SurfaceDescriptorGralloc();
-    return MakeAndAddRef<GrallocTextureHostBasic>(aFlags, desc);
-    }
-#endif
   return CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -12,17 +12,16 @@
 #include "gfx2DGlue.h"                  // for ImageFormatToSurfaceFormat
 #include "gfxPlatform.h"                // for gfxPlatform
 #include "GLReadTexImageHelper.h"
 #include "mozilla/gfx/BaseSize.h"       // for BaseSize
 #include "mozilla/layers/BufferTexture.h"
 #include "mozilla/layers/AsyncCanvasRenderer.h"
 #include "mozilla/layers/CompositableForwarder.h"
 #include "mozilla/layers/CompositorBridgeChild.h" // for CompositorBridgeChild
-#include "mozilla/layers/GrallocTextureClient.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/layers/TextureClient.h"  // for TextureClient, etc
 #include "mozilla/layers/TextureClientOGL.h"
 #include "nsDebug.h"                    // for printf_stderr, NS_ASSERTION
 #include "nsXULAppAPI.h"                // for XRE_GetProcessType, etc
 #include "TextureClientSharedSurface.h"
 
 using namespace mozilla::gfx;
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -233,17 +233,17 @@ ClientLayerManager::BeginTransactionWith
   // If we're drawing on behalf of a context with async pan/zoom
   // enabled, then the entire buffer of painted layers might be
   // composited (including resampling) asynchronously before we get
   // a chance to repaint, so we have to ensure that it's all valid
   // and not rotated.
   //
   // Desktop does not support async zoom yet, so we ignore this for those
   // platforms.
-#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_UIKIT)
+#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_UIKIT)
   if (mWidget && mWidget->GetOwningTabChild()) {
     mCompositorMightResample = AsyncPanZoomEnabled();
   }
 #endif
 
   // If we have a non-default target, we need to let our shadow manager draw
   // to it. This will happen at the end of the transaction.
   if (aTarget && XRE_IsParentProcess()) {
--- a/gfx/layers/client/ClientTiledPaintedLayer.cpp
+++ b/gfx/layers/client/ClientTiledPaintedLayer.cpp
@@ -145,17 +145,17 @@ ClientTiledPaintedLayer::BeginPaint()
   // with a displayport.
   LayerMetricsWrapper scrollAncestor;
   LayerMetricsWrapper displayPortAncestor;
   bool hasTransformAnimation;
   GetAncestorLayers(&scrollAncestor, &displayPortAncestor, &hasTransformAnimation);
 
   if (!displayPortAncestor || !scrollAncestor) {
     // No displayport or scroll ancestor, so we can't do progressive rendering.
-#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_WIDGET_ANDROID)
     // Both Android and b2g on phones are guaranteed to have a displayport set, so this
     // should never happen.
     NS_WARNING("Tiled PaintedLayer with no scrollable container ancestor");
 #endif
     return;
   }
 
   TILING_LOG("TILING %p: Found scrollAncestor %p, displayPortAncestor %p, transform %d\n", this,
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -28,20 +28,16 @@
 #include "mozilla/layers/TextureClient.h"  // for TextureClient, etc
 #include "mozilla/layers/TextureClientOGL.h"  // for SurfaceTextureClient
 #include "mozilla/mozalloc.h"           // for operator delete, etc
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_WARNING, NS_ASSERTION
 #include "nsISupportsImpl.h"            // for Image::Release, etc
 #include "nsRect.h"                     // for mozilla::gfx::IntRect
 
-#ifdef MOZ_WIDGET_GONK
-#include "GrallocImages.h"
-#endif
-
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 
 /* static */ already_AddRefed<ImageClient>
 ImageClient::CreateImageClient(CompositableType aCompositableHostType,
                                CompositableForwarder* aForwarder,
@@ -217,38 +213,16 @@ ImageClientSingle::UpdateImage(ImageCont
   }
 
   nsTArray<Buffer> newBuffers;
   AutoTArray<CompositableForwarder::TimedTextureClient,4> textures;
 
   for (auto& img : images) {
     Image* image = img.mImage;
 
-#ifdef MOZ_WIDGET_GONK
-    if (image->GetFormat() == ImageFormat::OVERLAY_IMAGE) {
-      OverlayImage* overlayImage = static_cast<OverlayImage*>(image);
-      OverlaySource source;
-      if (overlayImage->GetSidebandStream().IsValid()) {
-        // Duplicate GonkNativeHandle::NhObj for ipc,
-        // since ParamTraits<GonkNativeHandle>::Write() absorbs native_handle_t.
-        RefPtr<GonkNativeHandle::NhObj> nhObj = overlayImage->GetSidebandStream().GetDupNhObj();
-        GonkNativeHandle handle(nhObj);
-        if (!handle.IsValid()) {
-          return false;
-        }
-        source.handle() = OverlayHandle(handle);
-      } else {
-        source.handle() = OverlayHandle(overlayImage->GetOverlayId());
-      }
-      source.size() = overlayImage->GetSize();
-      GetForwarder()->UseOverlaySource(this, source, image->GetPictureRect());
-      continue;
-    }
-#endif
-
     RefPtr<TextureClient> texture = image->GetTextureClient(GetForwarder());
     const bool hasTextureClient = !!texture;
 
     for (int32_t i = mBuffers.Length() - 1; i >= 0; --i) {
       if (mBuffers[i].mImageSerial == image->GetSerial()) {
         if (hasTextureClient) {
           MOZ_ASSERT(image->GetTextureClient(GetForwarder()) == mBuffers[i].mTextureClient);
         } else {
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -48,21 +48,16 @@
 #include "GLXLibrary.h"
 #endif
 #endif
 
 #ifdef XP_MACOSX
 #include "mozilla/layers/MacIOSurfaceTextureClientOGL.h"
 #endif
 
-#ifdef MOZ_WIDGET_GONK
-#include <cutils/properties.h>
-#include "mozilla/layers/GrallocTextureClient.h"
-#endif
-
 #if 0
 #define RECYCLE_LOG(...) printf_stderr(__VA_ARGS__)
 #else
 #define RECYCLE_LOG(...) do { } while (0)
 #endif
 
 namespace mozilla {
 namespace layers {
@@ -721,23 +716,16 @@ TextureClient::ToSurfaceDescriptor(Surfa
 }
 
 void
 TextureClient::WaitForBufferOwnership(bool aWaitReleaseFence)
 {
   if (mFenceHandleWaiter) {
     mFenceHandleWaiter->WaitComplete();
   }
-
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION < 21
-  if (aWaitReleaseFence && mReleaseFenceHandle.IsValid()) {
-    mData->WaitForFence(&mReleaseFenceHandle);
-    mReleaseFenceHandle = FenceHandle();
-  }
-#endif
 }
 
 // static
 PTextureChild*
 TextureClient::CreateIPDLActor()
 {
   TextureChild* c = new TextureChild();
   c->AddIPDLReference();
@@ -1126,23 +1114,16 @@ TextureClient::CreateForDrawing(TextureF
       aFormat != SurfaceFormat::A8 &&
       gl::sGLXLibrary.UseTextureFromPixmap())
   {
     data = X11TextureData::Create(aSize, aFormat, aTextureFlags, aAllocator);
   }
 #endif
 #endif
 
-#ifdef MOZ_WIDGET_GONK
-  if (!data && aSize.width <= aMaxTextureSize && aSize.height <= aMaxTextureSize) {
-    data = GrallocTextureData::CreateForDrawing(aSize, aFormat, moz2DBackend,
-                                                aAllocator);
-  }
-#endif
-
 #ifdef XP_MACOSX
   if (!data && gfxPrefs::UseIOSurfaceTextures()) {
     data = MacIOSurfaceTextureData::Create(aSize, aFormat, moz2DBackend);
   }
 #endif
 
   if (data) {
     return MakeAndAddRef<TextureClient>(data, aTextureFlags, aAllocator);
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -37,27 +37,22 @@ class gfxImageSurface;
 namespace mozilla {
 
 // When defined, we track which pool the tile came from and test for
 // any inconsistencies.  This can be defined in release build as well.
 #ifdef DEBUG
 #define GFX_DEBUG_TRACK_CLIENTS_IN_POOL 1
 #endif
 
-namespace gl {
-class SharedSurface_Gralloc;
-}
-
 namespace layers {
 
 class AsyncTransactionWaiter;
 class BufferTextureData;
 class CompositableForwarder;
 class KnowsCompositor;
-class GrallocTextureData;
 class LayersIPCChannel;
 class CompositableClient;
 struct PlanarYCbCrData;
 class Image;
 class PTextureChild;
 class TextureChild;
 class TextureData;
 struct RawTextureBuffer;
@@ -301,18 +296,16 @@ public:
   virtual TextureFlags GetTextureFlags() const { return TextureFlags::NO_FLAGS; }
 
 #ifdef XP_WIN
   virtual D3D11TextureData* AsD3D11TextureData() {
     return nullptr;
   }
 #endif
 
-  virtual GrallocTextureData* AsGrallocTextureData() { return nullptr; }
-
   virtual BufferTextureData* AsBufferTextureData() { return nullptr; }
 };
 
 /**
  * TextureClient is a thin abstraction over texture data that need to be shared
  * between the content process and the compositor process. It is the
  * content-side half of a TextureClient/TextureHost pair. A corresponding
  * TextureHost lives on the compositor-side.
@@ -647,24 +640,17 @@ public:
   /// If you add new code that uses this method, you are probably doing something wrong.
   TextureData* GetInternalData() { return mData; }
   const TextureData* GetInternalData() const { return mData; }
 
   uint64_t GetSerial() const { return mSerial; }
 
   bool NeedsFenceHandle()
   {
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-    if (!mData) {
-      return false;
-    }
-    return !!mData->AsGrallocTextureData();
-#else
     return false;
-#endif
   }
 
   void WaitFenceHandleOnImageBridge(Mutex& aMutex);
   void ClearWaitFenceHandleOnImageBridge(Mutex& aMutex);
   void CancelWaitFenceHandleOnImageBridge();
 
   void CancelWaitForRecycle();
 
@@ -726,17 +712,16 @@ private:
    * texture's reference count reaches 0 (could be any thread).
    *
    * Here goes the shut-down code that uses virtual methods.
    * Must only be called by Release().
    */
   void Finalize() {}
 
   friend class AtomicRefCountedWithFinalize<TextureClient>;
-  friend class gl::SharedSurface_Gralloc;
 protected:
   /**
    * Should only be called *once* per texture, in TextureClient::InitIPDLActor.
    * Some texture implementations rely on the fact that the descriptor will be
    * deserialized.
    * Calling ToSurfaceDescriptor again after it has already returned true,
    * or never constructing a TextureHost with aDescriptor may result in a memory
    * leak (see TextureClientD3D9 for example).
--- a/gfx/layers/client/TextureClientSharedSurface.cpp
+++ b/gfx/layers/client/TextureClientSharedSurface.cpp
@@ -8,21 +8,16 @@
 #include "GLContext.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/Logging.h"        // for gfxDebug
 #include "mozilla/layers/ISurfaceAllocator.h"
 #include "mozilla/Unused.h"
 #include "nsThreadUtils.h"
 #include "SharedSurface.h"
 
-#ifdef MOZ_WIDGET_GONK
-#include "mozilla/layers/GrallocTextureClient.h"
-#include "SharedSurfaceGralloc.h"
-#endif
-
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
 
 SharedSurfaceTextureData::SharedSurfaceTextureData(UniquePtr<gl::SharedSurface> surf)
   : mSurf(Move(surf))
@@ -68,77 +63,16 @@ SharedSurfaceTextureClient::Create(Uniqu
   if (!surf) {
     return nullptr;
   }
   TextureFlags flags = aFlags | TextureFlags::RECYCLE | surf->GetTextureFlags();
   SharedSurfaceTextureData* data = new SharedSurfaceTextureData(Move(surf));
   return MakeAndAddRef<SharedSurfaceTextureClient>(data, flags, aAllocator);
 }
 
-void
-SharedSurfaceTextureClient::SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle)
-{
-#ifdef MOZ_WIDGET_GONK
-  gl::SharedSurface_Gralloc* surf = nullptr;
-  if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
-    surf = gl::SharedSurface_Gralloc::Cast(Surf());
-  }
-  if (surf && surf->GetTextureClient()) {
-    surf->GetTextureClient()->SetReleaseFenceHandle(aReleaseFenceHandle);
-    return;
-  }
-#endif
-  TextureClient::SetReleaseFenceHandle(aReleaseFenceHandle);
-}
-
-FenceHandle
-SharedSurfaceTextureClient::GetAndResetReleaseFenceHandle()
-{
-#ifdef MOZ_WIDGET_GONK
-  gl::SharedSurface_Gralloc* surf = nullptr;
-  if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
-    surf = gl::SharedSurface_Gralloc::Cast(Surf());
-  }
-  if (surf && surf->GetTextureClient()) {
-    return surf->GetTextureClient()->GetAndResetReleaseFenceHandle();
-  }
-#endif
-  return TextureClient::GetAndResetReleaseFenceHandle();
-}
-
-void
-SharedSurfaceTextureClient::SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle)
-{
-#ifdef MOZ_WIDGET_GONK
-  gl::SharedSurface_Gralloc* surf = nullptr;
-  if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
-    surf = gl::SharedSurface_Gralloc::Cast(Surf());
-  }
-  if (surf && surf->GetTextureClient()) {
-    return surf->GetTextureClient()->SetAcquireFenceHandle(aAcquireFenceHandle);
-  }
-#endif
-  TextureClient::SetAcquireFenceHandle(aAcquireFenceHandle);
-}
-
-const FenceHandle&
-SharedSurfaceTextureClient::GetAcquireFenceHandle() const
-{
-#ifdef MOZ_WIDGET_GONK
-  gl::SharedSurface_Gralloc* surf = nullptr;
-  if (Surf()->mType == gl::SharedSurfaceType::Gralloc) {
-    surf = gl::SharedSurface_Gralloc::Cast(Surf());
-  }
-  if (surf && surf->GetTextureClient()) {
-    return surf->GetTextureClient()->GetAcquireFenceHandle();
-  }
-#endif
-  return TextureClient::GetAcquireFenceHandle();
-}
-
 SharedSurfaceTextureClient::~SharedSurfaceTextureClient()
 {
   // XXX - Things break when using the proper destruction handshake with
   // SharedSurfaceTextureData because the TextureData outlives its gl
   // context. Having a strong reference to the gl context creates a cycle.
   // This needs to be fixed in a better way, though, because deleting
   // the TextureData here can race with the compositor and cause flashing.
   TextureData* data = mData;
--- a/gfx/layers/client/TextureClientSharedSurface.h
+++ b/gfx/layers/client/TextureClientSharedSurface.h
@@ -61,24 +61,16 @@ public:
                              LayersIPCChannel* aAllocator);
 
   ~SharedSurfaceTextureClient();
 
   static already_AddRefed<SharedSurfaceTextureClient>
   Create(UniquePtr<gl::SharedSurface> surf, gl::SurfaceFactory* factory,
          LayersIPCChannel* aAllocator, TextureFlags aFlags);
 
-  virtual void SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle) override;
-
-  virtual FenceHandle GetAndResetReleaseFenceHandle() override;
-
-  virtual void SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle) override;
-
-  virtual const FenceHandle& GetAcquireFenceHandle() const override;
-
   gl::SharedSurface* Surf() const {
     return static_cast<const SharedSurfaceTextureData*>(GetInternalData())->Surf();
   }
 };
 
 } // namespace layers
 } // namespace mozilla
 
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -303,28 +303,28 @@ gfxContentType
 ClientTiledLayerBuffer::GetContentType(SurfaceMode* aMode) const
 {
   gfxContentType content =
     mPaintedLayer.CanUseOpaqueSurface() ? gfxContentType::COLOR :
                                           gfxContentType::COLOR_ALPHA;
   SurfaceMode mode = mPaintedLayer.GetSurfaceMode();
 
   if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
-#if defined(MOZ_GFX_OPTIMIZE_MOBILE) || defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_GFX_OPTIMIZE_MOBILE)
     mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
 #else
     if (!mPaintedLayer.GetParent() ||
         !mPaintedLayer.GetParent()->SupportsComponentAlphaChildren()) {
       mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
     } else {
       content = gfxContentType::COLOR;
     }
 #endif
   } else if (mode == SurfaceMode::SURFACE_OPAQUE) {
-#if defined(MOZ_GFX_OPTIMIZE_MOBILE) || defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_GFX_OPTIMIZE_MOBILE)
     if (IsLowPrecision()) {
       // If we're in low-res mode, drawing can sample from outside the visible
       // region. Make sure that we only sample transparency if that happens.
       mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA;
       content = gfxContentType::COLOR_ALPHA;
     }
 #else
     if (mPaintedLayer.MayResample()) {
--- a/gfx/layers/composite/ImageHost.cpp
+++ b/gfx/layers/composite/ImageHost.cpp
@@ -698,25 +698,16 @@ ImageHostOverlay::Composite(Compositor* 
   aCompositor->DrawDiagnostics(DiagnosticFlags::IMAGE | DiagnosticFlags::BIGIMAGE,
                                rect, aClipRect, aTransform, aFlashCounter);
 }
 
 LayerRenderState
 ImageHostOverlay::GetRenderState()
 {
   LayerRenderState state;
-#ifdef MOZ_WIDGET_GONK
-  if (mOverlay.handle().type() == OverlayHandle::Tint32_t) {
-    state.SetOverlayId(mOverlay.handle().get_int32_t());
-  } else if (mOverlay.handle().type() == OverlayHandle::TGonkNativeHandle) {
-    state.SetSidebandStream(mOverlay.handle().get_GonkNativeHandle());
-  }
-  state.mSize.width = mPictureRect.Width();
-  state.mSize.height = mPictureRect.Height();
-#endif
   return state;
 }
 
 void
 ImageHostOverlay::UseOverlaySource(OverlaySource aOverlay,
                                    const nsIntRect& aPictureRect)
 {
   mOverlay = aOverlay;
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -53,26 +53,22 @@
 #include "nsIWidget.h"                  // for nsIWidget
 #include "nsPoint.h"                    // for nsIntPoint
 #include "nsRect.h"                     // for mozilla::gfx::IntRect
 #include "nsRegion.h"                   // for nsIntRegion, etc
 #ifdef MOZ_WIDGET_ANDROID
 #include <android/log.h>
 #include <android/native_window.h>
 #endif
-#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_WIDGET_ANDROID)
 #include "opengl/CompositorOGL.h"
 #include "GLContextEGL.h"
 #include "GLContextProvider.h"
 #include "ScopedGLHelpers.h"
 #endif
-#ifdef MOZ_WIDGET_GONK
-#include "nsScreenManagerGonk.h"
-#include "nsWindow.h"
-#endif
 #include "GeckoProfiler.h"
 #include "TextRenderer.h"               // for TextRenderer
 #include "mozilla/layers/CompositorBridgeParent.h"
 #include "TreeTraversal.h"              // for ForEachNode
 
 class gfxContext;
 
 namespace mozilla {
@@ -476,17 +472,17 @@ LayerManagerComposite::UpdateAndRender()
 
   if (!didEffectiveTransforms) {
     // The results of our drawing always go directly into a pixel buffer,
     // so we don't need to pass any global transform here.
     mRoot->ComputeEffectiveTransforms(gfx::Matrix4x4());
   }
 
   Render(invalid, opaque);
-#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_WIDGET_ANDROID)
   RenderToPresentationSurface();
 #endif
   mGeometryChanged = false;
   mWindowOverlayChanged = false;
 
   // Update cached layer tree information.
   mClonedLayerTreeProperties = LayerProperties::CloneFrom(GetRoot());
 }
@@ -1001,17 +997,17 @@ LayerManagerComposite::Render(const nsIn
     composer2D->Render(mCompositor->GetWidget()->RealWidget());
   }
 
   mCompositor->GetWidget()->PostRender(this);
 
   RecordFrame();
 }
 
-#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_WIDGET_ANDROID)
 class ScopedCompositorProjMatrix {
 public:
   ScopedCompositorProjMatrix(CompositorOGL* aCompositor, const Matrix4x4& aProjMatrix):
     mCompositor(aCompositor),
     mOriginalProjMatrix(mCompositor->GetProjMatrix())
   {
     mCompositor->SetProjMatrix(aProjMatrix);
   }
@@ -1108,50 +1104,16 @@ LayerManagerComposite::RenderToPresentat
 
   if (!egl) {
     return;
   }
 
   const IntSize windowSize(ANativeWindow_getWidth(window),
                            ANativeWindow_getHeight(window));
 
-#elif defined(MOZ_WIDGET_GONK)
-  CompositorOGL* compositor = mCompositor->AsCompositorOGL();
-  nsScreenGonk* screen = static_cast<nsWindow*>(mCompositor->GetWidget()->RealWidget())->GetScreen();
-  if (!screen->IsPrimaryScreen()) {
-    // Only primary screen support mirroring
-    return;
-  }
-
-  nsWindow* mirrorScreenWidget = screen->GetMirroringWidget();
-  if (!mirrorScreenWidget) {
-    // No mirroring
-    return;
-  }
-
-  nsScreenGonk* mirrorScreen = mirrorScreenWidget->GetScreen();
-  if (!mirrorScreen->GetTopWindows().IsEmpty()) {
-    return;
-  }
-
-  EGLSurface surface = mirrorScreen->GetEGLSurface();
-  if (surface == LOCAL_EGL_NO_SURFACE) {
-    // Create GLContext
-    RefPtr<GLContext> gl = gl::GLContextProvider::CreateForWindow(mirrorScreenWidget, false);
-    mirrorScreenWidget->SetNativeData(NS_NATIVE_OPENGL_CONTEXT,
-                                      reinterpret_cast<uintptr_t>(gl.get()));
-    surface = mirrorScreen->GetEGLSurface();
-    if (surface == LOCAL_EGL_NO_SURFACE) {
-      // Failed to create EGLSurface
-      return;
-    }
-  }
-  GLContext* gl = compositor->gl();
-  GLContextEGL* egl = GLContextEGL::Cast(gl);
-  const IntSize windowSize = mirrorScreen->GetNaturalBounds().Size().ToUnknownSize();
 #endif
 
   if ((windowSize.width <= 0) || (windowSize.height <= 0)) {
     return;
   }
 
   ScreenRotation rotation = compositor->GetScreenRotation();
 
@@ -1208,25 +1170,16 @@ LayerManagerComposite::RenderToPresentat
   egl->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
 
   const IntRect clipRect = IntRect::Truncate(0, 0, actualWidth, actualHeight);
 
   RootLayer()->Prepare(RenderTargetIntRect::FromUnknownRect(clipRect));
   RootLayer()->RenderLayer(clipRect);
 
   mCompositor->EndFrame();
-#ifdef MOZ_WIDGET_GONK
-  mCompositor->SetDispAcquireFence(mRoot); // Call after EndFrame()
-
-  RefPtr<Composer2D> composer2D;
-  composer2D = mCompositor->GetWidget()->GetComposer2D();
-  if (composer2D) {
-    composer2D->Render(mirrorScreenWidget);
-  }
-#endif
 }
 #endif
 
 already_AddRefed<PaintedLayerComposite>
 LayerManagerComposite::CreatePaintedLayerComposite()
 {
   if (mDestroyed) {
     NS_WARNING("Call on destroyed layer manager");
--- a/gfx/layers/composite/LayerManagerComposite.h
+++ b/gfx/layers/composite/LayerManagerComposite.h
@@ -321,17 +321,17 @@ private:
    * Update the invalid region and render it.
    */
   void UpdateAndRender();
 
   /**
    * Render the current layer tree to the active target.
    */
   void Render(const nsIntRegion& aInvalidRegion, const nsIntRegion& aOpaqueRegion);
-#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_WIDGET_ANDROID)
   void RenderToPresentationSurface();
 #endif
 
   /**
    * Render paint and composite times above the frame.
    */
   void DrawPaintTimes(Compositor* aCompositor);
 
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -30,21 +30,16 @@
 #include "gfxPrefs.h"
 #include "gfxUtils.h"
 #include "IPDLActor.h"
 
 #ifdef MOZ_ENABLE_D3D10_LAYER
 #include "../d3d11/CompositorD3D11.h"
 #endif
 
-#ifdef MOZ_WIDGET_GONK
-#include "../opengl/GrallocTextureClient.h"
-#include "../opengl/GrallocTextureHost.h"
-#endif
-
 #ifdef MOZ_X11
 #include "mozilla/layers/X11TextureHost.h"
 #endif
 
 #ifdef XP_MACOSX
 #include "../opengl/MacIOSurfaceTextureHostOGL.h"
 #endif
 
@@ -236,17 +231,16 @@ TextureHost::Create(const SurfaceDescrip
     case SurfaceDescriptor::TSurfaceDescriptorGPUVideo:
       return CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
 
     case SurfaceDescriptor::TEGLImageDescriptor:
     case SurfaceDescriptor::TSurfaceTextureDescriptor:
     case SurfaceDescriptor::TSurfaceDescriptorSharedGLTexture:
       return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
 
-    case SurfaceDescriptor::TSurfaceDescriptorGralloc:
     case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface:
       if (aBackend == LayersBackend::LAYERS_OPENGL) {
         return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
       } else {
         return CreateTextureHostBasic(aDesc, aDeallocator, aFlags);
       }
 
 #ifdef MOZ_X11
@@ -381,34 +375,31 @@ TextureHost::RecycleTexture(TextureFlags
 void
 TextureHost::NotifyNotUsed()
 {
   if (!mActor) {
     return;
   }
 
   // Do not need to call NotifyNotUsed() if TextureHost does not have
-  // TextureFlags::RECYCLE flag and TextureHost is not GrallocTextureHostOGL.
-  if (!(GetFlags() & TextureFlags::RECYCLE) &&
-      !AsGrallocTextureHostOGL()) {
+  // TextureFlags::RECYCLE flag.
+  if (!(GetFlags() & TextureFlags::RECYCLE)) {
     return;
   }
 
   auto compositor = GetCompositor();
   // The following cases do not need to defer NotifyNotUsed until next Composite.
   // - TextureHost does not have Compositor.
   // - Compositor is BasicCompositor.
   // - TextureHost has intermediate buffer.
-  // - TextureHost is GrallocTextureHostOGL. Fence object is used to detect
   //   end of buffer usage.
   if (!compositor ||
       compositor->IsDestroyed() ||
       compositor->AsBasicCompositor() ||
-      HasIntermediateBuffer() ||
-      AsGrallocTextureHostOGL()) {
+      HasIntermediateBuffer()) {
     static_cast<TextureParent*>(mActor)->NotifyNotUsed(mFwdTransactionId);
     return;
   }
 
   compositor->NotifyNotUsedAfterComposition(this);
 }
 
 void
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -39,17 +39,16 @@ class Shmem;
 namespace layers {
 
 class BufferDescriptor;
 class BufferTextureHost;
 class Compositor;
 class CompositableParentManager;
 class ReadLockDescriptor;
 class CompositorBridgeParent;
-class GrallocTextureHostOGL;
 class SurfaceDescriptor;
 class HostIPCAllocator;
 class ISurfaceAllocator;
 class TextureHostOGL;
 class TextureReadLock;
 class TextureSourceOGL;
 class TextureSourceD3D9;
 class TextureSourceD3D11;
@@ -617,18 +616,16 @@ public:
                            ISurfaceAllocator* aAllocator);
 
   TextureReadLock* GetReadLock() { return mReadLock; }
 
   virtual Compositor* GetCompositor() = 0;
 
   virtual BufferTextureHost* AsBufferTextureHost() { return nullptr; }
 
-  virtual GrallocTextureHostOGL* AsGrallocTextureHostOGL() { return nullptr; }
-
 protected:
   void ReadUnlock();
 
   FenceHandle mReleaseFenceHandle;
 
   FenceHandle mAcquireFenceHandle;
 
   void RecycleTexture(TextureFlags aFlags);
--- a/gfx/layers/composite/TiledContentHost.h
+++ b/gfx/layers/composite/TiledContentHost.h
@@ -23,20 +23,16 @@
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
 #include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
 #include "mozilla/layers/TextureHost.h"  // for TextureHost
 #include "mozilla/layers/TextureClient.h"
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nscore.h"                     // for nsACString
 
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-#include <ui/Fence.h>
-#endif
-
 namespace mozilla {
 
 namespace layers {
 
 class Compositor;
 class ISurfaceAllocator;
 class Layer;
 class ThebesBufferData;
--- a/gfx/layers/ipc/CompositableForwarder.h
+++ b/gfx/layers/ipc/CompositableForwarder.h
@@ -67,22 +67,16 @@ public:
   /**
    * Communicate to the compositor that aRegion in the texture identified by
    * aCompositable and aIdentifier has been updated to aThebesBuffer.
    */
   virtual void UpdateTextureRegion(CompositableClient* aCompositable,
                                    const ThebesBufferData& aThebesBufferData,
                                    const nsIntRegion& aUpdatedRegion) = 0;
 
-#ifdef MOZ_WIDGET_GONK
-  virtual void UseOverlaySource(CompositableClient* aCompositabl,
-                                const OverlaySource& aOverlay,
-                                const gfx::IntRect& aPictureRect) = 0;
-#endif
-
   virtual void Destroy(CompositableChild* aCompositable);
 
   virtual bool DestroyInTransaction(PTextureChild* aTexture, bool synchronously) = 0;
   virtual bool DestroyInTransaction(PCompositableChild* aCompositable, bool synchronously) = 0;
 
   /**
    * Tell the CompositableHost on the compositor side to remove the texture
    * from the CompositableHost.
--- a/gfx/layers/ipc/CompositableTransactionParent.cpp
+++ b/gfx/layers/ipc/CompositableTransactionParent.cpp
@@ -11,17 +11,16 @@
 #include "GLContext.h"                  // for GLContext
 #include "Layers.h"                     // for Layer
 #include "RenderTrace.h"                // for RenderTraceInvalidateEnd, etc
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/ContentHost.h"  // for ContentHostBase
 #include "mozilla/layers/ImageBridgeParent.h" // for ImageBridgeParent
-#include "mozilla/layers/SharedBufferManagerParent.h"
 #include "mozilla/layers/LayerManagerComposite.h"
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
 #include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_LOG
 #include "mozilla/layers/TextureHost.h"  // for TextureHost
 #include "mozilla/layers/TextureHostOGL.h"  // for TextureHostOGL
 #include "mozilla/layers/TiledContentHost.h"
 #include "mozilla/layers/PaintedLayerComposite.h"
 #include "mozilla/mozalloc.h"           // for operator delete
@@ -56,17 +55,17 @@ ScheduleComposition(CompositableHost* aC
   CompositorBridgeParent* cp = CompositorBridgeParent::GetCompositorBridgeParent(id);
   if (!cp) {
     return false;
   }
   cp->ScheduleComposition();
   return true;
 }
 
-#if defined(DEBUG) || defined(MOZ_WIDGET_GONK)
+#if defined(DEBUG)
 static bool ValidatePictureRect(const mozilla::gfx::IntSize& aSize,
                                 const nsIntRect& aPictureRect)
 {
   return nsIntRect(0, 0, aSize.width, aSize.height).Contains(aPictureRect) &&
       !aPictureRect.IsEmpty();
 }
 #endif
 
@@ -241,26 +240,16 @@ CompositableParentManager::ReceiveCompos
         MOZ_ASSERT(texOnWhite->NumCompositableRefs() > 0);
       }
 
       if (UsesImageBridge()) {
         ScheduleComposition(compositable);
       }
       break;
     }
-#ifdef MOZ_WIDGET_GONK
-    case CompositableOperationDetail::TOpUseOverlaySource: {
-      const OpUseOverlaySource& op = aEdit.detail().get_OpUseOverlaySource();
-      if (!ValidatePictureRect(op.overlay().size(), op.picture())) {
-        return false;
-      }
-      compositable->UseOverlaySource(op.overlay(), op.picture());
-      break;
-    }
-#endif
     default: {
       MOZ_ASSERT(false, "bad type");
     }
   }
 
   return true;
 }
 
--- a/gfx/layers/ipc/CompositorBench.cpp
+++ b/gfx/layers/ipc/CompositorBench.cpp
@@ -9,20 +9,16 @@
 #include "mozilla/gfx/2D.h"
 #include "mozilla/layers/Compositor.h"
 #include "mozilla/layers/Effects.h"
 #include "mozilla/TimeStamp.h"
 #include "gfxPrefs.h"
 #include <math.h>
 #include "GeckoProfiler.h"
 
-#ifdef MOZ_WIDGET_GONK
-#include "mozilla/layers/GrallocTextureHost.h"
-#endif
-
 #define TEST_STEPS 1000
 #define DURATION_THRESHOLD 30
 #define THRESHOLD_ABORT_COUNT 5
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
@@ -270,116 +266,26 @@ public:
   }
 
   virtual already_AddRefed<Effect> CreateEffect(size_t i) {
     return CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture,
                                 SamplingFilter::POINT, true);
   }
 };
 
-#ifdef MOZ_WIDGET_GONK
-class TrivialGrallocQuadBench : public BenchTest {
-public:
-  TrivialGrallocQuadBench()
-    : BenchTest("Travial Gralloc Quad (10s 256x256 quads)")
-  {}
-
-  uint32_t* mBuf;
-  android::sp<android::GraphicBuffer> mGralloc;
-  RefPtr<TextureSource> mTexture;
-
-  virtual void Setup(Compositor* aCompositor, size_t aStep) {
-    mBuf = nullptr;
-    int w = 256;
-    int h = 256;
-    int32_t format = android::PIXEL_FORMAT_RGBA_8888;;
-    mGralloc = new android::GraphicBuffer(w, h,
-                                 format,
-                                 android::GraphicBuffer::USAGE_SW_READ_OFTEN |
-                                 android::GraphicBuffer::USAGE_SW_WRITE_OFTEN |
-                                 android::GraphicBuffer::USAGE_HW_TEXTURE);
-    mTexture = new mozilla::layers::GrallocTextureSourceOGL((CompositorOGL*)aCompositor, mGralloc.get(), SurfaceFormat::B8G8R8A8);
-  }
-
-  void DrawFrame(Compositor* aCompositor, const gfx::Rect& aScreenRect, size_t aStep) {
-    EffectChain effects;
-    effects.mPrimaryEffect = CreateEffect(aStep);
-
-    DrawFrameTrivialQuad(aCompositor, aScreenRect, aStep, effects);
-  }
-
-  virtual void Teardown(Compositor* aCompositor) {
-    mGralloc = nullptr;
-    mTexture = nullptr;
-    free(mBuf);
-  }
-
-  virtual already_AddRefed<Effect> CreateEffect(size_t i) {
-    return CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture,
-                                SamplingFilter::POINT);
-  }
-};
-
-class StressGrallocQuadBench : public BenchTest {
-public:
-  StressGrallocQuadBench()
-    : BenchTest("Stress Gralloc Quad (10s 256x256 quads)")
-  {}
-
-  uint32_t* mBuf;
-  android::sp<android::GraphicBuffer> mGralloc;
-  RefPtr<TextureSource> mTexture;
-
-  virtual void Setup(Compositor* aCompositor, size_t aStep) {
-    mBuf = nullptr;
-    int w = 256;
-    int h = 256;
-    int32_t format = android::PIXEL_FORMAT_RGBA_8888;;
-    mGralloc = new android::GraphicBuffer(w, h,
-                                 format,
-                                 android::GraphicBuffer::USAGE_SW_READ_OFTEN |
-                                 android::GraphicBuffer::USAGE_SW_WRITE_OFTEN |
-                                 android::GraphicBuffer::USAGE_HW_TEXTURE);
-    mTexture = new mozilla::layers::GrallocTextureSourceOGL((CompositorOGL*)aCompositor, mGralloc.get(), SurfaceFormat::B8G8R8A8);
-  }
-
-  void DrawFrame(Compositor* aCompositor, const gfx::Rect& aScreenRect, size_t aStep) {
-    EffectChain effects;
-    effects.mPrimaryEffect = CreateEffect(aStep);
-
-    DrawFrameStressQuad(aCompositor, aScreenRect, aStep, effects);
-  }
-
-  virtual void Teardown(Compositor* aCompositor) {
-    mGralloc = nullptr;
-    mTexture = nullptr;
-    free(mBuf);
-  }
-
-  virtual already_AddRefed<Effect> CreateEffect(size_t i) {
-    return CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture,
-                                SamplingFilter::POINT);
-  }
-};
-#endif
-
 static void RunCompositorBench(Compositor* aCompositor, const gfx::Rect& aScreenRect)
 {
   std::vector<BenchTest*> tests;
 
   tests.push_back(new EffectSolidColorBench());
   tests.push_back(new UploadBench());
   tests.push_back(new EffectSolidColorTrivialBench());
   tests.push_back(new EffectSolidColorStressBench());
   tests.push_back(new TrivialTexturedQuadBench());
   tests.push_back(new StressTexturedQuadBench());
-#ifdef MOZ_WIDGET_GONK
-  tests.push_back(new TrivialGrallocQuadBench());
-  tests.push_back(new StressGrallocQuadBench());
-#endif
 
   for (size_t i = 0; i < tests.size(); i++) {
     BenchTest* test = tests[i];
     std::vector<TimeDuration> results;
     int testsOverThreshold = 0;
     PROFILER_MARKER(test->ToString());
     for (size_t j = 0; j < TEST_STEPS; j++) {
       test->Setup(aCompositor, j);
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -80,21 +80,16 @@
 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
 #include "VsyncSource.h"
 #endif
 #include "mozilla/widget/CompositorWidget.h"
 #ifdef MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING
 # include "mozilla/widget/CompositorWidgetParent.h"
 #endif
 
-#ifdef MOZ_WIDGET_GONK
-#include "GeckoTouchDispatcher.h"
-#include "nsScreenManagerGonk.h"
-#endif
-
 #include "LayerScope.h"
 
 namespace mozilla {
 
 namespace layers {
 
 using namespace mozilla::ipc;
 using namespace mozilla::gfx;
@@ -344,114 +339,46 @@ CompositorVsyncScheduler::CompositorVsyn
   , mIsObservingVsync(false)
   , mNeedsComposite(0)
   , mVsyncNotificationsSkipped(0)
   , mWidget(aWidget)
   , mCurrentCompositeTaskMonitor("CurrentCompositeTaskMonitor")
   , mCurrentCompositeTask(nullptr)
   , mSetNeedsCompositeMonitor("SetNeedsCompositeMonitor")
   , mSetNeedsCompositeTask(nullptr)
-#ifdef MOZ_WIDGET_GONK
-#if ANDROID_VERSION >= 19
-  , mDisplayEnabled(false)
-  , mSetDisplayMonitor("SetDisplayMonitor")
-  , mSetDisplayTask(nullptr)
-#endif
-#endif
 {
   MOZ_ASSERT(NS_IsMainThread() || XRE_GetProcessType() == GeckoProcessType_GPU);
   mVsyncObserver = new Observer(this);
-#ifdef MOZ_WIDGET_GONK
-  GeckoTouchDispatcher::GetInstance()->SetCompositorVsyncScheduler(this);
-
-#if ANDROID_VERSION >= 19
-  RefPtr<nsScreenManagerGonk> screenManager = nsScreenManagerGonk::GetInstance();
-  screenManager->SetCompositorVsyncScheduler(this);
-#endif
-#endif
 
   // mAsapScheduling is set on the main thread during init,
   // but is only accessed after on the compositor thread.
   mAsapScheduling = gfxPrefs::LayersCompositionFrameRate() == 0 ||
                     gfxPlatform::IsInLayoutAsapMode();
 }
 
 CompositorVsyncScheduler::~CompositorVsyncScheduler()
 {
   MOZ_ASSERT(!mIsObservingVsync);
   MOZ_ASSERT(!mVsyncObserver);
   // The CompositorVsyncDispatcher is cleaned up before this in the nsBaseWidget, which stops vsync listeners
   mCompositorBridgeParent = nullptr;
 }
 
-#ifdef MOZ_WIDGET_GONK
-#if ANDROID_VERSION >= 19
-void
-CompositorVsyncScheduler::SetDisplay(bool aDisplayEnable)
-{
-  // SetDisplay() is usually called from nsScreenManager at main thread. Post
-  // to compositor thread if needs.
-  if (!CompositorThreadHolder::IsInCompositorThread()) {
-    MOZ_ASSERT(NS_IsMainThread());
-    MonitorAutoLock lock(mSetDisplayMonitor);
-    RefPtr<CancelableRunnable> task =
-      NewCancelableRunnableMethod<bool>(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable);
-    mSetDisplayTask = task;
-    ScheduleTask(task.forget(), 0);
-    return;
-  } else {
-    MonitorAutoLock lock(mSetDisplayMonitor);
-    mSetDisplayTask = nullptr;
-  }
-
-  if (mDisplayEnabled == aDisplayEnable) {
-    return;
-  }
-
-  mDisplayEnabled = aDisplayEnable;
-  if (!mDisplayEnabled) {
-    CancelCurrentSetNeedsCompositeTask();
-    CancelCurrentCompositeTask();
-  }
-}
-
-void
-CompositorVsyncScheduler::CancelSetDisplayTask()
-{
-  MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
-  MonitorAutoLock lock(mSetDisplayMonitor);
-  if (mSetDisplayTask) {
-    mSetDisplayTask->Cancel();
-    mSetDisplayTask = nullptr;
-  }
-
-  // CancelSetDisplayTask is only be called in clean-up process, so
-  // mDisplayEnabled could be false there.
-  mDisplayEnabled = false;
-}
-#endif //ANDROID_VERSION >= 19
-#endif //MOZ_WIDGET_GONK
-
 void
 CompositorVsyncScheduler::Destroy()
 {
   if (!mVsyncObserver) {
     // Destroy was already called on this object.
     return;
   }
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
   UnobserveVsync();
   mVsyncObserver->Destroy();
   mVsyncObserver = nullptr;
 
-#ifdef MOZ_WIDGET_GONK
-#if ANDROID_VERSION >= 19
-  CancelSetDisplayTask();
-#endif
-#endif
   CancelCurrentSetNeedsCompositeTask();
   CancelCurrentCompositeTask();
 }
 
 void
 CompositorVsyncScheduler::PostCompositeTask(TimeStamp aCompositeTimestamp)
 {
   // can be called from the compositor or vsync thread
@@ -516,25 +443,16 @@ CompositorVsyncScheduler::SetNeedsCompos
     mSetNeedsCompositeTask = task;
     ScheduleTask(task.forget(), 0);
     return;
   } else {
     MonitorAutoLock lock(mSetNeedsCompositeMonitor);
     mSetNeedsCompositeTask = nullptr;
   }
 
-#ifdef MOZ_WIDGET_GONK
-#if ANDROID_VERSION >= 19
-  // Skip composition when display off.
-  if (!mDisplayEnabled) {
-    return;
-  }
-#endif
-#endif
-
   mNeedsComposite++;
   if (!mIsObservingVsync && mNeedsComposite) {
     ObserveVsync();
   }
 }
 
 bool
 CompositorVsyncScheduler::NotifyVsync(TimeStamp aVsyncTimestamp)
@@ -647,19 +565,16 @@ CompositorVsyncScheduler::UnobserveVsync
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
   mWidget->ObserveVsync(nullptr);
   mIsObservingVsync = false;
 }
 
 void
 CompositorVsyncScheduler::DispatchTouchEvents(TimeStamp aVsyncTimestamp)
 {
-#ifdef MOZ_WIDGET_GONK
-  GeckoTouchDispatcher::GetInstance()->NotifyVsync(aVsyncTimestamp);
-#endif
 }
 
 void
 CompositorVsyncScheduler::DispatchVREvents(TimeStamp aVsyncTimestamp)
 {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
 
   VRManager* vm = VRManager::Get();
--- a/gfx/layers/ipc/CompositorBridgeParent.h
+++ b/gfx/layers/ipc/CompositorBridgeParent.h
@@ -90,29 +90,16 @@ private:
 class CompositorVsyncScheduler
 {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorVsyncScheduler)
 
 public:
   explicit CompositorVsyncScheduler(CompositorBridgeParent* aCompositorBridgeParent,
                                     widget::CompositorWidget* aWidget);
 
-#ifdef MOZ_WIDGET_GONK
-  // emulator-ics never trigger the display on/off, so compositor will always
-  // skip composition request at that device. Only check the display status
-  // with kk device and upon.
-#if ANDROID_VERSION >= 19
-  // SetDisplay() and CancelSetDisplayTask() are used for the display on/off.
-  // It will clear all composition related task and flag, and skip another
-  // composition task during the display off. That could prevent the problem
-  // that compositor might show the old content at the first frame of display on.
-  void SetDisplay(bool aDisplayEnable);
-#endif
-#endif
-
   bool NotifyVsync(TimeStamp aVsyncTimestamp);
   void SetNeedsComposite();
   void OnForceComposeToTarget();
 
   void ScheduleTask(already_AddRefed<CancelableRunnable>, int);
   void ResumeComposition();
   void ComposeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect = nullptr);
   void PostCompositeTask(TimeStamp aCompositeTimestamp);
@@ -139,21 +126,16 @@ private:
   virtual ~CompositorVsyncScheduler();
 
   void NotifyCompositeTaskExecuted();
   void ObserveVsync();
   void UnobserveVsync();
   void DispatchTouchEvents(TimeStamp aVsyncTimestamp);
   void DispatchVREvents(TimeStamp aVsyncTimestamp);
   void CancelCurrentSetNeedsCompositeTask();
-#ifdef MOZ_WIDGET_GONK
-#if ANDROID_VERSION >= 19
-  void CancelSetDisplayTask();
-#endif
-#endif
 
   class Observer final : public VsyncObserver
   {
   public:
     explicit Observer(CompositorVsyncScheduler* aOwner);
     virtual bool NotifyVsync(TimeStamp aVsyncTimestamp) override;
     void Destroy();
   private:
@@ -178,24 +160,16 @@ private:
   widget::CompositorWidget* mWidget;
   RefPtr<CompositorVsyncScheduler::Observer> mVsyncObserver;
 
   mozilla::Monitor mCurrentCompositeTaskMonitor;
   RefPtr<CancelableRunnable> mCurrentCompositeTask;
 
   mozilla::Monitor mSetNeedsCompositeMonitor;
   RefPtr<CancelableRunnable> mSetNeedsCompositeTask;
-
-#ifdef MOZ_WIDGET_GONK
-#if ANDROID_VERSION >= 19
-  bool mDisplayEnabled;
-  mozilla::Monitor mSetDisplayMonitor;
-  RefPtr<CancelableRunnable> mSetDisplayTask;
-#endif
-#endif
 };
 
 class CompositorBridgeParentBase : public PCompositorBridgeParent,
                                    public HostIPCAllocator,
                                    public ShmemAllocator,
                                    public MetricsSharingController
 {
 public:
--- a/gfx/layers/ipc/FenceUtils.cpp
+++ b/gfx/layers/ipc/FenceUtils.cpp
@@ -1,51 +1,34 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim: sw=2 ts=8 et :
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-#pragma GCC visibility push(default)
-#include "sync/sync.h"       // for sync_merge
-#pragma GCC visibility pop
-#endif
-
 #include "FenceUtils.h"
 
 using namespace mozilla::layers;
 
 namespace IPC {
 
 void
 ParamTraits<FenceHandle>::Write(Message* aMsg,
                                 const paramType& aParam)
 {
   FenceHandle handle = aParam;
 
   MOZ_ASSERT(handle.IsValid());
-
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-  RefPtr<FenceHandle::FdObj> fence = handle.GetAndResetFdObj();
-  aMsg->WriteFileDescriptor(base::FileDescriptor(fence->GetAndResetFd(), true));
-#endif
 }
 
 bool
 ParamTraits<FenceHandle>::Read(const Message* aMsg,
                                PickleIterator* aIter, paramType* aResult)
 {
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-  base::FileDescriptor fd;
-  if (aMsg->ReadFileDescriptor(aIter, &fd)) {
-    aResult->Merge(FenceHandle(new FenceHandle::FdObj(fd.fd)));
-  }
-#endif
   return true;
 }
 
 } // namespace IPC
 
 namespace mozilla {
 namespace layers {
 
@@ -58,32 +41,16 @@ FenceHandle::FenceHandle(FdObj* aFdObj)
   : mFence(aFdObj)
 {
   MOZ_ASSERT(aFdObj);
 }
 
 void
 FenceHandle::Merge(const FenceHandle& aFenceHandle)
 {
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-  if (!aFenceHandle.IsValid()) {
-    return;
-  }
-
-  if (!IsValid()) {
-    mFence = aFenceHandle.mFence;
-  } else {
-    int result = sync_merge("FenceHandle", mFence->mFd, aFenceHandle.mFence->mFd);
-    if (result == -1) {
-      mFence = aFenceHandle.mFence;
-    } else {
-      mFence = new FdObj(result);
-    }
-  }
-#endif
 }
 
 void
 FenceHandle::TransferToAnotherFenceHandle(FenceHandle& aFenceHandle)
 {
   aFenceHandle.mFence = this->GetAndResetFdObj();
 }
 
--- a/gfx/layers/ipc/GonkNativeHandle.h
+++ b/gfx/layers/ipc/GonkNativeHandle.h
@@ -3,95 +3,22 @@
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef IPC_GonkNativeHandle_h
 #define IPC_GonkNativeHandle_h
 
-#ifdef MOZ_WIDGET_GONK
-#include <cutils/native_handle.h>
-#endif
-
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "nsISupportsImpl.h"
 
 namespace mozilla {
 namespace layers {
 
-#ifdef MOZ_WIDGET_GONK
-// GonkNativeHandle wraps android's native_handle_t and is used to support
-// android's sideband stream.
-// The sideband stream is a device-specific mechanism for passing buffers
-// to hwcomposer. It is used to render TV streams and DRM protected streams.
-// The native_handle_t represents device-specific kernel objects on android.
-class GonkNativeHandle {
-public:
-  class NhObj {
-    NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NhObj)
-    friend class GonkNativeHandle;
-  public:
-    NhObj()
-      : mHandle(nullptr) {}
-    explicit NhObj(native_handle_t* aHandle)
-      : mHandle(aHandle) {}
-    native_handle_t* GetAndResetNativeHandle()
-    {
-      native_handle_t* handle = mHandle;
-      mHandle = nullptr;
-      return handle;
-    }
-
-  private:
-    virtual ~NhObj() {
-      if (mHandle) {
-        native_handle_close(mHandle);
-        native_handle_delete(mHandle);
-      }
-    }
-
-    native_handle_t* mHandle;
-  };
-
-  GonkNativeHandle();
-
-  explicit GonkNativeHandle(NhObj* aNhObj);
-
-  bool operator==(const GonkNativeHandle& aOther) const {
-    return mNhObj.get() == aOther.mNhObj.get();
-  }
-
-  bool IsValid() const
-  {
-    return mNhObj && mNhObj->mHandle;
-  }
-
-  void TransferToAnother(GonkNativeHandle& aHandle);
-
-  already_AddRefed<NhObj> GetAndResetNhObj();
-
-  already_AddRefed<NhObj> GetDupNhObj();
-
-  static already_AddRefed<NhObj> CreateDupNhObj(native_handle_t* aHandle);
-
-  // Return non owning handle.
-  native_handle_t* GetRawNativeHandle() const
-  {
-    if (mNhObj) {
-      return mNhObj->mHandle;
-    }
-    return nullptr;
-  }
-
-private:
-  RefPtr<NhObj> mNhObj;
-};
-#else
 struct GonkNativeHandle {
   bool operator==(const GonkNativeHandle&) const { return false; }
 };
-#endif
 
 } // namespace layers
 } // namespace mozilla
 
 #endif // IPC_GonkNativeHandle_h
--- a/gfx/layers/ipc/GonkNativeHandleUtils.h
+++ b/gfx/layers/ipc/GonkNativeHandleUtils.h
@@ -9,28 +9,18 @@
 #define IPC_GonkNativeHandleUtils_h
 
 #include "ipc/IPCMessageUtils.h"
 
 #include "GonkNativeHandle.h"
 
 namespace IPC {
 
-#ifdef MOZ_WIDGET_GONK
-template <>
-struct ParamTraits<mozilla::layers::GonkNativeHandle> {
-  typedef mozilla::layers::GonkNativeHandle paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam);
-  static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult);
-};
-#else
 template <>
 struct ParamTraits<mozilla::layers::GonkNativeHandle> {
   typedef mozilla::layers::GonkNativeHandle paramType;
   static void Write(Message*, const paramType&) {}
   static bool Read(const Message*, PickleIterator*, paramType*) { return false; }
 };
-#endif
 
 } // namespace IPC
 
 #endif // IPC_GonkNativeHandleUtils_h
--- a/gfx/layers/ipc/ISurfaceAllocator.h
+++ b/gfx/layers/ipc/ISurfaceAllocator.h
@@ -12,28 +12,16 @@
 #include "mozilla/gfx/Point.h"          // for IntSize
 #include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
 #include "mozilla/RefPtr.h"
 #include "nsIMemoryReporter.h"          // for nsIMemoryReporter
 #include "mozilla/Atomics.h"            // for Atomic
 #include "mozilla/layers/LayersMessages.h" // for ShmemSection
 #include "LayersTypes.h"
 
-/*
- * FIXME [bjacob] *** PURE CRAZYNESS WARNING ***
- * (I think that this doesn't apply anymore.)
- *
- * This #define is actually needed here, because subclasses of ISurfaceAllocator,
- * namely ShadowLayerForwarder, will or will not override AllocGrallocBuffer
- * depending on whether MOZ_HAVE_SURFACEDESCRIPTORGRALLOC is defined.
- */
-#ifdef MOZ_WIDGET_GONK
-#define MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-#endif
-
 namespace mozilla {
 namespace ipc {
 class Shmem;
 } // namespace ipc
 namespace gfx {
 class DataSourceSurface;
 } // namespace gfx
 
--- a/gfx/layers/ipc/ImageBridgeChild.cpp
+++ b/gfx/layers/ipc/ImageBridgeChild.cpp
@@ -214,34 +214,16 @@ ImageBridgeChild::UseComponentAlphaTextu
         nullptr, aTextureOnBlack->GetIPDLActor(),
         nullptr, aTextureOnWhite->GetIPDLActor(),
         readLockB, readLockW
       )
     )
   );
 }
 
-#ifdef MOZ_WIDGET_GONK
-void
-ImageBridgeChild::UseOverlaySource(CompositableClient* aCompositable,
-                                   const OverlaySource& aOverlay,
-                                   const nsIntRect& aPictureRect)
-{
-  MOZ_ASSERT(aCompositable);
-  MOZ_ASSERT(aCompositable->IsConnected());
-
-  CompositableOperation op(
-    nullptr,
-    aCompositable->GetIPDLActor(),
-    OpUseOverlaySource(aOverlay, aPictureRect));
-
-  mTxn->AddEdit(op);
-}
-#endif
-
 void
 ImageBridgeChild::HoldUntilCompositableRefReleasedIfNecessary(TextureClient* aClient)
 {
   // Wait ReleaseCompositableRef only when TextureFlags::RECYCLE is set on ImageBridge.
   if (!aClient ||
       !(aClient->GetFlags() & TextureFlags::RECYCLE)) {
     return;
   }
@@ -275,93 +257,44 @@ ImageBridgeChild::DeliverFence(uint64_t 
 
 void
 ImageBridgeChild::HoldUntilFenceHandleDelivery(TextureClient* aClient, uint64_t aTransactionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
   // XXX Re-enable fence handling
   return;
 
-#ifdef MOZ_WIDGET_GONK
-  if (!aClient) {
-    return;
-  }
-  MutexAutoLock lock(mWaitingFenceHandleMutex);
-  aClient->SetLastFwdTransactionId(aTransactionId);
-  aClient->WaitFenceHandleOnImageBridge(mWaitingFenceHandleMutex);
-  mTexturesWaitingFenceHandle.Put(aClient->GetSerial(), aClient);
-#else
   NS_RUNTIMEABORT("not reached");
-#endif
 }
 
 void
 ImageBridgeChild::DeliverFenceToNonRecycle(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle)
 {
   // XXX Re-enable fence handling
   return;
 
-#ifdef MOZ_WIDGET_GONK
-  MutexAutoLock lock(mWaitingFenceHandleMutex);
-  TextureClient* client = mTexturesWaitingFenceHandle.Get(aTextureId).get();
-  if (!client) {
-    return;
-  }
-  MOZ_ASSERT(aTextureId == client->GetSerial());
-  client->SetReleaseFenceHandle(aReleaseFenceHandle);
-#else
   NS_RUNTIMEABORT("not reached");
-#endif
 }
 
 void
 ImageBridgeChild::NotifyNotUsedToNonRecycle(uint64_t aTextureId, uint64_t aTransactionId)
 {
   // XXX Re-enable fence handling
   return;
 
-#ifdef MOZ_WIDGET_GONK
-  MutexAutoLock lock(mWaitingFenceHandleMutex);
-
-  RefPtr<TextureClient> client = mTexturesWaitingFenceHandle.Get(aTextureId);
-  if (!client) {
-    return;
-  }
-  if (aTransactionId < client->GetLastFwdTransactionId()) {
-    return;
-  }
-
-  MOZ_ASSERT(aTextureId == client->GetSerial());
-  client->ClearWaitFenceHandleOnImageBridge(mWaitingFenceHandleMutex);
-  mTexturesWaitingFenceHandle.Remove(aTextureId);
-
-  // Release TextureClient on allocator's message loop.
-  RefPtr<TextureClientReleaseTask> task =
-    MakeAndAddRef<TextureClientReleaseTask>(client);
-  RefPtr<LayersIPCChannel> allocator = client->GetAllocator();
-  client = nullptr;
-  allocator->GetMessageLoop()->PostTask(task.forget());
-#else
   NS_RUNTIMEABORT("not reached");
-#endif
 }
 
 void
 ImageBridgeChild::CancelWaitFenceHandle(TextureClient* aClient)
 {
   // XXX Re-enable fence handling
   return;
 
-#ifdef MOZ_WIDGET_GONK
-  MutexAutoLock lock(mWaitingFenceHandleMutex);
-  aClient->ClearWaitFenceHandleOnImageBridge(mWaitingFenceHandleMutex);
-  mTexturesWaitingFenceHandle.Remove(aClient->GetSerial());
-#else
   NS_RUNTIMEABORT("not reached");
-#endif
 }
 
 void
 ImageBridgeChild::CancelWaitForRecycle(uint64_t aTextureId)
 {
   MOZ_ASSERT(InImageBridgeChildThread());
 
   RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
@@ -511,19 +444,16 @@ ImageBridgeChild::CreateCanvasClientSync
   AutoCompleteTask complete(aTask);
   *outResult = CreateCanvasClientNow(aType, aFlags);
 }
 
 ImageBridgeChild::ImageBridgeChild()
   : mCanSend(false)
   , mCalledClose(false)
   , mFwdTransactionId(0)
-#ifdef MOZ_WIDGET_GONK
-  , mWaitingFenceHandleMutex("ImageBridgeChild::mWaitingFenceHandleMutex")
-#endif
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   mTxn = new CompositableTransaction();
 }
 
 ImageBridgeChild::~ImageBridgeChild()
 {
@@ -717,82 +647,59 @@ ImageBridgeChild::UpdateAsyncCanvasRende
 }
 
 void
 ImageBridgeChild::FlushAllImagesSync(SynchronousTask* aTask,
                                      ImageClient* aClient,
                                      ImageContainer* aContainer,
                                      RefPtr<AsyncTransactionWaiter> aWaiter)
 {
-#ifdef MOZ_WIDGET_GONK
-  MOZ_ASSERT(aWaiter);
-#else
   MOZ_ASSERT(!aWaiter);
-#endif
 
   AutoCompleteTask complete(aTask);
 
   if (!CanSend()) {
-#ifdef MOZ_WIDGET_GONK
-    aWaiter->DecrementWaitCount();
-#endif
     return;
   }
 
   MOZ_ASSERT(aClient);
   BeginTransaction();
   if (aContainer) {
     aContainer->ClearImagesFromImageBridge();
   }
   aClient->FlushAllImages(aWaiter);
   EndTransaction();
-  // This decrement is balanced by the increment in FlushAllImages.
-  // If any AsyncTransactionTrackers were created by FlushAllImages and attached
-  // to aWaiter, aWaiter will not complete until those trackers all complete.
-  // Otherwise, aWaiter will be ready to complete now.
-#ifdef MOZ_WIDGET_GONK
-  aWaiter->DecrementWaitCount();
-#endif
 }
 
 void
 ImageBridgeChild::FlushAllImages(ImageClient* aClient, ImageContainer* aContainer)
 {
   MOZ_ASSERT(aClient);
   MOZ_ASSERT(!InImageBridgeChildThread());
 
   if (InImageBridgeChildThread()) {
     NS_ERROR("ImageBridgeChild::FlushAllImages() is called on ImageBridge thread.");
     return;
   }
 
   SynchronousTask task("FlushAllImages Lock");
 
   RefPtr<AsyncTransactionWaiter> waiter;
-#ifdef MOZ_WIDGET_GONK
-  waiter = new AsyncTransactionWaiter();
-  // This increment is balanced by the decrement in FlushAllImagesSync
-  waiter->IncrementWaitCount();
-#endif
 
   // RefPtrs on arguments are not needed since this dispatches synchronously.
   RefPtr<Runnable> runnable = WrapRunnable(
     RefPtr<ImageBridgeChild>(this),
     &ImageBridgeChild::FlushAllImagesSync,
     &task,
     aClient,
     aContainer,
     waiter);
   GetMessageLoop()->PostTask(runnable.forget());
 
   task.Wait();
-
-#ifdef MOZ_WIDGET_GONK
-  waiter->WaitComplete();
-#endif
 }
 
 void
 ImageBridgeChild::BeginTransaction()
 {
   MOZ_ASSERT(CanSend());
   MOZ_ASSERT(mTxn->Finished(), "uncommitted txn?");
   UpdateFwdTransactionId();
@@ -839,19 +746,16 @@ ImageBridgeChild::EndTransaction()
   for (nsTArray<EditReply>::size_type i = 0; i < replies.Length(); ++i) {
     NS_RUNTIMEABORT("not reached");
   }
 }
 
 void
 ImageBridgeChild::SendImageBridgeThreadId()
 {
-#ifdef MOZ_WIDGET_GONK
-  PImageBridgeChild::SendImageBridgeThreadId(gettid());
-#endif
 }
 
 bool
 ImageBridgeChild::InitForContent(Endpoint<PImageBridgeChild>&& aEndpoint)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   gfxPlatform::GetPlatform();
--- a/gfx/layers/ipc/ImageBridgeChild.h
+++ b/gfx/layers/ipc/ImageBridgeChild.h
@@ -274,21 +274,16 @@ public:
   /**
    * See CompositableForwarder::UseTextures
    */
   virtual void UseTextures(CompositableClient* aCompositable,
                            const nsTArray<TimedTextureClient>& aTextures) override;
   virtual void UseComponentAlphaTextures(CompositableClient* aCompositable,
                                          TextureClient* aClientOnBlack,
                                          TextureClient* aClientOnWhite) override;
-#ifdef MOZ_WIDGET_GONK
-  virtual void UseOverlaySource(CompositableClient* aCompositable,
-                                const OverlaySource& aOverlay,
-                                const nsIntRect& aPictureRect) override;
-#endif
 
   void Destroy(CompositableChild* aCompositable) override;
 
   /**
    * Hold TextureClient ref until end of usage on host side if TextureFlags::RECYCLE is set.
    * Host side's usage is checked via CompositableRef.
    */
   void HoldUntilCompositableRefReleasedIfNecessary(TextureClient* aClient);
@@ -410,19 +405,14 @@ private:
 
   /**
    * Hold TextureClients refs until end of their usages on host side.
    * It defer calling of TextureClient recycle callback.
    */
   nsDataHashtable<nsUint64HashKey, RefPtr<TextureClient> > mTexturesWaitingRecycled;
 
   AsyncTransactionTrackersHolder mTrackersHolder;
-
-#ifdef MOZ_WIDGET_GONK
-  Mutex mWaitingFenceHandleMutex;
-  nsDataHashtable<nsUint64HashKey, RefPtr<TextureClient> > mTexturesWaitingFenceHandle;
-#endif
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif
--- a/gfx/layers/ipc/ImageBridgeParent.cpp
+++ b/gfx/layers/ipc/ImageBridgeParent.cpp
@@ -127,19 +127,16 @@ ImageBridgeParent::ActorDestroy(ActorDes
 bool
 ImageBridgeParent::RecvImageBridgeThreadId(const PlatformThreadId& aThreadId)
 {
   MOZ_ASSERT(!mSetChildThreadPriority);
   if (mSetChildThreadPriority) {
     return false;
   }
   mSetChildThreadPriority = true;
-#ifdef MOZ_WIDGET_GONK
-  hal::SetThreadPriority(aThreadId, hal::THREAD_PRIORITY_COMPOSITOR);
-#endif
   return true;
 }
 
 class MOZ_STACK_CLASS AutoImageBridgeParentAsyncMessageSender
 {
 public:
   explicit AutoImageBridgeParentAsyncMessageSender(ImageBridgeParent* aImageBridge,
                                                    InfallibleTArray<OpDestroy>* aToDestroy = nullptr)
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -47,18 +47,16 @@
 
 typedef std::vector<mozilla::layers::EditReply> EditReplyVector;
 
 using mozilla::layout::RenderFrameParent;
 
 namespace mozilla {
 namespace layers {
 
-class PGrallocBufferParent;
-
 //--------------------------------------------------
 // Convenience accessors
 static ShadowLayerParent*
 cast(const PLayerParent* in)
 {
   return const_cast<ShadowLayerParent*>(
     static_cast<const ShadowLayerParent*>(in));
 }
--- a/gfx/layers/ipc/LayersSurfaces.ipdlh
+++ b/gfx/layers/ipc/LayersSurfaces.ipdlh
@@ -1,16 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 using struct gfxPoint from "gfxPoint.h";
 using nsIntRegion from "nsRegion.h";
-using struct mozilla::layers::MagicGrallocBufferHandle from "gfxipc/ShadowLayerUtils.h";
-using struct mozilla::layers::GrallocBufferRef from "gfxipc/ShadowLayerUtils.h";
 using struct mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h";
 using mozilla::StereoMode from "ImageTypes.h";
 using mozilla::YUVColorSpace from "ImageTypes.h";
 using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
 using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
 using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
 using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
 using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
@@ -26,22 +24,16 @@ union OverlayHandle {
   null_t;
 };
 
 struct OverlaySource {
   OverlayHandle handle;
   IntSize size;
 };
 
-union MaybeMagicGrallocBufferHandle {
-  MagicGrallocBufferHandle;
-  GrallocBufferRef;
-  null_t;
-};
-
 struct SurfaceDescriptorD3D9 {
   // IDirect3DTexture9*
   uintptr_t texture;
 };
 
 struct SurfaceDescriptorFileMapping {
   WindowsHandle handle;
   SurfaceFormat format;
@@ -89,21 +81,16 @@ struct EGLImageDescriptor {
 struct SurfaceDescriptorSharedGLTexture {
   uint32_t texture;
   uint32_t target;
   uintptr_t fence;
   IntSize size;
   bool hasAlpha;
 };
 
-struct SurfaceDescriptorGralloc {
-  MaybeMagicGrallocBufferHandle buffer;
-  bool isOpaque;
-};
-
 struct SurfaceDescriptorGPUVideo {
   uint64_t handle;
 };
 
 struct RGBDescriptor {
   IntSize size;
   SurfaceFormat format;
   bool hasIntermediateBuffer;
@@ -141,16 +128,15 @@ union SurfaceDescriptor {
   SurfaceDescriptorDIB;
   SurfaceDescriptorD3D10;
   SurfaceDescriptorFileMapping;
   SurfaceDescriptorDXGIYCbCr;
   SurfaceDescriptorX11;
   SurfaceTextureDescriptor;
   EGLImageDescriptor;
   SurfaceDescriptorMacIOSurface;
-  SurfaceDescriptorGralloc;
   SurfaceDescriptorSharedGLTexture;
   SurfaceDescriptorGPUVideo;
   null_t;
 };
 
 } // namespace
 } // namespace
deleted file mode 100644
--- a/gfx/layers/ipc/PSharedBufferManager.ipdl
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=8 et :
- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-include LayersSurfaces;
-include ProtocolTypes;
-
-include "mozilla/GfxMessageUtils.h";
-
-namespace mozilla {
-namespace layers {
-
-/**
- * This is a dedicated protocol to track/allocate/deallocate gralloc buffers.
- */
-
-sync protocol PSharedBufferManager {
-parent:
-  sync AllocateGrallocBuffer(IntSize size, uint32_t format, uint32_t usage)
-   returns (MaybeMagicGrallocBufferHandle handle);
-both:
-  async DropGrallocBuffer(MaybeMagicGrallocBufferHandle handle);
-};
-
-} // namespace layers
-} // namespace mozilla
--- a/gfx/layers/ipc/ShadowLayerUtils.h
+++ b/gfx/layers/ipc/ShadowLayerUtils.h
@@ -23,58 +23,27 @@
 namespace mozilla { namespace layers {
 struct SurfaceDescriptorX11 {
   bool operator==(const SurfaceDescriptorX11&) const { return false; }
 };
 } // namespace layers
 } // namespace mozilla
 #endif
 
-#if defined(MOZ_WIDGET_GONK)
-# include "mozilla/layers/ShadowLayerUtilsGralloc.h"
-#else
-namespace mozilla { namespace layers {
-struct MagicGrallocBufferHandle {
-  bool operator==(const MagicGrallocBufferHandle&) const { return false; }
-};
-
-struct GrallocBufferRef {
-  bool operator==(const GrallocBufferRef&) const { return false; }
-};
-} // namespace layers
-} // namespace mozilla
-#endif
-
 namespace IPC {
 
 #if !defined(MOZ_HAVE_SURFACEDESCRIPTORX11)
 template <>
 struct ParamTraits<mozilla::layers::SurfaceDescriptorX11> {
   typedef mozilla::layers::SurfaceDescriptorX11 paramType;
   static void Write(Message*, const paramType&) {}
   static bool Read(const Message*, PickleIterator*, paramType*) { return false; }
 };
 #endif  // !defined(MOZ_HAVE_XSURFACEDESCRIPTORX11)
 
-#if !defined(MOZ_HAVE_SURFACEDESCRIPTORGRALLOC)
-template <>
-struct ParamTraits<mozilla::layers::MagicGrallocBufferHandle> {
-  typedef mozilla::layers::MagicGrallocBufferHandle paramType;
-  static void Write(Message*, const paramType&) {}
-  static bool Read(const Message*, PickleIterator*, paramType*) { return false; }
-};
-
-template <>
-struct ParamTraits<mozilla::layers::GrallocBufferRef> {
-  typedef mozilla::layers::GrallocBufferRef paramType;
-  static void Write(Message*, const paramType&) {}
-  static bool Read(const Message*, PickleIterator*, paramType*) { return false; }
-};
-#endif  // !defined(MOZ_HAVE_XSURFACEDESCRIPTORGRALLOC)
-
 template <>
 struct ParamTraits<mozilla::ScreenRotation>
   : public ContiguousEnumSerializer<
              mozilla::ScreenRotation,
              mozilla::ROTATION_0,
              mozilla::ROTATION_COUNT>
 {};
 
deleted file mode 100644
--- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=8 et :
- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "mozilla/DebugOnly.h"
-
-#include "mozilla/gfx/Point.h"
-#include "mozilla/layers/LayerTransactionChild.h"
-#include "mozilla/layers/ShadowLayers.h"
-#include "mozilla/layers/LayerManagerComposite.h"
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/TextureHost.h"
-#include "mozilla/layers/SharedBufferManagerChild.h"
-#include "mozilla/layers/SharedBufferManagerParent.h"
-#include "mozilla/UniquePtr.h"
-#include "mozilla/Unused.h"
-#include "nsXULAppAPI.h"
-
-#include "ShadowLayerUtilsGralloc.h"
-
-#include "nsIMemoryReporter.h"
-
-#include "gfxPlatform.h"
-#include "gfx2DGlue.h"
-#include "GLContext.h"
-
-#include "GeckoProfiler.h"
-
-#include "cutils/properties.h"
-
-#include "MainThreadUtils.h"
-
-using namespace android;
-using namespace mozilla::layers;
-using namespace mozilla::gl;
-
-using base::FileDescriptor;
-
-namespace IPC {
-
-void
-ParamTraits<GrallocBufferRef>::Write(Message* aMsg,
-                                     const paramType& aParam)
-{
-  aMsg->WriteInt(aParam.mOwner);
-  aMsg->WriteInt64(aParam.mKey);
-}
-
-bool
-ParamTraits<GrallocBufferRef>::Read(const Message* aMsg, PickleIterator* aIter,
-                                    paramType* aParam)
-{
-  int owner;
-  int64_t index;
-  if (!aMsg->ReadInt(aIter, &owner) ||
-      !aMsg->ReadInt64(aIter, &index)) {
-    printf_stderr("ParamTraits<GrallocBufferRef>::Read() failed to read a message\n");
-    return false;
-  }
-  aParam->mOwner = owner;
-  aParam->mKey = index;
-  return true;
-}
-
-void
-ParamTraits<MagicGrallocBufferHandle>::Write(Message* aMsg,
-                                             const paramType& aParam)
-{
-#if ANDROID_VERSION >= 19
-  sp<GraphicBuffer> flattenable = aParam.mGraphicBuffer;
-#else
-  Flattenable *flattenable = aParam.mGraphicBuffer.get();
-#endif
-  size_t nbytes = flattenable->getFlattenedSize();
-  size_t nfds = flattenable->getFdCount();
-
-  char data[nbytes];
-  int fds[nfds];
-
-#if ANDROID_VERSION >= 19
-  // Make a copy of "data" and "fds" for flatten() to avoid casting problem
-  void *pdata = (void *)data;
-  int *pfds = fds;
-
-  flattenable->flatten(pdata, nbytes, pfds, nfds);
-
-  // In Kitkat, flatten() will change the value of nbytes and nfds, which dues
-  // to multiple parcelable object consumption. The actual size and fd count
-  // which returned by getFlattenedSize() and getFdCount() are not changed.
-  // So we change nbytes and nfds back by call corresponding calls.
-  nbytes = flattenable->getFlattenedSize();
-  nfds = flattenable->getFdCount();
-#else
-  flattenable->flatten(data, nbytes, fds, nfds);
-#endif
-  aMsg->WriteInt(aParam.mRef.mOwner);
-  aMsg->WriteInt64(aParam.mRef.mKey);
-  aMsg->WriteSize(nbytes);
-  aMsg->WriteBytes(data, nbytes);
-  for (size_t n = 0; n < nfds; ++n) {
-    // These buffers can't die in transit because they're created
-    // synchonously and the parent-side buffer can only be dropped if
-    // there's a crash.
-    aMsg->WriteFileDescriptor(FileDescriptor(fds[n], false));
-  }
-}
-
-bool
-ParamTraits<MagicGrallocBufferHandle>::Read(const Message* aMsg,
-                                            PickleIterator* aIter, paramType* aResult)
-{
-  MOZ_ASSERT(!aResult->mGraphicBuffer.get());
-  MOZ_ASSERT(aResult->mRef.mOwner == 0);
-  MOZ_ASSERT(aResult->mRef.mKey == -1);
-
-  size_t nbytes;
-  int owner;
-  int64_t index;
-
-  if (!aMsg->ReadInt(aIter, &owner) ||
-      !aMsg->ReadInt64(aIter, &index) ||
-      !aMsg->ReadSize(aIter, &nbytes)) {
-    printf_stderr("ParamTraits<MagicGrallocBufferHandle>::Read() failed to read a message\n");
-    return false;
-  }
-
-  auto data = mozilla::MakeUnique<char[]>(nbytes);
-
-  if (!aMsg->ReadBytesInto(aIter, data.get(), nbytes)) {
-    printf_stderr("ParamTraits<MagicGrallocBufferHandle>::Read() failed to read a message\n");
-    return false;
-  }
-
-  size_t nfds = aMsg->num_fds();
-  int fds[nfds];
-
-  for (size_t n = 0; n < nfds; ++n) {
-    FileDescriptor fd;
-    if (!aMsg->ReadFileDescriptor(aIter, &fd)) {
-      printf_stderr("ParamTraits<MagicGrallocBufferHandle>::Read() failed to read file descriptors\n");
-      return false;
-    }
-    // If the GraphicBuffer was shared cross-process, SCM_RIGHTS does
-    // the right thing and dup's the fd. If it's shared cross-thread,
-    // SCM_RIGHTS doesn't dup the fd.
-    // But in shared cross-thread, dup fd is not necessary because we get
-    // a pointer to the GraphicBuffer directly from SharedBufferManagerParent
-    // and don't create a new GraphicBuffer around the fd.
-    fds[n] = fd.fd;
-  }
-
-  aResult->mRef.mOwner = owner;
-  aResult->mRef.mKey = index;
-  if (XRE_IsParentProcess()) {
-    // If we are in chrome process, we can just get GraphicBuffer directly from
-    // SharedBufferManagerParent.
-    aResult->mGraphicBuffer = SharedBufferManagerParent::GetGraphicBuffer(aResult->mRef);
-  } else {
-    // Deserialize GraphicBuffer
-#if ANDROID_VERSION >= 19
-    sp<GraphicBuffer> buffer(new GraphicBuffer());
-    const void* datap = (const void*)data.get();
-    const int* fdsp = &fds[0];
-    if (NO_ERROR != buffer->unflatten(datap, nbytes, fdsp, nfds)) {
-      buffer = nullptr;
-    }
-#else
-    sp<GraphicBuffer> buffer(new GraphicBuffer());
-    Flattenable *flattenable = buffer.get();
-    if (NO_ERROR != flattenable->unflatten(data.get(), nbytes, fds, nfds)) {
-      buffer = nullptr;
-    }
-#endif
-    if (buffer.get()) {
-      aResult->mGraphicBuffer = buffer;
-    }
-  }
-
-  if (!aResult->mGraphicBuffer.get()) {
-    printf_stderr("ParamTraits<MagicGrallocBufferHandle>::Read() failed to get gralloc buffer\n");
-    return false;
-  }
-
-  return true;
-}
-
-} // namespace IPC
-
-namespace mozilla {
-namespace layers {
-
-MagicGrallocBufferHandle::MagicGrallocBufferHandle(const sp<GraphicBuffer>& aGraphicBuffer, GrallocBufferRef ref)
-  : mGraphicBuffer(aGraphicBuffer)
-  , mRef(ref)
-{
-}
-
-//-----------------------------------------------------------------------------
-// Parent process
-
-/*static*/ bool
-LayerManagerComposite::SupportsDirectTexturing()
-{
-  return true;
-}
-
-/*static*/ void
-LayerManagerComposite::PlatformSyncBeforeReplyUpdate()
-{
-  // Nothing to be done for gralloc.
-}
-
-//-----------------------------------------------------------------------------
-// Both processes
-
-/*static*/ sp<GraphicBuffer>
-GetGraphicBufferFrom(MaybeMagicGrallocBufferHandle aHandle)
-{
-  if (aHandle.type() != MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle) {
-    if (aHandle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef) {
-      if (XRE_IsParentProcess()) {
-        return SharedBufferManagerParent::GetGraphicBuffer(aHandle.get_GrallocBufferRef());
-      }
-      return SharedBufferManagerChild::GetSingleton()->GetGraphicBuffer(aHandle.get_GrallocBufferRef().mKey);
-    }
-  } else {
-    MagicGrallocBufferHandle realHandle = aHandle.get_MagicGrallocBufferHandle();
-    return realHandle.mGraphicBuffer;
-  }
-  return nullptr;
-}
-
-android::sp<android::GraphicBuffer>
-GetGraphicBufferFromDesc(SurfaceDescriptor aDesc)
-{
-  MaybeMagicGrallocBufferHandle handle;
-  if (aDesc.type() == SurfaceDescriptor::TSurfaceDescriptorGralloc) {
-    handle = aDesc.get_SurfaceDescriptorGralloc().buffer();
-  }
-  return GetGraphicBufferFrom(handle);
-}
-
-/*static*/ void
-ShadowLayerForwarder::PlatformSyncBeforeUpdate()
-{
-  // Nothing to be done for gralloc.
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=8 et :
- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_layers_ShadowLayerUtilsGralloc_h
-#define mozilla_layers_ShadowLayerUtilsGralloc_h
-
-#include <unistd.h>
-#include <ui/GraphicBuffer.h>
-
-#include "base/process.h"
-#include "ipc/IPCMessageUtils.h"
-
-#define MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-#define MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS
-
-namespace mozilla {
-namespace layers {
-
-class MaybeMagicGrallocBufferHandle;
-class SurfaceDescriptor;
-
-struct GrallocBufferRef {
-  base::ProcessId mOwner;
-  int64_t mKey;
-
-  GrallocBufferRef()
-    : mOwner(0)
-    , mKey(-1)
-  {
-
-  }
-
-  bool operator== (const GrallocBufferRef rhs) const{
-    return mOwner == rhs.mOwner && mKey == rhs.mKey;
-  }
-};
-/**
- * This class exists to share the underlying GraphicBuffer resources
- * from one thread context to another.  This requires going through
- * slow paths in the kernel so can be somewhat expensive.
- *
- * This is not just platform-specific, but also
- * gralloc-implementation-specific.
- */
-struct MagicGrallocBufferHandle {
-  typedef android::GraphicBuffer GraphicBuffer;
-  MagicGrallocBufferHandle() {}
-
-  MagicGrallocBufferHandle(const android::sp<GraphicBuffer>& aGraphicBuffer, GrallocBufferRef ref);
-
-  // Default copy ctor and operator= are OK
-
-  bool operator==(const MagicGrallocBufferHandle& aOther) const {
-    return mGraphicBuffer == aOther.mGraphicBuffer;
-  }
-
-  android::sp<GraphicBuffer> mGraphicBuffer;
-  GrallocBufferRef mRef;
-};
-
-/**
- * Util function to find GraphicBuffer from SurfaceDescriptor, caller of this function should check origin
- * to make sure not corrupt others buffer
- */
-android::sp<android::GraphicBuffer> GetGraphicBufferFrom(MaybeMagicGrallocBufferHandle aHandle);
-android::sp<android::GraphicBuffer> GetGraphicBufferFromDesc(SurfaceDescriptor aDesc);
-
-} // namespace layers
-} // namespace mozilla
-
-namespace IPC {
-
-template <>
-struct ParamTraits<mozilla::layers::MagicGrallocBufferHandle> {
-  typedef mozilla::layers::MagicGrallocBufferHandle paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam);
-  static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult);
-};
-
-template<>
-struct ParamTraits<mozilla::layers::GrallocBufferRef> {
-  typedef mozilla::layers::GrallocBufferRef paramType;
-  static void Write(Message* aMsg, const paramType& aParam);
-  static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult);
-};
-
-
-} // namespace IPC
-
-#endif  // mozilla_layers_ShadowLayerUtilsGralloc_h
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -24,17 +24,16 @@
 #include "mozilla/layers/CompositableClient.h"  // for CompositableClient, etc
 #include "mozilla/layers/CompositorBridgeChild.h"
 #include "mozilla/layers/ImageDataSerializer.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/layers/LayersMessages.h"  // for Edit, etc
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
 #include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_LOG
 #include "mozilla/layers/LayerTransactionChild.h"
-#include "mozilla/layers/SharedBufferManagerChild.h"
 #include "mozilla/layers/PCompositableChild.h"
 #include "mozilla/layers/PTextureChild.h"
 #include "ShadowLayerUtils.h"
 #include "mozilla/layers/TextureClient.h"  // for TextureClient
 #include "mozilla/mozalloc.h"           // for operator new, etc
 #include "nsTArray.h"                   // for AutoTArray, nsTArray, etc
 #include "nsXULAppAPI.h"                // for XRE_GetProcessType, etc
 #include "mozilla/ReentrantMonitor.h"
@@ -352,34 +351,16 @@ ShadowLayerForwarder::CheckSurfaceDescri
 #endif
 
 void
 ShadowLayerForwarder::UseTiledLayerBuffer(CompositableClient* aCompositable,
                                           const SurfaceDescriptorTiles& aTileLayerDescriptor)
 {
   MOZ_ASSERT(aCompositable && aCompositable->IsConnected());
 
-#ifdef MOZ_WIDGET_GONK
-  // GrallocTextureData alwasys requests fence delivery if ANDROID_VERSION >= 17.
-  const InfallibleTArray<TileDescriptor>& tileDescriptors = aTileLayerDescriptor.tiles();
-  for (size_t i = 0; i < tileDescriptors.Length(); i++) {
-    const TileDescriptor& tileDesc = tileDescriptors[i];
-    if (tileDesc.type() != TileDescriptor::TTexturedTileDescriptor) {
-      continue;
-    }
-    const TexturedTileDescriptor& texturedDesc = tileDesc.get_TexturedTileDescriptor();
-    RefPtr<TextureClient> texture = TextureClient::AsTextureClient(texturedDesc.textureChild());
-    mClientLayerManager->GetCompositorBridgeChild()->HoldUntilCompositableRefReleasedIfNecessary(texture);
-    if (texturedDesc.textureOnWhite().type() == MaybeTexture::TPTextureChild) {
-      texture = TextureClient::AsTextureClient(texturedDesc.textureOnWhite().get_PTextureChild());
-      mClientLayerManager->GetCompositorBridgeChild()->HoldUntilCompositableRefReleasedIfNecessary(texture);
-    }
-  }
-#endif
-
   mTxn->AddNoSwapPaint(CompositableOperation(nullptr, aCompositable->GetIPDLActor(),
                                              OpUseTiledLayerBuffer(aTileLayerDescriptor)));
 }
 
 void
 ShadowLayerForwarder::UpdateTextureRegion(CompositableClient* aCompositable,
                                           const ThebesBufferData& aThebesBufferData,
                                           const nsIntRegion& aUpdatedRegion)
@@ -458,30 +439,16 @@ ShadowLayerForwarder::UseComponentAlphaT
       OpUseComponentAlphaTextures(
         nullptr, aTextureOnBlack->GetIPDLActor(),
         nullptr, aTextureOnWhite->GetIPDLActor(),
         readLockB, readLockW)
       )
     );
 }
 
-#ifdef MOZ_WIDGET_GONK
-void
-ShadowLayerForwarder::UseOverlaySource(CompositableClient* aCompositable,
-                                       const OverlaySource& aOverlay,
-                                       const nsIntRect& aPictureRect)
-{
-  MOZ_ASSERT(aCompositable);
-  MOZ_ASSERT(aCompositable->IsConnected());
-
-  mTxn->AddEdit(CompositableOperation(nullptr, aCompositable->GetIPDLActor(),
-                                      OpUseOverlaySource(aOverlay, aPictureRect)));
-}
-#endif
-
 static bool
 AddOpDestroy(Transaction* aTxn, const OpDestroy& op, bool synchronously)
 {
   if (!aTxn->Opened()) {
     return false;
   }
 
   aTxn->mDestroyedActors.AppendElement(op);
--- a/gfx/layers/ipc/ShadowLayers.h
+++ b/gfx/layers/ipc/ShadowLayers.h
@@ -269,21 +269,16 @@ public:
   /**
    * See CompositableForwarder::UseTextures
    */
   virtual void UseTextures(CompositableClient* aCompositable,
                            const nsTArray<TimedTextureClient>& aTextures) override;
   virtual void UseComponentAlphaTextures(CompositableClient* aCompositable,
                                          TextureClient* aClientOnBlack,
                                          TextureClient* aClientOnWhite) override;
-#ifdef MOZ_WIDGET_GONK
-  virtual void UseOverlaySource(CompositableClient* aCompositable,
-                                const OverlaySource& aOverlay,
-                                const nsIntRect& aPictureRect) override;
-#endif
 
   /**
    * Used for debugging to tell the compositor how long this frame took to paint.
    */
   void SendPaintTime(uint64_t aId, TimeDuration aPaintTime);
 
   /**
    * End the current transaction and forward it to LayerManagerComposite.
deleted file mode 100644
--- a/gfx/layers/ipc/SharedBufferManagerChild.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=8 et :
- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "base/task.h"                  // for NewRunnableFunction, etc
-#include "base/thread.h"                // for Thread
-#include "mozilla/gfx/Logging.h"        // for gfxDebug
-#include "mozilla/layers/SharedBufferManagerChild.h"
-#include "mozilla/layers/SharedBufferManagerParent.h"
-#include "mozilla/Sprintf.h"            // for SprintfLiteral
-#include "mozilla/StaticPtr.h"          // for StaticRefPtr
-#include "mozilla/ReentrantMonitor.h"   // for ReentrantMonitor, etc
-#include "nsThreadUtils.h"              // for NS_IsMainThread
-
-#ifdef MOZ_WIDGET_GONK
-#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "SBMChild", ## args)
-#endif
-
-namespace mozilla {
-namespace layers {
-
-using namespace mozilla::gfx;
-
-// Singleton
-SharedBufferManagerChild* SharedBufferManagerChild::sSharedBufferManagerChildSingleton = nullptr;
-SharedBufferManagerParent* SharedBufferManagerChild::sSharedBufferManagerParentSingleton = nullptr;
-base::Thread* SharedBufferManagerChild::sSharedBufferManagerChildThread = nullptr;
-
-SharedBufferManagerChild::SharedBufferManagerChild()
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  : mBufferMutex("BufferMonitor")
-#endif
-{
-}
-
-static bool
-InSharedBufferManagerChildThread()
-{
-  return SharedBufferManagerChild::sSharedBufferManagerChildThread->thread_id() == PlatformThread::CurrentId();
-}
-
-// dispatched function
-static void
-DeleteSharedBufferManagerSync(ReentrantMonitor *aBarrier, bool *aDone)
-{
-  ReentrantMonitorAutoEnter autoMon(*aBarrier);
-
-  MOZ_ASSERT(InSharedBufferManagerChildThread(),
-             "Should be in SharedBufferManagerChild thread.");
-  SharedBufferManagerChild::sSharedBufferManagerChildSingleton = nullptr;
-  SharedBufferManagerChild::sSharedBufferManagerParentSingleton = nullptr;
-  *aDone = true;
-  aBarrier->NotifyAll();
-}
-
-// dispatched function
-static void
-ConnectSharedBufferManager(SharedBufferManagerChild *child, SharedBufferManagerParent *parent)
-{
-  MessageLoop *parentMsgLoop = parent->GetMessageLoop();
-  ipc::MessageChannel *parentChannel = parent->GetIPCChannel();
-  child->Open(parentChannel, parentMsgLoop, mozilla::ipc::ChildSide);
-}
-
-base::Thread*
-SharedBufferManagerChild::GetThread() const
-{
-  return sSharedBufferManagerChildThread;
-}
-
-SharedBufferManagerChild*
-SharedBufferManagerChild::GetSingleton()
-{
-  return sSharedBufferManagerChildSingleton;
-}
-
-bool
-SharedBufferManagerChild::IsCreated()
-{
-  return GetSingleton() != nullptr;
-}
-
-void
-SharedBufferManagerChild::StartUp()
-{
-  NS_ASSERTION(NS_IsMainThread(), "Should be on the main Thread!");
-  SharedBufferManagerChild::StartUpOnThread(new base::Thread("BufferMgrChild"));
-}
-
-static void
-ConnectSharedBufferManagerInChildProcess(mozilla::ipc::Transport* aTransport,
-                                         base::ProcessId aOtherPid)
-{
-  // Bind the IPC channel to the shared buffer manager thread.
-  SharedBufferManagerChild::sSharedBufferManagerChildSingleton->Open(aTransport,
-                                                                     aOtherPid,
-                                                                     XRE_GetIOMessageLoop(),
-                                                                     ipc::ChildSide);
-
-}
-
-PSharedBufferManagerChild*
-SharedBufferManagerChild::StartUpInChildProcess(Transport* aTransport,
-                                                base::ProcessId aOtherPid)
-{
-  NS_ASSERTION(NS_IsMainThread(), "Should be on the main Thread!");
-
-  sSharedBufferManagerChildThread = new base::Thread("BufferMgrChild");
-  if (!sSharedBufferManagerChildThread->Start()) {
-    return nullptr;
-  }
-
-  sSharedBufferManagerChildSingleton = new SharedBufferManagerChild();
-  sSharedBufferManagerChildSingleton->GetMessageLoop()->PostTask(
-    NewRunnableFunction(ConnectSharedBufferManagerInChildProcess,
-                        aTransport, aOtherPid));
-
-  return sSharedBufferManagerChildSingleton;
-}
-
-void
-SharedBufferManagerChild::ShutDown()
-{
-  NS_ASSERTION(NS_IsMainThread(), "Should be on the main Thread!");
-  if (IsCreated()) {
-    SharedBufferManagerChild::DestroyManager();
-    delete sSharedBufferManagerChildThread;
-    sSharedBufferManagerChildThread = nullptr;
-  }
-}
-
-bool
-SharedBufferManagerChild::StartUpOnThread(base::Thread* aThread)
-{
-  MOZ_ASSERT(aThread, "SharedBufferManager needs a thread.");
-  if (sSharedBufferManagerChildSingleton != nullptr) {
-    return false;
-  }
-
-  sSharedBufferManagerChildThread = aThread;
-  if (!aThread->IsRunning()) {
-    aThread->Start();
-  }
-  sSharedBufferManagerChildSingleton = new SharedBufferManagerChild();
-  char thrname[128];
-  SprintfLiteral(thrname, "BufMgrParent#%d", base::Process::Current().pid());
-  sSharedBufferManagerParentSingleton = new SharedBufferManagerParent(
-    base::Process::Current().pid(), new base::Thread(thrname));
-  sSharedBufferManagerChildSingleton->ConnectAsync(sSharedBufferManagerParentSingleton);
-  return true;
-}
-
-void
-SharedBufferManagerChild::DestroyManager()
-{
-  MOZ_ASSERT(!InSharedBufferManagerChildThread(),
-             "This method must not be called in this thread.");
-  // ...because we are about to dispatch synchronous messages to the
-  // BufferManagerChild thread.
-
-  if (!IsCreated()) {
-    return;
-  }
-
-  ReentrantMonitor barrier("BufferManagerDestroyTask lock");
-  ReentrantMonitorAutoEnter autoMon(barrier);
-
-  bool done = false;
-  sSharedBufferManagerChildSingleton->GetMessageLoop()->PostTask(
-    NewRunnableFunction(&DeleteSharedBufferManagerSync, &barrier, &done));
-  while (!done) {
-    barrier.Wait();
-  }
-
-}
-
-MessageLoop *
-SharedBufferManagerChild::GetMessageLoop() const
-{
-  return sSharedBufferManagerChildThread != nullptr ?
-      sSharedBufferManagerChildThread->message_loop() :
-      nullptr;
-}
-
-void
-SharedBufferManagerChild::ConnectAsync(SharedBufferManagerParent* aParent)
-{
-  GetMessageLoop()->PostTask(NewRunnableFunction(&ConnectSharedBufferManager,
-                                                 this, aParent));
-}
-
-// dispatched function
-void
-SharedBufferManagerChild::AllocGrallocBufferSync(const GrallocParam& aParam,
-                                                 Monitor* aBarrier,
-                                                 bool* aDone)
-{
-  MonitorAutoLock autoMon(*aBarrier);
-
-  sSharedBufferManagerChildSingleton->AllocGrallocBufferNow(aParam.size,
-                                                            aParam.format,
-                                                            aParam.usage,
-                                                            aParam.buffer);
-  *aDone = true;
-  aBarrier->NotifyAll();
-}
-
-// dispatched function
-void
-SharedBufferManagerChild::DeallocGrallocBufferSync(const mozilla::layers::MaybeMagicGrallocBufferHandle& aBuffer)
-{
-  SharedBufferManagerChild::sSharedBufferManagerChildSingleton->
-    DeallocGrallocBufferNow(aBuffer);
-}
-
-bool
-SharedBufferManagerChild::AllocGrallocBuffer(const gfx::IntSize& aSize,
-                                             const uint32_t& aFormat,
-                                             const uint32_t& aUsage,
-                                             mozilla::layers::MaybeMagicGrallocBufferHandle* aBuffer)
-{
-  if (aSize.width <= 0 || aSize.height <= 0) {
-    gfxDebug() << "Asking for gralloc of invalid size " << aSize.width << "x" << aSize.height;
-    return false;
-  }
-
-  if (InSharedBufferManagerChildThread()) {
-    return SharedBufferManagerChild::AllocGrallocBufferNow(aSize, aFormat, aUsage, aBuffer);
-  }
-
-  Monitor barrier("AllocSurfaceDescriptorGralloc Lock");
-  MonitorAutoLock autoMon(barrier);
-  bool done = false;
-
-  GetMessageLoop()->PostTask(
-    NewRunnableFunction(&AllocGrallocBufferSync,
-                        GrallocParam(aSize, aFormat, aUsage, aBuffer), &barrier, &done));
-
-  while (!done) {
-    barrier.Wait();
-  }
-  return true;
-}
-
-bool
-SharedBufferManagerChild::AllocGrallocBufferNow(const IntSize& aSize,
-                                                const uint32_t& aFormat,
-                                                const uint32_t& aUsage,
-                                                mozilla::layers::MaybeMagicGrallocBufferHandle* aHandle)
-{
-  // These are protected functions, we can just assert and ask the caller to test
-  MOZ_ASSERT(aSize.width >= 0 && aSize.height >= 0);
-
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  mozilla::layers::MaybeMagicGrallocBufferHandle handle;
-  if (!SendAllocateGrallocBuffer(aSize, aFormat, aUsage, &handle)) {
-    return false;
-  }
-  if (handle.type() != mozilla::layers::MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle) {
-    return false;
-  }
-  *aHandle = handle.get_MagicGrallocBufferHandle().mRef;
-
-  {
-    MutexAutoLock lock(mBufferMutex);
-    MOZ_ASSERT(mBuffers.count(handle.get_MagicGrallocBufferHandle().mRef.mKey)==0);
-    mBuffers[handle.get_MagicGrallocBufferHandle().mRef.mKey] = handle.get_MagicGrallocBufferHandle().mGraphicBuffer;
-  }
-  return true;
-#else
-  NS_RUNTIMEABORT("No GrallocBuffer for you");
-  return true;
-#endif
-}
-
-void
-SharedBufferManagerChild::DeallocGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aBuffer)
-{
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  NS_ASSERTION(aBuffer.type() != mozilla::layers::MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle, "We shouldn't try to do IPC with real buffer");
-  if (aBuffer.type() != mozilla::layers::MaybeMagicGrallocBufferHandle::TGrallocBufferRef) {
-    return;
-  }
-#endif
-
-  if (InSharedBufferManagerChildThread()) {
-    return SharedBufferManagerChild::DeallocGrallocBufferNow(aBuffer);
-  }
-
-  GetMessageLoop()->PostTask(NewRunnableFunction(&DeallocGrallocBufferSync, aBuffer));
-}
-
-void
-SharedBufferManagerChild::DeallocGrallocBufferNow(const mozilla::layers::MaybeMagicGrallocBufferHandle& aBuffer)
-{
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  NS_ASSERTION(aBuffer.type() != mozilla::layers::MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle, "We shouldn't try to do IPC with real buffer");
-
-  {
-    MutexAutoLock lock(mBufferMutex);
-    mBuffers.erase(aBuffer.get_GrallocBufferRef().mKey);
-  }
-  SendDropGrallocBuffer(aBuffer);
-#else
-  NS_RUNTIMEABORT("No GrallocBuffer for you");
-#endif
-}
-
-void
-SharedBufferManagerChild::DropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aHandle)
-{
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  int64_t bufferKey = -1;
-  if (aHandle.type() == mozilla::layers::MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle) {
-    bufferKey = aHandle.get_MagicGrallocBufferHandle().mRef.mKey;
-  } else if (aHandle.type() == mozilla::layers::MaybeMagicGrallocBufferHandle::TGrallocBufferRef) {
-    bufferKey = aHandle.get_GrallocBufferRef().mKey;
-  } else {
-    return;
-  }
-
-  {
-    MutexAutoLock lock(mBufferMutex);
-    mBuffers.erase(bufferKey);
-  }
-#endif
-}
-
-bool SharedBufferManagerChild::RecvDropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aHandle)
-{
-  DropGrallocBuffer(aHandle);
-  return true;
-}
-
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-android::sp<android::GraphicBuffer>
-SharedBufferManagerChild::GetGraphicBuffer(int64_t key)
-{
-  MutexAutoLock lock(mBufferMutex);
-  if (mBuffers.count(key) == 0) {
-    printf_stderr("SharedBufferManagerChild::GetGraphicBuffer -- invalid key");
-    return nullptr;
-  }
-  return mBuffers[key];
-}
-#endif
-
-} /* namespace layers */
-} /* namespace mozilla */
deleted file mode 100644
--- a/gfx/layers/ipc/SharedBufferManagerChild.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et tw=80 : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef SharedBufferManagerCHILD_H_
-#define SharedBufferManagerCHILD_H_
-
-#include "mozilla/layers/PSharedBufferManagerChild.h"
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-#include "mozilla/Mutex.h"
-#endif
-
-namespace base {
-class Thread;
-} // namespace base
-
-namespace mozilla {
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-class Mutex;
-#endif
-
-namespace layers {
-class SharedBufferManagerParent;
-
-struct GrallocParam {
-  gfx::IntSize size;
-  uint32_t format;
-  uint32_t usage;
-  mozilla::layers::MaybeMagicGrallocBufferHandle* buffer;
-
-  GrallocParam(const gfx::IntSize& aSize,
-               const uint32_t& aFormat,
-               const uint32_t& aUsage,
-               mozilla::layers::MaybeMagicGrallocBufferHandle* aBuffer)
-    : size(aSize)
-    , format(aFormat)
-    , usage(aUsage)
-    , buffer(aBuffer)
-  {}
-};
-
-class SharedBufferManagerChild : public PSharedBufferManagerChild {
-public:
-  SharedBufferManagerChild();
-  /**
-   * Creates the gralloc buffer manager with a dedicated thread for SharedBufferManagerChild.
-   *
-   * We may want to use a specific thread in the future. In this case, use
-   * CreateWithThread instead.
-   */
-  static void StartUp();
-
-  static PSharedBufferManagerChild*
-  StartUpInChildProcess(Transport* aTransport, ProcessId aOtherProcess);
-
-  /**
-   * Creates the SharedBufferManagerChild manager protocol.
-   */
-  static bool StartUpOnThread(base::Thread* aThread);
-
-  /**
-   * Destroys The SharedBufferManager protocol.
-   *
-   * The actual destruction happens synchronously on the SharedBufferManagerChild thread
-   * which means that if this function is called from another thread, the current
-   * thread will be paused until the destruction is done.
-   */
-  static void DestroyManager();
-
-  /**
-   * Destroys the grallob buffer manager calling DestroyManager, and destroys the
-   * SharedBufferManager's thread.
-   *
-   * If you don't want to destroy the thread, call DestroyManager directly
-   * instead.
-   */
-  static void ShutDown();
-
-  /**
-   * returns the singleton instance.
-   *
-   * can be called from any thread.
-   */
-  static SharedBufferManagerChild* GetSingleton();
-
-  /**
-   * Dispatches a task to the SharedBufferManagerChild thread to do the connection
-   */
-  void ConnectAsync(SharedBufferManagerParent* aParent);
-
-  /**
-   * Allocate GrallocBuffer remotely.
-  */
-  bool
-  AllocGrallocBuffer(const gfx::IntSize&, const uint32_t&, const uint32_t&, mozilla::layers::MaybeMagicGrallocBufferHandle*);
-
-  /**
-   * Deallocate a remotely allocated gralloc buffer.
-   * As gralloc buffer life cycle controlled by sp, this just break the sharing status of the underlying buffer
-   * and decrease the reference count on both side.
-   */
-  void
-  DeallocGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aBuffer);
-
-  void
-  DropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aHandle);
-
-  virtual bool RecvDropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aHandle);
-
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  android::sp<android::GraphicBuffer> GetGraphicBuffer(int64_t key);
-#endif
-
-  base::Thread* GetThread() const;
-
-  MessageLoop* GetMessageLoop() const;
-
-  static bool IsCreated();
-
-  static base::Thread* sSharedBufferManagerChildThread;
-  static SharedBufferManagerChild* sSharedBufferManagerChildSingleton;
-  static SharedBufferManagerParent* sSharedBufferManagerParentSingleton; // Only available in Chrome process
-
-protected:
-  /**
-   * Part of the allocation of gralloc SurfaceDescriptor that is
-   * executed on the SharedBufferManagerChild thread after invoking
-   * AllocSurfaceDescriptorGralloc.
-   *
-   * Must be called from the SharedBufferManagerChild thread.
-   */
-  bool
-  AllocGrallocBufferNow(const gfx::IntSize& aSize,
-                        const uint32_t& aFormat,
-                        const uint32_t& aUsage,
-                        mozilla::layers::MaybeMagicGrallocBufferHandle* aBuffer);
-
-  // Dispatched function
-  static void
-  AllocGrallocBufferSync(const GrallocParam& aParam,
-                         Monitor* aBarrier,
-                         bool* aDone);
-
-  /**
-   * Part of the deallocation of gralloc SurfaceDescriptor that is
-   * executed on the SharedBufferManagerChild thread after invoking
-   * DeallocSurfaceDescriptorGralloc.
-   *
-   * Must be called from the SharedBufferManagerChild thread.
-   */
-  void
-  DeallocGrallocBufferNow(const mozilla::layers::MaybeMagicGrallocBufferHandle& handle);
-
-  // dispatched function
-  static void
-  DeallocGrallocBufferSync(const mozilla::layers::MaybeMagicGrallocBufferHandle& handle);
-
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  std::map<int64_t, android::sp<android::GraphicBuffer> > mBuffers;
-  Mutex mBufferMutex;
-#endif
-};
-
-} /* namespace layers */
-} /* namespace mozilla */
-#endif /* SharedBufferManagerCHILD_H_*/
deleted file mode 100644
--- a/gfx/layers/ipc/SharedBufferManagerParent.cpp
+++ /dev/null
@@ -1,364 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et tw=80 : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "mozilla/layers/SharedBufferManagerParent.h"
-#include "base/message_loop.h"          // for MessageLoop
-#include "base/process.h"               // for ProcessId
-#include "base/task.h"                  // for CancelableTask, DeleteTask, etc
-#include "base/thread.h"
-#include "mozilla/Sprintf.h"            // for SprintfLiteral
-#include "mozilla/ipc/MessageChannel.h" // for MessageChannel, etc
-#include "mozilla/ipc/ProtocolUtils.h"
-#include "mozilla/ipc/Transport.h"      // for Transport
-#include "mozilla/Sprintf.h"
-#include "mozilla/UniquePtr.h"          // for UniquePtr
-#include "mozilla/Unused.h"
-#include "nsIMemoryReporter.h"
-#ifdef MOZ_WIDGET_GONK
-#include "mozilla/LinuxUtils.h"
-#include "ui/PixelFormat.h"
-#endif
-#include "nsPrintfCString.h"
-#include "nsThreadUtils.h"
-
-using namespace mozilla::ipc;
-#ifdef MOZ_WIDGET_GONK
-using namespace android;
-#endif
-using std::map;
-
-namespace mozilla {
-namespace layers {
-
-map<base::ProcessId, SharedBufferManagerParent* > SharedBufferManagerParent::sManagers;
-StaticAutoPtr<Monitor> SharedBufferManagerParent::sManagerMonitor;
-uint64_t SharedBufferManagerParent::sBufferKey(0);
-
-#ifdef MOZ_WIDGET_GONK
-class GrallocReporter final : public nsIMemoryReporter
-{
-public:
-  NS_DECL_ISUPPORTS
-
-  NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
-                            nsISupports* aData, bool aAnonymize) override
-  {
-    if (SharedBufferManagerParent::sManagerMonitor) {
-      SharedBufferManagerParent::sManagerMonitor->Lock();
-    }
-    map<base::ProcessId, SharedBufferManagerParent*>::iterator it;
-    for (it = SharedBufferManagerParent::sManagers.begin(); it != SharedBufferManagerParent::sManagers.end(); it++) {
-      base::ProcessId pid = it->first;
-      SharedBufferManagerParent *mgr = it->second;
-      if (!mgr) {
-        printf_stderr("GrallocReporter::CollectReports(): mgr is nullptr");
-        continue;
-      }
-
-      nsAutoCString pidName;
-      LinuxUtils::GetThreadName(pid, pidName);
-
-      MutexAutoLock lock(mgr->mLock);
-      std::map<int64_t, android::sp<android::GraphicBuffer> >::iterator buf_it;
-      for (buf_it = mgr->mBuffers.begin(); buf_it != mgr->mBuffers.end(); buf_it++) {
-        android::sp<android::GraphicBuffer> gb = buf_it->second;
-        int bpp = android::bytesPerPixel(gb->getPixelFormat());
-        int stride = gb->getStride();
-        int height = gb->getHeight();
-        int amount = bpp > 0
-          ? (stride * height * bpp)
-          // Special case for BSP specific formats (mainly YUV formats, count it as normal YUV buffer).
-          : (stride * height * 3 / 2);
-
-        nsPrintfCString gpath("gralloc/%s (pid=%d)/buffer(width=%d, height=%d, bpp=%d, stride=%d)",
-            pidName.get(), pid, gb->getWidth(), height, bpp, stride);
-
-        aHandleReport->Callback(
-          EmptyCString(), gpath, KIND_OTHER, UNITS_BYTES, amount,
-          NS_LITERAL_CSTRING(
-"Special RAM that can be shared between processes and directly accessed by "
-"both the CPU and GPU. Gralloc memory is usually a relatively precious "
-"resource, with much less available than generic RAM. When it's exhausted, "
-"graphics performance can suffer. This value can be incorrect because of race "
-"conditions."),
-          aData);
-      }
-    }
-    if (SharedBufferManagerParent::sManagerMonitor) {
-      SharedBufferManagerParent::sManagerMonitor->Unlock();
-    }
-    return NS_OK;
-  }
-
-protected:
-  ~GrallocReporter() {}
-};
-
-NS_IMPL_ISUPPORTS(GrallocReporter, nsIMemoryReporter)
-#endif
-
-void InitGralloc() {
-  NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
-#ifdef MOZ_WIDGET_GONK
-  RegisterStrongMemoryReporter(new GrallocReporter());
-#endif
-}
-
-/**
- * Task that deletes SharedBufferManagerParent on a specified thread.
- */
-class DeleteSharedBufferManagerParentTask : public Runnable
-{
-public:
-    explicit DeleteSharedBufferManagerParentTask(UniquePtr<SharedBufferManagerParent> aSharedBufferManager)
-        : mSharedBufferManager(Move(aSharedBufferManager)) {
-    }
-    NS_IMETHOD Run() override { return NS_OK; }
-private:
-    UniquePtr<SharedBufferManagerParent> mSharedBufferManager;
-};
-
-SharedBufferManagerParent::SharedBufferManagerParent(base::ProcessId aOwner, base::Thread* aThread)
-  : mThread(aThread)
-  , mDestroyed(false)
-  , mLock("SharedBufferManagerParent.mLock")
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  if (!sManagerMonitor) {
-    sManagerMonitor = new Monitor("Manager Monitor");
-  }
-
-  MonitorAutoLock lock(*sManagerMonitor.get());
-  NS_ASSERTION(NS_IsMainThread(), "Should be on main thread");
-  if (!aThread->IsRunning()) {
-    aThread->Start();
-  }
-
-  if (sManagers.count(aOwner) != 0) {
-    printf_stderr("SharedBufferManagerParent already exists.");
-  }
-  mOwner = aOwner;
-  sManagers[aOwner] = this;
-}
-
-SharedBufferManagerParent::~SharedBufferManagerParent()
-{
-  MonitorAutoLock lock(*sManagerMonitor.get());
-  sManagers.erase(mOwner);
-  delete mThread;
-}
-
-void
-SharedBufferManagerParent::ActorDestroy(ActorDestroyReason aWhy)
-{
-  MutexAutoLock lock(mLock);
-  mDestroyed = true;
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  mBuffers.clear();
-#endif
-  RefPtr<DeleteSharedBufferManagerParentTask> task =
-    new DeleteSharedBufferManagerParentTask(UniquePtr<SharedBufferManagerParent>(this));
-  NS_DispatchToMainThread(task.forget());
-}
-
-static void
-ConnectSharedBufferManagerInParentProcess(SharedBufferManagerParent* aManager,
-                                          Transport* aTransport,
-                                          base::ProcessId aOtherPid)
-{
-  aManager->Open(aTransport, aOtherPid, XRE_GetIOMessageLoop(), ipc::ParentSide);
-}
-
-PSharedBufferManagerParent* SharedBufferManagerParent::Create(Transport* aTransport,
-                                                              ProcessId aOtherPid)
-{
-  base::Thread* thread = nullptr;
-  char thrname[128];
-  SprintfLiteral(thrname, "BufMgrParent#%d", aOtherPid);
-  thread = new base::Thread(thrname);
-
-  SharedBufferManagerParent* manager = new SharedBufferManagerParent(aOtherPid, thread);
-  if (!thread->IsRunning()) {
-    thread->Start();
-  }
-  thread->message_loop()->PostTask(NewRunnableFunction(ConnectSharedBufferManagerInParentProcess,
-                                                       manager, aTransport, aOtherPid));
-  return manager;
-}
-
-bool SharedBufferManagerParent::RecvAllocateGrallocBuffer(const IntSize& aSize, const uint32_t& aFormat, const uint32_t& aUsage, mozilla::layers::MaybeMagicGrallocBufferHandle* aHandle)
-{
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-
-  *aHandle = null_t();
-
-  if (aFormat == 0 || aUsage == 0) {
-    printf_stderr("SharedBufferManagerParent::RecvAllocateGrallocBuffer -- format and usage must be non-zero");
-    return false;
-  }
-
-  if (aSize.width <= 0 || aSize.height <= 0) {
-    printf_stderr("SharedBufferManagerParent::RecvAllocateGrallocBuffer -- requested gralloc buffer size is invalid");
-    return false;
-  }
-
-  // If the requested size is too big (i.e. exceeds the commonly used max GL texture size)
-  // then we risk OOMing the parent process. It's better to just deny the allocation and
-  // kill the child process, which is what the following code does.
-  // TODO: actually use GL_MAX_TEXTURE_SIZE instead of hardcoding 4096
-  if (aSize.width > 4096 || aSize.height > 4096) {
-    printf_stderr("SharedBufferManagerParent::RecvAllocateGrallocBuffer -- requested gralloc buffer is too big.");
-    return false;
-  }
-
-  sp<GraphicBuffer> outgoingBuffer = new GraphicBuffer(aSize.width, aSize.height, aFormat, aUsage);
-  if (!outgoingBuffer.get() || outgoingBuffer->initCheck() != NO_ERROR) {
-    printf_stderr("SharedBufferManagerParent::RecvAllocateGrallocBuffer -- gralloc buffer allocation failed");
-    return true;
-  }
-
-  int64_t bufferKey;
-  {
-    MonitorAutoLock lock(*sManagerMonitor.get());
-    bufferKey = ++sBufferKey; 
-  }
-  GrallocBufferRef ref;
-  ref.mOwner = mOwner;
-  ref.mKey = bufferKey;
-  *aHandle = MagicGrallocBufferHandle(outgoingBuffer, ref);
-
-  {
-    MutexAutoLock lock(mLock);
-    mBuffers[bufferKey] = outgoingBuffer;
-  }
-#endif
-  return true;
-}
-
-bool SharedBufferManagerParent::RecvDropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& handle)
-{
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  NS_ASSERTION(handle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef, "We shouldn't interact with the real buffer!");
-  int64_t bufferKey = handle.get_GrallocBufferRef().mKey;
-  sp<GraphicBuffer> buf = GetGraphicBuffer(bufferKey);
-  MOZ_ASSERT(buf.get());
-  MutexAutoLock lock(mLock);
-  NS_ASSERTION(mBuffers.count(bufferKey) == 1, "No such buffer");
-  mBuffers.erase(bufferKey);
-
-  if(!buf.get()) {
-    printf_stderr("SharedBufferManagerParent::RecvDropGrallocBuffer -- invalid buffer key.");
-    return true;
-  }
-
-#endif
-  return true;
-}
-
-/*static*/
-void SharedBufferManagerParent::DropGrallocBufferSync(SharedBufferManagerParent* mgr, mozilla::layers::SurfaceDescriptor aDesc)
-{
-  mgr->DropGrallocBufferImpl(aDesc);
-}
-
-/*static*/
-void SharedBufferManagerParent::DropGrallocBuffer(ProcessId id, mozilla::layers::SurfaceDescriptor aDesc)
-{
-  if (aDesc.type() != SurfaceDescriptor::TSurfaceDescriptorGralloc) {
-    return;
-  }
-
-  MonitorAutoLock lock(*sManagerMonitor.get());
-  SharedBufferManagerParent* mgr = SharedBufferManagerParent::GetInstance(id);
-  if (!mgr) {
-    return;
-  }
-
-  MutexAutoLock mgrlock(mgr->mLock);
-  if (mgr->mDestroyed) {
-    return;
-  }
-
-  if (PlatformThread::CurrentId() == mgr->mThread->thread_id()) {
-    MOZ_CRASH("GFX: SharedBufferManagerParent::DropGrallocBuffer should not be called on SharedBufferManagerParent thread");
-  } else {
-    mgr->mThread->message_loop()->PostTask(
-                                      NewRunnableFunction(&DropGrallocBufferSync, mgr, aDesc));
-  }
-  return;
-}
-
-void SharedBufferManagerParent::DropGrallocBufferImpl(mozilla::layers::SurfaceDescriptor aDesc)
-{
-  MutexAutoLock lock(mLock);
-  if (mDestroyed) {
-    return;
-  }
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  int64_t key = -1;
-  MaybeMagicGrallocBufferHandle handle;
-  if (aDesc.type() == SurfaceDescriptor::TSurfaceDescriptorGralloc) {
-    handle = aDesc.get_SurfaceDescriptorGralloc().buffer();
-  } else {
-    return;
-  }
-
-  if (handle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef) {
-    key = handle.get_GrallocBufferRef().mKey;
-  } else if (handle.type() == MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle) {
-    key = handle.get_MagicGrallocBufferHandle().mRef.mKey;
-  }
-
-  NS_ASSERTION(key != -1, "Invalid buffer key");
-  NS_ASSERTION(mBuffers.count(key) == 1, "No such buffer");
-  mBuffers.erase(key);
-  mozilla::Unused << SendDropGrallocBuffer(handle);
-#endif
-}
-
-MessageLoop* SharedBufferManagerParent::GetMessageLoop()
-{
-  return mThread->message_loop();
-}
-
-SharedBufferManagerParent* SharedBufferManagerParent::GetInstance(ProcessId id)
-{
-  NS_ASSERTION(sManagers.count(id) == 1, "No BufferManager for the process");
-  if (sManagers.count(id) == 1) {
-    return sManagers[id];
-  } else {
-    return nullptr;
-  }
-}
-
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-android::sp<android::GraphicBuffer>
-SharedBufferManagerParent::GetGraphicBuffer(int64_t key)
-{
-  MutexAutoLock lock(mLock);
-  if (mBuffers.count(key) == 1) {
-    return mBuffers[key];
-  } else {
-    // The buffer can be dropped, or invalid
-    printf_stderr("SharedBufferManagerParent::GetGraphicBuffer -- invalid key");
-    return nullptr;
-  }
-}
-
-android::sp<android::GraphicBuffer>
-SharedBufferManagerParent::GetGraphicBuffer(GrallocBufferRef aRef)
-{
-  MonitorAutoLock lock(*sManagerMonitor.get());
-  SharedBufferManagerParent* parent = GetInstance(aRef.mOwner);
-  if (!parent) {
-    return nullptr;
-  }
-  return parent->GetGraphicBuffer(aRef.mKey);
-}
-#endif
-
-} /* namespace layers */
-} /* namespace mozilla */
deleted file mode 100644
--- a/gfx/layers/ipc/SharedBufferManagerParent.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et tw=80 : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef SharedBufferManagerPARENT_H_
-#define SharedBufferManagerPARENT_H_
-
-#include "mozilla/Atomics.h"          // for Atomic
-#include "mozilla/layers/PSharedBufferManagerParent.h"
-#include "mozilla/StaticPtr.h"
-
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-#include "mozilla/ipc/ProtocolUtils.h"
-#include "mozilla/Mutex.h"            // for Mutex
-
-namespace android {
-class GraphicBuffer;
-}
-#endif
-
-namespace base {
-class Thread;
-} // namespace base
-
-namespace mozilla {
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-class Mutex;
-#endif
-
-namespace layers {
-
-class SharedBufferManagerParent : public PSharedBufferManagerParent
-{
-friend class GrallocReporter;
-public:
-  /**
-   * Create a SharedBufferManagerParent for child process, and link to the child side before leaving
-   */
-  static PSharedBufferManagerParent* Create(Transport* aTransport, ProcessId aOtherProcess);
-
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  android::sp<android::GraphicBuffer> GetGraphicBuffer(int64_t key);
-  static android::sp<android::GraphicBuffer> GetGraphicBuffer(GrallocBufferRef aRef);
-#endif
-  /**
-   * Create a SharedBufferManagerParent but do not open the link
-   */
-  SharedBufferManagerParent(ProcessId aOwner, base::Thread* aThread);
-  virtual ~SharedBufferManagerParent();
-
-  /**
-   * When the IPC channel down or something bad make this Manager die, clear all the buffer reference!
-   */
-  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
-
-  virtual bool RecvAllocateGrallocBuffer(const IntSize&, const uint32_t&, const uint32_t&, mozilla::layers::MaybeMagicGrallocBufferHandle*) override;
-  virtual bool RecvDropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& handle) override;
-
-  /**
-   * Break the buffer's sharing state, decrease buffer reference for both side
-   */
-  static void DropGrallocBuffer(ProcessId id, mozilla::layers::SurfaceDescriptor aDesc);
-
-  MessageLoop* GetMessageLoop();
-
-protected:
-
-  /**
-   * Break the buffer's sharing state, decrease buffer reference for both side
-   *
-   * Must be called from SharedBufferManagerParent's thread
-   */
-  void DropGrallocBufferImpl(mozilla::layers::SurfaceDescriptor aDesc);
-
-  // dispatched function
-  static void DropGrallocBufferSync(SharedBufferManagerParent* mgr, mozilla::layers::SurfaceDescriptor aDesc);
-
-  /**
-   * Function for find the buffer owner, most buffer passing on IPC contains only owner/key pair.
-   * Use these function to access the real buffer.
-   * Caller needs to hold sManagerMonitor.
-   */
-  static SharedBufferManagerParent* GetInstance(ProcessId id);
-
-  /**
-   * All living SharedBufferManager instances used to find the buffer owner, and parent->child IPCs
-   */
-  static std::map<base::ProcessId, SharedBufferManagerParent*> sManagers;
-
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  /**
-   * Buffers owned by this SharedBufferManager pair
-   */
-  std::map<int64_t, android::sp<android::GraphicBuffer> > mBuffers;
-#endif
-  
-  base::ProcessId mOwner;
-  base::Thread* mThread;
-  bool mDestroyed;
-  Mutex mLock;
-
-  static uint64_t sBufferKey;
-  static StaticAutoPtr<Monitor> sManagerMonitor;
-};
-
-} /* namespace layers */
-} /* namespace mozilla */
-#endif /* SharedBufferManagerPARENT_H_ */
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -21,17 +21,16 @@ EXPORTS += [
     'composite/CompositableHost.h',
     'composite/ImageHost.h',
     'CompositorTypes.h',
     'CopyableCanvasLayer.h',
     'D3D9SurfaceImage.h',
     'FrameMetrics.h',
     'GLImages.h',
     'GPUVideoImage.h',
-    'GrallocImages.h',
     'ImageContainer.h',
     'ImageLayers.h',
     'ImageTypes.h',
     'IMFYCbCrImage.h',
     'ipc/ThreadSafeRefcountingWithMainThreadDestruction.h',
     'Layers.h',
     'LayerScope.h',
     'LayersLogging.h',
@@ -181,29 +180,25 @@ EXPORTS.mozilla.layers += [
     'ipc/KnowsCompositor.h',
     'ipc/LayerAnimationUtils.h',
     'ipc/LayerTransactionChild.h',
     'ipc/LayerTransactionParent.h',
     'ipc/LayerTreeOwnerTracker.h',
     'ipc/RemoteContentController.h',
     'ipc/ShadowLayerChild.h',
     'ipc/ShadowLayers.h',
-    'ipc/SharedBufferManagerChild.h',
-    'ipc/SharedBufferManagerParent.h',
     'ipc/SharedPlanarYCbCrImage.h',
     'ipc/SharedRGBImage.h',
     'ipc/TextureForwarder.h',
     'ipc/VideoBridgeChild.h',
     'ipc/VideoBridgeParent.h',
     'LayerMetricsWrapper.h',
     'LayersTypes.h',
     'opengl/CompositingRenderTargetOGL.h',
     'opengl/CompositorOGL.h',
-    'opengl/GrallocTextureClient.h',
-    'opengl/GrallocTextureHost.h',
     'opengl/MacIOSurfaceTextureClientOGL.h',
     'opengl/MacIOSurfaceTextureHostOGL.h',
     'opengl/TextureClientOGL.h',
     'opengl/TextureHostOGL.h',
     'PersistentBufferProvider.h',
     'RenderTrace.h',
     'TextureWrapperImage.h',
     'TransactionIdAllocator.h',
@@ -238,44 +233,16 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'coco
         'opengl/GLManager.cpp',
     ]
     SOURCES += [
         'ipc/ShadowLayerUtilsMac.cpp',
         'MacIOSurfaceHelpers.cpp',
         'MacIOSurfaceImage.cpp',
     ]
 
-# NB: Gralloc is available on other platforms that use the android GL
-# libraries, but only Gonk is able to use it reliably because Gecko
-# has full system permissions there.
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    EXPORTS.mozilla.layers += [
-        'basic/GrallocTextureHostBasic.h',
-        'ipc/ShadowLayerUtilsGralloc.h',
-    ]
-    UNIFIED_SOURCES += [
-        'basic/GrallocTextureHostBasic.cpp',
-        'GrallocImages.cpp',
-        'opengl/EGLImageHelpers.cpp',
-        'opengl/GrallocTextureClient.cpp',
-        'opengl/GrallocTextureHost.cpp',
-    ]
-    LOCAL_INCLUDES += ['/widget/gonk']
-    if CONFIG['ANDROID_VERSION'] >= '21':
-        LOCAL_INCLUDES += [
-             '%' + '%s/%s' % (CONFIG['ANDROID_SOURCE'], d) for d in [
-                 'system/core/libsync/include'
-             ]
-        ]
-    SOURCES += [
-        'ipc/GonkNativeHandle.cpp',
-        'ipc/GonkNativeHandleUtils.cpp',
-        'ipc/ShadowLayerUtilsGralloc.cpp',
-    ]
-
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     UNIFIED_SOURCES += [
         'apz/src/AndroidAPZ.cpp',
     ]
 
 UNIFIED_SOURCES += [
     'apz/public/IAPZCTreeManager.cpp',
     'apz/src/APZCTreeManager.cpp',
@@ -381,18 +348,16 @@ UNIFIED_SOURCES += [
     'ipc/LayerAnimationUtils.cpp',
     'ipc/LayerTransactionChild.cpp',
     'ipc/LayerTransactionParent.cpp',
     'ipc/LayerTreeOwnerTracker.cpp',
     'ipc/RemoteContentController.cpp',
     'ipc/ShadowLayerChild.cpp',
     'ipc/ShadowLayerParent.cpp',
     'ipc/ShadowLayers.cpp',
-    'ipc/SharedBufferManagerChild.cpp',
-    'ipc/SharedBufferManagerParent.cpp',
     'ipc/SharedPlanarYCbCrImage.cpp',
     'ipc/SharedRGBImage.cpp',
     'ipc/VideoBridgeChild.cpp',
     'ipc/VideoBridgeParent.cpp',
     'LayerScope.cpp',
     'LayersLogging.cpp',
     'LayerSorter.cpp',
     'LayersTypes.cpp',
@@ -442,17 +407,16 @@ IPDL_SOURCES = [
     'ipc/PAPZ.ipdl',
     'ipc/PAPZCTreeManager.ipdl',
     'ipc/PCompositable.ipdl',
     'ipc/PCompositorBridge.ipdl',
     'ipc/PImageBridge.ipdl',
     'ipc/PImageContainer.ipdl',
     'ipc/PLayer.ipdl',
     'ipc/PLayerTransaction.ipdl',
-    'ipc/PSharedBufferManager.ipdl',
     'ipc/PTexture.ipdl',
     'ipc/PVideoBridge.ipdl',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
     '/docshell/base',  # for nsDocShell.h
@@ -464,32 +428,16 @@ LOCAL_INCLUDES += [
 FINAL_LIBRARY = 'xul'
 
 if CONFIG['MOZ_DEBUG']:
     DEFINES['D3D_DEBUG_INFO'] = True
 
 if CONFIG['MOZ_ENABLE_D3D10_LAYER']:
     DEFINES['MOZ_ENABLE_D3D10_LAYER'] = True
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    if CONFIG['ANDROID_VERSION'] >= '17':
-        includes = [
-            'frameworks/av/include/media/stagefright',
-            'frameworks/native/include/media/openmax',
-        ]
-    else:
-        includes = [
-            'frameworks/base/include/media/stagefright',
-            'frameworks/base/include/media/stagefright/openmax',
-        ]
-
-    LOCAL_INCLUDES += [
-        '%' + '%s/%s' % (CONFIG['ANDROID_SOURCE'], d) for d in includes
-    ]
-
 if CONFIG['ENABLE_TESTS']:
     DIRS += ['apz/test/gtest']
 
 MOCHITEST_MANIFESTS += ['apz/test/mochitest/mochitest.ini']
 MOCHITEST_CHROME_MANIFESTS += ['apz/test/mochitest/chrome.ini']
 
 CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
 CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -143,22 +143,16 @@ CompositorOGL::CreateContext()
     context = gl::GLContextProvider::CreateForCompositorWidget(mWidget,
                 gfxVars::RequiresAcceleratedGLContextForCompositorOGL());
   }
 
   if (!context) {
     NS_WARNING("Failed to create CompositorOGL context");
   }
 
-#ifdef MOZ_WIDGET_GONK
-  MOZ_ASSERT(widget);
-  widget->SetNativeData(
-    NS_NATIVE_OPENGL_CONTEXT, reinterpret_cast<uintptr_t>(context.get()));
-#endif
-
   return context.forget();
 }
 
 void
 CompositorOGL::Destroy()
 {
   Compositor::Destroy();
 
@@ -174,21 +168,16 @@ CompositorOGL::Destroy()
 }
 
 void
 CompositorOGL::CleanupResources()
 {
   if (!mGLContext)
     return;
 
-#ifdef MOZ_WIDGET_GONK
-  mWidget->RealWidget()->SetNativeData(
-    NS_NATIVE_OPENGL_CONTEXT, reinterpret_cast<uintptr_t>(nullptr));
-#endif
-
   RefPtr<GLContext> ctx = mGLContext->GetSharedContext();
   if (!ctx) {
     ctx = mGLContext;
   }
 
   if (!ctx->MakeCurrent()) {
     // Leak resources!
     mQuadVBO = 0;
@@ -1773,21 +1762,17 @@ CompositorOGL::BlitTextureImageHelper()
 }
 
 
 
 GLuint
 CompositorOGL::GetTemporaryTexture(GLenum aTarget, GLenum aUnit)
 {
   if (!mTexturePool) {
-#ifdef MOZ_WIDGET_GONK
-    mTexturePool = new PerFrameTexturePoolOGL(gl());
-#else
     mTexturePool = new PerUnitTexturePoolOGL(gl());
-#endif
   }
   return mTexturePool->GetTexture(aTarget, aUnit);
 }
 
 GLuint
 PerUnitTexturePoolOGL::GetTexture(GLenum aTarget, GLenum aTextureUnit)
 {
   if (mTextureTarget == 0) {
--- a/gfx/layers/opengl/CompositorOGL.h
+++ b/gfx/layers/opengl/CompositorOGL.h
@@ -28,39 +28,31 @@
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_ASSERTION, NS_WARNING
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsTArray.h"                   // for AutoTArray, nsTArray, etc
 #include "nsThreadUtils.h"              // for nsRunnable
 #include "nsXULAppAPI.h"                // for XRE_GetProcessType
 #include "nscore.h"                     // for NS_IMETHOD
 
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
-#include "nsTHashtable.h"               // for nsTHashtable
-#endif
-
 class nsIWidget;
 
 namespace mozilla {
 
 namespace layers {
 
 class CompositingRenderTarget;
 class CompositingRenderTargetOGL;
 class DataTextureSource;
 class GLManagerCompositor;
 class TextureSource;
 struct Effect;
 struct EffectChain;
 class GLBlitTextureImageHelper;
 
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
-class ImageHostOverlay;
-#endif
-
 /**
  * Interface for pools of temporary gl textures for the compositor.
  * The textures are fully owned by the pool, so the latter is responsible
  * calling fDeleteTextures accordingly.
  * Users of GetTexture receive a texture that is only valid for the duration
  * of the current frame.
  * This is primarily intended for direct texturing APIs that need to attach
  * shared objects (such as an EGLImage) to a gl texture.
@@ -254,35 +246,25 @@ public:
     return LayersBackend::LAYERS_OPENGL;
   }
 
   virtual void Pause() override;
   virtual bool Resume() override;
 
   virtual bool HasImageHostOverlays() override
   {
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
-    return mImageHostOverlays.Count() > 0;
-#else
     return false;
-#endif
   }
 
   virtual void AddImageHostOverlay(ImageHostOverlay* aOverlay) override
   {
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
-    mImageHostOverlays.PutEntry(aOverlay);
-#endif
   }
 
   virtual void RemoveImageHostOverlay(ImageHostOverlay* aOverlay) override
   {
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
-    mImageHostOverlays.RemoveEntry(aOverlay);
-#endif
   }
 
   GLContext* gl() const { return mGLContext; }
   /**
    * Clear the program state. This must be called
    * before operating on the GLContext directly. */
   void ResetProgram();
 
@@ -504,19 +486,14 @@ private:
 
   /**
    * Size of the OpenGL context's primary framebuffer in pixels. Used by
    * FlipY for the y-flipping calculation and by the DEAA shader.
    */
   gfx::IntSize mViewportSize;
 
   ShaderProgramOGL *mCurrentProgram;
-
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
-  nsTHashtable<nsPtrHashKey<ImageHostOverlay> > mImageHostOverlays;
-#endif
-
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif /* MOZILLA_GFX_COMPOSITOROGL_H */
deleted file mode 100644
--- a/gfx/layers/opengl/GrallocTextureClient.cpp
+++ /dev/null
@@ -1,460 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-//  * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifdef MOZ_WIDGET_GONK
-
-#include "mozilla/gfx/2D.h"
-#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
-#include "mozilla/layers/GrallocTextureClient.h"
-#include "mozilla/layers/TextureForwarder.h"
-#include "mozilla/layers/ISurfaceAllocator.h"
-#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
-#include "mozilla/layers/SharedBufferManagerChild.h"
-#include "gfx2DGlue.h"
-#include "gfxPrefs.h" // for gfxPrefs
-#include "SharedSurfaceGralloc.h"
-
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-#include <ui/Fence.h>
-#endif
-
-namespace mozilla {
-namespace layers {
-
-using namespace mozilla::gfx;
-using namespace android;
-
-static bool
-DisableGralloc(SurfaceFormat aFormat, const gfx::IntSize& aSizeHint)
-{
-  if (gfxPrefs::DisableGralloc()) {
-    return true;
-  }
-  if (aFormat == gfx::SurfaceFormat::A8) {
-    return true;
-  }
-
-  return false;
-}
-
-gfx::SurfaceFormat
-SurfaceFormatForPixelFormat(android::PixelFormat aFormat)
-{
-  switch (aFormat) {
-  case PIXEL_FORMAT_RGBA_8888:
-    return gfx::SurfaceFormat::R8G8B8A8;
-  case PIXEL_FORMAT_BGRA_8888:
-    return gfx::SurfaceFormat::B8G8R8A8;
-  case PIXEL_FORMAT_RGBX_8888:
-    return gfx::SurfaceFormat::R8G8B8X8;
-  case PIXEL_FORMAT_RGB_565:
-    return gfx::SurfaceFormat::R5G6B5_UINT16;
-  case HAL_PIXEL_FORMAT_YV12:
-    return gfx::SurfaceFormat::YUV;
-  default:
-    return gfx::SurfaceFormat::UNKNOWN;
-  }
-}
-
-bool
-IsGrallocRBSwapped(gfx::SurfaceFormat aFormat) {
-  switch (aFormat) {
-  case gfx::SurfaceFormat::B8G8R8A8:
-  case gfx::SurfaceFormat::B8G8R8X8:
-    return true;
-  default:
-    return false;
-  }
-}
-
-uint32_t GetAndroidFormat(gfx::SurfaceFormat aFormat)
-{
-  switch (aFormat) {
-  case gfx::SurfaceFormat::R8G8B8A8:
-  case gfx::SurfaceFormat::B8G8R8A8:
-    return android::PIXEL_FORMAT_RGBA_8888;
-  case gfx::SurfaceFormat::R8G8B8X8:
-  case gfx::SurfaceFormat::B8G8R8X8:
-    return android::PIXEL_FORMAT_RGBX_8888;
-  case gfx::SurfaceFormat::R5G6B5_UINT16:
-    return android::PIXEL_FORMAT_RGB_565;
-  case gfx::SurfaceFormat::YUV:
-    return HAL_PIXEL_FORMAT_YV12;
-  case gfx::SurfaceFormat::A8:
-    NS_WARNING("gralloc does not support SurfaceFormat::A8");
-  default:
-    NS_WARNING("Unsupported surface format");
-    return android::PIXEL_FORMAT_UNKNOWN;
-  }
-}
-
-GrallocTextureData::GrallocTextureData(MaybeMagicGrallocBufferHandle aGrallocHandle,
-                                       gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
-                                       gfx::BackendType aMoz2DBackend)
-: mSize(aSize)
-, mFormat(aFormat)
-, mMoz2DBackend(aMoz2DBackend)
-, mGrallocHandle(aGrallocHandle)
-, mMappedBuffer(nullptr)
-, mMediaBuffer(nullptr)
-{
-  mGraphicBuffer = GetGraphicBufferFrom(aGrallocHandle);
-  MOZ_COUNT_CTOR(GrallocTextureData);
-}
-
-GrallocTextureData::~GrallocTextureData()
-{
-  MOZ_COUNT_DTOR(GrallocTextureData);
-}
-
-void
-GrallocTextureData::Deallocate(LayersIPCChannel* aAllocator)
-{
-  MOZ_ASSERT(aAllocator);
-  if (aAllocator && aAllocator->IPCOpen()) {
-    SharedBufferManagerChild::GetSingleton()->DeallocGrallocBuffer(mGrallocHandle);
-  }
-
-  mGrallocHandle = null_t();
-  mGraphicBuffer = nullptr;
-}
-
-void
-GrallocTextureData::Forget(LayersIPCChannel* aAllocator)
-{
-  MOZ_ASSERT(aAllocator);
-  if (aAllocator && aAllocator->IPCOpen()) {
-    SharedBufferManagerChild::GetSingleton()->DropGrallocBuffer(mGrallocHandle);
-  }
-
-  mGrallocHandle = null_t();
-  mGraphicBuffer = nullptr;
-}
-
-void
-GrallocTextureData::FillInfo(TextureData::Info& aInfo) const
-{
-  aInfo.size = mSize;
-  aInfo.format = mFormat;
-  aInfo.hasIntermediateBuffer = false;
-  aInfo.hasSynchronization = true;
-  aInfo.supportsMoz2D = true;
-  aInfo.canExposeMappedData = true;
-}
-
-bool
-GrallocTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
-{
-  aOutDescriptor = SurfaceDescriptorGralloc(mGrallocHandle, gfx::IsOpaque(mFormat));
-  return true;
-}
-
-void
-GrallocTextureData::WaitForFence(FenceHandle* aFence)
-{
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION < 21 && ANDROID_VERSION >= 17
-   if (aFence && aFence->IsValid()) {
-     RefPtr<FenceHandle::FdObj> fdObj = aFence->GetAndResetFdObj();
-     android::sp<Fence> fence = new Fence(fdObj->GetAndResetFd());
-#if ANDROID_VERSION == 17
-     fence->waitForever(1000, "GrallocTextureData::Lock");
-     // 1000 is what Android uses. It is a warning timeout in ms.
-     // This timeout was removed in ANDROID_VERSION 18.
-#else
-     fence->waitForever("GrallocTextureData::Lock");
-#endif
-   }
-#endif
-}
-
-bool
-GrallocTextureData::Lock(OpenMode aMode, FenceHandle* aReleaseFence)
-{
-  MOZ_ASSERT(!mMappedBuffer);
-
-  uint32_t usage = 0;
-  if (aMode & OpenMode::OPEN_READ) {
-    usage |= GRALLOC_USAGE_SW_READ_OFTEN;
-  }
-  if (aMode & OpenMode::OPEN_WRITE) {
-    usage |= GRALLOC_USAGE_SW_WRITE_OFTEN;
-  }
-
-  void** mappedBufferPtr = reinterpret_cast<void**>(&mMappedBuffer);
-
-  int32_t rv = 0;
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
-  if (aReleaseFence) {
-    RefPtr<FenceHandle::FdObj> fdObj = aReleaseFence->GetAndResetFdObj();
-    rv = mGraphicBuffer->lockAsync(usage, mappedBufferPtr,
-                                   fdObj->GetAndResetFd());
-  } else {
-    rv = mGraphicBuffer->lock(usage, mappedBufferPtr);
-  }
-#else
-  // older versions of android don't have lockAsync
-  WaitForFence(aReleaseFence);
-  rv = mGraphicBuffer->lock(usage, mappedBufferPtr);
-#endif
-
-  if (rv) {
-    mMappedBuffer = nullptr;
-    NS_WARNING("Couldn't lock graphic buffer");
-    return false;
-  }
-
-  return true;
-}
-
-void
-GrallocTextureData::Unlock()
-{
-  MOZ_ASSERT(mMappedBuffer);
-  mMappedBuffer = nullptr;
-  mGraphicBuffer->unlock();
-}
-
-already_AddRefed<gfx::DrawTarget>
-GrallocTextureData::BorrowDrawTarget()
-{
-  MOZ_ASSERT(mMappedBuffer);
-  if (!mMappedBuffer) {
-    return nullptr;
-  }
-  long byteStride = mGraphicBuffer->getStride() * BytesPerPixel(mFormat);
-  return gfxPlatform::CreateDrawTargetForData(mMappedBuffer, mSize,
-                                              byteStride, mFormat);
-}
-
-bool
-GrallocTextureData::BorrowMappedData(MappedTextureData& aMap)
-{
-  if (mFormat == gfx::SurfaceFormat::YUV || !mMappedBuffer) {
-    return false;
-  }
-
-  aMap.data = mMappedBuffer;
-  aMap.size = mSize;
-  aMap.stride = mGraphicBuffer->getStride() * BytesPerPixel(mFormat);
-  aMap.format = mFormat;
-
-  return true;
-}
-
-bool
-GrallocTextureData::UpdateFromSurface(gfx::SourceSurface* aSurface)
-{
-  MOZ_ASSERT(mMappedBuffer, "Calling TextureClient::BorrowDrawTarget without locking :(");
-
-  if (!mMappedBuffer) {
-    return false;
-  }
-
-  RefPtr<DataSourceSurface> srcSurf = aSurface->GetDataSurface();
-
-  if (!srcSurf) {
-    gfxCriticalError() << "Failed to GetDataSurface in UpdateFromSurface (GTC).";
-    return false;
-  }
-
-  gfx::SurfaceFormat format = SurfaceFormatForPixelFormat(mGraphicBuffer->getPixelFormat());
-  if (mSize != srcSurf->GetSize() || mFormat != srcSurf->GetFormat()) {
-    gfxCriticalError() << "Attempt to update texture client from a surface with a different size or format! This: " << mSize << " " << format << " Other: " << srcSurf->GetSize() << " " << srcSurf->GetFormat();
-    return false;
-  }
-
-  long pixelStride = mGraphicBuffer->getStride();
-  long byteStride = pixelStride * BytesPerPixel(format);
-
-  DataSourceSurface::MappedSurface sourceMap;
-
-  if (!srcSurf->Map(DataSourceSurface::READ, &sourceMap)) {
-    gfxCriticalError() << "Failed to map source surface for UpdateFromSurface (GTC).";
-    return false;
-  }
-
-  for (int y = 0; y < srcSurf->GetSize().height; y++) {
-    memcpy(mMappedBuffer + byteStride * y,
-           sourceMap.mData + sourceMap.mStride * y,
-           srcSurf->GetSize().width * BytesPerPixel(srcSurf->GetFormat()));
-  }
-
-  srcSurf->Unmap();
-
-  return true;
-}
-
-// static
-GrallocTextureData*
-GrallocTextureData::Create(gfx::IntSize aSize, AndroidFormat aAndroidFormat,
-                           gfx::BackendType aMoz2dBackend, uint32_t aUsage,
-                           LayersIPCChannel* aAllocator)
-{
-  if (!aAllocator || !aAllocator->IPCOpen()) {
-    return nullptr;
-  }
-  gfx::SurfaceFormat format;
-  switch (aAndroidFormat) {
-  case android::PIXEL_FORMAT_RGBA_8888:
-    format = gfx::SurfaceFormat::B8G8R8A8;
-    break;
-  case android::PIXEL_FORMAT_BGRA_8888:
-    format = gfx::SurfaceFormat::B8G8R8A8;
-    break;
-  case android::PIXEL_FORMAT_RGBX_8888:
-    format = gfx::SurfaceFormat::B8G8R8X8;
-    break;
-  case android::PIXEL_FORMAT_RGB_565:
-    format = gfx::SurfaceFormat::R5G6B5_UINT16;
-    break;
-  case HAL_PIXEL_FORMAT_YV12:
-    format = gfx::SurfaceFormat::YUV;
-    break;
-  default:
-    format = gfx::SurfaceFormat::UNKNOWN;
-  }
-
-  if (DisableGralloc(format, aSize)) {
-    return nullptr;
-  }
-
-  MaybeMagicGrallocBufferHandle handle;
-  if (!SharedBufferManagerChild::GetSingleton()->AllocGrallocBuffer(aSize, aAndroidFormat, aUsage, &handle)) {
-    return nullptr;
-  }
-
-  sp<GraphicBuffer> graphicBuffer = GetGraphicBufferFrom(handle);
-  if (!graphicBuffer.get()) {
-    return nullptr;
-  }
-
-  if (graphicBuffer->initCheck() != NO_ERROR) {
-    return nullptr;
-  }
-
-  return new GrallocTextureData(handle, aSize, format, aMoz2dBackend);
-}
-
-// static
-GrallocTextureData*
-GrallocTextureData::CreateForDrawing(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
-                                     gfx::BackendType aMoz2dBackend,
-                                     LayersIPCChannel* aAllocator)
-{
-  if (DisableGralloc(aFormat, aSize)) {
-    return nullptr;
-  }
-
-#if ANDROID_VERSION <= 15
-  // Adreno 200 has a problem of drawing gralloc buffer width less than 64 and
-  // drawing gralloc buffer with a height 9px-16px.
-  // See Bug 983971.
-  // We only have this restriction in TextureClients that we'll use for drawing
-  // (not with WebGL for instance). Not sure why that's OK, but we have tests that
-  // rely on being able to create 32x32 webgl canvases with gralloc, so moving
-  // this check in DisableGralloc will break them.
-  if (aSize.width < 64 || aSize.height < 32) {
-    return nullptr;
-  }
-#endif
-
-  uint32_t usage = android::GraphicBuffer::USAGE_SW_READ_OFTEN |
-                   android::GraphicBuffer::USAGE_SW_WRITE_OFTEN |
-                   android::GraphicBuffer::USAGE_HW_TEXTURE;
-  auto data =  GrallocTextureData::Create(aSize, GetAndroidFormat(aFormat),
-                                          aMoz2dBackend, usage, aAllocator);
-
-  if (!data) {
-    return nullptr;
-  }
-
-  DebugOnly<gfx::SurfaceFormat> grallocFormat =
-    SurfaceFormatForPixelFormat(data->mGraphicBuffer->getPixelFormat());
-  // mFormat may be different from the format the graphic buffer reports if we
-  // swap the R and B channels but we should always have at least the same bytes
-  // per pixel!
-  MOZ_ASSERT(BytesPerPixel(data->mFormat) == BytesPerPixel(grallocFormat));
-
-  return data;
-}
-
-TextureFlags
-GrallocTextureData::GetTextureFlags() const
-{
-  if (IsGrallocRBSwapped(mFormat)) {
-    return TextureFlags::RB_SWAPPED;
-  }
-  return TextureFlags::NO_FLAGS;
-}
-
-
-// static
-GrallocTextureData*
-GrallocTextureData::CreateForYCbCr(gfx::IntSize aYSize, gfx::IntSize aCbCrSize,
-                                   LayersIPCChannel* aAllocator)
-{
-  MOZ_ASSERT(aYSize.width == aCbCrSize.width * 2);
-  MOZ_ASSERT(aYSize.height == aCbCrSize.height * 2);
-  return GrallocTextureData::Create(aYSize, HAL_PIXEL_FORMAT_YV12,
-                                    gfx::BackendType::NONE,
-                                    android::GraphicBuffer::USAGE_SW_READ_OFTEN,
-                                    aAllocator);
-}
-
-// static
-GrallocTextureData*
-GrallocTextureData::CreateForGLRendering(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
-                                         LayersIPCChannel* aAllocator)
-{
-  if (aFormat == gfx::SurfaceFormat::YUV) {
-    return nullptr;
-  }
-  uint32_t usage = android::GraphicBuffer::USAGE_HW_RENDER |
-                   android::GraphicBuffer::USAGE_HW_TEXTURE;
-  return GrallocTextureData::Create(aSize, GetAndroidFormat(aFormat),
-                                    gfx::BackendType::NONE, usage, aAllocator);
-}
-
-// static
-already_AddRefed<TextureClient>
-GrallocTextureData::TextureClientFromSharedSurface(gl::SharedSurface* abstractSurf,
-                                                   TextureFlags flags)
-{
-  auto surf = gl::SharedSurface_Gralloc::Cast(abstractSurf);
-
-  RefPtr<TextureClient> ret = surf->GetTextureClient();
-
-  TextureFlags mask = TextureFlags::ORIGIN_BOTTOM_LEFT |
-                      TextureFlags::RB_SWAPPED |
-                      TextureFlags::NON_PREMULTIPLIED;
-  TextureFlags required = flags & mask;
-  TextureFlags present = ret->GetFlags() & mask;
-
-  if (present != required) {
-    printf_stderr("Present flags: 0x%x. Required: 0x%x.\n",
-                  (uint32_t)present,
-                  (uint32_t)required);
-    MOZ_CRASH("Flag requirement mismatch.");
-  }
-  return ret.forget();
-}
-
-TextureData*
-GrallocTextureData::CreateSimilar(LayersIPCChannel* aAllocator,
-                                  LayersBackend aLayersBackend,
-                                  TextureFlags aFlags,
-                                  TextureAllocationFlags aAllocFlags) const
-{
-  if (mFormat == gfx::SurfaceFormat::YUV) {
-    return GrallocTextureData::CreateForYCbCr(mSize, mSize*2, aAllocator);
-  } else {
-    return GrallocTextureData::CreateForDrawing(mSize, mFormat, mMoz2DBackend, aAllocator);
-  }
-}
-
-} // namesapace layers
-} // namesapace mozilla
-
-#endif // MOZ_WIDGET_GONK
deleted file mode 100644
--- a/gfx/layers/opengl/GrallocTextureClient.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-//  * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef MOZILLA_GFX_GRALLOCTEXTURECLIENT_H
-#define MOZILLA_GFX_GRALLOCTEXTURECLIENT_H
-#ifdef MOZ_WIDGET_GONK
-
-#include "mozilla/layers/TextureClient.h"
-#include "mozilla/layers/FenceUtils.h" // for FenceHandle
-#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
-#include <ui/GraphicBuffer.h>
-
-
-namespace android {
-class MediaBuffer;
-};
-
-namespace mozilla {
-namespace gl {
-class SharedSurface;
-}
-
-namespace layers {
-
-/// A TextureData implementation based on android::GraphicBuffer (also referred to
-/// as "gralloc").
-///
-/// Gralloc lets us map texture data in memory (accessible through pointers)
-/// and also use it directly as an OpenGL texture without the cost of texture
-/// uploads.
-/// Gralloc buffers can also be shared accros processes.
-///
-/// More info about Gralloc here: https://wiki.mozilla.org/Platform/GFX/Gralloc
-///
-/// This is only used in Firefox OS
-class GrallocTextureData : public TextureData {
-public:
-  typedef uint32_t AndroidFormat;
-
-  virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
-
-  virtual bool Lock(OpenMode aMode, FenceHandle* aFence) override;
-
-  virtual void Unlock() override;
-
-  virtual void FillInfo(TextureData::Info& aInfo) const override;
-
-  virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
-
-  virtual bool BorrowMappedData(MappedTextureData& aMap) override;
-
-  virtual void Deallocate(LayersIPCChannel*) override;
-
-  virtual void Forget(LayersIPCChannel*) override;
-
-  static GrallocTextureData* CreateForDrawing(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
-                                              gfx::BackendType aMoz2dBackend,
-                                              LayersIPCChannel* aAllocator);
-
-  static GrallocTextureData* CreateForYCbCr(gfx::IntSize aYSize, gfx::IntSize aCbCrSize,
-                                            LayersIPCChannel* aAllocator);
-
-  static GrallocTextureData* CreateForGLRendering(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
-                                                  LayersIPCChannel* aAllocator);
-
-  static GrallocTextureData* Create(gfx::IntSize aSize, AndroidFormat aFormat,
-                                    gfx::BackendType aMoz2DBackend, uint32_t aUsage,
-                                    LayersIPCChannel* aAllocator);
-
-
-  static already_AddRefed<TextureClient>
-  TextureClientFromSharedSurface(gl::SharedSurface* abstractSurf, TextureFlags flags);
-
-  virtual TextureData*
-  CreateSimilar(LayersIPCChannel* aAllocator,
-                LayersBackend aLayersBackend,
-                TextureFlags aFlags = TextureFlags::DEFAULT,
-                TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;
-
-  // use TextureClient's default implementation
-  virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
-
-  /// Hold android::MediaBuffer.
-  /// MediaBuffer needs to be add refed to keep MediaBuffer alive while the texture
-  /// is in use.
-  ///
-  /// TODO - ideally we should be able to put the MediaBuffer in the texture's
-  /// constructor and not expose these methods.
-  void SetMediaBuffer(android::MediaBuffer* aMediaBuffer) { mMediaBuffer = aMediaBuffer; }
-  android::MediaBuffer* GetMediaBuffer() { return mMediaBuffer; }
-
-  android::sp<android::GraphicBuffer> GetGraphicBuffer() { return mGraphicBuffer; }
-
-  virtual void WaitForFence(FenceHandle* aFence) override;
-
-  ~GrallocTextureData();
-
-  virtual TextureFlags GetTextureFlags() const override;
-
-  virtual GrallocTextureData* AsGrallocTextureData() { return this; }
-
-protected:
-  GrallocTextureData(MaybeMagicGrallocBufferHandle aGrallocHandle,
-                     gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
-                     gfx::BackendType aMoz2DBackend);
-
-  gfx::IntSize mSize;
-  gfx::SurfaceFormat mFormat;
-  gfx::BackendType mMoz2DBackend;
-
-  MaybeMagicGrallocBufferHandle mGrallocHandle;
-  android::sp<android::GraphicBuffer> mGraphicBuffer;
-
-  // Points to a mapped gralloc buffer between calls to lock and unlock.
-  // Should be null outside of the lock-unlock pair.
-  uint8_t* mMappedBuffer;
-
-  android::MediaBuffer* mMediaBuffer;
-};
-
-gfx::SurfaceFormat SurfaceFormatForPixelFormat(android::PixelFormat aFormat);
-
-} // namespace layers
-} // namespace mozilla
-
-#endif // MOZ_WIDGET_GONK
-#endif
deleted file mode 100644
--- a/gfx/layers/opengl/GrallocTextureHost.cpp
+++ /dev/null
@@ -1,480 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-//  * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "base/process.h"
-#include "GLContext.h"
-#include "gfx2DGlue.h"
-#include <ui/GraphicBuffer.h>
-#include "GrallocImages.h"  // for GrallocImage
-#include "GLLibraryEGL.h"   // for GLLibraryEGL
-#include "mozilla/gfx/2D.h"
-#include "mozilla/gfx/DataSurfaceHelpers.h"
-#include "mozilla/layers/GrallocTextureHost.h"
-#include "mozilla/layers/SharedBufferManagerParent.h"
-#include "EGLImageHelpers.h"
-#include "GLReadTexImageHelper.h"
-
-namespace mozilla {
-namespace layers {
-
-using namespace android;
-using namespace mozilla::gl;
-
-static gfx::SurfaceFormat
-SurfaceFormatForAndroidPixelFormat(android::PixelFormat aFormat,
-                                   TextureFlags aFlags)
-{
-  bool swapRB = bool(aFlags & TextureFlags::RB_SWAPPED);
-  switch (aFormat) {
-  case android::PIXEL_FORMAT_BGRA_8888:
-    return swapRB ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8A8;
-  case android::PIXEL_FORMAT_RGBA_8888:
-    return swapRB ? gfx::SurfaceFormat::B8G8R8A8 : gfx::SurfaceFormat::R8G8B8A8;
-  case android::PIXEL_FORMAT_RGBX_8888:
-    return swapRB ? gfx::SurfaceFormat::B8G8R8X8 : gfx::SurfaceFormat::R8G8B8X8;
-  case android::PIXEL_FORMAT_RGB_565:
-    return gfx::SurfaceFormat::R5G6B5_UINT16;
-  case HAL_PIXEL_FORMAT_YCbCr_422_SP:
-  case HAL_PIXEL_FORMAT_YCrCb_420_SP:
-  case HAL_PIXEL_FORMAT_YCbCr_422_I:
-  case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
-  case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
-  case HAL_PIXEL_FORMAT_YV12:
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-  case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
-#endif
-    return gfx::SurfaceFormat::R8G8B8A8; // yup, use SurfaceFormat::R8G8B8A8 even though it's a YUV texture. This is an external texture.
-  default:
-    if (aFormat >= 0x100 && aFormat <= 0x1FF) {
-      // Reserved range for HAL specific formats.
-      return gfx::SurfaceFormat::R8G8B8A8;
-    } else {
-      // This is not super-unreachable, there's a bunch of hypothetical pixel
-      // formats we don't deal with.
-      // We only want to abort in debug builds here, since if we crash here
-      // we'll take down the compositor process and thus the phone. This seems
-      // like undesirable behaviour. We'd rather have a subtle artifact.
-      printf_stderr(" xxxxx unknow android format %i\n", (int)aFormat);
-      MOZ_ASSERT(false, "Unknown Android pixel format.");
-      return gfx::SurfaceFormat::UNKNOWN;
-    }
-  }
-}
-
-static GLenum
-TextureTargetForAndroidPixelFormat(android::PixelFormat aFormat)
-{
-  switch (aFormat) {
-  case HAL_PIXEL_FORMAT_YCbCr_422_SP:
-  case HAL_PIXEL_FORMAT_YCrCb_420_SP:
-  case HAL_PIXEL_FORMAT_YCbCr_422_I:
-  case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
-  case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
-  case HAL_PIXEL_FORMAT_YV12:
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-  case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
-#endif
-    return LOCAL_GL_TEXTURE_EXTERNAL;
-  case android::PIXEL_FORMAT_BGRA_8888:
-  case android::PIXEL_FORMAT_RGBA_8888:
-  case android::PIXEL_FORMAT_RGBX_8888:
-  case android::PIXEL_FORMAT_RGB_565:
-    return LOCAL_GL_TEXTURE_2D;
-  default:
-    if (aFormat >= 0x100 && aFormat <= 0x1FF) {
-      // Reserved range for HAL specific formats.
-      return LOCAL_GL_TEXTURE_EXTERNAL;
-    } else {
-      // This is not super-unreachable, there's a bunch of hypothetical pixel
-      // formats we don't deal with.
-      // We only want to abort in debug builds here, since if we crash here
-      // we'll take down the compositor process and thus the phone. This seems
-      // like undesirable behaviour. We'd rather have a subtle artifact.
-      MOZ_ASSERT(false, "Unknown Android pixel format.");
-      return LOCAL_GL_TEXTURE_EXTERNAL;
-    }
-  }
-}
-
-GrallocTextureHostOGL::GrallocTextureHostOGL(TextureFlags aFlags,
-                                             const SurfaceDescriptorGralloc& aDescriptor)
-  : TextureHost(aFlags)
-  , mGrallocHandle(aDescriptor)
-  , mSize(0, 0)
-  , mCropSize(0, 0)
-  , mFormat(gfx::SurfaceFormat::UNKNOWN)
-  , mEGLImage(EGL_NO_IMAGE)
-  , mIsOpaque(aDescriptor.isOpaque())
-{
-  android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
-  MOZ_ASSERT(graphicBuffer);
-
-  if (graphicBuffer) {
-    mFormat =
-      SurfaceFormatForAndroidPixelFormat(graphicBuffer->getPixelFormat(),
-                                         aFlags & TextureFlags::RB_SWAPPED);
-    mSize = gfx::IntSize(graphicBuffer->getWidth(), graphicBuffer->getHeight());
-    mCropSize = mSize;
-  } else {
-    printf_stderr("gralloc buffer is nullptr\n");
-  }
-}
-
-GrallocTextureHostOGL::~GrallocTextureHostOGL()
-{
-  DestroyEGLImage();
-}
-
-void
-GrallocTextureHostOGL::SetCompositor(Compositor* aCompositor)
-{
-  mCompositor = AssertGLCompositor(aCompositor);
-  if (mGLTextureSource) {
-    mGLTextureSource->SetCompositor(mCompositor);
-  }
-
-  if (mCompositor && aCompositor != mCompositor) {
-    DestroyEGLImage();
-  }
-}
-
-bool
-GrallocTextureHostOGL::Lock()
-{
-  return IsValid();
-}
-
-void
-GrallocTextureHostOGL::Unlock()
-{
-  // Unlock is done internally by binding the texture to another gralloc buffer
-}
-
-bool
-GrallocTextureHostOGL::IsValid() const
-{
-  android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
-  return graphicBuffer != nullptr;
-}
-
-gfx::SurfaceFormat
-GrallocTextureHostOGL::GetFormat() const
-{
-  return mFormat;
-}
-
-void
-GrallocTextureHostOGL::DeallocateSharedData()
-{
-  if (mGLTextureSource) {
-    mGLTextureSource = nullptr;
-  }
-
-  DestroyEGLImage();
-
-  if (mGrallocHandle.buffer().type() != MaybeMagicGrallocBufferHandle::Tnull_t) {
-    MaybeMagicGrallocBufferHandle handle = mGrallocHandle.buffer();
-    base::ProcessId owner;
-    if (handle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef) {
-      owner = handle.get_GrallocBufferRef().mOwner;
-    }
-    else {
-      owner = handle.get_MagicGrallocBufferHandle().mRef.mOwner;
-    }
-
-    SharedBufferManagerParent::DropGrallocBuffer(owner, mGrallocHandle);
-  }
-}
-
-void
-GrallocTextureHostOGL::ForgetSharedData()
-{
-  if (mGLTextureSource) {
-    mGLTextureSource = nullptr;
-  }
-}
-
-void
-GrallocTextureHostOGL::DeallocateDeviceData()
-{
-  if (mGLTextureSource) {
-    mGLTextureSource = nullptr;
-  }
-  DestroyEGLImage();
-}
-
-LayerRenderState
-GrallocTextureHostOGL::GetRenderState()
-{
-  android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
-
-  if (graphicBuffer) {
-    LayerRenderStateFlags flags = LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT;
-    if (mIsOpaque) {
-      flags |= LayerRenderStateFlags::OPAQUE;
-    }
-    if (mFlags & TextureFlags::ORIGIN_BOTTOM_LEFT) {
-      flags |= LayerRenderStateFlags::ORIGIN_BOTTOM_LEFT;
-    }
-    if (mFlags & TextureFlags::RB_SWAPPED) {
-      flags |= LayerRenderStateFlags::FORMAT_RB_SWAP;
-    }
-    return LayerRenderState(graphicBuffer,
-                            mCropSize,
-                            flags,
-                            this);
-  }
-
-  return LayerRenderState();
-}
-
-already_AddRefed<gfx::DataSourceSurface>
-GrallocTextureHostOGL::GetAsSurface() {
-  android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
-  if (!graphicBuffer) {
-    return nullptr;
-  }
-  uint8_t* grallocData;
-  int32_t rv = graphicBuffer->lock(GRALLOC_USAGE_SW_READ_OFTEN, reinterpret_cast<void**>(&grallocData));
-  if (rv) {
-    return nullptr;
-  }
-  RefPtr<gfx::DataSourceSurface> grallocTempSurf =
-    gfx::Factory::CreateWrappingDataSourceSurface(grallocData,
-                                                  graphicBuffer->getStride() * android::bytesPerPixel(graphicBuffer->getPixelFormat()),
-                                                  GetSize(), GetFormat());
-  if (!grallocTempSurf) {
-    graphicBuffer->unlock();
-    return nullptr;
-  }
-  RefPtr<gfx::DataSourceSurface> surf = CreateDataSourceSurfaceByCloning(grallocTempSurf);
-
-  graphicBuffer->unlock();
-
-  return surf.forget();
-}
-
-void
-GrallocTextureHostOGL::UnbindTextureSource()
-{
-  TextureHost::UnbindTextureSource();
-  // Clear the reference to the TextureSource (if any), because we know that
-  // another TextureHost is being bound to the TextureSource. This means that
-  // we will have to re-do gl->fEGLImageTargetTexture2D next time we go through
-  // BindTextureSource (otherwise we would have skipped it).
-  // Note that this doesn't "unlock" the gralloc buffer or force it to be
-  // detached, Although decreasing the refcount of the TextureSource may lead
-  // to the gl handle being destroyed, which would unlock the gralloc buffer.
-  // That said, this method is called before another TextureHost attaches to the
-  // TextureSource, which has the effect of unlocking the gralloc buffer. So when
-  // this is called we know we are going to be unlocked soon.
-  mGLTextureSource = nullptr;
-}
-
-GLenum GetTextureTarget(gl::GLContext* aGL, android::PixelFormat aFormat) {
-  MOZ_ASSERT(aGL);
-  if (aGL->Renderer() == gl::GLRenderer::SGX530 ||
-      aGL->Renderer() == gl::GLRenderer::SGX540) {
-    // SGX has a quirk that only TEXTURE_EXTERNAL works and any other value will
-    // result in black pixels when trying to draw from bound textures.
-    // Unfortunately, using TEXTURE_EXTERNAL on Adreno has a terrible effect on
-    // performance.
-    // See Bug 950050.
-    return LOCAL_GL_TEXTURE_EXTERNAL;
-  } else {
-    return TextureTargetForAndroidPixelFormat(aFormat);
-  }
-}
-
-void
-GrallocTextureHostOGL::DestroyEGLImage()
-{
-  // Only called when we want to get rid of the gralloc buffer, usually
-  // around the end of life of the TextureHost.
-  if (mEGLImage != EGL_NO_IMAGE && GetGLContext()) {
-    EGLImageDestroy(GetGLContext(), mEGLImage);
-    mEGLImage = EGL_NO_IMAGE;
-  }
-}
-
-void
-GrallocTextureHostOGL::PrepareTextureSource(CompositableTextureSourceRef& aTextureSource)
-{
-  // This happens during the layers transaction.
-  // All of the gralloc magic goes here. The only thing that happens externally
-  // and that is good to keep in mind is that when the TextureSource is deleted,
-  // it destroys its gl texture handle which is important for genlock.
-
-  // If this TextureHost's mGLTextureSource member is non-null, it means we are
-  // still bound to the TextureSource, in which case we can skip the driver
-  // overhead of binding the texture again (fEGLImageTargetTexture2D)
-  // As a result, if the TextureHost is used with several CompositableHosts,
-  // it will be bound to only one TextureSource, and we'll do the driver work
-  // only once, which is great. This means that all of the compositables that
-  // use this TextureHost will keep a reference to this TextureSource at least
-  // for the duration of this frame.
-
-  // If the compositable already has a TextureSource (the aTextureSource parameter),
-  // that is compatible and is not in use by several compositable, we try to
-  // attach to it. This has the effect of unlocking the previous TextureHost that
-  // we attached to the TextureSource (the previous frame)
-
-  // If the TextureSource used by the compositable is also used by other
-  // compositables (see NumCompositableRefs), we have to create a new TextureSource,
-  // because otherwise we would be modifying the content of every layer that uses
-  // the TextureSource in question, even thoug they don't use this TextureHost.
-
-  android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
-
-  MOZ_ASSERT(graphicBuffer);
-  if (!graphicBuffer) {
-    mGLTextureSource = nullptr;
-    return;
-  }
-
-  if (mGLTextureSource && !mGLTextureSource->IsValid()) {
-    mGLTextureSource = nullptr;
-  }
-
-  if (mGLTextureSource) {
-    // We are already attached to a TextureSource, nothing to do except tell
-    // the compositable to use it.
-    aTextureSource = mGLTextureSource.get();
-    return;
-  }
-
-  gl::GLContext* gl = GetGLContext();
-  if (!gl || !gl->MakeCurrent()) {
-    mGLTextureSource = nullptr;
-    return;
-  }
-
-  if (mEGLImage == EGL_NO_IMAGE) {
-    gfx::IntSize cropSize(0, 0);
-    if (mCropSize != mSize) {
-      cropSize = mCropSize;
-    }
-    // Should only happen the first time.
-    mEGLImage = EGLImageCreateFromNativeBuffer(gl, graphicBuffer->getNativeBuffer(), cropSize);
-  }
-
-  GLenum textureTarget = GetTextureTarget(gl, graphicBuffer->getPixelFormat());
-
-  GLTextureSource* glSource = aTextureSource.get() ?
-    aTextureSource->AsSourceOGL()->AsGLTextureSource() : nullptr;
-
-  bool shouldCreateTextureSource = !glSource  || !glSource->IsValid()
-                                 || glSource->NumCompositableRefs() > 1
-                                 || glSource->GetTextureTarget() != textureTarget;
-
-  if (shouldCreateTextureSource) {
-    GLuint textureHandle;
-    gl->fGenTextures(1, &textureHandle);
-    gl->fBindTexture(textureTarget, textureHandle);
-    gl->fTexParameteri(textureTarget, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
-    gl->fTexParameteri(textureTarget, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
-    gl->fEGLImageTargetTexture2D(textureTarget, mEGLImage);
-
-    mGLTextureSource = new GLTextureSource(mCompositor, textureHandle, textureTarget,
-                                           mSize, mFormat);
-    aTextureSource = mGLTextureSource.get();
-  } else {
-    gl->fBindTexture(textureTarget, glSource->GetTextureHandle());
-
-    gl->fEGLImageTargetTexture2D(textureTarget, mEGLImage);
-    glSource->SetSize(mSize);
-    glSource->SetFormat(mFormat);
-    mGLTextureSource = glSource;
-  }
-}
-
-void
-GrallocTextureHostOGL::WaitAcquireFenceHandleSyncComplete()
-{
-  if (!mAcquireFenceHandle.IsValid()) {
-    return;
-  }
-
-  RefPtr<FenceHandle::FdObj> fence = mAcquireFenceHandle.GetAndResetFdObj();
-  int fenceFd = fence->GetAndResetFd();
-
-  EGLint attribs[] = {
-              LOCAL_EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fenceFd,
-              LOCAL_EGL_NONE
-          };
-
-  EGLSync sync = sEGLLibrary.fCreateSync(EGL_DISPLAY(),
-                                         LOCAL_EGL_SYNC_NATIVE_FENCE_ANDROID,
-                                         attribs);
-  if (!sync) {
-    NS_WARNING("failed to create native fence sync");
-    return;
-  }
-
-  // Wait sync complete with timeout.
-  // If a source of the fence becomes invalid because of error,
-  // fene complete is not signaled. See Bug 1061435.
-  EGLint status = sEGLLibrary.fClientWaitSync(EGL_DISPLAY(),
-                                              sync,
-                                              0,
-                                              400000000 /*400 msec*/);
-  if (status != LOCAL_EGL_CONDITION_SATISFIED) {
-    NS_ERROR("failed to wait native fence sync");
-  }
-  MOZ_ALWAYS_TRUE( sEGLLibrary.fDestroySync(EGL_DISPLAY(), sync) );
-}
-
-void
-GrallocTextureHostOGL::SetCropRect(nsIntRect aCropRect)
-{
-  MOZ_ASSERT(aCropRect.TopLeft() == gfx::IntPoint(0, 0));
-  MOZ_ASSERT(!aCropRect.IsEmpty());
-  MOZ_ASSERT(aCropRect.width <= mSize.width);
-  MOZ_ASSERT(aCropRect.height <= mSize.height);
-
-  gfx::IntSize cropSize(aCropRect.width, aCropRect.height);
-  if (mCropSize == cropSize) {
-    return;
-  }
-
-  mCropSize = cropSize;
-  mGLTextureSource = nullptr;
-}
-
-bool
-GrallocTextureHostOGL::BindTextureSource(CompositableTextureSourceRef& aTextureSource)
-{
-  // This happens at composition time.
-
-  // If mGLTextureSource is null it means PrepareTextureSource failed.
-  if (!mGLTextureSource) {
-    return false;
-  }
-
-  // If Prepare didn't fail, we expect our TextureSource to be the same as aTextureSource,
-  // otherwise it means something has fiddled with the TextureSource between Prepare and
-  // now.
-  MOZ_ASSERT(mGLTextureSource == aTextureSource);
-  aTextureSource = mGLTextureSource.get();
-
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-  // Wait until it's ready.
-  WaitAcquireFenceHandleSyncComplete();
-#endif
-  return true;
-}
-
-FenceHandle
-GrallocTextureHostOGL::GetCompositorReleaseFence()
-{
-  if (!mCompositor) {
-    return FenceHandle();
-  }
-  return mCompositor->GetReleaseFence();
-}
-
-
-} // namepsace layers
-} // namepsace mozilla
deleted file mode 100644
--- a/gfx/layers/opengl/GrallocTextureHost.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-//  * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef MOZILLA_GFX_GRALLOCTEXTUREHOST_H
-#define MOZILLA_GFX_GRALLOCTEXTUREHOST_H
-#ifdef MOZ_WIDGET_GONK
-
-#include "mozilla/layers/CompositorOGL.h"
-#include "mozilla/layers/TextureHostOGL.h"
-#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
-#include <ui/GraphicBuffer.h>
-
-namespace mozilla {
-namespace layers {
-
-class GrallocTextureHostOGL : public TextureHost
-{
-  friend class GrallocBufferActor;
-public:
-  GrallocTextureHostOGL(TextureFlags aFlags,
-                        const SurfaceDescriptorGralloc& aDescriptor);
-
-  virtual ~GrallocTextureHostOGL();
-
-  virtual bool Lock() override;
-
-  virtual void Unlock() override;
-
-  virtual void SetCompositor(Compositor* aCompositor) override;
-
-  virtual Compositor* GetCompositor() override { return mCompositor; }
-
-  virtual void DeallocateSharedData() override;
-
-  virtual void ForgetSharedData() override;
-
-  virtual void DeallocateDeviceData() override;
-
-  virtual gfx::SurfaceFormat GetFormat() const;
-
-  virtual gfx::IntSize GetSize() const override { return mCropSize; }
-
-  virtual LayerRenderState GetRenderState() override;
-
-  virtual void PrepareTextureSource(CompositableTextureSourceRef& aTextureSource) override;
-
-  virtual bool BindTextureSource(CompositableTextureSourceRef& aTextureSource) override;
-
-  virtual void UnbindTextureSource() override;
-
-  virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
-
-  virtual void WaitAcquireFenceHandleSyncComplete() override;
-
-  virtual void SetCropRect(nsIntRect aCropRect) override;
-
-  bool IsValid() const;
-
-  virtual const char* Name() override { return "GrallocTextureHostOGL"; }
-
-  gl::GLContext* GetGLContext() const { return mCompositor ? mCompositor->gl() : nullptr; }
-
-  virtual bool NeedsFenceHandle() override
-  {
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-    return true;
-#else
-    return false;
-#endif
-  }
-
-  virtual FenceHandle GetCompositorReleaseFence() override;
-
-  virtual GrallocTextureHostOGL* AsGrallocTextureHostOGL() override { return this; }
-
-private:
-  void DestroyEGLImage();
-
-  SurfaceDescriptorGralloc mGrallocHandle;
-  RefPtr<GLTextureSource> mGLTextureSource;
-  RefPtr<CompositorOGL> mCompositor;
-  // Size reported by the GraphicBuffer
-  gfx::IntSize mSize;
-  // Size reported by TextureClient, can be different in some cases (video?),
-  // used by LayerRenderState.
-  gfx::IntSize mCropSize;
-  gfx::SurfaceFormat mFormat;
-  EGLImage mEGLImage;
-  bool mIsOpaque;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif
-#endif
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -10,28 +10,22 @@
 #include "GLLibraryEGL.h"               // for GLLibraryEGL
 #include "GLUploadHelpers.h"
 #include "GLReadTexImageHelper.h"
 #include "gfx2DGlue.h"                  // for ContentForFormat, etc
 #include "mozilla/gfx/2D.h"             // for DataSourceSurface
 #include "mozilla/gfx/BaseSize.h"       // for BaseSize
 #include "mozilla/gfx/Logging.h"        // for gfxCriticalError
 #include "mozilla/layers/ISurfaceAllocator.h"
-#include "mozilla/layers/GrallocTextureHost.h"
 #include "nsRegion.h"                   // for nsIntRegion
 #include "AndroidSurfaceTexture.h"
 #include "GfxTexturesReporter.h"        // for GfxTexturesReporter
 #include "GLBlitTextureImageHelper.h"
 #include "GeckoProfiler.h"
 
-#ifdef MOZ_WIDGET_GONK
-# include "GrallocImages.h"  // for GrallocImage
-# include "EGLImageHelpers.h"
-#endif
-
 #ifdef XP_MACOSX
 #include "mozilla/layers/MacIOSurfaceTextureHostOGL.h"
 #endif
 
 #ifdef GL_PROVIDER_GLX
 #include "mozilla/layers/X11TextureHost.h"
 #endif
 
@@ -80,25 +74,16 @@ CreateTextureHostOGL(const SurfaceDescri
     case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface: {
       const SurfaceDescriptorMacIOSurface& desc =
         aDesc.get_SurfaceDescriptorMacIOSurface();
       result = new MacIOSurfaceTextureHostOGL(aFlags, desc);
       break;
     }
 #endif
 
-#ifdef MOZ_WIDGET_GONK
-    case SurfaceDescriptor::TSurfaceDescriptorGralloc: {
-      const SurfaceDescriptorGralloc& desc =
-        aDesc.get_SurfaceDescriptorGralloc();
-      result = new GrallocTextureHostOGL(aFlags, desc);
-      break;
-    }
-#endif
-
 #ifdef GL_PROVIDER_GLX
     case SurfaceDescriptor::TSurfaceDescriptorX11: {
       const auto& desc = aDesc.get_SurfaceDescriptorX11();
       result = new X11TextureHost(aFlags, desc);
       break;
     }
 #endif
 
--- a/gfx/skia/moz.build
+++ b/gfx/skia/moz.build
@@ -487,17 +487,17 @@ if CONFIG['MOZ_ENABLE_SKIA_GPU']:
         'skia/src/gpu/glsl/GrGLSLVarying.cpp',
         'skia/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp',
         'skia/src/gpu/glsl/GrGLSLXferProcessor.cpp',
         'skia/src/gpu/GrBatchAtlas.cpp',
         'skia/src/gpu/GrDrawContext.cpp',
         'skia/src/gpu/GrResourceCache.cpp',
         'skia/src/image/SkImage_Gpu.cpp',
     ]
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android'):
     UNIFIED_SOURCES += [
         'skia/src/ports/SkDebug_android.cpp',
         'skia/src/ports/SkOSFile_posix.cpp',
         'skia/src/ports/SkOSLibrary_posix.cpp',
         'skia/src/ports/SkTLS_pthread.cpp',
         'skia/src/utils/SkThreadUtils_pthread.cpp',
     ]
     SOURCES += [
@@ -645,26 +645,25 @@ LOCAL_INCLUDES += [
     'skia/src/lazy',
     'skia/src/opts',
     'skia/src/sfnt',
     'skia/src/utils',
     'skia/src/utils/mac',
     'skia/src/utils/win',
 ]
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android'):
     DEFINES['SK_FONTHOST_CAIRO_STANDALONE'] = 0
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in {
     'android',
     'cocoa',
     'gtk2',
     'gtk3',
     'uikit',
-    'gonk',
   }:
     DEFINES['SK_FONTHOST_DOES_NOT_USE_FONTMGR'] = 1
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     DEFINES['UNICODE'] = True
     DEFINES['_UNICODE'] = True
     # These are the usual dwrite default rendering param values
     DEFINES['SK_GAMMA_EXPONENT'] = 1.8
@@ -725,14 +724,14 @@ if CONFIG['GNU_CXX'] and not CONFIG['CLA
 if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
     CXXFLAGS += [
         '-Wno-implicit-fallthrough',
         '-Wno-inconsistent-missing-override',
         '-Wno-macro-redefined',
         '-Wno-unused-private-field',
     ]
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android', 'gonk'):
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android'):
     CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
     CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
     CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -20,22 +20,16 @@
 #include "nsIScreen.h"
 #include "nsIScreenManager.h"
 #include "nsILocaleService.h"
 #include "nsServiceManagerUtils.h"
 #include "gfxPrefs.h"
 #include "cairo.h"
 #include "VsyncSource.h"
 
-#ifdef MOZ_WIDGET_GONK
-#include <cutils/properties.h>
-#include "mozilla/layers/CompositorBridgeParent.h"
-#include "HwcComposer2D.h"
-#endif
-
 #include "ft2build.h"
 #include FT_FREETYPE_H
 #include FT_MODULE_H
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
@@ -100,22 +94,16 @@ gfxAndroidPlatform::gfxAndroidPlatform()
 
     mOffscreenFormat = GetScreenDepth() == 16
                        ? SurfaceFormat::R5G6B5_UINT16
                        : SurfaceFormat::X8R8G8B8_UINT32;
 
     if (gfxPrefs::AndroidRGB16Force()) {
         mOffscreenFormat = SurfaceFormat::R5G6B5_UINT16;
     }
-
-#ifdef MOZ_WIDGET_GONK
-    char propQemu[PROPERTY_VALUE_MAX];
-    property_get("ro.kernel.qemu", propQemu, "");
-    mIsInGonkEmulator = !strncmp(propQemu, "1", 1);
-#endif
 }
 
 gfxAndroidPlatform::~gfxAndroidPlatform()
 {
     FT_Done_Library(gPlatformFTLibrary);
     gPlatformFTLibrary = nullptr;
 }
 
@@ -174,35 +162,26 @@ void
 gfxAndroidPlatform::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
                                            Script aRunScript,
                                            nsTArray<const char*>& aFontList)
 {
     static const char kDroidSansJapanese[] = "Droid Sans Japanese";
     static const char kMotoyaLMaru[] = "MotoyaLMaru";
     static const char kNotoSansCJKJP[] = "Noto Sans CJK JP";
     static const char kNotoColorEmoji[] = "Noto Color Emoji";
-#ifdef MOZ_WIDGET_GONK
-    static const char kFirefoxEmoji[] = "Firefox Emoji";
-#endif
 
     if (aNextCh == 0xfe0fu) {
         // if char is followed by VS16, try for a color emoji glyph
-#ifdef MOZ_WIDGET_GONK
-        aFontList.AppendElement(kFirefoxEmoji);
-#endif
         aFontList.AppendElement(kNotoColorEmoji);
     }
 
     if (!IS_IN_BMP(aCh)) {
         uint32_t p = aCh >> 16;
         if (p == 1) { // try color emoji font, unless VS15 (text style) present
             if (aNextCh != 0xfe0fu && aNextCh != 0xfe0eu) {
-#ifdef MOZ_WIDGET_GONK
-                aFontList.AppendElement(kFirefoxEmoji);
-#endif
                 aFontList.AppendElement(kNotoColorEmoji);
             }
         }
     } else {
         // try language-specific "Droid Sans *" and "Noto Sans *" fonts for
         // certain blocks, as most devices probably have these
         uint8_t block = (aCh >> 8) & 0xff;
         switch (block) {
@@ -323,22 +302,16 @@ gfxAndroidPlatform::FontHintingEnabled()
     // content that can always be be non-reflow-zoomed.  So turn off
     // hinting.
     // 
     // XXX when gecko-android-java is used as an "app runtime", we may
     // want to re-enable hinting for non-browser processes there.
     return false;
 #endif //  MOZ_WIDGET_ANDROID
 
-#ifdef MOZ_WIDGET_GONK
-    // On B2G, the UX preference is currently to keep hinting disabled
-    // for all text (see bug 829523).
-    return false;
-#endif
-
     // Currently, we don't have any other targets, but if/when we do,
     // decide how to handle them here.
 
     NS_NOTREACHED("oops, what platform is this?");
     return gfxPlatform::FontHintingEnabled();
 }
 
 bool
@@ -349,109 +322,17 @@ gfxAndroidPlatform::RequiresLinearZoom()
     // content that can always be be non-reflow-zoomed.
     //
     // XXX when gecko-android-java is used as an "app runtime", we may
     // want to treat it like B2G and use linear zoom only for the web
     // browser process, not other apps.
     return true;
 #endif
 
-#ifdef MOZ_WIDGET_GONK
-    // On B2G, we need linear zoom for the browser, but otherwise prefer
-    // the improved glyph spacing that results from respecting the device
-    // pixel resolution for glyph layout (see bug 816614).
-    return XRE_IsContentProcess() &&
-           ContentChild::GetSingleton()->IsForBrowser();
-#endif
-
     NS_NOTREACHED("oops, what platform is this?");
     return gfxPlatform::RequiresLinearZoom();
 }
 
-#ifdef MOZ_WIDGET_GONK
-class GonkVsyncSource final : public VsyncSource
-{
-public:
-  GonkVsyncSource()
-  {
-  }
-
-  virtual Display& GetGlobalDisplay() override
-  {
-    return mGlobalDisplay;
-  }
-
-  class GonkDisplay final : public VsyncSource::Display
-  {
-  public:
-    GonkDisplay() : mVsyncEnabled(false)
-    {
-    }
-
-    ~GonkDisplay()
-    {
-      MOZ_ASSERT(NS_IsMainThread());
-    }
-
-    virtual void Shutdown() override
-    {
-      MOZ_ASSERT(NS_IsMainThread());
-      DisableVsync();
-    }
-
-    virtual void EnableVsync() override
-    {
-      MOZ_ASSERT(NS_IsMainThread());
-      if (IsVsyncEnabled()) {
-        return;
-      }
-      mVsyncEnabled = HwcComposer2D::GetInstance()->EnableVsync(true);
-    }
-
-    virtual void DisableVsync() override
-    {
-      MOZ_ASSERT(NS_IsMainThread());
-      if (!IsVsyncEnabled()) {
-        return;
-      }
-      mVsyncEnabled = HwcComposer2D::GetInstance()->EnableVsync(false);
-    }
-
-    virtual bool IsVsyncEnabled() override
-    {
-      MOZ_ASSERT(NS_IsMainThread());
-      return mVsyncEnabled;
-    }
-  private:
-    bool mVsyncEnabled;
-  }; // GonkDisplay
-
-private:
-  virtual ~GonkVsyncSource()
-  {
-  }
-
-  GonkDisplay mGlobalDisplay;
-}; // GonkVsyncSource
-#endif
-
 already_AddRefed<mozilla::gfx::VsyncSource>
 gfxAndroidPlatform::CreateHardwareVsyncSource()
 {
-    // Only enable true hardware vsync on kit-kat and L device. Jelly Bean has
-    // inaccurate hardware vsync so disable on JB. Android pre-JB doesn't have
-    // hardware vsync.
-    // L is android version 21, L-MR1 is 22, kit-kat is 19, 20 is kit-kat for
-    // wearables.
-#if defined(MOZ_WIDGET_GONK) && (ANDROID_VERSION == 19 || ANDROID_VERSION >= 21)
-    RefPtr<GonkVsyncSource> vsyncSource = new GonkVsyncSource();
-    VsyncSource::Display& display = vsyncSource->GetGlobalDisplay();
-    display.EnableVsync();
-    if (!display.IsVsyncEnabled()) {
-        NS_WARNING("Error enabling gonk vsync. Falling back to software vsync");
-        return gfxPlatform::CreateHardwareVsyncSource();
-    }
-    display.DisableVsync();
-    return vsyncSource.forget();
-#else
     return gfxPlatform::CreateHardwareVsyncSource();
-#endif
 }
--- a/gfx/thebes/gfxAndroidPlatform.h
+++ b/gfx/thebes/gfxAndroidPlatform.h
@@ -63,31 +63,23 @@ public:
     FT_Library GetFTLibrary();
 
     virtual bool CanRenderContentToDataSurface() const override {
       return true;
     }
 
     virtual already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource() override;
 
-#ifdef MOZ_WIDGET_GONK
-    virtual bool IsInGonkEmulator() const { return mIsInGonkEmulator; }
-#endif
-
     virtual bool SupportsApzTouchInput() const override {
       return true;
     }
 
 protected:
     bool AccelerateLayersByDefault() override {
       return true;
     }
 
 private:
     gfxImageFormat mOffscreenFormat;
-
-#ifdef MOZ_WIDGET_GONK
-    bool mIsInGonkEmulator;
-#endif
 };
 
 #endif /* GFX_PLATFORM_ANDROID_H */
 
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -1229,23 +1229,16 @@ gfxFT2FontList::FindFonts()
 
     FindFontsInDir(root, mFontNameCache.get(), FT2FontFamily::kVisible);
 
     if (mFontFamilies.Count() == 0) {
         // if we can't find/read the font directory, we are doomed!
         NS_RUNTIMEABORT("Could not read the system fonts directory");
     }
 
-#ifdef MOZ_WIDGET_GONK
-    // Look for fonts in /system/fonts/hidden and preload them to the
-    // user-font cache as data: URIs
-    root.AppendLiteral("/hidden");
-    FindFontsInDir(root, mFontNameCache.get(), FT2FontFamily::kHidden);
-#endif
-
     // Look for fonts stored in omnijar, unless we're on a low-memory
     // device where we don't want to spend the RAM to decompress them.
     // (Prefs may disable this, or force-enable it even with low memory.)
     bool lowmem;
     nsCOMPtr<nsIMemory> mem = nsMemory::GetGlobalMemoryService();
     if ((NS_SUCCEEDED(mem->IsLowMemoryPlatform(&lowmem)) && !lowmem &&
          Preferences::GetBool("gfx.bundled_fonts.enabled")) ||
         Preferences::GetBool("gfx.bundled_fonts.force-enabled")) {
@@ -1559,19 +1552,17 @@ searchDone:
 
     return fe;
 }
 
 gfxFontFamily*
 gfxFT2FontList::GetDefaultFontForPlatform(const gfxFontStyle* aStyle)
 {
     gfxFontFamily *ff = nullptr;
-#ifdef MOZ_WIDGET_GONK
-    ff = FindFamily(NS_LITERAL_STRING("Fira Sans"));
-#elif defined(MOZ_WIDGET_ANDROID)
+#if defined(MOZ_WIDGET_ANDROID)
     ff = FindFamily(NS_LITERAL_STRING("Roboto"));
     if (!ff) {
         ff = FindFamily(NS_LITERAL_STRING("Droid Sans"));
     }
 #endif
     /* TODO: what about Qt or other platforms that may use this? */
     return ff;
 }
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/CompositorBridgeChild.h"
 #include "mozilla/layers/CompositorThread.h"
 #include "mozilla/layers/ImageBridgeChild.h"
-#include "mozilla/layers/SharedBufferManagerChild.h"
 #include "mozilla/layers/ISurfaceAllocator.h"     // for GfxMemoryImageReporter
 #include "mozilla/gfx/gfxVars.h"
 #include "mozilla/gfx/GPUProcessManager.h"
 #include "mozilla/gfx/GraphicsMessages.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Unused.h"
@@ -92,20 +91,16 @@
 #if defined(MOZ_WIDGET_GTK)
 #include "gfxPlatformGtk.h" // xxx - for UseFcFontList
 #endif
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "TexturePoolOGL.h"
 #endif
 
-#ifdef MOZ_WIDGET_GONK
-#include "mozilla/layers/GrallocTextureHost.h"
-#endif
-
 #ifdef USE_SKIA
 # ifdef __GNUC__
 #  pragma GCC diagnostic push
 #  pragma GCC diagnostic ignored "-Wshadow"
 # endif
 # include "skia/include/core/SkGraphics.h"
 # ifdef USE_SKIA_GPU
 #  include "skia/include/gpu/GrContext.h"
@@ -142,19 +137,16 @@ class mozilla::gl::SkiaGLGlue : public G
 #include "mozilla/dom/ContentChild.h"
 #include "gfxVR.h"
 #include "VRManagerChild.h"
 #include "mozilla/gfx/GPUParent.h"
 #include "prsystem.h"
 
 namespace mozilla {
 namespace layers {
-#ifdef MOZ_WIDGET_GONK
-void InitGralloc();
-#endif
 void ShutdownTileCache();
 } // namespace layers
 } // namespace mozilla
 
 using namespace mozilla;
 using namespace mozilla::layers;
 using namespace mozilla::gl;
 using namespace mozilla::gfx;
@@ -748,20 +740,16 @@ gfxPlatform::Init()
 
     GLContext::PlatformStartup();
 
 #ifdef MOZ_WIDGET_ANDROID
     // Texture pool init
     TexturePoolOGL::Init();
 #endif
 
-#ifdef MOZ_WIDGET_GONK
-    mozilla::layers::InitGralloc();
-#endif
-
     Preferences::RegisterCallbackAndCall(RecordingPrefChanged, "gfx.2d.recording", nullptr);
 
     CreateCMSOutputProfile();
 
     // Listen to memory pressure event so we can purge DrawTarget caches
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
         gPlatform->mMemoryPressureObserver = new MemoryPressureObserver();
@@ -914,19 +902,16 @@ gfxPlatform::InitLayersIPC()
     if (sLayersIPCIsUp) {
       return;
     }
     sLayersIPCIsUp = true;
 
     if (XRE_IsParentProcess())
     {
         layers::CompositorThreadHolder::Start();
-#ifdef MOZ_WIDGET_GONK
-        SharedBufferManagerChild::StartUp();
-#endif
     }
 }
 
 /* static */ void
 gfxPlatform::ShutdownLayersIPC()
 {
     if (!sLayersIPCIsUp) {
       return;
@@ -940,20 +925,16 @@ gfxPlatform::ShutdownLayersIPC()
           layers::CompositorBridgeChild::ShutDown();
           layers::ImageBridgeChild::ShutDown();
         }
     } else if (XRE_IsParentProcess()) {
         gfx::VRManagerChild::ShutDown();
         layers::CompositorBridgeChild::ShutDown();
         layers::ImageBridgeChild::ShutDown();
 
-#ifdef MOZ_WIDGET_GONK
-        layers::SharedBufferManagerChild::ShutDown();
-#endif
-
         // This has to happen after shutting down the child protocols.
         layers::CompositorThreadHolder::Shutdown();
     } else {
       // TODO: There are other kind of processes and we should make sure gfx
       // stuff is either not created there or shut down properly.
     }
 }
 
@@ -1211,28 +1192,16 @@ gfxPlatform::ComputeTileSize()
   if (gfxPrefs::LayersTilesAdjust()) {
     gfx::IntSize screenSize = GetScreenSize();
     if (screenSize.width > 0) {
       // Choose a size so that there are between 2 and 4 tiles per screen width.
       // FIXME: we should probably make sure this is within the max texture size,
       // but I think everything should at least support 1024
       w = h = clamped(int32_t(RoundUpPow2(screenSize.width)) / 4, 256, 1024);
     }
-
-#ifdef MOZ_WIDGET_GONK
-    android::sp<android::GraphicBuffer> alloc =
-          new android::GraphicBuffer(w, h, android::PIXEL_FORMAT_RGBA_8888,
-                                     android::GraphicBuffer::USAGE_SW_READ_OFTEN |
-                                     android::GraphicBuffer::USAGE_SW_WRITE_OFTEN |
-                                     android::GraphicBuffer::USAGE_HW_TEXTURE);
-
-    if (alloc.get()) {
-      w = alloc->getStride(); // We want the tiles to be gralloc stride aligned.
-    }
-#endif
   }
 
   // Don't allow changing the tile size after we've set it.
   // Right now the code assumes that the tile size doesn't change.
   MOZ_ASSERT(gfxVars::TileSize().width == -1 &&
              gfxVars::TileSize().height == -1);
 
   gfxVars::SetTileSize(IntSize(w, h));
@@ -1388,21 +1357,16 @@ gfxPlatform::PurgeSkiaGPUCache()
   mSkiaGlue->GetGLContext()->MakeCurrent();
   mSkiaGlue->GetGLContext()->fFlush();
 #endif
 }
 
 bool
 gfxPlatform::HasEnoughTotalSystemMemoryForSkiaGL()
 {
-#ifdef MOZ_WIDGET_GONK
-  if (mTotalSystemMemory < 250*1024*1024) {
-    return false;
-  }
-#endif
   return true;
 }
 
 already_AddRefed<DrawTarget>
 gfxPlatform::CreateDrawTargetForBackend(BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat)
 {
   // There is a bunch of knowledge in the gfxPlatform heirarchy about how to
   // create the best offscreen surface for the current system and situation. We
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -69,33 +69,16 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'andr
     SOURCES += [
         'gfxAndroidPlatform.cpp',
         'gfxFT2FontBase.cpp',
         'gfxFT2FontList.cpp',
         'gfxFT2Fonts.cpp',
         'gfxFT2Utils.cpp',
         'PrintTargetPDF.cpp',
     ]
-elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    EXPORTS += [
-        'gfxAndroidPlatform.h',
-        'gfxFT2FontBase.h',
-        'gfxFT2Fonts.h',
-    ]
-    EXPORTS.mozilla.gfx += [
-        'PrintTargetPDF.h',
-    ]
-    SOURCES += [
-        'gfxAndroidPlatform.cpp',
-        'gfxFT2FontBase.cpp',
-        'gfxFT2FontList.cpp',
-        'gfxFT2Fonts.cpp',
-        'gfxFT2Utils.cpp',
-        'PrintTargetPDF.cpp',
-    ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     EXPORTS += [
         'gfxPlatformMac.h',
         'gfxQuartzNativeDrawing.h',
         'gfxQuartzSurface.h',
     ]
     EXPORTS.mozilla.gfx += [
         'PrintTargetCG.h',
@@ -256,33 +239,30 @@ GENERATED_FILES = [
 ]
 GENERATED_FILES['DeprecatedPremultiplyTables.h'].script = 'genTables.py:generate'
 
 LOCAL_INCLUDES += [
     '/dom/workers',
     '/dom/xml',
 ]
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-  LOCAL_INCLUDES += ['/widget/gonk']
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'gonk'):
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3'):
     DEFINES['MOZ_ENABLE_FREETYPE'] = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     for var in ('MOZ_ENABLE_D3D9_LAYER', 'MOZ_ENABLE_D3D10_LAYER'):
         if CONFIG[var]:
             DEFINES[var] = True
 
 CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
 CXXFLAGS += CONFIG['TK_CFLAGS']
 CFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
 CFLAGS += CONFIG['TK_CFLAGS']
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android'):
     CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
     CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
 
 LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
 LOCAL_INCLUDES += ['/media/libyuv/include']
 
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -13,17 +13,16 @@
 #include "mozilla/XPCOM.h"
 #include "nsXULAppAPI.h"
 
 #include "nsXPCOMPrivate.h"
 #include "nsXPCOMCIDInternal.h"
 
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/layers/CompositorBridgeParent.h"
-#include "mozilla/layers/SharedBufferManagerChild.h"
 
 #include "prlink.h"
 
 #include "nsCycleCollector.h"
 #include "nsObserverList.h"
 #include "nsObserverService.h"
 #include "nsProperties.h"
 #include "nsPersistentProperties.h"