Bug 778519 - Don't include Layers.h everywhere Part 2 r=cjones
authorDavid Zbarsky <dzbarsky@gmail.com>
Mon, 30 Jul 2012 17:42:26 -0700
changeset 100920 43e3fec490154e7473af28b13c5434ecc9c85c94
parent 100919 9378d1f70e5ce3c98579c52e4119f9a18ee6f6ae
child 100921 e64fcdf0c985131515f307d91523281b1f79429a
push id23202
push useremorley@mozilla.com
push dateTue, 31 Jul 2012 12:59:27 +0000
treeherdermozilla-central@1ab429a89429 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs778519
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 778519 - Don't include Layers.h everywhere Part 2 r=cjones
content/base/src/nsFrameLoader.h
content/html/content/public/nsHTMLCanvasElement.h
content/media/webrtc/MediaEngineDefault.cpp
content/media/webrtc/MediaEngineDefault.h
content/media/webrtc/MediaEngineWebRTC.h
gfx/layers/FrameMetrics.h
gfx/layers/ImageLayers.h
gfx/layers/Layers.h
gfx/layers/LayersBackend.h
gfx/layers/LayersTypes.h
gfx/layers/Makefile.in
gfx/layers/basic/BasicCanvasLayer.cpp
gfx/layers/basic/BasicLayers.h
gfx/layers/d3d9/Nv3DVUtils.cpp
gfx/layers/d3d9/Nv3DVUtils.h
gfx/layers/ipc/CompositorParent.h
gfx/layers/ipc/GeckoContentController.h
gfx/layers/ipc/ImageContainerChild.h
gfx/layers/ipc/ShadowLayerUtils.h
gfx/layers/ipc/ShadowLayers.cpp
gfx/layers/ipc/ShadowLayers.h
gfx/layers/opengl/ImageLayerOGL.cpp
gfx/layers/opengl/LayerManagerOGL.h
ipc/glue/IPCMessageUtils.h
layout/base/nsLayoutUtils.h
layout/generic/nsHTMLCanvasFrame.h
layout/generic/nsObjectFrame.h
layout/generic/nsVideoFrame.h
layout/ipc/RenderFrameChild.cpp
layout/ipc/RenderFrameParent.cpp
layout/ipc/RenderFrameParent.h
layout/svg/base/src/nsSVGIntegrationUtils.h
widget/android/AndroidBridge.h
widget/android/nsWindow.cpp
widget/android/nsWindow.h
widget/cocoa/nsChildView.mm
widget/gonk/nsWindow.cpp
widget/gtk2/nsWindow.cpp
widget/nsIWidget.h
widget/qt/nsWindow.cpp
widget/qt/nsWindow.h
widget/windows/nsWindowGfx.cpp
widget/xpwidgets/PuppetWidget.cpp
widget/xpwidgets/PuppetWidget.h
widget/xpwidgets/nsBaseWidget.cpp
widget/xpwidgets/nsBaseWidget.h
--- a/content/base/src/nsFrameLoader.h
+++ b/content/base/src/nsFrameLoader.h
@@ -16,17 +16,17 @@
 #include "nsIFrameLoader.h"
 #include "nsPoint.h"
 #include "nsSize.h"
 #include "nsIURI.h"
 #include "nsAutoPtr.h"
 #include "nsFrameMessageManager.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/Attributes.h"
-#include "Layers.h"
+#include "FrameMetrics.h"
 
 class nsIURI;
 class nsSubDocumentFrame;
 class nsIView;
 class nsIInProcessContentFrameMessageManager;
 class AutoResetInShow;
 class nsITabParent;
 
--- a/content/html/content/public/nsHTMLCanvasElement.h
+++ b/content/html/content/public/nsHTMLCanvasElement.h
@@ -12,22 +12,27 @@
 #include "nsSize.h"
 #include "nsIFrame.h"
 #include "nsDOMError.h"
 #include "nsNodeInfoManager.h"
 
 #include "nsICanvasElementExternal.h"
 #include "nsLayoutUtils.h"
 
-#include "Layers.h"
-
 class nsICanvasRenderingContextInternal;
 class nsIDOMFile;
 class nsIPropertyBag;
 
+namespace mozilla {
+namespace layers {
+class CanvasLayer;
+class LayerManager;
+}
+}
+
 class nsHTMLCanvasElement : public nsGenericHTMLElement,
                             public nsICanvasElementExternal,
                             public nsIDOMHTMLCanvasElement
 {
   typedef mozilla::layers::CanvasLayer CanvasLayer;
   typedef mozilla::layers::LayerManager LayerManager;
 
 public:
--- a/content/media/webrtc/MediaEngineDefault.cpp
+++ b/content/media/webrtc/MediaEngineDefault.cpp
@@ -20,16 +20,24 @@
 #define RATE USECS_PER_S
 
 namespace mozilla {
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(MediaEngineDefaultVideoSource, nsITimerCallback)
 /**
  * Default video source.
  */
+
+MediaEngineDefaultVideoSource::MediaEngineDefaultVideoSource()
+  : mTimer(nsnull), mState(kReleased)
+{}
+
+MediaEngineDefaultVideoSource::~MediaEngineDefaultVideoSource()
+{}
+
 void
 MediaEngineDefaultVideoSource::GetName(nsAString& aName)
 {
   aName.Assign(NS_LITERAL_STRING("Default Video Device"));
   return;
 }
 
 void
--- a/content/media/webrtc/MediaEngineDefault.h
+++ b/content/media/webrtc/MediaEngineDefault.h
@@ -7,44 +7,47 @@
 
 #include "prmem.h"
 #include "nsITimer.h"
 
 #include "nsCOMPtr.h"
 #include "nsDOMMediaStream.h"
 #include "nsComponentManagerUtils.h"
 
-#include "Layers.h"
 #include "VideoUtils.h"
 #include "MediaEngine.h"
-#include "ImageLayers.h"
 #include "VideoSegment.h"
 #include "AudioSegment.h"
 #include "StreamBuffer.h"
 #include "MediaStreamGraph.h"
 
 namespace mozilla {
 
+namespace layers {
+class ImageContainer;
+class PlanarYCbCrImage;
+}
+
 /**
  * The default implementation of the MediaEngine interface.
  */
 
 enum DefaultEngineState {
   kAllocated,
   kStarted,
   kStopped,
   kReleased
 };
 
 class MediaEngineDefaultVideoSource : public nsITimerCallback,
                                       public MediaEngineVideoSource
 {
 public:
-  MediaEngineDefaultVideoSource() : mTimer(nullptr), mState(kReleased) {}
-  ~MediaEngineDefaultVideoSource(){};
+  MediaEngineDefaultVideoSource();
+  ~MediaEngineDefaultVideoSource();
 
   virtual void GetName(nsAString&);
   virtual void GetUUID(nsAString&);
 
   virtual MediaEngineVideoOptions GetOptions();
   virtual nsresult Allocate();
 
   virtual nsresult Deallocate();
--- a/content/media/webrtc/MediaEngineWebRTC.h
+++ b/content/media/webrtc/MediaEngineWebRTC.h
@@ -13,20 +13,18 @@
 
 #include "nsCOMPtr.h"
 #include "nsDOMFile.h"
 #include "nsThreadUtils.h"
 #include "nsDOMMediaStream.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsComponentManagerUtils.h"
 
-#include "Layers.h"
 #include "VideoUtils.h"
 #include "MediaEngine.h"
-#include "ImageLayers.h"
 #include "VideoSegment.h"
 #include "AudioSegment.h"
 #include "StreamBuffer.h"
 #include "MediaStreamGraph.h"
 
 // WebRTC library includes follow
 
 // Audio Engine
new file mode 100644
--- /dev/null
+++ b/gfx/layers/FrameMetrics.h
@@ -0,0 +1,89 @@
+/* -*- 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/. */
+
+#ifndef GFX_FRAMEMETRICS_H
+#define GFX_FRAMEMETRICS_H
+
+#include "gfxPoint.h"
+#include "gfxTypes.h"
+#include "nsRect.h"
+#include "mozilla/gfx/Rect.h"
+
+namespace mozilla {
+namespace layers {
+
+/**
+ * The viewport and displayport metrics for the painted frame at the
+ * time of a layer-tree transaction.  These metrics are especially
+ * useful for shadow layers, because the metrics values are updated
+ * atomically with new pixels.
+ */
+struct THEBES_API FrameMetrics {
+public:
+  // We use IDs to identify frames across processes.
+  typedef PRUint64 ViewID;
+  static const ViewID NULL_SCROLL_ID;   // This container layer does not scroll.
+  static const ViewID ROOT_SCROLL_ID;   // This is the root scroll frame.
+  static const ViewID START_SCROLL_ID;  // This is the ID that scrolling subframes
+                                        // will begin at.
+
+  FrameMetrics()
+    : mViewport(0, 0, 0, 0)
+    , mContentRect(0, 0, 0, 0)
+    , mViewportScrollOffset(0, 0)
+    , mScrollId(NULL_SCROLL_ID)
+    , mCSSContentRect(0, 0, 0, 0)
+    , mResolution(1, 1)
+  {}
+
+  // Default copy ctor and operator= are fine
+
+  bool operator==(const FrameMetrics& aOther) const
+  {
+    return (mViewport.IsEqualEdges(aOther.mViewport) &&
+            mViewportScrollOffset == aOther.mViewportScrollOffset &&
+            mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
+            mScrollId == aOther.mScrollId);
+  }
+  bool operator!=(const FrameMetrics& aOther) const
+  {
+    return !operator==(aOther);
+  }
+
+  bool IsDefault() const
+  {
+    return (FrameMetrics() == *this);
+  }
+
+  bool IsRootScrollable() const
+  {
+    return mScrollId == ROOT_SCROLL_ID;
+  }
+
+  bool IsScrollable() const
+  {
+    return mScrollId != NULL_SCROLL_ID;
+  }
+
+  // These are all in layer coordinate space.
+  nsIntRect mViewport;
+  nsIntRect mContentRect;
+  nsIntPoint mViewportScrollOffset;
+  nsIntRect mDisplayPort;
+  ViewID mScrollId;
+
+  // Consumers often want to know the origin/size before scaling to pixels
+  // so we record this as well.
+  gfx::Rect mCSSContentRect;
+
+  // This represents the resolution at which the associated layer
+  // will been rendered.
+  gfxSize mResolution;
+};
+
+}
+}
+
+#endif /* GFX_FRAMEMETRICS_H */
--- a/gfx/layers/ImageLayers.h
+++ b/gfx/layers/ImageLayers.h
@@ -11,17 +11,16 @@
 #include "nsISupportsImpl.h"
 #include "gfxPattern.h"
 #include "nsThreadUtils.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/mozalloc.h"
 #include "mozilla/Mutex.h"
 #include "gfxPlatform.h"
-#include "LayersBackend.h"
 
 #ifdef XP_MACOSX
 #include "nsIOSurface.h"
 #endif
 #ifdef XP_WIN
 struct ID3D10Texture2D;
 struct ID3D10Device;
 struct ID3D10ShaderResourceView;
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -13,17 +13,18 @@
 #include "nsRect.h"
 #include "nsISupportsImpl.h"
 #include "nsAutoPtr.h"
 #include "gfx3DMatrix.h"
 #include "gfxColor.h"
 #include "gfxPattern.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
-#include "LayersBackend.h"
+#include "LayersTypes.h"
+#include "FrameMetrics.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/TimeStamp.h"
 
 #if defined(DEBUG) || defined(PR_LOGGING)
 #  include <stdio.h>            // FILE
 #  include "prlog.h"
 #  ifndef MOZ_LAYERS_HAVE_LOG
 #    define MOZ_LAYERS_HAVE_LOG
@@ -56,85 +57,16 @@ class ReadbackLayer;
 class ReadbackProcessor;
 class RefLayer;
 class ShadowLayer;
 class ShadowableLayer;
 class ShadowLayerForwarder;
 class ShadowLayerManager;
 class SpecificLayerAttributes;
 
-/**
- * The viewport and displayport metrics for the painted frame at the
- * time of a layer-tree transaction.  These metrics are especially
- * useful for shadow layers, because the metrics values are updated
- * atomically with new pixels.
- */
-struct THEBES_API FrameMetrics {
-public:
-  // We use IDs to identify frames across processes.
-  typedef PRUint64 ViewID;
-  static const ViewID NULL_SCROLL_ID;   // This container layer does not scroll.
-  static const ViewID ROOT_SCROLL_ID;   // This is the root scroll frame.
-  static const ViewID START_SCROLL_ID;  // This is the ID that scrolling subframes
-                                        // will begin at.
-
-  FrameMetrics()
-    : mViewport(0, 0, 0, 0)
-    , mContentRect(0, 0, 0, 0)
-    , mViewportScrollOffset(0, 0)
-    , mScrollId(NULL_SCROLL_ID)
-    , mCSSContentRect(0, 0, 0, 0)
-    , mResolution(1, 1)
-  {}
-
-  // Default copy ctor and operator= are fine
-
-  bool operator==(const FrameMetrics& aOther) const
-  {
-    return (mViewport.IsEqualEdges(aOther.mViewport) &&
-            mViewportScrollOffset == aOther.mViewportScrollOffset &&
-            mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
-            mScrollId == aOther.mScrollId);
-  }
-  bool operator!=(const FrameMetrics& aOther) const
-  { 
-    return !operator==(aOther);
-  }
-
-  bool IsDefault() const
-  {
-    return (FrameMetrics() == *this);
-  }
-
-  bool IsRootScrollable() const
-  {
-    return mScrollId == ROOT_SCROLL_ID;
-  }
-
-  bool IsScrollable() const
-  {
-    return mScrollId != NULL_SCROLL_ID;
-  }
-
-  // These are all in layer coordinate space.
-  nsIntRect mViewport;
-  nsIntRect mContentRect;
-  nsIntPoint mViewportScrollOffset;
-  nsIntRect mDisplayPort;
-  ViewID mScrollId;
-
-  // Consumers often want to know the origin/size before scaling to pixels
-  // so we record this as well.
-  gfx::Rect mCSSContentRect;
-
-  // This represents the resolution at which the associated layer
-  // will been rendered.
-  gfxSize mResolution;
-};
-
 #define MOZ_LAYER_DECL_NAME(n, e)                           \
   virtual const char* Name() const { return n; }            \
   virtual LayerType GetType() const { return e; }
 
 /**
  * Base class for userdata objects attached to layers and layer managers.
  */
 class THEBES_API LayerUserData {
deleted file mode 100644
--- a/gfx/layers/LayersBackend.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* -*- 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/. */
-
-#ifndef GFX_LAYERSBACKEND_H
-#define GFX_LAYERSBACKEND_H
-
-namespace mozilla {
-namespace layers {
-enum LayersBackend {
-  LAYERS_NONE = 0,
-  LAYERS_BASIC,
-  LAYERS_OPENGL,
-  LAYERS_D3D9,
-  LAYERS_D3D10,
-  LAYERS_LAST
-};
-}
-}
-
-#endif /* GFX_LAYERSBACKEND_H */
new file mode 100644
--- /dev/null
+++ b/gfx/layers/LayersTypes.h
@@ -0,0 +1,28 @@
+/* -*- 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/. */
+
+#ifndef GFX_LAYERSTYPES_H
+#define GFX_LAYERSTYPES_H
+
+namespace mozilla {
+namespace layers {
+enum LayersBackend {
+  LAYERS_NONE = 0,
+  LAYERS_BASIC,
+  LAYERS_OPENGL,
+  LAYERS_D3D9,
+  LAYERS_D3D10,
+  LAYERS_LAST
+};
+
+enum BufferMode {
+  BUFFER_NONE,
+  BUFFER_BUFFERED
+};
+
+}
+}
+
+#endif /* GFX_LAYERSTYPES_H */
--- a/gfx/layers/Makefile.in
+++ b/gfx/layers/Makefile.in
@@ -26,19 +26,20 @@ DEFINES += -DIMPL_THEBES
 ifdef MOZ_DEBUG
 DEFINES += -DD3D_DEBUG_INFO
 endif
 
 EXPORTS = \
         BasicLayers.h \
         BasicTiledThebesLayer.h \
         BasicImplData.h \
+        FrameMetrics.h \
         ImageLayers.h \
         Layers.h \
-        LayersBackend.h \
+        LayersTypes.h \
         LayerManagerOGLShaders.h \
         LayerManagerOGL.h \
         LayerManagerOGLProgram.h \
         ReadbackLayer.h \
         LayerSorter.h \
         TexturePoolOGL.h \
         SharedTextureImage.h \
         $(NULL)
--- a/gfx/layers/basic/BasicCanvasLayer.cpp
+++ b/gfx/layers/basic/BasicCanvasLayer.cpp
@@ -5,17 +5,16 @@
 
 #include "mozilla/layers/PLayersParent.h"
 #include "gfxImageSurface.h"
 #include "GLContext.h"
 #include "gfxUtils.h"
 
 #include "BasicLayersImpl.h"
 #include "nsXULAppAPI.h"
-#include "LayersBackend.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 class BasicCanvasLayer : public CanvasLayer,
                          public BasicImplData
--- a/gfx/layers/basic/BasicLayers.h
+++ b/gfx/layers/basic/BasicLayers.h
@@ -71,20 +71,16 @@ public:
    * 
    * aDoubleBuffering can request double-buffering for drawing to the
    * default target. When BUFFERED, the layer manager avoids blitting
    * temporary results to aContext and then overpainting them with final
    * results, by using a temporary buffer when necessary. In BUFFERED
    * mode we always completely overwrite the contents of aContext's
    * destination surface (within the clip region) using OPERATOR_SOURCE.
    */
-  enum BufferMode {
-    BUFFER_NONE,
-    BUFFER_BUFFERED
-  };
   virtual void SetDefaultTarget(gfxContext* aContext, BufferMode aDoubleBuffering,
                                 ScreenRotation aRotation);
   gfxContext* GetDefaultTarget() { return mDefaultTarget; }
 
   nsIWidget* GetRetainerWidget() { return mWidget; }
   void ClearRetainerWidget() { mWidget = nullptr; }
 
   virtual bool IsWidgetLayerManager() { return mWidget != nullptr; }
--- a/gfx/layers/d3d9/Nv3DVUtils.cpp
+++ b/gfx/layers/d3d9/Nv3DVUtils.cpp
@@ -100,34 +100,34 @@ Nv3DVUtils::SetDeviceInfo(IUnknown *devU
       return;
   }
 
   rv = m3DVStreaming->Nv3DVControl(NV_STEREO_MODE_RIGHT_LEFT, true, FIREFOX_3DV_APP_HANDLE);
   NS_WARN_IF_FALSE(rv, "Nv3DVStreaming Nv3DVControl failed!");
 }
 
 /*
- * Send Stereo Control Information. Used mainly to re-route 
+ * Send Stereo Control Information. Used mainly to re-route
  * calls from ImageLayerD3D9 to the 3DV COM object
  */
 void 
 Nv3DVUtils::SendNv3DVControl(Nv_Stereo_Mode eStereoMode, bool bEnableStereo, DWORD dw3DVAppHandle)
 {
   if (!m3DVStreaming)
       return;
 
   DebugOnly<bool> rv = m3DVStreaming->Nv3DVControl(eStereoMode, bEnableStereo, dw3DVAppHandle);
   NS_WARN_IF_FALSE(rv, "Nv3DVStreaming Nv3DVControl failed!");
 }
 
 /*
- * Send Stereo Metadata. Used mainly to re-route calls 
+ * Send Stereo Metadata. Used mainly to re-route calls
  * from ImageLayerD3D9 to the 3DV COM object
  */
-void 
+void
 Nv3DVUtils::SendNv3DVMetaData(unsigned int dwWidth, unsigned int dwHeight, HANDLE hSrcLuma, HANDLE hDst)
 {
   if (!m3DVStreaming)
       return;
 
   DebugOnly<bool> rv = m3DVStreaming->Nv3DVMetaData((DWORD)dwWidth, (DWORD)dwHeight, hSrcLuma, hDst);
   NS_WARN_IF_FALSE(rv, "Nv3DVStreaming Nv3DVMetaData failed!");
 }
--- a/gfx/layers/d3d9/Nv3DVUtils.h
+++ b/gfx/layers/d3d9/Nv3DVUtils.h
@@ -16,17 +16,17 @@ namespace layers {
 #define FIREFOX_3DV_APP_HANDLE    0xECB992B6
 
 enum Nv_Stereo_Mode {
   NV_STEREO_MODE_LEFT_RIGHT = 0,
   NV_STEREO_MODE_RIGHT_LEFT = 1,
   NV_STEREO_MODE_TOP_BOTTOM = 2,
   NV_STEREO_MODE_BOTTOM_TOP = 3,
   NV_STEREO_MODE_MONO       = 4,
-  NV_STEREO_MODE_LAST       = 5 
+  NV_STEREO_MODE_LAST       = 5
 };
 
 class INv3DVStreaming : public IUnknown {
 
 public:
   virtual bool Nv3DVInitialize()                  = 0;
   virtual bool Nv3DVRelease()                     = 0;
   virtual bool Nv3DVSetDevice(IUnknown* pDevice)  = 0;
--- a/gfx/layers/ipc/CompositorParent.h
+++ b/gfx/layers/ipc/CompositorParent.h
@@ -14,28 +14,29 @@
 //    2) Unless a frame was composited within the throttle threshold in
 //       which the deadline will be 15ms + throttle threshold
 //#define COMPOSITOR_PERFORMANCE_WARNING
 
 #include "mozilla/layers/PCompositorParent.h"
 #include "mozilla/layers/PLayersParent.h"
 #include "base/thread.h"
 #include "mozilla/Monitor.h"
+#include "mozilla/TimeStamp.h"
 #include "ShadowLayersManager.h"
-
 class nsIWidget;
 
 namespace base {
 class Thread;
 }
 
 namespace mozilla {
 namespace layers {
 
 class AsyncPanZoomController;
+class Layer;
 class LayerManager;
 
 // Represents (affine) transforms that are calculated from a content view.
 struct ViewTransform {
   ViewTransform(nsIntPoint aTranslation = nsIntPoint(0, 0), float aXScale = 1, float aYScale = 1)
     : mTranslation(aTranslation)
     , mXScale(aXScale)
     , mYScale(aYScale)
--- a/gfx/layers/ipc/GeckoContentController.h
+++ b/gfx/layers/ipc/GeckoContentController.h
@@ -2,17 +2,18 @@
 /* vim: set sw=4 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 mozilla_layers_GeckoContentController_h
 #define mozilla_layers_GeckoContentController_h
 
-#include "Layers.h"
+#include "FrameMetrics.h"
+#include "nsISupportsImpl.h"
 
 namespace mozilla {
 namespace layers {
 
 class GeckoContentController {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GeckoContentController)
 
--- a/gfx/layers/ipc/ImageContainerChild.h
+++ b/gfx/layers/ipc/ImageContainerChild.h
@@ -8,26 +8,27 @@
 
 #include "mozilla/layers/PImageContainerChild.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 
 namespace mozilla {
 namespace layers {
 
 class ImageBridgeCopyAndSendTask;
+class ImageContainer;
 
 /**
  * ImageContainerChild is the content-side part of the ImageBridge IPDL protocol
- * acting at the ImageContainer level. 
+ * acting at the ImageContainer level.
  *
  * There is one ImageContainerChild/Parent
  * pair for each ImageContainer that uses the protocol.
  * ImageContainers that use the ImageBridge protocol forward frames through
  * ImageContainerChild to the compositor without using the main thread whereas
- * ImageContainers that don't use it will forward frames in the main thread 
+ * ImageContainers that don't use it will forward frames in the main thread
  * within a transaction.
  *
  * See ImageBridgeChild.h for more details about the ImageBridge protocol
  */
 class ImageContainerChild : public PImageContainerChild
 {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageContainerChild)
 
--- a/gfx/layers/ipc/ShadowLayerUtils.h
+++ b/gfx/layers/ipc/ShadowLayerUtils.h
@@ -4,17 +4,17 @@
 /* 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_ShadowLayerUtils_h
 #define IPC_ShadowLayerUtils_h
 
 #include "IPC/IPCMessageUtils.h"
-#include "Layers.h"
+#include "FrameMetrics.h"
 #include "GLContext.h"
 #include "mozilla/WidgetUtils.h"
 
 #if defined(MOZ_ENABLE_D3D10_LAYER)
 # include "mozilla/layers/ShadowLayerUtilsD3D10.h"
 #endif
 
 #if defined(MOZ_X11)
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -17,17 +17,16 @@
 #include "mozilla/layers/PLayersChild.h"
 #include "mozilla/layers/PLayersParent.h"
 #include "ShadowLayers.h"
 #include "ShadowLayerChild.h"
 #include "gfxipc/ShadowLayerUtils.h"
 #include "RenderTrace.h"
 #include "sampler.h"
 #include "nsXULAppAPI.h"
-#include "LayersBackend.h"
 
 using namespace mozilla::ipc;
 
 namespace mozilla {
 namespace layers {
 
 typedef nsTArray<SurfaceDescriptor> BufferArray; 
 typedef std::vector<Edit> EditVector;
--- a/gfx/layers/ipc/ShadowLayers.h
+++ b/gfx/layers/ipc/ShadowLayers.h
@@ -7,17 +7,16 @@
 
 #ifndef mozilla_layers_ShadowLayers_h
 #define mozilla_layers_ShadowLayers_h 1
 
 #include "gfxASurface.h"
 #include "GLDefs.h"
 
 #include "ImageLayers.h"
-#include "LayersBackend.h"
 #include "mozilla/ipc/SharedMemory.h"
 #include "mozilla/WidgetUtils.h"
 
 class gfxSharedImageSurface;
 
 namespace mozilla {
 
 namespace gl {
--- a/gfx/layers/opengl/ImageLayerOGL.cpp
+++ b/gfx/layers/opengl/ImageLayerOGL.cpp
@@ -7,17 +7,16 @@
 #include "mozilla/layers/ImageContainerParent.h"
 
 #include "ipc/AutoOpenSurface.h"
 #include "ImageLayerOGL.h"
 #include "gfxImageSurface.h"
 #include "gfxUtils.h"
 #include "yuv_convert.h"
 #include "GLContextProvider.h"
-#include "LayersBackend.h"
 #if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
 # include "GLXLibrary.h"
 # include "mozilla/X11Util.h"
 #endif
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "nsSurfaceTexture.h"
 #endif
--- a/gfx/layers/opengl/LayerManagerOGL.h
+++ b/gfx/layers/opengl/LayerManagerOGL.h
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_LAYERMANAGEROGL_H
 #define GFX_LAYERMANAGEROGL_H
 
-#include "Layers.h"
 #include "LayerManagerOGLProgram.h"
 
 #include "mozilla/layers/ShadowLayers.h"
 
 #include "mozilla/TimeStamp.h"
 
 #ifdef XP_WIN
 #include <windows.h>
--- a/ipc/glue/IPCMessageUtils.h
+++ b/ipc/glue/IPCMessageUtils.h
@@ -20,17 +20,17 @@
 #include "gfx3DMatrix.h"
 #include "gfxColor.h"
 #include "gfxMatrix.h"
 #include "gfxPattern.h"
 #include "gfxPoint.h"
 #include "nsRect.h"
 #include "nsRegion.h"
 #include "gfxASurface.h"
-#include "LayersBackend.h"
+#include "LayersTypes.h"
 
 #ifdef _MSC_VER
 #pragma warning( disable : 4800 )
 #endif
 
 #if !defined(OS_POSIX)
 // This condition must be kept in sync with the one in
 // ipc_message_utils.h, but this dummy definition of
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -33,17 +33,17 @@ class nsHTMLImageElement;
 #include "nsThreadUtils.h"
 #include "nsIPresShell.h"
 #include "nsIPrincipal.h"
 #include "gfxPattern.h"
 #include "imgIContainer.h"
 #include "nsCSSPseudoElements.h"
 #include "nsHTMLReflowState.h"
 #include "nsIFrameLoader.h"
-#include "Layers.h"
+#include "FrameMetrics.h"
 
 class nsBlockFrame;
 class gfxDrawable;
 
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
--- a/layout/generic/nsHTMLCanvasFrame.h
+++ b/layout/generic/nsHTMLCanvasFrame.h
@@ -7,18 +7,23 @@
 
 #ifndef nsHTMLCanvasFrame_h___
 #define nsHTMLCanvasFrame_h___
 
 #include "nsContainerFrame.h"
 #include "nsString.h"
 #include "nsAString.h"
 #include "nsIIOService.h"
-#include "Layers.h"
-#include "ImageLayers.h"
+
+namespace mozilla {
+namespace layers {
+class Layer;
+class LayerManager;
+}
+}
 
 class nsPresContext;
 class nsDisplayItem;
 
 nsIFrame* NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
 
 class nsHTMLCanvasFrame : public nsContainerFrame
 {
@@ -53,17 +58,17 @@ public:
                              nsSize aCBSize, nscoord aAvailableWidth,
                              nsSize aMargin, nsSize aBorder, nsSize aPadding,
                              PRUint32 aFlags) MOZ_OVERRIDE;
 
   NS_IMETHOD Reflow(nsPresContext*          aPresContext,
                     nsHTMLReflowMetrics&     aDesiredSize,
                     const nsHTMLReflowState& aReflowState,
                     nsReflowStatus&          aStatus);
-  
+
   nsRect GetInnerArea() const;
 
 #ifdef ACCESSIBILITY
   virtual already_AddRefed<Accessible> CreateAccessible();
 #endif
 
   virtual nsIAtom* GetType() const;
 
--- a/layout/generic/nsObjectFrame.h
+++ b/layout/generic/nsObjectFrame.h
@@ -9,29 +9,35 @@
 #define nsObjectFrame_h___
 
 #include "nsPluginInstanceOwner.h"
 #include "nsIObjectFrame.h"
 #include "nsFrame.h"
 #include "nsRegion.h"
 #include "nsDisplayList.h"
 #include "nsIReflowCallback.h"
-#include "Layers.h"
-#include "ImageLayers.h"
 
 #ifdef ACCESSIBILITY
 class nsIAccessible;
 #endif
 
 class nsPluginHost;
 class nsPresContext;
 class nsDisplayPlugin;
 class nsIOSurface;
 class PluginBackgroundSink;
 
+namespace mozilla {
+namespace layers {
+class ImageContainer;
+class Layer;
+class LayerManager;
+}
+}
+
 #define nsObjectFrameSuper nsFrame
 
 class nsObjectFrame : public nsObjectFrameSuper,
                       public nsIObjectFrame,
                       public nsIReflowCallback {
 public:
   typedef mozilla::LayerState LayerState;
   typedef mozilla::layers::Layer Layer;
--- a/layout/generic/nsVideoFrame.h
+++ b/layout/generic/nsVideoFrame.h
@@ -11,18 +11,23 @@
 
 #include "nsContainerFrame.h"
 #include "nsString.h"
 #include "nsAString.h"
 #include "nsIIOService.h"
 #include "nsITimer.h"
 #include "nsTArray.h"
 #include "nsIAnonymousContentCreator.h"
-#include "Layers.h"
-#include "ImageLayers.h"
+
+namespace mozilla {
+namespace layers {
+class Layer;
+class LayerManager;
+}
+}
 
 class nsPresContext;
 class nsDisplayItem;
 
 nsIFrame* NS_NewVideoFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
 
 class nsVideoFrame : public nsContainerFrame, public nsIAnonymousContentCreator
 {
@@ -103,17 +108,17 @@ protected:
   // Sets the mPosterImage's src attribute to be the video's poster attribute,
   // if we're the frame for a video element. Only call on frames for video
   // elements, not for frames for audio elements.
   nsresult UpdatePosterSource(bool aNotify);
 
   virtual ~nsVideoFrame();
 
   nsMargin mBorderPadding;
-  
+
   // Anonymous child which is bound via XBL to the video controls.
   nsCOMPtr<nsIContent> mVideoControls;
-  
+
   // Anonymous child which is the image element of the poster frame.
   nsCOMPtr<nsIContent> mPosterImage;
 };
 
 #endif /* nsVideoFrame_h___ */
--- a/layout/ipc/RenderFrameChild.cpp
+++ b/layout/ipc/RenderFrameChild.cpp
@@ -2,17 +2,16 @@
  * 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 "RenderFrameChild.h"
 #include "mozilla/layers/ShadowLayersChild.h"
-#include "LayersBackend.h"
 
 using mozilla::layers::PLayersChild;
 using mozilla::layers::ShadowLayersChild;
 
 namespace mozilla {
 namespace layout {
 
 void
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -18,17 +18,16 @@
 #include "mozilla/layers/CompositorParent.h"
 #include "mozilla/layers/ShadowLayersParent.h"
 #include "nsContentUtils.h"
 #include "nsFrameLoader.h"
 #include "nsIObserver.h"
 #include "nsSubDocumentFrame.h"
 #include "nsViewportFrame.h"
 #include "RenderFrameParent.h"
-#include "LayersBackend.h"
 
 typedef nsContentView::ViewConfig ViewConfig;
 using namespace mozilla::dom;
 using namespace mozilla::layers;
 
 namespace mozilla {
 namespace layout {
 
--- a/layout/ipc/RenderFrameParent.h
+++ b/layout/ipc/RenderFrameParent.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_layout_RenderFrameParent_h
 #define mozilla_layout_RenderFrameParent_h
 
 #include <map>
 
-#include "LayersBackend.h"
 #include "mozilla/layout/PRenderFrameParent.h"
 #include "mozilla/layers/ShadowLayersManager.h"
 #include "nsDisplayList.h"
 #include "RenderFrameUtils.h"
 
 class nsContentView;
 class nsFrameLoader;
 class nsSubDocumentFrame;
--- a/layout/svg/base/src/nsSVGIntegrationUtils.h
+++ b/layout/svg/base/src/nsSVGIntegrationUtils.h
@@ -5,23 +5,28 @@
 
 #ifndef NSSVGINTEGRATIONUTILS_H_
 #define NSSVGINTEGRATIONUTILS_H_
 
 #include "gfxMatrix.h"
 #include "gfxPattern.h"
 #include "gfxRect.h"
 #include "nsRect.h"
-#include "Layers.h"
 
 class nsDisplayList;
 class nsDisplayListBuilder;
 class nsIFrame;
 class nsRenderingContext;
 
+namespace mozilla {
+namespace layers {
+class LayerManager;
+}
+}
+
 struct nsPoint;
 struct nsSize;
 
 /**
  * Integration of SVG effects (clipPath clipping, masking and filters) into
  * regular display list based painting and hit-testing.
  */
 class nsSVGIntegrationUtils MOZ_FINAL
--- a/widget/android/AndroidBridge.h
+++ b/widget/android/AndroidBridge.h
@@ -18,17 +18,16 @@
 #include "nsThreadUtils.h"
 
 #include "AndroidLayerViewWrapper.h"
 #include "AndroidJavaWrappers.h"
 
 #include "nsIMutableArray.h"
 #include "nsIMIMEInfo.h"
 #include "nsColor.h"
-#include "BasicLayers.h"
 #include "gfxRect.h"
 
 #include "nsIAndroidBridge.h"
 
 // Some debug #defines
 // #define DEBUG_ANDROID_EVENTS
 // #define DEBUG_ANDROID_WIDGET
 
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -522,18 +522,19 @@ nsWindow::FindTopLevel()
 
     ALOG("nsWindow::FindTopLevel(): couldn't find a toplevel or dialog window in this [%p] widget's hierarchy!", (void*)this);
     return this;
 }
 
 NS_IMETHODIMP
 nsWindow::SetFocus(bool aRaise)
 {
-    if (!aRaise)
+    if (!aRaise) {
         ALOG("nsWindow::SetFocus: can't set focus without raising, ignoring aRaise = false!");
+    }
 
     if (!AndroidBridge::Bridge())
         return NS_OK;
 
     nsWindow *top = FindTopLevel();
     top->mFocus = this;
     top->BringToFront();
 
@@ -989,17 +990,17 @@ nsWindow::DrawTo(gfxASurface *targetSurf
         switch (GetLayerManager(nullptr)->GetBackendType()) {
             case mozilla::layers::LAYERS_BASIC: {
 
                 nsRefPtr<gfxContext> ctx = new gfxContext(targetSurface);
 
                 {
                     mozilla::layers::RenderTraceScope trace2("Basic DrawTo", "727272");
                     AutoLayerManagerSetup
-                      setupLayerManager(this, ctx, BasicLayerManager::BUFFER_NONE);
+                      setupLayerManager(this, ctx, mozilla::layers::BUFFER_NONE);
 
                     status = DispatchEvent(&event);
                 }
 
                 // XXX uhh.. we can't just ignore this because we no longer have
                 // what we needed before, but let's keep drawing the children anyway?
 #if 0
                 if (status == nsEventStatus_eIgnore)
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -8,30 +8,30 @@
 
 #include "nsBaseWidget.h"
 #include "gfxPoint.h"
 #include "nsIIdleServiceInternal.h"
 #include "nsTArray.h"
 
 #ifdef MOZ_JAVA_COMPOSITOR
 #include "AndroidJavaWrappers.h"
-#include "Layers.h"
 #endif
 
 class gfxASurface;
 
 struct ANPEvent;
 
 namespace mozilla {
     class AndroidGeckoEvent;
     class AndroidKeyEvent;
 
     namespace layers {
         class CompositorParent;
         class CompositorChild;
+        class LayerManager;
     }
 }
 
 class nsWindow :
     public nsBaseWidget
 {
 public:
     using nsBaseWidget::GetLayerManager;
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2579,17 +2579,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
     targetContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height));
   }
   targetContext->Clip();
 
   nsAutoRetainCocoaObject kungFuDeathGrip(self);
   bool painted;
   {
     nsBaseWidget::AutoLayerManagerSetup
-      setupLayerManager(mGeckoChild, targetContext, BasicLayerManager::BUFFER_NONE);
+      setupLayerManager(mGeckoChild, targetContext, BUFFER_NONE);
     painted = mGeckoChild->DispatchWindowEvent(paintEvent);
   }
 
   // Force OpenGL to refresh the very first time we draw. This works around a
   // Mac OS X bug that stops windows updating on OS X when we use OpenGL.
   if (painted && !mDidForceRefreshOpenGL &&
       layerManager->AsShadowManager() && mUsingOMTCompositor) {
     if (!mDidForceRefreshOpenGL) {
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -30,16 +30,17 @@
 #include "LayerManagerOGL.h"
 #include "nsAutoPtr.h"
 #include "nsAppShell.h"
 #include "nsIdleService.h"
 #include "nsScreenManagerGonk.h"
 #include "nsTArray.h"
 #include "nsWindow.h"
 #include "cutils/properties.h"
+#include "BasicLayers.h"
 
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
 #define LOGW(args...) __android_log_print(ANDROID_LOG_WARN, "Gonk", ## args)
 #define LOGE(args...) __android_log_print(ANDROID_LOG_ERROR, "Gonk", ## args)
 
 #define IS_TOPLEVEL() (mWindowType == eWindowType_toplevel || mWindowType == eWindowType_dialog)
 
 using namespace mozilla;
@@ -138,17 +139,17 @@ static void *frameBufferWatcher(void *) 
             ScopedClose fd(open(kWakeFile, O_RDONLY, 0));
             do {
                 len = read(fd.get(), &buf, 1);
             } while (len < 0 && errno == EINTR);
             NS_WARN_IF_FALSE(len >= 0, "WAIT_FOR_FB_WAKE failed");
             NS_DispatchToMainThread(mScreenOnEvent);
         }
     }
-    
+
     return NULL;
 }
 
 } // anonymous namespace
 
 nsWindow::nsWindow()
 {
     if (!sScreenInitialized) {
@@ -157,17 +158,17 @@ nsWindow::nsWindow()
 
         // Watching screen on/off state by using a pthread
         // which implicitly calls exit() when the main thread ends
         if (pthread_create(&sFramebufferWatchThread, NULL, frameBufferWatcher, NULL)) {
             NS_RUNTIMEABORT("Failed to create framebufferWatcherThread, aborting...");
         }
 
         nsIntSize screenSize;
-        bool gotFB = Framebuffer::GetSize(&screenSize);
+        mozilla::DebugOnly<bool> gotFB = Framebuffer::GetSize(&screenSize);
         MOZ_ASSERT(gotFB);
         gScreenBounds = nsIntRect(nsIntPoint(0, 0), screenSize);
 
         char propValue[PROPERTY_VALUE_MAX];
         property_get("ro.sf.hwrotation", propValue, "0");
         sPhysicalScreenRotation = atoi(propValue) / 90;
 
         // Unlike nsScreenGonk::SetRotation(), only support 0 and 180 as there
@@ -244,17 +245,17 @@ nsWindow::DoDraw(void)
 
         {
             nsRefPtr<gfxContext> ctx = new gfxContext(targetSurface);
             gfxUtils::PathFromRegion(ctx, event.region);
             ctx->Clip();
 
             // No double-buffering needed.
             AutoLayerManagerSetup setupLayerManager(
-                gWindowToRedraw, ctx, BasicLayerManager::BUFFER_NONE,
+                gWindowToRedraw, ctx, mozilla::layers::BUFFER_NONE,
                 ScreenRotation(EffectiveScreenRotation()));
             gWindowToRedraw->mEventCallback(&event);
         }
 
         if (!sUsingOMTC) {
             targetSurface->Flush();
             Framebuffer::Present(event.region);
         }
@@ -684,17 +685,17 @@ nsScreenGonk::GetRotation(PRUint32* aRot
 {
     *aRotation = sScreenRotation;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsScreenGonk::SetRotation(PRUint32 aRotation)
 {
-    if (!(ROTATION_0_DEG <= aRotation && aRotation <= ROTATION_270_DEG))
+    if (!(aRotation <= ROTATION_270_DEG))
         return NS_ERROR_ILLEGAL_VALUE;
 
     if (sScreenRotation == aRotation)
         return NS_OK;
 
     sScreenRotation = aRotation;
     sRotationMatrix =
         ComputeGLTransformForRotation(gScreenBounds,
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -63,17 +63,17 @@
 
 #include "mozilla/Preferences.h"
 #include "nsIPrefService.h"
 #include "nsIGConfService.h"
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
 #include "nsGfxCIID.h"
 #include "nsIObserverService.h"
-
+#include "LayersTypes.h"
 #include "nsIIdleServiceInternal.h"
 #include "nsIPropertyBag2.h"
 
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #include "nsIAccessibleDocument.h"
 
 using namespace mozilla;
@@ -88,16 +88,17 @@ using namespace mozilla::widget;
 /* SetCursor(imgIContainer*) */
 #include <gdk/gdk.h>
 #include <wchar.h>
 #include "imgIContainer.h"
 #include "nsGfxCIID.h"
 #include "nsImageToPixbuf.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsAutoPtr.h"
+#include "BasicLayers.h"
 
 extern "C" {
 #define PIXMAN_DONT_DEFINE_STDINT
 #include "pixman.h"
 }
 #include "gfxPlatformGtk.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
@@ -2123,39 +2124,39 @@ nsWindow::OnExposeEvent(cairo_t *cr)
     if (GetLayerManager()->AsShadowForwarder() && GetLayerManager()->AsShadowForwarder()->HasShadowManager()) {
         nsEventStatus status;
 #if defined(MOZ_WIDGET_GTK2)
         nsRefPtr<gfxContext> ctx = new gfxContext(GetThebesSurface());
 #else
         nsRefPtr<gfxContext> ctx = new gfxContext(GetThebesSurface(cr));
 #endif
         nsBaseWidget::AutoLayerManagerSetup
-          setupLayerManager(this, ctx, BasicLayerManager::BUFFER_NONE);
+          setupLayerManager(this, ctx, mozilla::layers::BUFFER_NONE);
         DispatchEvent(&event, status);
 
         g_free(rects);
 
         DispatchDidPaint(this);
 
         return TRUE;
-    
+
     } else if (GetLayerManager()->GetBackendType() == mozilla::layers::LAYERS_OPENGL) {
         LayerManagerOGL *manager = static_cast<LayerManagerOGL*>(GetLayerManager());
         manager->SetClippingRegion(event.region);
 
         nsEventStatus status;
         DispatchEvent(&event, status);
 
         g_free(rects);
 
         DispatchDidPaint(this);
 
         return TRUE;
     }
-            
+
 #if defined(MOZ_WIDGET_GTK2)
     nsRefPtr<gfxContext> ctx = new gfxContext(GetThebesSurface());
 #else
     nsRefPtr<gfxContext> ctx = new gfxContext(GetThebesSurface(cr));
 #endif
 
 #ifdef MOZ_X11
     nsIntRect boundsRect; // for translucent only
@@ -2169,31 +2170,31 @@ nsWindow::OnExposeEvent(cairo_t *cr)
         boundsRect = event.region.GetBounds();
         ctx->Rectangle(gfxRect(boundsRect.x, boundsRect.y,
                                boundsRect.width, boundsRect.height));
     } else {
         gfxUtils::PathFromRegion(ctx, event.region);
     }
     ctx->Clip();
 
-    BasicLayerManager::BufferMode layerBuffering;
+    BufferMode layerBuffering;
     if (translucent) {
         // The double buffering is done here to extract the shape mask.
         // (The shape mask won't be necessary when a visual with an alpha
         // channel is used on compositing window managers.)
-        layerBuffering = BasicLayerManager::BUFFER_NONE;
+        layerBuffering = mozilla::layers::BUFFER_NONE;
         ctx->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
 #ifdef MOZ_HAVE_SHMIMAGE
     } else if (nsShmImage::UseShm()) {
         // We're using an xshm mapping as a back buffer.
-        layerBuffering = BasicLayerManager::BUFFER_NONE;
+        layerBuffering = mozilla::layers::BUFFER_NONE;
 #endif // MOZ_HAVE_SHMIMAGE
     } else {
         // Get the layer manager to do double buffering (if necessary).
-        layerBuffering = BasicLayerManager::BUFFER_BUFFERED;
+        layerBuffering = mozilla::layers::BUFFER_BUFFERED;
     }
 
 #if 0
     // NOTE: Paint flashing region would be wrong for cairo, since
     // cairo inflates the update region, etc.  So don't paint flash
     // for cairo.
 #ifdef DEBUG
     // XXX aEvent->region may refer to a newly-invalid area.  FIXME
@@ -6197,17 +6198,17 @@ nsWindow::BeginResizeDrag(nsGUIEvent* aE
     return NS_OK;
 }
 
 void
 nsWindow::ClearCachedResources()
 {
     if (mLayerManager &&
         mLayerManager->GetBackendType() == mozilla::layers::LAYERS_BASIC) {
-        static_cast<BasicLayerManager*> (mLayerManager.get())->
+        static_cast<mozilla::layers::BasicLayerManager*> (mLayerManager.get())->
             ClearCachedResources();
     }
 
     GList* children = gdk_window_peek_children(mGdkWindow);
     for (GList* list = children; list; list = list->next) {
         nsWindow* window = get_window_for_gdk_window(GDK_WINDOW(list->data));
         if (window) {
             window->ClearCachedResources();
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -17,17 +17,17 @@
 #include "prthread.h"
 #include "nsEvent.h"
 #include "nsCOMPtr.h"
 #include "nsITheme.h"
 #include "nsNativeWidget.h"
 #include "nsWidgetInitData.h"
 #include "nsTArray.h"
 #include "nsXULAppAPI.h"
-#include "LayersBackend.h"
+#include "LayersTypes.h"
 
 // forward declarations
 class   nsFontMetrics;
 class   nsRenderingContext;
 class   nsDeviceContext;
 struct  nsFont;
 class   nsIRollupListener;
 class   nsGUIEvent;
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim:expandtab:shiftwidth=4:tabstop=4:
  */
 /* 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/Util.h"
+#include "BasicLayers.h"
 
 #include <QtOpenGL/QGLWidget>
 #include <QtOpenGL/QGLContext>
 #include <QApplication>
 #include <QDesktopWidget>
 #include <QtGui/QCursor>
 #include <QIcon>
 #include <QGraphicsScene>
@@ -302,17 +303,16 @@ UpdateOffScreenBuffers(int aDepth, QSize
     // Use fallback RGB24 format, Qt will do conversion for us
     if (format == gfxASurface::ImageFormatUnknown)
         format = gfxASurface::ImageFormatRGB24;
 
 #ifdef MOZ_HAVE_SHMIMAGE
     if (aWidget) {
         if (gfxPlatform::GetPlatform()->ScreenReferenceSurface()->GetType() ==
             gfxASurface::SurfaceTypeImage) {
-            Display* dpy = mozilla::DefaultXDisplay();
             gShmImage = nsShmImage::Create(gBufferMaxSize,
                                            DefaultVisualOfScreen(gfxQtPlatform::GetXScreen(aWidget)),
                                            aDepth);
             gBufferSurface = gShmImage->AsSurface();
             return true;
         }
     }
 #endif
@@ -1113,17 +1113,17 @@ nsWindow::DoPaint(QPainter* aPainter, co
 
     nsPaintEvent event(true, NS_PAINT, this);
     event.willSendDidPaint = true;
     event.refPoint.x = rect.x;
     event.refPoint.y = rect.y;
     event.region = nsIntRegion(rect);
     {
         AutoLayerManagerSetup
-            setupLayerManager(this, ctx, BasicLayerManager::BUFFER_NONE);
+            setupLayerManager(this, ctx, mozilla::layers::BUFFER_NONE);
         status = DispatchEvent(&event);
     }
 
     // DispatchEvent can Destroy us (bug 378273), avoid doing any paint
     // operations below if that happened - it will lead to XError and exit().
     if (NS_UNLIKELY(mIsDestroyed))
         return status;
 
--- a/widget/qt/nsWindow.h
+++ b/widget/qt/nsWindow.h
@@ -17,16 +17,18 @@
 
 #include "nsBaseWidget.h"
 #include "nsGUIEvent.h"
 
 #include "nsWeakReference.h"
 
 #include "nsGkAtoms.h"
 #include "nsIIdleServiceInternal.h"
+#include "nsIRunnable.h"
+#include "nsThreadUtils.h"
 
 #ifdef MOZ_LOGGING
 
 // make sure that logging is enabled before including prlog.h
 #define FORCE_PR_LOG
 
 #include "prlog.h"
 #include "nsTArray.h"
@@ -323,17 +325,17 @@ private:
                        mActivatePending : 1;
     PRInt32            mSizeState;
     PluginType         mPluginType;
 
     nsRefPtr<gfxASurface> mThebesSurface;
     nsCOMPtr<nsIIdleServiceInternal> mIdleService;
 
     bool         mIsTransparent;
- 
+
     // all of our DND stuff
     // this is the last window that had a drag event happen on it.
     void   InitDragEvent         (nsMouseEvent &aEvent);
 
     // this is everything we need to be able to fire motion events
     // repeatedly
     PRUint32 mKeyDownFlags[8];
 
--- a/widget/windows/nsWindowGfx.cpp
+++ b/widget/windows/nsWindowGfx.cpp
@@ -391,37 +391,36 @@ bool nsWindow::OnPaint(HDC aDC, PRUint32
             }
             thebesContext->Clip();
             thebesContext->SetOperator(gfxContext::OPERATOR_CLEAR);
             thebesContext->Paint();
             thebesContext->SetOperator(gfxContext::OPERATOR_OVER);
           }
 
           // don't need to double buffer with anything but GDI
-          BasicLayerManager::BufferMode doubleBuffering =
-            BasicLayerManager::BUFFER_NONE;
+          BufferMode doubleBuffering = mozilla::layers::BUFFER_NONE;
           if (IsRenderMode(gfxWindowsPlatform::RENDER_GDI)) {
 #ifdef MOZ_XUL
             switch (mTransparencyMode) {
               case eTransparencyGlass:
               case eTransparencyBorderlessGlass:
               default:
                 // If we're not doing translucency, then double buffer
-                doubleBuffering = BasicLayerManager::BUFFER_BUFFERED;
+                doubleBuffering = mozilla::layers::BUFFER_BUFFERED;
                 break;
               case eTransparencyTransparent:
                 // If we're rendering with translucency, we're going to be
                 // rendering the whole window; make sure we clear it first
                 thebesContext->SetOperator(gfxContext::OPERATOR_CLEAR);
                 thebesContext->Paint();
                 thebesContext->SetOperator(gfxContext::OPERATOR_OVER);
                 break;
             }
 #else
-            doubleBuffering = BasicLayerManager::BUFFER_BUFFERED;
+            doubleBuffering = mozilla::layers::BUFFER_BUFFERED;
 #endif
           }
 
           {
             AutoLayerManagerSetup
                 setupLayerManager(this, thebesContext, doubleBuffering);
             result = DispatchWindowEvent(&event, eventStatus);
           }
--- a/widget/xpwidgets/PuppetWidget.cpp
+++ b/widget/xpwidgets/PuppetWidget.cpp
@@ -500,17 +500,17 @@ PuppetWidget::DispatchPaintEvent()
 
     if (mozilla::layers::LAYERS_D3D10 == mLayerManager->GetBackendType()) {
       DispatchEvent(&event, status);
     } else {
       nsRefPtr<gfxContext> ctx = new gfxContext(mSurface);
       ctx->Rectangle(gfxRect(0,0,0,0));
       ctx->Clip();
       AutoLayerManagerSetup setupLayerManager(this, ctx,
-                                              BasicLayerManager::BUFFER_NONE);
+                                              BUFFER_NONE);
       DispatchEvent(&event, status);
       mTabChild->NotifyPainted();
     }
   }
 
   nsPaintEvent didPaintEvent(true, NS_DID_PAINT, this);
   DispatchEvent(&didPaintEvent, status);
 
--- a/widget/xpwidgets/PuppetWidget.h
+++ b/widget/xpwidgets/PuppetWidget.h
@@ -16,17 +16,16 @@
 #define mozilla_widget_PuppetWidget_h__
 
 #include "nsBaseScreen.h"
 #include "nsBaseWidget.h"
 #include "nsIScreenManager.h"
 #include "nsThreadUtils.h"
 #include "nsWeakReference.h"
 #include "mozilla/Attributes.h"
-#include "LayersBackend.h"
 
 class gfxASurface;
 
 namespace mozilla {
 
 namespace dom {
 class TabChild;
 }
--- a/widget/xpwidgets/nsBaseWidget.cpp
+++ b/widget/xpwidgets/nsBaseWidget.cpp
@@ -726,17 +726,17 @@ NS_IMETHODIMP nsBaseWidget::MakeFullScre
            mOriginalBounds->height, true);
   }
 
   return NS_OK;
 }
 
 nsBaseWidget::AutoLayerManagerSetup::AutoLayerManagerSetup(
     nsBaseWidget* aWidget, gfxContext* aTarget,
-    BasicLayerManager::BufferMode aDoubleBuffering, ScreenRotation aRotation)
+    BufferMode aDoubleBuffering, ScreenRotation aRotation)
   : mWidget(aWidget)
 {
   BasicLayerManager* manager =
     static_cast<BasicLayerManager*>(mWidget->GetLayerManager());
   if (manager) {
     NS_ASSERTION(manager->GetBackendType() == LAYERS_BASIC,
       "AutoLayerManagerSetup instantiated for non-basic layer backend!");
     manager->SetDefaultTarget(aTarget, aDoubleBuffering, aRotation);
@@ -745,17 +745,17 @@ nsBaseWidget::AutoLayerManagerSetup::Aut
 
 nsBaseWidget::AutoLayerManagerSetup::~AutoLayerManagerSetup()
 {
   BasicLayerManager* manager =
     static_cast<BasicLayerManager*>(mWidget->GetLayerManager());
   if (manager) {
     NS_ASSERTION(manager->GetBackendType() == LAYERS_BASIC,
       "AutoLayerManagerSetup instantiated for non-basic layer backend!");
-    manager->SetDefaultTarget(nullptr, BasicLayerManager::BUFFER_NONE,
+    manager->SetDefaultTarget(nullptr, mozilla::layers::BUFFER_NONE,
                               ROTATION_0);
   }
 }
 
 nsBaseWidget::AutoUseBasicLayerManager::AutoUseBasicLayerManager(nsBaseWidget* aWidget)
   : mWidget(aWidget)
 {
   mWidget->mTemporarilyUseBasicLayerManager = true;
--- a/widget/xpwidgets/nsBaseWidget.h
+++ b/widget/xpwidgets/nsBaseWidget.h
@@ -9,26 +9,24 @@
 #include "nsRect.h"
 #include "nsIWidget.h"
 #include "nsWidgetsCID.h"
 #include "nsIFile.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsGUIEvent.h"
 #include "nsAutoPtr.h"
-#include "BasicLayers.h"
 #include "nsIRollupListener.h"
-#include "LayersBackend.h"
-
 class nsIContent;
 class nsAutoRollup;
 class gfxContext;
 
 namespace mozilla {
 namespace layers {
+class BasicLayerManager;
 class CompositorChild;
 class CompositorParent;
 }
 }
 
 namespace base {
 class Thread;
 }
@@ -44,26 +42,27 @@ class Thread;
 
 class nsBaseWidget : public nsIWidget
 {
   friend class nsAutoRollup;
 
 protected:
   typedef base::Thread Thread;
   typedef mozilla::layers::BasicLayerManager BasicLayerManager;
+  typedef mozilla::layers::BufferMode BufferMode;
   typedef mozilla::layers::CompositorChild CompositorChild;
   typedef mozilla::layers::CompositorParent CompositorParent;
   typedef mozilla::ScreenRotation ScreenRotation;
 
 public:
   nsBaseWidget();
   virtual ~nsBaseWidget();
-  
+
   NS_DECL_ISUPPORTS
-  
+
   // nsIWidget interface
   NS_IMETHOD              CaptureMouse(bool aCapture);
   NS_IMETHOD              GetClientData(void*& aClientData);
   NS_IMETHOD              SetClientData(void* aClientData);
   NS_IMETHOD              Destroy();
   NS_IMETHOD              SetParent(nsIWidget* aNewParent);
   virtual nsIWidget*      GetParent(void);
   virtual nsIWidget*      GetTopLevelWidget();
@@ -188,17 +187,17 @@ public:
    * |aNaturalWidgetBounds| is the un-rotated bounds of |aWidget|.
    * |aRotation| is the "virtual rotation" to apply when rendering to
    * the target.  When |aRotation| is ROTATION_0,
    * |aNaturalWidgetBounds| is not used.
    */
   class AutoLayerManagerSetup {
   public:
     AutoLayerManagerSetup(nsBaseWidget* aWidget, gfxContext* aTarget,
-                          BasicLayerManager::BufferMode aDoubleBuffering,
+                          BufferMode aDoubleBuffering,
                           ScreenRotation aRotation = mozilla::ROTATION_0);
     ~AutoLayerManagerSetup();
   private:
     nsBaseWidget* mWidget;
   };
   friend class AutoLayerManagerSetup;
 
   class AutoUseBasicLayerManager {