Backed out 6 changesets (bug 877115) for mochitest-1 and reftest orange on this CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Mon, 16 Dec 2013 16:33:07 -0800
changeset 160730 2dc6642eba5d2e5f1eb1a3b75d9be5d5051e19b5
parent 160729 2212cbf3e7ca3f431af9fb73e84719829d99e5ec
child 160731 ac84c96bc4dfdae3ac1f8fbbe86f6a343dd58b1d
push id37685
push userkwierso@gmail.com
push dateTue, 17 Dec 2013 00:33:24 +0000
treeherdermozilla-inbound@2dc6642eba5d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs877115
milestone29.0a1
backs out65ad9d8860d609cf6e9816912ef246b0e2a76088
bf8095c168fbd39add684831dabffa8a21ddd162
290ad58636151001326b02acef73b03126cfd152
4488ec28910eee8aadb9b1557382094eb196d1de
45f8859c6fd6a01d4264b5edd89f925a679814d7
111cc426fa9e98a09b2977d1e119eeb1f0767c5e
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
Backed out 6 changesets (bug 877115) for mochitest-1 and reftest orange on this CLOSED TREE Backed out changeset 65ad9d8860d6 (bug 877115) Backed out changeset bf8095c168fb (bug 877115) Backed out changeset 290ad5863615 (bug 877115) Backed out changeset 4488ec28910e (bug 877115) Backed out changeset 45f8859c6fd6 (bug 877115) Backed out changeset 111cc426fa9e (bug 877115)
gfx/gl/GLBlitHelper.cpp
gfx/gl/GLBlitHelper.h
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextProviderCGL.mm
gfx/gl/GLContextProviderEGL.cpp
gfx/gl/GLContextProviderWGL.cpp
gfx/gl/GLScreenBuffer.cpp
gfx/gl/GLScreenBuffer.h
gfx/gl/GLUploadHelpers.h
gfx/gl/SharedSurface.h
gfx/gl/SharedSurfaceANGLE.cpp
gfx/gl/SharedSurfaceANGLE.h
gfx/gl/SharedSurfaceEGL.cpp
gfx/gl/SharedSurfaceEGL.h
gfx/gl/SharedSurfaceGL.cpp
gfx/gl/SharedSurfaceGL.h
gfx/gl/SharedSurfaceGralloc.cpp
gfx/gl/SharedSurfaceGralloc.h
gfx/gl/SharedSurfaceIO.cpp
gfx/gl/SharedSurfaceIO.h
gfx/gl/SurfaceFactory.cpp
gfx/gl/SurfaceFactory.h
gfx/gl/SurfaceStream.cpp
gfx/gl/SurfaceStream.h
gfx/layers/CopyableCanvasLayer.cpp
gfx/layers/d3d10/CanvasLayerD3D10.cpp
gfx/layers/d3d9/CanvasLayerD3D9.cpp
gfx/layers/opengl/TextureHostOGL.cpp
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -9,34 +9,34 @@
 #include "ScopedGLHelpers.h"
 #include "mozilla/Preferences.h"
 
 namespace mozilla {
 namespace gl {
 
 static void
 RenderbufferStorageBySamples(GLContext* aGL, GLsizei aSamples,
-                             GLenum aInternalFormat, const gfx::IntSize& aSize)
+                             GLenum aInternalFormat, const gfxIntSize& aSize)
 {
     if (aSamples) {
         aGL->fRenderbufferStorageMultisample(LOCAL_GL_RENDERBUFFER,
                                              aSamples,
                                              aInternalFormat,
                                              aSize.width, aSize.height);
     } else {
         aGL->fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
                                   aInternalFormat,
                                   aSize.width, aSize.height);
     }
 }
 
 
 GLuint
 CreateTexture(GLContext* aGL, GLenum aInternalFormat, GLenum aFormat,
-              GLenum aType, const gfx::IntSize& aSize)
+              GLenum aType, const gfxIntSize& aSize)
 {
     GLuint tex = 0;
     aGL->fGenTextures(1, &tex);
     ScopedBindTexture autoTex(aGL, tex);
 
     aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
     aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
     aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
@@ -52,47 +52,47 @@ CreateTexture(GLContext* aGL, GLenum aIn
                      nullptr);
 
     return tex;
 }
 
 
 GLuint
 CreateTextureForOffscreen(GLContext* aGL, const GLFormats& aFormats,
-                          const gfx::IntSize& aSize)
+                          const gfxIntSize& aSize)
 {
     MOZ_ASSERT(aFormats.color_texInternalFormat);
     MOZ_ASSERT(aFormats.color_texFormat);
     MOZ_ASSERT(aFormats.color_texType);
 
     return CreateTexture(aGL,
                          aFormats.color_texInternalFormat,
                          aFormats.color_texFormat,
                          aFormats.color_texType,
                          aSize);
 }
 
 
 GLuint
 CreateRenderbuffer(GLContext* aGL, GLenum aFormat, GLsizei aSamples,
-                   const gfx::IntSize& aSize)
+                   const gfxIntSize& aSize)
 {
     GLuint rb = 0;
     aGL->fGenRenderbuffers(1, &rb);
     ScopedBindRenderbuffer autoRB(aGL, rb);
 
     RenderbufferStorageBySamples(aGL, aSamples, aFormat, aSize);
 
     return rb;
 }
 
 
 void
 CreateRenderbuffersForOffscreen(GLContext* aGL, const GLFormats& aFormats,
-                                const gfx::IntSize& aSize, bool aMultisample,
+                                const gfxIntSize& aSize, bool aMultisample,
                                 GLuint* aColorMSRB, GLuint* aDepthRB,
                                 GLuint* aStencilRB)
 {
     GLsizei samples = aMultisample ? aFormats.samples : 0;
     if (aColorMSRB) {
         MOZ_ASSERT(aFormats.samples > 0);
         MOZ_ASSERT(aFormats.color_rbFormat);
 
@@ -346,17 +346,17 @@ GLBlitHelper::InitTexQuadProgram(GLenum 
                               LOCAL_GL_FLOAT,
                               false,
                               0,
                               nullptr);
     return true;
 }
 
 bool
-GLBlitHelper::UseTexQuadProgram(GLenum target, const gfx::IntSize& srcSize)
+GLBlitHelper::UseTexQuadProgram(GLenum target, const gfxIntSize& srcSize)
 {
     if (!InitTexQuadProgram(target)) {
         return false;
     }
 
     if (target == LOCAL_GL_TEXTURE_RECTANGLE_ARB) {
         GLint texCoordMultLoc = mGL->fGetUniformLocation(mTex2DRectBlit_Program, "uTexCoordMult");
         MOZ_ASSERT(texCoordMultLoc != -1, "uniform not found");
@@ -392,18 +392,18 @@ GLBlitHelper::DeleteTexBlitProgram()
     if (mTex2DRectBlit_Program) {
         mGL->fDeleteProgram(mTex2DRectBlit_Program);
         mTex2DRectBlit_Program = 0;
     }
 }
 
 void
 GLBlitHelper::BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
-                                        const gfx::IntSize& srcSize,
-                                        const gfx::IntSize& destSize)
+                                        const gfxIntSize& srcSize,
+                                        const gfxIntSize& destSize)
 {
     MOZ_ASSERT(!srcFB || mGL->fIsFramebuffer(srcFB));
     MOZ_ASSERT(!destFB || mGL->fIsFramebuffer(destFB));
 
     MOZ_ASSERT(mGL->IsSupported(GLFeature::framebuffer_blit));
 
     ScopedBindFramebuffer boundFB(mGL);
     ScopedGLState scissor(mGL, LOCAL_GL_SCISSOR_TEST, false);
@@ -414,18 +414,18 @@ GLBlitHelper::BlitFramebufferToFramebuff
     mGL->fBlitFramebuffer(0, 0,  srcSize.width,  srcSize.height,
                           0, 0, destSize.width, destSize.height,
                           LOCAL_GL_COLOR_BUFFER_BIT,
                           LOCAL_GL_NEAREST);
 }
 
 void
 GLBlitHelper::BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
-                                        const gfx::IntSize& srcSize,
-                                        const gfx::IntSize& destSize,
+                                        const gfxIntSize& srcSize,
+                                        const gfxIntSize& destSize,
                                         const GLFormats& srcFormats)
 {
     MOZ_ASSERT(!srcFB || mGL->fIsFramebuffer(srcFB));
     MOZ_ASSERT(!destFB || mGL->fIsFramebuffer(destFB));
 
     if (mGL->IsSupported(GLFeature::framebuffer_blit)) {
         BlitFramebufferToFramebuffer(srcFB, destFB,
                                      srcSize, destSize);
@@ -438,18 +438,18 @@ GLBlitHelper::BlitFramebufferToFramebuff
     BlitFramebufferToTexture(srcFB, tex, srcSize, srcSize);
     BlitTextureToFramebuffer(tex, destFB, srcSize, destSize);
 
     mGL->fDeleteTextures(1, &tex);
 }
 
 void
 GLBlitHelper::BlitTextureToFramebuffer(GLuint srcTex, GLuint destFB,
-                                    const gfx::IntSize& srcSize,
-                                    const gfx::IntSize& destSize,
+                                    const gfxIntSize& srcSize,
+                                    const gfxIntSize& destSize,
                                     GLenum srcTarget)
 {
     MOZ_ASSERT(mGL->fIsTexture(srcTex));
     MOZ_ASSERT(!destFB || mGL->fIsFramebuffer(destFB));
 
     if (mGL->IsSupported(GLFeature::framebuffer_blit)) {
         ScopedFramebufferForTexture srcWrapper(mGL, srcTex, srcTarget);
         MOZ_ASSERT(srcWrapper.IsComplete());
@@ -558,18 +558,18 @@ GLBlitHelper::BlitTextureToFramebuffer(G
 
     mGL->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, boundBuffer);
 
     mGL->fUseProgram(boundProgram);
 }
 
 void
 GLBlitHelper::BlitFramebufferToTexture(GLuint srcFB, GLuint destTex,
-                                    const gfx::IntSize& srcSize,
-                                    const gfx::IntSize& destSize,
+                                    const gfxIntSize& srcSize,
+                                    const gfxIntSize& destSize,
                                     GLenum destTarget)
 {
     MOZ_ASSERT(!srcFB || mGL->fIsFramebuffer(srcFB));
     MOZ_ASSERT(mGL->fIsTexture(destTex));
 
     if (mGL->IsSupported(GLFeature::framebuffer_blit)) {
         ScopedFramebufferForTexture destWrapper(mGL, destTex, destTarget);
 
@@ -585,18 +585,18 @@ GLBlitHelper::BlitFramebufferToTexture(G
     mGL->fCopyTexSubImage2D(destTarget, 0,
                        0, 0,
                        0, 0,
                        srcSize.width, srcSize.height);
 }
 
 void
 GLBlitHelper::BlitTextureToTexture(GLuint srcTex, GLuint destTex,
-                                const gfx::IntSize& srcSize,
-                                const gfx::IntSize& destSize,
+                                const gfxIntSize& srcSize,
+                                const gfxIntSize& destSize,
                                 GLenum srcTarget, GLenum destTarget)
 {
     MOZ_ASSERT(mGL->fIsTexture(srcTex));
     MOZ_ASSERT(mGL->fIsTexture(destTex));
 
     // Generally, just use the CopyTexSubImage path
     ScopedFramebufferForTexture srcWrapper(mGL, srcTex, srcTarget);
 
--- a/gfx/gl/GLBlitHelper.h
+++ b/gfx/gl/GLBlitHelper.h
@@ -6,61 +6,62 @@
 
 #ifndef GLBLITHELPER_H_
 #define GLBLITHELPER_H_
 
 #include "GLContextTypes.h"
 #include "GLConsts.h"
 #include "nsSize.h"
 #include "mozilla/Attributes.h"
-#include "mozilla/gfx/Point.h"
+
+struct nsIntSize;
 
 namespace mozilla {
 namespace gl {
 
 class GLContext;
 
 /**
  * Helper function that creates a 2D texture aSize.width x aSize.height with
  * storage type specified by aFormats. Returns GL texture object id.
  *
  * See mozilla::gl::CreateTexture.
  */
 GLuint CreateTextureForOffscreen(GLContext* aGL, const GLFormats& aFormats,
-                                 const gfx::IntSize& aSize);
+                                 const gfxIntSize& aSize);
 
 /**
  * Helper function that creates a 2D texture aSize.width x aSize.height with
  * storage type aInternalFormat. Returns GL texture object id.
  *
  * Initialize textyre parameters to:
  *    GL_TEXTURE_MIN_FILTER = GL_LINEAR
  *    GL_TEXTURE_MAG_FILTER = GL_LINEAR
  *    GL_TEXTURE_WRAP_S = GL_CLAMP_TO_EDGE
  *    GL_TEXTURE_WRAP_T = GL_CLAMP_TO_EDGE
  */
 GLuint CreateTexture(GLContext* aGL, GLenum aInternalFormat, GLenum aFormat,
-                     GLenum aType, const gfx::IntSize& aSize);
+                     GLenum aType, const gfxIntSize& aSize);
 
 /**
  * Helper function to create, potentially, multisample render buffers suitable
  * for offscreen rendering. Buffers of size aSize.width x aSize.height with
  * storage specified by aFormat. returns GL render buffer object id.
  */
 GLuint CreateRenderbuffer(GLContext* aGL, GLenum aFormat, GLsizei aSamples,
-                          const gfx::IntSize& aSize);
+                          const gfxIntSize& aSize);
 
 /**
  * Helper function to create, potentially, multisample render buffers suitable
  * for offscreen rendering. Buffers of size aSize.width x aSize.height with
  * storage specified by aFormats. GL render buffer object ids are returned via
  * aColorMSRB, aDepthRB, and aStencilRB
  */
 void CreateRenderbuffersForOffscreen(GLContext* aGL, const GLFormats& aFormats,
-                                     const gfx::IntSize& aSize, bool aMultisample,
+                                     const gfxIntSize& aSize, bool aMultisample,
                                      GLuint* aColorMSRB, GLuint* aDepthRB,
                                      GLuint* aStencilRB);
 
 
 /** Buffer blitting helper */
 class GLBlitHelper MOZ_FINAL
 {
     // The GLContext is the sole owner of the GLBlitHelper.
@@ -71,46 +72,46 @@ class GLBlitHelper MOZ_FINAL
     GLuint mTex2DBlit_FragShader;
     GLuint mTex2DRectBlit_FragShader;
     GLuint mTex2DBlit_Program;
     GLuint mTex2DRectBlit_Program;
 
     void UseBlitProgram();
     void SetBlitFramebufferForDestTexture(GLuint aTexture);
 
-    bool UseTexQuadProgram(GLenum target, const gfx::IntSize& srcSize);
+    bool UseTexQuadProgram(GLenum target, const nsIntSize& srcSize);
     bool InitTexQuadProgram(GLenum target = LOCAL_GL_TEXTURE_2D);
     void DeleteTexBlitProgram();
 
 public:
 
     GLBlitHelper(GLContext* gl);
     ~GLBlitHelper();
 
     // If you don't have |srcFormats| for the 2nd definition,
     // then you'll need the framebuffer_blit extensions to use
     // the first BlitFramebufferToFramebuffer.
     void BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
-                                      const gfx::IntSize& srcSize,
-                                      const gfx::IntSize& destSize);
+                                      const nsIntSize& srcSize,
+                                      const nsIntSize& destSize);
     void BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
-                                      const gfx::IntSize& srcSize,
-                                      const gfx::IntSize& destSize,
+                                      const nsIntSize& srcSize,
+                                      const nsIntSize& destSize,
                                       const GLFormats& srcFormats);
     void BlitTextureToFramebuffer(GLuint srcTex, GLuint destFB,
-                                  const gfx::IntSize& srcSize,
-                                  const gfx::IntSize& destSize,
+                                  const nsIntSize& srcSize,
+                                  const nsIntSize& destSize,
                                   GLenum srcTarget = LOCAL_GL_TEXTURE_2D);
     void BlitFramebufferToTexture(GLuint srcFB, GLuint destTex,
-                                  const gfx::IntSize& srcSize,
-                                  const gfx::IntSize& destSize,
+                                  const nsIntSize& srcSize,
+                                  const nsIntSize& destSize,
                                   GLenum destTarget = LOCAL_GL_TEXTURE_2D);
     void BlitTextureToTexture(GLuint srcTex, GLuint destTex,
-                              const gfx::IntSize& srcSize,
-                              const gfx::IntSize& destSize,
+                              const nsIntSize& srcSize,
+                              const nsIntSize& destSize,
                               GLenum srcTarget = LOCAL_GL_TEXTURE_2D,
                               GLenum destTarget = LOCAL_GL_TEXTURE_2D);
 };
 
 }
 }
 
 #endif // GLBLITHELPER_H_
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -1490,17 +1490,17 @@ GLContext::AssembleOffscreenFBs(const GL
 
 
 
 bool
 GLContext::PublishFrame()
 {
     MOZ_ASSERT(mScreen);
 
-    if (!mScreen->PublishFrame(ThebesIntSize(OffscreenSize())))
+    if (!mScreen->PublishFrame(OffscreenSize()))
         return false;
 
     return true;
 }
 
 SharedSurface*
 GLContext::RequestFrame()
 {
@@ -2152,29 +2152,29 @@ GLContext::ReadPixelsIntoImageSurface(gf
 
     nsAutoPtr<gfxImageSurface> tempSurf;
     gfxImageSurface* readSurf = nullptr;
     int readPixelSize = 0;
     if (needsTempSurf) {
         if (DebugMode()) {
             NS_WARNING("Needing intermediary surface for ReadPixels. This will be slow!");
         }
-        SurfaceFormat readFormatGFX;
+        ImageFormat readFormatGFX;
 
         switch (readFormat) {
             case LOCAL_GL_RGBA:
             case LOCAL_GL_BGRA: {
-                readFormatGFX = hasAlpha ? FORMAT_B8G8R8A8
-                                         : FORMAT_B8G8R8X8;
+                readFormatGFX = hasAlpha ? gfxImageFormatARGB32
+                                         : gfxImageFormatRGB24;
                 break;
             }
             case LOCAL_GL_RGB: {
                 MOZ_ASSERT(readPixelSize == 2);
                 MOZ_ASSERT(readType == LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV);
-                readFormatGFX = FORMAT_R5G6B5;
+                readFormatGFX = gfxImageFormatRGB16_565;
                 break;
             }
             default: {
                 MOZ_CRASH("Bad read format.");
             }
         }
 
         switch (readType) {
@@ -2193,19 +2193,17 @@ GLContext::ReadPixelsIntoImageSurface(gf
                 readPixelSize = 2;
                 break;
             }
             default: {
                 MOZ_CRASH("Bad read type.");
             }
         }
 
-        tempSurf = new gfxImageSurface(dest->GetSize(),
-                                       gfxImageFormat(readFormatGFX),
-                                       false);
+        tempSurf = new gfxImageSurface(dest->GetSize(), readFormatGFX, false);
         readSurf = tempSurf;
     } else {
         readPixelSize = destPixelSize;
         readSurf = dest;
     }
     MOZ_ASSERT(readPixelSize);
 
     GLint currentPackAlignment = 0;
@@ -2454,25 +2452,25 @@ void
 GLContext::GuaranteeResolve()
 {
     if (mScreen) {
         mScreen->AssureBlitted();
     }
     fFinish();
 }
 
-const gfx::IntSize&
+const gfxIntSize&
 GLContext::OffscreenSize() const
 {
     MOZ_ASSERT(IsOffscreen());
     return mScreen->Size();
 }
 
 bool
-GLContext::CreateScreenBufferImpl(const IntSize& size, const SurfaceCaps& caps)
+GLContext::CreateScreenBufferImpl(const gfxIntSize& size, const SurfaceCaps& caps)
 {
     GLScreenBuffer* newScreen = GLScreenBuffer::Create(this, size, caps);
     if (!newScreen)
         return false;
 
     if (!newScreen->Resize(size)) {
         delete newScreen;
         return false;
@@ -2485,17 +2483,17 @@ GLContext::CreateScreenBufferImpl(const 
     ScopedBindFramebuffer autoFB(this);
 
     mScreen = newScreen;
 
     return true;
 }
 
 bool
-GLContext::ResizeScreenBuffer(const IntSize& size)
+GLContext::ResizeScreenBuffer(const gfxIntSize& size)
 {
     if (!IsOffscreenSizeAllowed(size))
         return false;
 
     return mScreen->Resize(size);
 }
 
 
@@ -2528,17 +2526,17 @@ GLContext::CleanDirtyScreen()
 
 void
 GLContext::EmptyTexGarbageBin()
 {
    TexGarbageBin()->EmptyGarbage();
 }
 
 bool
-GLContext::IsOffscreenSizeAllowed(const IntSize& aSize) const {
+GLContext::IsOffscreenSizeAllowed(const gfxIntSize& aSize) const {
   int32_t biggerDimension = std::max(aSize.width, aSize.height);
   int32_t maxAllowed = std::min(mMaxRenderbufferSize, mMaxTextureSize);
   return biggerDimension <= maxAllowed;
 }
 
 bool
 GLContext::IsOwningThreadCurrent()
 {
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -36,17 +36,16 @@
 #include "nsAutoPtr.h"
 #include "GLContextTypes.h"
 #include "GLTextureImage.h"
 #include "SurfaceTypes.h"
 #include "GLScreenBuffer.h"
 #include "GLContextSymbols.h"
 #include "mozilla/GenericRefCounted.h"
 #include "mozilla/Scoped.h"
-#include "gfx2DGlue.h"
 
 #ifdef DEBUG
 #define MOZ_ENABLE_GL_TRACKING 1
 #endif
 
 class nsIntRegion;
 class nsIRunnable;
 class nsIThread;
@@ -2373,16 +2372,17 @@ public:
 
 
 // -----------------------------------------------------------------------------
 // Everything that isn't standard GL APIs
 protected:
 
     typedef class gfx::SharedSurface SharedSurface;
     typedef gfx::SharedSurfaceType SharedSurfaceType;
+    typedef gfxImageFormat ImageFormat;
     typedef gfx::SurfaceFormat SurfaceFormat;
 
 public:
 
     virtual bool MakeCurrentImpl(bool aForce = false) = 0;
 
 #ifdef MOZ_ENABLE_GL_TRACKING
     static void StaticInit() {
@@ -2488,26 +2488,26 @@ public:
     /*
      * Resize the current offscreen buffer.  Returns true on success.
      * If it returns false, the context should be treated as unusable
      * and should be recreated.  After the resize, the viewport is not
      * changed; glViewport should be called as appropriate.
      *
      * Only valid if IsOffscreen() returns true.
      */
-    virtual bool ResizeOffscreen(const gfx::IntSize& size) {
+    virtual bool ResizeOffscreen(const gfxIntSize& size) {
         return ResizeScreenBuffer(size);
     }
 
     /*
      * Return size of this offscreen context.
      *
      * Only valid if IsOffscreen() returns true.
      */
-    const gfx::IntSize& OffscreenSize() const;
+    const gfxIntSize& OffscreenSize() const;
 
     void BindFB(GLuint fb) {
         fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, fb);
         MOZ_ASSERT(!fb || fIsFramebuffer(fb));
     }
 
     void BindDrawFB(GLuint fb) {
         fBindFramebuffer(LOCAL_GL_DRAW_FRAMEBUFFER_EXT, fb);
@@ -2709,17 +2709,17 @@ public:
         const GLContext* thisShared = this->mSharedContext ? this->mSharedContext
                                                            : this;
         const GLContext* otherShared = other->mSharedContext ? other->mSharedContext
                                                              : other;
 
         return thisShared == otherShared;
     }
 
-    bool InitOffscreen(const gfx::IntSize& size, const SurfaceCaps& caps) {
+    bool InitOffscreen(const gfxIntSize& size, const SurfaceCaps& caps) {
         if (!CreateScreenBuffer(size, caps))
             return false;
 
         MakeCurrent();
         fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
         fScissor(0, 0, size.width, size.height);
         fViewport(0, 0, size.width, size.height);
 
@@ -2730,17 +2730,17 @@ public:
         UpdateGLFormats(mCaps);
         UpdatePixelFormat();
 
         return true;
     }
 
 protected:
     // Note that it does -not- clear the resized buffers.
-    bool CreateScreenBuffer(const gfx::IntSize& size, const SurfaceCaps& caps) {
+    bool CreateScreenBuffer(const gfxIntSize& size, const SurfaceCaps& caps) {
         if (!IsOffscreenSizeAllowed(size))
             return false;
 
         SurfaceCaps tryCaps = caps;
         if (tryCaps.antialias) {
             // AA path
             if (CreateScreenBufferImpl(size, tryCaps))
                 return true;
@@ -2752,21 +2752,21 @@ protected:
 
         if (CreateScreenBufferImpl(size, tryCaps))
             return true;
 
         NS_WARNING("CreateScreenBuffer failed to initialize non-AA context!");
         return false;
     }
 
-    bool CreateScreenBufferImpl(const gfx::IntSize& size,
+    bool CreateScreenBufferImpl(const gfxIntSize& size,
                                 const SurfaceCaps& caps);
 
 public:
-    bool ResizeScreenBuffer(const gfx::IntSize& size);
+    bool ResizeScreenBuffer(const gfxIntSize& size);
 
 protected:
     SurfaceCaps mCaps;
     nsAutoPtr<GLFormats> mGLFormats;
     nsAutoPtr<PixelBufferFormat> mPixelFormat;
 
 public:
     void DetermineCaps();
@@ -2856,17 +2856,17 @@ protected:
 public:
     TextureGarbageBin* TexGarbageBin() {
         MOZ_ASSERT(mTexGarbageBin);
         return mTexGarbageBin;
     }
 
     void EmptyTexGarbageBin();
 
-    bool IsOffscreenSizeAllowed(const gfx::IntSize& aSize) const;
+    bool IsOffscreenSizeAllowed(const gfxIntSize& aSize) const;
 
 protected:
     GLuint mReadTextureImagePrograms[4];
 
     bool InitWithPrefix(const char *prefix, bool trygl);
 
     void InitExtensions();
 
--- a/gfx/gl/GLContextProviderCGL.mm
+++ b/gfx/gl/GLContextProviderCGL.mm
@@ -183,26 +183,26 @@ public:
 
     bool SwapBuffers()
     {
       PROFILER_LABEL("GLContext", "SwapBuffers");
       [mContext flushBuffer];
       return true;
     }
 
-    bool ResizeOffscreen(const gfx::IntSize& aNewSize);
+    bool ResizeOffscreen(const gfxIntSize& aNewSize);
 
     NSOpenGLContext *mContext;
     GLuint mTempTextureName;
 };
 
 bool
-GLContextCGL::ResizeOffscreen(const gfx::IntSize& aNewSize)
+GLContextCGL::ResizeOffscreen(const gfxIntSize& aNewSize)
 {
-    return ResizeScreenBuffer(ThebesIntSize(aNewSize));
+    return ResizeScreenBuffer(aNewSize);
 }
 
 static GLContextCGL *
 GetGlobalContextCGL()
 {
     return static_cast<GLContextCGL*>(GLContextProviderCGL::GetGlobalContext());
 }
 
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -534,17 +534,17 @@ public:
     }
 
     EGLContext Context() {
         return mContext;
     }
 
     bool BindTex2DOffscreen(GLContext *aOffscreen);
     void UnbindTex2DOffscreen(GLContext *aOffscreen);
-    bool ResizeOffscreen(const gfx::IntSize& aNewSize);
+    bool ResizeOffscreen(const gfxIntSize& aNewSize);
     void BindOffscreenFramebuffer();
 
     static already_AddRefed<GLContextEGL>
     CreateEGLPixmapOffscreenContext(const gfxIntSize& size);
 
     static already_AddRefed<GLContextEGL>
     CreateEGLPBufferOffscreenContext(const gfxIntSize& size);
 
@@ -608,19 +608,19 @@ protected:
             return nullptr;
         }
 
         return surface;
     }
 };
 
 bool
-GLContextEGL::ResizeOffscreen(const gfx::IntSize& aNewSize)
+GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
 {
-    return ResizeScreenBuffer(ThebesIntSize(aNewSize));
+	return ResizeScreenBuffer(aNewSize);
 }
 
 static const EGLint kEGLConfigAttribsOffscreenPBuffer[] = {
     LOCAL_EGL_SURFACE_TYPE,    LOCAL_EGL_PBUFFER_BIT,
     LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
     EGL_ATTRIBS_LIST_SAFE_TERMINATION_WORKING_AROUND_BUGS
 };
 
--- a/gfx/gl/GLContextProviderWGL.cpp
+++ b/gfx/gl/GLContextProviderWGL.cpp
@@ -373,17 +373,17 @@ public:
         case NativeGLContext:
             return mContext;
 
         default:
             return nullptr;
         }
     }
 
-    bool ResizeOffscreen(const gfx::IntSize& aNewSize);
+    bool ResizeOffscreen(const gfxIntSize& aNewSize);
 
     HGLRC Context() { return mContext; }
 
 protected:
     friend class GLContextProviderWGL;
 
     HDC mDC;
     HGLRC mContext;
@@ -423,19 +423,19 @@ IsValidSizeForFormat(HDC hDC, int format
         return false;
     if (requested.height > max.height)
         return false;
 
     return true;
 }
 
 bool
-GLContextWGL::ResizeOffscreen(const gfx::IntSize& aNewSize)
+GLContextWGL::ResizeOffscreen(const gfxIntSize& aNewSize)
 {
-    return ResizeScreenBuffer(ThebesIntSize(aNewSize));
+    return ResizeScreenBuffer(aNewSize);
 }
 
 static GLContextWGL *
 GetGlobalContextWGL(const ContextFlags aFlags = ContextFlagsNone)
 {
     return static_cast<GLContextWGL*>(GLContextProviderWGL::GetGlobalContext(aFlags));
 }
 
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -22,17 +22,17 @@
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace gl {
 
 GLScreenBuffer*
 GLScreenBuffer::Create(GLContext* gl,
-                     const gfx::IntSize& size,
+                     const gfxIntSize& size,
                      const SurfaceCaps& caps)
 {
     if (caps.antialias &&
         !gl->IsSupported(GLFeature::framebuffer_multisample))
     {
         return nullptr;
     }
 
@@ -342,18 +342,18 @@ GLScreenBuffer::AssureBlitted()
         MOZ_ASSERT(mDraw->Size() == mRead->Size());
 
         ScopedBindFramebuffer boundFB(mGL);
         ScopedGLState scissor(mGL, LOCAL_GL_SCISSOR_TEST, false);
 
         BindReadFB_Internal(drawFB);
         BindDrawFB_Internal(readFB);
 
-        const gfx::IntSize&  srcSize = mDraw->Size();
-        const gfx::IntSize& destSize = mRead->Size();
+        const gfxIntSize&  srcSize = mDraw->Size();
+        const gfxIntSize& destSize = mRead->Size();
 
         mGL->raw_fBlitFramebuffer(0, 0,  srcSize.width,  srcSize.height,
                                   0, 0, destSize.width, destSize.height,
                                   LOCAL_GL_COLOR_BUFFER_BIT,
                                   LOCAL_GL_NEAREST);
         // Done!
     }
 
@@ -376,17 +376,17 @@ GLScreenBuffer::Morph(SurfaceFactory_GL*
     SurfaceStream* newStream = SurfaceStream::CreateForType(streamType, mGL, mStream);
     MOZ_ASSERT(newStream);
 
     delete mStream;
     mStream = newStream;
 }
 
 void
-GLScreenBuffer::Attach(SharedSurface* surface, const gfx::IntSize& size)
+GLScreenBuffer::Attach(SharedSurface* surface, const gfxIntSize& size)
 {
     ScopedBindFramebuffer autoFB(mGL);
 
     SharedSurface_GL* surf = SharedSurface_GL::Cast(surface);
     if (mRead && SharedSurf())
         SharedSurf()->UnlockProd();
 
     surf->LockProd();
@@ -414,17 +414,17 @@ GLScreenBuffer::Attach(SharedSurface* su
     MOZ_ASSERT(SharedSurf() == surf);
 
     if (!PreserveBuffer()) {
         // DiscardFramebuffer here could help perf on some mobile platforms.
     }
 }
 
 bool
-GLScreenBuffer::Swap(const gfx::IntSize& size)
+GLScreenBuffer::Swap(const gfxIntSize& size)
 {
     SharedSurface* nextSurf = mStream->SwapProducer(mFactory, size);
     if (!nextSurf) {
         SurfaceFactory_Basic basicFactory(mGL, mFactory->Caps());
         nextSurf = mStream->SwapProducer(&basicFactory, size);
         if (!nextSurf)
           return false;
 
@@ -433,37 +433,37 @@ GLScreenBuffer::Swap(const gfx::IntSize&
     MOZ_ASSERT(nextSurf);
 
     Attach(nextSurf, size);
 
     return true;
 }
 
 bool
-GLScreenBuffer::PublishFrame(const gfx::IntSize& size)
+GLScreenBuffer::PublishFrame(const gfxIntSize& size)
 {
     AssureBlitted();
 
     bool good = Swap(size);
     return good;
 }
 
 bool
-GLScreenBuffer::Resize(const gfx::IntSize& size)
+GLScreenBuffer::Resize(const gfxIntSize& size)
 {
     SharedSurface* surface = mStream->Resize(mFactory, size);
     if (!surface)
         return false;
 
     Attach(surface, size);
     return true;
 }
 
 DrawBuffer*
-GLScreenBuffer::CreateDraw(const gfx::IntSize& size)
+GLScreenBuffer::CreateDraw(const gfxIntSize& size)
 {
     GLContext* gl = mFactory->GL();
     const GLFormats& formats = mFactory->Formats();
     const SurfaceCaps& caps = mFactory->DrawCaps();
 
     return DrawBuffer::Create(gl, caps, formats, size);
 }
 
@@ -477,17 +477,17 @@ GLScreenBuffer::CreateRead(SharedSurface
     return ReadBuffer::Create(gl, caps, formats, surf);
 }
 
 
 void
 GLScreenBuffer::Readback(SharedSurface_GL* src, gfxImageSurface* dest)
 {
     MOZ_ASSERT(src && dest);
-    MOZ_ASSERT(ToIntSize(dest->GetSize()) == src->Size());
+    MOZ_ASSERT(dest->GetSize() == src->Size());
     MOZ_ASSERT(dest->Format() == (src->HasAlpha() ? gfxImageFormatARGB32
                                                   : gfxImageFormatRGB24));
 
     mGL->MakeCurrent();
 
     bool needsSwap = src != SharedSurf();
     if (needsSwap) {
         SharedSurf()->UnlockProd();
@@ -509,17 +509,17 @@ GLScreenBuffer::Readback(SharedSurface_G
 }
 
 
 
 DrawBuffer*
 DrawBuffer::Create(GLContext* const gl,
                    const SurfaceCaps& caps,
                    const GLFormats& formats,
-                   const gfx::IntSize& size)
+                   const gfxIntSize& size)
 {
     if (!caps.color) {
         MOZ_ASSERT(!caps.alpha && !caps.depth && !caps.stencil);
 
         // Nothing is needed.
         return nullptr;
     }
 
@@ -676,16 +676,16 @@ ReadBuffer::Attach(SharedSurface_GL* sur
         mGL->AttachBuffersToFB(colorTex, colorRB, 0, 0, mFB, target);
         mGL->mFBOMapping[mFB] = surf;
         MOZ_ASSERT(mGL->IsFramebufferComplete(mFB));
     }
 
     mSurf = surf;
 }
 
-const gfx::IntSize&
+const gfxIntSize&
 ReadBuffer::Size() const
 {
     return mSurf->Size();
 }
 
 } /* namespace gl */
 } /* namespace mozilla */
--- a/gfx/gl/GLScreenBuffer.h
+++ b/gfx/gl/GLScreenBuffer.h
@@ -13,17 +13,17 @@
 */
 
 #ifndef SCREEN_BUFFER_H_
 #define SCREEN_BUFFER_H_
 
 #include "SurfaceTypes.h"
 #include "GLContextTypes.h"
 #include "GLDefs.h"
-#include "mozilla/gfx/Point.h"
+#include "gfxPoint.h"
 
 // Forwards:
 class gfxImageSurface;
 
 namespace mozilla {
     namespace gfx {
         class SurfaceStream;
         class SharedSurface;
@@ -43,44 +43,44 @@ class DrawBuffer
 protected:
     typedef struct gfx::SurfaceCaps SurfaceCaps;
 
 public:
     // Infallible, may return null if unneeded.
     static DrawBuffer* Create(GLContext* const gl,
                               const SurfaceCaps& caps,
                               const GLFormats& formats,
-                              const gfx::IntSize& size);
+                              const gfxIntSize& size);
 
 protected:
     GLContext* const mGL;
-    const gfx::IntSize mSize;
+    const gfxIntSize mSize;
     const GLuint mFB;
     const GLuint mColorMSRB;
     const GLuint mDepthRB;
     const GLuint mStencilRB;
 
     DrawBuffer(GLContext* gl,
-               const gfx::IntSize& size,
+               const gfxIntSize& size,
                GLuint fb,
                GLuint colorMSRB,
                GLuint depthRB,
                GLuint stencilRB)
         : mGL(gl)
         , mSize(size)
         , mFB(fb)
         , mColorMSRB(colorMSRB)
         , mDepthRB(depthRB)
         , mStencilRB(stencilRB)
     {}
 
 public:
     virtual ~DrawBuffer();
 
-    const gfx::IntSize& Size() const {
+    const gfxIntSize& Size() const {
         return mSize;
     }
 
     GLuint FB() const {
         return mFB;
     }
 };
 
@@ -119,17 +119,17 @@ protected:
     {}
 
 public:
     virtual ~ReadBuffer();
 
     // Cannot attach a surf of a different AttachType or Size than before.
     void Attach(SharedSurface_GL* surf);
 
-    const gfx::IntSize& Size() const;
+    const gfxIntSize& Size() const;
 
     GLuint FB() const {
         return mFB;
     }
 
     SharedSurface_GL* SharedSurf() const {
         return mSurf;
     }
@@ -143,17 +143,17 @@ protected:
     typedef class gfx::SharedSurface SharedSurface;
     typedef gfx::SurfaceStreamType SurfaceStreamType;
     typedef gfx::SharedSurfaceType SharedSurfaceType;
     typedef struct gfx::SurfaceCaps SurfaceCaps;
 
 public:
     // Infallible.
     static GLScreenBuffer* Create(GLContext* gl,
-                                  const gfx::IntSize& size,
+                                  const gfxIntSize& size,
                                   const SurfaceCaps& caps);
 
 protected:
     GLContext* const mGL;         // Owns us.
     SurfaceCaps mCaps;
     SurfaceFactory_GL* mFactory;  // Owned by us.
     SurfaceStream* mStream;       // Owned by us.
 
@@ -226,17 +226,17 @@ public:
     }
 
     GLuint ReadFB() const {
         return mRead->FB();
     }
 
     void DeletingFB(GLuint fb);
 
-    const gfx::IntSize& Size() const {
+    const gfxIntSize& Size() const {
         MOZ_ASSERT(mRead);
         MOZ_ASSERT(!mDraw || mDraw->Size() == mRead->Size());
         return mRead->Size();
     }
 
     void BindAsFramebuffer(GLContext* const gl, GLenum target) const;
 
     void RequireBlit();
@@ -265,29 +265,29 @@ public:
      *
      * Once you pass newFactory into Morph, newFactory will be owned by
      * GLScreenBuffer, so `forget` any references to it that still exist.
      */
     void Morph(SurfaceFactory_GL* newFactory, SurfaceStreamType streamType);
 
 protected:
     // Returns false on error or inability to resize.
-    bool Swap(const gfx::IntSize& size);
+    bool Swap(const gfxIntSize& size);
 
 public:
-    bool PublishFrame(const gfx::IntSize& size);
+    bool PublishFrame(const gfxIntSize& size);
 
-    bool Resize(const gfx::IntSize& size);
+    bool Resize(const gfxIntSize& size);
 
     void Readback(SharedSurface_GL* src, gfxImageSurface* dest);
 
 protected:
-    void Attach(SharedSurface* surface, const gfx::IntSize& size);
+    void Attach(SharedSurface* surface, const gfxIntSize& size);
 
-    DrawBuffer* CreateDraw(const gfx::IntSize& size);
+    DrawBuffer* CreateDraw(const gfxIntSize& size);
     ReadBuffer* CreateRead(SharedSurface_GL* surf);
 
 public:
     /* `fb` in these functions is the framebuffer the GLContext is hoping to
      * bind. When this is 0, we intercept the call and bind our own
      * framebuffers. As a client of these functions, just bind 0 when you want
      * to draw to the default framebuffer/'screen'.
      */
--- a/gfx/gl/GLUploadHelpers.h
+++ b/gfx/gl/GLUploadHelpers.h
@@ -84,21 +84,21 @@ UploadSurfaceToTexture(GLContext* gl,
 /**
   * Convenience wrapper around UploadImageDataToTexture for gfx::DataSourceSurface's.
   */
 gfx::SurfaceFormat
 UploadSurfaceToTexture(GLContext* gl,
                        gfx::DataSourceSurface *aSurface,
                        const nsIntRegion& aDstRegion,
                        GLuint& aTexture,
-                       bool aOverwrite = false,
-                       const nsIntPoint& aSrcPoint = nsIntPoint(0, 0),
-                       bool aPixelBuffer = false,
-                       GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
-                       GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
+                       bool aOverwrite,
+                       const nsIntPoint& aSrcPoint,
+                       bool aPixelBuffer,
+                       GLenum aTextureUnit,
+                       GLenum aTextureTarget);
 
 bool CanUploadSubTextures(GLContext* gl);
 bool CanUploadNonPowerOfTwo(GLContext* gl);
 
 }
 }
 
 #endif
--- a/gfx/gl/SharedSurface.h
+++ b/gfx/gl/SharedSurface.h
@@ -13,38 +13,38 @@
  */
 
 #ifndef SHARED_SURFACE_H_
 #define SHARED_SURFACE_H_
 
 #include <stdint.h>
 #include "mozilla/Attributes.h"
 #include "GLDefs.h"
-#include "mozilla/gfx/Point.h"
+#include "gfxPoint.h"
 #include "SurfaceTypes.h"
 
 namespace mozilla {
 namespace gfx {
 
 class SurfaceFactory;
 
 class SharedSurface
 {
 protected:
     const SharedSurfaceType mType;
     const APITypeT mAPI;
     const AttachmentType mAttachType;
-    const gfx::IntSize mSize;
+    const gfxIntSize mSize;
     const bool mHasAlpha;
     bool mIsLocked;
 
     SharedSurface(SharedSurfaceType type,
                   APITypeT api,
                   AttachmentType attachType,
-                  const gfx::IntSize& size,
+                  const gfxIntSize& size,
                   bool hasAlpha)
         : mType(type)
         , mAPI(api)
         , mAttachType(attachType)
         , mSize(size)
         , mHasAlpha(hasAlpha)
         , mIsLocked(false)
     {
@@ -88,17 +88,17 @@ public:
     APITypeT APIType() const {
         return mAPI;
     }
 
     AttachmentType AttachType() const {
         return mAttachType;
     }
 
-    const gfx::IntSize& Size() const {
+    const gfxIntSize& Size() const {
         return mSize;
     }
 
     bool HasAlpha() const {
         return mHasAlpha;
     }
 
 
--- a/gfx/gl/SharedSurfaceANGLE.cpp
+++ b/gfx/gl/SharedSurfaceANGLE.cpp
@@ -171,33 +171,33 @@ ChooseConfig(GLContext* gl,
     return config;
 }
 
 
 // Returns EGL_NO_SURFACE on error.
 static EGLSurface CreatePBufferSurface(GLLibraryEGL* egl,
                                        EGLDisplay display,
                                        EGLConfig config,
-                                       const gfx::IntSize& size)
+                                       const gfxIntSize& size)
 {
     EGLint attribs[] = {
         LOCAL_EGL_WIDTH, size.width,
         LOCAL_EGL_HEIGHT, size.height,
         LOCAL_EGL_NONE
     };
 
     EGLSurface surface = egl->fCreatePbufferSurface(display, config, attribs);
 
     return surface;
 }
 
 SharedSurface_ANGLEShareHandle*
 SharedSurface_ANGLEShareHandle::Create(GLContext* gl, ID3D10Device1* d3d,
                                        EGLContext context, EGLConfig config,
-                                       const gfx::IntSize& size, bool hasAlpha)
+                                       const gfxIntSize& size, bool hasAlpha)
 {
     GLLibraryEGL* egl = gl->GetLibraryEGL();
     MOZ_ASSERT(egl);
     MOZ_ASSERT(egl->IsExtensionSupported(
                GLLibraryEGL::ANGLE_surface_d3d_texture_2d_share_handle));
 
     if (!context || !config)
         return nullptr;
--- a/gfx/gl/SharedSurfaceANGLE.h
+++ b/gfx/gl/SharedSurfaceANGLE.h
@@ -20,17 +20,17 @@ namespace gl {
 class GLContext;
 
 class SharedSurface_ANGLEShareHandle
     : public SharedSurface_GL
 {
 public:
     static SharedSurface_ANGLEShareHandle* Create(GLContext* gl, ID3D10Device1* d3d,
                                                   EGLContext context, EGLConfig config,
-                                                  const gfx::IntSize& size,
+                                                  const gfxIntSize& size,
                                                   bool hasAlpha);
 
     static SharedSurface_ANGLEShareHandle* Cast(SharedSurface* surf) {
         MOZ_ASSERT(surf->Type() == SharedSurfaceType::EGLSurfaceANGLE);
 
         return (SharedSurface_ANGLEShareHandle*)surf;
     }
 
@@ -38,17 +38,17 @@ protected:
     GLLibraryEGL* const mEGL;
     const EGLContext mContext;
     const EGLSurface mPBuffer;
     nsRefPtr<ID3D10Texture2D> mTexture;
     nsRefPtr<ID3D10ShaderResourceView> mSRV;
 
     SharedSurface_ANGLEShareHandle(GLContext* gl,
                                    GLLibraryEGL* egl,
-                                   const gfx::IntSize& size,
+                                   const gfxIntSize& size,
                                    bool hasAlpha,
                                    EGLContext context,
                                    EGLSurface pbuffer,
                                    ID3D10Texture2D* texture,
                                    ID3D10ShaderResourceView* srv)
         : SharedSurface_GL(SharedSurfaceType::EGLSurfaceANGLE,
                            AttachmentType::Screen,
                            gl,
@@ -96,17 +96,17 @@ public:
                                                    const SurfaceCaps& caps);
 
 protected:
     SurfaceFactory_ANGLEShareHandle(GLContext* gl,
                                     GLLibraryEGL* egl,
                                     ID3D10Device1* d3d,
                                     const SurfaceCaps& caps);
 
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) {
+    virtual SharedSurface* CreateShared(const gfxIntSize& size) {
         bool hasAlpha = mReadCaps.alpha;
         return SharedSurface_ANGLEShareHandle::Create(mProdGL, mConsD3D,
                                                       mContext, mConfig,
                                                       size, hasAlpha);
     }
 };
 
 } /* namespace gfx */
--- a/gfx/gl/SharedSurfaceEGL.cpp
+++ b/gfx/gl/SharedSurfaceEGL.cpp
@@ -16,17 +16,17 @@
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace gl {
 
 SharedSurface_EGLImage*
 SharedSurface_EGLImage::Create(GLContext* prodGL,
                                const GLFormats& formats,
-                               const gfx::IntSize& size,
+                               const gfxIntSize& size,
                                bool hasAlpha,
                                EGLContext context)
 {
     GLLibraryEGL* egl = prodGL->GetLibraryEGL();
     MOZ_ASSERT(egl);
 
     if (!HasExtensions(egl, prodGL))
         return nullptr;
@@ -47,17 +47,17 @@ SharedSurface_EGLImage::HasExtensions(GL
 {
     return egl->HasKHRImageBase() &&
            egl->IsExtensionSupported(GLLibraryEGL::KHR_gl_texture_2D_image) &&
            gl->IsExtensionSupported(GLContext::OES_EGL_image);
 }
 
 SharedSurface_EGLImage::SharedSurface_EGLImage(GLContext* gl,
                                                GLLibraryEGL* egl,
-                                               const gfx::IntSize& size,
+                                               const gfxIntSize& size,
                                                bool hasAlpha,
                                                const GLFormats& formats,
                                                GLuint prodTex)
     : SharedSurface_GL(SharedSurfaceType::EGLImageShare,
                         AttachmentType::GLTexture,
                         gl,
                         size,
                         hasAlpha)
@@ -118,17 +118,17 @@ SharedSurface_EGLImage::LockProdImpl()
     mGL->fDeleteTextures(1, &mProdTex);
     mProdTex = mProdTexForPipe;
     mProdTexForPipe = 0;
     mPipeActive = true;
 }
 
 static bool
 CreateTexturePipe(GLLibraryEGL* const egl, GLContext* const gl,
-                  const GLFormats& formats, const gfx::IntSize& size,
+                  const GLFormats& formats, const gfxIntSize& size,
                   GLuint* const out_tex, EGLImage* const out_image)
 {
     MOZ_ASSERT(out_tex && out_image);
     *out_tex = 0;
     *out_image = 0;
 
     GLuint tex = CreateTextureForOffscreen(gl, formats, size);
     if (!tex)
@@ -165,28 +165,24 @@ SharedSurface_EGLImage::Fence()
             if (!CreateTexturePipe(mEGL, mGL, mFormats, Size(),
                                    &mProdTexForPipe, &mImage))
             {
                 mPipeFailed = true;
             }
         }
 
         if (!mPixels) {
-            SurfaceFormat format =
-                  HasAlpha() ? FORMAT_B8G8R8A8
-                             : FORMAT_B8G8R8X8;
-            mPixels = Factory::CreateDataSourceSurface(Size(), format);
+            gfxImageFormat format =
+                  HasAlpha() ? gfxImageFormatARGB32
+                             : gfxImageFormatRGB24;
+            mPixels = new gfxImageSurface(Size(), format);
         }
 
-        nsRefPtr<gfxImageSurface> wrappedData =
-            new gfxImageSurface(mPixels->GetData(),
-                                ThebesIntSize(mPixels->GetSize()),
-                                mPixels->Stride(),
-                                SurfaceFormatToImageFormat(mPixels->GetFormat()));
-        mGL->ReadScreenIntoImageSurface(wrappedData);
+        mPixels->Flush();
+        mGL->ReadScreenIntoImageSurface(mPixels);
         mPixels->MarkDirty();
         return;
     }
     MOZ_ASSERT(mPipeActive);
     MOZ_ASSERT(mCurConsGL);
 
     if (mEGL->IsExtensionSupported(GLLibraryEGL::KHR_fence_sync) &&
         mGL->IsExtensionSupported(GLContext::OES_EGL_sync))
@@ -269,17 +265,17 @@ SharedSurface_EGLImage::AcquireConsumerT
         mCurConsGL = consGL;
         mGarbageBin = consGL->TexGarbageBin();
     }
 
     MOZ_ASSERT(consGL == mCurConsGL);
     return 0;
 }
 
-DataSourceSurface*
+gfxImageSurface*
 SharedSurface_EGLImage::GetPixels() const
 {
     MutexAutoLock lock(mMutex);
     return mPixels;
 }
 
 
 
--- a/gfx/gl/SharedSurfaceEGL.h
+++ b/gfx/gl/SharedSurfaceEGL.h
@@ -19,46 +19,46 @@ namespace gl {
 class GLContext;
 class TextureGarbageBin;
 
 class SharedSurface_EGLImage
     : public SharedSurface_GL
 {
 public:
     static SharedSurface_EGLImage* Create(GLContext* prodGL,
-                                          const GLFormats& formats,
-                                          const gfx::IntSize& size,
-                                          bool hasAlpha,
-                                          EGLContext context);
+                                                  const GLFormats& formats,
+                                                  const gfxIntSize& size,
+                                                  bool hasAlpha,
+                                                  EGLContext context);
 
     static SharedSurface_EGLImage* Cast(SharedSurface* surf) {
         MOZ_ASSERT(surf->Type() == SharedSurfaceType::EGLImageShare);
 
         return (SharedSurface_EGLImage*)surf;
     }
 
 protected:
     mutable Mutex mMutex;
     GLLibraryEGL* const mEGL;
     const GLFormats mFormats;
     GLuint mProdTex;
-    RefPtr<gfx::DataSourceSurface> mPixels;
+    nsRefPtr<gfxImageSurface> mPixels;
     GLuint mProdTexForPipe; // Moves to mProdTex when mPipeActive becomes true.
     EGLImage mImage;
     GLContext* mCurConsGL;
     GLuint mConsTex;
     nsRefPtr<TextureGarbageBin> mGarbageBin;
     EGLSync mSync;
     bool mPipeFailed;   // Pipe creation failed, and has been abandoned.
     bool mPipeComplete; // Pipe connects (mPipeActive ? mProdTex : mProdTexForPipe) to mConsTex.
     bool mPipeActive;   // Pipe is complete and in use for production.
 
     SharedSurface_EGLImage(GLContext* gl,
                            GLLibraryEGL* egl,
-                           const gfx::IntSize& size,
+                           const gfxIntSize& size,
                            bool hasAlpha,
                            const GLFormats& formats,
                            GLuint prodTex);
 
     EGLDisplay Display() const;
 
     static bool HasExtensions(GLLibraryEGL* egl, GLContext* gl);
 
@@ -77,17 +77,17 @@ public:
         return mProdTex;
     }
 
     // Implementation-specific functions below:
     // Returns 0 if the pipe isn't ready. If 0, use GetPixels below.
     GLuint AcquireConsumerTexture(GLContext* consGL);
 
     // Will be void if AcquireConsumerTexture returns non-zero.
-    gfx::DataSourceSurface* GetPixels() const;
+    gfxImageSurface* GetPixels() const;
 };
 
 
 
 class SurfaceFactory_EGLImage
     : public SurfaceFactory_GL
 {
 public:
@@ -101,17 +101,17 @@ protected:
     SurfaceFactory_EGLImage(GLContext* prodGL,
                             EGLContext context,
                             const SurfaceCaps& caps)
         : SurfaceFactory_GL(prodGL, SharedSurfaceType::EGLImageShare, caps)
         , mContext(context)
     {}
 
 public:
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) {
+    virtual SharedSurface* CreateShared(const gfxIntSize& size) {
         bool hasAlpha = mReadCaps.alpha;
         return SharedSurface_EGLImage::Create(mGL, mFormats, size, hasAlpha, mContext);
     }
 };
 
 } /* namespace gfx */
 } /* namespace mozilla */
 
--- a/gfx/gl/SharedSurfaceGL.cpp
+++ b/gfx/gl/SharedSurfaceGL.cpp
@@ -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/. */
 
 #include "SharedSurfaceGL.h"
 #include "GLContext.h"
 #include "GLBlitHelper.h"
 #include "ScopedGLHelpers.h"
 #include "gfxImageSurface.h"
-#include "mozilla/gfx/2D.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace gl {
 
 // |src| must begin and end locked, though we may
 // temporarily unlock it if we need to.
@@ -239,57 +238,57 @@ SurfaceFactory_GL::ChooseBufferBits(cons
         readCaps = screenCaps;
     }
 }
 
 
 SharedSurface_Basic*
 SharedSurface_Basic::Create(GLContext* gl,
                             const GLFormats& formats,
-                            const IntSize& size,
+                            const gfxIntSize& size,
                             bool hasAlpha)
 {
     gl->MakeCurrent();
     GLuint tex = CreateTexture(gl, formats.color_texInternalFormat,
                                formats.color_texFormat,
                                formats.color_texType,
                                size);
 
-    SurfaceFormat format = FORMAT_B8G8R8X8;
+    gfxImageFormat format = gfxImageFormatRGB24;
     switch (formats.color_texInternalFormat) {
     case LOCAL_GL_RGB:
     case LOCAL_GL_RGB8:
         if (formats.color_texType == LOCAL_GL_UNSIGNED_SHORT_5_6_5)
-            format = FORMAT_R5G6B5;
+            format = gfxImageFormatRGB16_565;
         else
-            format = FORMAT_B8G8R8X8;
+            format = gfxImageFormatRGB24;
         break;
     case LOCAL_GL_RGBA:
     case LOCAL_GL_RGBA8:
-        format = FORMAT_B8G8R8A8;
+        format = gfxImageFormatARGB32;
         break;
     default:
         MOZ_CRASH("Unhandled Tex format.");
     }
     return new SharedSurface_Basic(gl, size, hasAlpha, format, tex);
 }
 
 SharedSurface_Basic::SharedSurface_Basic(GLContext* gl,
-                                         const IntSize& size,
+                                         const gfxIntSize& size,
                                          bool hasAlpha,
-                                         SurfaceFormat format,
+                                         gfxImageFormat format,
                                          GLuint tex)
     : SharedSurface_GL(SharedSurfaceType::Basic,
                        AttachmentType::GLTexture,
                        gl,
                        size,
                        hasAlpha)
     , mTex(tex)
 {
-    mData = Factory::CreateDataSourceSurface(size, format);
+    mData = new gfxImageSurface(size, format);
 }
 
 SharedSurface_Basic::~SharedSurface_Basic()
 {
     if (!mGL->MakeCurrent())
         return;
 
     GLuint tex = mTex;
@@ -297,33 +296,29 @@ SharedSurface_Basic::~SharedSurface_Basi
 }
 
 void
 SharedSurface_Basic::Fence()
 {
     MOZ_ASSERT(mData->GetSize() == mGL->OffscreenSize());
 
     mGL->MakeCurrent();
-    nsRefPtr<gfxImageSurface> wrappedData =
-      new gfxImageSurface(mData->GetData(),
-                          ThebesIntSize(mData->GetSize()),
-                          mData->Stride(),
-                          SurfaceFormatToImageFormat(mData->GetFormat()));
-    mGL->ReadScreenIntoImageSurface(wrappedData);
+    mData->Flush();
+    mGL->ReadScreenIntoImageSurface(mData);
     mData->MarkDirty();
 }
 
 
 
 SharedSurface_GLTexture*
 SharedSurface_GLTexture::Create(GLContext* prodGL,
-                                GLContext* consGL,
-                                const GLFormats& formats,
-                                const gfx::IntSize& size,
-                                bool hasAlpha)
+                             GLContext* consGL,
+                             const GLFormats& formats,
+                             const gfxIntSize& size,
+                             bool hasAlpha)
 {
     MOZ_ASSERT(prodGL);
     MOZ_ASSERT(!consGL || prodGL->SharesWith(consGL));
 
     prodGL->MakeCurrent();
     GLuint tex = CreateTextureForOffscreen(prodGL, formats, size);
 
     return new SharedSurface_GLTexture(prodGL, consGL, size, hasAlpha, tex);
--- a/gfx/gl/SharedSurfaceGL.h
+++ b/gfx/gl/SharedSurfaceGL.h
@@ -17,19 +17,16 @@
 #include <queue>
 
 // Forwards:
 class gfxImageSurface;
 namespace mozilla {
     namespace gl {
         class GLContext;
     }
-    namespace gfx {
-        class DataSourceSurface;
-    }
 }
 
 namespace mozilla {
 namespace gl {
 
 class SurfaceFactory_GL;
 
 class SharedSurface_GL
@@ -41,17 +38,17 @@ protected:
     typedef gfx::APITypeT APITypeT;
     typedef gfx::AttachmentType AttachmentType;
 
     GLContext* const mGL;
 
     SharedSurface_GL(SharedSurfaceType type,
                      AttachmentType attachType,
                      GLContext* gl,
-                     const gfx::IntSize& size,
+                     const gfxIntSize& size,
                      bool hasAlpha)
         : SharedSurface(type, APITypeT::OpenGL, attachType, size, hasAlpha)
         , mGL(gl)
     {}
 
 public:
     static void Copy(SharedSurface_GL* src, SharedSurface_GL* dest,
                      SurfaceFactory_GL* factory);
@@ -119,33 +116,33 @@ public:
 
 // For readback and bootstrapping:
 class SharedSurface_Basic
     : public SharedSurface_GL
 {
 public:
     static SharedSurface_Basic* Create(GLContext* gl,
                                        const GLFormats& formats,
-                                       const gfx::IntSize& size,
+                                       const gfxIntSize& size,
                                        bool hasAlpha);
 
     static SharedSurface_Basic* Cast(SharedSurface* surf) {
         MOZ_ASSERT(surf->Type() == SharedSurfaceType::Basic);
 
         return (SharedSurface_Basic*)surf;
     }
 
 protected:
     const GLuint mTex;
-    RefPtr<gfx::DataSourceSurface> mData;
+    nsRefPtr<gfxImageSurface> mData;
 
     SharedSurface_Basic(GLContext* gl,
-                        const gfx::IntSize& size,
+                        const gfxIntSize& size,
                         bool hasAlpha,
-                        gfx::SurfaceFormat format,
+                        gfxImageFormat format,
                         GLuint tex);
 
 public:
     virtual ~SharedSurface_Basic();
 
     virtual void LockProdImpl() {}
     virtual void UnlockProdImpl() {}
 
@@ -158,62 +155,62 @@ public:
     }
 
 
     virtual GLuint Texture() const {
         return mTex;
     }
 
     // Implementation-specific functions below:
-    gfx::DataSourceSurface* GetData() {
+    gfxImageSurface* GetData() {
         return mData;
     }
 };
 
 class SurfaceFactory_Basic
     : public SurfaceFactory_GL
 {
 public:
     SurfaceFactory_Basic(GLContext* gl, const SurfaceCaps& caps)
         : SurfaceFactory_GL(gl, SharedSurfaceType::Basic, caps)
     {}
 
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) {
+    virtual SharedSurface* CreateShared(const gfxIntSize& size) {
         bool hasAlpha = mReadCaps.alpha;
         return SharedSurface_Basic::Create(mGL, mFormats, size, hasAlpha);
     }
 };
 
 
 // Using shared GL textures:
 class SharedSurface_GLTexture
     : public SharedSurface_GL
 {
 public:
     static SharedSurface_GLTexture* Create(GLContext* prodGL,
                                            GLContext* consGL,
                                            const GLFormats& formats,
-                                           const gfx::IntSize& size,
+                                           const gfxIntSize& size,
                                            bool hasAlpha);
 
     static SharedSurface_GLTexture* Cast(SharedSurface* surf) {
         MOZ_ASSERT(surf->Type() == SharedSurfaceType::GLTextureShare);
 
         return (SharedSurface_GLTexture*)surf;
     }
 
 protected:
     GLContext* mConsGL;
     const GLuint mTex;
     GLsync mSync;
     mutable Mutex mMutex;
 
     SharedSurface_GLTexture(GLContext* prodGL,
                             GLContext* consGL,
-                            const gfx::IntSize& size,
+                            const gfxIntSize& size,
                             bool hasAlpha,
                             GLuint tex)
         : SharedSurface_GL(SharedSurfaceType::GLTextureShare,
                            AttachmentType::GLTexture,
                            prodGL,
                            size,
                            hasAlpha)
         , mConsGL(consGL)
@@ -256,17 +253,17 @@ public:
                              GLContext* consGL,
                              const SurfaceCaps& caps)
         : SurfaceFactory_GL(prodGL, SharedSurfaceType::GLTextureShare, caps)
         , mConsGL(consGL)
     {
         MOZ_ASSERT(consGL != prodGL);
     }
 
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) {
+    virtual SharedSurface* CreateShared(const gfxIntSize& size) {
         bool hasAlpha = mReadCaps.alpha;
         return SharedSurface_GLTexture::Create(mGL, mConsGL, mFormats, size, hasAlpha);
     }
 };
 
 } /* namespace gfx */
 } /* namespace mozilla */
 
--- a/gfx/gl/SharedSurfaceGralloc.cpp
+++ b/gfx/gl/SharedSurfaceGralloc.cpp
@@ -12,18 +12,16 @@
 #include "SurfaceFactory.h"
 #include "GLLibraryEGL.h"
 #include "mozilla/layers/ShadowLayers.h"
 
 #include "ui/GraphicBuffer.h"
 #include "../layers/ipc/ShadowLayers.h"
 #include "ScopedGLHelpers.h"
 
-#include "gfx2DGlue.h"
-
 #define DEBUG_GRALLOC
 #ifdef DEBUG_GRALLOC
 #define DEBUG_PRINT(...) do { printf_stderr(__VA_ARGS__); } while (0)
 #else
 #define DEBUG_PRINT(...) do { } while (0)
 #endif
 
 using namespace mozilla;
@@ -47,17 +45,17 @@ SurfaceFactory_Gralloc::SurfaceFactory_G
     MOZ_ASSERT(allocator);
 
     mAllocator = allocator;
 }
 
 SharedSurface_Gralloc*
 SharedSurface_Gralloc::Create(GLContext* prodGL,
                               const GLFormats& formats,
-                              const gfx::IntSize& size,
+                              const gfxIntSize& size,
                               bool hasAlpha,
                               ISurfaceAllocator* allocator)
 {
     static bool runOnce = true;
     if (runOnce) {
         sForceReadPixelsToFence = false;
         mozilla::Preferences::AddBoolVarCache(&sForceReadPixelsToFence,
                                               "gfx.gralloc.fence-with-readpixels");
@@ -72,17 +70,17 @@ SharedSurface_Gralloc::Create(GLContext*
     if (!HasExtensions(egl, prodGL))
         return nullptr;
 
     SurfaceDescriptor baseDesc;
     SurfaceDescriptorGralloc desc;
 
     gfxContentType type = hasAlpha ? GFX_CONTENT_COLOR_ALPHA
                                                 : GFX_CONTENT_COLOR;
-    if (!allocator->AllocSurfaceDescriptorWithCaps(ThebesIntSize(size), type, USING_GL_RENDERING_ONLY, &baseDesc))
+    if (!allocator->AllocSurfaceDescriptorWithCaps(size, type, USING_GL_RENDERING_ONLY, &baseDesc))
         return false;
 
     if (baseDesc.type() != SurfaceDescriptor::TSurfaceDescriptorGralloc) {
         allocator->DestroySharedSurface(&baseDesc);
         return false;
     }
 
     desc = baseDesc.get_SurfaceDescriptorGralloc();
--- a/gfx/gl/SharedSurfaceGralloc.h
+++ b/gfx/gl/SharedSurfaceGralloc.h
@@ -21,17 +21,17 @@ class GLContext;
 class GLLibraryEGL;
 
 class SharedSurface_Gralloc
     : public SharedSurface_GL
 {
 public:
     static SharedSurface_Gralloc* Create(GLContext* prodGL,
                                          const GLFormats& formats,
-                                         const gfx::IntSize& size,
+                                         const gfxIntSize& size,
                                          bool hasAlpha,
                                          layers::ISurfaceAllocator* allocator);
 
     static SharedSurface_Gralloc* Cast(SharedSurface* surf) {
         MOZ_ASSERT(surf->Type() == SharedSurfaceType::Gralloc);
 
         return (SharedSurface_Gralloc*)surf;
     }
@@ -47,17 +47,17 @@ protected:
     // actor) it in the destructor of this class.  This is okay to do
     // on the client, but is very bad to do on the server (because on
     // the client, the actor has no chance of going away unless the
     // whole app died).
     layers::SurfaceDescriptorGralloc mDesc;
     const GLuint mProdTex;
 
     SharedSurface_Gralloc(GLContext* prodGL,
-                          const gfx::IntSize& size,
+                          const gfxIntSize& size,
                           bool hasAlpha,
                           GLLibraryEGL* egl,
                           layers::ISurfaceAllocator* allocator,
                           layers::SurfaceDescriptorGralloc& desc,
                           GLuint prodTex)
         : SharedSurface_GL(SharedSurfaceType::Gralloc,
                            AttachmentType::GLTexture,
                            prodGL,
@@ -95,17 +95,17 @@ class SurfaceFactory_Gralloc
 protected:
     RefPtr<layers::ISurfaceAllocator> mAllocator;
 
 public:
     SurfaceFactory_Gralloc(GLContext* prodGL,
                            const SurfaceCaps& caps,
                            layers::ISurfaceAllocator* allocator = nullptr);
 
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) {
+    virtual SharedSurface* CreateShared(const gfxIntSize& size) {
         bool hasAlpha = mReadCaps.alpha;
         if (!mAllocator) {
             return nullptr;
         }
         return SharedSurface_Gralloc::Create(mGL, mFormats, size, hasAlpha, mAllocator);
     }
 };
 
--- a/gfx/gl/SharedSurfaceIO.cpp
+++ b/gfx/gl/SharedSurfaceIO.cpp
@@ -16,17 +16,17 @@ namespace gl {
 using namespace gfx;
 
 /* static */ SharedSurface_IOSurface*
 SharedSurface_IOSurface::Create(MacIOSurface* surface, GLContext *gl, bool hasAlpha)
 {
     MOZ_ASSERT(surface);
     MOZ_ASSERT(gl);
 
-    gfx::IntSize size(surface->GetWidth(), surface->GetHeight());
+    gfxIntSize size(surface->GetWidth(), surface->GetHeight());
     return new SharedSurface_IOSurface(surface, gl, size, hasAlpha);
 }
 
 void
 SharedSurface_IOSurface::Fence()
 {
     mGL->MakeCurrent();
     mGL->fFlush();
@@ -52,17 +52,17 @@ SharedSurface_IOSurface::ReadPixels(GLin
     ScopedBindFramebuffer bindFB(mGL, fb.FB());
 
     mGL->fReadPixels(0, 0, width, height, format, type, pixels);
     return true;
 }
 
 SharedSurface_IOSurface::SharedSurface_IOSurface(MacIOSurface* surface,
                                                  GLContext* gl,
-                                                 const gfx::IntSize& size,
+                                                 const gfxIntSize& size,
                                                  bool hasAlpha)
   : SharedSurface_GL(SharedSurfaceType::IOSurface, AttachmentType::GLTexture, gl, size, hasAlpha)
   , mSurface(surface)
 {
     mGL->MakeCurrent();
     mGL->fGenTextures(1, &mTexture);
 
     ScopedBindTexture texture(mGL, mTexture, LOCAL_GL_TEXTURE_RECTANGLE_ARB);
@@ -91,17 +91,17 @@ SharedSurface_IOSurface::~SharedSurface_
     if (mTexture) {
         DebugOnly<bool> success = mGL->MakeCurrent();
         MOZ_ASSERT(success);
         mGL->fDeleteTextures(1, &mTexture);
     }
 }
 
 SharedSurface*
-SurfaceFactory_IOSurface::CreateShared(const gfx::IntSize& size)
+SurfaceFactory_IOSurface::CreateShared(const gfxIntSize& size)
 {
     bool hasAlpha = mReadCaps.alpha;
     RefPtr<MacIOSurface> surf =
         MacIOSurface::CreateIOSurface(size.width, size.height, 1.0, hasAlpha);
 
     if (!surf) {
         NS_WARNING("Failed to create MacIOSurface.");
         return nullptr;
--- a/gfx/gl/SharedSurfaceIO.h
+++ b/gfx/gl/SharedSurfaceIO.h
@@ -43,32 +43,32 @@ public:
     {
         MOZ_ASSERT(surf->Type() == SharedSurfaceType::IOSurface);
         return static_cast<SharedSurface_IOSurface*>(surf);
     }
 
     MacIOSurface* GetIOSurface() { return mSurface; }
 
 private:
-    SharedSurface_IOSurface(MacIOSurface* surface, GLContext* gl, const gfx::IntSize& size, bool hasAlpha);
+    SharedSurface_IOSurface(MacIOSurface* surface, GLContext* gl, const gfxIntSize& size, bool hasAlpha);
 
     RefPtr<MacIOSurface> mSurface;
     nsRefPtr<gfxImageSurface> mImageSurface;
     GLuint mTexture;
 };
 
 class SurfaceFactory_IOSurface : public SurfaceFactory_GL
 {
 public:
     SurfaceFactory_IOSurface(GLContext* gl,
                              const SurfaceCaps& caps)
         : SurfaceFactory_GL(gl, SharedSurfaceType::IOSurface, caps)
     {
     }
 
 protected:
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE;
+    virtual SharedSurface* CreateShared(const gfxIntSize& size) MOZ_OVERRIDE;
 };
 
 } /* namespace gfx */
 } /* namespace mozilla */
 
 #endif /* SHARED_SURFACEIO_H_ */
--- a/gfx/gl/SurfaceFactory.cpp
+++ b/gfx/gl/SurfaceFactory.cpp
@@ -16,17 +16,17 @@ SurfaceFactory::~SurfaceFactory()
         SharedSurface* cur = mScraps.front();
         mScraps.pop();
 
         delete cur;
     }
 }
 
 SharedSurface*
-SurfaceFactory::NewSharedSurface(const gfx::IntSize& size)
+SurfaceFactory::NewSharedSurface(const gfxIntSize& size)
 {
     // Attempt to reuse an old surface.
     while (!mScraps.empty()) {
         SharedSurface* cur = mScraps.front();
         mScraps.pop();
         if (cur->Size() == size)
             return cur;
 
--- a/gfx/gl/SurfaceFactory.h
+++ b/gfx/gl/SurfaceFactory.h
@@ -25,22 +25,22 @@ protected:
         : mCaps(caps)
         , mType(type)
     {}
 
 public:
     virtual ~SurfaceFactory();
 
 protected:
-    virtual SharedSurface* CreateShared(const gfx::IntSize& size) = 0;
+    virtual SharedSurface* CreateShared(const gfxIntSize& size) = 0;
 
     std::queue<SharedSurface*> mScraps;
 
 public:
-    SharedSurface* NewSharedSurface(const gfx::IntSize& size);
+    SharedSurface* NewSharedSurface(const gfxIntSize& size);
 
     // Auto-deletes surfs of the wrong type.
     void Recycle(SharedSurface*& surf);
 
     const SurfaceCaps& Caps() const {
         return mCaps;
     }
 
--- a/gfx/gl/SurfaceStream.cpp
+++ b/gfx/gl/SurfaceStream.cpp
@@ -52,17 +52,17 @@ SurfaceStream::CreateForType(SurfaceStre
             MOZ_CRASH("Invalid Type.");
     }
 
     result->mGLContext = glContext;
     return result;
 }
 
 void
-SurfaceStream::New(SurfaceFactory* factory, const gfx::IntSize& size,
+SurfaceStream::New(SurfaceFactory* factory, const gfxIntSize& size,
                    SharedSurface*& surf)
 {
     MOZ_ASSERT(!surf);
     surf = factory->NewSharedSurface(size);
 
     if (surf)
         mSurfaces.insert(surf);
 }
@@ -165,17 +165,17 @@ SurfaceStream::SwapConsumer()
     if (!ret->WaitSync()) {
         return nullptr;
     }
 
     return ret;
 }
 
 SharedSurface*
-SurfaceStream::Resize(SurfaceFactory* factory, const gfx::IntSize& size)
+SurfaceStream::Resize(SurfaceFactory* factory, const gfxIntSize& size)
 {
     MonitorAutoLock lock(mMonitor);
 
     if (mProducer) {
         Scrap(mProducer);
     }
 
     New(factory, size, mProducer);
@@ -215,17 +215,17 @@ SurfaceStream_SingleBuffer::SurrenderSur
     consumer = Surrender(mConsumer);
 
     if (!consumer)
         consumer = producer;
 }
 
 SharedSurface*
 SurfaceStream_SingleBuffer::SwapProducer(SurfaceFactory* factory,
-                                         const gfx::IntSize& size)
+                                         const gfxIntSize& size)
 {
     MonitorAutoLock lock(mMonitor);
     if (mConsumer) {
         Recycle(factory, mConsumer);
     }
 
     if (mProducer) {
         // Fence now, before we start (maybe) juggling Prod around.
@@ -308,17 +308,17 @@ SurfaceStream_TripleBuffer_Copy::Surrend
     consumer = Surrender(mConsumer);
 
     if (!consumer)
         consumer = Surrender(mStaging);
 }
 
 SharedSurface*
 SurfaceStream_TripleBuffer_Copy::SwapProducer(SurfaceFactory* factory,
-                                              const gfx::IntSize& size)
+                                              const gfxIntSize& size)
 {
     MonitorAutoLock lock(mMonitor);
 
     RecycleScraps(factory);
     if (mProducer) {
         if (mStaging) {
             // We'll re-use this for a new mProducer later on if
             // the size remains the same
@@ -402,17 +402,17 @@ SurfaceStream_TripleBuffer::SurrenderSur
     consumer = Surrender(mConsumer);
 
     if (!consumer)
         consumer = Surrender(mStaging);
 }
 
 SharedSurface*
 SurfaceStream_TripleBuffer::SwapProducer(SurfaceFactory* factory,
-                                         const gfx::IntSize& size)
+                                         const gfxIntSize& size)
 {
     PROFILER_LABEL("SurfaceStream_TripleBuffer", "SwapProducer");
 
     MonitorAutoLock lock(mMonitor);
     if (mProducer) {
         RecycleScraps(factory);
 
         // If WaitForCompositor succeeds, mStaging has moved to mConsumer.
--- a/gfx/gl/SurfaceStream.h
+++ b/gfx/gl/SurfaceStream.h
@@ -5,17 +5,17 @@
 
 #ifndef SURFACESTREAM_H_
 #define SURFACESTREAM_H_
 
 #include <stack>
 #include <set>
 #include "mozilla/Monitor.h"
 #include "mozilla/Attributes.h"
-#include "mozilla/gfx/Point.h"
+#include "gfxPoint.h"
 #include "SurfaceTypes.h"
 
 namespace mozilla {
 
 namespace gl {
 class GLContext;
 }
 
@@ -84,17 +84,17 @@ protected:
     // For instance, using Move(a,b) instead of normal assignment assures that
     // we are never leaving anything hanging around, keeping things very safe.
     static void Move(SharedSurface*& from, SharedSurface*& to) {
         MOZ_ASSERT(!to);
         to = from;
         from = nullptr;
     }
 
-    void New(SurfaceFactory* factory, const gfx::IntSize& size,
+    void New(SurfaceFactory* factory, const gfxIntSize& size,
              SharedSurface*& surf);
     void Delete(SharedSurface*& surf);
     void Recycle(SurfaceFactory* factory, SharedSurface*& surf);
 
     // Surrender control of a surface, and return it for use elsewhere.
     SharedSurface* Surrender(SharedSurface*& surf);
     // Absorb control of a surface from elsewhere, clears its old location.
     SharedSurface* Absorb(SharedSurface*& surf);
@@ -112,19 +112,19 @@ public:
      * transfers to the caller.
      * SwapProd returns null on failure. Returning null doesn't mean nothing
      * happened, but rather that a surface allocation failed. After returning
      * null, we must be able to call SwapProducer again with better args
      * and have everything work again.
      * One common failure is asking for a too-large |size|.
      */
     virtual SharedSurface* SwapProducer(SurfaceFactory* factory,
-                                        const gfx::IntSize& size) = 0;
+                                        const gfxIntSize& size) = 0;
 
-    virtual SharedSurface* Resize(SurfaceFactory* factory, const gfx::IntSize& size);
+    virtual SharedSurface* Resize(SurfaceFactory* factory, const gfxIntSize& size);
 
 protected:
     // SwapCons will return the same surface more than once,
     // if nothing new has been published.
     virtual SharedSurface* SwapConsumer_NoWait() = 0;
 
 public:
     virtual SharedSurface* SwapConsumer();
@@ -143,17 +143,17 @@ public:
     SurfaceStream_SingleBuffer(SurfaceStream* prevStream);
     virtual ~SurfaceStream_SingleBuffer();
 
     /* Since we're non-OMTC, we know the order of execution here:
      * SwapProd gets called in UpdateSurface, followed by
      * SwapCons being called in Render.
      */
     virtual SharedSurface* SwapProducer(SurfaceFactory* factory,
-                                        const gfx::IntSize& size);
+                                        const gfxIntSize& size);
 
     virtual SharedSurface* SwapConsumer_NoWait();
 
     virtual void SurrenderSurfaces(SharedSurface*& producer, SharedSurface*& consumer);
 };
 
 // Our hero for preserveDrawingBuffer=true.
 class SurfaceStream_TripleBuffer_Copy
@@ -163,17 +163,17 @@ protected:
     SharedSurface* mStaging;
     SharedSurface* mConsumer;
 
 public:
     SurfaceStream_TripleBuffer_Copy(SurfaceStream* prevStream);
     virtual ~SurfaceStream_TripleBuffer_Copy();
 
     virtual SharedSurface* SwapProducer(SurfaceFactory* factory,
-                                        const gfx::IntSize& size);
+                                        const gfxIntSize& size);
 
     virtual SharedSurface* SwapConsumer_NoWait();
 
     virtual void SurrenderSurfaces(SharedSurface*& producer, SharedSurface*& consumer);
 };
 
 
 class SurfaceStream_TripleBuffer
@@ -195,17 +195,17 @@ public:
 
 private:
     // Common constructor code.
     void Init(SurfaceStream* prevStream);
 
 public:
     // Done writing to prod, swap prod and staging
     virtual SharedSurface* SwapProducer(SurfaceFactory* factory,
-                                        const gfx::IntSize& size);
+                                        const gfxIntSize& size);
 
     virtual SharedSurface* SwapConsumer_NoWait();
 
     virtual void SurrenderSurfaces(SharedSurface*& producer, SharedSurface*& consumer);
 };
 
 class SurfaceStream_TripleBuffer_Async
     : public SurfaceStream_TripleBuffer
--- a/gfx/layers/CopyableCanvasLayer.cpp
+++ b/gfx/layers/CopyableCanvasLayer.cpp
@@ -11,17 +11,16 @@
 #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 "gfx2DGlue.h"                  // for ThebesIntSize, etc
 #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
 
 using namespace mozilla::gfx;
 using namespace mozilla::gl;
@@ -93,26 +92,25 @@ CopyableCanvasLayer::UpdateSurface(gfxAS
     nsRefPtr<gfxContext> tmpCtx = new gfxContext(aDestSurface);
     tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
     CopyableCanvasLayer::PaintWithOpacity(tmpCtx, 1.0f, aMaskLayer);
     return;
   }
 
   if (mGLContext) {
     nsRefPtr<gfxImageSurface> readSurf;
-    RefPtr<DataSourceSurface> readDSurf;
     nsRefPtr<gfxASurface> resultSurf;
 
     SharedSurface* sharedSurf = mGLContext->RequestFrame();
     if (!sharedSurf) {
       NS_WARNING("Null frame received.");
       return;
     }
 
-    gfxIntSize readSize(ThebesIntSize(sharedSurf->Size()));
+    gfxIntSize readSize(sharedSurf->Size());
     gfxImageFormat format = (GetContentFlags() & CONTENT_OPAQUE)
                             ? gfxImageFormatRGB24
                             : gfxImageFormatARGB32;
 
     if (aDestSurface) {
       resultSurf = aDestSurface;
     } else {
       resultSurf = GetTempSurface(readSize, format);
@@ -122,24 +120,18 @@ CopyableCanvasLayer::UpdateSurface(gfxAS
       MOZ_ASSERT(false, "Bad resultSurf->CairoStatus().");
       return;
     }
 
     MOZ_ASSERT(sharedSurf->APIType() == APITypeT::OpenGL);
     SharedSurface_GL* surfGL = SharedSurface_GL::Cast(sharedSurf);
 
     if (surfGL->Type() == SharedSurfaceType::Basic) {
-      // sharedSurf_Basic->mData must outlive readSurf and readDSurf. Alas,
-      // readSurf and readDSurf may not leave the scope they were declared in.
       SharedSurface_Basic* sharedSurf_Basic = SharedSurface_Basic::Cast(surfGL);
-      readDSurf = sharedSurf_Basic->GetData();
-      readSurf = new gfxImageSurface(readDSurf->GetData(),
-                                     ThebesIntSize(readDSurf->GetSize()),
-                                     readDSurf->Stride(),
-                                     SurfaceFormatToImageFormat(readDSurf->GetFormat()));
+      readSurf = sharedSurf_Basic->GetData();
     } else {
       if (resultSurf->GetSize() != readSize ||
           !(readSurf = resultSurf->GetAsImageSurface()) ||
           readSurf->Format() != format)
       {
         readSurf = GetTempSurface(readSize, format);
       }
 
--- a/gfx/layers/d3d10/CanvasLayerD3D10.cpp
+++ b/gfx/layers/d3d10/CanvasLayerD3D10.cpp
@@ -154,27 +154,31 @@ CanvasLayerD3D10::UpdateSurface()
 
         HRESULT hr = mTexture->Map(0, D3D10_MAP_WRITE_DISCARD, 0, &map);
 
         if (FAILED(hr)) {
           NS_WARNING("Failed to map CanvasLayer texture.");
           return;
         }
 
-        gfx::DataSourceSurface* frameData = shareSurf->GetData();
-        // Scope for DrawTarget, so it's destroyed before Unmap.
+        gfxImageSurface* frameData = shareSurf->GetData();
+        // Scope for gfxContext, so it's destroyed before Unmap.
         {
-          RefPtr<DrawTarget> dt = Factory::CreateDrawTargetForData(BACKEND_CAIRO,
-                                                                   (uint8_t*)map.pData,
-                                                                   shareSurf->Size(),
-                                                                   map.RowPitch,
-                                                                   FORMAT_B8G8R8A8);
-          Rect drawRect(0, 0, shareSurf->Size().width, shareSurf->Size().height);
-          dt->DrawSurface(frameData, drawRect, drawRect);
-          dt->Flush();
+          nsRefPtr<gfxImageSurface> mapSurf = 
+              new gfxImageSurface((uint8_t*)map.pData,
+                                  shareSurf->Size(),
+                                  map.RowPitch,
+                                  gfxImageFormatARGB32);
+
+          nsRefPtr<gfxContext> ctx = new gfxContext(mapSurf);
+          ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
+          ctx->SetSource(frameData);
+          ctx->Paint();
+
+          mapSurf->Flush();
         }
 
         mTexture->Unmap(0);
         mSRView = mUploadSRView;
         break;
       }
 
       default:
--- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp
+++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp
@@ -96,27 +96,31 @@ CanvasLayerD3D9::UpdateSurface()
     LockTextureRectD3D9 textureLock(mTexture);
     if (!textureLock.HasLock()) {
       NS_WARNING("Failed to lock CanvasLayer texture.");
       return;
     }
 
     D3DLOCKED_RECT rect = textureLock.GetLockRect();
 
-    gfx::DataSourceSurface* frameData = shareSurf->GetData();
-    // Scope for DrawTarget, so it's destroyed early.
+    gfxImageSurface* frameData = shareSurf->GetData();
+    // Scope for gfxContext, so it's destroyed early.
     {
-      RefPtr<DrawTarget> mapDt = Factory::CreateDrawTargetForData(BACKEND_CAIRO,
-                                                                  (uint8_t*)rect.pBits,
-                                                                  shareSurf->Size(),
-                                                                  rect.Pitch,
-                                                                  FORMAT_B8G8R8A8);
-      Rect drawRect(0, 0, shareSurf->Size().width, shareSurf->Size().height);
-      mapDt->DrawSurface(frameData, drawRect, drawRect);
-      mapDt->Flush();
+      nsRefPtr<gfxImageSurface> mapSurf =
+          new gfxImageSurface((uint8_t*)rect.pBits,
+                              shareSurf->Size(),
+                              rect.Pitch,
+                              gfxImageFormatARGB32);
+
+      gfxContext ctx(mapSurf);
+      ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
+      ctx.SetSource(frameData);
+      ctx.Paint();
+
+      mapSurf->Flush();
     }
   } else {
     RECT r;
     r.left = mBounds.x;
     r.top = mBounds.y;
     r.right = mBounds.XMost();
     r.bottom = mBounds.YMost();
 
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -478,17 +478,17 @@ StreamTextureSourceOGL::RetrieveTextureF
     // We don't have a valid surf to show yet.
     return false;
   }
 
   gl()->MakeCurrent();
 
   mSize = IntSize(sharedSurf->Size().width, sharedSurf->Size().height);
 
-  gfx::DataSourceSurface* toUpload = nullptr;
+  gfxImageSurface* toUpload = nullptr;
   switch (sharedSurf->Type()) {
     case SharedSurfaceType::GLTextureShare: {
       SharedSurface_GLTexture* glTexSurf = SharedSurface_GLTexture::Cast(sharedSurf);
       glTexSurf->SetConsumerGL(gl());
       mTextureHandle = glTexSurf->Texture();
       mTextureTarget = glTexSurf->TextureTarget();
       MOZ_ASSERT(mTextureHandle);
       mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
@@ -527,17 +527,17 @@ StreamTextureSourceOGL::RetrieveTextureF
       break;
     }
     default:
       MOZ_CRASH("Invalid SharedSurface type.");
   }
 
   if (toUpload) {
     // mBounds seems to end up as (0,0,0,0) a lot, so don't use it?
-    nsIntSize size(ThebesIntSize(toUpload->GetSize()));
+    nsIntSize size(toUpload->GetSize());
     nsIntRect rect(nsIntPoint(0,0), size);
     nsIntRegion bounds(rect);
     mFormat = UploadSurfaceToTexture(gl(),
                                      toUpload,
                                      bounds,
                                      mUploadTexture,
                                      true);
     mTextureHandle = mUploadTexture;
@@ -944,17 +944,17 @@ SurfaceStreamHostOGL::Lock()
     // We don't have a valid surf to show yet.
     return false;
   }
 
   mGL->MakeCurrent();
 
   mSize = IntSize(sharedSurf->Size().width, sharedSurf->Size().height);
 
-  DataSourceSurface* toUpload = nullptr;
+  gfxImageSurface* toUpload = nullptr;
   switch (sharedSurf->Type()) {
     case SharedSurfaceType::GLTextureShare: {
       SharedSurface_GLTexture* glTexSurf = SharedSurface_GLTexture::Cast(sharedSurf);
       glTexSurf->SetConsumerGL(mGL);
       mTextureHandle = glTexSurf->Texture();
       mTextureTarget = glTexSurf->TextureTarget();
       MOZ_ASSERT(mTextureHandle);
       mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
@@ -993,17 +993,17 @@ SurfaceStreamHostOGL::Lock()
       break;
     }
     default:
       MOZ_CRASH("Invalid SharedSurface type.");
   }
 
   if (toUpload) {
     // mBounds seems to end up as (0,0,0,0) a lot, so don't use it?
-    nsIntSize size(ThebesIntSize(toUpload->GetSize()));
+    nsIntSize size(toUpload->GetSize());
     nsIntRect rect(nsIntPoint(0,0), size);
     nsIntRegion bounds(rect);
     mFormat = UploadSurfaceToTexture(mGL,
                                      toUpload,
                                      bounds,
                                      mUploadTexture,
                                      true);
     mTextureHandle = mUploadTexture;