Back out d393cfeb5dbf:9f82224bb8a3 (bug 903816) for Android reftest failures
authorPhil Ringnalda <philringnalda@gmail.com>
Sun, 11 Aug 2013 19:21:17 -0700
changeset 155116 cb38092d519d65b7c6c0b34acb3f9dfab04e71df
parent 155115 02fe3ecdf7fb322ada174a83fa155f083857a3a0
child 155117 4fcb0471e0c98ab2d4d057237b94603bac9c7415
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs903816
milestone26.0a1
backs outd393cfeb5dbf33497d1ac63919514d226bf9ba02
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
Back out d393cfeb5dbf:9f82224bb8a3 (bug 903816) for Android reftest failures CLOSED TREE
dom/base/nsDOMWindowUtils.cpp
dom/ipc/TabChild.cpp
gfx/2d/BasePoint3D.h
gfx/2d/Point.h
gfx/gl/GLTextureImage.cpp
gfx/gl/GLTextureImage.h
gfx/layers/Compositor.cpp
gfx/layers/Compositor.h
gfx/layers/CompositorTypes.h
gfx/layers/CopyableCanvasLayer.cpp
gfx/layers/CopyableCanvasLayer.h
gfx/layers/Effects.cpp
gfx/layers/Effects.h
gfx/layers/FrameMetrics.h
gfx/layers/GrallocImages.cpp
gfx/layers/ImageContainer.cpp
gfx/layers/ImageContainer.h
gfx/layers/ImageDataSerializer.cpp
gfx/layers/ImageDataSerializer.h
gfx/layers/ImageLayers.cpp
gfx/layers/ImageLayers.h
gfx/layers/LayerSorter.cpp
gfx/layers/LayerTreeInvalidation.cpp
gfx/layers/LayerTreeInvalidation.h
gfx/layers/Layers.cpp
gfx/layers/Layers.h
gfx/layers/LayersLogging.cpp
gfx/layers/LayersLogging.h
gfx/layers/LayersTypes.h
gfx/layers/ReadbackLayer.h
gfx/layers/ReadbackProcessor.cpp
gfx/layers/ReadbackProcessor.h
gfx/layers/RenderTrace.cpp
gfx/layers/SharedTextureImage.h
gfx/layers/ThebesLayerBuffer.cpp
gfx/layers/ThebesLayerBuffer.h
gfx/layers/TiledLayerBuffer.h
gfx/layers/YCbCrImageDataSerializer.cpp
gfx/layers/YCbCrImageDataSerializer.h
gfx/layers/basic/BasicCanvasLayer.cpp
gfx/layers/basic/BasicCanvasLayer.h
gfx/layers/basic/BasicColorLayer.cpp
gfx/layers/basic/BasicCompositor.h
gfx/layers/basic/BasicContainerLayer.cpp
gfx/layers/basic/BasicContainerLayer.h
gfx/layers/basic/BasicImageLayer.cpp
gfx/layers/basic/BasicImages.cpp
gfx/layers/basic/BasicImplData.h
gfx/layers/basic/BasicLayerManager.cpp
gfx/layers/basic/BasicLayers.h
gfx/layers/basic/BasicLayersImpl.cpp
gfx/layers/basic/BasicLayersImpl.h
gfx/layers/basic/BasicThebesLayer.cpp
gfx/layers/basic/BasicThebesLayer.h
gfx/layers/client/CanvasClient.cpp
gfx/layers/client/CanvasClient.h
gfx/layers/client/ClientCanvasLayer.cpp
gfx/layers/client/ClientCanvasLayer.h
gfx/layers/client/ClientColorLayer.cpp
gfx/layers/client/ClientContainerLayer.cpp
gfx/layers/client/ClientContainerLayer.h
gfx/layers/client/ClientImageLayer.cpp
gfx/layers/client/ClientLayerManager.cpp
gfx/layers/client/ClientLayerManager.h
gfx/layers/client/ClientThebesLayer.cpp
gfx/layers/client/ClientThebesLayer.h
gfx/layers/client/ClientTiledThebesLayer.cpp
gfx/layers/client/ClientTiledThebesLayer.h
gfx/layers/client/CompositableClient.cpp
gfx/layers/client/CompositableClient.h
gfx/layers/client/ContentClient.cpp
gfx/layers/client/ContentClient.h
gfx/layers/client/ImageClient.cpp
gfx/layers/client/ImageClient.h
gfx/layers/client/TextureClient.cpp
gfx/layers/client/TextureClient.h
gfx/layers/client/TiledContentClient.cpp
gfx/layers/client/TiledContentClient.h
gfx/layers/composite/APZCTreeManager.cpp
gfx/layers/composite/APZCTreeManager.h
gfx/layers/composite/AsyncCompositionManager.cpp
gfx/layers/composite/AsyncCompositionManager.h
gfx/layers/composite/CanvasLayerComposite.cpp
gfx/layers/composite/CanvasLayerComposite.h
gfx/layers/composite/ColorLayerComposite.cpp
gfx/layers/composite/ColorLayerComposite.h
gfx/layers/composite/CompositableHost.cpp
gfx/layers/composite/CompositableHost.h
gfx/layers/composite/ContainerLayerComposite.cpp
gfx/layers/composite/ContainerLayerComposite.h
gfx/layers/composite/ContentHost.cpp
gfx/layers/composite/ContentHost.h
gfx/layers/composite/ImageHost.cpp
gfx/layers/composite/ImageHost.h
gfx/layers/composite/ImageLayerComposite.cpp
gfx/layers/composite/ImageLayerComposite.h
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/composite/LayerManagerComposite.h
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/composite/ThebesLayerComposite.cpp
gfx/layers/composite/ThebesLayerComposite.h
gfx/layers/composite/TiledContentHost.cpp
gfx/layers/composite/TiledContentHost.h
gfx/layers/d3d10/ReadbackManagerD3D10.cpp
gfx/layers/ipc/AsyncPanZoomController.cpp
gfx/layers/ipc/Axis.cpp
gfx/layers/ipc/Axis.h
gfx/layers/ipc/CompositableForwarder.h
gfx/layers/ipc/CompositableTransactionParent.cpp
gfx/layers/ipc/CompositableTransactionParent.h
gfx/layers/ipc/CompositorChild.cpp
gfx/layers/ipc/CompositorChild.h
gfx/layers/ipc/CompositorParent.cpp
gfx/layers/ipc/CompositorParent.h
gfx/layers/ipc/GeckoContentController.h
gfx/layers/ipc/GestureEventListener.cpp
gfx/layers/ipc/GestureEventListener.h
gfx/layers/ipc/ISurfaceAllocator.cpp
gfx/layers/ipc/ISurfaceAllocator.h
gfx/layers/ipc/ImageBridgeChild.cpp
gfx/layers/ipc/ImageBridgeChild.h
gfx/layers/ipc/ImageBridgeParent.cpp
gfx/layers/ipc/ImageBridgeParent.h
gfx/layers/ipc/LayerTransactionChild.cpp
gfx/layers/ipc/LayerTransactionChild.h
gfx/layers/ipc/LayerTransactionParent.cpp
gfx/layers/ipc/LayerTransactionParent.h
gfx/layers/ipc/ShadowLayerChild.cpp
gfx/layers/ipc/ShadowLayerChild.h
gfx/layers/ipc/ShadowLayerParent.cpp
gfx/layers/ipc/ShadowLayerParent.h
gfx/layers/ipc/ShadowLayerUtilsX11.cpp
gfx/layers/ipc/ShadowLayerUtilsX11.h
gfx/layers/ipc/ShadowLayers.cpp
gfx/layers/ipc/ShadowLayers.h
gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
gfx/layers/ipc/SharedPlanarYCbCrImage.h
gfx/layers/ipc/SharedRGBImage.cpp
gfx/layers/ipc/SharedRGBImage.h
gfx/layers/ipc/TaskThrottler.cpp
gfx/layers/ipc/TaskThrottler.h
gfx/layers/opengl/CanvasLayerOGL.cpp
gfx/layers/opengl/CanvasLayerOGL.h
gfx/layers/opengl/ColorLayerOGL.cpp
gfx/layers/opengl/ColorLayerOGL.h
gfx/layers/opengl/CompositingRenderTargetOGL.h
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/CompositorOGL.h
gfx/layers/opengl/ContainerLayerOGL.cpp
gfx/layers/opengl/ContainerLayerOGL.h
gfx/layers/opengl/FPSCounter.h
gfx/layers/opengl/GLManager.cpp
gfx/layers/opengl/GLManager.h
gfx/layers/opengl/ImageLayerOGL.cpp
gfx/layers/opengl/ImageLayerOGL.h
gfx/layers/opengl/LayerManagerOGL.cpp
gfx/layers/opengl/LayerManagerOGL.h
gfx/layers/opengl/LayerManagerOGLProgram.cpp
gfx/layers/opengl/LayerManagerOGLProgram.h
gfx/layers/opengl/TextureClientOGL.cpp
gfx/layers/opengl/TextureClientOGL.h
gfx/layers/opengl/TextureHostOGL.cpp
gfx/layers/opengl/TextureHostOGL.h
gfx/layers/opengl/TexturePoolOGL.cpp
gfx/layers/opengl/TexturePoolOGL.h
gfx/layers/opengl/ThebesLayerOGL.cpp
gfx/layers/opengl/ThebesLayerOGL.h
gfx/thebes/gfxBaseSharedMemorySurface.h
gfx/thebes/gfxPlatform.h
widget/gtk2/nsWindow.cpp
widget/gtk2/nsWindow.h
widget/windows/nsWindow.cpp
xpcom/glue/nsThreadUtils.h
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -55,17 +55,16 @@
 #include <algorithm>
 
 #if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK)
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
 #endif
 
 #include "Layers.h"
-#include "mozilla/layers/ShadowLayers.h"
 #include "nsIIOService.h"
 
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
 #include "mozilla/dom/quota/QuotaManager.h"
 #include "GeckoProfiler.h"
 #include "nsDOMBlobBuilder.h"
 #include "nsIDOMFileHandle.h"
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -18,17 +18,16 @@
 #include "mozilla/dom/PContentChild.h"
 #include "mozilla/dom/PContentDialogChild.h"
 #include "mozilla/ipc/DocumentRendererChild.h"
 #include "mozilla/ipc/FileDescriptorUtils.h"
 #include "mozilla/layers/AsyncPanZoomController.h"
 #include "mozilla/layers/CompositorChild.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/layers/PLayerTransactionChild.h"
-#include "mozilla/layers/ShadowLayers.h"
 #include "mozilla/layout/RenderFrameChild.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/unused.h"
 #include "mozIApplication.h"
 #include "nsComponentManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsContentUtils.h"
 #include "nsCxPusher.h"
--- a/gfx/2d/BasePoint3D.h
+++ b/gfx/2d/BasePoint3D.h
@@ -1,18 +1,16 @@
 /* -*- 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 MOZILLA_BASEPOINT3D_H_
 #define MOZILLA_BASEPOINT3D_H_
 
-#include "nsDebug.h"
-
 namespace mozilla {
 namespace gfx {
 
 /**
  * Do not use this class directly. Subclass it, pass that subclass as the
  * Sub parameter, and only use that subclass. This allows methods to safely
  * cast 'this' to 'Sub*'.
  */
--- a/gfx/2d/Point.h
+++ b/gfx/2d/Point.h
@@ -4,18 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_GFX_POINT_H_
 #define MOZILLA_GFX_POINT_H_
 
 #include "Types.h"
 #include "BasePoint.h"
 #include "BaseSize.h"
-#include "nsMathUtils.h"                // for NS_lround
-
 
 namespace mozilla {
 namespace gfx {
 
 // This should only be used by the typedefs below.
 struct UnknownUnits {};
 
 template<class units>
--- a/gfx/gl/GLTextureImage.cpp
+++ b/gfx/gl/GLTextureImage.cpp
@@ -37,31 +37,16 @@ TextureImage::UpdateFromDataSource(gfx::
     RefPtr<gfxASurface> thebesSurf
         = new gfxImageSurface(aSurface->GetData(),
                               ThebesIntSize(aSurface->GetSize()),
                               aSurface->Stride(),
                               SurfaceFormatToImageFormat(aSurface->GetFormat()));
     return DirectUpdate(thebesSurf, destRegion, thebesSrcPoint);
 }
 
-BasicTextureImage::BasicTextureImage(GLuint aTexture,
-                                     const nsIntSize& aSize,
-                                     GLenum aWrapMode,
-                                     ContentType aContentType,
-                                     GLContext* aContext,
-                                     TextureImage::Flags aFlags /* = TextureImage::NoFlags */,
-                                     TextureImage::ImageFormat aImageFormat /* = gfxASurface::ImageFormatUnknown */)
-    : TextureImage(aSize, aWrapMode, aContentType, aFlags, aImageFormat)
-    , mTexture(aTexture)
-    , mTextureState(Created)
-    , mGLContext(aContext)
-    , mUpdateOffset(0, 0)
-{
-}
-
 BasicTextureImage::~BasicTextureImage()
 {
     GLContext *ctx = mGLContext;
     if (ctx->IsDestroyed() || !ctx->IsOwningThreadCurrent()) {
         ctx = ctx->GetSharedContext();
     }
 
     // If we have a context, then we need to delete the texture;
--- a/gfx/gl/GLTextureImage.h
+++ b/gfx/gl/GLTextureImage.h
@@ -293,17 +293,23 @@ public:
     virtual ~BasicTextureImage();
 
     BasicTextureImage(GLuint aTexture,
                       const nsIntSize& aSize,
                       GLenum aWrapMode,
                       ContentType aContentType,
                       GLContext* aContext,
                       TextureImage::Flags aFlags = TextureImage::NoFlags,
-                      TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown);
+                      TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown)
+        : TextureImage(aSize, aWrapMode, aContentType, aFlags, aImageFormat)
+        , mTexture(aTexture)
+        , mTextureState(Created)
+        , mGLContext(aContext)
+        , mUpdateOffset(0, 0)
+    {}
 
     virtual void BindTexture(GLenum aTextureUnit);
 
     virtual gfxASurface* BeginUpdate(nsIntRegion& aRegion);
     virtual void GetUpdateRegion(nsIntRegion& aForRegion);
     virtual void EndUpdate();
     virtual bool DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom = nsIntPoint(0,0));
     virtual GLuint GetTextureID() { return mTexture; }
--- a/gfx/layers/Compositor.cpp
+++ b/gfx/layers/Compositor.cpp
@@ -1,24 +1,18 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/Compositor.h"
-#include "base/message_loop.h"          // for MessageLoop
-#include "mozilla/layers/CompositorParent.h"  // for CompositorParent
-#include "mozilla/layers/Effects.h"     // for Effect, EffectChain, etc
-#include "mozilla/mozalloc.h"           // for operator delete, etc
+#include "mozilla/layers/Effects.h"
+#include "mozilla/layers/CompositorParent.h"
 
 namespace mozilla {
-namespace gfx {
-class Matrix4x4;
-}
-
 namespace layers {
 
 /* static */ LayersBackend Compositor::sBackend = LAYERS_NONE;
 /* static */ LayersBackend
 Compositor::GetBackend()
 {
   AssertOnCompositorThread();
   return sBackend;
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -1,27 +1,22 @@
 /* -*- 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_COMPOSITOR_H
 #define MOZILLA_GFX_COMPOSITOR_H
 
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "Units.h"                      // for ScreenPoint
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/RefPtr.h"             // for TemporaryRef, RefCounted
-#include "mozilla/gfx/Point.h"          // for IntSize, Point
-#include "mozilla/gfx/Rect.h"           // for Rect, IntRect
-#include "mozilla/gfx/Types.h"          // for Float
-#include "mozilla/layers/CompositorTypes.h"  // for DiagnosticTypes, etc
-#include "mozilla/layers/LayersTypes.h"  // for LayersBackend
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "mozilla/gfx/Rect.h"
+#include "mozilla/gfx/Matrix.h"
+#include "gfxMatrix.h"
+#include "Layers.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/layers/CompositorTypes.h"
 
 /**
  * Different elements of a web pages are rendered into separate "layers" before
  * they are flattened into the final image that is brought to the screen.
  * See Layers.h for more informations about layers and why we use retained
  * structures.
  * Most of the documentation for layers is directly in the source code in the
  * form of doc comments. An overview can also be found in the the wiki:
@@ -100,22 +95,20 @@
  * - Compositor (ex. CompositorOGL)
  * - TextureHost (ex. SharedTextureHostOGL)
  * Depending on the type of data that needs to be serialized, you may need to
  * add specific TextureClient implementations.
  */
 
 class gfxContext;
 class nsIWidget;
-struct gfxMatrix;
-struct nsIntSize;
 
 namespace mozilla {
 namespace gfx {
-class Matrix4x4;
+class DrawTarget;
 }
 
 namespace layers {
 
 struct Effect;
 struct EffectChain;
 class Image;
 class ISurfaceAllocator;
--- a/gfx/layers/CompositorTypes.h
+++ b/gfx/layers/CompositorTypes.h
@@ -1,20 +1,19 @@
 /* -*- 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_LAYERS_COMPOSITORTYPES_H
 #define MOZILLA_LAYERS_COMPOSITORTYPES_H
 
-#include <stdint.h>                     // for uint32_t
-#include <sys/types.h>                  // for int32_t
-#include "LayersTypes.h"                // for LayersBackend, etc
-#include "nsXULAppAPI.h"                // for GeckoProcessType, etc
+#include "LayersTypes.h"
+#include "nsXULAppAPI.h"
+
 
 namespace mozilla {
 namespace layers {
 
 typedef int32_t SurfaceDescriptorType;
 const SurfaceDescriptorType SURFACEDESCRIPTOR_UNKNOWN = 0;
 
 /**
--- a/gfx/layers/CopyableCanvasLayer.cpp
+++ b/gfx/layers/CopyableCanvasLayer.cpp
@@ -1,31 +1,27 @@
 /* -*- 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 "BasicLayersImpl.h"            // for FillWithMask, etc
+#include "mozilla/layers/PLayerTransactionParent.h"
 #include "CopyableCanvasLayer.h"
-#include "GLContext.h"                  // for GLContext
-#include "GLScreenBuffer.h"             // for GLScreenBuffer
-#include "SharedSurface.h"              // for SharedSurface
-#include "SharedSurfaceGL.h"            // for SharedSurface_GL, etc
-#include "SurfaceTypes.h"               // for APITypeT, APITypeT::OpenGL, etc
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPattern.h"                 // for gfxPattern, etc
-#include "gfxPlatform.h"                // for gfxPlatform, gfxImageFormat
-#include "gfxRect.h"                    // for gfxRect
-#include "gfxUtils.h"                   // for gfxUtils
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "nsDebug.h"                    // for NS_ASSERTION, NS_WARNING, etc
-#include "nsISupportsImpl.h"            // for gfxContext::AddRef, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
+#include "BasicLayersImpl.h"
+#include "gfxImageSurface.h"
+#include "GLContext.h"
+#include "gfxUtils.h"
+#include "gfxPlatform.h"
+#include "mozilla/Preferences.h"
+#include "SurfaceStream.h"
+#include "SharedSurfaceGL.h"
+#include "SharedSurfaceEGL.h"
+#include "GeckoProfiler.h"
+
+#include "nsXULAppAPI.h"
 
 using namespace mozilla::gfx;
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
 void
--- a/gfx/layers/CopyableCanvasLayer.h
+++ b/gfx/layers/CopyableCanvasLayer.h
@@ -1,37 +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_COPYABLECANVASLAYER_H
 #define GFX_COPYABLECANVASLAYER_H
 
-#include <stdint.h>                     // for uint32_t
-#include "GLContext.h"                  // for GLContext
-#include "Layers.h"                     // for CanvasLayer, etc
-#include "gfxASurface.h"                // for gfxASurface
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPlatform.h"                // for gfxImageFormat
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Preferences.h"        // for Preferences
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/gfx/2D.h"             // for DrawTarget
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "Layers.h"
+#include "mozilla/layers/CanvasClient.h"
+#include "mozilla/Preferences.h"
+
+#include "gfxPlatform.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
+class CanvasClient2D;
 class CanvasClientWebGL;
 
 /**
  * A shared CanvasLayer implementation that supports copying
  * its contents into a gfxASurface using UpdateSurface.
  */
 class CopyableCanvasLayer : public CanvasLayer
 {
--- a/gfx/layers/Effects.cpp
+++ b/gfx/layers/Effects.cpp
@@ -1,18 +1,16 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "Effects.h"
-#include "LayersLogging.h"              // for AppendToString
-#include "nsAString.h"
-#include "nsPrintfCString.h"            // for nsPrintfCString
-#include "nsString.h"                   // for nsAutoCString
+#include "LayersLogging.h"
+#include "nsPrintfCString.h"
 
 using namespace mozilla::layers;
 
 #ifdef MOZ_LAYERS_HAVE_LOG
 void
 TexturedEffect::PrintInfo(nsACString& aTo, const char* aPrefix)
 {
   aTo += aPrefix;
--- a/gfx/layers/Effects.h
+++ b/gfx/layers/Effects.h
@@ -1,27 +1,21 @@
 /* -*- 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_LAYERS_EFFECTS_H
 #define MOZILLA_LAYERS_EFFECTS_H
 
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef, etc
-#include "mozilla/gfx/Matrix.h"         // for Matrix4x4
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/gfx/Types.h"          // for Filter, etc
-#include "mozilla/layers/CompositorTypes.h"  // for EffectTypes, etc
-#include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_HAVE_LOG
-#include "mozilla/layers/TextureHost.h"  // for CompositingRenderTarget, etc
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nscore.h"                     // for nsACString
+#include "mozilla/gfx/Matrix.h"
+#include "mozilla/layers/Compositor.h"
+#include "mozilla/layers/TextureHost.h"
+#include "LayersLogging.h"
+#include "mozilla/RefPtr.h"
 
 namespace mozilla {
 namespace layers {
 
 /**
  * Effects and effect chains are used by the compositor API (see Compositor.h).
  * An effect chain represents a rendering method, for example some shader and
  * the data required for that shader to run. An effect is some component of the
--- a/gfx/layers/FrameMetrics.h
+++ b/gfx/layers/FrameMetrics.h
@@ -1,21 +1,21 @@
 /* -*- 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 <stdint.h>                     // for uint32_t, uint64_t
-#include "Units.h"                      // for CSSRect, CSSPixel, etc
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/gfx/Rect.h"           // for RoundedIn
-#include "mozilla/gfx/ScaleFactor.h"    // for ScaleFactor
+#include "gfxPoint.h"
+#include "gfxTypes.h"
+#include "nsRect.h"
+#include "mozilla/gfx/Rect.h"
+#include "Units.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
--- a/gfx/layers/GrallocImages.cpp
+++ b/gfx/layers/GrallocImages.cpp
@@ -1,19 +1,19 @@
 /* -*- 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 "mozilla/layers/ImageBridgeChild.h"
+
+#include "nsDebug.h"
+#include "ImageContainer.h"
 #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 <OMX_IVCommon.h>
 #include <ColorConverter.h>
 
 using namespace mozilla::ipc;
 using namespace android;
 
 #define ALIGN(x, align) ((x + align - 1) & ~(align - 1))
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -1,29 +1,27 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
+#include "mozilla/layers/ImageBridgeChild.h"
+
 #include "ImageContainer.h"
-#include <string.h>                     // for memcpy, memset
-#include "SharedTextureImage.h"         // for SharedTextureImage
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxUtils.h"                   // for gfxUtils
-#include "mozilla/RefPtr.h"             // for TemporaryRef
-#include "mozilla/ipc/CrossProcessMutex.h"  // for CrossProcessMutex, etc
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/ImageBridgeChild.h"  // for ImageBridgeChild
-#include "mozilla/layers/ImageClient.h"  // for ImageClient
-#include "nsISupportsUtils.h"           // for NS_IF_ADDREF
-#ifdef MOZ_WIDGET_GONK
 #include "GrallocImages.h"
-#endif
+#include "mozilla/ipc/Shmem.h"
+#include "mozilla/ipc/CrossProcessMutex.h"
+#include "SharedTextureImage.h"
+#include "gfxImageSurface.h"
+#include "gfxSharedImageSurface.h"
+#include "yuv_convert.h"
+#include "gfxUtils.h"
+#include "gfxPlatform.h"
+#include "mozilla/layers/ImageClient.h"
 
 #ifdef XP_MACOSX
 #include "mozilla/gfx/QuartzSupport.h"
 #endif
 
 #ifdef XP_WIN
 #include "gfxD2DSurface.h"
 #include "gfxWindowsPlatform.h"
@@ -36,19 +34,16 @@ using namespace mozilla::ipc;
 using namespace android;
 using mozilla::gfx::DataSourceSurface;
 using mozilla::gfx::SourceSurface;
 
 
 namespace mozilla {
 namespace layers {
 
-class DataSourceSurface;
-class SourceSurface;
-
 int32_t Image::sSerialCounter = 0;
 
 already_AddRefed<Image>
 ImageFactory::CreateImage(const ImageFormat *aFormats,
                           uint32_t aNumFormats,
                           const gfxIntSize &,
                           BufferRecycleBin *aRecycleBin)
 {
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -1,58 +1,47 @@
 /* -*- 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_IMAGECONTAINER_H
 #define GFX_IMAGECONTAINER_H
 
-#include <stdint.h>                     // for uint32_t, uint8_t, uint64_t
-#include <sys/types.h>                  // for int32_t
-#include "GeckoProfilerFunc.h"          // for TimeStamp
-#include "ImageTypes.h"                 // for ImageFormat, etc
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
-#include "mozilla/Mutex.h"              // for Mutex
-#include "mozilla/ReentrantMonitor.h"   // for ReentrantMonitorAutoEnter, etc
-#include "mozilla/TimeStamp.h"          // for TimeStamp
-#include "mozilla/layers/LayersTypes.h"  // for LayersBackend, etc
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr, nsAutoArrayPtr, etc
-#include "nsAutoRef.h"                  // for nsCountedRef
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsImpl.h"            // for Image::Release, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
-#include "nsTArray.h"                   // for nsTArray
-#include "nsThreadUtils.h"              // for NS_IsMainThread
-#include "pratom.h"                     // for PR_ATOMIC_INCREMENT
-class nsMainThreadSurfaceRef;
+#include "mozilla/Mutex.h"
+#include "mozilla/ReentrantMonitor.h"
+#include "gfxASurface.h" // for gfxImageFormat
+#include "mozilla/layers/LayersTypes.h" // for LayersBackend
+#include "mozilla/TimeStamp.h"
+#include "ImageTypes.h"
+#include "nsTArray.h"
+#include "pratom.h"
 
 #ifdef XP_WIN
 struct ID3D10Texture2D;
 struct ID3D10Device;
 struct ID3D10ShaderResourceView;
 #endif
 
 typedef void* HANDLE;
 
 namespace mozilla {
 
 class CrossProcessMutex;
+namespace ipc {
+class Shmem;
+}
 
 namespace layers {
 
 class ImageClient;
 class SharedPlanarYCbCrImage;
 class DeprecatedSharedPlanarYCbCrImage;
 class TextureClient;
+class SurfaceDescriptor;
 
 struct ImageBackendData
 {
   virtual ~ImageBackendData() {}
 
 protected:
   ImageBackendData() {}
 };
--- a/gfx/layers/ImageDataSerializer.cpp
+++ b/gfx/layers/ImageDataSerializer.cpp
@@ -1,22 +1,18 @@
 /* -*- 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 "ImageDataSerializer.h"
-#include "gfx2DGlue.h"                  // for SurfaceFormatToImageFormat
-#include "gfxASurface.h"                // for gfxASurface
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/gfx/2D.h"             // for DataSourceSurface, Factory
-#include "mozilla/gfx/Tools.h"          // for GetAlignedStride, etc
-#include "mozilla/mozalloc.h"           // for operator delete, etc
+#include "mozilla/layers/ImageDataSerializer.h"
+#include "gfxImageSurface.h"
+#include "mozilla/gfx/2D.h"
+#include "gfx2DGlue.h"
+#include "mozilla/gfx/Tools.h"
 
 namespace mozilla {
 namespace layers {
 
 // The Data is layed out as follows:
 //
 //  +-------------------+   -++ --+   <-- ImageDataSerializerBase::mData pointer
 //  | SurfaceBufferInfo |     |   |
--- a/gfx/layers/ImageDataSerializer.h
+++ b/gfx/layers/ImageDataSerializer.h
@@ -3,21 +3,20 @@
  */
 /* 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_LAYERS_BLOBSURFACE_H
 #define GFX_LAYERS_BLOBSURFACE_H
 
-#include <stdint.h>                     // for uint8_t, uint32_t
-#include "mozilla/Attributes.h"         // for MOZ_STACK_CLASS
-#include "mozilla/RefPtr.h"             // for TemporaryRef
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat
+#include "mozilla/gfx/Point.h"
+#include "mozilla/RefPtr.h"
+
+#include <stdint.h>
 
 class gfxImageSurface;
 
 namespace mozilla {
 namespace gfx {
 class DataSourceSurface;
 } // namespace gfx
 } // namespace mozilla
--- a/gfx/layers/ImageLayers.cpp
+++ b/gfx/layers/ImageLayers.cpp
@@ -1,19 +1,15 @@
 /* -*- 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 "ImageLayers.h"
-#include "ImageContainer.h"             // for ImageContainer
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxRect.h"                    // for gfxRect
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsImpl.h"            // for ImageContainer::Release, etc
+#include "ImageContainer.h"
 
 namespace mozilla {
 namespace layers {
 
 ImageLayer::ImageLayer(LayerManager* aManager, void* aImplData)
 : Layer(aManager, aImplData), mFilter(gfxPattern::FILTER_GOOD)
 , mScaleMode(SCALE_NONE), mDisallowBigImage(false)
 {}
--- a/gfx/layers/ImageLayers.h
+++ b/gfx/layers/ImageLayers.h
@@ -1,25 +1,21 @@
 /* -*- 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_IMAGELAYER_H
 #define GFX_IMAGELAYER_H
 
-#include "Layers.h"                     // for Layer, etc
-#include "gfxPattern.h"                 // for gfxPattern, etc
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/layers/LayersTypes.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nscore.h"                     // for nsACString
+#include "Layers.h"
 
-class gfx3DMatrix;
+#include "ImageTypes.h"
+#include "nsISupportsImpl.h"
+#include "gfxPattern.h"
 
 namespace mozilla {
 namespace layers {
 
 class ImageContainer;
 
 /**
  * A Layer which renders an Image.
--- a/gfx/layers/LayerSorter.cpp
+++ b/gfx/layers/LayerSorter.cpp
@@ -1,31 +1,18 @@
 /* -*- 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 "LayerSorter.h"
-#include <math.h>                       // for fabs
-#include <stdint.h>                     // for uint32_t
-#include <stdio.h>                      // for fprintf, stderr, FILE
-#include <stdlib.h>                     // for getenv
-#include "DirectedGraph.h"              // for DirectedGraph
-#include "Layers.h"                     // for Layer
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxLineSegment.h"             // for gfxLineSegment
-#include "gfxPoint.h"                   // for gfxPoint
-#include "gfxPoint3D.h"                 // for gfxPoint3D
-#include "gfxQuad.h"                    // for gfxQuad
-#include "gfxRect.h"                    // for gfxRect
-#include "gfxTypes.h"                   // for gfxFloat
-#include "mozilla/gfx/BasePoint3D.h"    // for BasePoint3D
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTArray.h"                   // for nsTArray, etc
+#include "DirectedGraph.h"
 #include "limits.h"
+#include "gfxLineSegment.h"
+#include "Layers.h"
 #include "mozilla/Assertions.h"
 
 namespace mozilla {
 namespace layers {
 
 enum LayerSortOrder {
   Undefined,
   ABeforeB,
--- a/gfx/layers/LayerTreeInvalidation.cpp
+++ b/gfx/layers/LayerTreeInvalidation.cpp
@@ -1,36 +1,18 @@
 /*-*- 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 "LayerTreeInvalidation.h"
-#include <stdint.h>                     // for uint32_t
-#include "ImageContainer.h"             // for ImageContainer
-#include "ImageLayers.h"                // for ImageLayer, etc
-#include "Layers.h"                     // for Layer, ContainerLayer, etc
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxColor.h"                   // for gfxRGBA
-#include "gfxPattern.h"                 // for gfxPattern, etc
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "gfxPoint3D.h"                 // for gfxPoint3D
-#include "gfxRect.h"                    // for gfxRect
-#include "gfxUtils.h"                   // for gfxUtils
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/mozalloc.h"           // for operator new, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr, nsAutoPtr, etc
-#include "nsDataHashtable.h"            // for nsDataHashtable
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsHashKeys.h"                 // for nsPtrHashKey
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsTArray.h"                   // for nsAutoTArray, nsTArray_Impl
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "Layers.h"
+#include "ImageLayers.h"
+#include "gfxUtils.h"
+#include "nsDataHashtable.h"
 
 namespace mozilla {
 namespace layers {
 
 struct LayerPropertiesBase;
 LayerPropertiesBase* CloneLayerTreePropertiesInternal(Layer* aRoot);
 
 static nsIntRect
--- a/gfx/layers/LayerTreeInvalidation.h
+++ b/gfx/layers/LayerTreeInvalidation.h
@@ -1,20 +1,19 @@
 /*-*- 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_LAYER_TREE_INVALIDATION_H
 #define GFX_LAYER_TREE_INVALIDATION_H
 
-#include "nsRegion.h"                   // for nsIntRegion
+#include "nsRegion.h"
 
 class nsPresContext;
-struct nsIntPoint;
 
 namespace mozilla {
 namespace layers {
 
 class Layer;
 class ContainerLayer;
 
 /**
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -1,42 +1,34 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim: sw=2 ts=8 et :
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/DebugOnly.h"
+
+#include "mozilla/layers/AsyncPanZoomController.h"
+#include "mozilla/layers/PLayerTransaction.h"
+#include "mozilla/layers/LayerManagerComposite.h"
+#include "mozilla/Telemetry.h"
+#include "CompositableHost.h"
+
+#include "ImageLayers.h"
+#include "ImageContainer.h"
 #include "Layers.h"
-#include <algorithm>                    // for max, min
-#include "AnimationCommon.h"            // for ComputedTimingFunction
-#include "CompositableHost.h"           // for CompositableHost
-#include "GeckoProfilerFunc.h"          // for TimeStamp, TimeDuration
-#include "ImageContainer.h"             // for ImageContainer, etc
-#include "ImageLayers.h"                // for ImageLayer
-#include "LayerSorter.h"                // for SortLayersBy3DZOrder
-#include "LayersLogging.h"              // for AppendToString
-#include "ReadbackLayer.h"              // for ReadbackLayer
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxUtils.h"                   // for gfxUtils, etc
-#include "mozilla/DebugOnly.h"          // for DebugOnly
-#include "mozilla/Preferences.h"        // for Preferences
-#include "mozilla/Telemetry.h"          // for Accumulate
-#include "mozilla/TelemetryHistogramEnums.h"
-#include "mozilla/gfx/2D.h"             // for DrawTarget
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/layers/AsyncPanZoomController.h"
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/LayerManagerComposite.h"  // for LayerComposite
-#include "mozilla/layers/LayerTransaction.h"  // for TransformFunction, etc
-#include "nsAString.h"
-#include "nsCSSValue.h"                 // for nsCSSValue::Array, etc
-#include "nsPrintfCString.h"            // for nsPrintfCString
-#include "nsStyleStruct.h"              // for nsTimingFunction, etc
+#include "gfxPlatform.h"
+#include "ReadbackLayer.h"
+#include "gfxUtils.h"
+#include "nsPrintfCString.h"
+#include "LayerSorter.h"
+#include "AnimationCommon.h"
+#include "mozilla/layers/Compositor.h"
+#include "LayersLogging.h"
 
 using namespace mozilla::layers;
 using namespace mozilla::gfx;
 
 typedef FrameMetrics::ViewID ViewID;
 const ViewID FrameMetrics::NULL_SCROLL_ID = 0;
 const ViewID FrameMetrics::ROOT_SCROLL_ID = 1;
 const ViewID FrameMetrics::START_SCROLL_ID = 2;
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -1,69 +1,46 @@
 /* -*- 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_LAYERS_H
 #define GFX_LAYERS_H
 
-#include <stdint.h>                     // for uint32_t, uint64_t, uint8_t
-#include <stdio.h>                      // for FILE
-#include <sys/types.h>                  // for int32_t, int64_t
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "FrameMetrics.h"               // for FrameMetrics
-#include "Units.h"                      // for LayerMargin, LayerPoint
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxColor.h"                   // for gfxRGBA
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPattern.h"                 // for gfxPattern, etc
-#include "gfxPoint.h"                   // for gfxPoint, gfxIntSize
-#include "gfxRect.h"                    // for gfxRect
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2, etc
-#include "mozilla/DebugOnly.h"          // for DebugOnly
-#include "mozilla/RefPtr.h"             // for TemporaryRef
-#include "mozilla/TimeStamp.h"          // for TimeStamp, TimeDuration
-#include "mozilla/gfx/BaseMargin.h"     // for BaseMargin
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat
-#include "mozilla/gfx/UserData.h"       // for UserData, etc
+#include "mozilla/DebugOnly.h"
+
 #include "mozilla/layers/LayersTypes.h"
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsAutoPtr.h"                  // for nsAutoPtr, nsRefPtr, etc
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsCSSProperty.h"              // for nsCSSProperty
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsImpl.h"            // for Layer::Release, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsSize.h"                     // for nsIntSize
-#include "nsString.h"                   // for nsCString
-#include "nsStyleAnimation.h"           // for nsStyleAnimation::Value, etc
-#include "nsTArray.h"                   // for nsTArray
-#include "nsTArrayForwardDeclare.h"     // for InfallibleTArray
-#include "nscore.h"                     // for nsACString, nsAString
-#include "prlog.h"                      // for PRLogModuleInfo
+#include "gfxTypes.h"
+#include "gfxASurface.h"
+#include "nsRegion.h"
+#include "nsPoint.h"
+#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 "nsStyleAnimation.h"
+#include "FrameMetrics.h"
+#include "mozilla/gfx/2D.h"
+#include "mozilla/TimeStamp.h"
 
 class gfxContext;
 class nsPaintEvent;
 
 extern uint8_t gLayerManagerLayerBuilder;
 
 namespace mozilla {
 
 class FrameLayerBuilder;
 class WebGLContext;
 
-namespace gfx {
-class DrawTarget;
-}
-
 namespace gl {
 class GLContext;
 }
 
 namespace css {
 class ComputedTimingFunction;
 }
 
@@ -85,16 +62,17 @@ class ReadbackProcessor;
 class RefLayer;
 class LayerComposite;
 class ShadowableLayer;
 class ShadowLayerForwarder;
 class LayerManagerComposite;
 class SpecificLayerAttributes;
 class SurfaceDescriptor;
 class Compositor;
+class LayerComposite;
 struct TextureFactoryIdentifier;
 struct EffectMask;
 
 #define MOZ_LAYER_DECL_NAME(n, e)                           \
   virtual const char* Name() const { return n; }            \
   virtual LayerType GetType() const { return e; }
 
 /**
@@ -608,16 +586,17 @@ private:
     uint32_t mLatestStartIndex;
     uint32_t mCurrentRunStartIndex;
   };
   FramesTimingRecording mRecording;
 
   TimeStamp mTabSwitchStart;
 };
 
+class ThebesLayer;
 typedef InfallibleTArray<Animation> AnimationArray;
 
 struct AnimData {
   InfallibleTArray<nsStyleAnimation::Value> mStartValues;
   InfallibleTArray<nsStyleAnimation::Value> mEndValues;
   InfallibleTArray<nsAutoPtr<mozilla::css::ComputedTimingFunction> > mFunctions;
 };
 
--- a/gfx/layers/LayersLogging.cpp
+++ b/gfx/layers/LayersLogging.cpp
@@ -1,25 +1,16 @@
 /* -*- 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 "LayersLogging.h"
-#include <stdint.h>                     // for uint8_t
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxColor.h"                   // for gfxRGBA
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "mozilla/gfx/Matrix.h"         // for Matrix4x4, Matrix
-#include "nsDebug.h"                    // for NS_ERROR
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 nsACString&
 AppendToString(nsACString& s, const void* p,
--- a/gfx/layers/LayersLogging.h
+++ b/gfx/layers/LayersLogging.h
@@ -1,38 +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/. */
 
 #ifndef GFX_LAYERSLOGGING_H
 #define GFX_LAYERSLOGGING_H
 
-#include "FrameMetrics.h"               // for FrameMetrics, etc
-#include "gfxPattern.h"                 // for gfxPattern, etc
-#include "mozilla/gfx/Point.h"          // for IntSize, etc
-#include "mozilla/gfx/Types.h"          // for Filter, SurfaceFormat
-#include "mozilla/layers/CompositorTypes.h"  // for TextureFlags
-#include "nsAString.h"
-#include "nsPrintfCString.h"            // for nsPrintfCString
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nscore.h"                     // for nsACString, etc
-
-class gfx3DMatrix;
-struct gfxRGBA;
-struct nsIntPoint;
-struct nsIntRect;
-struct nsIntSize;
+#include "Layers.h"
+#include "nsPoint.h"
+#include "mozilla/gfx/Point.h"
+#include "mozilla/gfx/Rect.h"
+#include "mozilla/layers/Compositor.h"
+#include "FrameMetrics.h"
+#include "gfxPattern.h"
+#include "gfxColor.h"
+#include "gfx3DMatrix.h"
+#include "nsRegion.h"
+#include "nsPrintfCString.h"
 
 namespace mozilla {
-namespace gfx {
-class Matrix4x4;
-template <class units> struct RectTyped;
-}
-
 namespace layers {
 
 nsACString&
 AppendToString(nsACString& s, const void* p,
                const char* pfx="", const char* sfx="");
 
 nsACString&
 AppendToString(nsACString& s, const gfxPattern::GraphicsFilter& f,
--- a/gfx/layers/LayersTypes.h
+++ b/gfx/layers/LayersTypes.h
@@ -1,25 +1,23 @@
 /* -*- 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
 
-#include <stdint.h>                     // for uint32_t
-#include "nsPoint.h"                    // for nsIntPoint
-
+#include "nsPoint.h"
 #ifdef MOZ_WIDGET_GONK
 #include <ui/GraphicBuffer.h>
 #endif
 #if defined(DEBUG) || defined(PR_LOGGING)
 #  include <stdio.h>            // FILE
-#  include "prlog.h"            // for PR_LOG
+#  include "prlog.h"
 #  ifndef MOZ_LAYERS_HAVE_LOG
 #    define MOZ_LAYERS_HAVE_LOG
 #  endif
 #  define MOZ_LAYERS_LOG(_args)                             \
   PR_LOG(LayerManager::GetLog(), PR_LOG_DEBUG, _args)
 #  define MOZ_LAYERS_LOG_IF_SHADOWABLE(layer, _args)         \
   do { if (layer->AsShadowableLayer()) { PR_LOG(LayerManager::GetLog(), PR_LOG_DEBUG, _args); } } while (0)
 #else
--- a/gfx/layers/ReadbackLayer.h
+++ b/gfx/layers/ReadbackLayer.h
@@ -1,31 +1,17 @@
 /* -*- 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_READBACKLAYER_H
 #define GFX_READBACKLAYER_H
 
-#include <stdint.h>                     // for uint64_t
-#include "Layers.h"                     // for Layer, etc
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxColor.h"                   // for gfxRGBA
-#include "gfxRect.h"                    // for gfxRect
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsAutoPtr.h"                  // for nsAutoPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
-#include "nscore.h"                     // for nsACString
-
-class gfxContext;
+#include "Layers.h"
 
 namespace mozilla {
 namespace layers {
 
 class ReadbackProcessor;
 
 /**
  * A ReadbackSink receives a stream of updates to a rectangle of pixels.
--- a/gfx/layers/ReadbackProcessor.cpp
+++ b/gfx/layers/ReadbackProcessor.cpp
@@ -1,30 +1,15 @@
 /* -*- 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 "ReadbackProcessor.h"
-#include <sys/types.h>                  // for int32_t
-#include "Layers.h"                     // for Layer, ThebesLayer, etc
-#include "ReadbackLayer.h"              // for ReadbackLayer, ReadbackSink
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxColor.h"                   // for gfxRGBA
-#include "gfxContext.h"                 // for gfxContext
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxRect.h"                    // for gfxRect
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "nsAutoPtr.h"                  // for nsRefPtr, nsAutoPtr
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsImpl.h"            // for gfxContext::Release, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsSize.h"                     // for nsIntSize
+#include "ReadbackLayer.h"
 
 namespace mozilla {
 namespace layers {
 
 void
 ReadbackProcessor::BuildUpdates(ContainerLayer* aContainer)
 {
   NS_ASSERTION(mAllUpdates.IsEmpty(), "Some updates not processed?");
--- a/gfx/layers/ReadbackProcessor.h
+++ b/gfx/layers/ReadbackProcessor.h
@@ -1,28 +1,24 @@
 /* -*- 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_READBACKPROCESSOR_H
 #define GFX_READBACKPROCESSOR_H
 
-#include <stdint.h>                     // for uint64_t
-#include "nsRect.h"                     // for nsIntRect
-#include "nsTArray.h"                   // for nsTArray
- 
-class nsIntRegion;
+#include "ThebesLayerBuffer.h"
+#include "nsTArray.h"
 
 namespace mozilla {
 namespace layers {
 
 class ContainerLayer;
 class ReadbackLayer;
-class ThebesLayer;
 
 class ReadbackProcessor {
 public:
   /**
    * Called by the container before processing any child layers. Call this
    * if any child layer might have changed in any way (other than content-only
    * changes to layers other than ColorLayers and ThebesLayers).
    *
--- a/gfx/layers/RenderTrace.cpp
+++ b/gfx/layers/RenderTrace.cpp
@@ -1,18 +1,18 @@
 /* -*- 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 "Layers.h"
 #include "RenderTrace.h"
 
 // If rendertrace is off let's no compile this code
 #ifdef MOZ_RENDERTRACE
-#include "Layers.h"
 
 
 namespace mozilla {
 namespace layers {
 
 static int colorId = 0;
 
 static gfx3DMatrix GetRootTransform(Layer *aLayer) {
--- a/gfx/layers/SharedTextureImage.h
+++ b/gfx/layers/SharedTextureImage.h
@@ -1,25 +1,19 @@
 /* -*- 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_SHAREDTEXTUREIMAGE_H
 #define GFX_SHAREDTEXTUREIMAGE_H
 
-#include "GLContext.h"                  // for GLContext, etc
-#include "GLContextProvider.h"          // for GLContextProvider
-#include "ImageContainer.h"             // for Image
-#include "ImageTypes.h"                 // for ImageFormat::SHARED_TEXTURE
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsSize.h"                     // for nsIntSize
-
-class gfxASurface;
+#include "ImageContainer.h"
+#include "GLContext.h"
+#include "GLContextProvider.h"
 
 // Split into a separate header from ImageLayers.h due to GLContext.h dependence
 // Implementation remains in ImageLayers.cpp
 
 namespace mozilla {
 
 namespace layers {
 
--- a/gfx/layers/ThebesLayerBuffer.cpp
+++ b/gfx/layers/ThebesLayerBuffer.cpp
@@ -1,40 +1,26 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "base/basictypes.h"
+
+#include "BasicLayersImpl.h"
 #include "ThebesLayerBuffer.h"
-#include <sys/types.h>                  // for int32_t
-#include <algorithm>                    // for max
-#include "BasicImplData.h"              // for BasicImplData
-#include "BasicLayersImpl.h"            // for ToData
-#include "GeckoProfilerImpl.h"          // for PROFILER_LABEL
-#include "Layers.h"                     // for ThebesLayer, Layer, etc
-#include "gfxColor.h"                   // for gfxRGBA
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPattern.h"                 // for gfxPattern
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxPoint.h"                   // for gfxPoint
-#include "gfxRect.h"                    // for gfxRect
-#include "gfxTeeSurface.h"              // for gfxTeeSurface
-#include "gfxUtils.h"                   // for gfxUtils
-#include "mozilla/Util.h"               // for ArrayLength
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/gfx/Matrix.h"         // for Matrix
-#include "mozilla/gfx/Point.h"          // for Point, IntPoint
-#include "mozilla/gfx/Rect.h"           // for Rect, IntRect
-#include "mozilla/gfx/Types.h"          // for ExtendMode::EXTEND_CLAMP, etc
-#include "mozilla/layers/ShadowLayers.h"  // for ShadowableLayer
-#include "mozilla/layers/TextureClient.h"  // for DeprecatedTextureClient
-#include "nsSize.h"                     // for nsIntSize
+#include "Layers.h"
+#include "gfxContext.h"
+#include "gfxPlatform.h"
+#include "gfxTeeSurface.h"
+#include "gfxUtils.h"
+#include "ipc/AutoOpenSurface.h"
+#include "nsDeviceContext.h"
+#include "GeckoProfiler.h"
+#include <algorithm>
 
 namespace mozilla {
 
 using namespace gfx;
 
 namespace layers {
 
 nsIntRect
--- a/gfx/layers/ThebesLayerBuffer.h
+++ b/gfx/layers/ThebesLayerBuffer.h
@@ -1,43 +1,27 @@
 /* -*- 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 THEBESLAYERBUFFER_H_
 #define THEBESLAYERBUFFER_H_
 
-#include <stdint.h>                     // for uint32_t
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxContext.h"                 // for gfxContext
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef
-#include "mozilla/gfx/2D.h"             // for DrawTarget, etc
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT
-#include "nsISupportsImpl.h"            // for gfxContext::AddRef, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-
-struct gfxMatrix;
-struct nsIntSize;
+#include "gfxContext.h"
+#include "gfxASurface.h"
+#include "nsRegion.h"
+#include "mozilla/layers/TextureClient.h"
+#include "mozilla/gfx/2D.h"
+#include "Layers.h"
 
 namespace mozilla {
-namespace gfx {
-class Matrix;
-}
-
 namespace layers {
 
-class DeprecatedTextureClient;
+class AutoOpenSurface;
 class ThebesLayer;
 
 /**
  * This is a cairo/Thebes surface, but with a literal twist. Scrolling
  * causes the layer's visible region to move. We want to keep
  * reusing the same surface if the region size hasn't changed, but we don't
  * want to keep moving the contents of the surface around in memory. So
  * we use a trick.
--- a/gfx/layers/TiledLayerBuffer.h
+++ b/gfx/layers/TiledLayerBuffer.h
@@ -11,23 +11,19 @@
   // This needs to go away as we enabled tiled
   // layers everywhere.
   #define FORCE_BASICTILEDTHEBESLAYER
 #endif
 // Debug defines
 //#define GFX_TILEDLAYER_DEBUG_OVERLAY
 //#define GFX_TILEDLAYER_PREF_WARNINGS
 
-#include <stdint.h>                     // for uint16_t, uint32_t
-#include <sys/types.h>                  // for int32_t
-#include "nsDebug.h"                    // for NS_ABORT_IF_FALSE
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTArray.h"                   // for nsTArray
+#include "nsRect.h"
+#include "nsRegion.h"
+#include "nsTArray.h"
 
 namespace mozilla {
 namespace layers {
 
 // An abstract implementation of a tile buffer. This code covers the logic of
 // moving and reusing tiles and leaves the validation up to the implementor. To
 // avoid the overhead of virtual dispatch, we employ the curiously recurring
 // template pattern.
--- a/gfx/layers/YCbCrImageDataSerializer.cpp
+++ b/gfx/layers/YCbCrImageDataSerializer.cpp
@@ -1,23 +1,20 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/YCbCrImageDataSerializer.h"
-#include <string.h>                     // for memcpy
-#include "gfx2DGlue.h"                  // for ToIntSize
-#include "mozilla/gfx/2D.h"             // for DataSourceSurface, Factory
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/gfx/Types.h"
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "yuv_convert.h"                // for ConvertYCbCrToRGB32, etc
+#include "yuv_convert.h"
+#include "mozilla/gfx/2D.h"
+#include "gfx2DGlue.h"
 
 #define MOZ_ALIGN_WORD(x) (((x) + 3) & ~3)
+using namespace mozilla::ipc;
 
 namespace mozilla {
 namespace layers {
 
 // The Data is layed out as follows:
 //
 //  +-----------------+   -++ --+ --+ <-- Beginning of the buffer
 //  | YCbCrBufferInfo |     |   |   |
--- a/gfx/layers/YCbCrImageDataSerializer.h
+++ b/gfx/layers/YCbCrImageDataSerializer.h
@@ -1,27 +1,28 @@
 /* -*- 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_LAYERS_BLOBYCBCRSURFACE_H
 #define MOZILLA_LAYERS_BLOBYCBCRSURFACE_H
 
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint8_t, uint32_t
-#include "ImageTypes.h"                 // for StereoMode
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Attributes.h"         // for MOZ_STACK_CLASS
-#include "mozilla/RefPtr.h"             // for TemporaryRef
-#include "mozilla/gfx/Point.h"          // for IntSize
+#include "mozilla/DebugOnly.h"
+
+#include "base/basictypes.h"
+#include "Shmem.h"
+#include "gfxPoint.h"
 
 namespace mozilla {
+namespace ipc {
+  class Shmem;
+}
 namespace gfx {
-class DataSourceSurface;
+  class DataSourceSurface;
 }
 
 namespace layers {
 
 class Image;
 
 /**
  * Convenience class to share code between YCbCrImageDataSerializer
--- a/gfx/layers/basic/BasicCanvasLayer.cpp
+++ b/gfx/layers/basic/BasicCanvasLayer.cpp
@@ -1,20 +1,27 @@
 /* -*- 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 "mozilla/layers/PLayerTransactionParent.h"
 #include "BasicCanvasLayer.h"
-#include "basic/BasicLayers.h"          // for BasicLayerManager
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-class gfxContext;
+#include "gfxImageSurface.h"
+#include "GLContext.h"
+#include "gfxUtils.h"
+#include "gfxPlatform.h"
+#include "mozilla/Preferences.h"
+#include "BasicLayersImpl.h"
+#include "SurfaceStream.h"
+#include "SharedSurfaceGL.h"
+#include "SharedSurfaceEGL.h"
+#include "GeckoProfiler.h"
+
+#include "nsXULAppAPI.h"
 
 using namespace mozilla::gfx;
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
 void
--- a/gfx/layers/basic/BasicCanvasLayer.h
+++ b/gfx/layers/basic/BasicCanvasLayer.h
@@ -1,29 +1,34 @@
 /* -*- 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_BASICCANVASLAYER_H
 #define GFX_BASICCANVASLAYER_H
 
-#include "BasicImplData.h"              // for BasicImplData
-#include "BasicLayers.h"                // for BasicLayerManager
-#include "CopyableCanvasLayer.h"        // for CopyableCanvasLayer
-#include "Layers.h"                     // for CanvasLayer, etc
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsRegion.h"                   // for nsIntRegion
-class gfxContext;
+#include "BasicLayersImpl.h"
+#include "nsXULAppAPI.h"
+#include "BasicLayers.h"
+#include "BasicImplData.h"
+#include "mozilla/layers/CanvasClient.h"
+#include "mozilla/Preferences.h"
+#include "CopyableCanvasLayer.h"
+
+#include "gfxPlatform.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
+class CanvasClient2D;
+class CanvasClientWebGL;
+
 class BasicCanvasLayer : public CopyableCanvasLayer,
                          public BasicImplData
 {
 public:
   BasicCanvasLayer(BasicLayerManager* aLayerManager) :
     CopyableCanvasLayer(aLayerManager, static_cast<BasicImplData*>(this))
   { }
   
--- a/gfx/layers/basic/BasicColorLayer.cpp
+++ b/gfx/layers/basic/BasicColorLayer.cpp
@@ -1,27 +1,15 @@
 /* -*- 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 "BasicLayersImpl.h"            // for FillWithMask, etc
-#include "Layers.h"                     // for ColorLayer, etc
-#include "BasicImplData.h"              // for BasicImplData
-#include "BasicLayers.h"                // for BasicLayerManager
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "gfxRect.h"                    // for gfxRect
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "mozilla/layers/PLayerTransactionParent.h"
+#include "BasicLayersImpl.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 class BasicColorLayer : public ColorLayer, public BasicImplData {
 public:
--- a/gfx/layers/basic/BasicCompositor.h
+++ b/gfx/layers/basic/BasicCompositor.h
@@ -3,17 +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 MOZILLA_GFX_BASICCOMPOSITOR_H
 #define MOZILLA_GFX_BASICCOMPOSITOR_H
 
 #include "mozilla/layers/Compositor.h"
 #include "mozilla/layers/TextureHost.h"
-#include "mozilla/gfx/2D.h"
 
 namespace mozilla {
 namespace layers {
 
 class BasicCompositingRenderTarget : public CompositingRenderTarget
 {
 public:
   BasicCompositingRenderTarget(gfx::DrawTarget* aDrawTarget, const gfx::IntSize& aSize)
--- a/gfx/layers/basic/BasicContainerLayer.cpp
+++ b/gfx/layers/basic/BasicContainerLayer.cpp
@@ -1,31 +1,23 @@
 /* -*- 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 "BasicLayersImpl.h"
 #include "BasicContainerLayer.h"
-#include <sys/types.h>                  // for int32_t
-#include "BasicLayersImpl.h"            // for ToData
-#include "basic/BasicImplData.h"        // for BasicImplData
-#include "basic/BasicLayers.h"          // for BasicLayerManager
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
+
+
 BasicContainerLayer::~BasicContainerLayer()
 {
   while (mFirstChild) {
     ContainerRemoveChild(mFirstChild, this);
   }
 
   MOZ_COUNT_DTOR(BasicContainerLayer);
 }
--- a/gfx/layers/basic/BasicContainerLayer.h
+++ b/gfx/layers/basic/BasicContainerLayer.h
@@ -1,26 +1,18 @@
 /* -*- 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_BASICCONTAINERLAYER_H
 #define GFX_BASICCONTAINERLAYER_H
 
-#include "BasicImplData.h"              // for BasicImplData
-#include "BasicLayers.h"                // for BasicLayerManager
-#include "Layers.h"                     // for Layer, ContainerLayer
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsUtils.h"           // for NS_ADDREF, NS_RELEASE
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR
-struct nsIntRect;
+#include "BasicLayers.h"
+#include "BasicImplData.h"
 
 namespace mozilla {
 namespace layers {
 
 template<class Container> void
 ContainerInsertAfter(Layer* aChild, Layer* aAfter, Container* aContainer)
 {
   NS_ASSERTION(aChild->Manager() == aContainer->Manager(),
--- a/gfx/layers/basic/BasicImageLayer.cpp
+++ b/gfx/layers/basic/BasicImageLayer.cpp
@@ -1,44 +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 "./../mozilla-config.h"        // for MOZ_X11
-#include "BasicLayersImpl.h"            // for FillWithMask, etc
-#include "ImageContainer.h"             // for AutoLockImage, etc
-#include "ImageLayers.h"                // for ImageLayer
-#include "Layers.h"                     // for Layer (ptr only), etc
-#include "basic/BasicImplData.h"        // for BasicImplData
-#include "basic/BasicLayers.h"          // for BasicLayerManager
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxContext.h"                 // for gfxContext
-#include "gfxPattern.h"                 // for gfxPattern, etc
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "gfxUtils.h"                   // for gfxUtils
+#include "mozilla/layers/PLayerTransactionParent.h"
+#include "BasicLayersImpl.h"
+#include "SharedTextureImage.h"
+#include "gfxUtils.h"
+#include "gfxSharedImageSurface.h"
+#include "mozilla/layers/ImageClient.h"
+#include "mozilla/layers/TextureClient.h"
 #ifdef MOZ_X11
-#include "gfxXlibSurface.h"             // for gfxXlibSurface
+#include "gfxXlibSurface.h"
 #endif
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsAutoPtr.h"                  // for nsRefPtr, getter_AddRefs, etc
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsImpl.h"            // for gfxPattern::Release, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
-class SurfaceDescriptor;
-
 class BasicImageLayer : public ImageLayer, public BasicImplData {
 public:
   BasicImageLayer(BasicLayerManager* aLayerManager) :
     ImageLayer(aLayerManager, static_cast<BasicImplData*>(this)),
     mSize(-1, -1)
   {
     MOZ_COUNT_CTOR(BasicImageLayer);
   }
--- a/gfx/layers/basic/BasicImages.cpp
+++ b/gfx/layers/basic/BasicImages.cpp
@@ -1,34 +1,31 @@
 /* -*- 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 <stdint.h>                     // for uint8_t, uint32_t
-#include "BasicLayers.h"                // for BasicLayerManager
-#include "ImageContainer.h"             // for PlanarYCbCrImage, etc
-#include "ImageTypes.h"                 // for ImageFormat, etc
-#include "cairo.h"                      // for cairo_user_data_key_t
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPlatform.h"                // for gfxPlatform, gfxImageFormat
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "gfxUtils.h"                   // for gfxUtils
-#include "mozilla/mozalloc.h"           // for operator delete[], etc
-#include "nsAutoPtr.h"                  // for nsRefPtr, nsAutoArrayPtr
-#include "nsAutoRef.h"                  // for nsCountedRef
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ERROR, NS_ASSERTION
-#include "nsISupportsImpl.h"            // for Image::Release, etc
-#include "nsThreadUtils.h"              // for NS_IsMainThread
+#include "mozilla/ReentrantMonitor.h"
+
+#include "ImageLayers.h"
+#include "BasicLayers.h"
+#include "gfxImageSurface.h"
+
 #ifdef XP_MACOSX
 #include "gfxQuartzImageSurface.h"
 #endif
 
+#include "cairo.h"
+
+#include "gfxUtils.h"
+
+#include "gfxPlatform.h"
+
+using mozilla::ReentrantMonitor;
+
 namespace mozilla {
 namespace layers {
 
 class BasicPlanarYCbCrImage : public PlanarYCbCrImage
 {
 public:
   BasicPlanarYCbCrImage(const gfxIntSize& aScaleHint, gfxImageFormat aOffscreenFormat, BufferRecycleBin *aRecycleBin)
     : PlanarYCbCrImage(aRecycleBin)
--- a/gfx/layers/basic/BasicImplData.h
+++ b/gfx/layers/basic/BasicImplData.h
@@ -1,27 +1,18 @@
 /* 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_BASICIMPLDATA_H
 #define GFX_BASICIMPLDATA_H
 
-#include "Layers.h"                     // for Layer (ptr only), etc
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-class gfxASurface;
-
 namespace mozilla {
 namespace layers {
 
-class ReadbackProcessor;
-class SurfaceDescriptor;
-
 /**
  * This is the ImplData for all Basic layers. It also exposes methods
  * private to the Basic implementation that are common to all Basic layer types.
  * In particular, there is an internal Paint() method that we can use
  * to paint the contents of non-Thebes layers.
  *
  * The class hierarchy for Basic layers is like this:
  *                                 BasicImplData
--- a/gfx/layers/basic/BasicLayerManager.cpp
+++ b/gfx/layers/basic/BasicLayerManager.cpp
@@ -1,60 +1,40 @@
 /* -*- 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 <stdint.h>                     // for uint32_t
-#include <stdlib.h>                     // for rand, RAND_MAX
-#include <sys/types.h>                  // for int32_t
-#include "BasicContainerLayer.h"        // for BasicContainerLayer
-#include "BasicLayersImpl.h"            // for ToData, BasicReadbackLayer, etc
-#include "GeckoProfilerImpl.h"          // for PROFILER_LABEL
-#include "ImageContainer.h"             // for ImageFactory
-#include "Layers.h"                     // for Layer, ContainerLayer, etc
-#include "ReadbackLayer.h"              // for ReadbackLayer
-#include "ReadbackProcessor.h"          // for ReadbackProcessor
-#include "RenderTrace.h"                // for RenderTraceLayers, etc
-#include "basic/BasicImplData.h"        // for BasicImplData
-#include "basic/BasicLayers.h"          // for BasicLayerManager, etc
-#include "cairo-rename.h"               // for pixman_image_create_bits, etc
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxCachedTempSurface.h"       // for gfxCachedTempSurface
-#include "gfxColor.h"                   // for gfxRGBA
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxPoint.h"                   // for gfxIntSize, gfxPoint
-#include "gfxRect.h"                    // for gfxRect
-#include "gfxUtils.h"                   // for gfxUtils
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/WidgetUtils.h"        // for ScreenRotation
-#include "mozilla/gfx/2D.h"             // for DrawTarget
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "mozilla/gfx/Matrix.h"         // for Matrix
-#include "mozilla/gfx/Rect.h"           // for IntRect, Rect
-#include "mozilla/layers/LayersTypes.h"  // for BufferMode::BUFFER_NONE, etc
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION, etc
-#include "nsISupportsImpl.h"            // for gfxContext::Release, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion, etc
-#include "nsTArray.h"                   // for nsAutoTArray
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "mozilla/dom/TabChild.h"
+#include "mozilla/Hal.h"
+#include "mozilla/layers/PLayerChild.h"
+#include "mozilla/layers/PLayerTransactionChild.h"
+#include "mozilla/layers/PLayerTransactionParent.h"
+
+#include "gfxSharedImageSurface.h"
+#include "gfxImageSurface.h"
+#include "gfxUtils.h"
+#include "gfxPlatform.h"
+#include "nsXULAppAPI.h"
+#include "RenderTrace.h"
+#include "GeckoProfiler.h"
+
 #define PIXMAN_DONT_DEFINE_STDINT
-#include "pixman.h"                     // for pixman_f_transform, etc
+#include "pixman.h"
 
-class nsIWidget;
+#include "BasicLayersImpl.h"
+#include "BasicThebesLayer.h"
+#include "BasicContainerLayer.h"
+#include "CompositorChild.h"
+#include "mozilla/Preferences.h"
+#include "nsIWidget.h"
+
+#ifdef MOZ_WIDGET_ANDROID
+#include "AndroidBridge.h"
+#endif
 
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 /**
--- a/gfx/layers/basic/BasicLayers.h
+++ b/gfx/layers/basic/BasicLayers.h
@@ -1,43 +1,39 @@
 /* -*- 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_BASICLAYERS_H
 #define GFX_BASICLAYERS_H
 
-#include <stdint.h>                     // for INT32_MAX, int32_t
-#include "Layers.h"                     // for Layer (ptr only), etc
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxCachedTempSurface.h"       // for gfxCachedTempSurface
-#include "gfxContext.h"                 // for gfxContext
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/WidgetUtils.h"        // for ScreenRotation
-#include "mozilla/layers/LayersTypes.h"  // for BufferMode, LayersBackend, etc
-#include "nsAString.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsISupportsImpl.h"            // for gfxContext::AddRef, etc
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nscore.h"                     // for nsAString, etc
+#include "Layers.h"
 
-class gfxPattern;
+#include "gfxContext.h"
+#include "gfxCachedTempSurface.h"
+#include "mozilla/layers/ShadowLayers.h"
+#include "mozilla/WidgetUtils.h"
+#include "nsAutoRef.h"
+#include "nsThreadUtils.h"
+
 class nsIWidget;
 
 namespace mozilla {
 namespace layers {
 
 class BasicShadowableLayer;
+class ThebesLayerComposite;
+class ContainerLayerComposite;
+class ImageLayerComposite;
+class CanvasLayerComposite;
+class ColorLayerComposite;
+class ReadbackProcessor;
 class ImageFactory;
-class ImageLayer;
 class PaintLayerContext;
-class ReadbackLayer;
-class ReadbackProcessor;
 
 /**
  * This is a cairo/Thebes-only, main-thread-only implementation of layers.
  * 
  * In each transaction, the client sets up the layer tree and then during
  * the drawing phase, each ThebesLayer is painted directly into the target
  * context (with appropriate clipping and Push/PopGroups performed
  * between layers).
--- a/gfx/layers/basic/BasicLayersImpl.cpp
+++ b/gfx/layers/basic/BasicLayersImpl.cpp
@@ -1,22 +1,17 @@
 /* -*- 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 "mozilla/DebugOnly.h"
+
 #include "BasicLayersImpl.h"
-#include <new>                          // for operator new
-#include "Layers.h"                     // for Layer, etc
-#include "basic/BasicImplData.h"        // for BasicImplData
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/DebugOnly.h"          // for DebugOnly
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/ISurfaceAllocator.h"
+#include "mozilla/layers/PLayerTransaction.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 void
 AutoMaskData::Construct(const gfxMatrix& aTransform,
--- a/gfx/layers/basic/BasicLayersImpl.h
+++ b/gfx/layers/basic/BasicLayersImpl.h
@@ -1,37 +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_BASICLAYERSIMPL_H
 #define GFX_BASICLAYERSIMPL_H
 
-#include "BasicImplData.h"              // for BasicImplData
-#include "BasicLayers.h"                // for BasicLayerManager
-#include "ReadbackLayer.h"              // for ReadbackLayer
-#include "gfxASurface.h"                // for gfxASurface
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "ipc/AutoOpenSurface.h"        // for AutoOpenSurface
-#include "mozilla/Attributes.h"         // for MOZ_DELETE, MOZ_STACK_CLASS
-#include "mozilla/Util.h"               // for Maybe
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsImpl.h"            // for gfxContext::Release, etc
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "ipc/AutoOpenSurface.h"
+#include "ipc/ShadowLayerChild.h"
+#include "BasicLayers.h"
+#include "BasicImplData.h"
+#include "ReadbackLayer.h"
+#include "ReadbackProcessor.h"
 
 namespace mozilla {
 namespace layers {
 
 class BasicContainerLayer;
-class Layer;
+class ShadowableLayer;
 
 class AutoSetOperator {
 public:
   AutoSetOperator(gfxContext* aContext, gfxContext::GraphicsOperator aOperator) {
     if (aOperator != gfxContext::OPERATOR_OVER) {
       aContext->SetOperator(aOperator);
       mContext = aContext;
     }
--- a/gfx/layers/basic/BasicThebesLayer.cpp
+++ b/gfx/layers/basic/BasicThebesLayer.cpp
@@ -1,37 +1,20 @@
 /* -*- 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 "BasicThebesLayer.h"
-#include <stdint.h>                     // for uint32_t
-#include "GeckoProfiler.h"              // for PROFILER_LABEL
-#include "ReadbackLayer.h"              // for ReadbackLayer, ReadbackSink
-#include "ReadbackProcessor.h"          // for ReadbackProcessor::Update, etc
-#include "RenderTrace.h"                // for RenderTraceInvalidateEnd, etc
-#include "BasicLayersImpl.h"            // for AutoMaskData, etc
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "gfxRect.h"                    // for gfxRect
-#include "gfxUtils.h"                   // for gfxUtils
-#include "mozilla/gfx/2D.h"             // for DrawTarget
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "mozilla/gfx/Matrix.h"         // for Matrix
-#include "mozilla/gfx/Rect.h"           // for Rect, IntRect
-#include "mozilla/gfx/Types.h"          // for Float, etc
-#include "mozilla/layers/LayersTypes.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsISupportsImpl.h"            // for gfxContext::Release, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsTArray.h"                   // for nsTArray, nsTArray_Impl
-struct gfxMatrix;
+#include "gfxUtils.h"
+#include "nsIWidget.h"
+#include "RenderTrace.h"
+#include "GeckoProfiler.h"
+
+#include "prprf.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 static nsIntRegion
 IntersectWithClip(const nsIntRegion& aRegion, gfxContext* aContext)
--- a/gfx/layers/basic/BasicThebesLayer.h
+++ b/gfx/layers/basic/BasicThebesLayer.h
@@ -1,36 +1,23 @@
 /* -*- 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_BASICTHEBESLAYER_H
 #define GFX_BASICTHEBESLAYER_H
 
-#include "Layers.h"                     // for ThebesLayer, LayerManager, etc
-#include "ThebesLayerBuffer.h"          // for ThebesLayerBuffer, etc
-#include "BasicImplData.h"              // for BasicImplData
-#include "BasicLayers.h"                // for BasicLayerManager
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxPoint.h"                   // for gfxPoint
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/layers/ContentClient.h"  // for ContentClientBasic
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-class gfxContext;
+#include "mozilla/layers/PLayerTransactionParent.h"
+#include "BasicLayersImpl.h"
+#include "mozilla/layers/ContentClient.h"
 
 namespace mozilla {
 namespace layers {
 
-class ReadbackProcessor;
-
 class BasicThebesLayer : public ThebesLayer, public BasicImplData {
 public:
   typedef ThebesLayerBuffer::PaintState PaintState;
   typedef ThebesLayerBuffer::ContentType ContentType;
 
   BasicThebesLayer(BasicLayerManager* aLayerManager) :
     ThebesLayer(aLayerManager, static_cast<BasicImplData*>(this)),
     mContentClient(nullptr)
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -1,43 +1,29 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/CanvasClient.h"
-#include "ClientCanvasLayer.h"          // for ClientCanvasLayer
-#include "GLContext.h"                  // for GLContext
-#include "GLScreenBuffer.h"             // for GLScreenBuffer
-#include "Layers.h"                     // for Layer, etc
-#include "SurfaceStream.h"              // for SurfaceStream
-#include "SurfaceTypes.h"               // for SurfaceStreamHandle
-#include "gfx2DGlue.h"                  // for ImageFormatToSurfaceFormat
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/layers/CompositableForwarder.h"
-#include "mozilla/layers/LayersTypes.h"
-#include "mozilla/layers/TextureClient.h"  // for TextureClient, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsDebug.h"                    // for printf_stderr, NS_ASSERTION
-#include "nsXULAppAPI.h"                // for XRE_GetProcessType, etc
+#include "mozilla/layers/TextureClient.h"
+#include "ClientCanvasLayer.h"
+#include "mozilla/layers/ShadowLayers.h"
+#include "SharedTextureImage.h"
+#include "nsXULAppAPI.h"
+#include "GLContext.h"
+#include "SurfaceStream.h"
+#include "SharedSurface.h"
 #ifdef MOZ_WIDGET_GONK
 #include "SharedSurfaceGralloc.h"
 #endif
 
 using namespace mozilla::gl;
 
 namespace mozilla {
-namespace gfx {
-class SharedSurface;
-}
-}
-
-namespace mozilla {
 namespace layers {
 
 /* static */ TemporaryRef<CanvasClient>
 CanvasClient::CreateCanvasClient(CanvasClientType aType,
                                  CompositableForwarder* aForwarder,
                                  TextureFlags aFlags)
 {
   if (aType == CanvasClientGLContext &&
--- a/gfx/layers/client/CanvasClient.h
+++ b/gfx/layers/client/CanvasClient.h
@@ -1,33 +1,24 @@
 /* -*- 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_CANVASCLIENT_H
 #define MOZILLA_GFX_CANVASCLIENT_H
 
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef
-#include "mozilla/layers/CompositableClient.h"  // for CompositableClient
-#include "mozilla/layers/CompositorTypes.h"  // for TextureInfo, etc
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
-#include "mozilla/layers/TextureClient.h"  // for TextureClient, etc
-#include "mozilla/mozalloc.h"           // for operator delete
-
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat
+#include "mozilla/layers/TextureClient.h"
+#include "mozilla/layers/CompositableClient.h"
 
 namespace mozilla {
+
 namespace layers {
 
 class ClientCanvasLayer;
-class CompositableForwarder;
 
 /**
  * Compositable client for 2d and webgl canvas.
  */
 class CanvasClient : public CompositableClient
 {
 public:
   /**
--- a/gfx/layers/client/ClientCanvasLayer.cpp
+++ b/gfx/layers/client/ClientCanvasLayer.cpp
@@ -1,29 +1,18 @@
 /* -*- 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 "ClientCanvasLayer.h"
-#include "GLContext.h"                  // for GLContext
-#include "GLScreenBuffer.h"             // for GLScreenBuffer
-#include "GeckoProfilerImpl.h"          // for PROFILER_LABEL
-#include "SharedSurfaceEGL.h"           // for SurfaceFactory_EGLImage
-#include "SharedSurfaceGL.h"            // for SurfaceFactory_GLTexture, etc
-#include "SurfaceStream.h"              // for SurfaceStream, etc
-#include "SurfaceTypes.h"               // for SurfaceStreamType
-#include "ClientLayerManager.h"         // for ClientLayerManager, etc
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/LayersTypes.h"
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsXULAppAPI.h"                // for XRE_GetProcessType, etc
+#include "gfxPlatform.h"
+#include "SurfaceStream.h"
+#include "SharedSurfaceGL.h"
+#include "SharedSurfaceEGL.h"
 #ifdef MOZ_WIDGET_GONK
 #include "SharedSurfaceGralloc.h"
 #endif
 #ifdef XP_MACOSX
 #include "SharedSurfaceIO.h"
 #endif
 
 using namespace mozilla::gl;
--- a/gfx/layers/client/ClientCanvasLayer.h
+++ b/gfx/layers/client/ClientCanvasLayer.h
@@ -1,36 +1,31 @@
 /* -*- 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_CLIENTCANVASLAYER_H
 #define GFX_CLIENTCANVASLAYER_H
 
-#include "mozilla/layers/CanvasClient.h"  // for CanvasClient, etc
-#include "ClientLayerManager.h"         // for ClientLayerManager, etc
-#include "CopyableCanvasLayer.h"        // for CopyableCanvasLayer
-#include "Layers.h"                     // for CanvasLayer, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/layers/LayerTransaction.h"  // for CanvasLayerAttributes, etc
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "ClientLayerManager.h"
+#include "nsXULAppAPI.h"
+#include "gfxASurface.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/layers/LayerTransaction.h"
+#include "mozilla/layers/CanvasClient.h"
+#include "CopyableCanvasLayer.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
-class CompositableClient;
-class ShadowableLayer;
+class CanvasClient2D;
+class CanvasClientWebGL;
 
 class ClientCanvasLayer : public CopyableCanvasLayer,
                           public ClientLayer
 {
   typedef CanvasClient::CanvasClientType CanvasClientType;
 public:
   ClientCanvasLayer(ClientLayerManager* aLayerManager) :
     CopyableCanvasLayer(aLayerManager, static_cast<ClientLayer*>(this))
--- a/gfx/layers/client/ClientColorLayer.cpp
+++ b/gfx/layers/client/ClientColorLayer.cpp
@@ -1,31 +1,21 @@
 /* -*- 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 "ClientLayerManager.h"         // for ClientLayerManager, etc
-#include "Layers.h"                     // for ColorLayer, etc
-#include "mozilla/layers/LayerTransaction.h"  // for ColorLayerAttributes, etc
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "ClientLayerManager.h"
+#include "mozilla/layers/LayerTransaction.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
-class ShadowableLayer;
-
 class ClientColorLayer : public ColorLayer, 
                          public ClientLayer {
 public:
   ClientColorLayer(ClientLayerManager* aLayerManager) :
     ColorLayer(aLayerManager, static_cast<ClientLayer*>(this))
   {
     MOZ_COUNT_CTOR(ClientColorLayer);
   }
--- a/gfx/layers/client/ClientContainerLayer.cpp
+++ b/gfx/layers/client/ClientContainerLayer.cpp
@@ -1,22 +1,10 @@
-/* -*- 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 "ClientContainerLayer.h"
-#include "ClientLayerManager.h"         // for ClientLayerManager, etc
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-
-namespace mozilla {
-namespace layers {
+#include "BasicLayersImpl.h"
 
 already_AddRefed<ContainerLayer>
 ClientLayerManager::CreateContainerLayer()
 {
   NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
   nsRefPtr<ClientContainerLayer> layer =
     new ClientContainerLayer(this);
   CREATE_SHADOW(Container);
@@ -27,11 +15,8 @@ already_AddRefed<RefLayer>
 ClientLayerManager::CreateRefLayer()
 {
   NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
   nsRefPtr<ClientRefLayer> layer =
     new ClientRefLayer(this);
   CREATE_SHADOW(Ref);
   return layer.forget();
 }
-
-}
-}
--- a/gfx/layers/client/ClientContainerLayer.h
+++ b/gfx/layers/client/ClientContainerLayer.h
@@ -1,32 +1,12 @@
-/* -*- 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_CLIENTCONTAINERLAYER_H
-#define GFX_CLIENTCONTAINERLAYER_H
+#include "ClientLayerManager.h"
+#include "gfxPlatform.h"
 
-#include <stdint.h>                     // for uint32_t
-#include "ClientLayerManager.h"         // for ClientLayerManager, etc
-#include "Layers.h"                     // for Layer, ContainerLayer, etc
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsUtils.h"           // for NS_ADDREF, NS_RELEASE
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTArray.h"                   // for nsAutoTArray
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-
-namespace mozilla {
-namespace layers {
-
-class ShadowableLayer;
+using namespace mozilla::layers;
 
 template<class Container> void
 ContainerInsertAfter(Layer* aChild, Layer* aAfter, Container* aContainer)
 {
   NS_ASSERTION(aChild->Manager() == aContainer->Manager(),
                "Child has wrong manager");
   NS_ASSERTION(!aChild->GetParent(),
                "aChild already in the tree");
@@ -295,13 +275,8 @@ public:
   }
 
 private:
   ClientLayerManager* ClientManager()
   {
     return static_cast<ClientLayerManager*>(mManager);
   }
 };
-
-}
-}
-
-#endif
--- a/gfx/layers/client/ClientImageLayer.cpp
+++ b/gfx/layers/client/ClientImageLayer.cpp
@@ -1,39 +1,23 @@
 /* -*- 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 "ClientLayerManager.h"         // for ClientLayerManager, etc
-#include "ImageContainer.h"             // for AutoLockImage, etc
-#include "ImageLayers.h"                // for ImageLayer
-#include "gfxASurface.h"                // for gfxASurface
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/ImageClient.h"  // for ImageClient, etc
-#include "mozilla/layers/LayerTransaction.h"  // for ImageLayerAttributes, etc
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr, getter_AddRefs, etc
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "ClientLayerManager.h"
+#include "mozilla/layers/LayerTransaction.h"
+#include "mozilla/layers/ImageClient.h"
+#include "ImageContainer.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
-class CompositableClient;
-class Layer;
-class ShadowableLayer;
-
 class ClientImageLayer : public ImageLayer, 
                          public ClientLayer {
 public:
   ClientImageLayer(ClientLayerManager* aLayerManager)
     : ImageLayer(aLayerManager, static_cast<ClientLayer*>(this))
     , mImageClientTypeContainer(BUFFER_UNKNOWN)
   {
     MOZ_COUNT_CTOR(ClientImageLayer);
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -1,35 +1,26 @@
 /* -*- 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 "ClientLayerManager.h"
-#include "CompositorChild.h"            // for CompositorChild
-#include "GeckoProfilerImpl.h"          // for PROFILER_LABEL
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "ipc/AutoOpenSurface.h"        // for AutoOpenSurface
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
+#include "nsIWidget.h"
+#include "mozilla/dom/TabChild.h"
 #include "mozilla/Hal.h"
-#include "mozilla/dom/ScreenOrientation.h"  // for ScreenOrientation
-#include "mozilla/dom/TabChild.h"       // for TabChild
-#include "mozilla/hal_sandbox/PHal.h"   // for ScreenConfiguration
-#include "mozilla/layers/CompositableClient.h"  // for CompositableChild, etc
-#include "mozilla/layers/ContentClient.h"  // for ContentClientRemote
-#include "mozilla/layers/ISurfaceAllocator.h"
-#include "mozilla/layers/LayerTransaction.h"  // for EditReply, etc
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
-#include "mozilla/layers/PLayerChild.h"  // for PLayerChild
+#include "mozilla/layers/PLayerChild.h"
 #include "mozilla/layers/PLayerTransactionChild.h"
-#include "nsAString.h"
-#include "nsIWidget.h"                  // for nsIWidget
-#include "nsTArray.h"                   // for AutoInfallibleTArray
-#include "nsXULAppAPI.h"                // for XRE_GetProcessType, etc
+#include "mozilla/layers/PLayerTransactionParent.h"
+#include "CompositorChild.h"
+#include "ipc/AutoOpenSurface.h"
+#include "ipc/ShadowLayerChild.h"
+#include "mozilla/layers/CompositableClient.h"
+#include "mozilla/layers/ContentClient.h"
+
 #ifdef MOZ_WIDGET_ANDROID
 #include "AndroidBridge.h"
 #endif
 
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 namespace mozilla {
--- a/gfx/layers/client/ClientLayerManager.h
+++ b/gfx/layers/client/ClientLayerManager.h
@@ -1,43 +1,23 @@
 /* -*- 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_CLIENTLAYERMANAGER_H
 #define GFX_CLIENTLAYERMANAGER_H
 
-#include <stdint.h>                     // for int32_t
 #include "Layers.h"
-#include "gfxContext.h"                 // for gfxContext
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/WidgetUtils.h"        // for ScreenRotation
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/LayersTypes.h"  // for BufferMode, LayersBackend, etc
-#include "mozilla/layers/ShadowLayers.h"  // for ShadowLayerForwarder, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ABORT_IF_FALSE
-#include "nsISupportsImpl.h"            // for Layer::Release, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsTArray.h"                   // for nsTArray
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR
-#include "nscore.h"                     // for nsAString
-
-class nsIWidget;
+#include "mozilla/layers/ShadowLayers.h"
 
 namespace mozilla {
 namespace layers {
 
-class ClientThebesLayer;
 class CompositorChild;
-class ImageLayer;
-class PLayerChild;
 
 class ClientLayerManager : public LayerManager,
                            public ShadowLayerForwarder
 {
   typedef nsTArray<nsRefPtr<Layer> > LayerRefArray;
 
 public:
   ClientLayerManager(nsIWidget* aWidget);
@@ -197,16 +177,17 @@ private:
   // Used to repeat the transaction right away (to avoid rebuilding
   // a display list) to support progressive drawing.
   bool mRepeatTransaction;
   bool mIsRepeatTransaction;
   bool mTransactionIncomplete;
   bool mCompositorMightResample;
 };
 
+class ClientThebesLayer;
 class ClientLayer : public ShadowableLayer
 {
 public:
   ClientLayer()
   {
     MOZ_COUNT_CTOR(ClientLayer);
   }
 
--- a/gfx/layers/client/ClientThebesLayer.cpp
+++ b/gfx/layers/client/ClientThebesLayer.cpp
@@ -1,30 +1,15 @@
 /* -*- 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 "ClientThebesLayer.h"
-#include <stdint.h>                     // for uint32_t
-#include "GeckoProfilerImpl.h"          // for PROFILER_LABEL
-#include "client/ClientLayerManager.h"  // for ClientLayerManager, etc
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxContext.h"                 // for gfxContext
-#include "gfxRect.h"                    // for gfxRect
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/gfx/2D.h"             // for DrawTarget
-#include "mozilla/gfx/Matrix.h"         // for Matrix
-#include "mozilla/gfx/Rect.h"           // for Rect, IntRect
-#include "mozilla/gfx/Types.h"          // for Float, etc
-#include "mozilla/layers/LayersTypes.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-#include "nsRect.h"                     // for nsIntRect
+#include "ClientTiledThebesLayer.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 static void
 SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget)
--- a/gfx/layers/client/ClientThebesLayer.h
+++ b/gfx/layers/client/ClientThebesLayer.h
@@ -1,37 +1,23 @@
 /* -*- 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_CLIENTTHEBESLAYER_H
 #define GFX_CLIENTTHEBESLAYER_H
 
-#include "ClientLayerManager.h"         // for ClientLayerManager, etc
-#include "Layers.h"                     // for ThebesLayer, etc
-#include "ThebesLayerBuffer.h"          // for ThebesLayerBuffer, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/layers/ContentClient.h"  // for ContentClient
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-#include "mozilla/layers/PLayerTransaction.h" // for ThebesLayerAttributes
-
-class gfxContext;
+#include "ClientLayerManager.h"
+#include "ThebesLayerBuffer.h"
+#include "mozilla/layers/ContentClient.h"
 
 namespace mozilla {
 namespace layers {
 
-class CompositableClient;
-class ShadowableLayer;
-class SpecificLayerAttributes;
-
 class ClientThebesLayer : public ThebesLayer, 
                           public ClientLayer {
 public:
   typedef ThebesLayerBuffer::PaintState PaintState;
   typedef ThebesLayerBuffer::ContentType ContentType;
 
   ClientThebesLayer(ClientLayerManager* aLayerManager) :
     ThebesLayer(aLayerManager, static_cast<ClientLayer*>(this)),
--- a/gfx/layers/client/ClientTiledThebesLayer.cpp
+++ b/gfx/layers/client/ClientTiledThebesLayer.cpp
@@ -1,27 +1,18 @@
 /* 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/PLayerTransactionChild.h"
 #include "ClientTiledThebesLayer.h"
-#include "FrameMetrics.h"               // for FrameMetrics
-#include "Units.h"                      // for ScreenIntRect, CSSPoint, etc
-#include "ClientLayerManager.h"         // for ClientLayerManager, etc
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxPoint.h"                   // for gfxSize
-#include "gfxRect.h"                    // for gfxRect
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/gfx/Rect.h"           // for Rect, RectTyped
-#include "mozilla/layers/LayerTransaction.h"
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "gfxImageSurface.h"
+#include "GeckoProfiler.h"
+#include "gfxPlatform.h"
+
 
 namespace mozilla {
 namespace layers {
 
 
 ClientTiledThebesLayer::ClientTiledThebesLayer(ClientLayerManager* const aManager)
   : ThebesLayer(aManager, static_cast<ClientLayer*>(this))
   , mContentClient()
--- a/gfx/layers/client/ClientTiledThebesLayer.h
+++ b/gfx/layers/client/ClientTiledThebesLayer.h
@@ -1,29 +1,23 @@
 /* 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_CLIENTTILEDTHEBESLAYER_H
 #define GFX_CLIENTTILEDTHEBESLAYER_H
 
-#include "ClientLayerManager.h"         // for ClientLayer, etc
-#include "Layers.h"                     // for ThebesLayer, etc
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/layers/TiledContentClient.h"
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT
-#include "nsRegion.h"                   // for nsIntRegion
-
-class gfxContext;
+#include "mozilla/layers/ShadowLayers.h"
+#include "ClientLayerManager.h"
+#include "mozilla/layers/TiledContentClient.h" // tiles and tile buffer
 
 namespace mozilla {
 namespace layers {
 
-class ShadowableLayer;
-class SpecificLayerAttributes;
+class BasicTiledLayerBuffer;
 
 /**
  * An implementation of ThebesLayer that ONLY supports remote
  * composition that is backed by tiles. This thebes layer implementation
  * is better suited to mobile hardware to work around slow implementation
  * of glTexImage2D (for OGL compositors), and restrait memory bandwidth.
  *
  * Tiled Thebes layers use a different protocol compared with other
--- a/gfx/layers/client/CompositableClient.cpp
+++ b/gfx/layers/client/CompositableClient.cpp
@@ -1,20 +1,19 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/CompositableClient.h"
-#include <stdint.h>                     // for uint64_t, uint32_t
-#include "gfxPlatform.h"                // for gfxPlatform
+#include "mozilla/layers/TextureClient.h"
+#include "mozilla/layers/TextureClientOGL.h"
+#include "mozilla/layers/LayerTransactionChild.h"
 #include "mozilla/layers/CompositableForwarder.h"
-#include "mozilla/layers/TextureClient.h"  // for DeprecatedTextureClient, etc
-#include "mozilla/layers/TextureClientOGL.h"
-#include "mozilla/mozalloc.h"           // for operator delete, etc
+#include "gfxPlatform.h"
 #ifdef XP_WIN
 #include "mozilla/layers/TextureD3D9.h"
 #include "mozilla/layers/TextureD3D11.h"
 #include "gfxWindowsPlatform.h"
 #endif
 
 namespace mozilla {
 namespace layers {
--- a/gfx/layers/client/CompositableClient.h
+++ b/gfx/layers/client/CompositableClient.h
@@ -1,34 +1,30 @@
 /* -*- 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_BUFFERCLIENT_H
 #define MOZILLA_GFX_BUFFERCLIENT_H
 
-#include <stdint.h>                     // for uint64_t
-#include <vector>                       // for vector
-#include "mozilla/Assertions.h"         // for MOZ_CRASH
-#include "mozilla/RefPtr.h"             // for TemporaryRef, RefCounted
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/LayersTypes.h"  // for LayersBackend
-#include "mozilla/layers/PCompositableChild.h"  // for PCompositableChild
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "mozilla/layers/PCompositableChild.h"
+#include "mozilla/layers/LayersTypes.h"
+#include "mozilla/RefPtr.h"
 
 namespace mozilla {
 namespace layers {
 
+class CompositableChild;
 class CompositableClient;
 class DeprecatedTextureClient;
 class TextureClient;
 class BufferTextureClient;
 class ImageBridgeChild;
+class ShadowableLayer;
 class CompositableForwarder;
 class CompositableChild;
 class SurfaceDescriptor;
 
 /**
  * CompositableClient manages the texture-specific logic for composite layers,
  * independently of the layer. It is the content side of a CompositableClient/
  * CompositableHost pair.
--- a/gfx/layers/client/ContentClient.cpp
+++ b/gfx/layers/client/ContentClient.cpp
@@ -1,37 +1,21 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/ContentClient.h"
-#include "BasicLayers.h"                // for BasicLayerManager
-#include "Layers.h"                     // for ThebesLayer, Layer, etc
-#include "gfxColor.h"                   // for gfxRGBA
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxPoint.h"                   // for gfxIntSize, gfxPoint
-#include "gfxTeeSurface.h"              // for gfxTeeSurface
-#include "gfxUtils.h"                   // for gfxUtils
-#include "ipc/ShadowLayers.h"           // for ShadowLayerForwarder
-#include "mozilla/Util.h"               // for ArrayLength
-#include "mozilla/gfx/2D.h"             // for DrawTarget, Factory
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/gfx/Types.h"
+#include "mozilla/gfx/2D.h"
+#include "BasicThebesLayer.h"
+#include "nsIWidget.h"
+#include "gfxUtils.h"
+#include "gfxPlatform.h"
 #include "mozilla/layers/LayerManagerComposite.h"
-#include "mozilla/layers/LayerTransaction.h"  // for ThebesBufferData
-#include "mozilla/layers/LayersTypes.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsDebug.h"                    // for NS_ASSERTION, NS_WARNING, etc
-#include "nsISupportsImpl.h"            // for gfxContext::Release, etc
-#include "nsIWidget.h"                  // for nsIWidget
-#include "prenv.h"                      // for PR_GetEnv
+#include "gfxTeeSurface.h"
 #ifdef XP_WIN
 #include "gfxWindowsPlatform.h"
 #endif
 
 namespace mozilla {
 
 using namespace gfx;
 
--- a/gfx/layers/client/ContentClient.h
+++ b/gfx/layers/client/ContentClient.h
@@ -1,49 +1,29 @@
 /* -*- 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_CONTENTCLIENT_H
 #define MOZILLA_GFX_CONTENTCLIENT_H
 
-#include <stdint.h>                     // for uint32_t
-#include "ThebesLayerBuffer.h"          // for ThebesLayerBuffer, etc
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "mozilla/Assertions.h"         // for MOZ_CRASH
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/layers/CompositableClient.h"  // for CompositableClient
-#include "mozilla/layers/CompositableForwarder.h"
-#include "mozilla/layers/CompositorTypes.h"  // for TextureInfo, etc
-#include "mozilla/layers/ISurfaceAllocator.h"
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
-#include "mozilla/layers/TextureClient.h"  // for DeprecatedTextureClient
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTArray.h"                   // for nsTArray
-
-class gfxContext;
-struct gfxMatrix;
+#include "mozilla/layers/LayersSurfaces.h"
+#include "mozilla/layers/CompositableClient.h"
+#include "gfxReusableSurfaceWrapper.h"
+#include "mozilla/layers/TextureClient.h"
+#include "ThebesLayerBuffer.h"
+#include "ipc/AutoOpenSurface.h"
+#include "ipc/ShadowLayerChild.h"
+#include "gfxPlatform.h"
 
 namespace mozilla {
-namespace gfx {
-class DrawTarget;
-}
-
 namespace layers {
 
 class BasicLayerManager;
-class ThebesLayer;
 
 /**
  * A compositable client for Thebes layers. These are different to Image/Canvas
  * clients due to sending a valid region across IPC and because we do a lot more
  * optimisation work, encapsualted in ThebesLayerBuffers.
  *
  * We use content clients for OMTC and non-OMTC, basic rendering so that
  * BasicThebesLayer has only one interface to deal with. We support single and
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -1,42 +1,23 @@
 /* -*- 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 "ImageClient.h"
-#include <stdint.h>                     // for uint32_t
-#include "ImageContainer.h"             // for Image, PlanarYCbCrImage, etc
-#include "ImageTypes.h"                 // for ImageFormat::PLANAR_YCBCR, etc
-#include "SharedTextureImage.h"         // for SharedTextureImage::Data, etc
-#include "gfx2DGlue.h"                  // for ImageFormatToSurfaceFormat
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat, etc
-#include "mozilla/layers/CompositableClient.h"  // for CompositableClient
-#include "mozilla/layers/CompositableForwarder.h"
-#include "mozilla/layers/CompositorTypes.h"  // for CompositableType, etc
-#include "mozilla/layers/ISurfaceAllocator.h"
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
-#include "mozilla/layers/ShadowLayers.h"  // for ShadowLayerForwarder
+#include "mozilla/layers/TextureClient.h"
+#include "mozilla/layers/ImageClient.h"
+#include "BasicLayers.h"
+#include "mozilla/layers/ShadowLayers.h"
+#include "SharedTextureImage.h"
+#include "ImageContainer.h" // For PlanarYCbCrImage
+#include "mozilla/layers/SharedRGBImage.h"
 #include "mozilla/layers/SharedPlanarYCbCrImage.h"
-#include "mozilla/layers/SharedRGBImage.h"
-#include "mozilla/layers/TextureClient.h"  // for TextureClient, etc
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#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 nsIntRect
+#include "gfxPlatform.h"
+
 #ifdef MOZ_WIDGET_GONK
 #include "GrallocImages.h"
 #endif
 
 namespace mozilla {
 namespace layers {
 
 /* static */ TemporaryRef<ImageClient>
--- a/gfx/layers/client/ImageClient.h
+++ b/gfx/layers/client/ImageClient.h
@@ -1,36 +1,27 @@
 /* -*- 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_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 MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat
-#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 DeprecatedTextureClient, etc
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsRect.h"                     // for nsIntRect
+#include "mozilla/layers/LayersSurfaces.h"
+#include "mozilla/layers/CompositableClient.h"
+#include "mozilla/layers/TextureClient.h"
+#include "gfxPattern.h"
 
 namespace mozilla {
 namespace layers {
 
-class CompositableForwarder;
-class Image;
 class ImageContainer;
-class ShadowableLayer;
+class ImageLayer;
+class PlanarYCbCrImage;
 
 /**
  * Image clients are used by basic image layers on the content thread, they
  * always match with an ImageHost on the compositor thread. See
  * CompositableClient.h for information on connecting clients to hosts.
  */
 class ImageClient : public CompositableClient
 {
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -1,37 +1,40 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/TextureClient.h"
-#include <stdint.h>                     // for uint8_t, uint32_t, etc
-#include "Layers.h"                     // for Layer, etc
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxPoint.h"                   // for gfxIntSize, gfxSize
-#include "gfxReusableSurfaceWrapper.h"  // for gfxReusableSurfaceWrapper
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
-#include "mozilla/layers/CompositableClient.h"  // for CompositableClient
-#include "mozilla/layers/CompositableForwarder.h"
-#include "mozilla/layers/ISurfaceAllocator.h"
+#include "mozilla/layers/TextureClientOGL.h"
+
+#include "mozilla/layers/ImageClient.h"
+#include "mozilla/layers/CanvasClient.h"
+#include "mozilla/layers/ContentClient.h"
+#include "mozilla/layers/ShadowLayers.h"
+#include "mozilla/layers/SharedPlanarYCbCrImage.h"
+#include "GLContext.h"
+#include "BasicLayers.h" // for PaintContext
+#include "mozilla/layers/YCbCrImageDataSerializer.h"
+#include "gfxReusableSurfaceWrapper.h"
+#include "gfxPlatform.h"
 #include "mozilla/layers/ImageDataSerializer.h"
-#include "mozilla/layers/ShadowLayers.h"  // for ShadowLayerForwarder
-#include "mozilla/layers/SharedPlanarYCbCrImage.h"
-#include "mozilla/layers/YCbCrImageDataSerializer.h"
-#include "nsDebug.h"                    // for NS_ASSERTION, NS_WARNING, etc
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "gfx2DGlue.h"
+
+#include <stdint.h>
 
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
+
+
+
+
 TextureClient::TextureClient(TextureFlags aFlags)
   : mID(0)
   , mFlags(aFlags)
 {}
 
 TextureClient::~TextureClient()
 {}
 
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -1,44 +1,35 @@
 /* -*- 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_TEXTURECLIENT_H
 #define MOZILLA_GFX_TEXTURECLIENT_H
 
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint32_t, uint8_t, uint64_t
-#include "GLContext.h"                  // for GLContext (ptr only), etc
-#include "GLTextureImage.h"             // for TextureImage
-#include "ImageContainer.h"             // for PlanarYCbCrImage, etc
-#include "ImageTypes.h"                 // for StereoMode
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#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/ipc/Shmem.h"          // for Shmem
-#include "mozilla/layers/CompositorTypes.h"  // for TextureFlags, etc
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsISupportsImpl.h"            // for TextureImage::AddRef, etc
+#include "mozilla/layers/LayersSurfaces.h"
+#include "gfxASurface.h"
+#include "mozilla/layers/CompositorTypes.h" // for TextureInfo
+#include "mozilla/RefPtr.h"
+#include "ImageContainer.h" // for PlanarYCbCrImage::Data
 
 class gfxReusableSurfaceWrapper;
 
 namespace mozilla {
+
+namespace gl {
+class GLContext;
+}
+
 namespace layers {
 
 class ContentClient;
+class PlanarYCbCrImage;
+class Image;
 class CompositableForwarder;
 class ISurfaceAllocator;
 class CompositableClient;
 
 /**
  * TextureClient is the abstraction that allows us to share data between the
  * content and the compositor side.
  * TextureClient can also provide with some more more "producer" facing APIs
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -1,29 +1,17 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/TiledContentClient.h"
-#include <math.h>                       // for ceil, ceilf, floor
-#include "ClientTiledThebesLayer.h"     // for ClientTiledThebesLayer
-#include "GeckoProfilerImpl.h"          // for PROFILER_LABEL
-#include "ClientLayerManager.h"         // for ClientLayerManager
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxRect.h"                    // for gfxRect
-#include "mozilla/MathAlgorithms.h"     // for Abs
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/layers/CompositableForwarder.h"
-#include "mozilla/layers/ShadowLayers.h"  // for ShadowLayerForwarder
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsImpl.h"            // for gfxContext::AddRef, etc
-#include "nsSize.h"                     // for nsIntSize
+#include "mozilla/gfx/2D.h"
+#include "mozilla/MathAlgorithms.h"
+#include "ClientTiledThebesLayer.h"
 
 #ifdef GFX_TILEDLAYER_DEBUG_OVERLAY
 #include "cairo.h"
 #include <sstream>
 using mozilla::layers::Layer;
 static void DrawDebugOverlay(gfxASurface* imgSurf, int x, int y)
 {
   gfxContext c(imgSurf);
--- a/gfx/layers/client/TiledContentClient.h
+++ b/gfx/layers/client/TiledContentClient.h
@@ -1,39 +1,19 @@
 /* -*- 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_TILEDCONTENTCLIENT_H
 #define MOZILLA_GFX_TILEDCONTENTCLIENT_H
 
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint16_t
-#include <algorithm>                    // for swap
-#include "Layers.h"                     // for LayerManager, etc
-#include "TiledLayerBuffer.h"           // for TiledLayerBuffer
-#include "Units.h"                      // for CSSPoint
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPoint.h"                   // for gfxSize
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/layers/CompositableClient.h"  // for CompositableClient
-#include "mozilla/layers/CompositorTypes.h"  // for TextureInfo, etc
-#include "mozilla/layers/TextureClient.h"
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTArray.h"                   // for nsTArray, nsTArray_Impl, etc
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_DTOR
-#include "gfxReusableSurfaceWrapper.h"
+#include "mozilla/layers/ContentClient.h"
+#include "TiledLayerBuffer.h"
+#include "gfxPlatform.h"
 
 namespace mozilla {
 namespace layers {
 
 /**
  * Represent a single tile in tiled buffer. The buffer keeps tiles,
  * each tile keeps a reference to a texture client. The texture client
  * is backed by a gfxReusableSurfaceWrapper that implements a
--- a/gfx/layers/composite/APZCTreeManager.cpp
+++ b/gfx/layers/composite/APZCTreeManager.cpp
@@ -1,46 +1,31 @@
 /* -*- Mode: C++; tab-width: 8; 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 "APZCTreeManager.h"
 #include "AsyncCompositionManager.h"    // for ViewTransform
-#include "Compositor.h"                 // for Compositor
-#include "CompositorParent.h"           // for CompositorParent, etc
-#include "InputData.h"                  // for InputData, etc
-#include "Layers.h"                     // for ContainerLayer, Layer, etc
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "mozilla/dom/Touch.h"          // for Touch
-#include "mozilla/gfx/Point.h"          // for Point
-#include "mozilla/layers/AsyncPanZoomController.h"
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsGUIEvent.h"                 // for nsMouseEvent, nsTouchEvent, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsTArray.h"                   // for nsTArray, nsTArray_Impl, etc
-#include "nsThreadUtils.h"              // for NS_IsMainThread
+#include "LayerManagerComposite.h"      // for AsyncCompositionManager.h
+#include "Compositor.h"
 
 #define APZC_LOG(...)
 // #define APZC_LOG(args...) printf_stderr(args)
 
 namespace mozilla {
 namespace layers {
 
 APZCTreeManager::APZCTreeManager()
     : mTreeLock("APZCTreeLock")
 {
   MOZ_ASSERT(NS_IsMainThread());
   AsyncPanZoomController::InitializeGlobalState();
 }
 
-APZCTreeManager::~APZCTreeManager()
-{
-}
-
 void
 APZCTreeManager::AssertOnCompositorThread()
 {
   Compositor::AssertOnCompositorThread();
 }
 
 /* Flatten the tree of APZC instances into the given nsTArray */
 static void
--- a/gfx/layers/composite/APZCTreeManager.h
+++ b/gfx/layers/composite/APZCTreeManager.h
@@ -1,38 +1,23 @@
 /* -*- Mode: C++; tab-width: 8; 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_layers_APZCTreeManager_h
 #define mozilla_layers_APZCTreeManager_h
 
-#include <stdint.h>                     // for uint64_t, uint32_t
-#include "FrameMetrics.h"               // for FrameMetrics, etc
-#include "Units.h"                      // for CSSPoint, CSSRect, etc
-#include "gfxPoint.h"                   // for gfxPoint
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
-#include "mozilla/Monitor.h"            // for Monitor
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsEvent.h"                    // for nsEventStatus
-#include "nsISupportsImpl.h"
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-
-class gfx3DMatrix;
-class nsInputEvent;
-template <class E> class nsTArray;
+#include "mozilla/layers/AsyncPanZoomController.h"
+#include "Layers.h"
+#include "CompositorParent.h"
 
 namespace mozilla {
-class InputData;
-
 namespace layers {
 
-class Layer;
 class AsyncPanZoomController;
 class CompositorParent;
 
 /**
  * This class allows us to uniquely identify a scrollable layer. The
  * mLayersId identifies the layer tree (corresponding to a child process
  * and/or tab) that the scrollable layer belongs to. The mPresShellId
  * is a temporal identifier (corresponding to the document loaded that
@@ -111,17 +96,17 @@ struct ScrollableLayerGuid {
  * Note that the ClearTree function MUST be called when this class is no longer needed;
  * see the method documentation for details.
  */
 class APZCTreeManager {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(APZCTreeManager)
 
 public:
   APZCTreeManager();
-  virtual ~APZCTreeManager();
+  virtual ~APZCTreeManager() {}
 
   /**
    * Rebuild the APZC tree based on the layer update that just came up. Preserve
    * APZC instances where possible, but retire those whose layers are no longer
    * in the layer tree.
    *
    * This must be called on the compositor thread as it walks the layer tree.
    *
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -1,50 +1,30 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set sw=2 ts=2 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/AsyncCompositionManager.h"
-#include <stdint.h>                     // for uint32_t
-#include "AnimationCommon.h"            // for ComputedTimingFunction
-#include "CompositorParent.h"           // for CompositorParent, etc
-#include "FrameMetrics.h"               // for FrameMetrics
-#include "LayerManagerComposite.h"      // for LayerManagerComposite, etc
-#include "Layers.h"                     // for Layer, ContainerLayer, etc
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPoint.h"                   // for gfxPoint, gfxSize
-#include "gfxPoint3D.h"                 // for gfxPoint3D
-#include "mozilla/WidgetUtils.h"        // for ComputeTransformForRotation
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "mozilla/gfx/Point.h"          // for RoundedToInt, PointTyped
-#include "mozilla/gfx/Rect.h"           // for RoundedToInt, RectTyped
-#include "mozilla/gfx/ScaleFactor.h"    // for ScaleFactor
-#include "mozilla/layers/AsyncPanZoomController.h"
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "nsAnimationManager.h"         // for ElementAnimations
-#include "nsCSSPropList.h"
-#include "nsCoord.h"                    // for NSAppUnitsToFloatPixels, etc
-#include "nsDebug.h"                    // for NS_ASSERTION, etc
-#include "nsDeviceContext.h"            // for nsDeviceContext
-#include "nsDisplayList.h"              // for nsDisplayTransform, etc
-#include "nsMathUtils.h"                // for NS_round
-#include "nsPoint.h"                    // for nsPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsStyleAnimation.h"           // for nsStyleAnimation::Value, etc
-#include "nsTArray.h"                   // for nsTArray, nsTArray_Impl, etc
-#include "nsTArrayForwardDeclare.h"     // for InfallibleTArray
+#include "base/basictypes.h"
+
 #if defined(MOZ_WIDGET_ANDROID)
 # include <android/log.h>
 # include "AndroidBridge.h"
 #endif
 
-struct nsCSSValueList;
+#include "CompositorParent.h"
+#include "LayerManagerComposite.h" 
+
+#include "nsStyleAnimation.h"
+#include "nsDisplayList.h"
+#include "AnimationCommon.h"
+#include "nsAnimationManager.h"
+#include "mozilla/layers/AsyncPanZoomController.h"
 
 using namespace mozilla::dom;
 
 namespace mozilla {
 namespace layers {
 
 enum Op { Resolve, Detach };
 
--- a/gfx/layers/composite/AsyncCompositionManager.h
+++ b/gfx/layers/composite/AsyncCompositionManager.h
@@ -1,34 +1,33 @@
 /* -*- 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_ASYNCCOMPOSITIONMANAGER_H
 #define GFX_ASYNCCOMPOSITIONMANAGER_H
 
-#include "GeckoProfilerFunc.h"          // for TimeStamp
-#include "Units.h"                      // for LayerPoint, etc
-#include "mozilla/layers/LayerManagerComposite.h"  // for LayerManagerComposite
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "mozilla/Attributes.h"         // for MOZ_DELETE, MOZ_FINAL, etc
-#include "mozilla/RefPtr.h"             // for RefCounted
-#include "mozilla/TimeStamp.h"          // for TimeStamp
-#include "mozilla/dom/ScreenOrientation.h"  // for ScreenOrientation
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/layers/LayerTransaction.h"  // for TargetConfig
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsISupportsImpl.h"            // for LayerManager::AddRef, etc
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "gfxPoint.h"
+#include "gfx3DMatrix.h"
+#include "nsAutoPtr.h"
+#include "nsRect.h"
+#include "mozilla/dom/ScreenOrientation.h"
+#include "mozilla/gfx/Rect.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/TimeStamp.h"
+#include "mozilla/layers/LayerTransaction.h" // for TargetConfig
 
 namespace mozilla {
 namespace layers {
 
+class AsyncPanZoomController;
 class Layer;
+class LayerManagerComposite;
 class AutoResolveRefLayers;
 
 // Represents (affine) transforms that are calculated from a content view.
 struct ViewTransform {
   ViewTransform(LayoutDevicePoint aTranslation = LayoutDevicePoint(),
                 LayoutDeviceToScreenScale aScale = LayoutDeviceToScreenScale())
     : mTranslation(aTranslation)
     , mScale(aScale)
--- a/gfx/layers/composite/CanvasLayerComposite.cpp
+++ b/gfx/layers/composite/CanvasLayerComposite.cpp
@@ -1,30 +1,23 @@
 /* -*- 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 "ipc/AutoOpenSurface.h"
+#include "mozilla/layers/PLayerTransaction.h"
+#include "mozilla/layers/ShadowLayers.h"
+#include "mozilla/layers/CompositorTypes.h" // for TextureInfo
+#include "mozilla/layers/Effects.h"
+
 #include "CanvasLayerComposite.h"
-#include "composite/CompositableHost.h"  // for CompositableHost
-#include "gfx2DGlue.h"                  // for ToFilter, ToMatrix4x4
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPattern.h"                 // for gfxPattern, etc
-#include "gfxUtils.h"                   // for gfxUtils, etc
-#include "mozilla/gfx/Matrix.h"         // for Matrix4x4
-#include "mozilla/gfx/Point.h"          // for Point
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/Effects.h"     // for EffectChain
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsAString.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsString.h"                   // for nsAutoCString
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "ImageHost.h"
+#include "gfxUtils.h"
+#include "gfx2DGlue.h"
 
 using namespace mozilla;
 using namespace mozilla::layers;
 
 CanvasLayerComposite::CanvasLayerComposite(LayerManagerComposite* aManager)
   : CanvasLayer(aManager, nullptr)
   , LayerComposite(aManager)
   , mImageHost(nullptr)
--- a/gfx/layers/composite/CanvasLayerComposite.h
+++ b/gfx/layers/composite/CanvasLayerComposite.h
@@ -1,30 +1,26 @@
 /* -*- 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_CanvasLayerComposite_H
 #define GFX_CanvasLayerComposite_H
 
-#include "Layers.h"                     // for CanvasLayer, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/layers/LayerManagerComposite.h"  // for LayerComposite, etc
-#include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT
-#include "nsRect.h"                     // for nsIntRect
-#include "nscore.h"                     // for nsACString
-struct nsIntPoint;
+
+#include "mozilla/layers/LayerManagerComposite.h"
+#include "gfxASurface.h"
+#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
+#include "mozilla/X11Util.h"
+#endif
 
 namespace mozilla {
 namespace layers {
 
-class CompositableHost;
 // Canvas layers use ImageHosts (but CanvasClients) because compositing a
 // canvas is identical to compositing an image.
 class ImageHost;
 
 class CanvasLayerComposite : public CanvasLayer,
                              public LayerComposite
 {
 public:
--- a/gfx/layers/composite/ColorLayerComposite.cpp
+++ b/gfx/layers/composite/ColorLayerComposite.cpp
@@ -1,27 +1,16 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ColorLayerComposite.h"
-#include "gfx2DGlue.h"                  // for ToMatrix4x4
-#include "gfxColor.h"                   // for gfxRGBA
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/gfx/Matrix.h"         // for Matrix4x4
-#include "mozilla/gfx/Point.h"          // for Point
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/gfx/Types.h"          // for Color
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/CompositorTypes.h"  // for DIAGNOSTIC_COLOR
-#include "mozilla/layers/Effects.h"     // for Effect, EffectChain, etc
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
+#include "mozilla/layers/Effects.h"
+#include "gfx2DGlue.h"
 
 namespace mozilla {
 namespace layers {
 
 void
 ColorLayerComposite::RenderLayer(const nsIntPoint& aOffset,
                                  const nsIntRect& aClipRect)
 {
--- a/gfx/layers/composite/ColorLayerComposite.h
+++ b/gfx/layers/composite/ColorLayerComposite.h
@@ -1,29 +1,24 @@
 /* -*- 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_ColorLayerComposite_H
 #define GFX_ColorLayerComposite_H
 
-#include "Layers.h"                     // for ColorLayer, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/layers/LayerManagerComposite.h"  // for LayerComposite, etc
-#include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_HAVE_LOG
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "mozilla/layers/PLayerTransaction.h"
+#include "mozilla/layers/ShadowLayers.h"
 
-struct nsIntPoint;
-struct nsIntRect;
+#include "mozilla/layers/LayerManagerComposite.h"
 
 namespace mozilla {
 namespace layers {
 
-class CompositableHost;
 
 class ColorLayerComposite : public ColorLayer,
                             public LayerComposite
 {
 public:
   ColorLayerComposite(LayerManagerComposite *aManager)
     : ColorLayer(aManager, nullptr)
     , LayerComposite(aManager)
--- a/gfx/layers/composite/CompositableHost.cpp
+++ b/gfx/layers/composite/CompositableHost.cpp
@@ -1,33 +1,24 @@
 /* -*- 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 "CompositableHost.h"
-#include <map>                          // for _Rb_tree_iterator, map, etc
-#include <utility>                      // for pair
-#include "ContentHost.h"                // for ContentHostDoubleBuffered, etc
-#include "Effects.h"                    // for EffectMask, Effect, etc
-#include "ImageHost.h"                  // for DeprecatedImageHostBuffered, etc
-#include "TiledContentHost.h"           // for TiledContentHost
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
-#include "mozilla/layers/TextureHost.h"  // for TextureHost, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsDebug.h"                    // for NS_WARNING
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "ImageHost.h"
+#include "ContentHost.h"
+#include "TiledContentHost.h"
+#include "Effects.h"
+#include "mozilla/layers/CompositableTransactionParent.h"
+#include "mozilla/layers/TextureHost.h"
 
 namespace mozilla {
 namespace layers {
 
-class Matrix4x4;
-class Compositor;
-
 CompositableHost::CompositableHost(const TextureInfo& aTextureInfo)
   : mTextureInfo(aTextureInfo)
   , mCompositor(nullptr)
   , mLayer(nullptr)
   , mAttached(false)
 {
   MOZ_COUNT_CTOR(CompositableHost);
 }
--- a/gfx/layers/composite/CompositableHost.h
+++ b/gfx/layers/composite/CompositableHost.h
@@ -1,45 +1,24 @@
 /* -*- 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_BUFFERHOST_H
 #define MOZILLA_GFX_BUFFERHOST_H
 
-#include <stdint.h>                     // for uint64_t
-#include <stdio.h>                      // for FILE
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "gfxPoint.h"                   // for gfxSize
-#include "gfxRect.h"                    // for gfxRect
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr, RefCounted, etc
-#include "mozilla/gfx/Point.h"          // for Point
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/gfx/Types.h"          // for Filter
-#include "mozilla/ipc/ProtocolUtils.h"
-#include "mozilla/layers/CompositorTypes.h"  // for TextureInfo, etc
-#include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
+#include "mozilla/layers/Compositor.h"
 #include "mozilla/layers/PCompositableParent.h"
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nscore.h"                     // for nsACString
-
-class gfxImageSurface;
-struct nsIntPoint;
-struct nsIntRect;
+#include "mozilla/layers/ISurfaceAllocator.h"
+#include "ThebesLayerBuffer.h"
+#include "ClientTiledThebesLayer.h" // for BasicTiledLayerBuffer
+#include "mozilla/RefPtr.h"
 
 namespace mozilla {
-namespace gfx {
-class Matrix4x4;
-}
-
 namespace layers {
 
 // Some properties of a Layer required for tiling
 struct TiledLayerProperties
 {
   nsIntRegion mVisibleRegion;
   nsIntRegion mValidRegion;
   gfxRect mDisplayPort;
@@ -47,21 +26,16 @@ struct TiledLayerProperties
   gfxRect mCompositionBounds;
   bool mRetainTiles;
 };
 
 class Layer;
 class DeprecatedTextureHost;
 class TextureHost;
 class SurfaceDescriptor;
-class Compositor;
-class ISurfaceAllocator;
-class ThebesBufferData;
-class TiledLayerComposer;
-struct EffectChain;
 
 /**
  * The compositor-side counterpart to CompositableClient. Responsible for
  * updating textures and data about textures from IPC and how textures are
  * composited (tiling, double buffering, etc.).
  *
  * Update (for images/canvases) and UpdateThebes (for Thebes) are called during
  * the layers transaction to update the Compositbale's textures from the
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -1,43 +1,18 @@
 /* -*- 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 "ContainerLayerComposite.h"
-#include <algorithm>                    // for min
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "FrameMetrics.h"               // for FrameMetrics
-#include "Units.h"                      // for LayerRect, LayerPixel, etc
-#include "gfx2DGlue.h"                  // for ToMatrix4x4
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxUtils.h"                   // for gfxUtils, etc
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "mozilla/gfx/Matrix.h"         // for Matrix4x4
-#include "mozilla/gfx/Point.h"          // for Point, IntPoint
-#include "mozilla/gfx/Rect.h"           // for IntRect, Rect
-#include "mozilla/layers/Compositor.h"  // for Compositor, etc
-#include "mozilla/layers/CompositorTypes.h"  // for DIAGNOSTIC_CONTAINER
-#include "mozilla/layers/Effects.h"     // for Effect, EffectChain, etc
-#include "mozilla/layers/TextureHost.h"  // for CompositingRenderTarget
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsUtils.h"           // for NS_ADDREF, NS_RELEASE
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTArray.h"                   // for nsAutoTArray
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "gfxUtils.h"
+#include "mozilla/layers/Compositor.h"
+#include "mozilla/layers/LayersTypes.h"
+#include "gfx2DGlue.h"
 
 namespace mozilla {
 namespace layers {
 
 // HasOpaqueAncestorLayer and ContainerRender are shared between RefLayer and ContainerLayer
 static bool
 HasOpaqueAncestorLayer(Layer* aLayer)
 {
--- a/gfx/layers/composite/ContainerLayerComposite.h
+++ b/gfx/layers/composite/ContainerLayerComposite.h
@@ -1,30 +1,29 @@
 /* -*- 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_ContainerLayerComposite_H
 #define GFX_ContainerLayerComposite_H
 
-#include "Layers.h"                     // for Layer (ptr only), etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
+#include "mozilla/layers/PLayerTransaction.h"
+#include "mozilla/layers/ShadowLayers.h"
+
+#include "Layers.h"
 #include "mozilla/layers/LayerManagerComposite.h"
-#include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_HAVE_LOG
+#include "mozilla/layers/Effects.h"
 
-class gfx3DMatrix;
-struct nsIntPoint;
-struct nsIntRect;
+#include "gfxUtils.h"
+#include "gfx2DGlue.h"
 
 namespace mozilla {
 namespace layers {
 
-class CompositableHost;
-
 class ContainerLayerComposite : public ContainerLayer,
                                 public LayerComposite
 {
   template<class ContainerT>
   friend void ContainerRender(ContainerT* aContainer,
                               const nsIntPoint& aOffset,
                               LayerManagerComposite* aManager,
                               const nsIntRect& aClipRect);
--- a/gfx/layers/composite/ContentHost.cpp
+++ b/gfx/layers/composite/ContentHost.cpp
@@ -1,34 +1,20 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/ContentHost.h"
-#include "LayersLogging.h"              // for AppendToString
-#include "gfx2DGlue.h"                  // for ContentForFormat
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/Effects.h"     // for TexturedEffect, Effect, etc
-#include "mozilla/layers/LayerTransaction.h"  // for ThebesBufferData
-#include "nsAString.h"
-#include "nsPrintfCString.h"            // for nsPrintfCString
-#include "nsString.h"                   // for nsAutoCString
-
-class gfxImageSurface;
+#include "mozilla/layers/Effects.h"
+#include "nsPrintfCString.h"
+#include "gfx2DGlue.h"
 
 namespace mozilla {
-namespace gfx {
-class Matrix4x4;
-}
 using namespace gfx;
-
 namespace layers {
 
 ContentHostBase::ContentHostBase(const TextureInfo& aTextureInfo)
   : ContentHost(aTextureInfo)
   , mPaintWillResample(false)
   , mInitialised(false)
 {}
 
--- a/gfx/layers/composite/ContentHost.h
+++ b/gfx/layers/composite/ContentHost.h
@@ -1,55 +1,24 @@
 /* -*- 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_CONTENTHOST_H
 #define GFX_CONTENTHOST_H
 
-#include <stdint.h>                     // for uint32_t
-#include <stdio.h>                      // for FILE
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "CompositableHost.h"           // for CompositableHost, etc
-#include "ThebesLayerBuffer.h"          // for ThebesLayerBuffer, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/gfx/Point.h"          // for Point
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/gfx/Types.h"          // for Filter
-#include "mozilla/layers/CompositorTypes.h"  // for TextureInfo, etc
-#include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
-#include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_HAVE_LOG, etc
-#include "mozilla/layers/TextureHost.h"  // for DeprecatedTextureHost
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsAutoPtr.h"                  // for nsAutoPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTArray.h"                   // for nsTArray
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-#include "nscore.h"                     // for nsACString
-
-class gfxImageSurface;
+#include "ThebesLayerBuffer.h"
+#include "CompositableHost.h"
 
 namespace mozilla {
-namespace gfx {
-class Matrix4x4;
-}
 namespace layers {
-class Compositor;
-class ThebesBufferData;
-class TiledLayerComposer;
-struct EffectChain;
 
+class ThebesBuffer;
+class OptionalThebesBuffer;
 struct TexturedEffect;
 
 /**
  * ContentHosts are used for compositing Thebes layers, always matched by a
  * ContentClient of the same type.
  *
  * ContentHosts support only UpdateThebes(), not Update().
  */
--- a/gfx/layers/composite/ImageHost.cpp
+++ b/gfx/layers/composite/ImageHost.cpp
@@ -1,38 +1,26 @@
 /* -*- 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 "ipc/AutoOpenSurface.h"
 #include "ImageHost.h"
-#include "LayersLogging.h"              // for AppendToString
-#include "composite/CompositableHost.h"  // for CompositableHost, etc
-#include "ipc/IPCMessageUtils.h"        // for null_t
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/Effects.h"     // for TexturedEffect, Effect, etc
-#include "nsAString.h"
-#include "nsDebug.h"                    // for NS_WARNING, NS_ASSERTION
-#include "nsPrintfCString.h"            // for nsPrintfCString
-#include "nsString.h"                   // for nsAutoCString
 
-class gfxImageSurface;
-class nsIntRegion;
+#include "mozilla/layers/Effects.h"
+#include "LayersLogging.h"
+#include "nsPrintfCString.h"
 
 namespace mozilla {
-namespace gfx {
-class Matrix4x4;
-}
 
 using namespace gfx;
 
 namespace layers {
 
-class ISurfaceAllocator;
-
 ImageHost::ImageHost(const TextureInfo& aTextureInfo)
   : CompositableHost(aTextureInfo)
   , mFrontBuffer(nullptr)
   , mHasPictureRect(false)
 {}
 
 ImageHost::~ImageHost() {}
 
--- a/gfx/layers/composite/ImageHost.h
+++ b/gfx/layers/composite/ImageHost.h
@@ -1,45 +1,23 @@
 /* -*- 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_IMAGEHOST_H
 #define MOZILLA_GFX_IMAGEHOST_H
 
-#include <stdio.h>                      // for FILE, NULL
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "CompositableHost.h"           // for CompositableHost
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/gfx/Point.h"          // for Point
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/gfx/Types.h"          // for Filter
-#include "mozilla/layers/CompositorTypes.h"  // for TextureInfo, etc
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
-#include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
-#include "mozilla/layers/TextureHost.h"  // for DeprecatedTextureHost, etc
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsRect.h"                     // for nsIntRect
-#include "nscore.h"                     // for nsACString
- 
-class gfxImageSurface;
-class nsIntRegion;
+#include "CompositableHost.h"
+#include "mozilla/layers/LayerManagerComposite.h"
 
 namespace mozilla {
-namespace gfx {
-class Matrix4x4;
-}
 namespace layers {
 
-class Compositor;
-class ISurfaceAllocator;
-struct EffectChain;
+class TextureHost;
 
 /**
  * ImageHost. Works with ImageClientSingle and ImageClientBuffered
  */
 class ImageHost : public CompositableHost
 {
 public:
   ImageHost(const TextureInfo& aTextureInfo);
--- a/gfx/layers/composite/ImageLayerComposite.cpp
+++ b/gfx/layers/composite/ImageLayerComposite.cpp
@@ -1,38 +1,26 @@
 /* -*- 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 "gfxSharedImageSurface.h"
+
+#include "ipc/AutoOpenSurface.h"
 #include "ImageLayerComposite.h"
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "CompositableHost.h"           // for CompositableHost
-#include "Layers.h"                     // for WriteSnapshotToDumpFile, etc
-#include "gfx2DGlue.h"                  // for ToFilter, ToMatrix4x4
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "gfxRect.h"                    // for gfxRect
-#include "gfxUtils.h"                   // for gfxUtils, etc
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/gfx/Matrix.h"         // for Matrix4x4
-#include "mozilla/gfx/Point.h"          // for IntSize, Point
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/Effects.h"     // for EffectChain
-#include "mozilla/layers/TextureHost.h"  // for DeprecatedTextureHost, etc
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsAString.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsString.h"                   // for nsAutoCString
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "ImageHost.h"
+#include "gfxImageSurface.h"
+#include "gfx2DGlue.h"
+#include "gfxUtils.h"
+
+#include "mozilla/layers/Compositor.h"
+#include "mozilla/layers/CompositorTypes.h" // for TextureInfo
+#include "mozilla/layers/Effects.h"
+#include "CompositableHost.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 ImageLayerComposite::ImageLayerComposite(LayerManagerComposite* aManager)
   : ImageLayer(aManager, nullptr)
--- a/gfx/layers/composite/ImageLayerComposite.h
+++ b/gfx/layers/composite/ImageLayerComposite.h
@@ -1,35 +1,27 @@
 /* -*- 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_ImageLayerComposite_H
 #define GFX_ImageLayerComposite_H
 
-#include "GLTextureImage.h"             // for TextureImage
-#include "ImageLayers.h"                // for ImageLayer
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/layers/LayerManagerComposite.h"  // for LayerComposite, etc
-#include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
-#include "nsISupportsImpl.h"            // for TextureImage::AddRef, etc
-#include "nscore.h"                     // for nsACString
+#include "mozilla/layers/PLayerTransaction.h"
+#include "mozilla/layers/ShadowLayers.h"
 
-class gfx3DMatrix;
-struct nsIntPoint;
-struct nsIntRect;
+#include "mozilla/layers/LayerManagerComposite.h"
+#include "ImageLayers.h"
+#include "mozilla/Mutex.h"
 
 namespace mozilla {
 namespace layers {
 
-class CompositableHost;
 class ImageHost;
-class Layer;
 
 class ImageLayerComposite : public ImageLayer,
                             public LayerComposite
 {
   typedef gl::TextureImage TextureImage;
 
 public:
   ImageLayerComposite(LayerManagerComposite* aManager);
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -1,72 +1,57 @@
 /* -*- 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 "LayerManagerComposite.h"
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint16_t, uint32_t
-#include "CanvasLayerComposite.h"       // for CanvasLayerComposite
-#include "ColorLayerComposite.h"        // for ColorLayerComposite
-#include "Composer2D.h"                 // for Composer2D
-#include "CompositableHost.h"           // for CompositableHost
-#include "ContainerLayerComposite.h"    // for ContainerLayerComposite, etc
-#include "FrameMetrics.h"               // for FrameMetrics
-#include "GeckoProfilerImpl.h"          // for profiler_set_frame_number, etc
-#include "ImageLayerComposite.h"        // for ImageLayerComposite
-#include "Layers.h"                     // for Layer, ContainerLayer, etc
-#include "ThebesLayerComposite.h"       // for ThebesLayerComposite
-#include "TiledLayerBuffer.h"           // for TiledLayerComposer
-#include "Units.h"                      // for ScreenIntRect
-#include "gfx2DGlue.h"                  // for ToMatrix4x4
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPlatform.h"                // for gfxPlatform
+#include "mozilla/layers/PLayerTransaction.h"
+
+// This must occur *after* layers/PLayerTransaction.h to avoid
+// typedefs conflicts.
+#include "mozilla/Util.h"
+
+#include "mozilla/layers/LayerManagerComposite.h"
+#include "ThebesLayerComposite.h"
+#include "ContainerLayerComposite.h"
+#include "ImageLayerComposite.h"
+#include "ColorLayerComposite.h"
+#include "CanvasLayerComposite.h"
+#include "CompositableHost.h"
+#include "mozilla/gfx/Matrix.h"
+#include "mozilla/TimeStamp.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/layers/ImageHost.h"
+#include "mozilla/layers/ContentHost.h"
+#include "mozilla/layers/Compositor.h"
+
+#include "gfxContext.h"
+#include "gfxUtils.h"
+#include "gfx2DGlue.h"
 #ifdef XP_MACOSX
 #include "gfxPlatformMac.h"
+#else
+#include "gfxPlatform.h"
 #endif
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "gfxRect.h"                    // for gfxRect
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef
-#include "mozilla/gfx/2D.h"             // for DrawTarget
-#include "mozilla/gfx/Matrix.h"         // for Matrix4x4
-#include "mozilla/gfx/Point.h"          // for IntSize, Point
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/gfx/Types.h"          // for Color, SurfaceFormat
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/Effects.h"     // for Effect, EffectChain, etc
-#include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_HAVE_LOG, etc
-#include "ipc/ShadowLayerUtils.h"
-#include "mozilla/mozalloc.h"           // for operator new, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_WARNING, NS_RUNTIMEABORT, etc
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-#include "nsIWidget.h"                  // for nsIWidget
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion, etc
+
+#include "nsIWidget.h"
+#include "nsIServiceManager.h"
+#include "nsIConsoleService.h"
+
+#include "gfxCrashReporterUtils.h"
+
+#include "GeckoProfiler.h"
+
 #ifdef MOZ_WIDGET_ANDROID
 #include <android/log.h>
 #endif
 
-class gfxASurface;
-class gfxContext;
-struct nsIntSize;
-
-
 namespace mozilla {
 namespace layers {
 
-class ImageLayer;
-
 using namespace mozilla::gfx;
 using namespace mozilla::gl;
 
 static LayerComposite*
 ToLayerComposite(Layer* aLayer)
 {
   return static_cast<LayerComposite*>(aLayer->ImplData());
 }
--- a/gfx/layers/composite/LayerManagerComposite.h
+++ b/gfx/layers/composite/LayerManagerComposite.h
@@ -1,73 +1,49 @@
 /* -*- 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_LayerManagerComposite_H
 #define GFX_LayerManagerComposite_H
 
-#include <stdint.h>                     // for int32_t, uint32_t
-#include "GLDefs.h"                     // for GLenum
+#include "mozilla/layers/Compositor.h"
+#include "mozilla/layers/ShadowLayers.h"
+#include "Composer2D.h"
+#include "mozilla/TimeStamp.h"
 #include "Layers.h"
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/LayersTypes.h"  // for LayersBackend, etc
-#include "nsAString.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nscore.h"                     // for nsAString, etc
-
-class gfxASurface;
-class gfxContext;
-struct nsIntPoint;
-struct nsIntSize;
 
 #ifdef XP_WIN
 #include <windows.h>
 #endif
 
+#include "gfxContext.h"
+#include "gfx3DMatrix.h"
+#include "GLDefs.h"
+
 namespace mozilla {
-namespace gfx {
-class DrawTarget;
-}
-
 namespace gl {
 class GLContext;
 class TextureImage;
 }
+}
 
+namespace mozilla {
 namespace layers {
 
+class LayerComposite;
+class ThebesLayerComposite;
+class ContainerLayerComposite;
+class ImageLayerComposite;
 class CanvasLayerComposite;
 class ColorLayerComposite;
-class Composer2D;
+class RefLayerComposite;
 class CompositableHost;
-class Compositor;
-class ContainerLayerComposite;
 class EffectChain;
-class ImageLayer;
-class ImageLayerComposite;
-class LayerComposite;
-class RefLayerComposite;
-class SurfaceDescriptor;
-class ThebesLayerComposite;
 class TiledLayerComposer;
 
 class LayerManagerComposite : public LayerManager
 {
 public:
   LayerManagerComposite(Compositor* aCompositor);
   ~LayerManagerComposite();
   
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -1,29 +1,24 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/TextureHost.h"
-#include "LayersLogging.h"              // for AppendToString
-#include "gfx2DGlue.h"                  // for ToIntSize
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "mozilla/gfx/2D.h"             // for DataSourceSurface, Factory
-#include "mozilla/ipc/Shmem.h"          // for Shmem
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator
+#include "mozilla/layers/LayersSurfaces.h"
+#include "LayersLogging.h"
+#include "nsPrintfCString.h"
+#include "mozilla/ipc/Shmem.h"
+#include "ipc/AutoOpenSurface.h"
 #include "mozilla/layers/ImageDataSerializer.h"
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
 #include "mozilla/layers/YCbCrImageDataSerializer.h"
-#include "nsAString.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsPrintfCString.h"            // for nsPrintfCString
+#include "gfx2DGlue.h"
+#include "mozilla/gfx/2D.h"
 
-struct nsIntPoint;
 
 namespace mozilla {
 namespace layers {
 
 // implemented in TextureOGL.cpp
 TemporaryRef<DeprecatedTextureHost> CreateDeprecatedTextureHostOGL(SurfaceDescriptorType aDescriptorType,
                                                            uint32_t aDeprecatedTextureHostFlags,
                                                            uint32_t aTextureFlags);
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -1,47 +1,35 @@
 /* -*- 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_TEXTUREHOST_H
 #define MOZILLA_GFX_TEXTUREHOST_H
 
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint64_t, uint32_t, uint8_t
-#include "./../mozilla-config.h"        // for MOZ_DUMP_PAINTING
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef, 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/CompositorTypes.h"  // for TextureFlags, etc
-#include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-#include "nscore.h"                     // for nsACString
+#include "mozilla/layers/LayersTypes.h"
+#include "nsRect.h"
+#include "nsRegion.h"
+#include "mozilla/gfx/Rect.h"
+#include "mozilla/layers/CompositorTypes.h"
+#include "nsAutoPtr.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/layers/ISurfaceAllocator.h"
 
+class gfxReusableSurfaceWrapper;
 class gfxImageSurface;
-class gfxReusableSurfaceWrapper;
-struct nsIntPoint;
-struct nsIntSize;
-
 
 namespace mozilla {
-namespace ipc {
-class Shmem;
+namespace gfx {
+class DataSourceSurface;
+}
 }
 
+namespace mozilla {
 namespace layers {
 
 class Compositor;
 class SurfaceDescriptor;
 class ISurfaceAllocator;
 class TextureSourceOGL;
 class TextureSourceD3D9;
 class TextureSourceD3D11;
--- a/gfx/layers/composite/ThebesLayerComposite.cpp
+++ b/gfx/layers/composite/ThebesLayerComposite.cpp
@@ -1,45 +1,35 @@
 /* -*- 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 "ipc/AutoOpenSurface.h"
+#include "mozilla/layers/PLayerTransaction.h"
+#include "TiledLayerBuffer.h"
+
+// This must occur *after* layers/PLayerTransaction.h to avoid
+// typedefs conflicts.
+#include "mozilla/Util.h"
+
+#include "mozilla/layers/ShadowLayers.h"
+
+#include "ThebesLayerBuffer.h"
 #include "ThebesLayerComposite.h"
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "CompositableHost.h"           // for TiledLayerProperties, etc
-#include "FrameMetrics.h"               // for FrameMetrics
-#include "Units.h"                      // for CSSRect, LayerPixel, etc
-#include "gfx2DGlue.h"                  // for ToMatrix4x4
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxUtils.h"                   // for gfxUtils, etc
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/gfx/Matrix.h"         // for Matrix4x4
-#include "mozilla/gfx/Point.h"          // for Point
-#include "mozilla/gfx/Rect.h"           // for RoundedToInt, Rect
-#include "mozilla/gfx/Types.h"          // for Filter::FILTER_LINEAR
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/ContentHost.h"  // for ContentHost
-#include "mozilla/layers/Effects.h"     // for EffectChain
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsAString.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsMathUtils.h"                // for NS_lround
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
-#include "nsString.h"                   // for nsAutoCString
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "mozilla/layers/ContentHost.h"
+#include "gfxUtils.h"
+#include "gfx2DGlue.h"
+
+#include "mozilla/layers/CompositorTypes.h" // for TextureInfo
+#include "mozilla/layers/Effects.h"
 
 namespace mozilla {
 namespace layers {
 
-class TiledLayerComposer;
-
 ThebesLayerComposite::ThebesLayerComposite(LayerManagerComposite *aManager)
   : ThebesLayer(aManager, nullptr)
   , LayerComposite(aManager)
   , mBuffer(nullptr)
   , mRequiresTiledProperties(false)
 {
   MOZ_COUNT_CTOR(ThebesLayerComposite);
   mImplData = static_cast<LayerComposite*>(this);
--- a/gfx/layers/composite/ThebesLayerComposite.h
+++ b/gfx/layers/composite/ThebesLayerComposite.h
@@ -1,43 +1,34 @@
 /* -*- 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_ThebesLayerComposite_H
 #define GFX_ThebesLayerComposite_H
 
-#include "Layers.h"                     // for Layer (ptr only), etc
-#include "gfxPoint.h"                   // for gfxSize
-#include "gfxRect.h"                    // for gfxRect
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/layers/LayerManagerComposite.h"  // for LayerComposite, etc
-#include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nscore.h"                     // for nsACString
+#include "mozilla/layers/PLayerTransaction.h"
+#include "mozilla/layers/ShadowLayers.h"
 
-struct nsIntPoint;
-struct nsIntRect;
+#include "Layers.h"
+#include "mozilla/layers/LayerManagerComposite.h"
+#include "base/task.h"
 
 
 namespace mozilla {
 namespace layers {
 
 /**
  * Thebes layers use ContentHosts for their compsositable host.
  * By using different ContentHosts, ThebesLayerComposite support tiled and
  * non-tiled Thebes layers and single or double buffering.
  */
 
-class CompositableHost;
 class ContentHost;
-class TiledLayerComposer;
 
 class ThebesLayerComposite : public ThebesLayer,
                              public LayerComposite
 {
 public:
   ThebesLayerComposite(LayerManagerComposite *aManager);
   virtual ~ThebesLayerComposite();
 
--- a/gfx/layers/composite/TiledContentHost.cpp
+++ b/gfx/layers/composite/TiledContentHost.cpp
@@ -1,34 +1,22 @@
 /* -*- 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 "TiledContentHost.h"
-#include "ThebesLayerComposite.h"       // for ThebesLayerComposite
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/gfx/Matrix.h"         // for Matrix4x4
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/Effects.h"     // for TexturedEffect, Effect, etc
-#include "nsAString.h"
-#include "nsDebug.h"                    // for NS_WARNING
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsPrintfCString.h"            // for nsPrintfCString
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
-
-class gfxReusableSurfaceWrapper;
+#include "mozilla/layers/Effects.h"
+#include "nsPrintfCString.h"
+#include "ThebesLayerComposite.h"
 
 namespace mozilla {
 using namespace gfx;
 namespace layers {
 
-class Layer;
-
 void
 TiledLayerBufferComposite::Upload(const BasicTiledLayerBuffer* aMainMemoryTiledBuffer,
                                   const nsIntRegion& aNewValidRegion,
                                   const nsIntRegion& aInvalidateRegion,
                                   const gfxSize& aResolution)
 {
 #ifdef GFX_TILEDLAYER_PREF_WARNINGS
   printf_stderr("Upload %i, %i, %i, %i\n", aInvalidateRegion.GetBounds().x, aInvalidateRegion.GetBounds().y, aInvalidateRegion.GetBounds().width, aInvalidateRegion.GetBounds().height);
--- a/gfx/layers/composite/TiledContentHost.h
+++ b/gfx/layers/composite/TiledContentHost.h
@@ -1,56 +1,26 @@
 /* -*- 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_TILEDCONTENTHOST_H
 #define GFX_TILEDCONTENTHOST_H
 
-#include <stdint.h>                     // for uint16_t
-#include <stdio.h>                      // for FILE
-#include <algorithm>                    // for swap
-#include "ContentHost.h"                // for ContentHost
-#include "TiledLayerBuffer.h"           // for TiledLayerBuffer, etc
-#include "CompositableHost.h"
-#include "gfxPoint.h"                   // for gfxSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/gfx/Point.h"          // for Point
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/gfx/Types.h"          // for Filter
-#include "mozilla/layers/CompositorTypes.h"  // for TextureInfo, etc
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
-#include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
-#include "mozilla/layers/TextureHost.h"  // for DeprecatedTextureHost
-#include "mozilla/layers/TiledContentClient.h"
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nscore.h"                     // for nsACString
-
-class gfxReusableSurfaceWrapper;
-struct nsIntPoint;
-struct nsIntRect;
-struct nsIntSize;
+#include "ContentHost.h"
+#include "ClientTiledThebesLayer.h" // for BasicTiledLayerBuffer
+#include "mozilla/layers/TextureHost.h"
 
 namespace mozilla {
-namespace gfx {
-class Matrix4x4;
-}
-
 namespace layers {
 
-class Compositor;
-class ISurfaceAllocator;
-class Layer;
-class ThebesBufferData;
-class TiledThebesLayerComposite;
-struct EffectChain;
+class ThebesBuffer;
+class OptionalThebesBuffer;
+struct TexturedEffect;
 
 class TiledTexture {
 public:
   // Constructs a placeholder TiledTexture. See the comments above
   // TiledLayerBuffer for more information on what this is used for;
   // essentially, this is a sentinel used to represent an invalid or blank
   // tile.
   TiledTexture()
@@ -131,16 +101,18 @@ protected:
   }
 
 private:
   Compositor* mCompositor;
   const BasicTiledLayerBuffer* mMainMemoryTiledBuffer;
   gfxSize mFrameResolution;
 };
 
+class TiledThebesLayerComposite;
+
 /**
  * ContentHost for tiled Thebes layers. Since tiled layers are special snow
  * flakes, we don't call UpdateThebes or AddTextureHost, etc. We do call Composite
  * in the usual way though.
  *
  * There is no corresponding content client - on the client side we use a
  * BasicTiledLayerBuffer owned by a BasicTiledThebesLayer. On the host side, we
  * just use a regular ThebesLayerComposite, but with a tiled content host.
--- a/gfx/layers/d3d10/ReadbackManagerD3D10.cpp
+++ b/gfx/layers/d3d10/ReadbackManagerD3D10.cpp
@@ -5,17 +5,16 @@
 
 #include "ReadbackManagerD3D10.h"
 #include "ReadbackProcessor.h"
 #include "ReadbackLayer.h"
 
 #include "nsIThread.h"
 #include "nsThreadUtils.h"
 #include "gfxImageSurface.h"
-#include "gfxContext.h"
 
 namespace mozilla {
 namespace layers {
 
 // Structure that contains the information required to execute a readback task,
 // the only member accessed off the main thread here is mReadbackTexture. Since
 // mLayer may be released only on the main thread this object should always be
 // destroyed on the main thread!
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -1,62 +1,31 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
-#include <math.h>                       // for fabsf, fabs, atan2
-#include <stdint.h>                     // for uint32_t, uint64_t
-#include <sys/types.h>                  // for int32_t
-#include <algorithm>                    // for max, min
-#include "AnimationCommon.h"            // for ComputedTimingFunction
-#include "AsyncPanZoomController.h"     // for AsyncPanZoomController, etc
-#include "CompositorParent.h"           // for CompositorParent
-#include "FrameMetrics.h"               // for FrameMetrics, etc
-#include "GeckoProfilerFunc.h"          // for TimeDuration, TimeStamp
-#include "GestureEventListener.h"       // for GestureEventListener
-#include "InputData.h"                  // for MultiTouchInput, etc
-#include "Units.h"                      // for CSSRect, CSSPoint, etc
-#include "base/message_loop.h"          // for MessageLoop
-#include "base/task.h"                  // for NewRunnableMethod, etc
-#include "base/tracked.h"               // for FROM_HERE
-#include "gfxTypes.h"                   // for gfxFloat
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/ClearOnShutdown.h"    // for ClearOnShutdown
-#include "mozilla/Preferences.h"        // for Preferences
-#include "mozilla/ReentrantMonitor.h"   // for ReentrantMonitorAutoEnter, etc
-#include "mozilla/StaticPtr.h"          // for StaticAutoPtr
-#include "mozilla/TimeStamp.h"          // for TimeDuration, TimeStamp
-#include "mozilla/dom/Touch.h"          // for Touch
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "mozilla/gfx/Point.h"          // for Point, RoundedToInt, etc
-#include "mozilla/gfx/Rect.h"           // for RoundedIn
-#include "mozilla/gfx/ScaleFactor.h"    // for ScaleFactor
-#include "mozilla/layers/APZCTreeManager.h"  // for ScrollableLayerGuid
-#include "mozilla/layers/AsyncCompositionManager.h"  // for ViewTransform
-#include "mozilla/layers/Axis.h"        // for AxisX, AxisY, Axis, etc
-#include "mozilla/layers/GeckoContentController.h"
-#include "mozilla/layers/TaskThrottler.h"  // for TaskThrottler
-#include "mozilla/mozalloc.h"           // for operator new, etc
-#include "nsAlgorithm.h"                // for clamped
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_WARNING
-#include "nsEvent.h"
-#include "nsGUIEvent.h"                 // for nsInputEvent, nsTouchEvent, etc
-#include "nsISupportsImpl.h"
-#include "nsMathUtils.h"                // for NS_hypot
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsStyleConsts.h"
-#include "nsStyleStruct.h"              // for nsTimingFunction
-#include "nsTArray.h"                   // for nsTArray, nsTArray_Impl, etc
-#include "nsThreadUtils.h"              // for NS_IsMainThread
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
+#include "CompositorParent.h"
+#include "mozilla/gfx/2D.h"
+#include "mozilla/ClearOnShutdown.h"
+#include "mozilla/Constants.h"
+#include "mozilla/Util.h"
+#include "mozilla/XPCOM.h"
+#include "mozilla/Monitor.h"
+#include "mozilla/StaticPtr.h"
+#include "AsyncPanZoomController.h"
+#include "GestureEventListener.h"
+#include "nsIThreadManager.h"
+#include "nsThreadUtils.h"
+#include "Layers.h"
+#include "AnimationCommon.h"
+#include <algorithm>
+#include "mozilla/layers/LayerManagerComposite.h"
 
 using namespace mozilla::css;
 
 namespace mozilla {
 namespace layers {
 
 /**
  * Constant describing the tolerance in distance we use, multiplied by the
--- a/gfx/layers/ipc/Axis.cpp
+++ b/gfx/layers/ipc/Axis.cpp
@@ -1,27 +1,19 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include "Axis.h"
-#include <math.h>                       // for fabsf, pow, powf
-#include <algorithm>                    // for max
-#include "AsyncPanZoomController.h"     // for AsyncPanZoomController
-#include "FrameMetrics.h"               // for FrameMetrics
-#include "GeckoProfilerFunc.h"          // for TimeDuration
-#include "mozilla/Attributes.h"         // for MOZ_FINAL
-#include "mozilla/Preferences.h"        // for Preferences
-#include "mozilla/gfx/Rect.h"           // for RoundedIn
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsMathUtils.h"                // for NS_lround
-#include "nsThreadUtils.h"              // for NS_DispatchToMainThread, etc
-#include "nscore.h"                     // for NS_IMETHOD
+#include "AsyncPanZoomController.h"
+#include "mozilla/Preferences.h"
+#include "nsThreadUtils.h"
+#include <algorithm>
 
 namespace mozilla {
 namespace layers {
 
 static const float EPSILON = 0.0001f;
 
 /**
  * Maximum acceleration that can happen between two frames. Velocity is
--- a/gfx/layers/ipc/Axis.h
+++ b/gfx/layers/ipc/Axis.h
@@ -2,20 +2,21 @@
 /* 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_Axis_h
 #define mozilla_layers_Axis_h
 
-#include <sys/types.h>                  // for int32_t
-#include "Units.h"                      // for CSSRect, CSSPoint
-#include "mozilla/TimeStamp.h"          // for TimeDuration
-#include "nsTArray.h"                   // for nsTArray
+#include "nsGUIEvent.h"
+#include "mozilla/TimeStamp.h"
+#include "mozilla/gfx/2D.h"
+#include "nsTArray.h"
+#include "Units.h"
 
 namespace mozilla {
 namespace layers {
 
 class AsyncPanZoomController;
 
 /**
  * Helper class to maintain each axis of movement (X,Y) for panning and zooming.
--- a/gfx/layers/ipc/CompositableForwarder.h
+++ b/gfx/layers/ipc/CompositableForwarder.h
@@ -2,26 +2,20 @@
 /* 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_LAYERS_COMPOSITABLEFORWARDER
 #define MOZILLA_LAYERS_COMPOSITABLEFORWARDER
 
-#include <stdint.h>                     // for int32_t, uint64_t
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator
-#include "mozilla/layers/LayersTypes.h"  // for LayersBackend
-#include "nsRegion.h"                   // for nsIntRegion
-
-struct nsIntPoint;
-struct nsIntRect;
+#include <stdint.h>
+#include "gfxASurface.h"
+#include "GLDefs.h"
+#include "mozilla/layers/ISurfaceAllocator.h"
 
 namespace mozilla {
 namespace layers {
 
 class CompositableClient;
 class TextureFactoryIdentifier;
 class SurfaceDescriptor;
 class ThebesBufferData;
--- a/gfx/layers/ipc/CompositableTransactionParent.cpp
+++ b/gfx/layers/ipc/CompositableTransactionParent.cpp
@@ -1,40 +1,31 @@
 /* -*- 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 "CompositableTransactionParent.h"
-#include "CompositableHost.h"           // for CompositableParent, etc
-#include "CompositorParent.h"           // for CompositorParent
-#include "Layers.h"                     // for Layer
-#include "RenderTrace.h"                // for RenderTraceInvalidateEnd, etc
-#include "TiledLayerBuffer.h"           // for TiledLayerComposer
-#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 "ShadowLayers.h"
+#include "RenderTrace.h"
+#include "ShadowLayersManager.h"
+#include "CompositableHost.h"
+#include "mozilla/layers/ContentHost.h"
+#include "ShadowLayerParent.h"
+#include "TiledLayerBuffer.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/ThebesLayerComposite.h"
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsDebug.h"                    // for NS_WARNING, NS_ASSERTION
-#include "nsRegion.h"                   // for nsIntRegion
+#include "mozilla/layers/TextureHost.h"
+#include "CompositorParent.h"
 
 namespace mozilla {
 namespace layers {
 
-class BasicTiledLayerBuffer;
-class Compositor;
-
 template<typename T>
 CompositableHost* AsCompositable(const T& op)
 {
   return static_cast<CompositableParent*>(op.compositableParent())->GetCompositableHost();
 }
 
 template<typename T>
 bool ScheduleComposition(const T& op)
--- a/gfx/layers/ipc/CompositableTransactionParent.h
+++ b/gfx/layers/ipc/CompositableTransactionParent.h
@@ -1,22 +1,17 @@
 /* -*- 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_COMPOSITABLETRANSACTIONPARENT_H
-#define MOZILLA_LAYERS_COMPOSITABLETRANSACTIONPARENT_H
-
-#include <vector>                       // for vector
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator
-#include "mozilla/layers/LayerTransaction.h"  // for EditReply, etc
+#include "mozilla/layers/ISurfaceAllocator.h"
+#include "mozilla/layers/LayerTransaction.h"
 
 namespace mozilla {
 namespace layers {
 
 typedef std::vector<mozilla::layers::EditReply> EditReplyVector;
 
 // Since PCompositble has two potential manager protocols, we can't just call
 // the Manager() method usually generated when there's one manager protocol,
@@ -28,12 +23,13 @@ protected:
   /**
    * Handle the IPDL messages that affect PCompositable actors.
    */
   bool ReceiveCompositableUpdate(const CompositableOperation& aEdit,
                                  EditReplyVector& replyv);
   bool IsOnCompositorSide() const MOZ_OVERRIDE { return true; }
 };
 
+
+
+
 } // namespace
 } // namespace
-
-#endif
--- a/gfx/layers/ipc/CompositorChild.cpp
+++ b/gfx/layers/ipc/CompositorChild.cpp
@@ -1,29 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set sw=2 ts=2 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 "CompositorChild.h"
-#include <stddef.h>                     // for size_t
-#include "Layers.h"                     // for LayerManager
-#include "base/message_loop.h"          // for MessageLoop
-#include "base/process_util.h"          // for OpenProcessHandle
-#include "base/task.h"                  // for NewRunnableMethod, etc
-#include "base/tracked.h"               // for FROM_HERE
+#include "CompositorParent.h"
+#include "LayerManagerOGL.h"
 #include "mozilla/layers/LayerTransactionChild.h"
-#include "mozilla/layers/PLayerTransactionChild.h"
-#include "mozilla/mozalloc.h"           // for operator new, etc
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT
-#include "nsIObserver.h"                // for nsIObserver
-#include "nsTArray.h"                   // for nsTArray, nsTArray_Impl
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-#include "nsXULAppAPI.h"                // for XRE_GetIOMessageLoop, etc
 
 using mozilla::layers::LayerTransactionChild;
 
 namespace mozilla {
 namespace layers {
 
 /*static*/ CompositorChild* CompositorChild::sCompositor;
 
--- a/gfx/layers/ipc/CompositorChild.h
+++ b/gfx/layers/ipc/CompositorChild.h
@@ -2,32 +2,25 @@
 /* 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 mozilla_layers_CompositorChild_h
 #define mozilla_layers_CompositorChild_h
 
-#include "base/basictypes.h"            // for DISALLOW_EVIL_CONSTRUCTORS
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/ipc/ProtocolUtils.h"
 #include "mozilla/layers/PCompositorChild.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for nsCOMPtr
-#include "nsISupportsImpl.h"            // for NS_INLINE_DECL_REFCOUNTING
-
-class nsIObserver;
+#include "nsXULAppAPI.h"
 
 namespace mozilla {
 namespace layers {
 
 class LayerManager;
 class CompositorParent;
+struct TextureFactoryIdentifier;
 
 class CompositorChild : public PCompositorChild
 {
   NS_INLINE_DECL_REFCOUNTING(CompositorChild)
 public:
   CompositorChild(LayerManager *aLayerManager);
   virtual ~CompositorChild();
 
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -1,58 +1,34 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set sw=2 ts=2 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 <map>
+
+#include "mozilla/DebugOnly.h"
+
+#include "AutoOpenSurface.h"
 #include "CompositorParent.h"
-#include <stdio.h>                      // for fprintf, stdout
-#include <stdint.h>                     // for uint64_t
-#include <map>                          // for _Rb_tree_iterator, etc
-#include <utility>                      // for pair
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "AutoOpenSurface.h"            // for AutoOpenSurface
-#include "LayerTransactionParent.h"     // for LayerTransactionParent
-#include "RenderTrace.h"                // for RenderTraceLayers
-#include "base/message_loop.h"          // for MessageLoop
-#include "base/process.h"               // for ProcessHandle
-#include "base/process_util.h"          // for OpenProcessHandle
-#include "base/task.h"                  // for CancelableTask, etc
-#include "base/thread.h"                // for Thread
-#include "base/tracked.h"               // for FROM_HERE
-#include "gfxContext.h"                 // for gfxContext
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "ipc/ShadowLayersManager.h"    // for ShadowLayersManager
-#include "mozilla/AutoRestore.h"        // for AutoRestore
-#include "mozilla/DebugOnly.h"          // for DebugOnly
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/ipc/Transport.h"      // for Transport
-#include "mozilla/layers/APZCTreeManager.h"  // for APZCTreeManager
-#include "mozilla/layers/AsyncCompositionManager.h"
-#include "mozilla/layers/BasicCompositor.h"  // for BasicCompositor
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/CompositorOGL.h"  // for CompositorOGL
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/LayerManagerComposite.h"
-#include "mozilla/layers/LayersTypes.h"
-#include "mozilla/layers/PLayerTransactionParent.h"
-#include "mozilla/mozalloc.h"           // for operator new, etc
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ABORT_IF_FALSE, etc
-#include "nsIWidget.h"                  // for nsIWidget
-#include "nsRect.h"                     // for nsIntRect
-#include "nsTArray.h"                   // for nsTArray
-#include "nsThreadUtils.h"              // for NS_IsMainThread
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-#include "nsXULAppAPI.h"                // for XRE_GetIOMessageLoop
+#include "mozilla/layers/CompositorOGL.h"
+#include "mozilla/layers/BasicCompositor.h"
 #ifdef XP_WIN
 #include "mozilla/layers/CompositorD3D11.h"
 #include "mozilla/layers/CompositorD3D9.h"
 #endif
+#include "LayerTransactionParent.h"
+#include "nsIWidget.h"
+#include "nsGkAtoms.h"
+#include "RenderTrace.h"
+#include "gfxPlatform.h"
+#include "mozilla/AutoRestore.h"
+#include "mozilla/layers/AsyncCompositionManager.h"
+#include "mozilla/layers/LayerManagerComposite.h"
 
 using namespace base;
 using namespace mozilla;
 using namespace mozilla::ipc;
 using namespace std;
 
 namespace mozilla {
 namespace layers {
--- a/gfx/layers/ipc/CompositorParent.h
+++ b/gfx/layers/ipc/CompositorParent.h
@@ -10,47 +10,38 @@
 // Enable this pref to turn on compositor performance warning.
 // This will print warnings if the compositor isn't meeting
 // its responsiveness objectives:
 //    1) Compose a frame within 15ms of receiving a ScheduleCompositeCall
 //    2) Unless a frame was composited within the throttle threshold in
 //       which the deadline will be 15ms + throttle threshold
 //#define COMPOSITOR_PERFORMANCE_WARNING
 
-#include <stdint.h>                     // for uint64_t
-#include "GeckoProfilerFunc.h"          // for TimeStamp
-#include "Layers.h"                     // for Layer
-#include "ShadowLayersManager.h"        // for ShadowLayersManager
-#include "base/basictypes.h"            // for DISALLOW_EVIL_CONSTRUCTORS
-#include "base/platform_thread.h"       // for PlatformThreadId
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/Monitor.h"            // for Monitor
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/TimeStamp.h"          // for TimeStamp
-#include "mozilla/ipc/ProtocolUtils.h"
-#include "mozilla/layers/GeckoContentController.h"
-#include "mozilla/layers/LayerTransaction.h"  // for TargetConfig
 #include "mozilla/layers/PCompositorParent.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsISupportsImpl.h"
-#include "nsSize.h"                     // for nsIntSize
+#include "mozilla/layers/PLayerTransactionParent.h"
+#include "mozilla/layers/APZCTreeManager.h"
+#include "base/thread.h"
+#include "mozilla/Monitor.h"
+#include "mozilla/TimeStamp.h"
+#include "ShadowLayersManager.h"
 
-class CancelableTask;
-class MessageLoop;
-class gfxContext;
 class nsIWidget;
 
+namespace base {
+class Thread;
+}
+
 namespace mozilla {
 namespace layers {
 
 class APZCTreeManager;
-class AsyncCompositionManager;
+class Layer;
 class LayerManagerComposite;
-class LayerTransactionParent;
+class AsyncCompositionManager;
+struct TextureFactoryIdentifier;
 
 struct ScopedLayerTreeRegistration
 {
   ScopedLayerTreeRegistration(uint64_t aLayersId,
                               Layer* aRoot,
                               GeckoContentController* aController);
   ~ScopedLayerTreeRegistration();
 
--- a/gfx/layers/ipc/GeckoContentController.h
+++ b/gfx/layers/ipc/GeckoContentController.h
@@ -2,28 +2,25 @@
 /* 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 "FrameMetrics.h"               // for FrameMetrics, etc
-#include "Units.h"                      // for CSSIntPoint, CSSRect, etc
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
+#include "FrameMetrics.h"
 #include "nsISupportsImpl.h"
 
 class Task;
 
 namespace mozilla {
 namespace layers {
 
-class GeckoContentController
-{
+class GeckoContentController {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GeckoContentController)
 
   /**
    * Requests a paint of the given FrameMetrics |aFrameMetrics| from Gecko.
    * Implementations per-platform are responsible for actually handling this.
    */
   virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) = 0;
--- a/gfx/layers/ipc/GestureEventListener.cpp
+++ b/gfx/layers/ipc/GestureEventListener.cpp
@@ -1,24 +1,21 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
+#include "base/basictypes.h"
+#include "base/thread.h"
+
 #include "GestureEventListener.h"
-#include <math.h>                       // for fabsf
-#include <stddef.h>                     // for size_t
-#include "AsyncPanZoomController.h"     // for AsyncPanZoomController
-#include "base/task.h"                  // for CancelableTask, etc
-#include "mozilla/Preferences.h"        // for Preferences
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsDebug.h"                    // for NS_WARN_IF_FALSE
-#include "nsMathUtils.h"                // for NS_hypot
+#include "AsyncPanZoomController.h"
+
+#include "mozilla/Preferences.h"
 
 namespace mozilla {
 namespace layers {
 
 /**
  * Maximum time for a touch on the screen and corresponding lift of the finger
  * to be considered a tap. This also applies to double taps, except that it is
  * used twice.
--- a/gfx/layers/ipc/GestureEventListener.h
+++ b/gfx/layers/ipc/GestureEventListener.h
@@ -2,32 +2,25 @@
 /* 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_GestureEventListener_h
 #define mozilla_layers_GestureEventListener_h
 
-#include <stdint.h>                     // for uint64_t
-#include "InputData.h"                  // for MultiTouchInput, etc
-#include "Units.h"                      // for ScreenIntPoint
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsEvent.h"                    // for nsEventStatus
-#include "nsISupportsImpl.h"
-#include "nsTArray.h"                   // for nsTArray
+#include "mozilla/RefPtr.h"
+#include "InputData.h"
+#include "Axis.h"
 
-class CancelableTask;
+#include "base/message_loop.h"
 
 namespace mozilla {
 namespace layers {
 
-class AsyncPanZoomController;
-
 /**
  * Platform-non-specific, generalized gesture event listener. This class
  * intercepts all touches events on their way to AsyncPanZoomController and
  * determines whether or not they are part of a gesture.
  *
  * For example, seeing that two fingers are on the screen means that the user
  * wants to do a pinch gesture, so we don't forward the touches along to
  * AsyncPanZoomController since it will think that they are just trying to pan
--- a/gfx/layers/ipc/ISurfaceAllocator.cpp
+++ b/gfx/layers/ipc/ISurfaceAllocator.cpp
@@ -1,28 +1,25 @@
 /* -*- 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 "ISurfaceAllocator.h"
-#include <sys/types.h>                  // for int32_t
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxPlatform.h"                // for gfxPlatform, gfxImageFormat
-#include "gfxSharedImageSurface.h"      // for gfxSharedImageSurface
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
-#include "ShadowLayerUtils.h"
-#include "mozilla/mozalloc.h"           // for operator delete[], etc
-#include "nsAutoPtr.h"                  // for nsRefPtr, getter_AddRefs, etc
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT
-#include "nsXULAppAPI.h"                // for XRE_GetProcessType, etc
+#include "mozilla/ipc/SharedMemory.h"
+#include "gfxSharedImageSurface.h"
+#include "gfxPlatform.h"
+#include "gfxASurface.h"
+#include "mozilla/layers/LayersSurfaces.h"
+#include "mozilla/layers/SharedPlanarYCbCrImage.h"
+#include "mozilla/layers/SharedRGBImage.h"
+#include "nsXULAppAPI.h"
+
 #ifdef DEBUG
 #include "prenv.h"
 #endif
 
 using namespace mozilla::ipc;
 
 namespace mozilla {
 namespace layers {
--- a/gfx/layers/ipc/ISurfaceAllocator.h
+++ b/gfx/layers/ipc/ISurfaceAllocator.h
@@ -1,45 +1,43 @@
 /* -*- 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_LAYERS_ISURFACEDEALLOCATOR
 #define GFX_LAYERS_ISURFACEDEALLOCATOR
 
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint32_t
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
+#include "mozilla/ipc/SharedMemory.h"
+#include "mozilla/RefPtr.h"
+#include "gfxPoint.h"
+#include "gfxASurface.h"
 
 /*
  * FIXME [bjacob] *** PURE CRAZYNESS WARNING ***
  *
  * 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
 
+class gfxSharedImageSurface;
 class gfxASurface;
-class gfxSharedImageSurface;
 
 namespace base {
 class Thread;
-}
+} // namespace
 
 namespace mozilla {
 namespace ipc {
 class Shmem;
-}
-
+} // namespace
 namespace layers {
 
 class PGrallocBufferChild;
 class MaybeMagicGrallocBufferHandle;
 
 enum BufferCapabilities {
   DEFAULT_BUFFER_CAPS = 0,
   /**
--- a/gfx/layers/ipc/ImageBridgeChild.cpp
+++ b/gfx/layers/ipc/ImageBridgeChild.cpp
@@ -1,59 +1,35 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "base/thread.h"
+
+#include "CompositorParent.h" // for CompositorParent::CompositorLoop
 #include "ImageBridgeChild.h"
-#include <vector>                       // for vector
-#include "CompositorParent.h"           // for CompositorParent
-#include "ImageBridgeParent.h"          // for ImageBridgeParent
-#include "ImageContainer.h"             // for ImageContainer
-#include "Layers.h"                     // for Layer, etc
-#include "ShadowLayers.h"               // for ShadowLayerForwarder
-#include "base/message_loop.h"          // for MessageLoop
-#include "base/platform_thread.h"       // for PlatformThread
-#include "base/process.h"               // for ProcessHandle
-#include "base/process_util.h"          // for OpenProcessHandle
-#include "base/task.h"                  // for NewRunnableFunction, etc
-#include "base/thread.h"                // for Thread
-#include "base/tracked.h"               // for FROM_HERE
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Monitor.h"            // for Monitor, MonitorAutoLock
-#include "mozilla/ReentrantMonitor.h"   // for ReentrantMonitor, etc
-#include "mozilla/ipc/AsyncChannel.h"   // for AsyncChannel, etc
-#include "mozilla/ipc/Transport.h"      // for Transport
-#include "mozilla/layers/CompositableClient.h"  // for CompositableChild, etc
-#include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator
-#include "mozilla/layers/ImageClient.h"  // for ImageClient
-#include "mozilla/layers/LayerTransaction.h"  // for CompositableOperation
-#include "mozilla/layers/PCompositableChild.h"  // for PCompositableChild
-#include "mozilla/layers/TextureClient.h"  // for TextureClient
-#include "mozilla/mozalloc.h"           // for operator new, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsISupportsImpl.h"            // for ImageContainer::AddRef, etc
-#include "nsTArray.h"                   // for nsAutoTArray, nsTArray, etc
-#include "nsTArrayForwardDeclare.h"     // for AutoInfallibleTArray
-#include "nsThreadUtils.h"              // for NS_IsMainThread
-#include "nsXULAppAPI.h"                // for XRE_GetIOMessageLoop
-
-struct nsIntRect;
+#include "ImageBridgeParent.h"
+#include "gfxSharedImageSurface.h"
+#include "mozilla/Monitor.h"
+#include "mozilla/ReentrantMonitor.h"
+#include "mozilla/layers/CompositableClient.h"
+#include "nsXULAppAPI.h"
+#include "mozilla/layers/TextureClient.h"
+#include "mozilla/layers/ImageClient.h"
+#include "ImageContainer.h"
+#include "mozilla/layers/LayersTypes.h"
+#include "ShadowLayers.h"
  
 using namespace base;
 using namespace mozilla::ipc;
 
 namespace mozilla {
-namespace ipc {
-class Shmem;
-}
-
 namespace layers {
 
-class PGrallocBufferChild;
 typedef std::vector<CompositableOperation> OpVector;
 
 struct CompositableTransaction
 {
   CompositableTransaction()
   : mSwapRequired(false)
   , mFinished(true)
   {}
@@ -757,17 +733,17 @@ static void ProxyAllocShmemNow(AllocShme
   ReentrantMonitorAutoEnter autoMon(*aBarrier);
   *aDone = true;
   aBarrier->NotifyAll();
 }
 
 bool
 ImageBridgeChild::DispatchAllocShmemInternal(size_t aSize,
                                              SharedMemory::SharedMemoryType aType,
-                                             ipc::Shmem* aShmem,
+                                             Shmem* aShmem,
                                              bool aUnsafe)
 {
   ReentrantMonitor barrier("AllocatorProxy alloc");
   ReentrantMonitorAutoEnter autoMon(barrier);
 
   AllocShmemParams params = {
     this, aSize, aType, aShmem, aUnsafe, true
   };
@@ -780,17 +756,17 @@ ImageBridgeChild::DispatchAllocShmemInte
                                                  &done));
   while (!done) {
     barrier.Wait();
   }
   return params.mSuccess;
 }
 
 static void ProxyDeallocShmemNow(ISurfaceAllocator* aAllocator,
-                                 ipc::Shmem* aShmem,
+                                 Shmem* aShmem,
                                  ReentrantMonitor* aBarrier,
                                  bool* aDone)
 {
   MOZ_ASSERT(aShmem);
   MOZ_ASSERT(aDone);
   MOZ_ASSERT(aBarrier);
 
   aAllocator->DeallocShmem(*aShmem);
--- a/gfx/layers/ipc/ImageBridgeChild.h
+++ b/gfx/layers/ipc/ImageBridgeChild.h
@@ -1,49 +1,37 @@
 /* -*- 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_IMAGEBRIDGECHILD_H
 #define MOZILLA_GFX_IMAGEBRIDGECHILD_H
 
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint32_t, uint64_t
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for TemporaryRef
-#include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
+#include "mozilla/layers/PImageBridgeChild.h"
+#include "nsAutoPtr.h"
 #include "mozilla/layers/CompositableForwarder.h"
-#include "mozilla/layers/CompositorTypes.h"  // for TextureIdentifier, etc
-#include "mozilla/layers/LayersSurfaces.h"  // for PGrallocBufferChild
-#include "mozilla/layers/PImageBridgeChild.h"
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT
-#include "nsRegion.h"                   // for nsIntRegion
-class MessageLoop;
-struct nsIntPoint;
-struct nsIntRect;
+#include "mozilla/layers/LayersTypes.h"
+
+class gfxSharedImageSurface;
 
 namespace base {
 class Thread;
 }
 
 namespace mozilla {
-namespace ipc {
-class Shmem;
-}
-
 namespace layers {
 
-class BasicTiledLayerBuffer;
 class ImageClient;
 class ImageContainer;
 class ImageBridgeParent;
+class SurfaceDescriptor;
 class CompositableClient;
 class CompositableTransaction;
+class ShadowableLayer;
 class Image;
 class TextureClient;
 
 /**
  * Returns true if the current thread is the ImageBrdigeChild's thread.
  *
  * Can be called from any thread.
  */
--- a/gfx/layers/ipc/ImageBridgeParent.cpp
+++ b/gfx/layers/ipc/ImageBridgeParent.cpp
@@ -1,47 +1,28 @@
 /* -*- 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 "ImageBridgeParent.h"
-#include <stdint.h>                     // for uint64_t, uint32_t
-#include "CompositableHost.h"           // for CompositableParent, Create
-#include "base/message_loop.h"          // for MessageLoop
-#include "base/process.h"               // for ProcessHandle
-#include "base/process_util.h"          // for OpenProcessHandle
-#include "base/task.h"                  // for CancelableTask, DeleteTask, etc
-#include "base/tracked.h"               // for FROM_HERE
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/ipc/AsyncChannel.h"   // for AsyncChannel, etc
-#include "mozilla/ipc/ProtocolUtils.h"
-#include "mozilla/ipc/Transport.h"      // for Transport
-#include "mozilla/layers/CompositableTransactionParent.h"
-#include "mozilla/layers/CompositorParent.h"  // for CompositorParent
+#include "base/thread.h"
+
+#include "mozilla/layers/CompositorParent.h"
+#include "mozilla/layers/ImageBridgeParent.h"
+#include "CompositableHost.h"
+#include "nsTArray.h"
+#include "nsXULAppAPI.h"
 #include "mozilla/layers/LayerManagerComposite.h"
-#include "mozilla/layers/LayerTransaction.h"  // for EditReply
-#include "mozilla/layers/LayersSurfaces.h"  // for PGrallocBufferParent
-#include "mozilla/layers/PCompositableParent.h"
-#include "mozilla/layers/PImageBridgeParent.h"
-#include "mozilla/mozalloc.h"           // for operator new, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT, etc
-#include "nsISupportsImpl.h"            // for ImageBridgeParent::Release, etc
-#include "nsTArray.h"                   // for nsTArray, nsTArray_Impl
-#include "nsTArrayForwardDeclare.h"     // for InfallibleTArray
-#include "nsXULAppAPI.h"                // for XRE_GetIOMessageLoop
 
 using namespace base;
 using namespace mozilla::ipc;
 
 namespace mozilla {
 namespace layers {
 
-class PGrallocBufferParent;
 
 ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop, Transport* aTransport)
   : mMessageLoop(aLoop)
   , mTransport(aTransport)
 {
   // creates the map only if it has not been created already, so it is safe
   // with several bridges
   CompositableMap::Create();
--- a/gfx/layers/ipc/ImageBridgeParent.h
+++ b/gfx/layers/ipc/ImageBridgeParent.h
@@ -1,35 +1,22 @@
 /* -*- 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 <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint32_t, uint64_t
+#include "mozilla/layers/PImageBridgeParent.h"
 #include "CompositableTransactionParent.h"
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/ipc/ProtocolUtils.h"
-#include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
-#include "mozilla/layers/PImageBridgeParent.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsISupportsImpl.h"
-#include "nsTArrayForwardDeclare.h"     // for InfallibleTArray
 
 class MessageLoop;
 
 namespace mozilla {
-namespace ipc {
-class Shmem;
-}
-
 namespace layers {
 
+class CompositorParent;
 /**
  * ImageBridgeParent is the manager Protocol of ImageContainerParent.
  * It's purpose is mainly to setup the IPDL connection. Most of the
  * interesting stuff is in ImageContainerParent.
  */
 class ImageBridgeParent : public PImageBridgeParent,
                           public CompositableParentManager
 {
--- a/gfx/layers/ipc/LayerTransactionChild.cpp
+++ b/gfx/layers/ipc/LayerTransactionChild.cpp
@@ -1,29 +1,23 @@
 /* -*- 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 "ShadowLayerChild.h"
 #include "LayerTransactionChild.h"
-#include "mozilla/layers/CompositableClient.h"  // for CompositableChild
-#include "mozilla/layers/LayersSurfaces.h"  // for PGrallocBufferChild
-#include "mozilla/layers/PCompositableChild.h"  // for PCompositableChild
-#include "mozilla/layers/PLayerChild.h"  // for PLayerChild
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT, etc
-#include "nsTArray.h"                   // for nsTArray
+#include "ShadowLayerUtils.h"
+#include "mozilla/layers/CompositableClient.h"
 
 namespace mozilla {
 namespace layers {
 
-class PGrallocBufferChild;
-
 void
 LayerTransactionChild::Destroy()
 {
   NS_ABORT_IF_FALSE(0 == ManagedPLayerChild().Length(),
                     "layers should have been cleaned up by now");
   PLayerTransactionChild::Send__delete__(this);
   // WARNING: |this| has gone to the great heap in the sky
 }
--- a/gfx/layers/ipc/LayerTransactionChild.h
+++ b/gfx/layers/ipc/LayerTransactionChild.h
@@ -3,20 +3,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/. */
 
 #ifndef MOZILLA_LAYERS_LAYERTRANSACTIONCHILD_H
 #define MOZILLA_LAYERS_LAYERTRANSACTIONCHILD_H
 
-#include <stdint.h>                     // for uint32_t
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/ipc/ProtocolUtils.h"
 #include "mozilla/layers/PLayerTransactionChild.h"
 
 namespace mozilla {
 namespace layers {
 
 class LayerTransactionChild : public PLayerTransactionChild
 {
 public:
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -1,58 +1,45 @@
 /* -*- 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 <vector>
+
+#include "AutoOpenSurface.h"
+#include "CompositorParent.h"
+#include "gfxSharedImageSurface.h"
+#include "ImageLayers.h"
+#include "mozilla/layout/RenderFrameParent.h"
+#include "mozilla/unused.h"
+#include "RenderTrace.h"
+#include "ShadowLayerParent.h"
 #include "LayerTransactionParent.h"
-#include <vector>                       // for vector
-#include "CompositableHost.h"           // for CompositableParent, Get, etc
-#include "ImageLayers.h"                // for ImageLayer
-#include "Layers.h"                     // for Layer, ContainerLayer, etc
-#include "ShadowLayerParent.h"          // for ShadowLayerParent
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxPoint3D.h"                 // for gfxPoint3D
-#include "CompositableTransactionParent.h"  // for EditReplyVector
-#include "ShadowLayersManager.h"        // for ShadowLayersManager
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/gfx/BasePoint3D.h"    // for BasePoint3D
-#include "mozilla/layers/CanvasLayerComposite.h"
-#include "mozilla/layers/ColorLayerComposite.h"
-#include "mozilla/layers/Compositor.h"  // for Compositor
-#include "mozilla/layers/ContainerLayerComposite.h"
+#include "ShadowLayers.h"
+#include "ShadowLayerUtils.h"
+#include "TiledLayerBuffer.h"
+#include "gfxPlatform.h"
+#include "CompositableHost.h"
+#include "mozilla/layers/ThebesLayerComposite.h"
 #include "mozilla/layers/ImageLayerComposite.h"
-#include "mozilla/layers/LayerManagerComposite.h"
-#include "mozilla/layers/LayerTransaction.h"  // for EditReply, etc
-#include "mozilla/layers/LayersSurfaces.h"  // for PGrallocBufferParent
-#include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_LOG
-#include "mozilla/layers/PCompositableParent.h"
-#include "mozilla/layers/PLayerParent.h"  // for PLayerParent
-#include "mozilla/layers/ThebesLayerComposite.h"
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsCoord.h"                    // for NSAppUnitsToFloatPixels
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT
-#include "nsISupportsImpl.h"            // for Layer::Release, etc
-#include "nsLayoutUtils.h"              // for nsLayoutUtils
-#include "nsMathUtils.h"                // for NS_round
-#include "nsPoint.h"                    // for nsPoint
-#include "nsTArray.h"                   // for nsTArray, nsTArray_Impl, etc
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "mozilla/layers/ColorLayerComposite.h"
+#include "mozilla/layers/ContainerLayerComposite.h"
+#include "mozilla/layers/CanvasLayerComposite.h"
+#include "mozilla/layers/PLayerTransaction.h"
 
 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/LayerTransactionParent.h
+++ b/gfx/layers/ipc/LayerTransactionParent.h
@@ -3,45 +3,33 @@
  */
 /* 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_LAYERTRANSACTIONPARENT_H
 #define MOZILLA_LAYERS_LAYERTRANSACTIONPARENT_H
 
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint64_t, uint32_t
+#include "mozilla/layers/PLayerTransactionParent.h"
+#include "ShadowLayers.h"
+#include "ShadowLayersManager.h"
 #include "CompositableTransactionParent.h"
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
-#include "mozilla/layers/PLayerTransactionParent.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsTArrayForwardDeclare.h"     // for InfallibleTArray
-
-class gfx3DMatrix;
 
 namespace mozilla {
 
-namespace ipc {
-class Shmem;
-}
-
 namespace layout {
 class RenderFrameParent;
 }
 
 namespace layers {
 
 class Layer;
 class LayerManagerComposite;
 class ShadowLayerParent;
 class CompositableParent;
-class ShadowLayersManager;
 
 class LayerTransactionParent : public PLayerTransactionParent,
                                public CompositableParentManager
 {
   typedef mozilla::layout::RenderFrameParent RenderFrameParent;
   typedef InfallibleTArray<Edit> EditArray;
   typedef InfallibleTArray<EditReply> EditReplyArray;
 
--- a/gfx/layers/ipc/ShadowLayerChild.cpp
+++ b/gfx/layers/ipc/ShadowLayerChild.cpp
@@ -1,19 +1,18 @@
 /* -*- 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 "ShadowLayerChild.h"
-#include "Layers.h"                     // for Layer
-#include "ShadowLayers.h"               // for ShadowableLayer
-#include "nsDebug.h"                    // for NS_ABORT_IF_FALSE
+#include "Layers.h"
+#include "ShadowLayers.h"
 
 namespace mozilla {
 namespace layers {
 
 ShadowLayerChild::ShadowLayerChild(ShadowableLayer* aLayer)
   : mLayer(aLayer)
 { }
 
--- a/gfx/layers/ipc/ShadowLayerChild.h
+++ b/gfx/layers/ipc/ShadowLayerChild.h
@@ -3,19 +3,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 mozilla_layers_ShadowLayerChild_h
 #define mozilla_layers_ShadowLayerChild_h
 
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/ipc/ProtocolUtils.h"
-#include "mozilla/layers/PLayerChild.h"  // for PLayerChild
+#include "mozilla/layers/PLayerChild.h"
 
 namespace mozilla {
 namespace layers {
 
 class ShadowableLayer;
 
 class ShadowLayerChild : public PLayerChild
 {
--- a/gfx/layers/ipc/ShadowLayerParent.cpp
+++ b/gfx/layers/ipc/ShadowLayerParent.cpp
@@ -1,19 +1,20 @@
 /* -*- 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 "LayerTransactionParent.h"
 #include "ShadowLayerParent.h"
-#include "Layers.h"                     // for Layer, ContainerLayer
-#include "nsDebug.h"                    // for NS_RUNTIMEABORT
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
+#include "ShadowLayers.h"
+
+#include "BasicLayers.h"
 
 namespace mozilla {
 namespace layers {
 
 ShadowLayerParent::ShadowLayerParent() : mLayer(nullptr)
 {
 }
 
--- a/gfx/layers/ipc/ShadowLayerParent.h
+++ b/gfx/layers/ipc/ShadowLayerParent.h
@@ -3,20 +3,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 mozilla_layers_ShadowLayerParent_h
 #define mozilla_layers_ShadowLayerParent_h
 
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/ipc/ProtocolUtils.h"
-#include "mozilla/layers/PLayerParent.h"  // for PLayerParent
-#include "nsAutoPtr.h"                  // for nsRefPtr
+#include "mozilla/layers/PLayerParent.h"
 
 namespace mozilla {
 namespace layers {
 
 class ContainerLayer;
 class Layer;
 class LayerManager;
 
--- a/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
@@ -1,49 +1,30 @@
 /* -*- 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 "ShadowLayerUtilsX11.h"
-#include <X11/X.h>                      // for Drawable, XID
-#include <X11/Xlib.h>                   // for Display, Visual, etc
-#include <X11/extensions/Xrender.h>     // for XRenderPictFormat, etc
-#include <X11/extensions/render.h>      // for PictFormat
+#include "mozilla/layers/PLayerTransaction.h"
+#include "mozilla/layers/LayerManagerComposite.h"
+#include "mozilla/layers/CompositorTypes.h"
+#include "mozilla/layers/ISurfaceAllocator.h"
+#include "mozilla/layers/ShadowLayers.h"
+
+#include "gfxPlatform.h"
+
+#include "gfxXlibSurface.h"
+#include "mozilla/X11Util.h"
 #include "cairo-xlib.h"
-#include <stdint.h>                     // for uint32_t
-#include "GLDefs.h"                     // for GLenum
-#include "cairo-rename.h"
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "gfxXlibSurface.h"             // for gfxXlibSurface
-#include "mozilla/X11Util.h"            // for DefaultXDisplay, FinishX, etc
-#include "mozilla/layers/CompositableForwarder.h"
-#include "mozilla/layers/CompositorTypes.h"  // for OpenMode
-#include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator, etc
-#include "mozilla/layers/LayerManagerComposite.h"
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
-#include "mozilla/layers/ShadowLayers.h"  // for ShadowLayerForwarder, etc
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ERROR
-#include "prenv.h"                      // for PR_GetEnv
 
 using namespace mozilla::gl;
 
 namespace mozilla {
-namespace gl {
-class GLContext;
-class TextureImage;
-}
-
 namespace layers {
 
 // Return true if we're likely compositing using X and so should use
 // Xlib surfaces in shadow layers.
 static bool
 UsingXCompositing()
 {
   return (gfxASurface::SurfaceTypeXlib ==
--- a/gfx/layers/ipc/ShadowLayerUtilsX11.h
+++ b/gfx/layers/ipc/ShadowLayerUtilsX11.h
@@ -3,34 +3,26 @@
  */
 /* 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_ShadowLayerUtilsX11_h
 #define mozilla_layers_ShadowLayerUtilsX11_h
 
-#include <X11/X.h>                      // for Drawable
+#include <X11/extensions/Xrender.h>
+#include <X11/Xlib.h>
+
 #include "ipc/IPCMessageUtils.h"
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "nsCOMPtr.h"                   // for already_AddRefed
-
-//#include <X11/extensions/Xrender.h>
-//#include <X11/Xlib.h>
-
 
 #define MOZ_HAVE_SURFACEDESCRIPTORX11
 #define MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS
 
 class gfxXlibSurface;
 
-namespace IPC {
-class Message;
-}
-
 namespace mozilla {
 namespace layers {
 
 struct SurfaceDescriptorX11 {
   SurfaceDescriptorX11()
   { }
 
   SurfaceDescriptorX11(gfxXlibSurface* aSurf);
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -1,59 +1,48 @@
 /* -*- 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 <set>
+#include <vector>
+
+#include "gfxSharedImageSurface.h"
+#include "gfxPlatform.h"
+
+#include "AutoOpenSurface.h"
+#include "mozilla/ipc/SharedMemorySysV.h"
+#include "mozilla/layers/PLayerChild.h"
+#include "mozilla/layers/PLayerTransactionChild.h"
+#include "mozilla/layers/PLayerTransactionParent.h"
+#include "mozilla/layers/LayerTransaction.h"
+#include "mozilla/layers/LayersSurfaces.h"
 #include "ShadowLayers.h"
-#include <set>                          // for _Rb_tree_const_iterator, etc
-#include <vector>                       // for vector
-#include "AutoOpenSurface.h"            // for AutoOpenSurface, etc
-#include "GeckoProfilerImpl.h"          // for PROFILER_LABEL
-#include "ISurfaceAllocator.h"          // for IsSurfaceDescriptorValid
-#include "Layers.h"                     // for Layer
-#include "RenderTrace.h"                // for RenderTraceScope
-#include "ShadowLayerChild.h"           // for ShadowLayerChild
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPlatform.h"                // for gfxImageFormat, gfxPlatform
-#include "gfxSharedImageSurface.h"      // for gfxSharedImageSurface
-#include "ipc/IPCMessageUtils.h"        // for gfxContentType, null_t
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/layers/CompositableClient.h"  // for CompositableClient, etc
-#include "mozilla/layers/LayerTransaction.h"  // for Edit, etc
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
-#include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_LOG
-#include "mozilla/layers/PLayerTransactionChild.h"
-#include "ShadowLayerUtils.h"
-#include "mozilla/layers/TextureClient.h"  // for TextureClient
-#include "mozilla/mozalloc.h"           // for operator new, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr, getter_AddRefs, etc
-#include "nsDebug.h"                    // for NS_ABORT_IF_FALSE, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
-#include "nsTArray.h"                   // for nsAutoTArray, nsTArray, etc
-#include "nsXULAppAPI.h"                // for XRE_GetProcessType, etc
+#include "ShadowLayerChild.h"
+#include "gfxipc/ShadowLayerUtils.h"
+#include "RenderTrace.h"
+#include "GeckoProfiler.h"
+#include "nsXULAppAPI.h"
+#include "mozilla/layers/ImageClient.h"
+#include "mozilla/layers/CanvasClient.h"
+#include "mozilla/layers/ContentClient.h"
+#include "ISurfaceAllocator.h"
 
-struct nsIntPoint;
+#include "nsTraceRefcntImpl.h"
 
 using namespace mozilla::ipc;
 using namespace mozilla::gl;
 using namespace mozilla::dom;
 
 namespace mozilla {
-namespace ipc {
-class Shmem;
-}
-
 namespace layers {
 
-class BasicTiledLayerBuffer;
-
 typedef nsTArray<SurfaceDescriptor> BufferArray;
 typedef std::vector<Edit> EditVector;
 typedef std::set<ShadowableLayer*> ShadowableLayerSet;
 
 class Transaction
 {
 public:
   Transaction()
--- a/gfx/layers/ipc/ShadowLayers.h
+++ b/gfx/layers/ipc/ShadowLayers.h
@@ -3,64 +3,68 @@
  */
 /* 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_ShadowLayers_h
 #define mozilla_layers_ShadowLayers_h 1
 
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint64_t
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/WidgetUtils.h"        // for ScreenRotation
-#include "mozilla/dom/ScreenOrientation.h"  // for ScreenOrientation
-#include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
+#include "gfxASurface.h"
+#include "GLDefs.h"
+
+#include "ImageLayers.h"
+#include "mozilla/layers/Compositor.h"
+#include "mozilla/ipc/SharedMemory.h"
+#include "mozilla/WidgetUtils.h"
+#include "mozilla/layers/ISurfaceAllocator.h"
+#include "mozilla/dom/ScreenOrientation.h"
 #include "mozilla/layers/CompositableForwarder.h"
-#include "mozilla/layers/CompositorTypes.h"  // for OpenMode, etc
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTArrayForwardDeclare.h"     // for InfallibleTArray
+#include "mozilla/layers/CompositorTypes.h"
 
-struct nsIntPoint;
-struct nsIntRect;
+class gfxSharedImageSurface;
 
 namespace mozilla {
+
+namespace gl {
+class GLContext;
+class TextureImage;
+}
+
 namespace layers {
 
-class BasicTiledLayerBuffer;
-class CanvasClient;
-class CanvasLayerComposite;
-class CanvasSurface;
-class ColorLayerComposite;
-class CompositableChild;
-class ContainerLayerComposite;
-class ContentClient;
-class ContentClientRemote;
+class CompositableClient;
+class Edit;
 class EditReply;
-class ImageClient;
-class ImageLayerComposite;
-class Layer;
 class OptionalThebesBuffer;
 class PLayerChild;
 class PLayerTransactionChild;
 class PLayerTransactionParent;
+class ShadowableLayer;
+class ThebesLayerComposite;
+class ContainerLayerComposite;
+class ImageLayerComposite;
+class ColorLayerComposite;
+class CanvasLayerComposite;
 class RefLayerComposite;
-class ShadowableLayer;
-class Shmem;
-class ShmemTextureClient;
 class SurfaceDescriptor;
-class TextureClient;
-class ThebesLayerComposite;
 class ThebesBuffer;
-class ThebesBufferData;
 class TiledLayerComposer;
 class Transaction;
+class SurfaceDescriptor;
+class CanvasSurface;
+class DeprecatedTextureClientShmem;
+class ShmemTextureClient;
+class ContentClientRemote;
+class CompositableChild;
+class ImageClient;
+class CanvasClient;
+class ContentClient;
+class TextureClient;
+
 
 /**
  * We want to share layer trees across thread contexts and address
  * spaces for several reasons; chief among them
  *
  *  - a parent process can paint a child process's layer tree while
  *    the child process is blocked, say on content script.  This is
  *    important on mobile devices where UI responsiveness is key.
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
@@ -1,29 +1,19 @@
 /* -*- 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 "SharedPlanarYCbCrImage.h"
-#include <stddef.h>                     // for size_t
-#include <stdio.h>                      // for printf
-#include "ISurfaceAllocator.h"          // for ISurfaceAllocator, etc
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat::FORMAT_YUV
-#include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
-#include "mozilla/layers/ImageClient.h"  // for ImageClient
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
-#include "mozilla/layers/TextureClient.h"  // for BufferTextureClient, etc
 #include "mozilla/layers/YCbCrImageDataSerializer.h"
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsISupportsImpl.h"            // for Image::AddRef
-
-class gfxASurface;
+#include "ISurfaceAllocator.h"
+#include "mozilla/layers/LayersSurfaces.h"
+#include "mozilla/layers/TextureClient.h"
+#include "mozilla/layers/ImageClient.h"
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::ipc;
 
 SharedPlanarYCbCrImage::SharedPlanarYCbCrImage(ImageClient* aCompositable)
 : PlanarYCbCrImage(nullptr)
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.h
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.h
@@ -1,35 +1,27 @@
 /* -*- 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 <stdint.h>                     // for uint8_t, uint32_t
-#include "ImageContainer.h"             // for PlanarYCbCrImage, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/ipc/Shmem.h"          // for Shmem
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_WARNING
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR
-
-class gfxASurface;
+#include "ImageContainer.h"
+#include "mozilla/ipc/Shmem.h"
+#include "mozilla/ipc/SharedMemory.h"
+#include "mozilla/layers/ISurfaceAllocator.h"
 
 #ifndef MOZILLA_LAYERS_DeprecatedSharedPlanarYCbCrImage_H
 #define MOZILLA_LAYERS_DeprecatedSharedPlanarYCbCrImage_H
 
 namespace mozilla {
 namespace layers {
 
+class ImageClient;
+class TextureClient;
 class BufferTextureClient;
-class ImageClient;
-class ISurfaceAllocator;
-class SurfaceDescriptor;
-class TextureClient;
 
 // XXX - This class will be removed along with DeprecatedImageClient
 class DeprecatedSharedPlanarYCbCrImage : public PlanarYCbCrImage
 {
 public:
   DeprecatedSharedPlanarYCbCrImage(ISurfaceAllocator* aAllocator)
   : PlanarYCbCrImage(nullptr)
   , mSurfaceAllocator(aAllocator), mAllocated(false)
--- a/gfx/layers/ipc/SharedRGBImage.cpp
+++ b/gfx/layers/ipc/SharedRGBImage.cpp
@@ -1,28 +1,20 @@
 /* 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 "ShadowLayers.h"
 #include "SharedRGBImage.h"
-#include "ImageTypes.h"                 // for ImageFormat::SHARED_RGB, etc
-#include "Shmem.h"                      // for Shmem
-#include "gfx2DGlue.h"                  // for ImageFormatToSurfaceFormat, etc
-#include "gfxPlatform.h"                // for gfxPlatform, gfxImageFormat
-#include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator, etc
-#include "mozilla/layers/ImageClient.h"  // for ImageClient
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
-#include "mozilla/layers/TextureClient.h"  // for BufferTextureClient, etc
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsDebug.h"                    // for NS_WARNING, NS_ASSERTION
-#include "nsISupportsImpl.h"            // for Image::AddRef, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
+#include "mozilla/layers/LayersSurfaces.h"
+#include "Shmem.h"
+#include "mozilla/layers/ISurfaceAllocator.h"
+#include "mozilla/layers/TextureClient.h"
+#include "mozilla/layers/ImageClient.h"
+#include "gfx2DGlue.h"
 
 // Just big enough for a 1080p RGBA32 frame
 #define MAX_FRAME_SIZE (16 * 1024 * 1024)
 
 namespace mozilla {
 namespace layers {
 
 DeprecatedSharedRGBImage::DeprecatedSharedRGBImage(ISurfaceAllocator *aAllocator) :
--- a/gfx/layers/ipc/SharedRGBImage.h
+++ b/gfx/layers/ipc/SharedRGBImage.h
@@ -1,38 +1,26 @@
 /* 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 SHAREDRGBIMAGE_H_
 #define SHAREDRGBIMAGE_H_
 
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint8_t
-#include "ImageContainer.h"             // for ISharedImage, Image, etc
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat
-#include "nsCOMPtr.h"                   // for already_AddRefed
+#include "ImageContainer.h"
+#include "ISurfaceAllocator.h"
 
 namespace mozilla {
 namespace ipc {
 class Shmem;
 }
-
 namespace layers {
-
 class BufferTextureClient;
+class TextureClient;
 class ImageClient;
-class ISurfaceAllocator;
-class TextureClient;
-class SurfaceDescriptor;
 
 already_AddRefed<Image> CreateSharedRGBImage(ImageContainer* aImageContainer,
                                              nsIntSize aSize,
                                              gfxASurface::gfxImageFormat aImageFormat);
 
 /**
  * Stores RGB data in shared memory
  * It is assumed that the image width and stride are equal
--- a/gfx/layers/ipc/TaskThrottler.cpp
+++ b/gfx/layers/ipc/TaskThrottler.cpp
@@ -1,14 +1,16 @@
 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- */
 /* vim: set sw=2 sts=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 "base/basictypes.h"
+#include "base/message_loop.h"
 #include "TaskThrottler.h"
 
 namespace mozilla {
 namespace layers {
 
 TaskThrottler::TaskThrottler(const TimeStamp& aTimeStamp)
   : mOutstanding(false)
   , mQueuedTask(nullptr)
--- a/gfx/layers/ipc/TaskThrottler.h
+++ b/gfx/layers/ipc/TaskThrottler.h
@@ -2,25 +2,23 @@
 /* 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_dom_TaskThrottler_h
 #define mozilla_dom_TaskThrottler_h
 
-#include <stdint.h>                     // for uint32_t
-#include "base/task.h"                  // for CancelableTask
-#include "mozilla/TimeStamp.h"          // for TimeDuration, TimeStamp
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsAutoPtr.h"                  // for nsAutoPtr
-#include "nsTArray.h"                   // for nsTArray
+#include "nsAutoPtr.h"
+#include "nsTArray.h"
+#include "mozilla/TimeStamp.h"
 
+class CancelableTask;
 namespace tracked_objects {
-class Location;
+  class Location;
 }
 
 namespace mozilla {
 namespace layers {
 
 /** The TaskThrottler prevents update event overruns. It is used in cases where
  * you're sending an async message and waiting for a reply. You need to call
  * PostTask to queue a task and TaskComplete when you get a response.
--- a/gfx/layers/opengl/CanvasLayerOGL.cpp
+++ b/gfx/layers/opengl/CanvasLayerOGL.cpp
@@ -1,47 +1,45 @@
 /* -*- 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 "ipc/AutoOpenSurface.h"
+#include "mozilla/layers/PLayerTransaction.h"
+#include "mozilla/layers/ShadowLayers.h"
+
+#include "gfxSharedImageSurface.h"
+
 #include "CanvasLayerOGL.h"
-#include "GLScreenBuffer.h"             // for GLScreenBuffer
-#include "SharedSurface.h"              // for SharedSurface
-#include "SharedSurfaceGL.h"            // for SharedSurface_Basic, etc
-#include "SurfaceStream.h"              // for SurfaceStream, etc
-#include "SurfaceTypes.h"               // for SharedSurfaceType, etc
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat, etc
-#include "nsDebug.h"                    // for NS_ABORT_IF_FALSE, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsSize.h"                     // for nsIntSize
-#include "LayerManagerOGL.h"            // for LayerOGL::GLContext, etc
+
+#include "gfxImageSurface.h"
+#include "gfxContext.h"
+#include "GLContextProvider.h"
+#include "gfxPlatform.h"
+#include "SharedSurfaceGL.h"
+#include "SharedSurfaceEGL.h"
+#include "SurfaceStream.h"
+#include "gfxColor.h"
 
 #ifdef XP_MACOSX
 #include "mozilla/gfx/MacIOSurface.h"
 #include "SharedSurfaceIO.h"
 #endif
 
 #ifdef XP_WIN
 #include "gfxWindowsSurface.h"
 #include "WGLLibrary.h"
 #endif
 
 #ifdef XP_MACOSX
 #include <OpenGL/OpenGL.h>
 #endif
 
 #ifdef GL_PROVIDER_GLX
-#include "GLXLibrary.h"                 // for GLXLibrary, sDefGLXLib
 #include "gfxXlibSurface.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::layers;
 using namespace mozilla::gl;
 using namespace mozilla::gfx;
 
--- a/gfx/layers/opengl/CanvasLayerOGL.h
+++ b/gfx/layers/opengl/CanvasLayerOGL.h
@@ -1,38 +1,26 @@
 /* -*- 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_CANVASLAYEROGL_H
 #define GFX_CANVASLAYEROGL_H
 
-#include "GLContext.h"                  // for GLContext
-#include "GLContextTypes.h"             // for GLuint, GLenum
-#include "GLDefs.h"                     // for LOCAL_GL_TEXTURE_2D
-#include "LayerManagerOGL.h"            // for LayerOGL::GLContext, etc
-#include "Layers.h"                     // for CanvasLayer, etc
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Preferences.h"        // for Preferences
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/gfx/2D.h"             // for DrawTarget
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "opengl/LayerManagerOGLProgram.h"  // for ShaderProgramType, etc
-#include "./../mozilla-config.h"        // for GL_PROVIDER_GLX
+#include "LayerManagerOGL.h"
+#include "gfxASurface.h"
+#include "GLDefs.h"
+#include "mozilla/Preferences.h"
+
 #if defined(GL_PROVIDER_GLX)
 #include "GLXLibrary.h"
 #include "mozilla/X11Util.h"
 #endif
 
-struct nsIntPoint;
-
 
 namespace mozilla {
 namespace layers {
 
 class CanvasLayerOGL :
   public CanvasLayer,
   public LayerOGL
 {
--- a/gfx/layers/opengl/ColorLayerOGL.cpp
+++ b/gfx/layers/opengl/ColorLayerOGL.cpp
@@ -1,19 +1,14 @@
 /* -*- 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 "ColorLayerOGL.h"
-#include "gfxColor.h"                   // for gfxRGBA
-#include "LayerManagerOGL.h"            // for LayerManagerOGL
-#include "LayerManagerOGLProgram.h"     // for ShaderProgramOGL, etc
-
-struct nsIntPoint;
 
 namespace mozilla {
 namespace layers {
 
 static void
 RenderColorLayer(ColorLayer* aLayer, LayerManagerOGL *aManager,
                  const nsIntPoint& aOffset)
 {
--- a/gfx/layers/opengl/ColorLayerOGL.h
+++ b/gfx/layers/opengl/ColorLayerOGL.h
@@ -1,20 +1,20 @@
 /* -*- 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_COLORLAYEROGL_H
 #define GFX_COLORLAYEROGL_H
 
-#include "LayerManagerOGL.h"            // for LayerOGL, LayerManagerOGL
-#include "Layers.h"                     // for ColorLayer, etc
+#include "mozilla/layers/PLayerTransaction.h"
+#include "mozilla/layers/ShadowLayers.h"
 
-struct nsIntPoint;
+#include "LayerManagerOGL.h"
 
 namespace mozilla {
 namespace layers {
 
 class ColorLayerOGL : public ColorLayer,
                       public LayerOGL
 {
 public:
--- a/gfx/layers/opengl/CompositingRenderTargetOGL.h
+++ b/gfx/layers/opengl/CompositingRenderTargetOGL.h
@@ -1,46 +1,31 @@
 /* -*- 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_COMPOSITINGRENDERTARGETOGL_H
 #define MOZILLA_GFX_COMPOSITINGRENDERTARGETOGL_H
 
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "GLContext.h"                  // for GLContext
-#include "GLContextTypes.h"             // for GLenum, GLuint
-#include "GLDefs.h"                     // for LOCAL_GL_FRAMEBUFFER, etc
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr, TemporaryRef
-#include "mozilla/gfx/Point.h"          // for IntSize, IntSizeTyped
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat, etc
-#include "mozilla/layers/Compositor.h"  // for SurfaceInitMode, etc
-#include "mozilla/layers/TextureHost.h" // for CompositingRenderTarget
-#include "mozilla/layers/CompositorOGL.h"  // for CompositorOGL
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsAString.h"
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ERROR, NS_WARNING
-#include "nsString.h"                   // for nsAutoCString
+#include "mozilla/layers/CompositorOGL.h"
+#include "mozilla/gfx/Rect.h"
+#include "gfxASurface.h"
 
-class gfxImageSurface;
+#ifdef MOZ_DUMP_PAINTING
+#include "mozilla/layers/CompositorOGL.h"
+#endif
 
 namespace mozilla {
 namespace gl {
+  class TextureImage;
   class BindableTexture;
 }
-
 namespace layers {
 
-class TextureSource;
-
 class CompositingRenderTargetOGL : public CompositingRenderTarget
 {
   typedef mozilla::gl::GLContext GLContext;
 
   // For lazy initialisation of the GL stuff
   struct InitParams
   {
     InitParams() : mStatus(NO_PARAMS) {}
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -1,48 +1,38 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/layers/TextureHostOGL.h"
 #include "CompositorOGL.h"
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint32_t, uint8_t
-#include <stdlib.h>                     // for free, malloc
-#include "FPSCounter.h"                 // for FPSState, FPSCounter
-#include "GLContextProvider.h"          // for GLContextProvider
-#include "Layers.h"                     // for WriteSnapshotToDumpFile
-#include "gfx2DGlue.h"                  // for ThebesFilter
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxCrashReporterUtils.h"      // for ScopedGfxFeatureReporter
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPattern.h"                 // for gfxPattern, etc
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxRect.h"                    // for gfxRect
-#include "gfxUtils.h"                   // for NextPowerOfTwo, gfxUtils, etc
-#include "mozilla/Preferences.h"        // for Preferences
-#include "mozilla/Util.h"               // for ArrayLength
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/gfx/Matrix.h"         // for Matrix4x4, Matrix
+#include "mozilla/layers/ImageHost.h"
+#include "mozilla/layers/ContentHost.h"
 #include "mozilla/layers/CompositingRenderTargetOGL.h"
-#include "mozilla/layers/Effects.h"     // for EffectChain, TexturedEffect, etc
-#include "mozilla/layers/TextureHost.h"  // for TextureSource, etc
-#include "mozilla/layers/TextureHostOGL.h"  // for TextureSourceOGL, etc
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsAString.h"
-#include "nsIConsoleService.h"          // for nsIConsoleService, etc
-#include "nsIWidget.h"                  // for nsIWidget
-#include "nsLiteralString.h"            // for NS_LITERAL_STRING
-#include "nsMathUtils.h"                // for NS_roundf
-#include "nsRect.h"                     // for nsIntRect
-#include "nsServiceManagerUtils.h"      // for do_GetService
-#include "nsString.h"                   // for nsString, nsAutoCString, etc
-#include "prtypes.h"                    // for PR_INT32_MAX
+#include "mozilla/Preferences.h"
+#include "mozilla/layers/ShadowLayers.h"
+#include "mozilla/layers/PLayer.h"
+#include "mozilla/layers/Effects.h"
+#include "nsIWidget.h"
+#include "FPSCounter.h"
+
+#include "gfxUtils.h"
+
+#include "GLContextProvider.h"
+
+#include "nsIServiceManager.h"
+#include "nsIConsoleService.h"
+
+#include "gfxCrashReporterUtils.h"
+
+#include "nsMathUtils.h"
+
+#include "GeckoProfiler.h"
+#include <algorithm>
 
 #if MOZ_ANDROID_OMTC
 #include "TexturePoolOGL.h"
 #endif
 
 
 namespace mozilla {
 
--- a/gfx/layers/opengl/CompositorOGL.h
+++ b/gfx/layers/opengl/CompositorOGL.h
@@ -1,65 +1,30 @@
 /* -*- 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_COMPOSITOROGL_H
 #define MOZILLA_GFX_COMPOSITOROGL_H
 
-#include "./../mozilla-config.h"        // for MOZ_DUMP_PAINTING
-#include "GLContext.h"                  // for GLContext
-#include "GLContextTypes.h"             // for GLuint, GLenum, GLint
-#include "GLDefs.h"                     // for GLintptr, GLvoid, etc
-#include "GeckoProfilerFunc.h"          // for TimeStamp
-#include "LayerManagerOGLProgram.h"     // for ShaderProgramOGL, etc
-#include "Units.h"                      // for ScreenPoint
-#include "gfxContext.h"                 // for gfxContext
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE, MOZ_FINAL
-#include "mozilla/RefPtr.h"             // for TemporaryRef, RefPtr
-#include "mozilla/TimeStamp.h"          // for TimeStamp
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/gfx/Point.h"          // for IntSize, Point
-#include "mozilla/gfx/Rect.h"           // for Rect, IntRect
-#include "mozilla/gfx/Types.h"          // for Float, SurfaceFormat, etc
-#include "mozilla/layers/Compositor.h"  // for SurfaceInitMode, Compositor, etc
-#include "mozilla/layers/CompositorTypes.h"  // for MaskType::NumMaskTypes, etc
-#include "mozilla/layers/LayersTypes.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr, nsAutoPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION, NS_WARNING
-#include "nsISupportsImpl.h"            // for gfxContext::AddRef, etc
-#include "nsSize.h"                     // for nsIntSize
-#include "nsTArray.h"                   // for nsAutoTArray, nsTArray, etc
-#include "nsThreadUtils.h"              // for nsRunnable
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-#include "nsXULAppAPI.h"                // for XRE_GetProcessType
-#include "nscore.h"                     // for NS_IMETHOD
-class gfx3DMatrix;
-class nsIWidget;
-struct gfxMatrix;
+#include "mozilla/layers/Compositor.h"
+#include "GLContext.h"
+#include "LayerManagerOGLProgram.h"
+#include "mozilla/layers/Effects.h"
+#include "nsTArray.h"
+
+#include "mozilla/TimeStamp.h"
 
 namespace mozilla {
-namespace gfx {
-class Matrix4x4;
-}
-
 namespace layers {
 
-class CompositingRenderTarget;
+struct FPSState;
 class CompositingRenderTargetOGL;
-class DataTextureSource;
 class GLManagerCompositor;
-class TextureSource;
-struct Effect;
-struct EffectChain;
-struct FPSState;
 
 class CompositorOGL : public Compositor
 {
   typedef mozilla::gl::GLContext GLContext;
   typedef ShaderProgramType ProgramType;
   
   friend class GLManagerCompositor;
 
--- a/gfx/layers/opengl/ContainerLayerOGL.cpp
+++ b/gfx/layers/opengl/ContainerLayerOGL.cpp
@@ -1,34 +1,17 @@
 /* -*- 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 "ContainerLayerOGL.h"
-#include <stdint.h>                     // for uint32_t
-#include <algorithm>                    // for min
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
+#include "gfxUtils.h"
+#include "gfxPlatform.h"
 #include "GLContext.h"
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxUtils.h"                   // for gfxUtils, etc
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "mozilla/layers/CompositorTypes.h"  // for MaskType, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsISupportsUtils.h"           // for NS_ADDREF, NS_RELEASE
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsTArray.h"                   // for nsAutoTArray
-#include "LayerManagerOGL.h"            // for LayerManagerOGL, LayerOGL, etc
-#include "LayerManagerOGLProgram.h"     // for ShaderProgramOGL
-class gfxImageSurface;
 
 namespace mozilla {
 namespace layers {
 
 template<class Container>
 static void
 ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter)
 {
--- a/gfx/layers/opengl/ContainerLayerOGL.h
+++ b/gfx/layers/opengl/ContainerLayerOGL.h
@@ -1,20 +1,18 @@
 /* -*- 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_CONTAINERLAYEROGL_H
 #define GFX_CONTAINERLAYEROGL_H
 
-#include "LayerManagerOGL.h"            // for LayerOGL
-#include "Layers.h"                     // for Layer (ptr only), etc
-class gfx3DMatrix;
-struct nsIntPoint;
+#include "Layers.h"
+#include "LayerManagerOGL.h"
 
 namespace mozilla {
 namespace layers {
 
 template<class Container>
 static void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter);
 template<class Container>
 static void ContainerRemoveChild(Container* aContainer, Layer* aChild);
--- a/gfx/layers/opengl/FPSCounter.h
+++ b/gfx/layers/opengl/FPSCounter.h
@@ -1,27 +1,22 @@
 /* -*- 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 <stddef.h>                     // for size_t
-#include <algorithm>                    // for min
-#include "GLDefs.h"                     // for GLuint
-#include "mozilla/TimeStamp.h"          // for TimeStamp, TimeDuration
-#include "nsTArray.h"                   // for nsAutoTArray, nsTArray_Impl, etc
+#include "mozilla/TimeStamp.h"
+#include "LayerManagerOGLProgram.h"
 
 namespace mozilla {
 namespace gl {
 class GLContext;
 }
 namespace layers {
 
-class ShaderProgramOGL;
-
 const double kFpsWindowMs = 250.0;
 const size_t kNumFrameTimeStamps = 16;
 struct FPSCounter {
   FPSCounter() : mCurrentFrameIndex(0) {
       mFrames.SetLength(kNumFrameTimeStamps);
   }
 
   // We keep a circular buffer of the time points at which the last K
--- a/gfx/layers/opengl/GLManager.cpp
+++ b/gfx/layers/opengl/GLManager.cpp
@@ -1,27 +1,13 @@
-/* -*- 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 "GLManager.h"
-#include "CompositorOGL.h"              // for CompositorOGL
-#include "GLContext.h"                  // for GLContext
-#include "LayerManagerOGL.h"            // for LayerManagerOGL
-#include "Layers.h"                     // for LayerManager
-#include "mozilla/Assertions.h"         // for MOZ_CRASH
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/layers/Compositor.h"  // for Compositor
+#include "LayerManagerOGL.h"
+#include "CompositorOGL.h"
 #include "mozilla/layers/LayerManagerComposite.h"
-#include "mozilla/layers/LayersTypes.h"
-#include "mozilla/mozalloc.h"           // for operator new, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsISupportsImpl.h"            // for LayerManager::AddRef, etc
+#include "GLContext.h"
 
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
 class GLManagerLayerManager : public GLManager
 {
--- a/gfx/layers/opengl/GLManager.h
+++ b/gfx/layers/opengl/GLManager.h
@@ -1,28 +1,24 @@
 /* -*- 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_GLMANAGER_H
 #define MOZILLA_GFX_GLMANAGER_H
 
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat
-#include "LayerManagerOGLProgram.h"
+#include "LayerManagerOGL.h"
 
 namespace mozilla {
 namespace gl {
 class GLContext;
 }
-
 namespace layers {
 
-class LayerManager;
-
 /**
  * Minimal interface to allow widgets to draw using OpenGL. Abstracts
  * LayerManagerOGL and CompositorOGL. Call CreateGLManager with either a
  * LayerManagerOGL or a LayerManagerComposite backed by a CompositorOGL.
  */
 class GLManager
 {
 public:
--- a/gfx/layers/opengl/ImageLayerOGL.cpp
+++ b/gfx/layers/opengl/ImageLayerOGL.cpp
@@ -1,50 +1,34 @@
 /* -*- 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 "gfxSharedImageSurface.h"
+
+#include "ImageContainer.h" // for PlanarYCBCRImage
+#include "ipc/AutoOpenSurface.h"
 #include "ImageLayerOGL.h"
-#include <stdint.h>                     // for uint32_t
-#include "mozilla-config.h"             // for GL_PROVIDER_GLX
-#include "GLDefs.h"                     // for LOCAL_GL_TEXTURE_2D, etc
-#include "ImageContainer.h"             // for CairoImage, etc
-#include "ImageTypes.h"                 // for ImageFormat::CAIRO_SURFACE, etc
-#include "SharedTextureImage.h"         // for SharedTextureImage::Data, etc
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxUtils.h"                   // for NextPowerOfTwo
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat
-#include "mozilla/layers/LayersTypes.h"
-#include "nsAutoRef.h"                  // for nsCountedRef, nsAutoRefBase
-#include "nsCOMPtr.h"                   // for nsCOMPtr, already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION, NS_ERROR
-#include "nsIRunnable.h"                // for nsIRunnable
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
-#include "nsThreadUtils.h"              // for nsRunnable
-#include "nscore.h"                     // for NS_IMETHOD
-#include "LayerManagerOGL.h"            // for LayerOGL::GLContext, etc
+#include "gfxImageSurface.h"
+#include "gfxUtils.h"
+#include "yuv_convert.h"
+#include "GLContextProvider.h"
 #if defined(GL_PROVIDER_GLX)
 # include "GLXLibrary.h"
 # include "gfxXlibSurface.h"
 #endif
+#include "SharedTextureImage.h"
 
 using namespace mozilla::gfx;
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
-class Layer;
-
 /**
  * This is an event used to unref a GLContext on the main thread and
  * optionally delete a texture associated with that context.
  */
 class TextureDeleter : public nsRunnable {
 public:
   TextureDeleter(already_AddRefed<GLContext> aContext,
                  GLuint aTexture)
--- a/gfx/layers/opengl/ImageLayerOGL.h
+++ b/gfx/layers/opengl/ImageLayerOGL.h
@@ -1,37 +1,30 @@
 /* -*- 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_IMAGELAYEROGL_H
 #define GFX_IMAGELAYEROGL_H
 
-#include "GLContext.h"                  // for GLContext
-#include "GLContextTypes.h"             // for GLuint
-#include "ImageContainer.h"             // for ImageBackendData, etc
-#include "ImageLayers.h"                // for ImageLayer
-#include "LayerManagerOGL.h"            // for LayerOGL
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
-#include "mozilla/Mutex.h"              // for Mutex
-#include "mozilla/mozalloc.h"           // for operator delete
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsISupportsImpl.h"            // for TextureRecycleBin::Release, etc
-#include "nsTArray.h"                   // for nsTArray
-#include "opengl/LayerManagerOGLProgram.h"  // for ShaderProgramType, etc
+#include "mozilla/layers/PLayerTransaction.h"
 
-struct nsIntPoint;
+#include "LayerManagerOGL.h"
+#include "ImageLayers.h"
+#include "ImageContainer.h"
+#include "yuv_convert.h"
+#include "mozilla/Mutex.h"
 
 namespace mozilla {
 namespace layers {
 
+class CairoImage;
+class PlanarYCbCrImage;
 class BlobYCbCrSurface;
-class Layer;
 
 /**
  * This class wraps a GL texture. It includes a GLContext reference
  * so we can use to free the texture when destroyed. The implementation
  * makes sure to always free the texture on the main thread, even if the
  * destructor runs on another thread.
  *
  * We ensure that the GLContext reference is only addrefed and released
--- a/gfx/layers/opengl/LayerManagerOGL.cpp
+++ b/gfx/layers/opengl/LayerManagerOGL.cpp
@@ -1,57 +1,50 @@
 /* -*- 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 "LayerManagerOGL.h"
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint32_t, uint8_t, etc
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "CanvasLayerOGL.h"             // for CanvasLayerOGL
-#include "ColorLayerOGL.h"              // for ColorLayerOGL
-#include "Composer2D.h"                 // for Composer2D
-#include "ContainerLayerOGL.h"          // for ContainerLayerOGL
-#include "FPSCounter.h"                 // for FPSState, FPSCounter
-#include "GLContext.h"                  // for GLContext, etc
-#include "GLContextProvider.h"          // for GLContextProvider
-#include "GeckoProfilerFunc.h"          // for TimeStamp
-#include "GeckoProfiler.h"              // for PROFILER_LABEL
-#include "ImageLayerOGL.h"              // for ImageLayerOGL
-#include "ImageLayers.h"                // for ImageLayer
-#include "ThebesLayerOGL.h"             // for ThebesLayerOGL
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "gfxCrashReporterUtils.h"      // for ScopedGfxFeatureReporter
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPlatform.h"                // for gfxPlatform
-#include "gfxRect.h"                    // for gfxRect
-#include "gfxUtils.h"                   // for NextPowerOfTwo, gfxUtils, etc
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Preferences.h"        // for Preferences
-#include "mozilla/TimeStamp.h"          // for TimeStamp
-#include "mozilla/Util.h"               // for ArrayLength
-#include "mozilla/gfx/2D.h"             // for DrawTarget
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsIConsoleService.h"          // for nsIConsoleService, etc
-#include "nsIWidget.h"                  // for nsIWidget
-#include "nsLiteralString.h"            // for NS_LITERAL_STRING
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsServiceManagerUtils.h"      // for do_GetService
-#include "nsString.h"                   // for nsAutoCString, nsString, etc
-#include "LayerManagerOGLProgram.h"     // for ShaderProgramOGL, etc
-#ifdef XP_WIN
-#include "prenv.h"                      // for PR_GetEnv
-#endif
+
+#include "mozilla/layers/PLayerTransaction.h"
+#include <algorithm>
+
+/* This must occur *after* layers/PLayerTransaction.h to avoid typedefs conflicts. */
+#include "mozilla/Util.h"
+
+#include "Composer2D.h"
+#include "ThebesLayerOGL.h"
+#include "ContainerLayerOGL.h"
+#include "ImageLayerOGL.h"
+#include "ColorLayerOGL.h"
+#include "CanvasLayerOGL.h"
+#include "mozilla/TimeStamp.h"
+#include "mozilla/Preferences.h"
+#include "TexturePoolOGL.h"
+
+#include "gfxContext.h"
+#include "gfxUtils.h"
+#include "gfxPlatform.h"
+#include "nsIWidget.h"
+
+#include "GLContext.h"
+#include "GLContextProvider.h"
+#include "Composer2D.h"
+#include "FPSCounter.h"
+
+#include "nsIServiceManager.h"
+#include "nsIConsoleService.h"
+
+#include "gfxCrashReporterUtils.h"
+
+#include "GeckoProfiler.h"
+
 #ifdef MOZ_WIDGET_ANDROID
 #include <android/log.h>
-#include "TexturePoolOGL.h"
 #endif
 #ifdef XP_MACOSX
 #include "gfxPlatformMac.h"
 #endif
 
 namespace mozilla {
 namespace layers {
 
--- a/gfx/layers/opengl/LayerManagerOGL.h
+++ b/gfx/layers/opengl/LayerManagerOGL.h
@@ -1,63 +1,41 @@
 /* -*- 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 <sys/types.h>                  // for int32_t
-#include "GLDefs.h"                     // for GLuint, GLenum, GLintptr, etc
-#include "LayerManagerOGLProgram.h"     // for ShaderProgramOGL, etc
 #include "Layers.h"
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE, MOZ_FINAL
-#include "mozilla/RefPtr.h"             // for TemporaryRef
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat, etc
-#include "mozilla/layers/CompositorTypes.h"  // for MaskType::MaskNone, etc
-#include "mozilla/layers/LayersTypes.h"  // for LayersBackend, etc
-#include "nsAString.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr, nsAutoPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION, NS_WARNING
-#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsRegion.h"                   // for nsIntRegion
-#include "nsSize.h"                     // for nsIntSize
-#include "nsTArray.h"                   // for nsTArray, nsTArray_Impl, etc
-#include "nsThreadUtils.h"              // for nsRunnable
-#include "nscore.h"                     // for NS_IMETHOD, nsAString, etc
+#include "LayerManagerOGLProgram.h"
+
+#include "mozilla/TimeStamp.h"
+#include "nsPoint.h"
+
 #ifdef XP_WIN
 #include <windows.h>
 #endif
 
 #define BUFFER_OFFSET(i) ((char *)nullptr + (i))
 
-class gfx3DMatrix;
-class gfxASurface;
-class gfxContext;
-class nsIWidget;
-struct nsIntPoint;
+#include "gfxContext.h"
+#include "gfx3DMatrix.h"
+#include "nsIWidget.h"
+#include "GLContextTypes.h"
+#include "GLDefs.h"
 
 namespace mozilla {
 namespace gl {
 class GLContext;
 }
-namespace gfx {
-class DrawTarget;
-}
 namespace layers {
 
 class Composer2D;
-class ImageLayer;
 class LayerOGL;
 class ThebesLayerComposite;
 class ContainerLayerComposite;
 class ImageLayerComposite;
 class CanvasLayerComposite;
 class ColorLayerComposite;
 struct FPSState;
 
--- a/gfx/layers/opengl/LayerManagerOGLProgram.cpp
+++ b/gfx/layers/opengl/LayerManagerOGLProgram.cpp
@@ -1,29 +1,21 @@
 /* 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 "LayerManagerOGLProgram.h"
-#include <stdint.h>                     // for uint32_t
-#include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPoint.h"                   // for gfxIntSize, gfxPoint, etc
-#include "gfxRect.h"                    // for gfxRect
-#include "mozilla/DebugOnly.h"          // for DebugOnly
-#include "nsAString.h"
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsString.h"                   // for nsAutoCString
-#include "prenv.h"                      // for PR_GetEnv
+
+#include "LayerManagerOGLShaders.h"
 #include "LayerManagerOGL.h"
-#include "LayerManagerOGLShaders.h"
-#include "Layers.h"
+
 #include "GLContext.h"
 
-struct gfxRGBA;
-
 namespace mozilla {
 namespace layers {
 
 typedef ProgramProfileOGL::Argument Argument;
 
 // helper methods for GetProfileFor
 void
 AddCommonArgs(ProgramProfileOGL& aProfile)
--- a/gfx/layers/opengl/LayerManagerOGLProgram.h
+++ b/gfx/layers/opengl/LayerManagerOGLProgram.h
@@ -1,31 +1,31 @@
 /* -*- 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_LAYERMANAGEROGLPROGRAM_H
 #define GFX_LAYERMANAGEROGLPROGRAM_H
 
-#include "GLDefs.h"                     // for GLint, GLenum, GLuint, etc
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/gfx/Matrix.h"         // for Matrix4x4
-#include "mozilla/gfx/Rect.h"           // for Rect
-#include "mozilla/gfx/Types.h"
-#include "nsDebug.h"                    // for NS_ASSERTION
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsTArray.h"                   // for nsTArray
+#include <string.h>
+
+#include "prenv.h"
+
+#include "nsString.h"
+#include "nsTArray.h"
+#include "GLContextTypes.h"
+#include "GLDefs.h"
+#include "gfx3DMatrix.h"
+#include "mozilla/layers/LayersTypes.h"
 #include "mozilla/layers/CompositorTypes.h"
-
-struct gfxRGBA;
+#include "gfxColor.h"
+#include "mozilla/gfx/Matrix.h"
+#include "mozilla/RefPtr.h"
+#include "gfxASurface.h"
 
 namespace mozilla {
 namespace gl {
 class GLContext;
 }
 namespace layers {
 
 class Layer;
--- a/gfx/layers/opengl/TextureClientOGL.cpp
+++ b/gfx/layers/opengl/TextureClientOGL.cpp
@@ -1,26 +1,24 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/TextureClientOGL.h"
-#include "GLContext.h"                  // for GLContext, etc
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/layers/ISurfaceAllocator.h"
-#include "nsSize.h"                     // for nsIntSize
+#include "mozilla/layers/CompositableClient.h"
+#include "mozilla/layers/CompositableForwarder.h"
+#include "GLContext.h"
+#include "gfxipc/ShadowLayerUtils.h"
 
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
-class CompositableForwarder;
-
 SharedTextureClientOGL::SharedTextureClientOGL()
 : mHandle(0), mIsCrossProcess(false), mInverted(false)
 {
 }
 
 SharedTextureClientOGL::~SharedTextureClientOGL()
 {
   // the data is released by the host
--- a/gfx/layers/opengl/TextureClientOGL.h
+++ b/gfx/layers/opengl/TextureClientOGL.h
@@ -1,31 +1,28 @@
 /* -*- 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_TEXTURECLIENTOGL_H
 #define MOZILLA_GFX_TEXTURECLIENTOGL_H
 
-#include "GLContext.h"                  // for SharedTextureHandle, etc
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/gfx/Point.h"          // for IntSize
-#include "mozilla/layers/CompositorTypes.h"
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
-#include "mozilla/layers/TextureClient.h"  // for DeprecatedTextureClient, etc
+#include "mozilla/layers/TextureClient.h"
+#include "ISurfaceAllocator.h" // For IsSurfaceDescriptorValid
+#include "GLContext.h" // For SharedTextureHandle
+
 #ifdef MOZ_WIDGET_GONK
 #include <ui/GraphicBuffer.h>
 #endif
 
 namespace mozilla {
 namespace layers {
 
-class CompositableForwarder;
+
 
 /**
  * A TextureClient implementation to share TextureMemory that is already
  * on the GPU, for the OpenGL backend.
  */
 class SharedTextureClientOGL : public TextureClient
 {
 public:
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -1,45 +1,34 @@
 /* -*- 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 "TextureHostOGL.h"
-#include "GLContext.h"                  // for GLContext, etc
-#include "SharedSurface.h"              // for SharedSurface
-#include "SharedSurfaceEGL.h"           // for SharedSurface_EGLImage
-#include "SharedSurfaceGL.h"            // for SharedSurface_GLTexture, etc
-#include "SurfaceStream.h"              // for SurfaceStream
-#include "SurfaceTypes.h"               // for SharedSurfaceType, etc
-#include "TiledLayerBuffer.h"           // for TILEDLAYERBUFFER_TILE_SIZE
-#include "gfx2DGlue.h"                  // for ContentForFormat, etc
-#include "gfxImageSurface.h"            // for gfxImageSurface
-#include "gfxPoint.h"                   // for gfxIntSize
-#include "gfxReusableSurfaceWrapper.h"  // for gfxReusableSurfaceWrapper
-#include "ipc/AutoOpenSurface.h"        // for AutoOpenSurface
-#include "mozilla/gfx/2D.h"             // for DataSourceSurface
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/layers/CompositorOGL.h"  // for CompositorOGL
-#include "mozilla/layers/ISurfaceAllocator.h"
+#include "ipc/AutoOpenSurface.h"
+#include "gfx2DGlue.h"
 #include "mozilla/layers/YCbCrImageDataSerializer.h"
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRegion.h"                   // for nsIntRegion
+#include "GLContext.h"
+#include "gfxImageSurface.h"
+#include "SurfaceStream.h"
+#include "SharedSurface.h"
+#include "SharedSurfaceGL.h"
+#include "SharedSurfaceEGL.h"
 #ifdef XP_MACOSX
 #include "SharedSurfaceIO.h"
 #endif
+#include "mozilla/layers/CompositorOGL.h"
 
 using namespace mozilla::gl;
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
-class Compositor; 
-
 TemporaryRef<DeprecatedTextureHost>
 CreateDeprecatedTextureHostOGL(SurfaceDescriptorType aDescriptorType,
                      uint32_t aDeprecatedTextureHostFlags,
                      uint32_t aTextureFlags)
 {
   RefPtr<DeprecatedTextureHost> result = nullptr;
 
   if (aDescriptorType == SurfaceDescriptor::TYCbCrImage) {
--- a/gfx/layers/opengl/TextureHostOGL.h
+++ b/gfx/layers/opengl/TextureHostOGL.h
@@ -1,63 +1,32 @@
 /* -*- 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_TEXTUREOGL_H
 #define MOZILLA_GFX_TEXTUREOGL_H
 
-#include <stddef.h>                     // for size_t
-#include <stdint.h>                     // for uint64_t
-#include "GLContext.h"                  // for GLContext, etc
-#include "GLContextTypes.h"             // for GLenum, GLuint
-#include "GLDefs.h"                     // for LOCAL_GL_CLAMP_TO_EDGE, etc
-#include "GLTextureImage.h"             // for TextureImage
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "IPCMessageUtils.h"            // for gfxContentType
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
-#include "mozilla/RefPtr.h"             // for RefPtr
-#include "mozilla/gfx/Point.h"          // for IntSize, IntPoint
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat, etc
-#include "mozilla/layers/CompositorTypes.h"  // for TextureFlags
-#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
-#include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_HAVE_LOG
-#include "mozilla/layers/TextureHost.h"  // for DeprecatedTextureHost, etc
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_WARNING
-#include "nsISupportsImpl.h"            // for TextureImage::Release, etc
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
-#include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
-#include "LayerManagerOGLProgram.h"     // for ShaderProgramType, etc
+#include "ImageLayerOGL.h"
+#include "GLContextTypes.h"
+#include "gfx2DGlue.h"
+#include "mozilla/layers/Effects.h"
+#include "gfxReusableSurfaceWrapper.h"
+#include "TiledLayerBuffer.h" // for TILEDLAYERBUFFER_TILE_SIZE
+
 #ifdef MOZ_WIDGET_GONK
 #include <ui/GraphicBuffer.h>
 #endif
 
-class gfxImageSurface;
-class gfxReusableSurfaceWrapper;
-class nsIntRegion;
-struct nsIntPoint;
-
 namespace mozilla {
-namespace gfx {
-class DataSourceSurface;
-class SurfaceStream;
-}
-
 namespace layers {
 
-class Compositor;
+class TextureImageDeprecatedTextureHostOGL;
 class CompositorOGL;
-class TextureImageDeprecatedTextureHostOGL;
 
 /*
  * TextureHost implementations for the OpenGL backend.
  *
  * Note that it is important to be careful about the ownership model with
  * the OpenGL backend, due to some widget limitation on Linux: before
  * the nsBaseWidget associated with our OpenGL context has been completely
  * deleted, every resource belonging to the OpenGL context MUST have been
--- a/gfx/layers/opengl/TexturePoolOGL.cpp
+++ b/gfx/layers/opengl/TexturePoolOGL.cpp
@@ -1,19 +1,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 "TexturePoolOGL.h"
-#include <stdlib.h>                     // for malloc
-#include "GLContext.h"                  // for GLContext
-#include "mozilla/Monitor.h"            // for Monitor, MonitorAutoLock
-#include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsDebug.h"                    // for NS_ASSERTION, NS_ERROR, etc
-#include "nsDeque.h"                    // for nsDeque
+#include "GLContext.h"
+#include "nsDeque.h"
+#include "mozilla/Monitor.h"
 
 #define TEXTURE_POOL_SIZE 10
 
 namespace mozilla {
 namespace gl {
 
 static GLContext* sActiveContext = nullptr;
 
--- a/gfx/layers/opengl/TexturePoolOGL.h
+++ b/gfx/layers/opengl/TexturePoolOGL.h
@@ -1,22 +1,20 @@
 /* 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_TEXTUREPOOLOGL_H
 #define GFX_TEXTUREPOOLOGL_H
 
-#include "GLContextTypes.h"             // for GLuint
+#include "GLContext.h"
 
 namespace mozilla {
 namespace gl {
 
-class GLContext;
-
 // A texture pool for for the on-screen GLContext. The main purpose of this class
 // is to provide the ability to easily allocate an on-screen texture from the
 // content thread. The unfortunate nature of the SurfaceTexture API (see nsSurfaceTexture)
 // necessitates this.
 class TexturePoolOGL
 {
 public:
   // Get a new texture from the pool. Will block
--- a/gfx/layers/opengl/ThebesLayerOGL.cpp
+++ b/gfx/layers/opengl/ThebesLayerOGL.cpp
@@ -1,44 +1,27 @@
 /* -*- 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 "ipc/AutoOpenSurface.h"
+#include "mozilla/layers/PLayerTransaction.h"
+#include "TiledLayerBuffer.h"
+
+/* This must occur *after* layers/PLayerTransaction.h to avoid typedefs conflicts. */
+#include "mozilla/Util.h"
+
+#include "ThebesLayerBuffer.h"
 #include "ThebesLayerOGL.h"
-#include <stdint.h>                     // for uint32_t
-#include <sys/types.h>                  // for int32_t
-#include "mozilla-config.h"             // for MOZ_DUMP_PAINTING
-#include "GLContext.h"                  // for GLContext, etc
-#include "GLContextTypes.h"             // for GLenum
-#include "GLDefs.h"                     // for LOCAL_GL_ONE, LOCAL_GL_BGRA, etc
-#include "GLTextureImage.h"             // for TextureImage, etc
-#include "ThebesLayerBuffer.h"          // for ThebesLayerBuffer, etc
-#include "gfx3DMatrix.h"                // for gfx3DMatrix
-#include "gfxASurface.h"                // for gfxASurface, etc
-#include "gfxColor.h"                   // for gfxRGBA
-#include "gfxContext.h"                 // for gfxContext, etc
-#include "gfxImageSurface.h"            // for gfxImageSurface
+#include "gfxUtils.h"
+#include "gfxTeeSurface.h"
 #include "gfxPlatform.h"
-#include "gfxPoint.h"                   // for gfxPoint
-#include "gfxTeeSurface.h"              // for gfxTeeSurface
-#include "gfxUtils.h"                   // for gfxUtils, etc
-#include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
-#include "mozilla/Util.h"               // for ArrayLength
-#include "mozilla/gfx/BasePoint.h"      // for BasePoint
-#include "mozilla/gfx/BaseRect.h"       // for BaseRect
-#include "mozilla/gfx/BaseSize.h"       // for BaseSize
-#include "mozilla/mozalloc.h"           // for operator new
-#include "nsCOMPtr.h"                   // for already_AddRefed
-#include "nsDebug.h"                    // for NS_ASSERTION, etc
-#include "nsPoint.h"                    // for nsIntPoint
-#include "nsRect.h"                     // for nsIntRect
-#include "nsSize.h"                     // for nsIntSize
-#include "LayerManagerOGL.h"            // for LayerManagerOGL, etc
-#include "LayerManagerOGLProgram.h"     // for ShaderProgramOGL, etc
+
+#include "base/message_loop.h"
 
 namespace mozilla {
 namespace layers {
 
 using gl::GLContext;
 using gl::TextureImage;
 
 static const int ALLOW_REPEAT = ThebesLayerBuffer::ALLOW_REPEAT;
--- a/gfx/layers/opengl/ThebesLayerOGL.h
+++ b/gfx/layers/opengl/ThebesLayerOGL.h
@@ -1,21 +1,22 @@
 /* -*- 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_THEBESLAYEROGL_H
 #define GFX_THEBESLAYEROGL_H
 
-#include "LayerManagerOGL.h"            // for LayerOGL
-#include "Layers.h"                     // for Layer (ptr only), etc
-#include "nsAutoPtr.h"                  // for nsRefPtr
-#include "nsISupportsImpl.h"
-#include "nsRegion.h"                   // for nsIntRegion
+#include "Layers.h"
+#include "LayerManagerOGL.h"
+#include "gfxImageSurface.h"
+#include "GLContext.h"
+#include "base/task.h"
+
 
 namespace mozilla {
 namespace layers {
 
 class ThebesLayerBufferOGL;
 class BasicBufferOGL;
 
 class ThebesLayerOGL : public ThebesLayer, 
--- a/gfx/thebes/gfxBaseSharedMemorySurface.h
+++ b/gfx/thebes/gfxBaseSharedMemorySurface.h
@@ -4,20 +4,20 @@
  * 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_SHARED_MEMORYSURFACE_H
 #define GFX_SHARED_MEMORYSURFACE_H
 
 #include "mozilla/ipc/Shmem.h"
 #include "mozilla/ipc/SharedMemory.h"
-#include "cairo/cairo.h"
 
 #include "gfxASurface.h"
 #include "gfxImageSurface.h"
+#include "cairo.h"
 
 struct SharedImageInfo {
     int32_t width;
     int32_t height;
     int32_t format;
 };
 
 inline SharedImageInfo*
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -12,17 +12,16 @@
 #include "nsIObserver.h"
 
 #include "gfxTypes.h"
 #include "gfxASurface.h"
 #include "gfxColor.h"
 
 #include "qcms.h"
 
-#include "mozilla/gfx/2D.h"
 #include "gfx2DGlue.h"
 #include "mozilla/RefPtr.h"
 #include "GfxInfoCollector.h"
 
 #include "mozilla/layers/CompositorTypes.h"
 
 #ifdef XP_OS2
 #undef OS2EMX_PLAIN_CHAR
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -104,31 +104,29 @@ extern "C" {
 }
 #include "gfxPlatformGtk.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
 #include "gfxUtils.h"
 #include "Layers.h"
 #include "LayerManagerOGL.h"
 #include "GLContextProvider.h"
-#include "mozilla/gfx/2D.h"
 
 #ifdef MOZ_X11
 #include "gfxXlibSurface.h"
 #include "cairo-xlib.h"
 #endif
   
 #include "nsShmImage.h"
 
 #include "nsIDOMWheelEvent.h"
 
 #include "nsWindow.h"
 
 using namespace mozilla;
-using namespace mozilla::gfx;
 using namespace mozilla::widget;
 using namespace mozilla::layers;
 using mozilla::gl::GLContext;
 using mozilla::layers::LayerManagerOGL;
 
 // Don't put more than this many rects in the dirty region, just fluff
 // out to the bounding-box if there are more
 #define MAX_RECTS_IN_REGION 100
@@ -5959,25 +5957,25 @@ nsWindow::GetSurfaceForGdkDrawable(GdkDr
                                     gfxIntSize(aSize.width, aSize.height));
     }
 
     return result.forget();
 }
 #endif
 
 #if defined(MOZ_WIDGET_GTK2)
-TemporaryRef<DrawTarget>
+TemporaryRef<gfx::DrawTarget>
 nsWindow::StartRemoteDrawing()
 {
   gfxASurface *surf = GetThebesSurface();
   if (!surf) {
     return nullptr;
   }
 
-  IntSize size(surf->GetSize().width, surf->GetSize().height);
+  gfx::IntSize size(surf->GetSize().width, surf->GetSize().height);
   if (size.width <= 0 || size.height <= 0) {
     return nullptr;
   }
 
   return gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(surf, size);
 }
 #endif
 
--- a/widget/gtk2/nsWindow.h
+++ b/widget/gtk2/nsWindow.h
@@ -31,17 +31,16 @@
 #endif /* MOZ_X11 */
 
 #ifdef ACCESSIBILITY
 #include "mozilla/a11y/Accessible.h"
 #endif
 
 #include "nsGtkIMModule.h"
 
-#undef LOG
 #ifdef MOZ_LOGGING
 
 // make sure that logging is enabled before including prlog.h
 #define FORCE_PR_LOG
 
 #include "prlog.h"
 #include "nsTArray.h"
 
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -68,17 +68,16 @@
 #include <commctrl.h>
 #include <unknwn.h>
 #include <psapi.h>
 
 #include "prlog.h"
 #include "prtime.h"
 #include "prprf.h"
 #include "prmem.h"
-#include "prenv.h"
 
 #include "mozilla/WidgetTraceEvent.h"
 #include "nsIAppShell.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsITheme.h"
 #include "nsIObserverService.h"
 #include "nsIScreenManager.h"
--- a/xpcom/glue/nsThreadUtils.h
+++ b/xpcom/glue/nsThreadUtils.h
@@ -4,17 +4,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 nsThreadUtils_h__
 #define nsThreadUtils_h__
 
 #include "prthread.h"
 #include "prinrval.h"
-#include "nscore.h"
 #include "nsIThreadManager.h"
 #include "nsIThread.h"
 #include "nsIRunnable.h"
 #include "nsICancelableRunnable.h"
 #include "nsStringGlue.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "mozilla/threads/nsThreadIDs.h"