merge mozilla-inbound to mozilla-central a=merge
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Thu, 27 Oct 2016 16:45:00 +0200
changeset 319707 9888f1a23001fde6435e1a9ed7e6d3af8dd988d8
parent 319681 23cbe1a93a98bb0a9822fd2d079fc259ff262899 (current diff)
parent 319706 cc3d6c32ed8016883293256289b614b1c677ccc3 (diff)
child 319708 9272c247ecf1fc24a72b4ef3181d95c12b2063d2
child 319757 1ba788373d460f774c9cd1653510dc1765df58cc
child 319834 56eec29053f22ce7f79f243fd5d4dfce831fe709
push id20746
push usercbook@mozilla.com
push dateThu, 27 Oct 2016 14:49:14 +0000
treeherderfx-team@9888f1a23001 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone52.0a1
merge mozilla-inbound to mozilla-central a=merge
dom/workers/ServiceWorkerMessageEvent.cpp
dom/workers/ServiceWorkerMessageEvent.h
gfx/gl/SharedSurfaceGralloc.cpp
gfx/gl/SharedSurfaceGralloc.h
gfx/layers/GrallocImages.cpp
gfx/layers/GrallocImages.h
gfx/layers/basic/GrallocTextureHostBasic.cpp
gfx/layers/basic/GrallocTextureHostBasic.h
gfx/layers/ipc/AsyncTransactionTracker.cpp
gfx/layers/ipc/AsyncTransactionTracker.h
gfx/layers/ipc/FenceUtils.cpp
gfx/layers/ipc/FenceUtils.h
gfx/layers/ipc/PSharedBufferManager.ipdl
gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
gfx/layers/ipc/ShadowLayerUtilsGralloc.h
gfx/layers/ipc/SharedBufferManagerChild.cpp
gfx/layers/ipc/SharedBufferManagerChild.h
gfx/layers/ipc/SharedBufferManagerParent.cpp
gfx/layers/ipc/SharedBufferManagerParent.h
gfx/layers/opengl/GrallocTextureClient.cpp
gfx/layers/opengl/GrallocTextureClient.h
gfx/layers/opengl/GrallocTextureHost.cpp
gfx/layers/opengl/GrallocTextureHost.h
security/sandbox/linux/SandboxHooks.cpp
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -745,16 +745,22 @@
 #if defined(MOZ_SANDBOX)
 #if defined(XP_WIN)
 #if defined(WOW_HELPER)
 @BINPATH@/wow_helper.exe
 #endif
 #endif
 #endif
 
+#if defined(MOZ_SANDBOX)
+#if defined(XP_LINUX)
+@BINPATH@/@DLL_PREFIX@mozsandbox@DLL_SUFFIX@
+#endif
+#endif
+
 ; for Solaris SPARC
 #ifdef SOLARIS
 bin/libfreebl_32fpu_3.so
 bin/libfreebl_32int_3.so
 bin/libfreebl_32int64_3.so
 #endif
 
 ; [Updater]
--- a/devtools/client/shared/components/reps/date-time.js
+++ b/devtools/client/shared/components/reps/date-time.js
@@ -32,24 +32,28 @@ define(function (require, exports, modul
           object: grip
         }, grip.class + " ");
       }
       return "";
     },
 
     render: function () {
       let grip = this.props.object;
-      return (
-        span({className: "objectBox"},
+      let date;
+      try {
+        date = span({className: "objectBox"},
           this.getTitle(grip),
           span({className: "Date"},
             new Date(grip.preview.timestamp).toISOString()
           )
-        )
-      );
+        );
+      } catch (e) {
+        date = span({className: "objectBox"}, "Invalid Date");
+      }
+      return date;
     },
   });
 
   // Registration
 
   function supportsObject(grip, type) {
     if (!isGrip(grip)) {
       return false;
--- a/devtools/client/shared/components/test/mochitest/test_reps_date-time.html
+++ b/devtools/client/shared/components/test/mochitest/test_reps_date-time.html
@@ -10,20 +10,29 @@ Test DateTime rep
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 </head>
 <body>
 <pre id="test">
 <script src="head.js" type="application/javascript;version=1.8"></script>
 <script type="application/javascript;version=1.8">
 window.onload = Task.async(function* () {
+  let { Rep } = browserRequire("devtools/client/shared/components/reps/rep");
+  let { DateTime } = browserRequire("devtools/client/shared/components/reps/date-time");
+
   try {
-    let { Rep } = browserRequire("devtools/client/shared/components/reps/rep");
-    let { DateTime } = browserRequire("devtools/client/shared/components/reps/date-time");
+    testValid();
+    testInvalid();
+  } catch(e) {
+    ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
+  } finally {
+    SimpleTest.finish();
+  }
 
+  function testValid() {
     let gripStub = {
       "type": "object",
       "class": "Date",
       "actor": "server1.conn0.child1/obj32",
       "extensible": true,
       "frozen": false,
       "sealed": false,
       "ownPropertyLength": 0,
@@ -33,19 +42,36 @@ window.onload = Task.async(function* () 
     };
 
     // Test that correct rep is chosen
     const renderedRep = shallowRenderComponent(Rep, { object: gripStub });
     is(renderedRep.type, DateTime.rep, `Rep correctly selects ${DateTime.rep.displayName}`);
 
     // Test rendering
     const renderedComponent = renderComponent(DateTime.rep, { object: gripStub });
-    is(renderedComponent.textContent, "2016-03-30T21:17:24.859Z", "DateTime rep has expected text content");
-  } catch(e) {
-    ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
-  } finally {
-    SimpleTest.finish();
+    is(renderedComponent.textContent, "2016-03-30T21:17:24.859Z", "DateTime rep has expected text content for valid date");
+  }
+
+  function testInvalid() {
+    let gripStub = {
+      "type": "object",
+      "actor": "server1.conn0.child1/obj32",
+      "class": "Date",
+      "extensible": true,
+      "frozen": false,
+      "sealed": false,
+      "ownPropertyLength": 0,
+      "preview": {
+        "timestamp": {
+          "type": "NaN"
+        }
+      }
+    };
+
+    // Test rendering
+    const renderedComponent = renderComponent(DateTime.rep, { object: gripStub });
+    is(renderedComponent.textContent, "Invalid Date", "DateTime rep has expected text content for invalid date");
   }
 });
 </script>
 </pre>
 </body>
 </html>
--- a/dom/base/PostMessageEvent.cpp
+++ b/dom/base/PostMessageEvent.cpp
@@ -139,24 +139,25 @@ PostMessageEvent::Run()
   nsCOMPtr<mozilla::dom::EventTarget> eventTarget = do_QueryObject(targetWindow);
   RefPtr<MessageEvent> event =
     new MessageEvent(eventTarget, nullptr, nullptr);
 
 
   Nullable<WindowProxyOrMessagePort> source;
   source.SetValue().SetAsWindowProxy() = mSource ? mSource->AsOuter() : nullptr;
 
+  Sequence<OwningNonNull<MessagePort>> ports;
+  if (!TakeTransferredPortsAsSequence(ports)) {
+    return NS_ERROR_OUT_OF_MEMORY;
+  }
+
   event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"),
                           false /*non-bubbling */, false /*cancelable */,
                           messageData, mCallerOrigin,
-                          EmptyString(), source,
-                          Sequence<OwningNonNull<MessagePort>>());
-
-  nsTArray<RefPtr<MessagePort>> ports = TakeTransferredPorts();
-  event->SetPorts(Move(ports));
+                          EmptyString(), source, ports);
 
   // We can't simply call dispatchEvent on the window because doing so ends
   // up flipping the trusted bit on the event, and we don't want that to
   // happen because then untrusted content can call postMessage on a chrome
   // window if it can get a reference to it.
 
   nsIPresShell *shell = targetWindow->GetExtantDoc()->GetShell();
   RefPtr<nsPresContext> presContext;
--- a/dom/base/StructuredCloneHolder.cpp
+++ b/dom/base/StructuredCloneHolder.cpp
@@ -1274,10 +1274,25 @@ StructuredCloneHolder::CustomFreeTransfe
     MOZ_ASSERT(aContent);
     ImageBitmapCloneData* data =
       static_cast<ImageBitmapCloneData*>(aContent);
     delete data;
     return;
   }
 }
 
+bool
+StructuredCloneHolder::TakeTransferredPortsAsSequence(Sequence<OwningNonNull<mozilla::dom::MessagePort>>& aPorts)
+{
+  nsTArray<RefPtr<MessagePort>> ports = TakeTransferredPorts();
+
+  aPorts.Clear();
+  for (uint32_t i = 0, len = ports.Length(); i < len; ++i) {
+    if (!aPorts.AppendElement(ports[i].forget(), fallible)) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
 } // dom namespace
 } // mozilla namespace
--- a/dom/base/StructuredCloneHolder.h
+++ b/dom/base/StructuredCloneHolder.h
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_StructuredCloneHolder_h
 #define mozilla_dom_StructuredCloneHolder_h
 
 #include "js/StructuredClone.h"
 #include "mozilla/Move.h"
 #include "mozilla/UniquePtr.h"
+#include "mozilla/dom/BindingDeclarations.h"
 #include "nsISupports.h"
 #include "nsTArray.h"
 
 #ifdef DEBUG
 #include "nsIThread.h"
 #endif
 
 namespace mozilla {
@@ -202,16 +203,21 @@ public:
   // MessagePorts are not thread-safe and they must be retrieved in the thread
   // where they are created.
   nsTArray<RefPtr<MessagePort>>&& TakeTransferredPorts()
   {
     MOZ_ASSERT(mSupportsTransferring);
     return Move(mTransferredPorts);
   }
 
+  // This method uses TakeTransferredPorts() to populate a sequence of
+  // MessagePorts for WebIDL binding classes.
+  bool
+  TakeTransferredPortsAsSequence(Sequence<OwningNonNull<mozilla::dom::MessagePort>>& aPorts);
+
   nsTArray<MessagePortIdentifier>& PortIdentifiers() const
   {
     MOZ_ASSERT(mSupportsTransferring);
     return mPortIdentifiers;
   }
 
   nsTArray<RefPtr<gfx::DataSourceSurface>>& GetSurfaces()
   {
--- a/dom/events/MessageEvent.cpp
+++ b/dom/events/MessageEvent.cpp
@@ -170,23 +170,10 @@ MessageEvent::InitMessageEvent(JSContext
 }
 
 void
 MessageEvent::GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts)
 {
   aPorts = mPorts;
 }
 
-void
-MessageEvent::SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts)
-{
-  MOZ_ASSERT(mPorts.IsEmpty());
-  mPorts = Move(aPorts);
-}
-
-void
-MessageEvent::SetSource(mozilla::dom::MessagePort* aPort)
-{
-  mPortSource = aPort;
-}
-
 } // namespace dom
 } // namespace mozilla
--- a/dom/events/MessageEvent.h
+++ b/dom/events/MessageEvent.h
@@ -44,26 +44,16 @@ public:
   void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
                ErrorResult& aRv);
   void GetOrigin(nsAString&) const;
   void GetLastEventId(nsAString&) const;
   void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const;
 
   void GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts);
 
-  void SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts);
-
-  // Non WebIDL methods
-  void SetSource(mozilla::dom::MessagePort* aPort);
-
-  void SetSource(nsPIDOMWindowInner* aWindow)
-  {
-    mWindowSource = aWindow;
-  }
-
   static already_AddRefed<MessageEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const MessageEventInit& aEventInit,
               ErrorResult& aRv);
 
   static already_AddRefed<MessageEvent>
   Constructor(EventTarget* aEventTarget,
--- 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"
@@ -1207,23 +1206,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*
@@ -1416,17 +1408,21 @@ ContentChild::RecvSetProcessSandbox(cons
   sandboxEnabled = StartMacOSContentSandbox();
 #endif
 
 #if defined(MOZ_CRASHREPORTER)
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("ContentSandboxEnabled"),
     sandboxEnabled? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0"));
 #if defined(XP_LINUX) && !defined(OS_ANDROID)
-  SandboxInfo::Get().AnnotateCrashReport();
+  nsAutoCString flagsString;
+  flagsString.AppendInt(SandboxInfo::Get().AsInteger());
+
+  CrashReporter::AnnotateCrashReport(
+    NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString);
 #endif /* XP_LINUX && !OS_ANDROID */
 #endif /* MOZ_CRASHREPORTER */
 #endif /* MOZ_CONTENT_SANDBOX */
 
   return true;
 }
 
 bool
--- 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
@@ -79,17 +79,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"
@@ -2207,20 +2206,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();
@@ -2840,23 +2835,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 PTestShell;
 include protocol PJavaScript;
 include protocol PRemoteSpellcheckEngine;
 include protocol PWebBrowserPersistDocument;
 include protocol PWebrtcGlobal;
 include protocol PPresentation;
@@ -338,17 +337,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/dom/ipc/ProcessHangMonitor.cpp
+++ b/dom/ipc/ProcessHangMonitor.cpp
@@ -311,17 +311,17 @@ HangMonitorChild::InterruptCallback()
     forcePaintEpoch = mForcePaintEpoch;
 
     mForcePaint = false;
   }
 
   if (forcePaint) {
     RefPtr<TabChild> tabChild = TabChild::FindTabChild(forcePaintTab);
     if (tabChild) {
-      JS::AutoAssertOnGC nogc(mContext);
+      JS::AutoAssertNoGC nogc(mContext);
       JS::AutoAssertOnBarrier nobarrier(mContext);
       tabChild->ForcePaint(forcePaintEpoch);
     }
   }
 }
 
 void
 HangMonitorChild::Shutdown()
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -115,16 +115,21 @@ include('/ipc/chromium/chromium-config.m
 
 FINAL_LIBRARY = 'xul'
 
 if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_TARGET'] == 'Darwin':
     USE_LIBS += [
         'mozsandbox',
     ]
 
+if CONFIG['MOZ_CONTENT_SANDBOX'] and CONFIG['OS_ARCH'] == 'Linux':
+    USE_LIBS += [
+        'mozsandbox',
+    ]
+
 LOCAL_INCLUDES += [
     '/caps',
     '/chrome',
     '/docshell/base',
     '/dom/base',
     '/dom/bluetooth/common',
     '/dom/bluetooth/ipc',
     '/dom/devicestorage',
--- a/dom/media/platforms/omx/GonkOmxPlatformLayer.cpp
+++ b/dom/media/platforms/omx/GonkOmxPlatformLayer.cpp
@@ -324,20 +324,16 @@ GonkBufferData::GetPlatformMediaData()
       this, info.mDisplay.width, info.mDisplay.height,
       info.mImage.width, info.mImage.height, mBuffer->nTimeStamp);
 
   // Get TextureClient Promise here to wait for resolved.
   RefPtr<GonkBufferData> self(this);
   mTextureClientRecycleHandler->WaitforRecycle()
     ->Then(mGonkPlatformLayer->GetTaskQueue(), __func__,
            [self] () {
-             // Waiting for texture to be freed.
-             if (self->mTextureClientRecycleHandler) {
-               self->mTextureClientRecycleHandler->GetTextureClient()->WaitForBufferOwnership();
-             }
              self->mPromise.ResolveIfExists(self, __func__);
            },
            [self] () {
              OmxBufferFailureHolder failure(OMX_ErrorUndefined, self);
              self->mPromise.RejectIfExists(failure, __func__);
            });
 
   return data.forget();
--- a/dom/messagechannel/MessagePort.cpp
+++ b/dom/messagechannel/MessagePort.cpp
@@ -129,26 +129,29 @@ private:
     }
 
     // Create the event
     nsCOMPtr<mozilla::dom::EventTarget> eventTarget =
       do_QueryInterface(mPort->GetOwner());
     RefPtr<MessageEvent> event =
       new MessageEvent(eventTarget, nullptr, nullptr);
 
+    Sequence<OwningNonNull<MessagePort>> ports;
+    if (!mData->TakeTransferredPortsAsSequence(ports)) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
+
+    Nullable<WindowProxyOrMessagePort> source;
+    source.SetValue().SetAsMessagePort() = mPort;
+
     event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"),
                             false /* non-bubbling */,
                             false /* cancelable */, value, EmptyString(),
-                            EmptyString(), nullptr,
-                            Sequence<OwningNonNull<MessagePort>>());
+                            EmptyString(), source, ports);
     event->SetTrusted(true);
-    event->SetSource(mPort);
-
-    nsTArray<RefPtr<MessagePort>> ports = mData->TakeTransferredPorts();
-    event->SetPorts(Move(ports));
 
     bool dummy;
     mPort->DispatchEvent(static_cast<dom::Event*>(event.get()), &dummy);
 
     return NS_OK;
   }
 
 private:
--- a/dom/webidl/ServiceWorkerMessageEvent.webidl
+++ b/dom/webidl/ServiceWorkerMessageEvent.webidl
@@ -10,17 +10,16 @@
 
 [Pref="dom.serviceWorkers.enabled",
  Constructor(DOMString type, optional ServiceWorkerMessageEventInit eventInitDict),
  Exposed=Window]
 interface ServiceWorkerMessageEvent : Event {
   /**
    * Custom data associated with this event.
    */
-  [GetterThrows]
   readonly attribute any data;
 
   /**
    * The origin of the site from which this event originated.
    */
   readonly attribute DOMString origin;
 
   /**
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -405,17 +405,16 @@ WEBIDL_FILES = [
     'ScreenOrientation.webidl',
     'ScriptProcessorNode.webidl',
     'ScrollAreaEvent.webidl',
     'ScrollBoxObject.webidl',
     'Selection.webidl',
     'ServiceWorker.webidl',
     'ServiceWorkerContainer.webidl',
     'ServiceWorkerGlobalScope.webidl',
-    'ServiceWorkerMessageEvent.webidl',
     'ServiceWorkerRegistration.webidl',
     'SettingChangeNotification.webidl',
     'SettingsManager.webidl',
     'ShadowRoot.webidl',
     'SharedWorker.webidl',
     'SharedWorkerGlobalScope.webidl',
     'SimpleGestureEvent.webidl',
     'SocketCommon.webidl',
@@ -766,16 +765,17 @@ GENERATED_EVENTS_WEBIDL_FILES = [
     'PluginCrashedEvent.webidl',
     'PopStateEvent.webidl',
     'PopupBlockedEvent.webidl',
     'PresentationConnectionAvailableEvent.webidl',
     'PresentationConnectionClosedEvent.webidl',
     'ProgressEvent.webidl',
     'RecordErrorEvent.webidl',
     'ScrollViewChangeEvent.webidl',
+    'ServiceWorkerMessageEvent.webidl',
     'StyleRuleChangeEvent.webidl',
     'StyleSheetApplicableStateChangeEvent.webidl',
     'StyleSheetChangeEvent.webidl',
     'TCPServerSocketEvent.webidl',
     'TCPSocketErrorEvent.webidl',
     'TCPSocketEvent.webidl',
     'TrackEvent.webidl',
     'UDPMessageEvent.webidl',
--- a/dom/workers/ServiceWorkerClient.cpp
+++ b/dom/workers/ServiceWorkerClient.cpp
@@ -160,22 +160,24 @@ private:
     }
     init.mOrigin = NS_ConvertUTF8toUTF16(origin);
 
     RefPtr<ServiceWorker> serviceWorker = aTargetContainer->GetController();
     if (serviceWorker) {
       init.mSource.SetValue().SetAsServiceWorker() = serviceWorker;
     }
 
+    if (!TakeTransferredPortsAsSequence(init.mPorts)) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
+
     RefPtr<ServiceWorkerMessageEvent> event =
       ServiceWorkerMessageEvent::Constructor(aTargetContainer,
-                                             NS_LITERAL_STRING("message"), init, rv);
-
-    nsTArray<RefPtr<MessagePort>> ports = TakeTransferredPorts();
-    event->SetPorts(Move(ports));
+                                             NS_LITERAL_STRING("message"),
+                                             init);
 
     event->SetTrusted(true);
     bool status = false;
     aTargetContainer->DispatchEvent(static_cast<dom::Event*>(event.get()),
                                     &status);
 
     if (!status) {
       return NS_ERROR_FAILURE;
--- a/dom/workers/ServiceWorkerEvents.cpp
+++ b/dom/workers/ServiceWorkerEvents.cpp
@@ -1247,35 +1247,16 @@ ExtendableMessageEvent::Constructor(mozi
 }
 
 void
 ExtendableMessageEvent::GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts)
 {
   aPorts = mPorts;
 }
 
-void
-ExtendableMessageEvent::SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts)
-{
-  MOZ_ASSERT(mPorts.IsEmpty());
-  mPorts = Move(aPorts);
-}
-
-void
-ExtendableMessageEvent::SetSource(ServiceWorkerClient* aClient)
-{
-  mClient = aClient;
-}
-
-void
-ExtendableMessageEvent::SetSource(ServiceWorker* aServiceWorker)
-{
-  mServiceWorker = aServiceWorker;
-}
-
 NS_IMPL_CYCLE_COLLECTION_CLASS(ExtendableMessageEvent)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ExtendableMessageEvent, Event)
   tmp->mData.setUndefined();
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mClient)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mServiceWorker)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessagePort)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPorts)
--- a/dom/workers/ServiceWorkerEvents.h
+++ b/dom/workers/ServiceWorkerEvents.h
@@ -303,19 +303,13 @@ public:
 
   NS_IMETHOD GetLastEventId(nsAString& aLastEventId)
   {
     aLastEventId = mLastEventId;
     return NS_OK;
   }
 
   void GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts);
-
-  void SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts);
-
-  void SetSource(ServiceWorkerClient* aClient);
-
-  void SetSource(ServiceWorker* aServiceWorker);
 };
 
 END_WORKERS_NAMESPACE
 
 #endif /* mozilla_dom_workers_serviceworkerevents_h__ */
deleted file mode 100644
--- a/dom/workers/ServiceWorkerMessageEvent.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/* vim: set ts=8 sts=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 "mozilla/dom/ServiceWorkerMessageEvent.h"
-#include "mozilla/dom/ServiceWorkerMessageEventBinding.h"
-#include "mozilla/dom/MessagePort.h"
-#include "mozilla/dom/MessagePortBinding.h"
-
-#include "mozilla/HoldDropJSObjects.h"
-#include "jsapi.h"
-
-#include "ServiceWorker.h"
-
-namespace mozilla {
-namespace dom {
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(ServiceWorkerMessageEvent)
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ServiceWorkerMessageEvent, Event)
-  tmp->mData.setUndefined();
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mServiceWorker)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessagePort)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mPorts)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServiceWorkerMessageEvent, Event)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mServiceWorker)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessagePort)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPorts)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(ServiceWorkerMessageEvent, Event)
-  NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mData)
-NS_IMPL_CYCLE_COLLECTION_TRACE_END
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServiceWorkerMessageEvent)
-NS_INTERFACE_MAP_END_INHERITING(Event)
-
-NS_IMPL_ADDREF_INHERITED(ServiceWorkerMessageEvent, Event)
-NS_IMPL_RELEASE_INHERITED(ServiceWorkerMessageEvent, Event)
-
-ServiceWorkerMessageEvent::ServiceWorkerMessageEvent(EventTarget* aOwner,
-                                                     nsPresContext* aPresContext,
-                                                     WidgetEvent* aEvent)
-  : Event(aOwner, aPresContext, aEvent)
-  , mData(JS::UndefinedValue())
-{
-  mozilla::HoldJSObjects(this);
-}
-
-ServiceWorkerMessageEvent::~ServiceWorkerMessageEvent()
-{
-  mData.setUndefined();
-  DropJSObjects(this);
-}
-
-JSObject*
-ServiceWorkerMessageEvent::WrapObjectInternal(JSContext* aCx,
-                                              JS::Handle<JSObject*> aGivenProto)
-{
-  return mozilla::dom::ServiceWorkerMessageEventBinding::Wrap(aCx, this, aGivenProto);
-}
-
-
-void
-ServiceWorkerMessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
-                                   ErrorResult& aRv) const
-{
-  aData.set(mData);
-  if (!JS_WrapValue(aCx, aData)) {
-    aRv.Throw(NS_ERROR_FAILURE);
-  }
-}
-
-void
-ServiceWorkerMessageEvent::GetOrigin(nsAString& aOrigin) const
-{
-  aOrigin = mOrigin;
-}
-
-void
-ServiceWorkerMessageEvent::GetLastEventId(nsAString& aLastEventId) const
-{
-  aLastEventId = mLastEventId;
-}
-
-void
-ServiceWorkerMessageEvent::GetSource(Nullable<OwningServiceWorkerOrMessagePort>& aValue) const
-{
-  if (mServiceWorker) {
-    aValue.SetValue().SetAsServiceWorker() = mServiceWorker;
-  } else if (mMessagePort) {
-    aValue.SetValue().SetAsMessagePort() = mMessagePort;
-  }
-}
-
-void
-ServiceWorkerMessageEvent::SetSource(mozilla::dom::MessagePort* aPort)
-{
-  mMessagePort = aPort;
-}
-
-void
-ServiceWorkerMessageEvent::SetSource(workers::ServiceWorker* aServiceWorker)
-{
-  mServiceWorker = aServiceWorker;
-}
-
-void
-ServiceWorkerMessageEvent::GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts)
-{
-  aPorts = mPorts;
-}
-
-void
-ServiceWorkerMessageEvent::SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts)
-{
-  MOZ_ASSERT(mPorts.IsEmpty());
-  mPorts = Move(aPorts);
-}
-
-/* static */ already_AddRefed<ServiceWorkerMessageEvent>
-ServiceWorkerMessageEvent::Constructor(const GlobalObject& aGlobal,
-                                       const nsAString& aType,
-                                       const ServiceWorkerMessageEventInit& aParam,
-                                       ErrorResult& aRv)
-{
-  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
-  return Constructor(t, aType, aParam, aRv);
-}
-
-/* static */ already_AddRefed<ServiceWorkerMessageEvent>
-ServiceWorkerMessageEvent::Constructor(EventTarget* aEventTarget,
-                                       const nsAString& aType,
-                                       const ServiceWorkerMessageEventInit& aParam,
-                                       ErrorResult& aRv)
-{
-  RefPtr<ServiceWorkerMessageEvent> event =
-    new ServiceWorkerMessageEvent(aEventTarget, nullptr, nullptr);
-
-  event->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
-
-  bool trusted = event->Init(aEventTarget);
-  event->SetTrusted(trusted);
-
-  event->mData = aParam.mData;
-  event->mOrigin = aParam.mOrigin;
-  event->mLastEventId = aParam.mLastEventId;
-
-  if (!aParam.mSource.IsNull()) {
-    if (aParam.mSource.Value().IsServiceWorker()) {
-      event->mServiceWorker = aParam.mSource.Value().GetAsServiceWorker();
-    } else if (aParam.mSource.Value().IsMessagePort()) {
-      event->mMessagePort = aParam.mSource.Value().GetAsMessagePort();
-    }
-  }
-
-  event->mPorts.AppendElements(aParam.mPorts);
-
-  return event.forget();
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/workers/ServiceWorkerMessageEvent.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=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/. */
-
-#ifndef mozilla_dom_serviceworkermessageevent_h__
-#define mozilla_dom_serviceworkermessageevent_h__
-
-#include "mozilla/dom/Event.h"
-
-namespace mozilla {
-namespace dom {
-
-struct ServiceWorkerMessageEventInit;
-class MessagePort;
-class OwningServiceWorkerOrMessagePort;
-
-namespace workers {
-
-class ServiceWorker;
-
-}
-
-class ServiceWorkerMessageEvent final : public Event
-{
-public:
-  ServiceWorkerMessageEvent(EventTarget* aOwner,
-                            nsPresContext* aPresContext,
-                            WidgetEvent* aEvent);
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(ServiceWorkerMessageEvent, Event)
-
-  // Forward to base class
-  NS_FORWARD_TO_EVENT
-
-  virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-  void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
-               ErrorResult& aRv) const;
-
-  void GetOrigin(nsAString& aOrigin) const;
-
-  void GetLastEventId(nsAString& aLastEventId) const;
-
-  void GetSource(Nullable<OwningServiceWorkerOrMessagePort>& aValue) const;
-
-  void GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts);
-
-  void SetSource(mozilla::dom::MessagePort* aPort);
-
-  void SetSource(workers::ServiceWorker* aServiceWorker);
-
-  void SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts);
-
-  static already_AddRefed<ServiceWorkerMessageEvent>
-  Constructor(const GlobalObject& aGlobal,
-              const nsAString& aType,
-              const ServiceWorkerMessageEventInit& aEventInit,
-              ErrorResult& aRv);
-
-  static already_AddRefed<ServiceWorkerMessageEvent>
-  Constructor(EventTarget* aEventTarget,
-              const nsAString& aType,
-              const ServiceWorkerMessageEventInit& aEventInit,
-              ErrorResult& aRv);
-
-protected:
-  ~ServiceWorkerMessageEvent();
-
-private:
-  JS::Heap<JS::Value> mData;
-  nsString mOrigin;
-  nsString mLastEventId;
-  RefPtr<workers::ServiceWorker> mServiceWorker;
-  RefPtr<MessagePort> mMessagePort;
-  nsTArray<RefPtr<MessagePort>> mPorts;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif /* mozilla_dom_workers_serviceworkermessageevent_h__ */
-
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -678,56 +678,58 @@ public:
       timelines->AddMarkerForAllObservedDocShells(end);
     }
 
     if (NS_WARN_IF(rv.Failed())) {
       xpc::Throw(aCx, rv.StealNSResult());
       return false;
     }
 
-    nsTArray<RefPtr<MessagePort>> ports = TakeTransferredPorts();
+    Sequence<OwningNonNull<MessagePort>> ports;
+    if (!TakeTransferredPortsAsSequence(ports)) {
+      return false;
+    }
 
     nsCOMPtr<nsIDOMEvent> domEvent;
     RefPtr<ExtendableMessageEvent> extendableEvent;
     // For messages dispatched to service worker, use ExtendableMessageEvent
     // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#extendablemessage-event-section
     if (mEventSource) {
       RefPtr<ServiceWorkerClient> client =
         new ServiceWorkerWindowClient(aTarget, *mEventSource);
 
       RootedDictionary<ExtendableMessageEventInit> init(aCx);
 
       init.mBubbles = false;
       init.mCancelable = false;
 
       init.mData = messageData;
+      init.mPorts = ports;
+      init.mSource.SetValue().SetAsClient() = client;
 
       ErrorResult rv;
       extendableEvent = ExtendableMessageEvent::Constructor(
         aTarget, NS_LITERAL_STRING("message"), init, rv);
       if (NS_WARN_IF(rv.Failed())) {
         rv.SuppressException();
         return false;
       }
-      extendableEvent->SetSource(client);
-      extendableEvent->SetPorts(Move(ports));
 
       domEvent = do_QueryObject(extendableEvent);
     } else {
       RefPtr<MessageEvent> event = new MessageEvent(aTarget, nullptr, nullptr);
       event->InitMessageEvent(nullptr,
                               NS_LITERAL_STRING("message"),
                               false /* non-bubbling */,
                               false /* cancelable */,
                               messageData,
                               EmptyString(),
                               EmptyString(),
                               nullptr,
-                              Sequence<OwningNonNull<MessagePort>>());
-      event->SetPorts(Move(ports));
+                              ports);
       domEvent = do_QueryObject(event);
     }
 
     domEvent->SetTrusted(true);
 
     nsEventStatus dummy = nsEventStatus_eIgnore;
     aTarget->DispatchDOMEvent(nullptr, domEvent, nullptr, &dummy);
 
@@ -6484,28 +6486,26 @@ WorkerPrivate::ConnectMessagePort(JSCont
   if (globalObject.Failed()) {
     return false;
   }
 
   RootedDictionary<MessageEventInit> init(aCx);
   init.mBubbles = false;
   init.mCancelable = false;
   init.mSource.SetValue().SetAsMessagePort() = port;
+  if (!init.mPorts.AppendElement(port.forget(), fallible)) {
+    return false;
+  }
 
   RefPtr<MessageEvent> event =
     MessageEvent::Constructor(globalObject,
                               NS_LITERAL_STRING("connect"), init, rv);
 
   event->SetTrusted(true);
 
-  nsTArray<RefPtr<MessagePort>> ports;
-  ports.AppendElement(port);
-
-  event->SetPorts(Move(ports));
-
   nsCOMPtr<nsIDOMEvent> domEvent = do_QueryObject(event);
 
   nsEventStatus dummy = nsEventStatus_eIgnore;
   globalScope->DispatchDOMEvent(nullptr, domEvent, nullptr, &dummy);
 
   return true;
 }
 
--- a/dom/workers/moz.build
+++ b/dom/workers/moz.build
@@ -5,17 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # Public stuff.
 EXPORTS.mozilla.dom += [
     'FileReaderSync.h',
     'ServiceWorkerCommon.h',
     'ServiceWorkerContainer.h',
     'ServiceWorkerEvents.h',
-    'ServiceWorkerMessageEvent.h',
     'ServiceWorkerRegistrar.h',
     'ServiceWorkerRegistration.h',
     'WorkerLocation.h',
     'WorkerNavigator.h',
     'WorkerPrefs.h',
     'WorkerPrivate.h',
     'WorkerRunnable.h',
     'WorkerScope.h',
@@ -61,17 +60,16 @@ UNIFIED_SOURCES += [
     'ServiceWorkerEvents.cpp',
     'ServiceWorkerInfo.cpp',
     'ServiceWorkerJob.cpp',
     'ServiceWorkerJobQueue.cpp',
     'ServiceWorkerManager.cpp',
     'ServiceWorkerManagerChild.cpp',
     'ServiceWorkerManagerParent.cpp',
     'ServiceWorkerManagerService.cpp',
-    'ServiceWorkerMessageEvent.cpp',
     'ServiceWorkerPrivate.cpp',
     'ServiceWorkerRegisterJob.cpp',
     'ServiceWorkerRegistrar.cpp',
     'ServiceWorkerRegistration.cpp',
     'ServiceWorkerRegistrationInfo.cpp',
     'ServiceWorkerScriptCache.cpp',
     'ServiceWorkerUnregisterJob.cpp',
     'ServiceWorkerUpdateJob.cpp',
--- 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/BufferTexture.h
+++ b/gfx/layers/BufferTexture.h
@@ -38,17 +38,17 @@ public:
   // It is generally better to use CreateForYCbCr instead.
   // This creates a half-initialized texture since we don't know the sizes and
   // offsets in the buffer.
   static BufferTextureData* CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
                                                          int32_t aSize,
                                                          YUVColorSpace aYUVColorSpace,
                                                          TextureFlags aTextureFlags);
 
-  virtual bool Lock(OpenMode aMode, FenceHandle*) override { return true; }
+  virtual bool Lock(OpenMode aMode) override { return true; }
 
   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;
--- 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,15 @@ 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
@@ -12,17 +12,16 @@
 #include "mozilla/gfx/2D.h"             // for DrawTarget
 #include "mozilla/gfx/MatrixFwd.h"      // for Matrix4x4
 #include "mozilla/gfx/Point.h"          // for IntSize, Point
 #include "mozilla/gfx/Polygon.h"        // for Polygon3D
 #include "mozilla/gfx/Rect.h"           // for Rect, IntRect
 #include "mozilla/gfx/Types.h"          // for Float
 #include "mozilla/gfx/Triangle.h"       // for Triangle, TexturedTriangle
 #include "mozilla/layers/CompositorTypes.h"  // for DiagnosticTypes, etc
-#include "mozilla/layers/FenceUtils.h"  // for FenceHandle
 #include "mozilla/layers/LayersTypes.h"  // for LayersBackend
 #include "mozilla/widget/CompositorWidget.h"
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsRegion.h"
 #include <vector>
 #include "mozilla/WidgetUtils.h"
 
 /**
@@ -430,18 +429,16 @@ public:
    * Flush the current frame to the screen and tidy up.
    *
    * Derived class overriding this should call Compositor::EndFrame.
    */
   virtual void EndFrame();
 
   virtual void SetDispAcquireFence(Layer* aLayer);
 
-  virtual FenceHandle GetReleaseFence();
-
   /**
    * Post-rendering stuff if the rendering is done outside of this Compositor
    * e.g., by Composer2D.
    * aTransform is the transform from user space to window space.
    */
   virtual void EndFrameForExternalComposition(const gfx::Matrix& aTransform) = 0;
 
   /**
@@ -678,20 +675,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/TextureDIB.h
+++ b/gfx/layers/TextureDIB.h
@@ -13,17 +13,17 @@
 #include "gfxWindowsPlatform.h"
 
 namespace mozilla {
 namespace layers {
 
 class DIBTextureData : public TextureData
 {
 public:
-  virtual bool Lock(OpenMode, FenceHandle*) override { return true; }
+  virtual bool Lock(OpenMode) override { return true; }
 
   virtual void Unlock() override {}
 
   virtual void FillInfo(TextureData::Info& aInfo) const override;
 
   virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
 
   static
--- 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/TextureClientX11.cpp
+++ b/gfx/layers/basic/TextureClientX11.cpp
@@ -29,17 +29,17 @@ X11TextureData::X11TextureData(gfx::IntS
 , mSurface(aSurface)
 , mClientDeallocation(aClientDeallocation)
 , mIsCrossProcess(aIsCrossProcess)
 {
   MOZ_ASSERT(mSurface);
 }
 
 bool
-X11TextureData::Lock(OpenMode aMode, FenceHandle*)
+X11TextureData::Lock(OpenMode aMode)
 {
   return true;
 }
 
 void
 X11TextureData::Unlock()
 {
   if (mSurface && mIsCrossProcess) {
--- a/gfx/layers/basic/TextureClientX11.h
+++ b/gfx/layers/basic/TextureClientX11.h
@@ -16,17 +16,17 @@ namespace layers {
 class X11TextureData : public TextureData
 {
 public:
   static X11TextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
                                 TextureFlags aFlags, LayersIPCChannel* aAllocator);
 
   virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
 
-  virtual bool Lock(OpenMode aMode, FenceHandle*) override;
+  virtual bool Lock(OpenMode aMode) override;
 
   virtual void Unlock() override;
 
   virtual void FillInfo(TextureData::Info& aInfo) const override;
 
   virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
 
   virtual void Deallocate(LayersIPCChannel*) override;
--- 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/CompositableClient.cpp
+++ b/gfx/layers/client/CompositableClient.cpp
@@ -23,32 +23,16 @@
 #include "IPDLActor.h"
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 
 void
-RemoveTextureFromCompositableTracker::ReleaseTextureClient()
-{
-  if (mTextureClient &&
-      mTextureClient->GetAllocator() &&
-      !mTextureClient->GetAllocator()->UsesImageBridge())
-  {
-    RefPtr<TextureClientReleaseTask> task = new TextureClientReleaseTask(mTextureClient);
-    RefPtr<LayersIPCChannel> allocator = mTextureClient->GetAllocator();
-    mTextureClient = nullptr;
-    allocator->GetMessageLoop()->PostTask(task.forget());
-  } else {
-    mTextureClient = nullptr;
-  }
-}
-
-void
 CompositableClient::InitIPDLActor(PCompositableChild* aActor, uint64_t aAsyncID)
 {
   MOZ_ASSERT(aActor);
 
   mForwarder->AssertInForwarderThread();
 
   mCompositableChild = static_cast<CompositableChild*>(aActor);
   mCompositableChild->Init(this, aAsyncID);
--- a/gfx/layers/client/CompositableClient.h
+++ b/gfx/layers/client/CompositableClient.h
@@ -7,17 +7,16 @@
 #define MOZILLA_GFX_BUFFERCLIENT_H
 
 #include <stdint.h>                     // for uint64_t
 #include <vector>                       // for vector
 #include <map>                          // for map
 #include "mozilla/Assertions.h"         // for MOZ_CRASH
 #include "mozilla/RefPtr.h"             // for already_AddRefed, RefCounted
 #include "mozilla/gfx/Types.h"          // for SurfaceFormat
-#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/LayersTypes.h"  // for LayersBackend, TextureDumpMode
 #include "mozilla/layers/TextureClient.h"  // for TextureClient
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 
 namespace mozilla {
 namespace layers {
 
@@ -25,65 +24,16 @@ class CompositableClient;
 class ImageBridgeChild;
 class ImageContainer;
 class CompositableForwarder;
 class CompositableChild;
 class PCompositableChild;
 class TextureClientRecycleAllocator;
 
 /**
- * Handle RemoveTextureFromCompositableAsync() transaction.
- */
-class RemoveTextureFromCompositableTracker : public AsyncTransactionTracker {
-public:
-  explicit RemoveTextureFromCompositableTracker(AsyncTransactionWaiter* aWaiter = nullptr)
-    : AsyncTransactionTracker(aWaiter)
-  {
-    MOZ_COUNT_CTOR(RemoveTextureFromCompositableTracker);
-  }
-
-protected:
-  ~RemoveTextureFromCompositableTracker()
-  {
-    MOZ_COUNT_DTOR(RemoveTextureFromCompositableTracker);
-    ReleaseTextureClient();
-  }
-
-public:
-  virtual void Complete() override
-  {
-    ReleaseTextureClient();
-  }
-
-  virtual void Cancel() override
-  {
-    ReleaseTextureClient();
-  }
-
-  virtual void SetTextureClient(TextureClient* aTextureClient) override
-  {
-    ReleaseTextureClient();
-    mTextureClient = aTextureClient;
-  }
-
-  virtual void SetReleaseFenceHandle(FenceHandle& aReleaseFenceHandle) override
-  {
-    if (mTextureClient) {
-      mTextureClient->SetReleaseFenceHandle(aReleaseFenceHandle);
-    }
-  }
-
-protected:
-  void ReleaseTextureClient();
-
-private:
-  RefPtr<TextureClient> mTextureClient;
-};
-
-/**
  * CompositableClient manages the texture-specific logic for composite layers,
  * independently of the layer. It is the content side of a CompositableClient/
  * CompositableHost pair.
  *
  * CompositableClient's purpose is to send texture data to the compositor side
  * along with any extra information about how the texture is to be composited.
  * Things like opacity or transformation belong to layer and not compositable.
  *
--- a/gfx/layers/client/GPUVideoTextureClient.h
+++ b/gfx/layers/client/GPUVideoTextureClient.h
@@ -19,17 +19,17 @@ public:
     : mSD(aSD)
     , mSize(aSize)
   {}
 
   ~GPUVideoTextureData() {};
 
   virtual void FillInfo(TextureData::Info& aInfo) const override;
 
-  virtual bool Lock(OpenMode, FenceHandle*) override { return true; };
+  virtual bool Lock(OpenMode) override { return true; };
 
   virtual void Unlock() override {};
 
   virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
 
   virtual void Deallocate(LayersIPCChannel* aAllocator) override;
 
   virtual void Forget(LayersIPCChannel* aAllocator) override;
--- 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,
@@ -65,53 +61,38 @@ ImageClient::CreateImageClient(Composita
   NS_ASSERTION(result, "Failed to create ImageClient");
 
   return result.forget();
 }
 
 void
 ImageClient::RemoveTexture(TextureClient* aTexture)
 {
-  RemoveTextureWithWaiter(aTexture);
-}
-
-void
-ImageClient::RemoveTextureWithWaiter(TextureClient* aTexture,
-                                     AsyncTransactionWaiter* aAsyncTransactionWaiter)
-{
-  if (aAsyncTransactionWaiter &&
-      GetForwarder()->GetTextureForwarder()->UsesImageBridge()) {
-    RefPtr<AsyncTransactionTracker> request =
-      new RemoveTextureFromCompositableTracker(aAsyncTransactionWaiter);
-    GetForwarder()->RemoveTextureFromCompositableAsync(request, this, aTexture);
-    return;
-  }
-  MOZ_ASSERT(!aAsyncTransactionWaiter);
   GetForwarder()->RemoveTextureFromCompositable(this, aTexture);
 }
 
 ImageClientSingle::ImageClientSingle(CompositableForwarder* aFwd,
                                      TextureFlags aFlags,
                                      CompositableType aType)
   : ImageClient(aFwd, aFlags, aType)
 {
 }
 
 TextureInfo ImageClientSingle::GetTextureInfo() const
 {
   return TextureInfo(CompositableType::IMAGE);
 }
 
 void
-ImageClientSingle::FlushAllImages(AsyncTransactionWaiter* aAsyncTransactionWaiter)
+ImageClientSingle::FlushAllImages()
 {
   MOZ_ASSERT(GetForwarder()->GetTextureForwarder()->UsesImageBridge());
 
   for (auto& b : mBuffers) {
-    RemoveTextureWithWaiter(b.mTextureClient, aAsyncTransactionWaiter);
+    RemoveTexture(b.mTextureClient);
   }
   mBuffers.Clear();
 }
 
 /* static */ already_AddRefed<TextureClient>
 ImageClient::CreateTextureClientForImage(Image* aImage, KnowsCompositor* aForwarder)
 {
   RefPtr<TextureClient> texture;
@@ -217,38 +198,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/ImageClient.h
+++ b/gfx/layers/client/ImageClient.h
@@ -6,31 +6,29 @@
 #ifndef MOZILLA_GFX_IMAGECLIENT_H
 #define MOZILLA_GFX_IMAGECLIENT_H
 
 #include <stdint.h>                     // for uint32_t, uint64_t
 #include <sys/types.h>                  // for int32_t
 #include "mozilla/Attributes.h"         // for override
 #include "mozilla/RefPtr.h"             // for RefPtr, already_AddRefed
 #include "mozilla/gfx/Types.h"          // for SurfaceFormat
-#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
 #include "mozilla/layers/CompositableClient.h"  // for CompositableClient
 #include "mozilla/layers/CompositorTypes.h"  // for CompositableType, etc
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
 #include "mozilla/layers/TextureClient.h"  // for TextureClient, etc
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsRect.h"                     // for mozilla::gfx::IntRect
 
 namespace mozilla {
 namespace layers {
 
 class ClientLayer;
 class CompositableForwarder;
-class AsyncTransactionTracker;
 class Image;
 class ImageContainer;
 class ShadowableLayer;
 class ImageClientSingle;
 
 /**
  * Image clients are used by basic image layers on the content thread, they
  * always match with an ImageHost on the compositor thread. See
@@ -59,23 +57,20 @@ public:
 
   void SetLayer(ClientLayer* aLayer) { mLayer = aLayer; }
   ClientLayer* GetLayer() const { return mLayer; }
 
   /**
    * asynchronously remove all the textures used by the image client.
    *
    */
-  virtual void FlushAllImages(AsyncTransactionWaiter* aAsyncTransactionWaiter) {}
+  virtual void FlushAllImages() {}
 
   virtual void RemoveTexture(TextureClient* aTexture) override;
 
-  void RemoveTextureWithWaiter(TextureClient* aTexture,
-                               AsyncTransactionWaiter* aAsyncTransactionWaiter = nullptr);
-
   virtual ImageClientSingle* AsImageClientSingle() { return nullptr; }
 
   static already_AddRefed<TextureClient> CreateTextureClientForImage(Image* aImage, KnowsCompositor* aForwarder);
 
 protected:
   ImageClient(CompositableForwarder* aFwd, TextureFlags aFlags,
               CompositableType aType);
 
@@ -97,17 +92,17 @@ public:
   virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags) override;
 
   virtual void OnDetach() override;
 
   virtual bool AddTextureClient(TextureClient* aTexture) override;
 
   virtual TextureInfo GetTextureInfo() const override;
 
-  virtual void FlushAllImages(AsyncTransactionWaiter* aAsyncTransactionWaiter) override;
+  virtual void FlushAllImages() override;
 
   ImageClientSingle* AsImageClientSingle() override { return this; }
 
 protected:
   struct Buffer {
     RefPtr<TextureClient> mTextureClient;
     int32_t mImageSerial;
   };
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -5,17 +5,16 @@
 
 #include "mozilla/layers/TextureClient.h"
 #include <stdint.h>                     // for uint8_t, uint32_t, etc
 #include "Layers.h"                     // for Layer, etc
 #include "gfx2DGlue.h"
 #include "gfxPlatform.h"                // for gfxPlatform
 #include "mozilla/Atomics.h"
 #include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
-#include "mozilla/layers/AsyncTransactionTracker.h"
 #include "mozilla/layers/CompositableForwarder.h"
 #include "mozilla/layers/ISurfaceAllocator.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/layers/ImageDataSerializer.h"
 #include "mozilla/layers/TextureClientRecycleAllocator.h"
 #include "mozilla/Mutex.h"
 #include "nsDebug.h"                    // for NS_ASSERTION, NS_WARNING, etc
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
@@ -48,21 +47,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 {
@@ -417,17 +411,16 @@ void TextureClient::Destroy(bool aForceS
 {
   if (mActor && !mIsLocked) {
     mActor->Lock();
   }
 
   mBorrowedDrawTarget = nullptr;
   mReadLock = nullptr;
 
-  CancelWaitFenceHandleOnImageBridge();
   RefPtr<TextureChild> actor = mActor;
   mActor = nullptr;
 
   if (actor && !actor->mDestroyed.compareExchange(false, true)) {
     actor->Unlock();
     actor = nullptr;
   }
 
@@ -492,29 +485,24 @@ TextureClient::Lock(OpenMode aMode)
   MOZ_ASSERT(!mIsLocked);
   if (!IsValid()) {
     return false;
   }
   if (mIsLocked) {
     return mOpenMode == aMode;
   }
 
-  if (!!mFenceHandleWaiter && (aMode & OpenMode::OPEN_WRITE)) {
-    mFenceHandleWaiter->WaitComplete();
-  }
-
   if (aMode & OpenMode::OPEN_WRITE && IsReadLocked()) {
     NS_WARNING("Attempt to Lock a texture that is being read by the compositor!");
     return false;
   }
 
   LockActor();
 
-  FenceHandle* fence = (mReleaseFenceHandle.IsValid() && (aMode & OpenMode::OPEN_WRITE)) ? &mReleaseFenceHandle : nullptr;
-  mIsLocked = mData->Lock(aMode, fence);
+  mIsLocked = mData->Lock(aMode);
   mOpenMode = aMode;
 
   auto format = GetFormat();
   if (mIsLocked && CanExposeDrawTarget() &&
       aMode == OpenMode::OPEN_READ_WRITE &&
       NS_IsMainThread() &&
       // the formats that we apparently expect, in the cairo backend. Any other
       // format will trigger an assertion in GfxFormatToCairoFormat.
@@ -715,31 +703,16 @@ TextureClient::BorrowMappedYCbCrData(Map
 bool
 TextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
 {
   MOZ_ASSERT(IsValid());
 
   return mData ? mData->Serialize(aOutDescriptor) : false;
 }
 
-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();
   return c;
 }
@@ -824,56 +797,16 @@ TextureClient::SetAddedToCompositableCli
     LockActor();
     if (IsValid() && mActor && !mActor->mDestroyed && mActor->IPCOpen()) {
       mActor->SendRecycleTexture(mFlags);
     }
     UnlockActor();
   }
 }
 
-void
-TextureClient::WaitFenceHandleOnImageBridge(Mutex& aMutex)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  aMutex.AssertCurrentThreadOwns();
-
-  if (!mFenceHandleWaiter) {
-    mFenceHandleWaiter = new AsyncTransactionWaiter();
-  }
-  MOZ_ASSERT(mFenceHandleWaiter->GetWaitCount() <= 1);
-  if (mFenceHandleWaiter->GetWaitCount() > 0) {
-    return;
-  }
-  mFenceHandleWaiter->IncrementWaitCount();
-}
-
-void
-TextureClient::ClearWaitFenceHandleOnImageBridge(Mutex& aMutex)
-{
-  aMutex.AssertCurrentThreadOwns();
-
-  if (!mFenceHandleWaiter) {
-    return;
-  }
-  MOZ_ASSERT(mFenceHandleWaiter->GetWaitCount() <= 1);
-  if (mFenceHandleWaiter->GetWaitCount() == 0) {
-    return;
-  }
-  mFenceHandleWaiter->DecrementWaitCount();
-}
-
-void
-TextureClient::CancelWaitFenceHandleOnImageBridge()
-{
-  if (!NeedsFenceHandle() || GetFlags() & TextureFlags::RECYCLE) {
-    return;
-  }
-  ImageBridgeChild::GetSingleton()->CancelWaitFenceHandle(this);
-}
-
 void CancelTextureClientRecycle(uint64_t aTextureId, LayersIPCChannel* aAllocator)
 {
   if (!aAllocator) {
     return;
   }
   MessageLoop* msgLoop = nullptr;
   msgLoop = aAllocator->GetMessageLoop();
   if (!msgLoop) {
@@ -889,17 +822,16 @@ void CancelTextureClientRecycle(uint64_t
 
 void
 TextureClient::CancelWaitForRecycle()
 {
   if (GetFlags() & TextureFlags::RECYCLE) {
     CancelTextureClientRecycle(mSerial, GetAllocator());
     return;
   }
-  CancelWaitFenceHandleOnImageBridge();
 }
 
 /* static */ void
 TextureClient::TextureClientRecycleCallback(TextureClient* aClient, void* aClosure)
 {
   MOZ_ASSERT(aClient->GetRecycleAllocator());
   aClient->GetRecycleAllocator()->RecycleTextureClient(aClient);
 }
@@ -1126,23 +1058,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
@@ -12,17 +12,16 @@
 #include "ImageTypes.h"                 // for StereoMode
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/Attributes.h"         // for override
 #include "mozilla/DebugOnly.h"
 #include "mozilla/RefPtr.h"             // for RefPtr, RefCounted
 #include "mozilla/gfx/2D.h"             // for DrawTarget
 #include "mozilla/gfx/Point.h"          // for IntSize
 #include "mozilla/gfx/Types.h"          // for SurfaceFormat
-#include "mozilla/layers/FenceUtils.h"  // for FenceHandle
 #include "mozilla/ipc/Shmem.h"          // for Shmem
 #include "mozilla/layers/AtomicRefCountedWithFinalize.h"
 #include "mozilla/layers/CompositorTypes.h"  // for TextureFlags, etc
 #include "mozilla/layers/ISurfaceAllocator.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "mozilla/gfx/CriticalSection.h"
@@ -37,27 +36,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;
@@ -260,17 +254,17 @@ public:
   };
 
   TextureData() { MOZ_COUNT_CTOR(TextureData); }
 
   virtual ~TextureData() { MOZ_COUNT_DTOR(TextureData); }
 
   virtual void FillInfo(TextureData::Info& aInfo) const = 0;
 
-  virtual bool Lock(OpenMode aMode, FenceHandle* aFence) = 0;
+  virtual bool Lock(OpenMode aMode) = 0;
 
   virtual void Unlock() = 0;
 
   virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() { return nullptr; }
 
   virtual bool BorrowMappedData(MappedTextureData&) { return false; }
 
   virtual bool BorrowMappedYCbCrData(MappedYCbCrTextureData&) { return false; }
@@ -287,32 +281,26 @@ public:
                 LayersBackend aLayersBackend,
                 TextureFlags aFlags = TextureFlags::DEFAULT,
                 TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const { return nullptr; }
 
   virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) { return false; };
 
   virtual bool ReadBack(TextureReadbackSink* aReadbackSink) { return false; }
 
-  /// Ideally this should not be exposed and users of TextureClient would use Lock/Unlock
-  /// preoperly but that requires a few changes to SharedSurface and maybe gonk video.
-  virtual void WaitForFence(FenceHandle* aFence) {};
-
   virtual void SyncWithObject(SyncObject* aFence) {};
 
   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.
@@ -585,46 +573,16 @@ public:
    * If the texture flags contain TextureFlags::DEALLOCATE_CLIENT, the destruction
    * will be synchronously coordinated with the compositor side, otherwise it
    * will be done asynchronously.
    * If sync is true, the destruction will be synchronous regardless of the
    * texture's flags (bad for performance, use with care).
    */
   void Destroy(bool sync = false);
 
-  virtual void SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle)
-  {
-    mReleaseFenceHandle.Merge(aReleaseFenceHandle);
-  }
-
-  virtual FenceHandle GetAndResetReleaseFenceHandle()
-  {
-    FenceHandle fence;
-    mReleaseFenceHandle.TransferToAnotherFenceHandle(fence);
-    return fence;
-  }
-
-  virtual void SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle)
-  {
-    mAcquireFenceHandle = aAcquireFenceHandle;
-  }
-
-  virtual const FenceHandle& GetAcquireFenceHandle() const
-  {
-    return mAcquireFenceHandle;
-  }
-
-  /**
-   * This function waits until the buffer is no longer being used.
-   *
-   * XXX - Ideally we shouldn't need this method because Lock the right
-   * thing already.
-   */
-  virtual void WaitForBufferOwnership(bool aWaitReleaseFence = true);
-
   /**
    * Track how much of this texture is wasted.
    * For example we might allocate a 256x256 tile but only use 10x10.
    */
   void SetWaste(int aWasteArea) {
     mWasteTracker.Update(aWasteArea, BytesPerPixel(GetFormat()));
   }
 
@@ -645,32 +603,16 @@ public:
   void SetRecycleAllocator(ITextureClientRecycleAllocator* aAllocator);
 
   /// 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();
 
   /**
    * Set last transaction id of CompositableForwarder.
    * 
    * Called when TextureClient has TextureFlags::RECYCLE flag.
    * When CompositableForwarder forwards the TextureClient with
    * TextureFlags::RECYCLE, it holds TextureClient's ref until host side
@@ -726,17 +668,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).
@@ -752,19 +693,16 @@ protected:
   RefPtr<TextureChild> mActor;
   RefPtr<ITextureClientRecycleAllocator> mRecycleAllocator;
   RefPtr<TextureReadLock> mReadLock;
 
   TextureData* mData;
   RefPtr<gfx::DrawTarget> mBorrowedDrawTarget;
 
   TextureFlags mFlags;
-  FenceHandle mReleaseFenceHandle;
-  FenceHandle mAcquireFenceHandle;
-  RefPtr<AsyncTransactionWaiter> mFenceHandleWaiter;
 
   gl::GfxTextureWasteTracker mWasteTracker;
 
   OpenMode mOpenMode;
 #ifdef DEBUG
   uint32_t mExpectedDtRefs;
 #endif
   bool mIsLocked;
@@ -784,17 +722,16 @@ protected:
   uint64_t mFwdTransactionId;
 
   // Serial id of TextureClient. It is unique in current process.
   const uint64_t mSerial;
   // Used to assign serial ids of TextureClient.
   static mozilla::Atomic<uint64_t> sSerialCounter;
 
   friend class TextureChild;
-  friend class RemoveTextureFromCompositableTracker;
   friend void TestTextureClientSurface(TextureClient*, gfxImageSurface*);
   friend void TestTextureClientYCbCr(TextureClient*, PlanarYCbCrData&);
 
 #ifdef GFX_DEBUG_TRACK_CLIENTS_IN_POOL
 public:
   // Pointer to the pool this tile came from.
   TextureClientPool* mPoolTracker;
 #endif
--- 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
@@ -35,17 +35,17 @@ protected:
 
   friend class SharedSurfaceTextureClient;
 
   explicit SharedSurfaceTextureData(UniquePtr<gl::SharedSurface> surf);
 public:
 
   ~SharedSurfaceTextureData();
 
-  virtual bool Lock(OpenMode, FenceHandle*) override { return false; }
+  virtual bool Lock(OpenMode) override { return false; }
 
   virtual void Unlock() override {}
 
   virtual void FillInfo(TextureData::Info& aInfo) const override;
 
   virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
 
   virtual void Deallocate(LayersIPCChannel*) override;
@@ -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
 
@@ -156,51 +151,16 @@ TextureHost::GetTextureSerial(PTexturePa
 }
 
 PTextureParent*
 TextureHost::GetIPDLActor()
 {
   return mActor;
 }
 
-bool
-TextureHost::SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle)
-{
-  if (!aReleaseFenceHandle.IsValid()) {
-    // HWC might not provide Fence.
-    // In this case, HWC implicitly handles buffer's fence.
-    return false;
-  }
-
-  mReleaseFenceHandle.Merge(aReleaseFenceHandle);
-
-  return true;
-}
-
-FenceHandle
-TextureHost::GetAndResetReleaseFenceHandle()
-{
-  FenceHandle fence;
-  mReleaseFenceHandle.TransferToAnotherFenceHandle(fence);
-  return fence;
-}
-
-void
-TextureHost::SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle)
-{
-  mAcquireFenceHandle = aAcquireFenceHandle;
-}
-
-FenceHandle
-TextureHost::GetAndResetAcquireFenceHandle()
-{
-  RefPtr<FenceHandle::FdObj> fdObj = mAcquireFenceHandle.GetAndResetFdObj();
-  return FenceHandle(fdObj);
-}
-
 void
 TextureHost::SetLastFwdTransactionId(uint64_t aTransactionId)
 {
   MOZ_ASSERT(mFwdTransactionId <= aTransactionId);
   mFwdTransactionId = aTransactionId;
 }
 
 // implemented in TextureHostOGL.cpp
@@ -236,17 +196,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 +340,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
@@ -12,17 +12,16 @@
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/Attributes.h"         // for override
 #include "mozilla/RefPtr.h"             // for RefPtr, already_AddRefed, etc
 #include "mozilla/gfx/2D.h"             // for DataSourceSurface
 #include "mozilla/gfx/Point.h"          // for IntSize, IntPoint
 #include "mozilla/gfx/Types.h"          // for SurfaceFormat, etc
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/CompositorTypes.h"  // for TextureFlags, etc
-#include "mozilla/layers/FenceUtils.h"  // for FenceHandle
 #include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
 #include "mozilla/layers/LayersSurfaces.h"
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "mozilla/UniquePtr.h"          // for UniquePtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsRegion.h"                   // for nsIntRegion
@@ -39,17 +38,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;
@@ -582,60 +580,30 @@ public:
       UnbindTextureSource();
       // Send mFwdTransactionId to client side if necessary.
       NotifyNotUsed();
     }
   }
 
   int NumCompositableRefs() const { return mCompositableCount; }
 
-  /**
-   * Store a fence that will signal when the current buffer is no longer being read.
-   * Similar to android's GLConsumer::setReleaseFence()
-   */
-  bool SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle);
-
-  /**
-   * Return a releaseFence's Fence and clear a reference to the Fence.
-   */
-  FenceHandle GetAndResetReleaseFenceHandle();
-
-  void SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle);
-
-  /**
-   * Return a acquireFence's Fence and clear a reference to the Fence.
-   */
-  FenceHandle GetAndResetAcquireFenceHandle();
-
-  virtual void WaitAcquireFenceHandleSyncComplete() {};
-
   void SetLastFwdTransactionId(uint64_t aTransactionId);
 
-  virtual bool NeedsFenceHandle() { return false; }
-
-  virtual FenceHandle GetCompositorReleaseFence() { return FenceHandle(); }
-
   void DeserializeReadLock(const ReadLockDescriptor& aDesc,
                            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);
 
   virtual void UpdatedInternal(const nsIntRegion *Region) {}
 
   /**
    * Called when mCompositableCount becomes 0.
    */
   void NotifyNotUsed();
--- 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/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -244,25 +244,25 @@ D3D11TextureData::D3D11TextureData(ID3D1
 
 D3D11TextureData::~D3D11TextureData()
 {
 #ifdef DEBUG
   // An Azure DrawTarget needs to be locked when it gets nullptr'ed as this is
   // when it calls EndDraw. This EndDraw should not execute anything so it
   // shouldn't -really- need the lock but the debug layer chokes on this.
   if (mDrawTarget) {
-    Lock(OpenMode::OPEN_NONE, nullptr);
+    Lock(OpenMode::OPEN_NONE);
     mDrawTarget = nullptr;
     Unlock();
   }
 #endif
 }
 
 bool
-D3D11TextureData::Lock(OpenMode aMode, FenceHandle*)
+D3D11TextureData::Lock(OpenMode aMode)
 {
   if (!LockD3DTexture(mTexture.get())) {
     return false;
   }
 
   if (NS_IsMainThread() && !mIsForOutOfBandContent) {
     if (!PrepareDrawTargetInLock(aMode)) {
       Unlock();
--- a/gfx/layers/d3d11/TextureD3D11.h
+++ b/gfx/layers/d3d11/TextureD3D11.h
@@ -60,29 +60,28 @@ public:
          ID3D11Device* aDevice = nullptr);
   static DXGITextureData*
   Create(gfx::SourceSurface* aSurface,
          TextureAllocationFlags aAllocFlags,
          ID3D11Device* aDevice = nullptr);
 
   virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
 
-  virtual bool Lock(OpenMode aMode, FenceHandle*) override;
+  virtual bool Lock(OpenMode aMode) override;
 
   virtual void Unlock() override;
 
   virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
 
   virtual TextureData*
   CreateSimilar(LayersIPCChannel* aAllocator,
                 LayersBackend aLayersBackend,
                 TextureFlags aFlags,
                 TextureAllocationFlags aAllocFlags) const override;
 
-  // TODO - merge this with the FenceHandle API!
   virtual void SyncWithObject(SyncObject* aSync) override;
 
   ID3D11Texture2D* GetD3D11Texture() { return mTexture; }
 
   virtual void Deallocate(LayersIPCChannel* aAllocator) override;
 
   D3D11TextureData* AsD3D11TextureData() override {
     return this;
@@ -131,17 +130,17 @@ public:
   Create(TextureFlags aFlags,
          ID3D11Texture2D* aTextureCb,
          ID3D11Texture2D* aTextureY,
          ID3D11Texture2D* aTextureCr,
          const gfx::IntSize& aSize,
          const gfx::IntSize& aSizeY,
          const gfx::IntSize& aSizeCbCr);
 
-  virtual bool Lock(OpenMode, FenceHandle*) override { return true; }
+  virtual bool Lock(OpenMode) override { return true; }
 
   virtual void Unlock() override {}
 
   virtual void FillInfo(TextureData::Info& aInfo) const override;
 
   virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
 
   virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override { return nullptr; }
--- a/gfx/layers/d3d9/TextureD3D9.cpp
+++ b/gfx/layers/d3d9/TextureD3D9.cpp
@@ -605,17 +605,17 @@ D3D9TextureData::FillInfo(TextureData::I
   aInfo.format = mFormat;
   aInfo.hasIntermediateBuffer = true;
   aInfo.supportsMoz2D = true;
   aInfo.canExposeMappedData = false;
   aInfo.hasSynchronization = false;
 }
 
 bool
-D3D9TextureData::Lock(OpenMode aMode, FenceHandle*)
+D3D9TextureData::Lock(OpenMode aMode)
 {
   if (!DeviceManagerD3D9::GetDevice()) {
     // If the device has failed then we should not lock the surface,
     // even if we could.
     mD3D9Surface = nullptr;
     return false;
   }
 
--- a/gfx/layers/d3d9/TextureD3D9.h
+++ b/gfx/layers/d3d9/TextureD3D9.h
@@ -173,17 +173,17 @@ protected:
  */
 class D3D9TextureData : public TextureData
 {
 public:
   ~D3D9TextureData();
 
   virtual bool Serialize(SurfaceDescriptor& aOutDescrptor) override;
 
-  virtual bool Lock(OpenMode aMode, FenceHandle*) override;
+  virtual bool Lock(OpenMode aMode) override;
 
   virtual void Unlock() override;
 
   virtual void FillInfo(TextureData::Info& aInfo) const override;
 
   virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
 
   virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
@@ -222,17 +222,17 @@ class DXGID3D9TextureData : public Textu
 public:
   static DXGID3D9TextureData*
   Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, TextureFlags aFlags, IDirect3DDevice9* aDevice);
 
   ~DXGID3D9TextureData();
 
   virtual void FillInfo(TextureData::Info& aInfo) const override;
 
-  virtual bool Lock(OpenMode, FenceHandle*) override { return true; }
+  virtual bool Lock(OpenMode) override { return true; }
 
   virtual void Unlock() override {}
 
   virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
 
   virtual void Deallocate(LayersIPCChannel* aAllocator) override {}
 
   IDirect3DDevice9* GetD3D9Device() { return mDevice; }
deleted file mode 100755
--- a/gfx/layers/ipc/AsyncTransactionTracker.cpp
+++ /dev/null
@@ -1,169 +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 "AsyncTransactionTracker.h"
-
-#include "mozilla/layers/ImageBridgeChild.h"  // for ImageBridgeChild
-#include "mozilla/gfx/Logging.h"
-
-namespace mozilla {
-namespace layers {
-
-void
-AsyncTransactionWaiter::WaitComplete()
-{
-  MOZ_ASSERT(!InImageBridgeChildThread());
-
-  MonitorAutoLock mon(mCompletedMonitor);
-  int count = 0;
-  const int maxCount = 5;
-  while (mWaitCount > 0 && (count < maxCount)) {
-    if (!NS_SUCCEEDED(mCompletedMonitor.Wait(PR_MillisecondsToInterval(10000)))) {
-      NS_WARNING("Failed to wait Monitor");
-      return;
-    }
-    if (count > 1) {
-      printf_stderr("Waiting async transaction complete.\n");
-    }
-    count++;
-  }
-
-  if (mWaitCount > 0) {
-    printf_stderr("Timeout of waiting transaction complete.");
-  }
-
-  if (count == maxCount) {
-    gfxDevCrash(gfx::LogReason::AsyncTransactionTimeout) << "Bug 1244883: AsyncTransactionWaiter timed out.";
-  }
-}
-
-Atomic<uint64_t> AsyncTransactionTracker::sSerialCounter(0);
-
-AsyncTransactionTracker::AsyncTransactionTracker(AsyncTransactionWaiter* aWaiter)
-    : mSerial(GetNextSerial())
-    , mWaiter(aWaiter)
-#ifdef DEBUG
-    , mCompleted(false)
-#endif
-{
-  if (mWaiter) {
-    mWaiter->IncrementWaitCount();
-  }
-}
-
-AsyncTransactionTracker::~AsyncTransactionTracker()
-{
-}
-
-void
-AsyncTransactionTracker::NotifyComplete()
-{
-  MOZ_ASSERT(!mCompleted);
-#ifdef DEBUG
-  mCompleted = true;
-#endif
-  Complete();
-  if (mWaiter) {
-    mWaiter->DecrementWaitCount();
-  }
-}
-
-void
-AsyncTransactionTracker::NotifyCancel()
-{
-  MOZ_ASSERT(!mCompleted);
-#ifdef DEBUG
-  mCompleted = true;
-#endif
-  Cancel();
-  if (mWaiter) {
-    mWaiter->DecrementWaitCount();
-  }
-}
-
-Atomic<uint64_t> AsyncTransactionTrackersHolder::sSerialCounter(0);
-
-AsyncTransactionTrackersHolder::AsyncTransactionTrackersHolder()
-  : mSerial(GetNextSerial())
-  , mIsTrackersHolderDestroyed(false)
-{
-  MOZ_COUNT_CTOR(AsyncTransactionTrackersHolder);
-}
-
-AsyncTransactionTrackersHolder::~AsyncTransactionTrackersHolder()
-{
-  if (!mIsTrackersHolderDestroyed) {
-    DestroyAsyncTransactionTrackersHolder();
-  }
-  MOZ_COUNT_DTOR(AsyncTransactionTrackersHolder);
-}
-
-void
-AsyncTransactionTrackersHolder::HoldUntilComplete(AsyncTransactionTracker* aTransactionTracker)
-{
-  if (!aTransactionTracker) {
-    return;
-  }
-
-  if (mIsTrackersHolderDestroyed && aTransactionTracker) {
-    aTransactionTracker->NotifyComplete();
-    return;
-  }
-
-  if (aTransactionTracker) {
-    mAsyncTransactionTrackers[aTransactionTracker->GetId()] = aTransactionTracker;
-  }
-}
-
-void
-AsyncTransactionTrackersHolder::TransactionCompleteted(uint64_t aTransactionId)
-{
-  TransactionCompletetedInternal(aTransactionId);
-}
-
-void
-AsyncTransactionTrackersHolder::TransactionCompletetedInternal(uint64_t aTransactionId)
-{
-  std::map<uint64_t, RefPtr<AsyncTransactionTracker> >::iterator it
-    = mAsyncTransactionTrackers.find(aTransactionId);
-  if (it != mAsyncTransactionTrackers.end()) {
-    it->second->NotifyComplete();
-    mAsyncTransactionTrackers.erase(it);
-  }
-}
-
-void
-AsyncTransactionTrackersHolder::SetReleaseFenceHandle(FenceHandle& aReleaseFenceHandle,
-                                                      uint64_t aTransactionId)
-{
-  std::map<uint64_t, RefPtr<AsyncTransactionTracker> >::iterator it
-    = mAsyncTransactionTrackers.find(aTransactionId);
-  if (it != mAsyncTransactionTrackers.end()) {
-    it->second->SetReleaseFenceHandle(aReleaseFenceHandle);
-  }
-}
-
-void
-AsyncTransactionTrackersHolder::ClearAllAsyncTransactionTrackers()
-{
-  std::map<uint64_t, RefPtr<AsyncTransactionTracker> >::iterator it;
-  for (it = mAsyncTransactionTrackers.begin();
-       it != mAsyncTransactionTrackers.end(); it++) {
-    it->second->NotifyCancel();
-  }
-  mAsyncTransactionTrackers.clear();
-}
-
-void
-AsyncTransactionTrackersHolder::DestroyAsyncTransactionTrackersHolder() {
-  mIsTrackersHolderDestroyed = true;
-  ClearAllAsyncTransactionTrackers();
-}
-
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/ipc/AsyncTransactionTracker.h
+++ /dev/null
@@ -1,172 +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_AsyncTransactionTracker_h
-#define mozilla_layers_AsyncTransactionTracker_h
-
-#include <map>
-
-#include "mozilla/Atomics.h"
-#include "mozilla/layers/FenceUtils.h"  // for FenceHandle
-#include "mozilla/Monitor.h"      // for Monitor
-#include "mozilla/RefPtr.h"       // for AtomicRefCounted
-
-namespace mozilla {
-namespace layers {
-
-class TextureClient;
-class AsyncTransactionTrackersHolder;
-
-/**
- * Object that lets you wait for one or more async transactions to complete.
- */
-class AsyncTransactionWaiter
-{
-public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AsyncTransactionWaiter)
-
-  AsyncTransactionWaiter()
-    : mCompletedMonitor("AsyncTransactionWaiter")
-    , mWaitCount(0)
-  {}
-
-  void IncrementWaitCount()
-  {
-    MonitorAutoLock lock(mCompletedMonitor);
-    ++mWaitCount;
-  }
-  void DecrementWaitCount()
-  {
-    MonitorAutoLock lock(mCompletedMonitor);
-    MOZ_ASSERT(mWaitCount > 0);
-    --mWaitCount;
-    if (mWaitCount == 0) {
-      mCompletedMonitor.Notify();
-    }
-  }
-
-  /**
-   * Wait until asynchronous transactions complete.
-   */
-  void WaitComplete();
-
-  uint32_t GetWaitCount() { return mWaitCount; }
-
-private:
-  ~AsyncTransactionWaiter() {}
-
-  Monitor mCompletedMonitor;
-  uint32_t mWaitCount;
-};
-
-/**
- * AsyncTransactionTracker tracks asynchronous transaction.
- * It is typically used for asynchronous layer transaction handling.
- */
-class AsyncTransactionTracker
-{
-  friend class AsyncTransactionTrackersHolder;
-public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AsyncTransactionTracker)
-
-  explicit AsyncTransactionTracker(AsyncTransactionWaiter* aWaiter = nullptr);
-
-  /**
-   * Notify async transaction complete.
-   */
-  void NotifyComplete();
-
-  /**
-   * Notify async transaction cancel.
-   */
-  void NotifyCancel();
-
-  uint64_t GetId()
-  {
-    return mSerial;
-  }
-
-  /**
-   * Called when asynchronous transaction complete.
-   */
-  virtual void Complete()= 0;
-
-  /**
-   * Called when asynchronous transaction is cancelled.
-   * The cancel typically happens when IPC is disconnected
-   */
-  virtual void Cancel()= 0;
-
-  virtual void SetTextureClient(TextureClient* aTextureClient) {}
-
-  virtual void SetReleaseFenceHandle(FenceHandle& aReleaseFenceHandle) {}
-
-protected:
-  virtual ~AsyncTransactionTracker();
-
-  static uint64_t GetNextSerial()
-  {
-    return ++sSerialCounter;
-  }
-
-  uint64_t mSerial;
-  RefPtr<AsyncTransactionWaiter> mWaiter;
-#ifdef DEBUG
-  bool mCompleted;
-#endif
-
-  static Atomic<uint64_t> sSerialCounter;
-};
-
-class AsyncTransactionTrackersHolder
-{
-public:
-  AsyncTransactionTrackersHolder();
-  virtual ~AsyncTransactionTrackersHolder();
-
-  void HoldUntilComplete(AsyncTransactionTracker* aTransactionTracker);
-
-  void TransactionCompleteted(uint64_t aTransactionId);
-
-  static void TransactionCompleteted(uint64_t aHolderId, uint64_t aTransactionId);
-
-  static void SetReleaseFenceHandle(FenceHandle& aReleaseFenceHandle,
-                                    uint64_t aHolderId,
-                                    uint64_t aTransactionId);
-
-  uint64_t GetId()
-  {
-    return mSerial;
-  }
-
-  void DestroyAsyncTransactionTrackersHolder();
-
-protected:
-
-  static uint64_t GetNextSerial()
-  {
-    return ++sSerialCounter;
-  }
-
-  void TransactionCompletetedInternal(uint64_t aTransactionId);
-
-  void SetReleaseFenceHandle(FenceHandle& aReleaseFenceHandle, uint64_t aTransactionId);
-
-  void ClearAllAsyncTransactionTrackers();
-
-  const uint64_t mSerial;
-
-  bool mIsTrackersHolderDestroyed;
-  std::map<uint64_t, RefPtr<AsyncTransactionTracker> > mAsyncTransactionTrackers;
-
-  static Atomic<uint64_t> sSerialCounter;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif  // mozilla_layers_AsyncTransactionTracker_h
--- a/gfx/layers/ipc/CompositableForwarder.h
+++ b/gfx/layers/ipc/CompositableForwarder.h
@@ -21,17 +21,16 @@
 #include "mozilla/gfx/Rect.h"
 #include "nsHashKeys.h"
 #include "nsTHashtable.h"
 
 namespace mozilla {
 namespace layers {
 
 class CompositableClient;
-class AsyncTransactionTracker;
 class ImageContainer;
 class SurfaceDescriptor;
 class SurfaceDescriptorTiles;
 class ThebesBufferData;
 class PTextureChild;
 
 /**
  * A transaction is a set of changes that happenned on the content side, that
@@ -67,51 +66,32 @@ 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.
    * This function does not delete the TextureHost corresponding to the
    * TextureClient passed in parameter.
    * When the TextureClient has TEXTURE_DEALLOCATE_CLIENT flag,
    * the transaction becomes synchronous.
    */
   virtual void RemoveTextureFromCompositable(CompositableClient* aCompositable,
                                              TextureClient* aTexture) = 0;
 
-  /**
-   * Tell the CompositableHost on the compositor side to remove the texture
-   * from the CompositableHost. The compositor side sends back transaction
-   * complete message.
-   * This function does not delete the TextureHost corresponding to the
-   * TextureClient passed in parameter.
-   * It is used when the TextureClient recycled.
-   * Only ImageBridge implements it.
-   */
-  virtual void RemoveTextureFromCompositableAsync(AsyncTransactionTracker* aAsyncTransactionTracker,
-                                                  CompositableClient* aCompositable,
-                                                  TextureClient* aTexture) {}
-
   struct TimedTextureClient {
     TimedTextureClient()
         : mTextureClient(nullptr), mFrameID(0), mProducerID(0) {}
 
     TextureClient* mTextureClient;
     TimeStamp mTimeStamp;
     nsIntRect mPictureRect;
     int32_t mFrameID;
--- 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
 
@@ -154,54 +153,31 @@ CompositableParentManager::ReceiveCompos
       const OpRemoveTexture& op = aEdit.detail().get_OpRemoveTexture();
 
       RefPtr<TextureHost> tex = TextureHost::AsTextureHost(op.textureParent());
 
       MOZ_ASSERT(tex.get());
       compositable->RemoveTextureHost(tex);
       break;
     }
-    case CompositableOperationDetail::TOpRemoveTextureAsync: {
-      const OpRemoveTextureAsync& op = aEdit.detail().get_OpRemoveTextureAsync();
-      RefPtr<TextureHost> tex = TextureHost::AsTextureHost(op.textureParent());
-
-      MOZ_ASSERT(tex.get());
-      compositable->RemoveTextureHost(tex);
-
-      // Only ImageBridge child sends it.
-      MOZ_ASSERT(UsesImageBridge());
-      if (UsesImageBridge()) {
-        ReplyRemoveTexture(OpReplyRemoveTexture(op.holderId(),
-                                                op.transactionId()));
-      }
-      break;
-    }
     case CompositableOperationDetail::TOpUseTexture: {
       const OpUseTexture& op = aEdit.detail().get_OpUseTexture();
 
       AutoTArray<CompositableHost::TimedTexture,4> textures;
       for (auto& timedTexture : op.textures()) {
         CompositableHost::TimedTexture* t = textures.AppendElement();
         t->mTexture =
             TextureHost::AsTextureHost(timedTexture.textureParent());
         MOZ_ASSERT(t->mTexture);
         t->mTimeStamp = timedTexture.timeStamp();
         t->mPictureRect = timedTexture.picture();
         t->mFrameID = timedTexture.frameID();
         t->mProducerID = timedTexture.producerID();
         t->mTexture->DeserializeReadLock(timedTexture.sharedLock(), this);
         MOZ_ASSERT(ValidatePictureRect(t->mTexture->GetSize(), t->mPictureRect));
-
-        MaybeFence maybeFence = timedTexture.fence();
-        if (maybeFence.type() == MaybeFence::TFenceHandle) {
-          FenceHandle fence = maybeFence.get_FenceHandle();
-          if (fence.IsValid()) {
-            t->mTexture->SetAcquireFenceHandle(fence);
-          }
-        }
       }
       if (textures.Length() > 0) {
         compositable->UseTextureHost(textures);
 
         for (auto& timedTexture : op.textures()) {
           RefPtr<TextureHost> texture = TextureHost::AsTextureHost(timedTexture.textureParent());
           if (texture) {
             texture->SetLastFwdTransactionId(mFwdTransactionId);
@@ -241,26 +217,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/CompositableTransactionParent.h
+++ b/gfx/layers/ipc/CompositableTransactionParent.h
@@ -5,17 +5,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 MOZILLA_LAYERS_COMPOSITABLETRANSACTIONPARENT_H
 #define MOZILLA_LAYERS_COMPOSITABLETRANSACTIONPARENT_H
 
 #include <vector>                       // for vector
 #include "mozilla/Attributes.h"         // for override
-#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
 #include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator
 #include "mozilla/layers/LayersMessages.h"  // for EditReply, etc
 
 namespace mozilla {
 namespace layers {
 
 class CompositableHost;
 
@@ -42,17 +41,15 @@ public:
 
 protected:
   /**
    * Handle the IPDL messages that affect PCompositable actors.
    */
   bool ReceiveCompositableUpdate(const CompositableOperation& aEdit,
                                  EditReplyVector& replyv);
 
-  virtual void ReplyRemoveTexture(const OpReplyRemoveTexture& aReply) {};
-
   uint64_t mFwdTransactionId = 0;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif
--- 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/CompositorBridgeChild.cpp
+++ b/gfx/layers/ipc/CompositorBridgeChild.cpp
@@ -871,22 +871,16 @@ CompositorBridgeChild::DeallocPTextureCh
 
 bool
 CompositorBridgeChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessageData>&& aMessages)
 {
   for (AsyncParentMessageArray::index_type i = 0; i < aMessages.Length(); ++i) {
     const AsyncParentMessageData& message = aMessages[i];
 
     switch (message.type()) {
-      case AsyncParentMessageData::TOpDeliverFence: {
-        const OpDeliverFence& op = message.get_OpDeliverFence();
-        FenceHandle fence = op.fence();
-        DeliverFence(op.TextureId(), fence);
-        break;
-      }
       case AsyncParentMessageData::TOpNotifyNotUsed: {
         const OpNotifyNotUsed& op = message.get_OpNotifyNotUsed();
         NotifyNotUsed(op.TextureId(), op.fwdTransactionId());
         break;
       }
       default:
         NS_ERROR("unknown AsyncParentMessageData type");
         return false;
@@ -913,31 +907,22 @@ CompositorBridgeChild::RecvObserveLayerU
 
 void
 CompositorBridgeChild::HoldUntilCompositableRefReleasedIfNecessary(TextureClient* aClient)
 {
   if (!aClient) {
     return;
   }
 
-  if (!(aClient->GetFlags() & TextureFlags::RECYCLE) &&
-     !aClient->NeedsFenceHandle()) {
+  if (!(aClient->GetFlags() & TextureFlags::RECYCLE)) {
     return;
   }
 
-  if (aClient->GetFlags() & TextureFlags::RECYCLE) {
-    aClient->SetLastFwdTransactionId(GetFwdTransactionId());
-    mTexturesWaitingRecycled.Put(aClient->GetSerial(), aClient);
-    return;
-  }
-  MOZ_ASSERT(!(aClient->GetFlags() & TextureFlags::RECYCLE));
-  MOZ_ASSERT(aClient->NeedsFenceHandle());
-  // Handle a case of fence delivery via ImageBridge.
-  // GrallocTextureData alwasys requests fence delivery if ANDROID_VERSION >= 17.
-  ImageBridgeChild::GetSingleton()->HoldUntilFenceHandleDelivery(aClient, GetFwdTransactionId());
+  aClient->SetLastFwdTransactionId(GetFwdTransactionId());
+  mTexturesWaitingRecycled.Put(aClient->GetSerial(), aClient);
 }
 
 void
 CompositorBridgeChild::NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId)
 {
   RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
   if (!client) {
     return;
@@ -945,26 +930,16 @@ CompositorBridgeChild::NotifyNotUsed(uin
   if (aFwdTransactionId < client->GetLastFwdTransactionId()) {
     // Released on host side, but client already requested newer use texture.
     return;
   }
   mTexturesWaitingRecycled.Remove(aTextureId);
 }
 
 void
-CompositorBridgeChild::DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle)
-{
-  RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
-  if (!client) {
-    return;
-  }
-  client->SetReleaseFenceHandle(aReleaseFenceHandle);
-}
-
-void
 CompositorBridgeChild::CancelWaitForRecycle(uint64_t aTextureId)
 {
   RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
   if (!client) {
     return;
   }
   mTexturesWaitingRecycled.Remove(aTextureId);
 }
--- a/gfx/layers/ipc/CompositorBridgeChild.h
+++ b/gfx/layers/ipc/CompositorBridgeChild.h
@@ -184,18 +184,16 @@ public:
   void HoldUntilCompositableRefReleasedIfNecessary(TextureClient* aClient);
 
   /**
    * Notify id of Texture When host side end its use. Transaction id is used to
    * make sure if there is no newer usage.
    */
   void NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId);
 
-  void DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle);
-
   virtual void CancelWaitForRecycle(uint64_t aTextureId) override;
 
   TextureClientPool* GetTexturePool(KnowsCompositor* aAllocator,
                                     gfx::SurfaceFormat aFormat,
                                     TextureFlags aFlags);
   void ClearTexturePool();
 
   virtual FixedSizeSmallShmemSectionAllocator* GetTileLockAllocator() override;
--- 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;
@@ -112,48 +107,23 @@ CompositorBridgeParentBase::GetChildProc
 void
 CompositorBridgeParentBase::NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId)
 {
   RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
   if (!texture) {
     return;
   }
 
-  if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
-     !texture->NeedsFenceHandle()) {
-    return;
-  }
-
-  if (texture->GetFlags() & TextureFlags::RECYCLE) {
-    SendFenceHandleIfPresent(aTexture);
-    uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
-    mPendingAsyncMessage.push_back(
-      OpNotifyNotUsed(textureId, aTransactionId));
+  if (!(texture->GetFlags() & TextureFlags::RECYCLE)) {
     return;
   }
 
-  // Gralloc requests to deliver fence to client side.
-  // If client side does not use TextureFlags::RECYCLE flag,
-  // The fence can not be delivered via LayerTransactionParent.
-  // TextureClient might wait the fence delivery on main thread.
-
-  MOZ_ASSERT(ImageBridgeParent::GetInstance(GetChildProcessId()));
-  if (ImageBridgeParent::GetInstance(GetChildProcessId())) {
-    // Send message back via PImageBridge.
-    ImageBridgeParent::NotifyNotUsedToNonRecycle(
-      GetChildProcessId(),
-      aTexture,
-      aTransactionId);
-   } else {
-     NS_ERROR("ImageBridgeParent should exist");
-   }
-
-   if (!IsAboutToSendAsyncMessages()) {
-     SendPendingAsyncMessages();
-   }
+  uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
+  mPendingAsyncMessage.push_back(
+    OpNotifyNotUsed(textureId, aTransactionId));
 }
 
 void
 CompositorBridgeParentBase::SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage)
 {
   Unused << SendParentAsyncMessages(aMessage);
 }
 
@@ -344,114 +314,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 +418,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 +540,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:
deleted file mode 100644
--- a/gfx/layers/ipc/FenceUtils.cpp
+++ /dev/null
@@ -1,111 +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/. */
-
-#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 {
-
-FenceHandle::FenceHandle()
-  : mFence(new FdObj())
-{
-}
-
-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();
-}
-
-already_AddRefed<FenceHandle::FdObj>
-FenceHandle::GetAndResetFdObj()
-{
-  RefPtr<FdObj> fence = mFence;
-  mFence = new FdObj();
-  return fence.forget();
-}
-
-already_AddRefed<FenceHandle::FdObj>
-FenceHandle::GetDupFdObj()
-{
-  RefPtr<FdObj> fdObj;
-  if (IsValid()) {
-    fdObj = new FenceHandle::FdObj(dup(mFence->mFd));
-  } else {
-    fdObj = new FenceHandle::FdObj();
-  }
-  return fdObj.forget();
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/ipc/FenceUtils.h
+++ /dev/null
@@ -1,84 +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 IPC_FencerUtils_h
-#define IPC_FencerUtils_h
-
-#include "ipc/IPCMessageUtils.h"
-#include "mozilla/RefPtr.h"             // for nsRefPtr
-
-namespace mozilla {
-namespace layers {
-
-class FenceHandle {
-public:
-  class FdObj {
-    NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FdObj)
-    friend class FenceHandle;
-  public:
-    FdObj()
-      : mFd(-1) {}
-    explicit FdObj(int aFd)
-      : mFd(aFd) {}
-    int GetAndResetFd()
-    {
-      int fd = mFd;
-      mFd = -1;
-      return fd;
-    }
-
-  private:
-    virtual ~FdObj() {
-      if (mFd != -1) {
-        close(mFd);
-      }
-    }
-
-    int mFd;
-  };
-
-  FenceHandle();
-
-  explicit FenceHandle(FdObj* aFdObj);
-
-  bool operator==(const FenceHandle& aOther) const {
-    return mFence.get() == aOther.mFence.get();
-  }
-
-  bool IsValid() const
-  {
-    return (mFence->mFd != -1);
-  }
-
-  void Merge(const FenceHandle& aFenceHandle);
-
-  void TransferToAnotherFenceHandle(FenceHandle& aFenceHandle);
-
-  already_AddRefed<FdObj> GetAndResetFdObj();
-
-  already_AddRefed<FdObj> GetDupFdObj();
-
-private:
-  RefPtr<FdObj> mFence;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-namespace IPC {
-
-template <>
-struct ParamTraits<mozilla::layers::FenceHandle> {
-  typedef mozilla::layers::FenceHandle paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam);
-  static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult);
-};
-
-} // namespace IPC
-
-#endif // IPC_FencerUtils_h
--- 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.cpp
+++ b/gfx/layers/ipc/ISurfaceAllocator.cpp
@@ -20,44 +20,16 @@ NS_IMPL_ISUPPORTS(GfxMemoryImageReporter
 mozilla::Atomic<ptrdiff_t> GfxMemoryImageReporter::sAmount(0);
 
 mozilla::ipc::SharedMemory::SharedMemoryType OptimalShmemType()
 {
   return ipc::SharedMemory::SharedMemoryType::TYPE_BASIC;
 }
 
 void
-HostIPCAllocator::SendFenceHandleIfPresent(PTextureParent* aTexture)
-{
-  RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
-  if (!texture) {
-    return;
-  }
-
-  if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
-     !texture->NeedsFenceHandle()) {
-    return;
-  }
-
-  uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
-
-  // Send a ReleaseFence of CompositorOGL.
-  FenceHandle fence = texture->GetCompositorReleaseFence();
-  if (fence.IsValid()) {
-    mPendingAsyncMessage.push_back(OpDeliverFence(textureId, fence));
-  }
-
-  // Send a ReleaseFence that is set to TextureHost by HwcComposer2D.
-  fence = texture->GetAndResetReleaseFenceHandle();
-  if (fence.IsValid()) {
-    mPendingAsyncMessage.push_back(OpDeliverFence(textureId, fence));
-  }
-}
-
-void
 HostIPCAllocator::SendPendingAsyncMessages()
 {
   if (mPendingAsyncMessage.empty()) {
     return;
   }
 
   // Some type of AsyncParentMessageData message could have
   // one file descriptor (e.g. OpDeliverFence).
--- 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
 
@@ -143,18 +131,16 @@ public:
    * Get child side's process Id.
    */
   virtual base::ProcessId GetChildProcessId() = 0;
 
   virtual void NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) = 0;
 
   virtual void SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage) = 0;
 
-  void SendFenceHandleIfPresent(PTextureParent* aTexture);
-
   virtual void SendPendingAsyncMessages();
 
   virtual void SetAboutToSendAsyncMessages()
   {
     mAboutToSendAsyncMessages = true;
   }
 
   bool IsAboutToSendAsyncMessages()
--- a/gfx/layers/ipc/ImageBridgeChild.cpp
+++ b/gfx/layers/ipc/ImageBridgeChild.cpp
@@ -166,20 +166,18 @@ ImageBridgeChild::UseTextures(Compositab
 
     if (!t.mTextureClient->IsSharedWithCompositor()) {
       return;
     }
 
     ReadLockDescriptor readLock;
     t.mTextureClient->SerializeReadLock(readLock);
 
-    FenceHandle fence = t.mTextureClient->GetAcquireFenceHandle();
     textures.AppendElement(TimedTexture(nullptr, t.mTextureClient->GetIPDLActor(),
                                         readLock,
-                                        fence.IsValid() ? MaybeFence(fence) : MaybeFence(null_t()),
                                         t.mTimeStamp, t.mPictureRect,
                                         t.mFrameID, t.mProducerID));
 
     // Wait end of usage on host side if TextureFlags::RECYCLE is set or GrallocTextureData case
     HoldUntilCompositableRefReleasedIfNecessary(t.mTextureClient);
   }
   mTxn->AddNoSwapEdit(CompositableOperation(nullptr, aCompositable->GetIPDLActor(),
                                             OpUseTexture(textures)));
@@ -214,34 +212,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;
   }
@@ -259,112 +239,16 @@ ImageBridgeChild::NotifyNotUsed(uint64_t
   if (aFwdTransactionId < client->GetLastFwdTransactionId()) {
     // Released on host side, but client already requested newer use texture.
     return;
   }
   mTexturesWaitingRecycled.Remove(aTextureId);
 }
 
 void
-ImageBridgeChild::DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle)
-{
-  RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
-  if (!client) {
-    return;
-  }
-  client->SetReleaseFenceHandle(aReleaseFenceHandle);
-}
-
-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);
   if (!client) {
     return;
   }
@@ -511,35 +395,31 @@ 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()
 {
   delete mTxn;
 }
 
 void
 ImageBridgeChild::MarkShutDown()
 {
   mTexturesWaitingRecycled.Clear();
-  mTrackersHolder.DestroyAsyncTransactionTrackersHolder();
 
   mCanSend = false;
 }
 
 void
 ImageBridgeChild::Connect(CompositableClient* aCompositable,
                           ImageContainer* aImageContainer)
 {
@@ -714,85 +594,56 @@ ImageBridgeChild::UpdateAsyncCanvasRende
   BeginTransaction();
   aWrapper->GetCanvasClient()->Updated();
   EndTransaction();
 }
 
 void
 ImageBridgeChild::FlushAllImagesSync(SynchronousTask* aTask,
                                      ImageClient* aClient,
-                                     ImageContainer* aContainer,
-                                     RefPtr<AsyncTransactionWaiter> aWaiter)
+                                     ImageContainer* aContainer)
 {
-#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);
+  aClient->FlushAllImages();
   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);
+    aContainer);
   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 +690,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();
@@ -1299,55 +1147,21 @@ ImageBridgeChild::DeallocPImageContainer
 
 bool
 ImageBridgeChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessageData>&& aMessages)
 {
   for (AsyncParentMessageArray::index_type i = 0; i < aMessages.Length(); ++i) {
     const AsyncParentMessageData& message = aMessages[i];
 
     switch (message.type()) {
-      case AsyncParentMessageData::TOpDeliverFence: {
-        const OpDeliverFence& op = message.get_OpDeliverFence();
-        FenceHandle fence = op.fence();
-        DeliverFence(op.TextureId(), fence);
-        break;
-      }
-      case AsyncParentMessageData::TOpDeliverFenceToNonRecycle: {
-        // Notify ReleaseCompositableRef to a TextureClient that belongs to
-        // LayerTransactionChild. It is used only on gonk to deliver fence to
-        // a TextureClient that does not have TextureFlags::RECYCLE.
-        // In this case, LayerTransactionChild's ipc could not be used to deliver fence.
-
-        const OpDeliverFenceToNonRecycle& op = message.get_OpDeliverFenceToNonRecycle();
-        FenceHandle fence = op.fence();
-        DeliverFenceToNonRecycle(op.TextureId(), fence);
-        break;
-      }
       case AsyncParentMessageData::TOpNotifyNotUsed: {
         const OpNotifyNotUsed& op = message.get_OpNotifyNotUsed();
         NotifyNotUsed(op.TextureId(), op.fwdTransactionId());
         break;
       }
-      case AsyncParentMessageData::TOpNotifyNotUsedToNonRecycle: {
-        // Notify ReleaseCompositableRef to a TextureClient that belongs to
-        // LayerTransactionChild. It is used only on gonk to deliver fence to
-        // a TextureClient that does not have TextureFlags::RECYCLE.
-        // In this case, LayerTransactionChild's ipc could not be used to deliver fence.
-
-        const OpNotifyNotUsedToNonRecycle& op = message.get_OpNotifyNotUsedToNonRecycle();
-        NotifyNotUsedToNonRecycle(op.TextureId(), op.fwdTransactionId());
-        break;
-      }
-      case AsyncParentMessageData::TOpReplyRemoveTexture: {
-        const OpReplyRemoveTexture& op = message.get_OpReplyRemoveTexture();
-
-        MOZ_ASSERT(mTrackersHolder.GetId() == op.holderId());
-        mTrackersHolder.TransactionCompleteted(op.transactionId());
-        break;
-      }
       default:
         NS_ERROR("unknown AsyncParentMessageData type");
         return false;
     }
   }
   return true;
 }
 
@@ -1421,42 +1235,16 @@ ImageBridgeChild::RemoveTextureFromCompo
 
   if (aTexture->GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
     mTxn->AddEdit(op);
   } else {
     mTxn->AddNoSwapEdit(op);
   }
 }
 
-void
-ImageBridgeChild::RemoveTextureFromCompositableAsync(AsyncTransactionTracker* aAsyncTransactionTracker,
-                                                     CompositableClient* aCompositable,
-                                                     TextureClient* aTexture)
-{
-  MOZ_ASSERT(CanSend());
-  MOZ_ASSERT(aTexture);
-  MOZ_ASSERT(aTexture->IsSharedWithCompositor());
-  MOZ_ASSERT(aCompositable->IsConnected());
-  if (!aTexture || !aTexture->IsSharedWithCompositor() || !aCompositable->IsConnected()) {
-    return;
-  }
-
-  CompositableOperation op(
-    nullptr, aCompositable->GetIPDLActor(),
-    OpRemoveTextureAsync(
-      mTrackersHolder.GetId(),
-      aAsyncTransactionTracker->GetId(),
-      nullptr, aCompositable->GetIPDLActor(),
-      nullptr, aTexture->GetIPDLActor()));
-
-  mTxn->AddNoSwapEdit(op);
-  // Hold AsyncTransactionTracker until receving reply
-  mTrackersHolder.HoldUntilComplete(aAsyncTransactionTracker);
-}
-
 bool ImageBridgeChild::IsSameProcess() const
 {
   return OtherPid() == base::GetCurrentProcId();
 }
 
 void
 ImageBridgeChild::Destroy(CompositableChild* aCompositable)
 {
--- a/gfx/layers/ipc/ImageBridgeChild.h
+++ b/gfx/layers/ipc/ImageBridgeChild.h
@@ -7,17 +7,16 @@
 #define MOZILLA_GFX_IMAGEBRIDGECHILD_H
 
 #include <stddef.h>                     // for size_t
 #include <stdint.h>                     // for uint32_t, uint64_t
 #include "mozilla/Attributes.h"         // for override
 #include "mozilla/Atomics.h"
 #include "mozilla/RefPtr.h"             // for already_AddRefed
 #include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
-#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTrackerHolder
 #include "mozilla/layers/CanvasClient.h"
 #include "mozilla/layers/CompositableForwarder.h"
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/PImageBridgeChild.h"
 #include "mozilla/Mutex.h"
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT
 #include "nsIObserver.h"
 #include "nsRegion.h"                   // for nsIntRegion
@@ -32,17 +31,16 @@ class Thread;
 namespace mozilla {
 namespace ipc {
 class Shmem;
 } // namespace ipc
 
 namespace layers {
 
 class AsyncCanvasRenderer;
-class AsyncTransactionTracker;
 class ImageClient;
 class ImageContainer;
 class ImageContainerChild;
 class ImageBridgeParent;
 class CompositableClient;
 struct CompositableTransaction;
 class Image;
 class TextureClient;
@@ -252,18 +250,17 @@ private:
   void UpdateAsyncCanvasRendererNow(AsyncCanvasRenderer* aClient);
   void UpdateAsyncCanvasRendererSync(
     SynchronousTask* aTask,
     AsyncCanvasRenderer* aWrapper);
 
   void FlushAllImagesSync(
     SynchronousTask* aTask,
     ImageClient* aClient,
-    ImageContainer* aContainer,
-    RefPtr<AsyncTransactionWaiter> aWaiter);
+    ImageContainer* aContainer);
 
   void ProxyAllocShmemNow(SynchronousTask* aTask, AllocShmemParams* aParams);
   void ProxyDeallocShmemNow(SynchronousTask* aTask, Shmem* aShmem);
 
 public:
   // CompositableForwarder
 
   virtual void Connect(CompositableClient* aCompositable,
@@ -274,58 +271,39 @@ 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);
 
   /**
    * Notify id of Texture When host side end its use. Transaction id is used to
    * make sure if there is no newer usage.
    */
   void NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId);
 
-  void DeliverFence(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle);
-
-  void HoldUntilFenceHandleDelivery(TextureClient* aClient, uint64_t aTransactionId);
-
-  void DeliverFenceToNonRecycle(uint64_t aTextureId, FenceHandle& aReleaseFenceHandle);
-
-  void NotifyNotUsedToNonRecycle(uint64_t aTextureId, uint64_t aTransactionId);
-
-  void CancelWaitFenceHandle(TextureClient* aClient);
-
   virtual void CancelWaitForRecycle(uint64_t aTextureId) override;
 
   virtual bool DestroyInTransaction(PTextureChild* aTexture, bool synchronously) override;
   virtual bool DestroyInTransaction(PCompositableChild* aCompositable, bool synchronously) override;
 
   virtual void RemoveTextureFromCompositable(CompositableClient* aCompositable,
                                              TextureClient* aTexture) override;
 
-  virtual void RemoveTextureFromCompositableAsync(AsyncTransactionTracker* aAsyncTransactionTracker,
-                                                  CompositableClient* aCompositable,
-                                                  TextureClient* aTexture) override;
-
   virtual void UseTiledLayerBuffer(CompositableClient* aCompositable,
                                    const SurfaceDescriptorTiles& aTileLayerDescriptor) override
   {
     NS_RUNTIMEABORT("should not be called");
   }
 
   virtual void UpdateTextureRegion(CompositableClient* aCompositable,
                                    const ThebesBufferData& aThebesBufferData,
@@ -408,21 +386,14 @@ private:
    */
   uint64_t mFwdTransactionId;
 
   /**
    * 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)
@@ -405,84 +402,16 @@ ImageBridgeParent::DeallocShmem(ipc::Shm
   PImageBridgeParent::DeallocShmem(aShmem);
 }
 
 bool ImageBridgeParent::IsSameProcess() const
 {
   return OtherPid() == base::GetCurrentProcId();
 }
 
-void
-ImageBridgeParent::ReplyRemoveTexture(const OpReplyRemoveTexture& aReply)
-{
-  mPendingAsyncMessage.push_back(aReply);
-}
-
-void
-ImageBridgeParent::SendFenceHandleToNonRecycle(PTextureParent* aTexture)
-{
-  RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
-  if (!texture) {
-    return;
-  }
-
-  if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
-     !texture->NeedsFenceHandle()) {
-    return;
-  }
-
-  uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
-
-  // Send a ReleaseFence of CompositorOGL.
-  FenceHandle fence = texture->GetCompositorReleaseFence();
-  if (fence.IsValid()) {
-    mPendingAsyncMessage.push_back(OpDeliverFenceToNonRecycle(textureId, fence));
-  }
-
-  // Send a ReleaseFence that is set to TextureHost by HwcComposer2D.
-  fence = texture->GetAndResetReleaseFenceHandle();
-  if (fence.IsValid()) {
-    mPendingAsyncMessage.push_back(OpDeliverFenceToNonRecycle(textureId, fence));
-  }
-}
-
-void
-ImageBridgeParent::NotifyNotUsedToNonRecycle(PTextureParent* aTexture,
-                                             uint64_t aTransactionId)
-{
-  RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
-  if (!texture) {
-    return;
-  }
-
-  if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
-     !texture->NeedsFenceHandle()) {
-    return;
-  }
-
-  SendFenceHandleToNonRecycle(aTexture);
-
-  uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
-  mPendingAsyncMessage.push_back(
-    OpNotifyNotUsedToNonRecycle(textureId, aTransactionId));
-
-}
-
-/*static*/ void
-ImageBridgeParent::NotifyNotUsedToNonRecycle(base::ProcessId aChildProcessId,
-                                             PTextureParent* aTexture,
-                                             uint64_t aTransactionId)
-{
-  ImageBridgeParent* imageBridge = ImageBridgeParent::GetInstance(aChildProcessId);
-  if (!imageBridge) {
-    return;
-  }
-  imageBridge->NotifyNotUsedToNonRecycle(aTexture, aTransactionId);
-}
-
 /*static*/ void
 ImageBridgeParent::SetAboutToSendAsyncMessages(base::ProcessId aChildProcessId)
 {
   ImageBridgeParent* imageBridge = ImageBridgeParent::GetInstance(aChildProcessId);
   if (!imageBridge) {
     return;
   }
   imageBridge->SetAboutToSendAsyncMessages();
@@ -501,22 +430,20 @@ ImageBridgeParent::SendPendingAsyncMessa
 void
 ImageBridgeParent::NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId)
 {
   RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
   if (!texture) {
     return;
   }
 
-  if (!(texture->GetFlags() & TextureFlags::RECYCLE) &&
-     !texture->NeedsFenceHandle()) {
+  if (!(texture->GetFlags() & TextureFlags::RECYCLE)) {
     return;
   }
 
-  SendFenceHandleIfPresent(aTexture);
   uint64_t textureId = TextureHost::GetTextureSerial(aTexture);
   mPendingAsyncMessage.push_back(
     OpNotifyNotUsed(textureId, aTransactionId));
 
   if (!IsAboutToSendAsyncMessages()) {
     SendPendingAsyncMessages();
   }
 }
--- a/gfx/layers/ipc/ImageBridgeParent.h
+++ b/gfx/layers/ipc/ImageBridgeParent.h
@@ -108,27 +108,16 @@ public:
   virtual bool AllocUnsafeShmem(size_t aSize,
                                 ipc::SharedMemory::SharedMemoryType aType,
                                 ipc::Shmem* aShmem) override;
 
   virtual void DeallocShmem(ipc::Shmem& aShmem) override;
 
   virtual bool IsSameProcess() const override;
 
-  virtual void ReplyRemoveTexture(const OpReplyRemoveTexture& aReply) override;
-
-  void SendFenceHandleToNonRecycle(PTextureParent* aTexture);
-
-  void NotifyNotUsedToNonRecycle(PTextureParent* aTexture,
-                                 uint64_t aTransactionId);
-
-  static void NotifyNotUsedToNonRecycle(base::ProcessId aChildProcessId,
-                                        PTextureParent* aTexture,
-                                        uint64_t aTransactionId);
-
   using CompositableParentManager::SetAboutToSendAsyncMessages;
   static void SetAboutToSendAsyncMessages(base::ProcessId aChildProcessId);
 
   using CompositableParentManager::SendPendingAsyncMessages;
   static void SendPendingAsyncMessages(base::ProcessId aChildProcessId);
 
   static ImageBridgeParent* GetInstance(ProcessId aId);
 
--- a/gfx/layers/ipc/LayerTransactionChild.h
+++ b/gfx/layers/ipc/LayerTransactionChild.h
@@ -6,17 +6,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_LAYERS_LAYERTRANSACTIONCHILD_H
 #define MOZILLA_LAYERS_LAYERTRANSACTIONCHILD_H
 
 #include <stdint.h>                     // for uint32_t
 #include "mozilla/Attributes.h"         // for override
 #include "mozilla/ipc/ProtocolUtils.h"
-#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
 #include "mozilla/layers/PLayerTransactionChild.h"
 #include "mozilla/RefPtr.h"
 
 namespace mozilla {
 
 namespace layout {
 class RenderFrameChild;
 } // namespace layout
--- 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/LayersMessages.ipdlh
+++ b/gfx/layers/ipc/LayersMessages.ipdlh
@@ -38,17 +38,16 @@ using mozilla::LayerIntRegion from "Unit
 using mozilla::ParentLayerIntRect from "Units.h";
 using mozilla::LayoutDeviceIntRect from "Units.h";
 using mozilla::layers::ScaleMode from "mozilla/layers/LayersTypes.h";
 using mozilla::layers::EventRegions from "mozilla/layers/LayersTypes.h";
 using mozilla::layers::EventRegionsOverride from "mozilla/layers/LayersTypes.h";
 using mozilla::layers::DiagnosticTypes from "mozilla/layers/CompositorTypes.h";
 using struct mozilla::layers::ScrollMetadata from "FrameMetrics.h";
 using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h";
-using struct mozilla::layers::FenceHandle from "mozilla/layers/FenceUtils.h";
 using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h";
 using mozilla::layers::MaybeLayerClip from "FrameMetrics.h";
 
 namespace mozilla {
 namespace layers {
 
 struct TargetConfig {
   IntRect naturalBounds;
@@ -370,37 +369,19 @@ struct OpPaintTextureRegion {
 
 /**
  * Tells the CompositableHost to remove the corresponding TextureHost
  */
 struct OpRemoveTexture {
   PTexture texture;
 };
 
-struct OpRemoveTextureAsync {
-  uint64_t holderId;
-  uint64_t transactionId;
-  PCompositable compositable;
-  PTexture texture;
-};
-
-struct OpReplyRemoveTexture {
-  uint64_t holderId;
-  uint64_t transactionId;
-};
-
-union MaybeFence {
-  FenceHandle;
-  null_t;
-};
-
 struct TimedTexture {
   PTexture texture;
   ReadLockDescriptor sharedLock;
-  MaybeFence fence;
   TimeStamp timeStamp;
   IntRect picture;
   uint32_t frameID;
   uint32_t producerID;
 };
 
 /**
  * Tells the compositor-side which textures to use (for example, as front buffer
@@ -423,43 +404,27 @@ struct OpUseComponentAlphaTextures {
   ReadLockDescriptor sharedLockWhite;
 };
 
 union MaybeRegion {
   nsIntRegion;
   null_t;
 };
 
-struct OpDeliverFence {
-  uint64_t TextureId;
-  FenceHandle fence;
-};
-
-struct OpDeliverFenceToNonRecycle {
-  uint64_t TextureId;
-  FenceHandle fence;
-};
-
 struct OpNotifyNotUsed {
   uint64_t TextureId;
   uint64_t fwdTransactionId;
 };
 
-struct OpNotifyNotUsedToNonRecycle {
-  uint64_t TextureId;
-  uint64_t fwdTransactionId;
-};
-
 union CompositableOperationDetail {
   OpPaintTextureRegion;
 
   OpUseTiledLayerBuffer;
 
   OpRemoveTexture;
-  OpRemoveTextureAsync;
 
   OpUseTexture;
   OpUseComponentAlphaTextures;
   OpUseOverlaySource;
 };
 
 struct CompositableOperation {
   PCompositable compositable;
@@ -522,17 +487,13 @@ struct ImageCompositeNotification {
 
 // Unit of a "changeset reply".  This is a weird abstraction, probably
 // only to be used for buffer swapping.
 union EditReply {
   OpContentBufferSwap;
 };
 
 union AsyncParentMessageData {
-  OpDeliverFence;
-  OpDeliverFenceToNonRecycle;
   OpNotifyNotUsed;
-  OpNotifyNotUsedToNonRecycle;
-  OpReplyRemoveTexture;
 };
 
 } // namespace
 } // namespace
--- 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)
@@ -401,22 +382,20 @@ ShadowLayerForwarder::UseTextures(Compos
   MOZ_ASSERT(aCompositable && aCompositable->IsConnected());
 
   AutoTArray<TimedTexture,4> textures;
 
   for (auto& t : aTextures) {
     MOZ_ASSERT(t.mTextureClient);
     MOZ_ASSERT(t.mTextureClient->GetIPDLActor());
     MOZ_RELEASE_ASSERT(t.mTextureClient->GetIPDLActor()->GetIPCChannel() == mShadowManager->GetIPCChannel());
-    FenceHandle fence = t.mTextureClient->GetAcquireFenceHandle();
     ReadLockDescriptor readLock;
     t.mTextureClient->SerializeReadLock(readLock);
     textures.AppendElement(TimedTexture(nullptr, t.mTextureClient->GetIPDLActor(),
                                         readLock,
-                                        fence.IsValid() ? MaybeFence(fence) : MaybeFence(null_t()),
                                         t.mTimeStamp, t.mPictureRect,
                                         t.mFrameID, t.mProducerID));
     if ((t.mTextureClient->GetFlags() & TextureFlags::IMMEDIATE_UPLOAD)
         && t.mTextureClient->HasIntermediateBuffer()) {
 
       // We use IMMEDIATE_UPLOAD when we want to be sure that the upload cannot
       // race with updates on the main thread. In this case we want the transaction
       // to be synchronous.
@@ -458,30 +437,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);
@@ -522,24 +487,16 @@ ShadowLayerForwarder::RemoveTextureFromC
     CompositableOperation(
       nullptr, aCompositable->GetIPDLActor(),
       OpRemoveTexture(nullptr, aTexture->GetIPDLActor())));
   if (aTexture->GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
     mTxn->MarkSyncTransaction();
   }
 }
 
-void
-ShadowLayerForwarder::RemoveTextureFromCompositableAsync(AsyncTransactionTracker* aAsyncTransactionTracker,
-                                                         CompositableClient* aCompositable,
-                                                         TextureClient* aTexture)
-{
-  NS_RUNTIMEABORT("not reached");
-}
-
 bool
 ShadowLayerForwarder::InWorkerThread()
 {
   return MessageLoop::current() && (GetTextureForwarder()->GetMessageLoop()->id() == MessageLoop::current()->id());
 }
 
 void
 ShadowLayerForwarder::StorePluginWidgetConfigurations(const nsTArray<nsIWidget::Configuration>&
--- a/gfx/layers/ipc/ShadowLayers.h
+++ b/gfx/layers/ipc/ShadowLayers.h
@@ -249,41 +249,32 @@ public:
                                    const SurfaceDescriptorTiles& aTileLayerDescriptor) override;
 
   bool DestroyInTransaction(PTextureChild* aTexture, bool synchronously) override;
   bool DestroyInTransaction(PCompositableChild* aCompositable, bool synchronously) override;
 
   virtual void RemoveTextureFromCompositable(CompositableClient* aCompositable,
                                              TextureClient* aTexture) override;
 
-  virtual void RemoveTextureFromCompositableAsync(AsyncTransactionTracker* aAsyncTransactionTracker,
-                                                  CompositableClient* aCompositable,
-                                                  TextureClient* aTexture) override;
-
   /**
    * Communicate to the compositor that aRegion in the texture identified by aLayer
    * and aIdentifier has been updated to aThebesBuffer.
    */
   virtual void UpdateTextureRegion(CompositableClient* aCompositable,
                                    const ThebesBufferData& aThebesBufferData,
                                    const nsIntRegion& aUpdatedRegion) override;
 
   /**
    * 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',
@@ -159,51 +158,45 @@ EXPORTS.mozilla.layers += [
     'CompositorTypes.h',
     'D3D11ShareHandleImage.h',
     'D3D9SurfaceImage.h',
     'Effects.h',
     'ImageDataSerializer.h',
     'ipc/APZChild.h',
     'ipc/APZCTreeManagerChild.h',
     'ipc/APZCTreeManagerParent.h',
-    'ipc/AsyncTransactionTracker.h',
     'ipc/CompositableForwarder.h',
     'ipc/CompositableTransactionParent.h',
     'ipc/CompositorBridgeChild.h',
     'ipc/CompositorBridgeParent.h',
     'ipc/CompositorThread.h',
-    'ipc/FenceUtils.h',
     'ipc/GonkNativeHandle.h',
     'ipc/GonkNativeHandleUtils.h',
     'ipc/ImageBridgeChild.h',
     'ipc/ImageBridgeParent.h',
     'ipc/ImageContainerChild.h',
     'ipc/ImageContainerParent.h',
     'ipc/ISurfaceAllocator.h',
     '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 +231,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',
@@ -360,39 +325,35 @@ UNIFIED_SOURCES += [
     'Effects.cpp',
     'FrameMetrics.cpp',
     'GLImages.cpp',
     'ImageDataSerializer.cpp',
     'ImageLayers.cpp',
     'ipc/APZChild.cpp',
     'ipc/APZCTreeManagerChild.cpp',
     'ipc/APZCTreeManagerParent.cpp',
-    'ipc/AsyncTransactionTracker.cpp',
     'ipc/CompositableForwarder.cpp',
     'ipc/CompositableTransactionParent.cpp',
     'ipc/CompositorBench.cpp',
     'ipc/CompositorBridgeChild.cpp',
     'ipc/CompositorBridgeParent.cpp',
     'ipc/CompositorThread.cpp',
-    'ipc/FenceUtils.cpp',
     'ipc/ImageBridgeChild.cpp',
     'ipc/ImageBridgeParent.cpp',
     'ipc/ImageContainerChild.cpp',
     'ipc/ImageContainerParent.cpp',
     'ipc/ISurfaceAllocator.cpp',
     '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 +403,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 +424,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);