Bug 952033 - Part b: Use IntSize in CreateOffscreenSurface; r=roc
authorMs2ger <ms2ger@gmail.com>
Sun, 09 Feb 2014 09:04:38 +0100
changeset 184913 768b9e5779e3d5207ea6986b3f2e5d7c4ee91546
parent 184912 63f6af2df6027e8352c557f8d8290a345b468c4a
child 184914 2ec27f839431e624ae015938ebeb0e73442d0dfb
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs952033
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 952033 - Part b: Use IntSize in CreateOffscreenSurface; r=roc
content/canvas/src/CanvasRenderingContext2D.cpp
gfx/gl/GLTextureImage.cpp
gfx/gl/TextureImageCGL.mm
gfx/layers/Layers.cpp
gfx/layers/basic/TextureClientX11.cpp
gfx/layers/ipc/ShadowLayerUtilsX11.cpp
gfx/tests/gtest/gfxFontSelectionTest.cpp
gfx/tests/gtest/gfxTextRunPerfTest.cpp
gfx/tests/gtest/gfxWordCacheTest.cpp
gfx/thebes/gfxAndroidPlatform.cpp
gfx/thebes/gfxAndroidPlatform.h
gfx/thebes/gfxDrawable.cpp
gfx/thebes/gfxOS2Platform.cpp
gfx/thebes/gfxOS2Platform.h
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformGtk.h
gfx/thebes/gfxPlatformMac.cpp
gfx/thebes/gfxPlatformMac.h
gfx/thebes/gfxQtPlatform.cpp
gfx/thebes/gfxQtPlatform.h
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
image/src/imgFrame.cpp
layout/base/FrameLayerBuilder.cpp
layout/base/nsCSSRendering.cpp
layout/base/nsPresShell.cpp
layout/svg/nsSVGFilterInstance.cpp
layout/svg/nsSVGPatternFrame.cpp
widget/qt/nsWindow.cpp
widget/xpwidgets/PuppetWidget.cpp
widget/xpwidgets/nsBaseDragService.cpp
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -3458,17 +3458,17 @@ CanvasRenderingContext2D::DrawWindow(nsG
       error.Throw(NS_ERROR_FAILURE);
       return;
     }
 
     thebes = new gfxContext(drawDT);
     thebes->Scale(matrix._11, matrix._22);
   } else {
     drawSurf =
-      gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(ceil(sw), ceil(sh)),
+      gfxPlatform::GetPlatform()->CreateOffscreenSurface(IntSize(ceil(sw), ceil(sh)),
                                                          gfxContentType::COLOR_ALPHA);
     if (!drawSurf) {
       error.Throw(NS_ERROR_FAILURE);
       return;
     }
 
     thebes = new gfxContext(drawSurf);
     thebes->Scale(matrix._11, matrix._22);
--- a/gfx/gl/GLTextureImage.cpp
+++ b/gfx/gl/GLTextureImage.cpp
@@ -204,17 +204,18 @@ BasicTextureImage::BindTexture(GLenum aT
     mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
     mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
 }
 
 already_AddRefed<gfxASurface>
 BasicTextureImage::GetSurfaceForUpdate(const gfxIntSize& aSize, ImageFormat aFmt)
 {
     return gfxPlatform::GetPlatform()->
-        CreateOffscreenSurface(aSize, gfxASurface::ContentFromFormat(aFmt));
+        CreateOffscreenSurface(aSize.ToIntSize(),
+                               gfxASurface::ContentFromFormat(aFmt));
 }
 
 bool
 BasicTextureImage::FinishedSurfaceUpdate()
 {
     return false;
 }
 
@@ -507,17 +508,18 @@ TiledTextureImage::BeginUpdate(nsIntRegi
     mUpdateRegion = aRegion;
     bounds = aRegion.GetBounds();
 
     // update covers multiple Images - create a temp surface to paint in
     gfxImageFormat format =
         (GetContentType() == gfxContentType::COLOR) ?
         gfxImageFormat::RGB24 : gfxImageFormat::ARGB32;
     mUpdateSurface = gfxPlatform::GetPlatform()->
-        CreateOffscreenSurface(gfxIntSize(bounds.width, bounds.height), gfxASurface::ContentFromFormat(format));
+        CreateOffscreenSurface(bounds.Size().ToIntSize(),
+                               gfxASurface::ContentFromFormat(format));
     mUpdateSurface->SetDeviceOffset(gfxPoint(-bounds.x, -bounds.y));
 
     return mUpdateSurface;
 }
 
 void
 TiledTextureImage::EndUpdate()
 {
--- a/gfx/gl/TextureImageCGL.mm
+++ b/gfx/gl/TextureImageCGL.mm
@@ -1,20 +1,24 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "TextureImageCGL.h"
 #include "GLContext.h"
+#include "gfx2DGlue.h"
 #include "gfxQuartzSurface.h"
 #include "gfxPlatform.h"
 #include "gfxFailure.h"
 
 namespace mozilla {
+
+using namespace gfx;
+
 namespace gl {
 
 TextureImageCGL::TextureImageCGL(GLuint aTexture,
                 const nsIntSize& aSize,
                 GLenum aWrapMode,
                 ContentType aContentType,
                 GLContext* aContext,
                 TextureImage::Flags aFlags,
@@ -32,17 +36,17 @@ TextureImageCGL::~TextureImageCGL()
         mGLContext->MakeCurrent();
         mGLContext->fDeleteBuffers(1, &mPixelBuffer);
     }
 }
 
 already_AddRefed<gfxASurface>
 TextureImageCGL::GetSurfaceForUpdate(const gfxIntSize& aSize, ImageFormat aFmt)
 {
-    gfxIntSize size(aSize.width + 1, aSize.height + 1);
+    IntSize size(aSize.width + 1, aSize.height + 1);
     mGLContext->MakeCurrent();
     if (!mGLContext->
         IsExtensionSupported(GLContext::ARB_pixel_buffer_object))
     {
         return gfxPlatform::GetPlatform()->
             CreateOffscreenSurface(size,
                                     gfxASurface::ContentFromFormat(aFmt));
     }
@@ -73,17 +77,17 @@ TextureImageCGL::GetSurfaceForUpdate(con
 
         mGLContext->fBindBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER, 0);
         return gfxPlatform::GetPlatform()->
             CreateOffscreenSurface(size,
                                     gfxASurface::ContentFromFormat(aFmt));
     }
 
     nsRefPtr<gfxQuartzSurface> surf =
-        new gfxQuartzSurface(data, size, size.width * 4, aFmt);
+        new gfxQuartzSurface(data, ThebesIntSize(size), size.width * 4, aFmt);
 
     mBoundPixelBuffer = true;
     return surf.forget();
 }
 
 bool
 TextureImageCGL::FinishedSurfaceUpdate()
 {
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -113,17 +113,17 @@ LayerManager::GetScrollableLayers(nsTArr
   }
 }
 
 already_AddRefed<gfxASurface>
 LayerManager::CreateOptimalSurface(const gfx::IntSize &aSize,
                                    gfxImageFormat aFormat)
 {
   return gfxPlatform::GetPlatform()->
-    CreateOffscreenSurface(gfx::ThebesIntSize(aSize), gfxASurface::ContentFromFormat(aFormat));
+    CreateOffscreenSurface(aSize, gfxASurface::ContentFromFormat(aFormat));
 }
 
 already_AddRefed<gfxASurface>
 LayerManager::CreateOptimalMaskSurface(const gfx::IntSize &aSize)
 {
   return CreateOptimalSurface(aSize, gfxImageFormat::A8);
 }
 
--- a/gfx/layers/basic/TextureClientX11.cpp
+++ b/gfx/layers/basic/TextureClientX11.cpp
@@ -116,18 +116,17 @@ TextureClientX11::GetAsSurface()
 
 bool
 TextureClientX11::AllocateForSurface(IntSize aSize, TextureAllocationFlags aTextureFlags)
 {
   MOZ_ASSERT(IsValid());
   //MOZ_ASSERT(mFormat != gfx::FORMAT_YUV, "This TextureClient cannot use YCbCr data");
 
   gfxContentType contentType = ContentForFormat(mFormat);
-  gfxIntSize size = ThebesIntSize(aSize);
-  nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, contentType);
+  nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(aSize, contentType);
   if (!surface || surface->GetType() != gfxSurfaceType::Xlib) {
     NS_ERROR("creating Xlib surface failed!");
     return false;
   }
 
   mSize = aSize;
   mSurface = static_cast<gfxXlibSurface*>(surface.get());
 
--- a/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
@@ -130,17 +130,17 @@ ISurfaceAllocator::PlatformAllocSurfaceD
   if (MAP_AS_IMAGE_SURFACE & aCaps) {
     // We can't efficiently map pixmaps as gfxImageSurface, in
     // general.  Fall back on Shmem.
     return false;
   }
 
   gfxPlatform* platform = gfxPlatform::GetPlatform();
   nsRefPtr<gfxASurface> buffer =
-    platform->CreateOffscreenSurface(gfx::ThebesIntSize(aSize), aContent);
+    platform->CreateOffscreenSurface(aSize, aContent);
   if (!buffer ||
       buffer->GetType() != gfxSurfaceType::Xlib) {
     NS_ERROR("creating Xlib front/back surfaces failed!");
     return false;
   }
 
   gfxXlibSurface* bufferX = static_cast<gfxXlibSurface*>(buffer.get());
   // Release Pixmap ownership to the layers model
--- a/gfx/tests/gtest/gfxFontSelectionTest.cpp
+++ b/gfx/tests/gtest/gfxFontSelectionTest.cpp
@@ -183,17 +183,17 @@ struct TestEntry {
 static already_AddRefed<gfxContext>
 MakeContext ()
 {
     const int size = 200;
 
     nsRefPtr<gfxASurface> surface;
 
     surface = gfxPlatform::GetPlatform()->
-        CreateOffscreenSurface(gfxIntSize(size, size),
+        CreateOffscreenSurface(IntSize(size, size),
                                gfxASurface::ContentFromFormat(gfxImageFormat::RGB24));
     nsRefPtr<gfxContext> ctx = new gfxContext(surface);
     return ctx.forget();
 }
 
 TestEntry*
 AddTest (nsTArray<TestEntry>& testList,
          const char *utf8FamilyString,
--- a/gfx/tests/gtest/gfxTextRunPerfTest.cpp
+++ b/gfx/tests/gtest/gfxTextRunPerfTest.cpp
@@ -35,17 +35,17 @@ TestEntry testList[] = {
 static already_AddRefed<gfxContext>
 MakeContext ()
 {
     const int size = 200;
 
     nsRefPtr<gfxASurface> surface;
 
     surface = gfxPlatform::GetPlatform()->
-        CreateOffscreenSurface(gfxIntSize(size, size),
+        CreateOffscreenSurface(IntSize(size, size),
                                gfxASurface::ContentFromFormat(gfxImageFormat::RGB24));
     nsRefPtr<gfxContext> ctx = new gfxContext(surface);
     return ctx.forget();
 }
 
 const char* lastFamilies = nullptr;
 
 static void
--- a/gfx/tests/gtest/gfxWordCacheTest.cpp
+++ b/gfx/tests/gtest/gfxWordCacheTest.cpp
@@ -76,17 +76,17 @@ MakeTextRun(const char16_t *aText, uint3
 static already_AddRefed<gfxContext>
 MakeContext ()
 {
    const int size = 200;
 
    nsRefPtr<gfxASurface> surface;
 
    surface = gfxPlatform::GetPlatform()->
-       CreateOffscreenSurface(gfxIntSize(size, size),
+       CreateOffscreenSurface(IntSize(size, size),
                               gfxASurface::ContentFromFormat(gfxImageFormat::RGB24));
    nsRefPtr<gfxContext> ctx = new gfxContext(surface);
    return ctx.forget();
 }
 
 TEST(Gfx, WordCache) {
    gTextRuns = new FrameTextRunCache();
 
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "base/basictypes.h"
 
 #include "gfxAndroidPlatform.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/Preferences.h"
 
+#include "gfx2DGlue.h"
 #include "gfxFT2FontList.h"
 #include "gfxImageSurface.h"
 #include "mozilla/dom/ContentChild.h"
 #include "nsXULAppAPI.h"
 #include "nsIScreen.h"
 #include "nsIScreenManager.h"
 #include "nsILocaleService.h"
 #include "nsServiceManagerUtils.h"
@@ -130,21 +131,22 @@ gfxAndroidPlatform::~gfxAndroidPlatform(
 {
     cairo_debug_reset_static_data();
 
     FT_Done_Library(gPlatformFTLibrary);
     gPlatformFTLibrary = nullptr;
 }
 
 already_AddRefed<gfxASurface>
-gfxAndroidPlatform::CreateOffscreenSurface(const gfxIntSize& size,
-                                      gfxContentType contentType)
+gfxAndroidPlatform::CreateOffscreenSurface(const IntSize& size,
+                                           gfxContentType contentType)
 {
     nsRefPtr<gfxASurface> newSurface;
-    newSurface = new gfxImageSurface(size, OptimalFormatForContent(contentType));
+    newSurface = new gfxImageSurface(ThebesIntSize(size),
+                                     OptimalFormatForContent(contentType));
 
     return newSurface.forget();
 }
 
 already_AddRefed<gfxASurface>
 gfxAndroidPlatform::OptimizeImage(gfxImageSurface *aSurface,
                                   gfxImageFormat format)
 {
--- a/gfx/thebes/gfxAndroidPlatform.h
+++ b/gfx/thebes/gfxAndroidPlatform.h
@@ -28,17 +28,17 @@ public:
     gfxAndroidPlatform();
     virtual ~gfxAndroidPlatform();
 
     static gfxAndroidPlatform *GetPlatform() {
         return (gfxAndroidPlatform*) gfxPlatform::GetPlatform();
     }
 
     virtual already_AddRefed<gfxASurface>
-    CreateOffscreenSurface(const gfxIntSize& size,
+    CreateOffscreenSurface(const IntSize& size,
                            gfxContentType contentType);
     virtual already_AddRefed<gfxASurface>
     OptimizeImage(gfxImageSurface *aSurface,
                   gfxImageFormat format) MOZ_OVERRIDE;
     
     virtual gfxImageFormat GetOffscreenFormat() { return mOffscreenFormat; }
     
     mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
--- a/gfx/thebes/gfxDrawable.cpp
+++ b/gfx/thebes/gfxDrawable.cpp
@@ -191,17 +191,18 @@ gfxCallbackDrawable::gfxCallbackDrawable
  , mCallback(aCallback)
 {
 }
 
 already_AddRefed<gfxSurfaceDrawable>
 gfxCallbackDrawable::MakeSurfaceDrawable(const GraphicsFilter aFilter)
 {
     nsRefPtr<gfxASurface> surface =
-        gfxPlatform::GetPlatform()->CreateOffscreenSurface(mSize, gfxContentType::COLOR_ALPHA);
+        gfxPlatform::GetPlatform()->CreateOffscreenSurface(mSize.ToIntSize(),
+                                                           gfxContentType::COLOR_ALPHA);
     if (!surface || surface->CairoStatus() != 0)
         return nullptr;
 
     nsRefPtr<gfxContext> ctx = new gfxContext(surface);
     Draw(ctx, gfxRect(0, 0, mSize.width, mSize.height), false, aFilter);
     nsRefPtr<gfxSurfaceDrawable> drawable = new gfxSurfaceDrawable(surface, mSize);
     return drawable.forget();
 }
--- a/gfx/thebes/gfxOS2Platform.cpp
+++ b/gfx/thebes/gfxOS2Platform.cpp
@@ -44,39 +44,40 @@ gfxOS2Platform::~gfxOS2Platform()
     // clean up OS/2 cairo stuff
     cairo_os2_fini();
 #ifdef DEBUG_thebes
     printf("  cairo_os2_fini() was called\n");
 #endif
 }
 
 already_AddRefed<gfxASurface>
-gfxOS2Platform::CreateOffscreenSurface(const gfxIntSize& aSize,
+gfxOS2Platform::CreateOffscreenSurface(const IntSize& aSize,
                                        gfxContentType contentType)
 {
 #ifdef DEBUG_thebes_2
     printf("gfxOS2Platform::CreateOffscreenSurface(%d/%d, %d)\n",
            aSize.width, aSize.height, aImageFormat);
 #endif
-    gfxASurface *newSurface = nullptr;
+    nsRefPtr<gfxASurface> newSurface;
 
     // we only ever seem to get aImageFormat=0 or gfxImageFormat::ARGB32 but
     // I don't really know if we need to differ between ARGB32 and RGB24 here
     if (contentType == gfxContentType::COLOR_ALPHA ||
         contentType == gfxContentType::COLOR)
     {
-        newSurface = new gfxOS2Surface(aSize, OptimalFormatForContent(contentType));
+        newSurface = new gfxOS2Surface(ThebesIntSize(aSize),
+                                       OptimalFormatForContent(contentType));
     } else if (contentType == gfxContentType::ALPHA) {
-        newSurface = new gfxImageSurface(aSize, OptimalFormatForContent(contentType));
+        newSurface = new gfxImageSurface(ThebesIntSize(aSize),
+                                         OptimalFormatForContent(contentType));
     } else {
         return nullptr;
     }
 
-    NS_IF_ADDREF(newSurface);
-    return newSurface;
+    return newSurface.forget();
 }
 
 nsresult
 gfxOS2Platform::GetFontList(nsIAtom *aLangGroup,
                             const nsACString& aGenericFamily,
                             nsTArray<nsString>& aListOfFonts)
 {
 #ifdef DEBUG_thebes
--- a/gfx/thebes/gfxOS2Platform.h
+++ b/gfx/thebes/gfxOS2Platform.h
@@ -21,19 +21,19 @@ class gfxOS2Platform : public gfxPlatfor
 public:
     gfxOS2Platform();
     virtual ~gfxOS2Platform();
 
     static gfxOS2Platform *GetPlatform() {
         return (gfxOS2Platform*) gfxPlatform::GetPlatform();
     }
 
-    already_AddRefed<gfxASurface>
-        CreateOffscreenSurface(const gfxIntSize& size,
-                               gfxContentType contentType);
+    virtual already_AddRefed<gfxASurface>
+      CreateOffscreenSurface(const IntSize& size,
+                             gfxContentType contentType) MOZ_OVERRIDE;
 
     nsresult GetFontList(nsIAtom *aLangGroup,
                          const nsACString& aGenericFamily,
                          nsTArray<nsString>& aListOfFonts);
     nsresult UpdateFontList();
     nsresult ResolveFontName(const nsAString& aFontName,
                              FontResolverCallback aCallback,
                              void *aClosure, bool& aAborted);
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -435,17 +435,17 @@ gfxPlatform::Init()
 #if defined(XP_MACOSX) || defined(XP_WIN) || defined(ANDROID) // temporary, until this is implemented on others
     rv = gfxPlatformFontList::Init();
     if (NS_FAILED(rv)) {
         NS_RUNTIMEABORT("Could not initialize gfxPlatformFontList");
     }
 #endif
 
     gPlatform->mScreenReferenceSurface =
-        gPlatform->CreateOffscreenSurface(gfxIntSize(1,1),
+        gPlatform->CreateOffscreenSurface(IntSize(1, 1),
                                           gfxContentType::COLOR_ALPHA);
     if (!gPlatform->mScreenReferenceSurface) {
         NS_RUNTIMEABORT("Could not initialize mScreenReferenceSurface");
     }
 
     if (gPlatform->SupportsAzureContent()) {
         gPlatform->mScreenReferenceDrawTarget =
             gPlatform->CreateOffscreenContentDrawTarget(IntSize(1, 1),
@@ -628,17 +628,17 @@ gfxPlatform::CreateOffscreenImageSurface
 
   return newSurface.forget();
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatform::OptimizeImage(gfxImageSurface *aSurface,
                            gfxImageFormat format)
 {
-    const gfxIntSize& surfaceSize = aSurface->GetSize();
+    IntSize surfaceSize = aSurface->GetSize().ToIntSize();
 
 #ifdef XP_WIN
     if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() ==
         gfxWindowsPlatform::RENDER_DIRECT2D) {
         return nullptr;
     }
 #endif
     nsRefPtr<gfxASurface> optSurface = CreateOffscreenSurface(surfaceSize, gfxASurface::ContentFromFormat(format));
@@ -987,17 +987,17 @@ gfxPlatform::CreateDrawTargetForBackend(
   // create the best offscreen surface for the current system and situation. We
   // can easily take advantage of this for the Cairo backend, so that's what we
   // do.
   // mozilla::gfx::Factory can get away without having all this knowledge for
   // now, but this might need to change in the future (using
   // CreateOffscreenSurface() and CreateDrawTargetForSurface() for all
   // backends).
   if (aBackend == BackendType::CAIRO) {
-    nsRefPtr<gfxASurface> surf = CreateOffscreenSurface(ThebesIntSize(aSize),
+    nsRefPtr<gfxASurface> surf = CreateOffscreenSurface(aSize,
                                                         ContentForFormat(aFormat));
     if (!surf || surf->CairoStatus()) {
       return nullptr;
     }
 
     return CreateDrawTargetForSurface(surf, aSize);
   } else {
     return Factory::CreateDrawTarget(aBackend, aSize, aFormat);
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -153,16 +153,18 @@ GetBackendName(mozilla::gfx::BackendType
       case mozilla::gfx::BackendType::NONE:
         return "none";
   }
   MOZ_CRASH("Incomplete switch");
 }
 
 class gfxPlatform {
 public:
+    typedef mozilla::gfx::IntSize IntSize;
+
     /**
      * Return a pointer to the current active platform.
      * This is a singleton; it contains mostly convenience
      * functions to obtain platform-specific objects.
      */
     static gfxPlatform *GetPlatform();
 
 
@@ -171,18 +173,19 @@ public:
      * Init() arranges for this to be called at an appropriate time.
      */
     static void Shutdown();
 
     /**
      * Create an offscreen surface of the given dimensions
      * and image format.
      */
-    virtual already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
-                                                                 gfxContentType contentType) = 0;
+    virtual already_AddRefed<gfxASurface>
+      CreateOffscreenSurface(const IntSize& size,
+                             gfxContentType contentType) = 0;
 
     /**
      * Create an offscreen surface of the given dimensions and image format which
      * can be converted to a gfxImageSurface without copying. If we can provide
      * a platform-hosted surface, then we will return that instead of an actual
      * gfxImageSurface.
      * Sub-classes should override this method if CreateOffscreenSurface returns a
      * surface which implements GetAsImageSurface
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -6,16 +6,17 @@
 #define PANGO_ENABLE_BACKEND
 #define PANGO_ENABLE_ENGINE
 
 #include "gfxPlatformGtk.h"
 #include "prenv.h"
 
 #include "nsUnicharUtils.h"
 #include "nsUnicodeProperties.h"
+#include "gfx2DGlue.h"
 #include "gfxFontconfigUtils.h"
 #include "gfxPangoFonts.h"
 #include "gfxContext.h"
 #include "gfxUserFontSet.h"
 #include "gfxFT2FontBase.h"
 
 #include "mozilla/gfx/2D.h"
 
@@ -80,17 +81,17 @@ gfxPlatformGtk::~gfxPlatformGtk()
     // the cairo shutdown that happens in ~gfxPlatform).  It even looks
     // idempotent.  But it has fatal assertions that fire if stuff is
     // leaked, and we hit them.
     FcFini();
 #endif
 }
 
 already_AddRefed<gfxASurface>
-gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size,
+gfxPlatformGtk::CreateOffscreenSurface(const IntSize& size,
                                        gfxContentType contentType)
 {
     nsRefPtr<gfxASurface> newSurface;
     bool needsClear = true;
     gfxImageFormat imageFormat = OptimalFormatForContent(contentType);
 #ifdef MOZ_X11
     // XXX we really need a different interface here, something that passes
     // in more context, including the display and/or target surface type that
@@ -99,34 +100,35 @@ gfxPlatformGtk::CreateOffscreenSurface(c
     if (gdkScreen) {
         if (UseXRender()) {
             Screen *screen = gdk_x11_screen_get_xscreen(gdkScreen);
             XRenderPictFormat* xrenderFormat =
                 gfxXlibSurface::FindRenderFormat(DisplayOfScreen(screen),
                                                  imageFormat);
 
             if (xrenderFormat) {
-                newSurface = gfxXlibSurface::Create(screen, xrenderFormat, size);
+                newSurface = gfxXlibSurface::Create(screen, xrenderFormat,
+                                                    ThebesIntSize(size));
             }
         } else {
             // We're not going to use XRender, so we don't need to
             // search for a render format
-            newSurface = new gfxImageSurface(size, imageFormat);
+            newSurface = new gfxImageSurface(ThebesIntSize(size), imageFormat);
             // The gfxImageSurface ctor zeroes this for us, no need to
             // waste time clearing again
             needsClear = false;
         }
     }
 #endif
 
     if (!newSurface) {
         // We couldn't create a native surface for whatever reason;
         // e.g., no display, no RENDER, bad size, etc.
         // Fall back to image surface for the data.
-        newSurface = new gfxImageSurface(size, imageFormat);
+        newSurface = new gfxImageSurface(ThebesIntSize(size), imageFormat);
     }
 
     if (newSurface->CairoStatus()) {
         newSurface = nullptr; // surface isn't valid for some reason
     }
 
     if (newSurface && needsClear) {
         gfxContext tmpCtx(newSurface);
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -22,18 +22,19 @@ class gfxPlatformGtk : public gfxPlatfor
 public:
     gfxPlatformGtk();
     virtual ~gfxPlatformGtk();
 
     static gfxPlatformGtk *GetPlatform() {
         return (gfxPlatformGtk*) gfxPlatform::GetPlatform();
     }
 
-    already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
-                                                         gfxContentType contentType);
+    virtual already_AddRefed<gfxASurface>
+      CreateOffscreenSurface(const IntSize& size,
+                             gfxContentType contentType) MOZ_OVERRIDE;
 
     mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
       GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
 
     nsresult GetFontList(nsIAtom *aLangGroup,
                          const nsACString& aGenericFamily,
                          nsTArray<nsString>& aListOfFonts);
 
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -85,29 +85,31 @@ gfxPlatformMac::CreatePlatformFontList()
     if (NS_SUCCEEDED(list->InitFontList())) {
         return list;
     }
     gfxPlatformFontList::Shutdown();
     return nullptr;
 }
 
 already_AddRefed<gfxASurface>
-gfxPlatformMac::CreateOffscreenSurface(const gfxIntSize& size,
+gfxPlatformMac::CreateOffscreenSurface(const IntSize& size,
                                        gfxContentType contentType)
 {
     nsRefPtr<gfxASurface> newSurface =
-      new gfxQuartzSurface(size, OptimalFormatForContent(contentType));
+      new gfxQuartzSurface(ThebesIntSize(size),
+                           OptimalFormatForContent(contentType));
     return newSurface.forget();
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatformMac::CreateOffscreenImageSurface(const gfxIntSize& aSize,
                                             gfxContentType aContentType)
 {
-    nsRefPtr<gfxASurface> surface = CreateOffscreenSurface(aSize, aContentType);
+    nsRefPtr<gfxASurface> surface =
+        CreateOffscreenSurface(aSize.ToIntSize(), aContentType);
 #ifdef DEBUG
     nsRefPtr<gfxImageSurface> imageSurface = surface->GetAsImageSurface();
     NS_ASSERTION(imageSurface, "Surface cannot be converted to a gfxImageSurface");
 #endif
     return surface.forget();
 }
 
 
--- a/gfx/thebes/gfxPlatformMac.h
+++ b/gfx/thebes/gfxPlatformMac.h
@@ -20,18 +20,20 @@ class gfxPlatformMac : public gfxPlatfor
 public:
     gfxPlatformMac();
     virtual ~gfxPlatformMac();
 
     static gfxPlatformMac *GetPlatform() {
         return (gfxPlatformMac*) gfxPlatform::GetPlatform();
     }
 
-    already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
-                                                         gfxContentType contentType);
+    virtual already_AddRefed<gfxASurface>
+      CreateOffscreenSurface(const IntSize& size,
+                             gfxContentType contentType) MOZ_OVERRIDE;
+
     virtual already_AddRefed<gfxASurface>
       CreateOffscreenImageSurface(const gfxIntSize& aSize,
                                   gfxContentType aContentType);
 
     already_AddRefed<gfxASurface> OptimizeImage(gfxImageSurface *aSurface,
                                                 gfxImageFormat format);
 
     mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
--- a/gfx/thebes/gfxQtPlatform.cpp
+++ b/gfx/thebes/gfxQtPlatform.cpp
@@ -161,42 +161,43 @@ gfxQtPlatform::GetXScreen(QWidget* aWind
                          (int)(intptr_t)qApp->platformNativeInterface()->
                            nativeResourceForWindow("screen",
                              aWindow ? aWindow->windowHandle() : nullptr));
 #endif
 }
 #endif
 
 already_AddRefed<gfxASurface>
-gfxQtPlatform::CreateOffscreenSurface(const gfxIntSize& size,
+gfxQtPlatform::CreateOffscreenSurface(const IntSize& size,
                                       gfxContentType contentType)
 {
     nsRefPtr<gfxASurface> newSurface = nullptr;
 
     gfxImageFormat imageFormat = OptimalFormatForContent(contentType);
 
 #ifdef CAIRO_HAS_QT_SURFACE
     if (mRenderMode == RENDER_QPAINTER) {
-      newSurface = new gfxQPainterSurface(size, imageFormat);
+      newSurface = new gfxQPainterSurface(ThebesIntSize(size), imageFormat);
       return newSurface.forget();
     }
 #endif
 
     if ((mRenderMode == RENDER_BUFFERED || mRenderMode == RENDER_DIRECT) &&
         sDefaultQtPaintEngineType != QPaintEngine::X11) {
-      newSurface = new gfxImageSurface(size, imageFormat);
+      newSurface = new gfxImageSurface(ThebesIntSize(size), imageFormat);
       return newSurface.forget();
     }
 
 #ifdef MOZ_X11
     XRenderPictFormat* xrenderFormat =
         gfxXlibSurface::FindRenderFormat(GetXDisplay(), imageFormat);
 
     Screen* screen = GetXScreen();
-    newSurface = gfxXlibSurface::Create(screen, xrenderFormat, size);
+    newSurface = gfxXlibSurface::Create(screen, xrenderFormat,
+                                        ThebesIntSize(size));
 #endif
 
     if (newSurface) {
         gfxContext ctx(newSurface);
         ctx.SetOperator(gfxContext::OPERATOR_CLEAR);
         ctx.Paint();
     }
 
--- a/gfx/thebes/gfxQtPlatform.h
+++ b/gfx/thebes/gfxQtPlatform.h
@@ -33,18 +33,19 @@ public:
 
     gfxQtPlatform();
     virtual ~gfxQtPlatform();
 
     static gfxQtPlatform *GetPlatform() {
         return (gfxQtPlatform*) gfxPlatform::GetPlatform();
     }
 
-    already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
-                                                         gfxContentType contentType);
+    virtual already_AddRefed<gfxASurface>
+      CreateOffscreenSurface(const IntSize& size,
+                             gfxContentType contentType) MOZ_OVERRIDE;
 
     mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
       GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
 
     nsresult GetFontList(nsIAtom *aLangGroup,
                          const nsACString& aGenericFamily,
                          nsTArray<nsString>& aListOfFonts);
 
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -645,33 +645,36 @@ gfxWindowsPlatform::CreatePlatformFontLi
         return pfl;
     }
 
     gfxPlatformFontList::Shutdown();
     return nullptr;
 }
 
 already_AddRefed<gfxASurface>
-gfxWindowsPlatform::CreateOffscreenSurface(const gfxIntSize& size,
+gfxWindowsPlatform::CreateOffscreenSurface(const IntSize& size,
                                            gfxContentType contentType)
 {
     nsRefPtr<gfxASurface> surf = nullptr;
 
 #ifdef CAIRO_HAS_WIN32_SURFACE
     if (mRenderMode == RENDER_GDI)
-        surf = new gfxWindowsSurface(size, OptimalFormatForContent(contentType));
+        surf = new gfxWindowsSurface(ThebesIntSize(size),
+                                     OptimalFormatForContent(contentType));
 #endif
 
 #ifdef CAIRO_HAS_D2D_SURFACE
     if (mRenderMode == RENDER_DIRECT2D)
-        surf = new gfxD2DSurface(size, OptimalFormatForContent(contentType));
+        surf = new gfxD2DSurface(ThebesIntSize(size),
+                                 OptimalFormatForContent(contentType));
 #endif
 
     if (!surf || surf->CairoStatus()) {
-        surf = new gfxImageSurface(size, OptimalFormatForContent(contentType));
+        surf = new gfxImageSurface(ThebesIntSize(size),
+                                   OptimalFormatForContent(contentType));
     }
 
     return surf.forget();
 }
 
 already_AddRefed<gfxASurface>
 gfxWindowsPlatform::CreateOffscreenImageSurface(const gfxIntSize& aSize,
                                                 gfxContentType aContentType)
@@ -679,17 +682,18 @@ gfxWindowsPlatform::CreateOffscreenImage
 #ifdef CAIRO_HAS_D2D_SURFACE
     if (mRenderMode == RENDER_DIRECT2D) {
         nsRefPtr<gfxASurface> surface =
           new gfxImageSurface(aSize, OptimalFormatForContent(aContentType));
         return surface.forget();
     }
 #endif
 
-    nsRefPtr<gfxASurface> surface = CreateOffscreenSurface(aSize, aContentType);
+    nsRefPtr<gfxASurface> surface = CreateOffscreenSurface(aSize.ToIntSize(),
+                                                           aContentType);
 #ifdef DEBUG
     nsRefPtr<gfxImageSurface> imageSurface = surface->GetAsImageSurface();
     NS_ASSERTION(imageSurface, "Surface cannot be converted to a gfxImageSurface");
 #endif
     return surface.forget();
 }
 
 TemporaryRef<ScaledFont>
--- a/gfx/thebes/gfxWindowsPlatform.h
+++ b/gfx/thebes/gfxWindowsPlatform.h
@@ -120,18 +120,19 @@ public:
     gfxWindowsPlatform();
     virtual ~gfxWindowsPlatform();
     static gfxWindowsPlatform *GetPlatform() {
         return (gfxWindowsPlatform*) gfxPlatform::GetPlatform();
     }
 
     virtual gfxPlatformFontList* CreatePlatformFontList();
 
-    already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
-                                                         gfxContentType contentType);
+    virtual already_AddRefed<gfxASurface>
+      CreateOffscreenSurface(const IntSize& size,
+                             gfxContentType contentType) MOZ_OVERRIDE;
     virtual already_AddRefed<gfxASurface>
       CreateOffscreenImageSurface(const gfxIntSize& aSize,
                                   gfxContentType aContentType);
 
     virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
       GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
     virtual already_AddRefed<gfxASurface>
       GetThebesSurfaceForDrawTarget(mozilla::gfx::DrawTarget *aTarget);
--- a/image/src/imgFrame.cpp
+++ b/image/src/imgFrame.cpp
@@ -4,16 +4,17 @@
  * 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 "imgFrame.h"
 #include "DiscardTracker.h"
 
 #include "prenv.h"
 
+#include "gfx2DGlue.h"
 #include "gfxPlatform.h"
 #include "gfxUtils.h"
 
 static bool gDisableOptimize = false;
 
 #include "cairo.h"
 #include "GeckoProfiler.h"
 #include "mozilla/Likely.h"
@@ -26,16 +27,17 @@ static bool gDisableOptimize = false;
 #include "gfxWindowsPlatform.h"
 
 /* Whether to use the windows surface; only for desktop win32 */
 #define USE_WIN_SURFACE 1
 
 #endif
 
 using namespace mozilla;
+using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 // Returns true if an image of aWidth x aHeight is allowed and legal.
 static bool AllowedImageSize(int32_t aWidth, int32_t aHeight)
 {
   // reject over-wide or over-tall images
   const int32_t k64KLimit = 0x0000FFFF;
   if (MOZ_UNLIKELY(aWidth > k64KLimit || aHeight > k64KLimit )) {
@@ -338,20 +340,20 @@ imgFrame::SurfaceForDrawing(bool        
                             bool               aDoTile,
                             const nsIntMargin& aPadding,
                             gfxMatrix&         aUserSpaceToImageSpace,
                             gfxRect&           aFill,
                             gfxRect&           aSubimage,
                             gfxRect&           aSourceRect,
                             gfxRect&           aImageRect)
 {
-  gfxIntSize size(int32_t(aImageRect.Width()), int32_t(aImageRect.Height()));
+  IntSize size(int32_t(aImageRect.Width()), int32_t(aImageRect.Height()));
   if (!aDoPadding && !aDoPartialDecode) {
     NS_ASSERTION(!mSinglePixel, "This should already have been handled");
-    return SurfaceWithFormat(new gfxSurfaceDrawable(ThebesSurface(), size), mFormat);
+    return SurfaceWithFormat(new gfxSurfaceDrawable(ThebesSurface(), ThebesIntSize(size)), mFormat);
   }
 
   gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width, mDecoded.height);
 
   if (aDoTile || mSinglePixel) {
     // Create a temporary surface.
     // Give this surface an alpha channel because there are
     // transparent pixels in the padding or undecoded area
@@ -367,17 +369,17 @@ imgFrame::SurfaceForDrawing(bool        
     if (mSinglePixel) {
       tmpCtx.SetDeviceColor(mSinglePixelColor);
     } else {
       tmpCtx.SetSource(ThebesSurface(), gfxPoint(aPadding.left, aPadding.top));
     }
     tmpCtx.Rectangle(available);
     tmpCtx.Fill();
 
-    return SurfaceWithFormat(new gfxSurfaceDrawable(surface, size), format);
+    return SurfaceWithFormat(new gfxSurfaceDrawable(surface, ThebesIntSize(size)), format);
   }
 
   // Not tiling, and we have a surface, so we can account for
   // padding and/or a partial decode just by twiddling parameters.
   // First, update our user-space fill rect.
   aSourceRect = aSourceRect.Intersect(available);
   gfxMatrix imageSpaceToUserSpace = aUserSpaceToImageSpace;
   imageSpaceToUserSpace.Invert();
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -2197,17 +2197,17 @@ PaintInactiveLayer(nsDisplayListBuilder*
   nsRefPtr<gfxContext> context = aContext;
 #ifdef MOZ_DUMP_PAINTING
   int32_t appUnitsPerDevPixel = AppUnitsPerDevPixel(aItem);
   nsIntRect itemVisibleRect =
     aItem->GetVisibleRect().ToOutsidePixels(appUnitsPerDevPixel);
 
   nsRefPtr<gfxASurface> surf;
   if (gfxUtils::sDumpPainting) {
-    surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(itemVisibleRect.Size(),
+    surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(itemVisibleRect.Size().ToIntSize(),
                                                               gfxContentType::COLOR_ALPHA);
     surf->SetDeviceOffset(-itemVisibleRect.TopLeft());
     context = new gfxContext(surf);
   }
 #endif
   basic->BeginTransaction();
   basic->SetTarget(context);
 
@@ -3387,17 +3387,17 @@ FrameLayerBuilder::GetThebesLayerScaleFo
 static void DebugPaintItem(nsRenderingContext* aDest, nsDisplayItem *aItem, nsDisplayListBuilder* aBuilder)
 {
   bool snap;
   nsRect appUnitBounds = aItem->GetBounds(aBuilder, &snap);
   gfxRect bounds(appUnitBounds.x, appUnitBounds.y, appUnitBounds.width, appUnitBounds.height);
   bounds.ScaleInverse(aDest->AppUnitsPerDevPixel());
 
   nsRefPtr<gfxASurface> surf =
-    gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(bounds.width, bounds.height),
+    gfxPlatform::GetPlatform()->CreateOffscreenSurface(IntSize(bounds.width, bounds.height),
                                                        gfxContentType::COLOR_ALPHA);
   surf->SetDeviceOffset(-bounds.TopLeft());
   nsRefPtr<gfxContext> context = new gfxContext(surf);
   nsRefPtr<nsRenderingContext> ctx = new nsRenderingContext();
   ctx->Init(aDest->DeviceContext(), context);
 
   aItem->Paint(aBuilder, ctx);
   DumpPaintedImage(aItem, surf);
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -4732,17 +4732,17 @@ nsImageRenderer::DrawBorderImageComponen
 
     // draw the source image slice into an intermediate surface
     nsPresContext* presContext = mForFrame->PresContext();
     gfxRect srcRect = gfxRect(presContext->CSSPixelsToDevPixels(aSrc.x),
                               presContext->CSSPixelsToDevPixels(aSrc.y),
                               presContext->CSSPixelsToDevPixels(aSrc.width),
                               presContext->CSSPixelsToDevPixels(aSrc.height));
     nsRefPtr<gfxASurface> srcSlice = gfxPlatform::GetPlatform()->
-      CreateOffscreenSurface(gfxIntSize(srcRect.width, srcRect.height),
+      CreateOffscreenSurface(IntSize(srcRect.width, srcRect.height),
                              gfxContentType::COLOR_ALPHA);
     nsRefPtr<gfxContext> ctx = new gfxContext(srcSlice);
 
     // grab the entire source
     nsRefPtr<gfxDrawable> drawable = DrawableForElement(nsRect(nsPoint(), mSize),
                                                         aRenderingContext);
     if (!drawable) {
       NS_WARNING("Could not create drawable for element");
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -172,16 +172,17 @@
 #endif
 
 #define ANCHOR_SCROLL_FLAGS \
   (nsIPresShell::SCROLL_OVERFLOW_HIDDEN | nsIPresShell::SCROLL_NO_PARENT_FRAMES)
 
 using namespace mozilla;
 using namespace mozilla::css;
 using namespace mozilla::dom;
+using namespace mozilla::gfx;
 using namespace mozilla::layers;
 using namespace mozilla::gfx;
 
 CapturingContentInfo nsIPresShell::gCaptureInfo =
   { false /* mAllowed */, false /* mPointerLock */, false /* mRetargetToElement */,
     false /* mPreventDrag */, nullptr /* mContent */ };
 nsIContent* nsIPresShell::gKeyDownTarget;
 nsRefPtrHashtable<nsUint32HashKey, dom::Touch>* nsIPresShell::gCaptureTouchList;
@@ -8917,17 +8918,17 @@ DumpToPNG(nsIPresShell* shell, nsAString
   nsRefPtr<gfxImageSurface> imgSurface =
      new gfxImageSurface(gfxIntSize(width, height),
                          gfxImageFormat::ARGB32);
 
   nsRefPtr<gfxContext> imgContext = new gfxContext(imgSurface);
 
   nsRefPtr<gfxASurface> surface = 
     gfxPlatform::GetPlatform()->
-    CreateOffscreenSurface(gfxIntSize(width, height),
+    CreateOffscreenSurface(IntSize(width, height),
       gfxASurface::ContentFromFormat(gfxImageFormat::ARGB32));
   NS_ENSURE_TRUE(surface, NS_ERROR_OUT_OF_MEMORY);
 
   nsRefPtr<gfxContext> context = new gfxContext(surface);
 
   shell->RenderDocument(r, 0, NS_RGB(255, 255, 0), context);
 
   imgContext->DrawSurface(surface, gfxSize(width, height));
--- a/layout/svg/nsSVGFilterInstance.cpp
+++ b/layout/svg/nsSVGFilterInstance.cpp
@@ -525,17 +525,17 @@ nsSVGFilterInstance::BuildSourcePaint(So
 {
   nsIntRect neededRect = aSource->mNeededBounds;
 
   RefPtr<DrawTarget> offscreenDT;
   nsRefPtr<gfxASurface> offscreenSurface;
   nsRefPtr<gfxContext> ctx;
   if (aTargetSurface) {
     offscreenSurface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(
-      neededRect.Size(), gfxContentType::COLOR_ALPHA);
+      neededRect.Size().ToIntSize(), gfxContentType::COLOR_ALPHA);
     if (!offscreenSurface || offscreenSurface->CairoStatus()) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
     ctx = new gfxContext(offscreenSurface);
   } else {
     offscreenDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
       ToIntSize(neededRect.Size()), SurfaceFormat::B8G8R8A8);
     if (!offscreenDT) {
@@ -612,17 +612,17 @@ nsSVGFilterInstance::BuildSourceImage(gf
     return NS_OK;
   }
 
   RefPtr<DrawTarget> offscreenDT;
   nsRefPtr<gfxASurface> offscreenSurface;
   nsRefPtr<gfxContext> ctx;
   if (aTargetSurface) {
     offscreenSurface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(
-      neededRect.Size(), gfxContentType::COLOR_ALPHA);
+      neededRect.Size().ToIntSize(), gfxContentType::COLOR_ALPHA);
     if (!offscreenSurface || offscreenSurface->CairoStatus()) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
     ctx = new gfxContext(offscreenSurface);
   } else {
     offscreenDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
       ToIntSize(neededRect.Size()), SurfaceFormat::B8G8R8A8);
     if (!offscreenDT) {
@@ -693,17 +693,17 @@ nsSVGFilterInstance::Render(gfxContext* 
     return NS_OK;
   }
 
   Matrix oldDTMatrix;
   nsRefPtr<gfxASurface> resultImage;
   RefPtr<DrawTarget> dt;
   if (aContext->IsCairo()) {
     resultImage =
-      gfxPlatform::GetPlatform()->CreateOffscreenSurface(filterRect.Size(),
+      gfxPlatform::GetPlatform()->CreateOffscreenSurface(filterRect.Size().ToIntSize(),
                                                          gfxContentType::COLOR_ALPHA);
     if (!resultImage || resultImage->CairoStatus())
       return NS_ERROR_OUT_OF_MEMORY;
 
     // Create a Cairo DrawTarget around resultImage.
     dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(
            resultImage, ToIntSize(filterRect.Size()));
   } else {
--- a/layout/svg/nsSVGPatternFrame.cpp
+++ b/layout/svg/nsSVGPatternFrame.cpp
@@ -332,19 +332,19 @@ nsSVGPatternFrame::PaintPattern(gfxASurf
     return NS_ERROR_FAILURE;
   }
 
   // Now that we have all of the necessary geometries, we can
   // create our surface.
   gfxRect transformedBBox = patternTransform.TransformBounds(bbox);
 
   bool resultOverflows;
-  gfxIntSize surfaceSize =
+  IntSize surfaceSize =
     nsSVGUtils::ConvertToSurfaceSize(
-      transformedBBox.Size(), &resultOverflows);
+      transformedBBox.Size(), &resultOverflows).ToIntSize();
 
   // 0 disables rendering, < 0 is an error
   if (surfaceSize.width <= 0 || surfaceSize.height <= 0)
     return NS_ERROR_FAILURE;
 
   gfxFloat patternWidth = bbox.Width();
   gfxFloat patternHeight = bbox.Height();
 
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -295,17 +295,18 @@ UpdateOffScreenBuffers(int aDepth, QSize
                                            aDepth);
             gBufferSurface = gShmImage->AsSurface();
             return true;
         }
     }
 #endif
 
     gBufferSurface = gfxPlatform::GetPlatform()->
-        CreateOffscreenSurface(gBufferMaxSize, gfxASurface::ContentFromFormat(format));
+        CreateOffscreenSurface(gBufferMaxSize.ToIntSize(),
+                               gfxASurface::ContentFromFormat(format));
 
     return true;
 }
 
 nsWindow::~nsWindow()
 {
     LOG(("%s [%p]\n", __PRETTY_FUNCTION__, (void *)this));
 
--- a/widget/xpwidgets/PuppetWidget.cpp
+++ b/widget/xpwidgets/PuppetWidget.cpp
@@ -19,16 +19,17 @@
 #include "mozilla/TextEvents.h"
 #include "PuppetWidget.h"
 #include "nsIWidgetListener.h"
 #include "nsIMEStateManager.h"
 #include "TextComposition.h"
 
 using namespace mozilla::dom;
 using namespace mozilla::hal;
+using namespace mozilla::gfx;
 using namespace mozilla::layers;
 using namespace mozilla::widget;
 
 static void
 InvalidateRegion(nsIWidget* aWidget, const nsIntRegion& aRegion)
 {
   nsIntRegionRectIterator it(aRegion);
   while(const nsIntRect* r = it.Next()) {
@@ -98,17 +99,17 @@ PuppetWidget::Create(nsIWidget        *a
 
   BaseCreate(nullptr, aRect, aContext, aInitData);
 
   mBounds = aRect;
   mEnabled = true;
   mVisible = true;
 
   mSurface = gfxPlatform::GetPlatform()
-             ->CreateOffscreenSurface(gfxIntSize(1, 1),
+             ->CreateOffscreenSurface(IntSize(1, 1),
                                       gfxASurface::ContentFromFormat(gfxImageFormat::ARGB32));
 
   mIMEComposing = false;
   mNeedIMEStateInit = MightNeedIMEFocus(aInitData);
 
   PuppetWidget* parent = static_cast<PuppetWidget*>(aParent);
   if (parent) {
     parent->SetChild(this);
--- a/widget/xpwidgets/nsBaseDragService.cpp
+++ b/widget/xpwidgets/nsBaseDragService.cpp
@@ -613,18 +613,17 @@ nsBaseDragService::DrawDragForImage(nsPr
     aScreenDragRect->x = NSToIntFloor(aScreenX - float(mImageX) * scale);
     aScreenDragRect->y = NSToIntFloor(aScreenY - float(mImageY) * scale);
     aScreenDragRect->width = destSize.width;
     aScreenDragRect->height = destSize.height;
   }
 
   RefPtr<DrawTarget> dt =
     gfxPlatform::GetPlatform()->
-      CreateOffscreenContentDrawTarget(IntSize(destSize.width, destSize.height),
-
+      CreateOffscreenContentDrawTarget(destSize.ToIntSize(),
                                        SurfaceFormat::B8G8R8A8);
   if (!dt)
     return NS_ERROR_FAILURE;
 
   nsRefPtr<gfxContext> ctx = new gfxContext(dt);
   if (!ctx)
     return NS_ERROR_FAILURE;