Back out f872d288480b:9b86b4e60b29 (bug 929513) for failing to build on Windows
authorPhil Ringnalda <philringnalda@gmail.com>
Sun, 27 Oct 2013 15:38:40 -0700
changeset 166245 a2eecdb6d6b0ced94b3ffe8a47d831173e390d90
parent 166244 f872d288480b9079697d4c52bc26d1116e5c3131
child 166246 2d537818dfb9e359b20bcf8a6fab80f7e7edb7ea
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs929513
milestone27.0a1
backs outf872d288480b9079697d4c52bc26d1116e5c3131
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Back out f872d288480b:9b86b4e60b29 (bug 929513) for failing to build on Windows CLOSED TREE
content/canvas/src/CanvasRenderingContext2D.cpp
content/media/MediaDecoderReader.cpp
content/media/MediaStreamGraph.cpp
content/media/VideoFrameContainer.cpp
content/media/plugins/MediaPluginReader.cpp
content/media/webrtc/MediaEngineDefault.cpp
content/media/webrtc/MediaEngineTabVideoSource.cpp
content/media/webrtc/MediaEngineWebRTCVideo.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/PBrowser.ipdl
dom/ipc/PContent.ipdl
gfx/gl/GLTextureImage.cpp
gfx/gl/GLTextureImage.h
gfx/ipc/GfxMessageUtils.h
gfx/layers/Compositor.h
gfx/layers/D3D9SurfaceImage.cpp
gfx/layers/D3D9SurfaceImage.h
gfx/layers/GrallocImages.cpp
gfx/layers/ImageContainer.cpp
gfx/layers/ImageContainer.h
gfx/layers/ImageLayers.cpp
gfx/layers/ImageLayers.h
gfx/layers/LayerTreeInvalidation.cpp
gfx/layers/Layers.h
gfx/layers/SharedTextureImage.h
gfx/layers/YCbCrImageDataSerializer.cpp
gfx/layers/YCbCrImageDataSerializer.h
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicCompositor.h
gfx/layers/basic/BasicImageLayer.cpp
gfx/layers/basic/BasicImages.cpp
gfx/layers/client/ClientImageLayer.cpp
gfx/layers/client/ClientTiledThebesLayer.cpp
gfx/layers/client/ImageClient.cpp
gfx/layers/client/TextureClient.cpp
gfx/layers/client/TextureClient.h
gfx/layers/client/TiledContentClient.cpp
gfx/layers/client/TiledContentClient.h
gfx/layers/composite/AsyncCompositionManager.cpp
gfx/layers/composite/CompositableHost.h
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/composite/LayerManagerComposite.h
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/ThebesLayerComposite.cpp
gfx/layers/composite/ThebesLayerComposite.h
gfx/layers/composite/TiledContentHost.cpp
gfx/layers/composite/TiledContentHost.h
gfx/layers/d3d10/ImageLayerD3D10.cpp
gfx/layers/d3d10/ImageLayerD3D10.h
gfx/layers/d3d10/LayerManagerD3D10.h
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/CompositorD3D11.h
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d9/CompositorD3D9.cpp
gfx/layers/d3d9/CompositorD3D9.h
gfx/layers/d3d9/ImageLayerD3D9.cpp
gfx/layers/d3d9/LayerManagerD3D9.h
gfx/layers/d3d9/TextureD3D9.cpp
gfx/layers/ipc/ISurfaceAllocator.cpp
gfx/layers/ipc/ISurfaceAllocator.h
gfx/layers/ipc/ImageBridgeChild.cpp
gfx/layers/ipc/ImageBridgeChild.h
gfx/layers/ipc/ImageBridgeParent.cpp
gfx/layers/ipc/ImageBridgeParent.h
gfx/layers/ipc/LayerTransactionChild.cpp
gfx/layers/ipc/LayerTransactionChild.h
gfx/layers/ipc/LayerTransactionParent.cpp
gfx/layers/ipc/LayerTransactionParent.h
gfx/layers/ipc/LayersMessages.ipdlh
gfx/layers/ipc/LayersSurfaces.ipdlh
gfx/layers/ipc/PImageBridge.ipdl
gfx/layers/ipc/PLayerTransaction.ipdl
gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp
gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
gfx/layers/ipc/ShadowLayerUtilsMac.cpp
gfx/layers/ipc/ShadowLayerUtilsX11.cpp
gfx/layers/ipc/ShadowLayers.h
gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
gfx/layers/ipc/SharedRGBImage.cpp
gfx/layers/ipc/SharedRGBImage.h
gfx/layers/opengl/CanvasLayerOGL.cpp
gfx/layers/opengl/CanvasLayerOGL.h
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/CompositorOGL.h
gfx/layers/opengl/GrallocTextureClient.cpp
gfx/layers/opengl/GrallocTextureClient.h
gfx/layers/opengl/ImageLayerOGL.cpp
gfx/layers/opengl/ImageLayerOGL.h
gfx/layers/opengl/LayerManagerOGL.h
gfx/layers/opengl/LayerManagerOGLProgram.cpp
gfx/layers/opengl/TextureHostOGL.cpp
gfx/tests/gtest/TestTextures.cpp
gfx/thebes/gfxImageSurface.cpp
gfx/thebes/gfxImageSurface.h
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
layout/base/nsDisplayList.cpp
layout/base/nsLayoutUtils.cpp
layout/generic/nsObjectFrame.cpp
layout/generic/nsVideoFrame.cpp
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
widget/android/nsScreenManagerAndroid.cpp
widget/android/nsWindow.cpp
widget/android/nsWindow.h
xpcom/base/nsMemoryReporterManager.cpp
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -3974,13 +3974,13 @@ CanvasRenderingContext2D::MarkContextCle
   mIsEntireFrameInvalid = false;
   mInvalidateCount = 0;
 }
 
 
 bool
 CanvasRenderingContext2D::ShouldForceInactiveLayer(LayerManager *aManager)
 {
-  return !aManager->CanUseCanvasLayerForSize(LayerIntSize(mWidth, mHeight));
+  return !aManager->CanUseCanvasLayerForSize(gfxIntSize(mWidth, mHeight));
 }
 
 }
 }
--- a/content/media/MediaDecoderReader.cpp
+++ b/content/media/MediaDecoderReader.cpp
@@ -234,28 +234,28 @@ VideoData* VideoData::Create(VideoInfo& 
   }
   NS_ASSERTION(v->mImage->GetFormat() == PLANAR_YCBCR ||
                v->mImage->GetFormat() == GRALLOC_PLANAR_YCBCR,
                "Wrong format?");
   PlanarYCbCrImage* videoImage = static_cast<PlanarYCbCrImage*>(v->mImage.get());
 
   PlanarYCbCrData data;
   data.mYChannel = Y.mData + Y.mOffset;
-  data.mYSize = LayerIntSize(Y.mWidth, Y.mHeight);
+  data.mYSize = gfxIntSize(Y.mWidth, Y.mHeight);
   data.mYStride = Y.mStride;
   data.mYSkip = Y.mSkip;
   data.mCbChannel = Cb.mData + Cb.mOffset;
   data.mCrChannel = Cr.mData + Cr.mOffset;
-  data.mCbCrSize = LayerIntSize(Cb.mWidth, Cb.mHeight);
+  data.mCbCrSize = gfxIntSize(Cb.mWidth, Cb.mHeight);
   data.mCbCrStride = Cb.mStride;
   data.mCbSkip = Cb.mSkip;
   data.mCrSkip = Cr.mSkip;
   data.mPicX = aPicture.x;
   data.mPicY = aPicture.y;
-  data.mPicSize = LayerIntSize(aPicture.width, aPicture.height);
+  data.mPicSize = gfxIntSize(aPicture.width, aPicture.height);
   data.mStereoMode = aInfo.mStereoMode;
 
   videoImage->SetDelayedConversion(true);
   if (!aImage) {
     videoImage->SetData(data);
   } else {
     videoImage->SetDataNoCopy(data);
   }
--- a/content/media/MediaStreamGraph.cpp
+++ b/content/media/MediaStreamGraph.cpp
@@ -871,17 +871,17 @@ SetImageToBlackPixel(PlanarYCbCrImage* a
 {
   uint8_t blackPixel[] = { 0x10, 0x80, 0x80 };
 
   PlanarYCbCrData data;
   data.mYChannel = blackPixel;
   data.mCbChannel = blackPixel + 1;
   data.mCrChannel = blackPixel + 2;
   data.mYStride = data.mCbCrStride = 1;
-  data.mPicSize = data.mYSize = data.mCbCrSize = LayerIntSize(1, 1);
+  data.mPicSize = data.mYSize = data.mCbCrSize = gfxIntSize(1, 1);
   aImage->SetData(data);
 }
 
 void
 MediaStreamGraphImpl::PlayVideo(MediaStream* aStream)
 {
   MOZ_ASSERT(mRealtime, "Should only attempt to play video in realtime mode");
 
--- a/content/media/VideoFrameContainer.cpp
+++ b/content/media/VideoFrameContainer.cpp
@@ -35,34 +35,34 @@ void VideoFrameContainer::SetCurrentFram
 {
   MutexAutoLock lock(mMutex);
 
   if (aIntrinsicSize != mIntrinsicSize) {
     mIntrinsicSize = aIntrinsicSize;
     mIntrinsicSizeChanged = true;
   }
 
-  gfx::IntSize oldFrameSize = mImageContainer->GetCurrentSize();
+  gfxIntSize oldFrameSize = mImageContainer->GetCurrentSize();
   TimeStamp lastPaintTime = mImageContainer->GetPaintTime();
   if (!lastPaintTime.IsNull() && !mPaintTarget.IsNull()) {
     mPaintDelay = lastPaintTime - mPaintTarget;
   }
 
   // When using the OMX decoder, destruction of the current image can indirectly
   //  block on main thread I/O. If we let this happen while holding onto
   //  |mImageContainer|'s lock, then when the main thread then tries to
   //  composite it can then block on |mImageContainer|'s lock, causing a
   //  deadlock. We use this hack to defer the destruction of the current image
   //  until it is safe.
   nsRefPtr<Image> kungFuDeathGrip;
   kungFuDeathGrip = mImageContainer->LockCurrentImage();
   mImageContainer->UnlockCurrentImage();
 
   mImageContainer->SetCurrentImage(aImage);
-  gfx::IntSize newFrameSize = mImageContainer->GetCurrentSize();
+  gfxIntSize newFrameSize = mImageContainer->GetCurrentSize();
   if (oldFrameSize != newFrameSize) {
     mImageSizeChanged = true;
   }
 
   mPaintTarget = aTargetTime;
 }
 
 void VideoFrameContainer::Reset()
--- a/content/media/plugins/MediaPluginReader.cpp
+++ b/content/media/plugins/MediaPluginReader.cpp
@@ -8,17 +8,16 @@
 #include "mozilla/dom/TimeRanges.h"
 #include "MediaResource.h"
 #include "VideoUtils.h"
 #include "MediaPluginDecoder.h"
 #include "MediaPluginHost.h"
 #include "MediaDecoderStateMachine.h"
 #include "ImageContainer.h"
 #include "AbstractMediaDecoder.h"
-#include "mozilla/gfx/Point.h"
 
 namespace mozilla {
 
 typedef mozilla::layers::Image Image;
 
 MediaPluginReader::MediaPluginReader(AbstractMediaDecoder *aDecoder,
                                      const nsACString& aContentType) :
   MediaDecoderReader(aDecoder),
@@ -165,20 +164,20 @@ bool MediaPluginReader::DecodeVideoFrame
     }
 
     if (frame.mSize == 0)
       return true;
 
     currentImage = bufferCallback.GetImage();
     int64_t pos = mDecoder->GetResource()->Tell();
     nsIntRect picture = mPicture;
-
+ 
     nsAutoPtr<VideoData> v;
     if (currentImage) {
-      gfx::IntSize frameSize = currentImage->GetSize();
+      gfxIntSize frameSize = currentImage->GetSize();
       if (frameSize.width != mInitialFrame.width ||
           frameSize.height != mInitialFrame.height) {
         // Frame size is different from what the container reports. This is legal,
         // and we will preserve the ratio of the crop rectangle as it
         // was reported relative to the picture size reported by the container.
         picture.x = (mPicture.x * frameSize.width) / mInitialFrame.width;
         picture.y = (mPicture.y * frameSize.height) / mInitialFrame.height;
         picture.width = (frameSize.width * mPicture.width) / mInitialFrame.width;
--- a/content/media/webrtc/MediaEngineDefault.cpp
+++ b/content/media/webrtc/MediaEngineDefault.cpp
@@ -87,25 +87,25 @@ static void AllocateSolidColorFrame(laye
   int cbLen = yLen>>2;
   int crLen = cbLen;
   uint8_t* frame = (uint8_t*) PR_Malloc(yLen+cbLen+crLen);
   memset(frame, aY, yLen);
   memset(frame+yLen, aCb, cbLen);
   memset(frame+yLen+cbLen, aCr, crLen);
 
   aData.mYChannel = frame;
-  aData.mYSize = LayerIntSize(aWidth, aHeight);
+  aData.mYSize = gfxIntSize(aWidth, aHeight);
   aData.mYStride = aWidth;
   aData.mCbCrStride = aWidth>>1;
   aData.mCbChannel = frame + yLen;
   aData.mCrChannel = aData.mCbChannel + cbLen;
-  aData.mCbCrSize = LayerIntSize(aWidth>>1, aHeight>>1);
+  aData.mCbCrSize = gfxIntSize(aWidth>>1, aHeight>>1);
   aData.mPicX = 0;
   aData.mPicY = 0;
-  aData.mPicSize = LayerIntSize(aWidth, aHeight);
+  aData.mPicSize = gfxIntSize(aWidth, aHeight);
   aData.mStereoMode = STEREO_MODE_MONO;
 }
 
 static void ReleaseFrame(layers::PlanarYCbCrData& aData)
 {
   PR_Free(aData.mYChannel);
 }
 
--- a/content/media/webrtc/MediaEngineTabVideoSource.cpp
+++ b/content/media/webrtc/MediaEngineTabVideoSource.cpp
@@ -10,18 +10,16 @@
 #include "Layers.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDOMDocument.h"
 #include "nsITabSource.h"
 #include "MediaEngineTabVideoSource.h"
 #include "VideoUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIPrefService.h"
-#include "gfx2DGlue.h"
-
 namespace mozilla {
 
 NS_IMPL_ISUPPORTS1(MediaEngineTabVideoSource, MediaEngineVideoSource)
 
 MediaEngineTabVideoSource::MediaEngineTabVideoSource()
   : mName(NS_LITERAL_STRING("share tab")), mUuid(NS_LITERAL_STRING("uuid")),
   mMonitor("MediaEngineTabVideoSource")
 {
@@ -151,17 +149,17 @@ NotifyPull(MediaStreamGraph*, SourceMedi
 
   // Note: we're not giving up mImage here
   nsRefPtr<layers::CairoImage> image = mImage;
   TrackTicks target = TimeToTicksRoundUp(USECS_PER_S, aDesiredTime);
   TrackTicks delta = target - aLastEndTime;
   if (delta > 0) {
     // nullptr images are allowed
     if (image) {
-      gfxIntSize size = ThebesIntSize(image->GetSize());
+      gfxIntSize size = image->GetSize();
       segment.AppendFrame(image.forget(), delta, size);
     } else {
       segment.AppendFrame(nullptr, delta, gfxIntSize(0,0));
     }
     // This can fail if either a) we haven't added the track yet, or b)
     // we've removed or finished the track.
     if (aSource->AppendToTrack(aID, &(segment))) {
       aLastEndTime = target;
--- a/content/media/webrtc/MediaEngineWebRTCVideo.cpp
+++ b/content/media/webrtc/MediaEngineWebRTCVideo.cpp
@@ -71,25 +71,25 @@ MediaEngineWebRTCVideoSource::DeliverFra
   layers::PlanarYCbCrImage* videoImage = static_cast<layers::PlanarYCbCrImage*>(image.get());
 
   uint8_t* frame = static_cast<uint8_t*> (buffer);
   const uint8_t lumaBpp = 8;
   const uint8_t chromaBpp = 4;
 
   layers::PlanarYCbCrData data;
   data.mYChannel = frame;
-  data.mYSize = LayerIntSize(mWidth, mHeight);
+  data.mYSize = gfxIntSize(mWidth, mHeight);
   data.mYStride = mWidth * lumaBpp/ 8;
   data.mCbCrStride = mWidth * chromaBpp / 8;
   data.mCbChannel = frame + mHeight * data.mYStride;
   data.mCrChannel = data.mCbChannel + mHeight * data.mCbCrStride / 2;
-  data.mCbCrSize = LayerIntSize(mWidth/ 2, mHeight/ 2);
+  data.mCbCrSize = gfxIntSize(mWidth/ 2, mHeight/ 2);
   data.mPicX = 0;
   data.mPicY = 0;
-  data.mPicSize = LayerIntSize(mWidth, mHeight);
+  data.mPicSize = gfxIntSize(mWidth, mHeight);
   data.mStereoMode = STEREO_MODE_MONO;
 
   videoImage->SetData(data);
 
 #ifdef DEBUG
   static uint32_t frame_num = 0;
   LOGFRAME(("frame %d (%dx%d); timestamp %u, render_time %lu", frame_num++,
             mWidth, mHeight, time_stamp, render_time));
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1208,17 +1208,17 @@ ContentChild::RecvAddPermission(const IP
                                  nsPermissionManager::eNotify,
                                  nsPermissionManager::eNoDBOperation);
 #endif
 
   return true;
 }
 
 bool
-ContentChild::RecvScreenSizeChanged(const gfx::IntSize& size)
+ContentChild::RecvScreenSizeChanged(const gfxIntSize& size)
 {
 #ifdef ANDROID
     mScreenSize = size;
 #else
     NS_RUNTIMEABORT("Message currently only expected on android");
 #endif
   return true;
 }
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -186,17 +186,17 @@ public:
     virtual bool RecvAsyncMessage(const nsString& aMsg,
                                   const ClonedMessageData& aData,
                                   const InfallibleTArray<CpowEntry>& aCpows);
 
     virtual bool RecvGeolocationUpdate(const GeoPosition& somewhere);
 
     virtual bool RecvAddPermission(const IPC::Permission& permission);
 
-    virtual bool RecvScreenSizeChanged(const gfx::IntSize &size);
+    virtual bool RecvScreenSizeChanged(const gfxIntSize &size);
 
     virtual bool RecvFlushMemory(const nsString& reason);
 
     virtual bool RecvActivateA11y();
 
     virtual bool RecvGarbageCollect();
     virtual bool RecvCycleCollect();
 
@@ -222,17 +222,17 @@ public:
     virtual bool RecvMinimizeMemoryUsage();
     virtual bool RecvCancelMinimizeMemoryUsage();
 
     virtual bool RecvLoadAndRegisterSheet(const URIParams& aURI, const uint32_t& aType);
     virtual bool RecvUnregisterSheet(const URIParams& aURI, const uint32_t& aType);
 
     virtual bool RecvNotifyPhoneStateChange(const nsString& state);
 #ifdef ANDROID
-    gfx::IntSize GetScreenSize() { return mScreenSize; }
+    gfxIntSize GetScreenSize() { return mScreenSize; }
 #endif
 
     // Get the directory for IndexedDB files. We query the parent for this and
     // cache the value
     nsString &GetIndexedDBPath();
 
     uint64_t GetID() { return mID; }
 
@@ -267,17 +267,17 @@ private:
      * We expect our content parent to set this ID immediately after opening a
      * channel to us.
      */
     uint64_t mID;
 
     AppInfo mAppInfo;
 
 #ifdef ANDROID
-    gfx::IntSize mScreenSize;
+    gfxIntSize mScreenSize;
 #endif
 
     bool mIsForApp;
     bool mIsForBrowser;
     nsString mProcessName;
     nsWeakPtr mMemoryMinimizerRunnable;
 
     static ContentChild* sSingleton;
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -24,16 +24,17 @@ include "ipc/nsGUIEventIPC.h";
 include "mozilla/dom/TabMessageUtils.h";
 include "mozilla/dom/ScreenOrientation.h";
 include "mozilla/dom/PermissionMessageUtils.h";
 include "mozilla/layout/RenderFrameUtils.h";
 include "mozilla/layers/CompositorTypes.h";
 
 using IPC::Principal;
 using gfxMatrix;
+using gfxSize;
 using CSSRect;
 using mozilla::layers::FrameMetrics;
 using FrameMetrics::ViewID;
 using mozilla::layout::ScrollingBehavior;
 using mozilla::void_t;
 using mozilla::WindowsHandle;
 using nscolor;
 using mozilla::WidgetCompositionEvent;
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -50,17 +50,17 @@ using IPC::Permission;
 using IPC::Principal;
 using mozilla::null_t;
 using mozilla::void_t;
 using mozilla::dom::AudioChannelType;
 using mozilla::dom::AudioChannelState;
 using mozilla::dom::BlobConstructorParams;
 using mozilla::dom::NativeThreadId;
 using mozilla::hal::ProcessPriority;
-using mozilla::gfx::IntSize;
+using gfxIntSize;
 
 namespace mozilla {
 namespace dom {
 
 struct FontListEntry {
     nsString  familyName;
     nsString  faceName;
     nsCString filepath;
@@ -282,23 +282,23 @@ child:
 
     NotifyAlertsObserver(nsCString topic, nsString data);
 
     GeolocationUpdate(GeoPosition somewhere);
 
     // nsIPermissionManager messages
     AddPermission(Permission permission);
 
-    ScreenSizeChanged(IntSize size);
+    ScreenSizeChanged(gfxIntSize size);
 
     FlushMemory(nsString reason);
 
     GarbageCollect();
     CycleCollect();
-
+    
     /**
      * Start accessibility engine in content process.
      */
     ActivateA11y();
 
     AppInfo(nsCString version, nsCString buildID, nsCString name, nsCString UAName);
 
     // Notify child that last-pb-context-exited notification was observed
--- a/gfx/gl/GLTextureImage.cpp
+++ b/gfx/gl/GLTextureImage.cpp
@@ -272,23 +272,22 @@ BasicTextureImage::BasicTextureImage(GLu
   , mTexture(aTexture)
   , mTextureState(Created)
   , mGLContext(aContext)
   , mUpdateOffset(0, 0)
 {}
 
 already_AddRefed<TextureImage>
 CreateBasicTextureImage(GLContext* aGL,
-                        const LayerIntSize& aSize,
+                        const gfx::IntSize& aSize,
                         TextureImage::ContentType aContentType,
                         GLenum aWrapMode,
                         TextureImage::Flags aFlags)
 {
-  return CreateBasicTextureImage(aGL, ThebesIntSize(aSize.ToUnknownSize()),
-                                 aContentType, aWrapMode, aFlags);
+  return CreateBasicTextureImage(aGL, ThebesIntSize(aSize), aContentType, aWrapMode, aFlags);
 }
 
 TiledTextureImage::TiledTextureImage(GLContext* aGL,
                                      nsIntSize aSize,
                                      TextureImage::ContentType aContentType,
                                      TextureImage::Flags aFlags,
                                      TextureImage::ImageFormat aImageFormat)
     : TextureImage(aSize, LOCAL_GL_CLAMP_TO_EDGE, aContentType, aFlags)
--- a/gfx/gl/GLTextureImage.h
+++ b/gfx/gl/GLTextureImage.h
@@ -8,17 +8,16 @@
 
 #include "nsAutoPtr.h"
 #include "nsRegion.h"
 #include "nsTArray.h"
 #include "gfxTypes.h"
 #include "GLContextTypes.h"
 #include "GraphicsFilter.h"
 #include "mozilla/gfx/Rect.h"
-#include "Units.h"
 
 class gfxASurface;
 
 namespace mozilla {
 namespace gfx {
 class DataSourceSurface;
 }
 }
@@ -423,17 +422,17 @@ CreateBasicTextureImage(GLContext* aGL,
                         const nsIntSize& aSize,
                         TextureImage::ContentType aContentType,
                         GLenum aWrapMode,
                         TextureImage::Flags aFlags,
                         TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
 
 already_AddRefed<TextureImage>
 CreateBasicTextureImage(GLContext* aGL,
-                        const LayerIntSize& aSize,
+                        const gfx::IntSize& aSize,
                         TextureImage::ContentType aContentType,
                         GLenum aWrapMode,
                         TextureImage::Flags aFlags);
 
 } // namespace gl
 } // namespace mozilla
 
 #endif /* GLTEXTUREIMAGE_H_ */
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -115,16 +115,37 @@ struct ParamTraits<gfxPoint3D>
   {
     return (ReadParam(aMsg, aIter, &aResult->x) &&
             ReadParam(aMsg, aIter, &aResult->y) &&
             ReadParam(aMsg, aIter, &aResult->z));
   }
 };
 
 template<>
+struct ParamTraits<gfxSize>
+{
+  typedef gfxSize paramType;
+
+  static void Write(Message* aMsg, const paramType& aParam)
+  {
+    WriteParam(aMsg, aParam.width);
+    WriteParam(aMsg, aParam.height);
+  }
+
+  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
+  {
+    if (ReadParam(aMsg, aIter, &aResult->width) &&
+        ReadParam(aMsg, aIter, &aResult->height))
+      return true;
+
+    return false;
+  }
+};
+
+template<>
 struct ParamTraits<gfxRect>
 {
   typedef gfxRect paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, aParam.x);
     WriteParam(aMsg, aParam.y);
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -205,17 +205,17 @@ public:
    * across process or thread boundaries that are compatible with this
    * compositor.
    */
   virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() = 0;
 
   /**
    * Properties of the compositor.
    */
-  virtual bool CanUseCanvasLayerForSize(const LayerIntSize& aSize) = 0;
+  virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) = 0;
   virtual int32_t GetMaxTextureSize() const = 0;
 
   /**
    * Set the target for rendering. Results will have been written to aTarget by
    * the time that EndFrame returns.
    *
    * If this method is not used, or we pass in nullptr, we target the compositor's
    * usual swap chain and render to the screen.
--- a/gfx/layers/D3D9SurfaceImage.cpp
+++ b/gfx/layers/D3D9SurfaceImage.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "D3D9SurfaceImage.h"
 #include "gfxImageSurface.h"
-#include "gfx2DGlue.h"
 
 namespace mozilla {
 namespace layers {
 
 HRESULT
 D3D9SurfaceImage::SetData(const Data& aData)
 {
   NS_ENSURE_TRUE(aData.mSurface, E_POINTER);
@@ -105,30 +104,30 @@ D3D9SurfaceImage::GetShareHandle()
 }
 
 const D3DSURFACE_DESC&
 D3D9SurfaceImage::GetDesc() const
 {
   return mDesc;
 }
 
-gfx::IntSize
+gfxIntSize
 D3D9SurfaceImage::GetSize()
 {
   return mSize;
 }
 
 already_AddRefed<gfxASurface>
 D3D9SurfaceImage::GetAsSurface()
 {
   NS_ENSURE_TRUE(mTexture, nullptr);
 
   HRESULT hr;
   nsRefPtr<gfxImageSurface> surface =
-    new gfxImageSurface(ThebesIntSize(mSize), gfxImageFormatRGB24);
+    new gfxImageSurface(mSize, gfxImageFormatRGB24);
 
   if (!surface->CairoSurface() || surface->CairoStatus()) {
     NS_WARNING("Failed to created Cairo image surface for D3D9SurfaceImage.");
     return nullptr;
   }
 
   // Ensure that the texture is ready to be used.
   EnsureSynchronized();
--- a/gfx/layers/D3D9SurfaceImage.h
+++ b/gfx/layers/D3D9SurfaceImage.h
@@ -5,17 +5,16 @@
 
 #ifndef GFX_D3DSURFACEIMAGE_H
 #define GFX_D3DSURFACEIMAGE_H
 
 #include "mozilla/RefPtr.h"
 #include "ImageContainer.h"
 #include "nsAutoPtr.h"
 #include "d3d9.h"
-#include "mozilla/gfx/Point.h"
 
 namespace mozilla {
 namespace layers {
 
 // Image class that wraps a IDirect3DSurface9. This class copies the image
 // passed into SetData(), so that it can be accessed from other D3D devices.
 // This class also manages the synchronization of the copy, to ensure the
 // resource is ready to use.
@@ -40,27 +39,27 @@ public:
   const D3DSURFACE_DESC& GetDesc() const;
 
   // Returns the HANDLE that can be used to open the image as a shared resource.
   // If the operation to copy the original resource to the shared resource
   // hasn't finished yet, this function blocks until the synchronization is
   // complete.
   HANDLE GetShareHandle();
 
-  gfx::IntSize GetSize() MOZ_OVERRIDE;
+  gfxIntSize GetSize() MOZ_OVERRIDE;
 
   already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
 
 private:
 
   // Blocks the calling thread until the copy operation started in SetData()
   // is complete, whereupon the texture is safe to use.
   void EnsureSynchronized();
 
-  gfx::IntSize mSize;
+  gfxIntSize mSize;
   RefPtr<IDirect3DTexture9> mTexture;
   RefPtr<IDirect3DQuery9> mQuery;
   HANDLE mShareHandle;
   D3DSURFACE_DESC mDesc;
 };
 
 } // namepace layers
 } // namespace mozilla
--- a/gfx/layers/GrallocImages.cpp
+++ b/gfx/layers/GrallocImages.cpp
@@ -71,23 +71,23 @@ GrallocImage::~GrallocImage()
 void
 GrallocImage::SetData(const Data& aData)
 {
   NS_PRECONDITION(aData.mYSize.width % 2 == 0, "Image should have even width");
   NS_PRECONDITION(aData.mYSize.height % 2 == 0, "Image should have even height");
   NS_PRECONDITION(aData.mYStride % 16 == 0, "Image should have stride of multiple of 16 pixels");
 
   mData = aData;
-  mSize = aData.mPicSize.ToUnknownSize();
+  mSize = aData.mPicSize;
 
   if (!mGraphicBuffer.get()) {
 
     SurfaceDescriptor desc;
     ImageBridgeChild *ibc = ImageBridgeChild::GetSingleton();
-    ibc->AllocSurfaceDescriptorGralloc(ThebesIntSize(aData.mYSize.ToUnknownSize()),
+    ibc->AllocSurfaceDescriptorGralloc(aData.mYSize,
                                        HAL_PIXEL_FORMAT_YV12,
                                        GraphicBuffer::USAGE_SW_READ_OFTEN |
                                        GraphicBuffer::USAGE_SW_WRITE_OFTEN |
                                        GraphicBuffer::USAGE_HW_TEXTURE,
                                        &desc);
     mBufferAllocated = true;
     mGraphicBuffer = new GraphicBufferLocked(desc);
   }
@@ -224,22 +224,22 @@ GrallocImage::GetAsSurface()
     }
   }
 
   if (!omxFormat) {
     NS_WARNING("Unknown color format");
     return nullptr;
   }
 
+  nsRefPtr<gfxImageSurface> imageSurface =
+    new gfxImageSurface(GetSize(), gfxImageFormatRGB16_565);
+
   uint32_t width = GetSize().width;
   uint32_t height = GetSize().height;
 
-  nsRefPtr<gfxImageSurface> imageSurface =
-    new gfxImageSurface(gfxIntSize(width, height), gfxImageFormatRGB16_565);
-
   if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO) {
     // The Adreno hardware decoder aligns image dimensions to a multiple of 32,
     // so we have to account for that here
     uint32_t alignedWidth = ALIGN(width, 32);
     uint32_t alignedHeight = ALIGN(height, 32);
     uint32_t uvOffset = ALIGN(alignedHeight * alignedWidth, 4096);
     uint32_t uvStride = 2 * ALIGN(width / 2, 32);
     uint8_t* buffer_as_bytes = static_cast<uint8_t*>(buffer);
@@ -290,16 +290,18 @@ GrallocImage::GetTextureClient()
       return nullptr;
     }
     const SurfaceDescriptorGralloc& desc = sd.get_SurfaceDescriptorGralloc();
     TextureFlags flags = desc.external() ? TEXTURE_DEALLOCATE_CLIENT : 0;
     if (desc.isRBSwapped()) {
       flags |= TEXTURE_RB_SWAPPED;
     }
     GrallocBufferActor* actor = static_cast<GrallocBufferActor*>(desc.bufferChild());
-    mTextureClient = new GrallocTextureClientOGL(actor, mSize, flags);
+    mTextureClient = new GrallocTextureClientOGL(actor,
+                                                 gfx::ToIntSize(mSize),
+                                                 flags);
     mTextureClient->SetGraphicBufferLocked(mGraphicBuffer);
   }
   return mTextureClient;
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -11,17 +11,16 @@
 #include "gfxPlatform.h"                // for gfxPlatform
 #include "gfxUtils.h"                   // for gfxUtils
 #include "mozilla/RefPtr.h"             // for TemporaryRef
 #include "mozilla/ipc/CrossProcessMutex.h"  // for CrossProcessMutex, etc
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/ImageBridgeChild.h"  // for ImageBridgeChild
 #include "mozilla/layers/ImageClient.h"  // for ImageClient
 #include "nsISupportsUtils.h"           // for NS_IF_ADDREF
-#include "gfx2DGlue.h"
 #ifdef MOZ_WIDGET_GONK
 #include "GrallocImages.h"
 #endif
 
 #ifdef XP_MACOSX
 #include "mozilla/gfx/QuartzSupport.h"
 #endif
 
@@ -45,17 +44,17 @@ namespace layers {
 class DataSourceSurface;
 class SourceSurface;
 
 Atomic<int32_t> Image::sSerialCounter(0);
 
 already_AddRefed<Image>
 ImageFactory::CreateImage(const ImageFormat *aFormats,
                           uint32_t aNumFormats,
-                          const gfx::IntSize &,
+                          const gfxIntSize &,
                           BufferRecycleBin *aRecycleBin)
 {
   if (!aNumFormats) {
     return nullptr;
   }
   nsRefPtr<Image> img;
 #ifdef MOZ_WIDGET_GONK
   if (FormatInList(aFormats, aNumFormats, GRALLOC_PLANAR_YCBCR)) {
@@ -271,17 +270,17 @@ ImageContainer::LockCurrentImage()
 
   EnsureActiveImage();
 
   nsRefPtr<Image> retval = mActiveImage;
   return retval.forget();
 }
 
 already_AddRefed<gfxASurface>
-ImageContainer::LockCurrentAsSurface(gfx::IntSize *aSize, Image** aCurrentImage)
+ImageContainer::LockCurrentAsSurface(gfxIntSize *aSize, Image** aCurrentImage)
 {
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   if (mRemoteData) {
     NS_ASSERTION(mRemoteDataMutex, "Should have remote data mutex when having remote data!");
     mRemoteDataMutex->Lock();
 
     EnsureActiveImage();
@@ -329,17 +328,17 @@ ImageContainer::UnlockCurrentImage()
 {
   if (mRemoteData) {
     NS_ASSERTION(mRemoteDataMutex, "Should have remote data mutex when having remote data!");
     mRemoteDataMutex->Unlock();
   }
 }
 
 already_AddRefed<gfxASurface>
-ImageContainer::GetCurrentAsSurface(gfx::IntSize *aSize)
+ImageContainer::GetCurrentAsSurface(gfxIntSize *aSize)
 {
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   if (mRemoteData) {
     CrossProcessMutexAutoLock autoLock(*mRemoteDataMutex);
     EnsureActiveImage();
 
     if (!mActiveImage)
@@ -348,31 +347,31 @@ ImageContainer::GetCurrentAsSurface(gfx:
   } else {
     if (!mActiveImage)
       return nullptr;
     *aSize = mActiveImage->GetSize();
   }
   return mActiveImage->GetAsSurface();
 }
 
-gfx::IntSize
+gfxIntSize
 ImageContainer::GetCurrentSize()
 {
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   if (mRemoteData) {
     CrossProcessMutexAutoLock autoLock(*mRemoteDataMutex);
 
     // We don't need to ensure we have an active image here, as we need to
     // be in the mutex anyway, and this is easiest to return from there.
     return mRemoteData->mSize;
   }
 
   if (!mActiveImage) {
-    return gfx::IntSize(0,0);
+    return gfxIntSize(0,0);
   }
 
   return mActiveImage->GetSize();
 }
 
 void
 ImageContainer::SetRemoteImageData(RemoteImageData *aData, CrossProcessMutex *aMutex)
 {
@@ -446,17 +445,17 @@ PlanarYCbCrImage::~PlanarYCbCrImage()
 uint8_t* 
 PlanarYCbCrImage::AllocateBuffer(uint32_t aSize)
 {
   return mRecycleBin->GetBuffer(aSize); 
 }
 
 static void
 CopyPlane(uint8_t *aDst, const uint8_t *aSrc,
-          const LayerIntSize &aSize, int32_t aStride, int32_t aSkip)
+          const gfxIntSize &aSize, int32_t aStride, int32_t aSkip)
 {
   if (!aSkip) {
     // Fast path: planar input.
     memcpy(aDst, aSrc, aSize.height * aStride);
   } else {
     int32_t height = aSize.height;
     int32_t width = aSize.width;
     for (int y = 0; y < height; ++y) {
@@ -493,17 +492,17 @@ PlanarYCbCrImage::CopyData(const Data& a
 
   CopyPlane(mData.mYChannel, aData.mYChannel,
             mData.mYSize, mData.mYStride, mData.mYSkip);
   CopyPlane(mData.mCbChannel, aData.mCbChannel,
             mData.mCbCrSize, mData.mCbCrStride, mData.mCbSkip);
   CopyPlane(mData.mCrChannel, aData.mCrChannel,
             mData.mCbCrSize, mData.mCbCrStride, mData.mCrSkip);
 
-  mSize = aData.mPicSize.ToUnknownSize();
+  mSize = aData.mPicSize;
 }
 
 void
 PlanarYCbCrImage::SetData(const Data &aData)
 {
   CopyData(aData);
 }
 
@@ -514,17 +513,17 @@ PlanarYCbCrImage::GetOffscreenFormat()
     gfxPlatform::GetPlatform()->GetOffscreenFormat() :
     mOffscreenFormat;
 }
 
 void
 PlanarYCbCrImage::SetDataNoCopy(const Data &aData)
 {
   mData = aData;
-  mSize = aData.mPicSize.ToUnknownSize();
+  mSize = aData.mPicSize;
 }
 
 uint8_t*
 PlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
 {
   // update buffer size
   mBufferSize = aSize;
 
@@ -537,42 +536,41 @@ already_AddRefed<gfxASurface>
 PlanarYCbCrImage::GetAsSurface()
 {
   if (mSurface) {
     nsRefPtr<gfxASurface> result = mSurface.get();
     return result.forget();
   }
 
   gfxImageFormat format = GetOffscreenFormat();
-  LayerIntSize size(mSize.width, mSize.height);
+  gfxIntSize size(mSize);
   gfxUtils::GetYCbCrToRGBDestFormatAndSize(mData, format, size);
   if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
       size.height > PlanarYCbCrImage::MAX_DIMENSION) {
     NS_ERROR("Illegal image dest width or height");
     return nullptr;
   }
 
   nsRefPtr<gfxImageSurface> imageSurface =
-    new gfxImageSurface(ThebesIntSize(mSize), format);
+    new gfxImageSurface(mSize, format);
 
-  size = LayerIntSize(mSize.width, mSize.height);
-  gfxUtils::ConvertYCbCrToRGB(mData, format, size,
+  gfxUtils::ConvertYCbCrToRGB(mData, format, mSize,
                               imageSurface->Data(),
                               imageSurface->Stride());
 
   mSurface = imageSurface;
 
   return imageSurface.forget();
 }
 
 already_AddRefed<gfxASurface>
 RemoteBitmapImage::GetAsSurface()
 {
   nsRefPtr<gfxImageSurface> newSurf =
-    new gfxImageSurface(ThebesIntSize(mSize),
+    new gfxImageSurface(mSize,
     mFormat == RemoteImageData::BGRX32 ? gfxImageFormatRGB24 : gfxImageFormatARGB32);
 
   for (int y = 0; y < mSize.height; y++) {
     memcpy(newSurf->Data() + newSurf->Stride() * y,
            mData + mStride * y,
            mSize.width * 4);
   }
 
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -22,17 +22,16 @@
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupportsImpl.h"            // for Image::Release, etc
 #include "nsRect.h"                     // for nsIntRect
 #include "nsSize.h"                     // for nsIntSize
 #include "nsTArray.h"                   // for nsTArray
 #include "mozilla/Atomics.h"
 #include "nsThreadUtils.h"
-#include "Units.h"
 
 #ifndef XPCOM_GLUE_AVOID_NSPR
 /**
  * We need to be able to hold a reference to a gfxASurface from Image
  * subclasses. This is potentially a problem since Images can be addrefed
  * or released off the main thread. We can ensure that we never AddRef
  * a gfxASurface off the main thread, but we might want to Release due
  * to an Image being destroyed off the main thread.
@@ -143,17 +142,17 @@ public:
   virtual ~Image() {}
 
   virtual ISharedImage* AsSharedImage() { return nullptr; }
 
   ImageFormat GetFormat() { return mFormat; }
   void* GetImplData() { return mImplData; }
 
   virtual already_AddRefed<gfxASurface> GetAsSurface() = 0;
-  virtual gfx::IntSize GetSize() = 0;
+  virtual gfxIntSize GetSize() = 0;
   virtual nsIntRect GetPictureRect()
   {
     return nsIntRect(0, 0, GetSize().width, GetSize().height);
   }
 
   ImageBackendData* GetBackendData(LayersBackend aBackend)
   { return mBackendData[aBackend]; }
   void SetBackendData(LayersBackend aBackend, ImageBackendData* aData)
@@ -258,17 +257,17 @@ class ImageFactory
 protected:
   friend class ImageContainer;
 
   ImageFactory() {}
   virtual ~ImageFactory() {}
 
   virtual already_AddRefed<Image> CreateImage(const ImageFormat* aFormats,
                                               uint32_t aNumFormats,
-                                              const gfx::IntSize &aScaleHint,
+                                              const gfxIntSize &aScaleHint,
                                               BufferRecycleBin *aRecycleBin);
 
 };
  
 /**
  * This struct is used to store RemoteImages, it is meant to be able to live in
  * shared memory. Therefor it should not contain a vtable pointer. Remote
  * users can manipulate the data in this structure to specify what image is to
@@ -479,35 +478,35 @@ public:
    * Can be called on any thread. This method takes mReentrantMonitor
    * when accessing thread-shared state.
    * If the current image is a remote image, that is, if it is an image that
    * may be shared accross processes, calling this function will make
    * a copy of the image data while holding the mRemoteDataMutex. If possible,
    * the lock methods should be used to avoid the copy, however this should be
    * avoided if the surface is required for a long period of time.
    */
-  already_AddRefed<gfxASurface> GetCurrentAsSurface(gfx::IntSize* aSizeResult);
+  already_AddRefed<gfxASurface> GetCurrentAsSurface(gfxIntSize* aSizeResult);
 
   /**
    * This is similar to GetCurrentAsSurface, however this does not make a copy
    * of the image data and requires the user to call UnlockCurrentImage when
    * done with the image data. Once UnlockCurrentImage has been called the
    * surface returned by this function is no longer valid! This works for any
    * type of image. Optionally a pointer can be passed to receive the current
    * image.
    */
-  already_AddRefed<gfxASurface> LockCurrentAsSurface(gfx::IntSize* aSizeResult,
+  already_AddRefed<gfxASurface> LockCurrentAsSurface(gfxIntSize* aSizeResult,
                                                      Image** aCurrentImage = nullptr);
 
   /**
    * Returns the size of the image in pixels.
    * Can be called on any thread. This method takes mReentrantMonitor when accessing
    * thread-shared state.
    */
-  gfx::IntSize GetCurrentSize();
+  gfxIntSize GetCurrentSize();
 
   /**
    * Sets a size that the image is expected to be rendered at.
    * This is a hint for image backends to optimize scaling.
    * Default implementation in this class is to ignore the hint.
    * Can be called on any thread. This method takes mReentrantMonitor
    * when accessing thread-shared state.
    */
@@ -669,17 +668,17 @@ class AutoLockImage
 public:
   AutoLockImage(ImageContainer *aContainer) : mContainer(aContainer) { mImage = mContainer->LockCurrentImage(); }
   AutoLockImage(ImageContainer *aContainer, gfxASurface **aSurface) : mContainer(aContainer) {
     *aSurface = mContainer->LockCurrentAsSurface(&mSize, getter_AddRefs(mImage)).get();
   }
   ~AutoLockImage() { if (mContainer) { mContainer->UnlockCurrentImage(); } }
 
   Image* GetImage() { return mImage; }
-  const gfx::IntSize &GetSize() { return mSize; }
+  const gfxIntSize &GetSize() { return mSize; }
 
   void Unlock() { 
     if (mContainer) {
       mImage = nullptr;
       mContainer->UnlockCurrentImage();
       mContainer = nullptr;
     }
   }
@@ -694,36 +693,36 @@ public:
       mContainer->UnlockCurrentImage();
       mImage = mContainer->LockCurrentImage();
     }
   }
 
 private:
   ImageContainer *mContainer;
   nsRefPtr<Image> mImage;
-  gfx::IntSize mSize;
+  gfxIntSize mSize;
 };
 
 struct PlanarYCbCrData {
   // Luminance buffer
   uint8_t* mYChannel;
   int32_t mYStride;
-  LayerIntSize mYSize;
+  gfxIntSize mYSize;
   int32_t mYSkip;
   // Chroma buffers
   uint8_t* mCbChannel;
   uint8_t* mCrChannel;
   int32_t mCbCrStride;
-  LayerIntSize mCbCrSize;
+  gfxIntSize mCbCrSize;
   int32_t mCbSkip;
   int32_t mCrSkip;
   // Picture region
   uint32_t mPicX;
   uint32_t mPicY;
-  LayerIntSize mPicSize;
+  gfxIntSize mPicSize;
   StereoMode mStereoMode;
 
   nsIntRect GetPictureRect() const {
     return nsIntRect(mPicX, mPicY,
                      mPicSize.width,
                      mPicSize.height);
   }
 
@@ -815,17 +814,17 @@ public:
 
   /**
    * Return the number of bytes of heap memory used to store this image.
    */
   virtual uint32_t GetDataSize() { return mBufferSize; }
 
   virtual bool IsValid() { return !!mBufferSize; }
 
-  virtual gfx::IntSize GetSize() { return mSize; }
+  virtual gfxIntSize GetSize() { return mSize; }
 
   PlanarYCbCrImage(BufferRecycleBin *aRecycleBin);
 
   virtual SharedPlanarYCbCrImage *AsSharedPlanarYCbCrImage() { return nullptr; }
   virtual DeprecatedSharedPlanarYCbCrImage *AsDeprecatedSharedPlanarYCbCrImage() { return nullptr; }
 
 protected:
   /**
@@ -845,17 +844,17 @@ protected:
   already_AddRefed<gfxASurface> GetAsSurface();
 
   void SetOffscreenFormat(gfxImageFormat aFormat) { mOffscreenFormat = aFormat; }
   gfxImageFormat GetOffscreenFormat();
 
   nsAutoArrayPtr<uint8_t> mBuffer;
   uint32_t mBufferSize;
   Data mData;
-  gfx::IntSize mSize;
+  gfxIntSize mSize;
   gfxImageFormat mOffscreenFormat;
   nsCountedRef<nsMainThreadSurfaceRef> mSurface;
   nsRefPtr<BufferRecycleBin> mRecycleBin;
 };
 
 /**
  * Currently, the data in a CairoImage surface is treated as being in the
  * device output color space. This class is very simple as all backends
@@ -881,34 +880,34 @@ public:
 
 
   virtual already_AddRefed<gfxASurface> GetAsSurface()
   {
     nsRefPtr<gfxASurface> surface = mSurface.get();
     return surface.forget();
   }
 
-  gfx::IntSize GetSize() { return mSize; }
+  gfxIntSize GetSize() { return mSize; }
 
   CairoImage() : Image(nullptr, CAIRO_SURFACE) {}
 
   nsCountedRef<nsMainThreadSurfaceRef> mSurface;
-  gfx::IntSize mSize;
+  gfxIntSize mSize;
 };
 
 class RemoteBitmapImage : public Image {
 public:
   RemoteBitmapImage() : Image(nullptr, REMOTE_IMAGE_BITMAP) {}
 
   already_AddRefed<gfxASurface> GetAsSurface();
 
-  gfx::IntSize GetSize() { return mSize; }
+  gfxIntSize GetSize() { return mSize; }
 
   unsigned char *mData;
   int mStride;
-  gfx::IntSize mSize;
+  gfxIntSize mSize;
   RemoteImageData::Format mFormat;
 };
 
 } //namespace
 } //namespace
 
 #endif
--- a/gfx/layers/ImageLayers.cpp
+++ b/gfx/layers/ImageLayers.cpp
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ImageLayers.h"
 #include "ImageContainer.h"             // for ImageContainer
 #include "gfx3DMatrix.h"                // for gfx3DMatrix
 #include "gfxRect.h"                    // for gfxRect
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupportsImpl.h"            // for ImageContainer::Release, etc
-#include "gfx2DGlue.h"
 
 namespace mozilla {
 namespace layers {
 
 ImageLayer::ImageLayer(LayerManager* aManager, void* aImplData)
 : Layer(aManager, aImplData), mFilter(GraphicsFilter::FILTER_GOOD)
 , mScaleMode(SCALE_NONE), mDisallowBigImage(false)
 {}
@@ -29,17 +28,17 @@ void ImageLayer::SetContainer(ImageConta
 
 void ImageLayer::ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
 {
   gfx3DMatrix local = GetLocalTransform();
 
   // Snap image edges to pixel boundaries
   gfxRect sourceRect(0, 0, 0, 0);
   if (mContainer) {
-    sourceRect.SizeTo(ThebesIntSize(mContainer->GetCurrentSize()));
+    sourceRect.SizeTo(mContainer->GetCurrentSize());
     if (mScaleMode != SCALE_NONE &&
         sourceRect.width != 0.0 && sourceRect.height != 0.0) {
       NS_ASSERTION(mScaleMode == SCALE_STRETCH,
                    "No other scalemodes than stretch and none supported yet.");
       local.Scale(mScaleToSize.width / sourceRect.width,
                   mScaleToSize.height / sourceRect.height, 1.0);
     }
   }
--- a/gfx/layers/ImageLayers.h
+++ b/gfx/layers/ImageLayers.h
@@ -45,30 +45,29 @@ public:
       Mutated();
     }
   }
 
   /**
    * CONSTRUCTION PHASE ONLY
    * Set the size to scale the image to and the mode at which to scale.
    */
-  void SetScaleToSize(const gfx::IntSize &aSize, ScaleMode aMode)
+  void SetScaleToSize(const gfxIntSize &aSize, ScaleMode aMode)
   {
-    LayerIntSize size(aSize.width, aSize.height);
-    if (mScaleToSize != size || mScaleMode != aMode) {
-      mScaleToSize = size;
+    if (mScaleToSize != aSize || mScaleMode != aMode) {
+      mScaleToSize = aSize;
       mScaleMode = aMode;
       Mutated();
     }
   }
 
 
   ImageContainer* GetContainer() { return mContainer; }
   GraphicsFilter GetFilter() { return mFilter; }
-  const LayerIntSize& GetScaleToSize() { return mScaleToSize; }
+  const gfxIntSize& GetScaleToSize() { return mScaleToSize; }
   ScaleMode GetScaleMode() { return mScaleMode; }
 
   MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE)
 
   virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface);
 
   /**
    * if true, the image will only be backed by a single tile texture
@@ -85,17 +84,17 @@ public:
 protected:
   ImageLayer(LayerManager* aManager, void* aImplData);
   ~ImageLayer();
   virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
 
 
   nsRefPtr<ImageContainer> mContainer;
   GraphicsFilter mFilter;
-  LayerIntSize mScaleToSize;
+  gfxIntSize mScaleToSize;
   ScaleMode mScaleMode;
   bool mDisallowBigImage;
 };
 
 }
 }
 
 #endif /* GFX_IMAGELAYER_H */
--- a/gfx/layers/LayerTreeInvalidation.cpp
+++ b/gfx/layers/LayerTreeInvalidation.cpp
@@ -346,17 +346,17 @@ struct ImageLayerProperties : public Lay
     }
 
     return nsIntRect();
   }
 
   nsIntRegion mVisibleRegion;
   nsRefPtr<ImageContainer> mContainer;
   GraphicsFilter mFilter;
-  LayerIntSize mScaleToSize;
+  gfxIntSize mScaleToSize;
   ScaleMode mScaleMode;
 };
 
 LayerPropertiesBase*
 CloneLayerTreePropertiesInternal(Layer* aRoot)
 {
   if (!aRoot) {
     return new LayerPropertiesBase();
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -410,17 +410,17 @@ public:
   /**
    * Creates a DrawTarget for use with canvas which is optimized for
    * inter-operating with this layermanager.
    */
   virtual TemporaryRef<mozilla::gfx::DrawTarget>
     CreateDrawTarget(const mozilla::gfx::IntSize &aSize,
                      mozilla::gfx::SurfaceFormat aFormat);
 
-  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) { return true; }
+  virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) { return true; }
 
   /**
    * Returns a TextureFactoryIdentifier which describes properties of the backend
    * used to decide what kind of texture and buffer clients to create
    */
   virtual TextureFactoryIdentifier GetTextureFactoryIdentifier();
 
   /**
--- a/gfx/layers/SharedTextureImage.h
+++ b/gfx/layers/SharedTextureImage.h
@@ -22,24 +22,24 @@ namespace mozilla {
 
 namespace layers {
 
 class SharedTextureImage : public Image {
 public:
   struct Data {
     gl::SharedTextureHandle mHandle;
     gl::SharedTextureShareType mShareType;
-    gfx::IntSize mSize;
+    gfxIntSize mSize;
     bool mInverted;
   };
 
   void SetData(const Data& aData) { mData = aData; }
   const Data* GetData() { return &mData; }
 
-  gfx::IntSize GetSize() { return mData.mSize; }
+  gfxIntSize GetSize() { return mData.mSize; }
 
   virtual already_AddRefed<gfxASurface> GetAsSurface() { 
     return gl::GLContextProvider::GetSharedHandleAsSurface(mData.mShareType, mData.mHandle);
   }
 
   SharedTextureImage() : Image(nullptr, SHARED_TEXTURE) {}
 
 private:
--- a/gfx/layers/YCbCrImageDataSerializer.cpp
+++ b/gfx/layers/YCbCrImageDataSerializer.cpp
@@ -90,98 +90,115 @@ uint32_t YCbCrImageDataDeserializerBase:
 }
 
 uint32_t YCbCrImageDataDeserializerBase::GetCbCrStride()
 {
   YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
   return info->mCbCrWidth;
 }
 
-LayerIntSize YCbCrImageDataDeserializerBase::GetYSize()
+gfxIntSize YCbCrImageDataDeserializerBase::GetYSize()
 {
   YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
-  return LayerIntSize(info->mYWidth, info->mYHeight);
+  return gfxIntSize(info->mYWidth, info->mYHeight);
 }
 
-LayerIntSize YCbCrImageDataDeserializerBase::GetCbCrSize()
+gfxIntSize YCbCrImageDataDeserializerBase::GetCbCrSize()
 {
   YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
-  return LayerIntSize(info->mCbCrWidth, info->mCbCrHeight);
+  return gfxIntSize(info->mCbCrWidth, info->mCbCrHeight);
 }
 
 StereoMode YCbCrImageDataDeserializerBase::GetStereoMode()
 {
   YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
   return info->mStereoMode;
 }
 
 // Offset in bytes
 static size_t ComputeOffset(uint32_t aHeight, uint32_t aStride)
 {
   return MOZ_ALIGN_WORD(aHeight * aStride);
 }
 
 // Minimum required shmem size in bytes
 size_t
-YCbCrImageDataSerializer::ComputeMinBufferSize(const LayerIntSize& aYSize,
-                                               const LayerIntSize& aCbCrSize)
+YCbCrImageDataSerializer::ComputeMinBufferSize(const gfx::IntSize& aYSize,
+                                               const gfx::IntSize& aCbCrSize)
 {
   uint32_t yStride = aYSize.width;
   uint32_t CbCrStride = aCbCrSize.width;
 
   return ComputeOffset(aYSize.height, yStride)
          + 2 * ComputeOffset(aCbCrSize.height, CbCrStride)
          + MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
 }
 
+size_t
+YCbCrImageDataSerializer::ComputeMinBufferSize(const gfxIntSize& aYSize,
+                                               const gfxIntSize& aCbCrSize)
+{
+  return ComputeMinBufferSize(gfx::IntSize(aYSize.width, aYSize.height),
+                              gfx::IntSize(aCbCrSize.width, aCbCrSize.height));
+}
 // Offset in bytes
 static size_t ComputeOffset(uint32_t aSize)
 {
   return MOZ_ALIGN_WORD(aSize);
 }
 
 // Minimum required shmem size in bytes
 size_t
 YCbCrImageDataSerializer::ComputeMinBufferSize(uint32_t aSize)
 {
   return ComputeOffset(aSize) + MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
 }
 
 void
-YCbCrImageDataSerializer::InitializeBufferInfo(const LayerIntSize& aYSize,
-                                               const LayerIntSize& aCbCrSize,
+YCbCrImageDataSerializer::InitializeBufferInfo(const gfx::IntSize& aYSize,
+                                               const gfx::IntSize& aCbCrSize,
                                                StereoMode aStereoMode)
 {
   YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
   info->mYOffset = MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
   info->mCbOffset = info->mYOffset
                   + MOZ_ALIGN_WORD(aYSize.width * aYSize.height);
   info->mCrOffset = info->mCbOffset
                   + MOZ_ALIGN_WORD(aCbCrSize.width * aCbCrSize.height);
 
   info->mYWidth = aYSize.width;
   info->mYHeight = aYSize.height;
   info->mCbCrWidth = aCbCrSize.width;
   info->mCbCrHeight = aCbCrSize.height;
   info->mStereoMode = aStereoMode;
 }
 
+void
+YCbCrImageDataSerializer::InitializeBufferInfo(const gfxIntSize& aYSize,
+                                               const gfxIntSize& aCbCrSize,
+                                               StereoMode aStereoMode)
+{
+  InitializeBufferInfo(gfx::IntSize(aYSize.width, aYSize.height),
+                       gfx::IntSize(aCbCrSize.width, aCbCrSize.height),
+                       aStereoMode);
+}
+
 static void CopyLineWithSkip(const uint8_t* src, uint8_t* dst, uint32_t len, uint32_t skip) {
   for (uint32_t i = 0; i < len; ++i) {
     *dst = *src;
     src += 1 + skip;
     ++dst;
   }
 }
 
 bool
 YCbCrImageDataSerializer::CopyData(const uint8_t* aYData,
                                    const uint8_t* aCbData, const uint8_t* aCrData,
-                                   LayerIntSize aYSize, uint32_t aYStride,
-                                   LayerIntSize aCbCrSize, uint32_t aCbCrStride,
+                                   gfxIntSize aYSize, uint32_t aYStride,
+                                   gfxIntSize aCbCrSize, uint32_t aCbCrStride,
                                    uint32_t aYSkip, uint32_t aCbCrSkip)
 {
   if (!IsValid() || GetYSize() != aYSize || GetCbCrSize() != aCbCrSize) {
     return false;
   }
   for (int i = 0; i < aYSize.height; ++i) {
     if (aYSkip == 0) {
       // fast path
@@ -216,17 +233,17 @@ YCbCrImageDataSerializer::CopyData(const
   }
   return true;
 }
 
 TemporaryRef<gfx::DataSourceSurface>
 YCbCrImageDataDeserializer::ToDataSourceSurface()
 {
   RefPtr<gfx::DataSourceSurface> result =
-    gfx::Factory::CreateDataSourceSurface(GetYSize().ToUnknownSize(), gfx::FORMAT_R8G8B8X8);
+    gfx::Factory::CreateDataSourceSurface(ToIntSize(GetYSize()), gfx::FORMAT_R8G8B8X8);
 
   gfx::ConvertYCbCrToRGB32(GetYData(), GetCbData(), GetCrData(),
                            result->GetData(),
                            0, 0, //pic x and y
                            GetYSize().width, GetYSize().height,
                            GetYStride(), GetCbCrStride(),
                            result->Stride(),
                            gfx::YV12);
--- a/gfx/layers/YCbCrImageDataSerializer.h
+++ b/gfx/layers/YCbCrImageDataSerializer.h
@@ -8,17 +8,16 @@
 
 #include <stddef.h>                     // for size_t
 #include <stdint.h>                     // for uint8_t, uint32_t
 #include "ImageTypes.h"                 // for StereoMode
 #include "gfxPoint.h"                   // for gfxIntSize
 #include "mozilla/Attributes.h"         // for MOZ_STACK_CLASS
 #include "mozilla/RefPtr.h"             // for TemporaryRef
 #include "mozilla/gfx/Point.h"          // for IntSize
-#include "Units.h"
 
 namespace mozilla {
 namespace gfx {
 class DataSourceSurface;
 }
 
 namespace layers {
 
@@ -54,22 +53,22 @@ public:
   /**
    * Returns the stride of the Cb and Cr channels.
    */
   uint32_t GetCbCrStride();
 
   /**
    * Returns the dimensions of the Y Channel.
    */
-  LayerIntSize GetYSize();
+  gfxIntSize GetYSize();
 
   /**
    * Returns the dimensions of the Cb and Cr Channel.
    */
-  LayerIntSize GetCbCrSize();
+  gfxIntSize GetCbCrSize();
 
   /**
    * Stereo mode for the image.
    */
   StereoMode GetStereoMode();
 
   /**
    * Return a pointer to the begining of the data buffer.
@@ -99,33 +98,38 @@ class MOZ_STACK_CLASS YCbCrImageDataSeri
 public:
   YCbCrImageDataSerializer(uint8_t* aData) : YCbCrImageDataDeserializerBase(aData) {}
 
   /**
    * This function is meant as a helper to know how much shared memory we need
    * to allocate in a shmem in order to place a shared YCbCr image blob of
    * given dimensions.
    */
-  static size_t ComputeMinBufferSize(const LayerIntSize& aYSize,
-                                     const LayerIntSize& aCbCrSize);
+  static size_t ComputeMinBufferSize(const gfx::IntSize& aYSize,
+                                     const gfx::IntSize& aCbCrSize);
+  static size_t ComputeMinBufferSize(const gfxIntSize& aYSize,
+                                     const gfxIntSize& aCbCrSize);
   static size_t ComputeMinBufferSize(uint32_t aSize);
 
   /**
    * Write the image informations in the buffer for given dimensions.
    * The provided pointer should point to the beginning of the (chunk of)
    * buffer on which we want to store the image.
    */
-  void InitializeBufferInfo(const LayerIntSize& aYSize,
-                            const LayerIntSize& aCbCrSize,
+  void InitializeBufferInfo(const gfx::IntSize& aYSize,
+                            const gfx::IntSize& aCbCrSize,
+                            StereoMode aStereoMode);
+  void InitializeBufferInfo(const gfxIntSize& aYSize,
+                            const gfxIntSize& aCbCrSize,
                             StereoMode aStereoMode);
 
   bool CopyData(const uint8_t* aYData,
                 const uint8_t* aCbData, const uint8_t* aCrData,
-                LayerIntSize aYSize, uint32_t aYStride,
-                LayerIntSize aCbCrSize, uint32_t aCbCrStride,
+                gfxIntSize aYSize, uint32_t aYStride,
+                gfxIntSize aCbCrSize, uint32_t aCbCrStride,
                 uint32_t aYSkip, uint32_t aCbCrSkip);
 };
 
 /**
  * A view on a YCbCr image stored with its metadata in a blob of memory.
  * It is only meant as a convenience to access the image data, and does not own
  * the data. The instance can live on the stack and used as follows:
  *
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -181,26 +181,26 @@ public:
 
   void ConvertImageToRGB(const SurfaceDescriptor& aImage)
   {
     YCbCrImageDataDeserializer deserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
     PlanarYCbCrData data;
     DeserializerToPlanarYCbCrImageData(deserializer, data);
 
     gfxImageFormat format = gfxImageFormatRGB24;
-    LayerIntSize size;
+    gfxIntSize size;
     gfxUtils::GetYCbCrToRGBDestFormatAndSize(data, format, size);
     if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
         size.height > PlanarYCbCrImage::MAX_DIMENSION) {
       NS_ERROR("Illegal image dest width or height");
       return;
     }
 
     mThebesSurface = mThebesImage =
-      new gfxImageSurface(ThebesIntSize(size.ToUnknownSize()), format);
+      new gfxImageSurface(size, format);
 
     gfxUtils::ConvertYCbCrToRGB(data, format, size,
                                 mThebesImage->Data(),
                                 mThebesImage->Stride());
 
     mSize = IntSize(size.width, size.height);
     mFormat =
       (format == gfxImageFormatARGB32) ? FORMAT_B8G8R8A8 :
--- a/gfx/layers/basic/BasicCompositor.h
+++ b/gfx/layers/basic/BasicCompositor.h
@@ -89,17 +89,17 @@ public:
   virtual void EndFrame() MOZ_OVERRIDE;
   virtual void EndFrameForExternalComposition(const gfxMatrix& aTransform) MOZ_OVERRIDE
   {
     NS_RUNTIMEABORT("We shouldn't ever hit this");
   }
   virtual void AbortFrame() MOZ_OVERRIDE;
 
   virtual bool SupportsPartialTextureUpdate() { return true; }
-  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) MOZ_OVERRIDE { return true; }
+  virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE { return true; }
   virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE { return INT32_MAX; }
   virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) MOZ_OVERRIDE { }
   virtual void SetTargetContext(gfx::DrawTarget* aTarget) MOZ_OVERRIDE
   {
     mCopyTarget = aTarget;
   }
   
   virtual void SetScreenRenderOffset(const ScreenPoint& aOffset) MOZ_OVERRIDE {
--- a/gfx/layers/basic/BasicImageLayer.cpp
+++ b/gfx/layers/basic/BasicImageLayer.cpp
@@ -64,17 +64,17 @@ protected:
   }
 
   // only paints the image if aContext is non-null
   already_AddRefed<gfxPattern>
   GetAndPaintCurrentImage(gfxContext* aContext,
                           float aOpacity,
                           Layer* aMaskLayer);
 
-  gfx::IntSize mSize;
+  gfxIntSize mSize;
 };
 
 void
 BasicImageLayer::Paint(gfxContext* aContext, Layer* aMaskLayer)
 {
   if (IsHidden())
     return;
   nsRefPtr<gfxPattern> dontcare =
@@ -89,17 +89,17 @@ BasicImageLayer::GetAndPaintCurrentImage
   if (!mContainer)
     return nullptr;
 
   mContainer->SetImageFactory(mManager->IsCompositingCheap() ? nullptr : BasicManager()->GetImageFactory());
 
   nsRefPtr<gfxASurface> surface;
   AutoLockImage autoLock(mContainer, getter_AddRefs(surface));
   Image *image = autoLock.GetImage();
-  gfx::IntSize size = mSize = autoLock.GetSize();
+  gfxIntSize size = mSize = autoLock.GetSize();
 
   if (!surface || surface->CairoStatus()) {
     return nullptr;
   }
 
   nsRefPtr<gfxPattern> pat = new gfxPattern(surface);
   if (!pat) {
     return nullptr;
@@ -161,17 +161,17 @@ PaintContext(gfxPattern* aPattern,
 bool
 BasicImageLayer::GetAsSurface(gfxASurface** aSurface,
                               SurfaceDescriptor* aDescriptor)
 {
   if (!mContainer) {
     return false;
   }
 
-  gfx::IntSize dontCare;
+  gfxIntSize dontCare;
   nsRefPtr<gfxASurface> surface = mContainer->GetCurrentAsSurface(&dontCare);
   *aSurface = surface.forget().get();
   return true;
 }
 
 already_AddRefed<ImageLayer>
 BasicLayerManager::CreateImageLayer()
 {
--- a/gfx/layers/basic/BasicImages.cpp
+++ b/gfx/layers/basic/BasicImages.cpp
@@ -6,36 +6,36 @@
 #include <stdint.h>                     // for uint8_t, uint32_t
 #include "BasicLayers.h"                // for BasicLayerManager
 #include "ImageContainer.h"             // for PlanarYCbCrImage, etc
 #include "ImageTypes.h"                 // for ImageFormat, etc
 #include "cairo.h"                      // for cairo_user_data_key_t
 #include "gfxASurface.h"                // for gfxASurface, etc
 #include "gfxImageSurface.h"            // for gfxImageSurface
 #include "gfxPlatform.h"                // for gfxPlatform, gfxImageFormat
+#include "gfxPoint.h"                   // for gfxIntSize
 #include "gfxUtils.h"                   // for gfxUtils
 #include "mozilla/mozalloc.h"           // for operator delete[], etc
 #include "nsAutoPtr.h"                  // for nsRefPtr, nsAutoArrayPtr
 #include "nsAutoRef.h"                  // for nsCountedRef
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_ERROR, NS_ASSERTION
 #include "nsISupportsImpl.h"            // for Image::Release, etc
 #include "nsThreadUtils.h"              // for NS_IsMainThread
 #ifdef XP_MACOSX
 #include "gfxQuartzImageSurface.h"
 #endif
-#include "gfx2DGlue.h"
 
 namespace mozilla {
 namespace layers {
 
 class BasicPlanarYCbCrImage : public PlanarYCbCrImage
 {
 public:
-  BasicPlanarYCbCrImage(const gfx::IntSize& aScaleHint, gfxImageFormat aOffscreenFormat, BufferRecycleBin *aRecycleBin)
+  BasicPlanarYCbCrImage(const gfxIntSize& aScaleHint, gfxImageFormat aOffscreenFormat, BufferRecycleBin *aRecycleBin)
     : PlanarYCbCrImage(aRecycleBin)
     , mScaleHint(aScaleHint)
     , mDelayedConversion(false)
   {
     SetOffscreenFormat(aOffscreenFormat);
   }
 
   ~BasicPlanarYCbCrImage()
@@ -49,29 +49,29 @@ public:
 
   virtual void SetData(const Data& aData);
   virtual void SetDelayedConversion(bool aDelayed) { mDelayedConversion = aDelayed; }
 
   already_AddRefed<gfxASurface> GetAsSurface();
 
 private:
   nsAutoArrayPtr<uint8_t> mDecodedBuffer;
-  gfx::IntSize mScaleHint;
+  gfxIntSize mScaleHint;
   int mStride;
   bool mDelayedConversion;
 };
 
 class BasicImageFactory : public ImageFactory
 {
 public:
   BasicImageFactory() {}
 
   virtual already_AddRefed<Image> CreateImage(const ImageFormat* aFormats,
                                               uint32_t aNumFormats,
-                                              const gfx::IntSize &aScaleHint,
+                                              const gfxIntSize &aScaleHint,
                                               BufferRecycleBin *aRecycleBin)
   {
     if (!aNumFormats) {
       return nullptr;
     }
 
     nsRefPtr<Image> image;
     if (aFormats[0] == PLANAR_YCBCR) {
@@ -96,34 +96,34 @@ BasicPlanarYCbCrImage::SetData(const Dat
   if (aData.mYSize.width > PlanarYCbCrImage::MAX_DIMENSION ||
       aData.mYSize.height > PlanarYCbCrImage::MAX_DIMENSION) {
     NS_ERROR("Illegal image source width or height");
     return;
   }
 
   gfxImageFormat format = GetOffscreenFormat();
 
-  LayerIntSize size(mScaleHint.width, mScaleHint.height);
+  gfxIntSize size(mScaleHint);
   gfxUtils::GetYCbCrToRGBDestFormatAndSize(aData, format, size);
   if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
       size.height > PlanarYCbCrImage::MAX_DIMENSION) {
     NS_ERROR("Illegal image dest width or height");
     return;
   }
 
   mStride = gfxASurface::FormatStrideForWidth(format, size.width);
   mDecodedBuffer = AllocateBuffer(size.height * mStride);
   if (!mDecodedBuffer) {
     // out of memory
     return;
   }
 
   gfxUtils::ConvertYCbCrToRGB(aData, format, size, mDecodedBuffer, mStride);
   SetOffscreenFormat(format);
-  mSize = size.ToUnknownSize();
+  mSize = size;
 }
 
 static cairo_user_data_key_t imageSurfaceDataKey;
 
 static void
 DestroyBuffer(void* aBuffer)
 {
   delete[] static_cast<uint8_t*>(aBuffer);
@@ -141,17 +141,17 @@ BasicPlanarYCbCrImage::GetAsSurface()
 
   if (!mDecodedBuffer) {
     return PlanarYCbCrImage::GetAsSurface();
   }
 
   gfxImageFormat format = GetOffscreenFormat();
 
   nsRefPtr<gfxImageSurface> imgSurface =
-      new gfxImageSurface(mDecodedBuffer, ThebesIntSize(mSize), mStride, format);
+      new gfxImageSurface(mDecodedBuffer, mSize, mStride, format);
   if (!imgSurface || imgSurface->CairoStatus() != 0) {
     return nullptr;
   }
 
   // Pass ownership of the buffer to the surface
   imgSurface->SetData(&imageSurfaceDataKey, mDecodedBuffer.forget(), DestroyBuffer);
 
   nsRefPtr<gfxASurface> result = imgSurface.get();
--- a/gfx/layers/client/ClientImageLayer.cpp
+++ b/gfx/layers/client/ClientImageLayer.cpp
@@ -58,17 +58,17 @@ public:
   
   virtual void ClearCachedResources() MOZ_OVERRIDE
   {
     DestroyBackBuffer();
   }
 
   virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
   {
-    aAttrs = ImageLayerAttributes(mFilter, mScaleToSize.ToUnknownSize(), mScaleMode);
+    aAttrs = ImageLayerAttributes(mFilter, mScaleToSize, mScaleMode);
   }
 
   virtual Layer* AsLayer() { return this; }
   virtual ShadowableLayer* AsShadowableLayer() { return this; }
 
   virtual void Disconnect()
   {
     DestroyBackBuffer();
--- a/gfx/layers/client/ClientTiledThebesLayer.cpp
+++ b/gfx/layers/client/ClientTiledThebesLayer.cpp
@@ -3,16 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ClientTiledThebesLayer.h"
 #include "FrameMetrics.h"               // for FrameMetrics
 #include "Units.h"                      // for ScreenIntRect, CSSPoint, etc
 #include "ClientLayerManager.h"         // for ClientLayerManager, etc
 #include "gfx3DMatrix.h"                // for gfx3DMatrix
 #include "gfxPlatform.h"                // for gfxPlatform
+#include "gfxPoint.h"                   // for gfxSize
 #include "gfxRect.h"                    // for gfxRect
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/gfx/BaseSize.h"       // for BaseSize
 #include "mozilla/gfx/Rect.h"           // for Rect, RectTyped
 #include "mozilla/layers/LayersMessages.h"
 #include "mozilla/mozalloc.h"           // for operator delete, etc
 #include "nsRect.h"                     // for nsIntRect
 #include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -164,18 +164,18 @@ ImageClientSingle::UpdateImage(ImageCont
     if (mFrontBuffer && mFrontBuffer->IsImmutable()) {
       RemoveTextureClient(mFrontBuffer);
       mFrontBuffer = nullptr;
     }
 
     bool bufferCreated = false;
     if (!mFrontBuffer) {
       mFrontBuffer = CreateBufferTextureClient(gfx::FORMAT_YUV, TEXTURE_FLAGS_DEFAULT);
-      LayerIntSize ySize(data->mYSize.width, data->mYSize.height);
-      LayerIntSize cbCrSize(data->mCbCrSize.width, data->mCbCrSize.height);
+      gfx::IntSize ySize(data->mYSize.width, data->mYSize.height);
+      gfx::IntSize cbCrSize(data->mCbCrSize.width, data->mCbCrSize.height);
       if (!mFrontBuffer->AsTextureClientYCbCr()->AllocateForYCbCr(ySize, cbCrSize, data->mStereoMode)) {
         mFrontBuffer = nullptr;
         return false;
       }
       bufferCreated = true;
     }
 
     if (!mFrontBuffer->Lock(OPEN_READ_WRITE)) {
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -310,17 +310,17 @@ BufferTextureClient::AllocateForSurface(
 
   int bufSize
     = ImageDataSerializer::ComputeMinBufferSize(aSize, mFormat);
   if (!Allocate(bufSize)) {
     return false;
   }
   ImageDataSerializer serializer(GetBuffer());
   serializer.InitializeBufferInfo(aSize, mFormat);
-  mSize = LayerIntSize(aSize.width, aSize.height);
+  mSize = aSize;
   return true;
 }
 
 bool
 BufferTextureClient::UpdateYCbCr(const PlanarYCbCrData& aData)
 {
   MOZ_ASSERT(mFormat == gfx::FORMAT_YUV, "This textureClient can only use YCbCr data");
   MOZ_ASSERT(!IsImmutable());
@@ -341,18 +341,18 @@ BufferTextureClient::UpdateYCbCr(const P
     // We don't have support for proper locking yet, so we'll
     // have to be immutable instead.
     MarkImmutable();
   }
   return true;
 }
 
 bool
-BufferTextureClient::AllocateForYCbCr(LayerIntSize aYSize,
-                                      LayerIntSize aCbCrSize,
+BufferTextureClient::AllocateForYCbCr(gfx::IntSize aYSize,
+                                      gfx::IntSize aCbCrSize,
                                       StereoMode aStereoMode)
 {
   MOZ_ASSERT(IsValid());
 
   size_t bufSize = YCbCrImageDataSerializer::ComputeMinBufferSize(aYSize,
                                                                   aCbCrSize);
   if (!Allocate(bufSize)) {
     return false;
@@ -630,25 +630,25 @@ DeprecatedTextureClientTile::LockImageSu
 bool AutoLockShmemClient::Update(Image* aImage,
                                  uint32_t aContentFlags,
                                  gfxASurface *aSurface)
 {
   if (!aImage) {
     return false;
   }
 
-  gfx::IntSize size = aImage->GetSize();
+  gfxIntSize size = aImage->GetSize();
 
   gfxContentType contentType = aSurface->GetContentType();
   bool isOpaque = (aContentFlags & Layer::CONTENT_OPAQUE);
   if (contentType != GFX_CONTENT_ALPHA &&
       isOpaque) {
     contentType = GFX_CONTENT_COLOR;
   }
-  mDeprecatedTextureClient->EnsureAllocated(size, contentType);
+  mDeprecatedTextureClient->EnsureAllocated(gfx::IntSize(size.width, size.height), contentType);
 
   OpenMode mode = mDeprecatedTextureClient->GetAccessMode() == DeprecatedTextureClient::ACCESS_READ_WRITE
                   ? OPEN_READ_WRITE
                   : OPEN_READ_ONLY;
   nsRefPtr<gfxASurface> tmpASurface =
     ShadowLayerForwarder::OpenDescriptor(mode,
                                          *mDeprecatedTextureClient->LockSurfaceDescriptor());
   if (!tmpASurface) {
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -19,17 +19,16 @@
 #include "mozilla/gfx/Types.h"          // for SurfaceFormat
 #include "mozilla/ipc/Shmem.h"          // for Shmem
 #include "mozilla/layers/CompositorTypes.h"  // for TextureFlags, etc
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsISupportsImpl.h"            // for TextureImage::AddRef, etc
-#include "Units.h"
 
 class gfxReusableSurfaceWrapper;
 class gfxASurface;
 class gfxImageSurface;
 
 namespace mozilla {
 namespace layers {
 
@@ -62,18 +61,18 @@ public:
 
 /**
  * Interface for TextureClients that can be updated using YCbCr data.
  */
 class TextureClientYCbCr
 {
 public:
   virtual bool UpdateYCbCr(const PlanarYCbCrData& aData) = 0;
-  virtual bool AllocateForYCbCr(LayerIntSize aYSize,
-                                LayerIntSize aCbCrSize,
+  virtual bool AllocateForYCbCr(gfx::IntSize aYSize,
+                                gfx::IntSize aCbCrSize,
                                 StereoMode aStereoMode) = 0;
 };
 
 /**
  * Holds the shared data of a TextureClient, to be destroyed later.
  *
  * TextureClient's destructor initiates the destruction sequence of the
  * texture client/host pair. If the shared data is to be deallocated on the
@@ -246,17 +245,17 @@ public:
   virtual ~BufferTextureClient();
 
   virtual bool IsAllocated() const = 0;
 
   virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) = 0;
 
   virtual uint8_t* GetBuffer() const = 0;
 
-  virtual gfx::IntSize GetSize() const { return mSize.ToUnknownSize(); }
+  virtual gfx::IntSize GetSize() const { return mSize; }
 
   // TextureClientSurface
 
   virtual TextureClientSurface* AsTextureClientSurface() MOZ_OVERRIDE { return this; }
 
   virtual bool UpdateSurface(gfxASurface* aSurface) MOZ_OVERRIDE;
 
   virtual already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
@@ -264,34 +263,34 @@ public:
   virtual bool AllocateForSurface(gfx::IntSize aSize) MOZ_OVERRIDE;
 
   // TextureClientYCbCr
 
   virtual TextureClientYCbCr* AsTextureClientYCbCr() MOZ_OVERRIDE { return this; }
 
   virtual bool UpdateYCbCr(const PlanarYCbCrData& aData) MOZ_OVERRIDE;
 
-  virtual bool AllocateForYCbCr(LayerIntSize aYSize,
-                                LayerIntSize aCbCrSize,
+  virtual bool AllocateForYCbCr(gfx::IntSize aYSize,
+                                gfx::IntSize aCbCrSize,
                                 StereoMode aStereoMode) MOZ_OVERRIDE;
 
   gfx::SurfaceFormat GetFormat() const { return mFormat; }
 
   // XXX - Bug 908196 - Make Allocate(uint32_t) and GetBufferSize() protected.
   // these two methods should only be called by methods of BufferTextureClient
   // that are overridden in GrallocTextureClient (which does not implement the
   // two methods below)
   virtual bool Allocate(uint32_t aSize) = 0;
 
   virtual size_t GetBufferSize() const = 0;
 
 protected:
   CompositableClient* mCompositable;
   gfx::SurfaceFormat mFormat;
-  LayerIntSize mSize;
+  gfx::IntSize mSize;
 };
 
 /**
  * TextureClient that wraps shared memory.
  * the corresponding texture on the host side is ShmemTextureHost.
  */
 class ShmemTextureClient : public BufferTextureClient
 {
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -416,17 +416,17 @@ BasicTiledLayerBuffer::ValidateTile(Basi
   }
 
   return aTile;
 }
 
 static nsIntRect
 RoundedTransformViewportBounds(const gfx::Rect& aViewport,
                                const CSSPoint& aScrollOffset,
-                               const LayerSize& aResolution,
+                               const gfxSize& aResolution,
                                float aScaleX,
                                float aScaleY,
                                const gfx3DMatrix& aTransform)
 {
   gfxRect transformedViewport(aViewport.x - (aScrollOffset.x * aResolution.width),
                               aViewport.y - (aScrollOffset.y * aResolution.height),
                               aViewport.width, aViewport.height);
   transformedViewport.Scale((aScaleX / aResolution.width) / aResolution.width,
--- a/gfx/layers/client/TiledContentClient.h
+++ b/gfx/layers/client/TiledContentClient.h
@@ -9,16 +9,17 @@
 #include <stddef.h>                     // for size_t
 #include <stdint.h>                     // for uint16_t
 #include <algorithm>                    // for swap
 #include "Layers.h"                     // for LayerManager, etc
 #include "TiledLayerBuffer.h"           // for TiledLayerBuffer
 #include "Units.h"                      // for CSSPoint
 #include "gfx3DMatrix.h"                // for gfx3DMatrix
 #include "gfxTypes.h"
+#include "gfxPoint.h"                   // for gfxSize
 #include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "mozilla/layers/CompositableClient.h"  // for CompositableClient
 #include "mozilla/layers/CompositorTypes.h"  // for TextureInfo, etc
 #include "mozilla/layers/TextureClient.h"
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsPoint.h"                    // for nsIntPoint
@@ -102,17 +103,17 @@ struct BasicTiledLayerTile {
  * This struct stores all the data necessary to perform a paint so that it
  * doesn't need to be recalculated on every repeated transaction.
  */
 struct BasicTiledLayerPaintData {
   CSSPoint mScrollOffset;
   CSSPoint mLastScrollOffset;
   gfx3DMatrix mTransformScreenToLayer;
   nsIntRect mLayerCriticalDisplayPort;
-  LayerSize mResolution;
+  gfxSize mResolution;
   nsIntRect mCompositionBounds;
   uint16_t mLowPrecisionPaintCount;
   bool mFirstPaint : 1;
   bool mPaintFinished : 1;
 };
 
 class ClientTiledThebesLayer;
 class ClientLayerManager;
@@ -174,18 +175,18 @@ public:
 
   void ReadLock() {
     for (size_t i = 0; i < mRetainedTiles.Length(); i++) {
       if (mRetainedTiles[i].IsPlaceholderTile()) continue;
       mRetainedTiles[i].ReadLock();
     }
   }
 
-  const LayerSize& GetFrameResolution() { return mFrameResolution; }
-  void SetFrameResolution(const LayerSize& aResolution) { mFrameResolution = aResolution; }
+  const gfxSize& GetFrameResolution() { return mFrameResolution; }
+  void SetFrameResolution(const gfxSize& aResolution) { mFrameResolution = aResolution; }
 
   bool HasFormatChanged() const;
 
   /**
    * Performs a progressive update of a given tiled buffer.
    * See ComputeProgressiveUpdateRegion below for parameter documentation.
    */
   bool ProgressiveUpdate(nsIntRegion& aValidRegion,
@@ -220,17 +221,17 @@ protected:
   BasicTiledLayerTile GetPlaceholderTile() const { return BasicTiledLayerTile(); }
 
 private:
   gfxContentType GetContentType() const;
   ClientTiledThebesLayer* mThebesLayer;
   ClientLayerManager* mManager;
   LayerManager::DrawThebesLayerCallback mCallback;
   void* mCallbackData;
-  LayerSize mFrameResolution;
+  gfxSize mFrameResolution;
   bool mLastPaintOpaque;
 
   // The buffer we use when UseSinglePaintBuffer() above is true.
   nsRefPtr<gfxImageSurface>     mSinglePaintBuffer;
   RefPtr<gfx::DrawTarget>       mSinglePaintDrawTarget;
   nsIntPoint                    mSinglePaintBufferOffset;
 
   BasicTiledLayerTile ValidateTileInternal(BasicTiledLayerTile aTile,
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -7,17 +7,17 @@
 #include "mozilla/layers/AsyncCompositionManager.h"
 #include <stdint.h>                     // for uint32_t
 #include "AnimationCommon.h"            // for ComputedTimingFunction
 #include "CompositorParent.h"           // for CompositorParent, etc
 #include "FrameMetrics.h"               // for FrameMetrics
 #include "LayerManagerComposite.h"      // for LayerManagerComposite, etc
 #include "Layers.h"                     // for Layer, ContainerLayer, etc
 #include "gfxMatrix.h"                  // for gfxMatrix
-#include "gfxPoint.h"                   // for gfxPoint
+#include "gfxPoint.h"                   // for gfxPoint, gfxSize
 #include "gfxPoint3D.h"                 // for gfxPoint3D
 #include "mozilla/WidgetUtils.h"        // for ComputeTransformForRotation
 #include "mozilla/gfx/BaseRect.h"       // for BaseRect
 #include "mozilla/gfx/Point.h"          // for RoundedToInt, PointTyped
 #include "mozilla/gfx/Rect.h"           // for RoundedToInt, RectTyped
 #include "mozilla/gfx/ScaleFactor.h"    // for ScaleFactor
 #include "mozilla/layers/AsyncPanZoomController.h"
 #include "mozilla/layers/Compositor.h"  // for Compositor
@@ -651,17 +651,17 @@ AsyncCompositionManager::TransformScroll
   if (userScroll.y < contentScreenRect.y) {
     overscrollTranslation.y = contentScreenRect.y - userScroll.y;
   } else if (userScroll.y + metrics.mCompositionBounds.height > contentScreenRect.YMost()) {
     overscrollTranslation.y = contentScreenRect.YMost() -
       (userScroll.y + metrics.mCompositionBounds.height);
   }
   oldTransform.Translate(overscrollTranslation);
 
-  gfx::Size underZoomScale(1.0f, 1.0f);
+  gfxSize underZoomScale(1.0f, 1.0f);
   if (mContentRect.width * userZoom.scale < metrics.mCompositionBounds.width) {
     underZoomScale.width = (mContentRect.width * userZoom.scale) /
       metrics.mCompositionBounds.width;
   }
   if (mContentRect.height * userZoom.scale < metrics.mCompositionBounds.height) {
     underZoomScale.height = (mContentRect.height * userZoom.scale) /
       metrics.mCompositionBounds.height;
   }
--- a/gfx/layers/composite/CompositableHost.h
+++ b/gfx/layers/composite/CompositableHost.h
@@ -3,32 +3,32 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_GFX_BUFFERHOST_H
 #define MOZILLA_GFX_BUFFERHOST_H
 
 #include <stdint.h>                     // for uint64_t
 #include <stdio.h>                      // for FILE
+#include "gfxPoint.h"                   // for gfxSize
 #include "gfxRect.h"                    // for gfxRect
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
 #include "mozilla/RefPtr.h"             // for RefPtr, RefCounted, etc
 #include "mozilla/gfx/Point.h"          // for Point
 #include "mozilla/gfx/Rect.h"           // for Rect
 #include "mozilla/gfx/Types.h"          // for Filter
 #include "mozilla/ipc/ProtocolUtils.h"
 #include "mozilla/layers/CompositorTypes.h"  // for TextureInfo, etc
 #include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
 #include "mozilla/layers/PCompositableParent.h"
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nscore.h"                     // for nsACString
-#include "Units.h"
 
 class gfxImageSurface;
 struct nsIntPoint;
 struct nsIntRect;
 
 namespace mozilla {
 namespace gfx {
 class Matrix4x4;
@@ -37,17 +37,17 @@ class Matrix4x4;
 namespace layers {
 
 // Some properties of a Layer required for tiling
 struct TiledLayerProperties
 {
   nsIntRegion mVisibleRegion;
   nsIntRegion mValidRegion;
   gfxRect mDisplayPort;
-  LayerSize mEffectiveResolution;
+  gfxSize mEffectiveResolution;
   gfxRect mCompositionBounds;
   bool mRetainTiles;
 };
 
 class Layer;
 class DeprecatedTextureHost;
 class TextureHost;
 class SurfaceDescriptor;
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -762,19 +762,20 @@ LayerManagerComposite::SetCompositorID(u
 
 void
 LayerManagerComposite::NotifyShadowTreeTransaction()
 {
   mCompositor->NotifyLayersTransaction();
 }
 
 bool
-LayerManagerComposite::CanUseCanvasLayerForSize(const LayerIntSize &aSize)
+LayerManagerComposite::CanUseCanvasLayerForSize(const gfxIntSize &aSize)
 {
-  return mCompositor->CanUseCanvasLayerForSize(aSize);
+  return mCompositor->CanUseCanvasLayerForSize(gfx::IntSize(aSize.width,
+                                                            aSize.height));
 }
 
 TextureFactoryIdentifier
 LayerManagerComposite::GetTextureFactoryIdentifier()
 {
   return mCompositor->GetTextureFactoryIdentifier();
 }
 
--- a/gfx/layers/composite/LayerManagerComposite.h
+++ b/gfx/layers/composite/LayerManagerComposite.h
@@ -113,17 +113,17 @@ public:
 
   virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) MOZ_OVERRIDE;
   virtual void EndTransaction(DrawThebesLayerCallback aCallback,
                               void* aCallbackData,
                               EndTransactionFlags aFlags = END_DEFAULT) MOZ_OVERRIDE;
 
   virtual void SetRoot(Layer* aLayer) MOZ_OVERRIDE { mRoot = aLayer; }
 
-  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) MOZ_OVERRIDE;
+  virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) MOZ_OVERRIDE;
 
   virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() MOZ_OVERRIDE;
 
   virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE;
 
   virtual void ClearCachedResources(Layer* aSubtree = nullptr) MOZ_OVERRIDE;
 
   virtual already_AddRefed<ThebesLayer> CreateThebesLayer() MOZ_OVERRIDE;
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -408,27 +408,27 @@ BufferTextureHost::Upload(nsIntRegion *a
       srcU = mFirstSource->GetNextSibling()->AsDataTextureSource();
       srcV = mFirstSource->GetNextSibling()->GetNextSibling()->AsDataTextureSource();
     }
 
 
     RefPtr<gfx::DataSourceSurface> tempY =
       gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetYData(),
                                                     yuvDeserializer.GetYStride(),
-                                                    yuvDeserializer.GetYSize().ToUnknownSize(),
+                                                    gfx::ToIntSize(yuvDeserializer.GetYSize()),
                                                     gfx::FORMAT_A8);
     RefPtr<gfx::DataSourceSurface> tempCb =
       gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCbData(),
                                                     yuvDeserializer.GetCbCrStride(),
-                                                    yuvDeserializer.GetCbCrSize().ToUnknownSize(),
+                                                    gfx::ToIntSize(yuvDeserializer.GetCbCrSize()),
                                                     gfx::FORMAT_A8);
     RefPtr<gfx::DataSourceSurface> tempCr =
       gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCrData(),
                                                     yuvDeserializer.GetCbCrStride(),
-                                                    yuvDeserializer.GetCbCrSize().ToUnknownSize(),
+                                                    gfx::ToIntSize(yuvDeserializer.GetCbCrSize()),
                                                     gfx::FORMAT_A8);
     // We don't support partial updates for Y U V textures
     NS_ASSERTION(!aRegion, "Unsupported partial updates for YCbCr textures");
     if (!srcY->Update(tempY, mFlags) ||
         !srcU->Update(tempCb, mFlags) ||
         !srcV->Update(tempCr, mFlags)) {
       NS_WARNING("failed to update the DataTextureSource");
       return false;
@@ -465,17 +465,17 @@ BufferTextureHost::GetAsSurface()
     NS_WARNING("BufferTextureHost: unsupported format!");
     return nullptr;
   } else if (mFormat == gfx::FORMAT_YUV) {
     YCbCrImageDataDeserializer yuvDeserializer(GetBuffer());
     if (!yuvDeserializer.IsValid()) {
       return nullptr;
     }
     result = new gfxImageSurface(yuvDeserializer.GetYData(),
-                                 ThebesIntSize(yuvDeserializer.GetYSize().ToUnknownSize()),
+                                 yuvDeserializer.GetYSize(),
                                  yuvDeserializer.GetYStride(),
                                  gfxImageFormatA8);
   } else {
     ImageDataDeserializer deserializer(GetBuffer());
     if (!deserializer.IsValid()) {
       return nullptr;
     }
     RefPtr<gfxImageSurface> surf = deserializer.GetAsThebesSurface();
--- a/gfx/layers/composite/ThebesLayerComposite.cpp
+++ b/gfx/layers/composite/ThebesLayerComposite.cpp
@@ -171,25 +171,25 @@ void
 ThebesLayerComposite::CleanupResources()
 {
   if (mBuffer) {
     mBuffer->Detach(this);
   }
   mBuffer = nullptr;
 }
 
-LayerSize
+gfxSize
 ThebesLayerComposite::GetEffectiveResolution()
 {
   // Work out render resolution by multiplying the resolution of our ancestors.
   // Only container layers can have frame metrics, so we start off with a
   // resolution of 1, 1.
   // XXX For large layer trees, it would be faster to do this once from the
   //     root node upwards and store the value on each layer.
-  LayerSize resolution(1, 1);
+  gfxSize resolution(1, 1);
   for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
     const FrameMetrics& metrics = parent->GetFrameMetrics();
     resolution.width *= metrics.mResolution.scale;
     resolution.height *= metrics.mResolution.scale;
   }
 
   return resolution;
 }
@@ -201,17 +201,17 @@ ThebesLayerComposite::GetDisplayPort()
   // as we want the transform of the shadowable layers and not that of the
   // shadow layers, which may have been modified due to async scrolling/
   // zooming.
   gfx3DMatrix transform = GetTransform();
 
   // Find out the area of the nearest display-port to invalidate retained
   // tiles.
   gfxRect displayPort;
-  LayerSize parentResolution = GetEffectiveResolution();
+  gfxSize parentResolution = GetEffectiveResolution();
   for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
     const FrameMetrics& metrics = parent->GetFrameMetrics();
     if (displayPort.IsEmpty()) {
       if (!metrics.mDisplayPort.IsEmpty()) {
           // We use the bounds to cut down on complication/computation time.
           // This will be incorrect when the transform involves rotation, but
           // it'd be quite hard to retain invalid tiles correctly in this
           // situation anyway.
--- a/gfx/layers/composite/ThebesLayerComposite.h
+++ b/gfx/layers/composite/ThebesLayerComposite.h
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_ThebesLayerComposite_H
 #define GFX_ThebesLayerComposite_H
 
 #include "Layers.h"                     // for Layer (ptr only), etc
+#include "gfxPoint.h"                   // for gfxSize
 #include "gfxRect.h"                    // for gfxRect
 #include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "mozilla/layers/LayerManagerComposite.h"  // for LayerComposite, etc
 #include "mozilla/layers/LayersTypes.h"  // for LayerRenderState, etc
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nscore.h"                     // for nsACString
@@ -80,17 +81,17 @@ public:
 protected:
 
 #ifdef MOZ_LAYERS_HAVE_LOG
   virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix) MOZ_OVERRIDE;
 #endif
 
 private:
   gfxRect GetDisplayPort();
-  LayerSize GetEffectiveResolution();
+  gfxSize GetEffectiveResolution();
   gfxRect GetCompositionBounds();
 
   RefPtr<ContentHost> mBuffer;
   bool mRequiresTiledProperties;
 };
 
 } /* layers */
 } /* mozilla */
--- a/gfx/layers/composite/TiledContentHost.cpp
+++ b/gfx/layers/composite/TiledContentHost.cpp
@@ -23,17 +23,17 @@ using namespace gfx;
 namespace layers {
 
 class Layer;
 
 void
 TiledLayerBufferComposite::Upload(const BasicTiledLayerBuffer* aMainMemoryTiledBuffer,
                                   const nsIntRegion& aNewValidRegion,
                                   const nsIntRegion& aInvalidateRegion,
-                                  const LayerSize& aResolution)
+                                  const gfxSize& aResolution)
 {
 #ifdef GFX_TILEDLAYER_PREF_WARNINGS
   printf_stderr("Upload %i, %i, %i, %i\n", aInvalidateRegion.GetBounds().x, aInvalidateRegion.GetBounds().y, aInvalidateRegion.GetBounds().width, aInvalidateRegion.GetBounds().height);
   long start = PR_IntervalNow();
 #endif
 
   mFrameResolution = aResolution;
   mMainMemoryTiledBuffer = aMainMemoryTiledBuffer;
@@ -222,22 +222,22 @@ TiledContentHost::RenderLayerBuffer(Tile
                                     nsIntRect aVisibleRect,
                                     gfx::Matrix4x4 aTransform)
 {
   if (!mCompositor) {
     NS_WARNING("Can't render tiled content host - no compositor");
     return;
   }
   float resolution = aLayerBuffer.GetResolution();
-  LayerSize layerScale(1, 1);
+  gfxSize layerScale(1, 1);
   // We assume that the current frame resolution is the one used in our primary
   // layer buffer. Compensate for a changing frame resolution.
   if (aLayerBuffer.GetFrameResolution() != mVideoMemoryTiledBuffer.GetFrameResolution()) {
-    const LayerSize& layerResolution = aLayerBuffer.GetFrameResolution();
-    const LayerSize& localResolution = mVideoMemoryTiledBuffer.GetFrameResolution();
+    const gfxSize& layerResolution = aLayerBuffer.GetFrameResolution();
+    const gfxSize& localResolution = mVideoMemoryTiledBuffer.GetFrameResolution();
     layerScale.width = layerResolution.width / localResolution.width;
     layerScale.height = layerResolution.height / localResolution.height;
     aVisibleRect.ScaleRoundOut(layerScale.width, layerScale.height);
   }
   aTransform.Scale(1/(resolution * layerScale.width),
                    1/(resolution * layerScale.height), 1);
 
   uint32_t rowCount = 0;
--- a/gfx/layers/composite/TiledContentHost.h
+++ b/gfx/layers/composite/TiledContentHost.h
@@ -7,16 +7,17 @@
 #define GFX_TILEDCONTENTHOST_H
 
 #include <stdint.h>                     // for uint16_t
 #include <stdio.h>                      // for FILE
 #include <algorithm>                    // for swap
 #include "ContentHost.h"                // for ContentHost
 #include "TiledLayerBuffer.h"           // for TiledLayerBuffer, etc
 #include "CompositableHost.h"
+#include "gfxPoint.h"                   // for gfxSize
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "mozilla/gfx/Point.h"          // for Point
 #include "mozilla/gfx/Rect.h"           // for Rect
 #include "mozilla/gfx/Types.h"          // for Filter
 #include "mozilla/layers/CompositorTypes.h"  // for TextureInfo, etc
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
@@ -100,23 +101,23 @@ public:
   typedef TiledLayerBuffer<TiledLayerBufferComposite, TiledTexture>::Iterator Iterator;
   TiledLayerBufferComposite()
     : mCompositor(nullptr)
   {}
 
   void Upload(const BasicTiledLayerBuffer* aMainMemoryTiledBuffer,
               const nsIntRegion& aNewValidRegion,
               const nsIntRegion& aInvalidateRegion,
-              const LayerSize& aResolution);
+              const gfxSize& aResolution);
 
   TiledTexture GetPlaceholderTile() const { return TiledTexture(); }
 
   // Stores the absolute resolution of the containing frame, calculated
   // by the sum of the resolutions of all parent layers' FrameMetrics.
-  const LayerSize& GetFrameResolution() { return mFrameResolution; }
+  const gfxSize& GetFrameResolution() { return mFrameResolution; }
 
   void SetCompositor(Compositor* aCompositor)
   {
     mCompositor = aCompositor;
   }
 
 protected:
   TiledTexture ValidateTile(TiledTexture aTile,
@@ -128,17 +129,17 @@ protected:
 
   void SwapTiles(TiledTexture& aTileA, TiledTexture& aTileB) {
     std::swap(aTileA, aTileB);
   }
 
 private:
   Compositor* mCompositor;
   const BasicTiledLayerBuffer* mMainMemoryTiledBuffer;
-  LayerSize mFrameResolution;
+  gfxSize mFrameResolution;
 };
 
 /**
  * ContentHost for tiled Thebes layers. Since tiled layers are special snow
  * flakes, we don't call UpdateThebes or AddTextureHost, etc. We do call Composite
  * in the usual way though.
  *
  * There is no corresponding content client - on the client side we use a
--- a/gfx/layers/d3d10/ImageLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ImageLayerD3D10.cpp
@@ -7,26 +7,25 @@
 #include "gfxImageSurface.h"
 #include "gfxD2DSurface.h"
 #include "gfxWindowsSurface.h"
 #include "yuv_convert.h"
 #include "../d3d9/Nv3DVUtils.h"
 #include "D3D9SurfaceImage.h"
 
 #include "gfxWindowsPlatform.h"
-#include "gfx2DGlue.h"
 
 namespace mozilla {
 namespace layers {
 
 static already_AddRefed<ID3D10Texture2D>
 DataToTexture(ID3D10Device *aDevice,
               unsigned char *data,
               int stride,
-              const gfx::IntSize &aSize)
+              const gfxIntSize &aSize)
 {
   D3D10_SUBRESOURCE_DATA srdata;
 
   CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM,
                              aSize.width,
                              aSize.height,
                              1, 1);
   desc.Usage = D3D10_USAGE_IMMUTABLE;
@@ -43,17 +42,17 @@ DataToTexture(ID3D10Device *aDevice,
   }
 
   return texture.forget();
 }
 
 static already_AddRefed<ID3D10Texture2D>
 SurfaceToTexture(ID3D10Device *aDevice,
                  gfxASurface *aSurface,
-                 const gfx::IntSize &aSize)
+                 const gfxIntSize &aSize)
 {
   if (!aSurface) {
     return nullptr;
   }
 
   if (aSurface->GetType() == gfxSurfaceTypeD2D) {
     void *data = aSurface->GetData(&gKeyD3D10Texture);
     if (data) {
@@ -64,17 +63,17 @@ SurfaceToTexture(ID3D10Device *aDevice,
         return texture.forget();
       }
     }
   }
 
   nsRefPtr<gfxImageSurface> imageSurface = aSurface->GetAsImageSurface();
 
   if (!imageSurface) {
-    imageSurface = new gfxImageSurface(ThebesIntSize(aSize),
+    imageSurface = new gfxImageSurface(aSize,
                                        gfxImageFormatARGB32);
 
     nsRefPtr<gfxContext> context = new gfxContext(imageSurface);
     context->SetSource(aSurface);
     context->SetOperator(gfxContext::OPERATOR_SOURCE);
     context->Paint();
   }
 
@@ -198,17 +197,17 @@ ImageLayerD3D10::RenderLayer()
 
   AutoLockImage autoLock(container);
 
   Image *image = autoLock.GetImage();
   if (!image) {
     return;
   }
 
-  gfx::IntSize size = image->GetSize();
+  gfxIntSize size = image->GetSize();
 
   SetEffectTransformAndOpacity();
 
   ID3D10EffectTechnique *technique;
   nsRefPtr<IDXGIKeyedMutex> keyedMutex;
 
   if (image->GetFormat() == ImageFormat::CAIRO_SURFACE ||
       image->GetFormat() == ImageFormat::REMOTE_IMAGE_BITMAP ||
@@ -406,17 +405,17 @@ ImageLayerD3D10::GetAsTexture(gfxIntSize
   if (!image) {
     return nullptr;
   }
 
   if (image->GetFormat() != ImageFormat::CAIRO_SURFACE) {
     return nullptr;
   }
 
-  *aSize = ThebesIntSize(image->GetSize());
+  *aSize = image->GetSize();
   bool dontCare;
   nsRefPtr<ID3D10ShaderResourceView> result = GetImageSRView(image, dontCare);
   return result.forget();
 }
 
 already_AddRefed<gfxASurface>
 RemoteDXGITextureImage::GetAsSurface()
 {
@@ -461,20 +460,19 @@ RemoteDXGITextureImage::GetAsSurface()
     NS_WARNING("Failed to create 2D staging texture.");
     return nullptr;
   }
 
   device->CopyResource(softTexture, data->mTexture);
   keyedMutex->ReleaseSync(0);
 
   nsRefPtr<gfxImageSurface> surface =
-    new gfxImageSurface(ThebesIntSize(mSize),
-                        mFormat == RemoteImageData::BGRX32 ?
-                                   gfxImageFormatRGB24 :
-                                   gfxImageFormatARGB32);
+    new gfxImageSurface(mSize, mFormat == RemoteImageData::BGRX32 ?
+                                          gfxImageFormatRGB24 :
+                                          gfxImageFormatARGB32);
 
   if (!surface->CairoSurface() || surface->CairoStatus()) {
     NS_WARNING("Failed to created image surface for DXGI texture.");
     return nullptr;
   }
 
   D3D10_MAPPED_TEXTURE2D mapped;
   softTexture->Map(0, D3D10_MAP_READ, 0, &mapped);
--- a/gfx/layers/d3d10/ImageLayerD3D10.h
+++ b/gfx/layers/d3d10/ImageLayerD3D10.h
@@ -5,17 +5,16 @@
 
 #ifndef GFX_IMAGELAYERD3D10_H
 #define GFX_IMAGELAYERD3D10_H
 
 #include "LayerManagerD3D10.h"
 #include "ImageLayers.h"
 #include "ImageContainer.h"
 #include "yuv_convert.h"
-#include "mozilla/gfx/Point.h"
 
 namespace mozilla {
 namespace layers {
 
 class ImageLayerD3D10 : public ImageLayer,
                         public LayerD3D10
 {
 public:
@@ -56,20 +55,20 @@ struct TextureD3D10BackendData : public 
 };
 
 class RemoteDXGITextureImage : public Image {
 public:
   RemoteDXGITextureImage() : Image(nullptr, REMOTE_IMAGE_DXGI_TEXTURE) {}
 
   already_AddRefed<gfxASurface> GetAsSurface();
 
-  gfx::IntSize GetSize() { return mSize; }
+  gfxIntSize GetSize() { return mSize; }
 
   TextureD3D10BackendData *GetD3D10TextureBackendData(ID3D10Device *aDevice);
 
-  gfx::IntSize mSize;
+  gfxIntSize mSize;
   RemoteImageData::Format mFormat;
   HANDLE mHandle;
 };
 
 } /* layers */
 } /* mozilla */
 #endif /* GFX_IMAGELAYERD3D10_H */
--- a/gfx/layers/d3d10/LayerManagerD3D10.h
+++ b/gfx/layers/d3d10/LayerManagerD3D10.h
@@ -87,19 +87,19 @@ public:
                               EndTransactionFlags aFlags = END_DEFAULT);
 
   const CallbackInfo &GetCallbackInfo() { return mCurrentCallbackInfo; }
 
   // D3D10 guarantees textures can be at least this size
   enum {
     MAX_TEXTURE_SIZE = 8192
   };
-  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize)
+  virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize)
   {
-    return aSize <= LayerIntSize(MAX_TEXTURE_SIZE, MAX_TEXTURE_SIZE);
+    return aSize <= gfxIntSize(MAX_TEXTURE_SIZE, MAX_TEXTURE_SIZE);
   }
 
   virtual int32_t GetMaxTextureSize() const
   {
     return MAX_TEXTURE_SIZE;
   }
 
   virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -344,20 +344,25 @@ CompositorD3D11::GetTextureFactoryIdenti
   TextureFactoryIdentifier ident;
   ident.mMaxTextureSize = GetMaxTextureSize();
   ident.mParentProcessId = XRE_GetProcessType();
   ident.mParentBackend = LAYERS_D3D11;
   return ident;
 }
 
 bool
-CompositorD3D11::CanUseCanvasLayerForSize(const LayerIntSize& aSize)
+CompositorD3D11::CanUseCanvasLayerForSize(const gfx::IntSize& aSize)
 {
   int32_t maxTextureSize = GetMaxTextureSize();
-  return aSize < LayerIntSize(maxTextureSize, maxTextureSize);
+
+  if (aSize.width > maxTextureSize || aSize.height > maxTextureSize) {
+    return false;
+  }
+
+  return true;
 }
 
 int32_t
 CompositorD3D11::GetMaxTextureSize() const
 {
   return GetMaxTextureSizeForFeatureLevel(mFeatureLevel);
 }
 
--- a/gfx/layers/d3d11/CompositorD3D11.h
+++ b/gfx/layers/d3d11/CompositorD3D11.h
@@ -46,17 +46,17 @@ public:
   virtual void Destroy() MOZ_OVERRIDE {}
 
   virtual TextureFactoryIdentifier
     GetTextureFactoryIdentifier() MOZ_OVERRIDE;
 
   virtual TemporaryRef<DataTextureSource>
     CreateDataTextureSource(TextureFlags aFlags = 0) MOZ_OVERRIDE { return nullptr; }
 
-  virtual bool CanUseCanvasLayerForSize(const LayerIntSize& aSize) MOZ_OVERRIDE;
+  virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) MOZ_OVERRIDE;
   virtual int32_t GetMaxTextureSize() const MOZ_FINAL;
 
   virtual void SetTargetContext(gfx::DrawTarget* aTarget)  MOZ_OVERRIDE
   {
     mTarget = aTarget;
   }
 
   virtual void MakeCurrent(MakeCurrentFlags aFlags = 0)  MOZ_OVERRIDE {}
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -481,37 +481,37 @@ void
 DeprecatedTextureHostYCbCrD3D11::UpdateImpl(const SurfaceDescriptor& aImage,
                                   nsIntRegion* aRegion,
                                   nsIntPoint* aOffset)
 {
   MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TYCbCrImage);
 
   YCbCrImageDataDeserializer yuvDeserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
 
-  LayerIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
+  gfxIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
 
-  LayerIntSize size = yuvDeserializer.GetYSize();
+  gfxIntSize size = yuvDeserializer.GetYSize();
 
   D3D11_SUBRESOURCE_DATA initData;
   initData.pSysMem = yuvDeserializer.GetYData();
   initData.SysMemPitch = yuvDeserializer.GetYStride();
 
   CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_R8_UNORM, size.width, size.height,
                              1, 1, D3D11_BIND_SHADER_RESOURCE,
                              D3D11_USAGE_IMMUTABLE);
 
   mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[0]));
 
   initData.pSysMem = yuvDeserializer.GetCbData();
   initData.SysMemPitch = yuvDeserializer.GetCbCrStride();
-  desc.Width = gfxCbCrSize.width;
-  desc.Height = gfxCbCrSize.height;
+  desc.Width = yuvDeserializer.GetCbCrSize().width;
+  desc.Height = yuvDeserializer.GetCbCrSize().height;
 
   mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[1]));
 
   initData.pSysMem = yuvDeserializer.GetCrData();
   mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[2]));
 
-  mSize = size.ToUnknownSize();
+  mSize = IntSize(size.width, size.height);
 }
 
 }
 }
--- a/gfx/layers/d3d9/CompositorD3D9.cpp
+++ b/gfx/layers/d3d9/CompositorD3D9.cpp
@@ -60,20 +60,25 @@ CompositorD3D9::GetTextureFactoryIdentif
   TextureFactoryIdentifier ident;
   ident.mMaxTextureSize = GetMaxTextureSize();
   ident.mParentBackend = LAYERS_D3D9;
   ident.mParentProcessId = XRE_GetProcessType();
   return ident;
 }
 
 bool
-CompositorD3D9::CanUseCanvasLayerForSize(const LayerIntSize &aSize)
+CompositorD3D9::CanUseCanvasLayerForSize(const IntSize &aSize)
 {
   int32_t maxTextureSize = GetMaxTextureSize();
-  return aSize < LayerIntSize(maxTextureSize, maxTextureSize);
+
+  if (aSize.width > maxTextureSize || aSize.height > maxTextureSize) {
+    return false;
+  }
+
+  return true;
 }
 
 int32_t
 CompositorD3D9::GetMaxTextureSize() const
 {
   return mDeviceManager->GetMaxTextureSize();
 }
 
--- a/gfx/layers/d3d9/CompositorD3D9.h
+++ b/gfx/layers/d3d9/CompositorD3D9.h
@@ -23,17 +23,17 @@ public:
   ~CompositorD3D9();
 
   virtual bool Initialize() MOZ_OVERRIDE;
   virtual void Destroy() MOZ_OVERRIDE {}
 
   virtual TextureFactoryIdentifier
     GetTextureFactoryIdentifier() MOZ_OVERRIDE;
 
-  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) MOZ_OVERRIDE;
+  virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE;
   virtual int32_t GetMaxTextureSize() const MOZ_FINAL;
 
   virtual void SetTargetContext(gfx::DrawTarget *aTarget) MOZ_OVERRIDE
   {
     mTarget = aTarget;
   }
 
   virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) MOZ_OVERRIDE {}
--- a/gfx/layers/d3d9/ImageLayerD3D9.cpp
+++ b/gfx/layers/d3d9/ImageLayerD3D9.cpp
@@ -11,17 +11,16 @@
 #include "ThebesLayerD3D9.h"
 #include "gfxPlatform.h"
 #include "gfxImageSurface.h"
 #include "yuv_convert.h"
 #include "nsIServiceManager.h"
 #include "nsIConsoleService.h"
 #include "Nv3DVUtils.h"
 #include "D3D9SurfaceImage.h"
-#include "gfx2DGlue.h"
 
 namespace mozilla {
 namespace layers {
 
 static inline _D3DFORMAT
 D3dFormatForGfxFormat(gfxImageFormat aFormat)
 {
   if (aFormat == gfxImageFormatA8) {
@@ -30,17 +29,17 @@ D3dFormatForGfxFormat(gfxImageFormat aFo
 
   return D3DFMT_A8R8G8B8;
 }
 
 static already_AddRefed<IDirect3DTexture9>
 DataToTexture(IDirect3DDevice9 *aDevice,
               unsigned char *aData,
               int aStride,
-              const gfx::IntSize &aSize,
+              const gfxIntSize &aSize,
               _D3DFORMAT aFormat)
 {
   nsRefPtr<IDirect3DTexture9> texture;
   nsRefPtr<IDirect3DDevice9Ex> deviceEx;
   aDevice->QueryInterface(IID_IDirect3DDevice9Ex,
                           (void**)getter_AddRefs(deviceEx));
 
   nsRefPtr<IDirect3DSurface9> surface;
@@ -126,23 +125,23 @@ OpenSharedTexture(const D3DSURFACE_DESC&
     NS_WARNING("Failed to open shared texture on our device");
   }
   return sharedTexture.forget();
 }
 
 static already_AddRefed<IDirect3DTexture9>
 SurfaceToTexture(IDirect3DDevice9 *aDevice,
                  gfxASurface *aSurface,
-                 const gfx::IntSize &aSize)
+                 const gfxIntSize &aSize)
 {
 
   nsRefPtr<gfxImageSurface> imageSurface = aSurface->GetAsImageSurface();
 
   if (!imageSurface) {
-    imageSurface = new gfxImageSurface(ThebesIntSize(aSize),
+    imageSurface = new gfxImageSurface(aSize,
                                        gfxImageFormatARGB32);
 
     nsRefPtr<gfxContext> context = new gfxContext(imageSurface);
     context->SetSource(aSurface);
     context->SetOperator(gfxContext::OPERATOR_SOURCE);
     context->Paint();
   }
 
@@ -399,17 +398,17 @@ ImageLayerD3D9::RenderLayer()
 
   Image *image = autoLock.GetImage();
   if (!image) {
     return;
   }
 
   SetShaderTransformAndOpacity();
 
-  gfx::IntSize size = image->GetSize();
+  gfxIntSize size = image->GetSize();
 
   if (image->GetFormat() == CAIRO_SURFACE ||
       image->GetFormat() == REMOTE_IMAGE_BITMAP ||
       image->GetFormat() == D3D9_RGB32_TEXTURE)
   {
     NS_ASSERTION(image->GetFormat() != CAIRO_SURFACE ||
                  !static_cast<CairoImage*>(image)->mSurface ||
                  static_cast<CairoImage*>(image)->mSurface->GetContentType() != GFX_CONTENT_ALPHA,
@@ -560,15 +559,15 @@ ImageLayerD3D9::GetAsTexture(gfxIntSize*
   }
 
   if (image->GetFormat() != CAIRO_SURFACE &&
       image->GetFormat() != REMOTE_IMAGE_BITMAP) {
     return nullptr;
   }
 
   bool dontCare;
-  *aSize = gfx::ThebesIntSize(image->GetSize());
+  *aSize = image->GetSize();
   nsRefPtr<IDirect3DTexture9> result = GetTexture(image, dontCare);
   return result.forget();
 }
 
 } /* layers */
 } /* mozilla */
--- a/gfx/layers/d3d9/LayerManagerD3D9.h
+++ b/gfx/layers/d3d9/LayerManagerD3D9.h
@@ -73,22 +73,22 @@ public:
   virtual void EndTransaction(DrawThebesLayerCallback aCallback,
                               void* aCallbackData,
                               EndTransactionFlags aFlags = END_DEFAULT);
 
   const CallbackInfo &GetCallbackInfo() { return mCurrentCallbackInfo; }
 
   void SetRoot(Layer* aLayer);
 
-  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize)
+  virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize)
   {
     if (!mDeviceManager)
       return false;
     int32_t maxSize = mDeviceManager->GetMaxTextureSize();
-    return aSize <= LayerIntSize(maxSize, maxSize);
+    return aSize <= gfxIntSize(maxSize, maxSize);
   }
 
   virtual int32_t GetMaxTextureSize() const
   {
     return mDeviceManager->GetMaxTextureSize();
   }
 
   virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
--- a/gfx/layers/d3d9/TextureD3D9.cpp
+++ b/gfx/layers/d3d9/TextureD3D9.cpp
@@ -6,17 +6,16 @@
 #include "TextureD3D9.h"
 #include "CompositorD3D9.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
 #include "Effects.h"
 #include "ipc/AutoOpenSurface.h"
 #include "mozilla/layers/YCbCrImageDataSerializer.h"
 #include "gfxWindowsPlatform.h"
-#include "gfx2DGlue.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 TemporaryRef<DeprecatedTextureHost>
 CreateDeprecatedTextureHostD3D9(SurfaceDescriptorType aDescriptorType,
@@ -211,26 +210,26 @@ FinishTextures(IDirect3DDevice9* aDevice
     aTexture->UnlockRect(0);
   }
 }
 
 static TemporaryRef<IDirect3DTexture9>
 DataToTexture(IDirect3DDevice9 *aDevice,
               unsigned char *aData,
               int aStride,
-              const LayerIntSize &aSize,
+              const gfxIntSize &aSize,
               _D3DFORMAT aFormat,
               uint32_t aBPP)
 {
   RefPtr<IDirect3DTexture9> texture;
   RefPtr<IDirect3DSurface9> surface;
   D3DLOCKED_RECT lockedRect;
   bool usingD3D9Ex;
 
-  if (!InitTextures(aDevice, ThebesIntSize(aSize.ToUnknownSize()), aFormat,
+  if (!InitTextures(aDevice, aSize, aFormat,
                     texture, surface, lockedRect, usingD3D9Ex)) {
     return nullptr;
   }
 
   uint32_t width = aSize.width * aBPP;
 
   for (int y = 0; y < aSize.height; y++) {
     memcpy((char*)lockedRect.pBits + lockedRect.Pitch * y,
@@ -281,35 +280,34 @@ DeprecatedTextureHostShmemD3D9::UpdateIm
   default:
     NS_ERROR("Bad image format");
   }
 
   int32_t maxSize = mCompositor->GetMaxTextureSize();
   if (size.width <= maxSize && size.height <= maxSize) {
     mTextures[0] = DataToTexture(mDevice,
                                  surf->Data(), surf->Stride(),
-                                 LayerIntSize(size.width, size.height),
-                                 format, bpp);
+                                 size, format, bpp);
     NS_ASSERTION(mTextures[0], "Could not upload texture");
     mIsTiled = false;
   } else {
     mIsTiled = true;
     uint32_t tileCount = GetRequiredTiles(size.width, maxSize) *
                          GetRequiredTiles(size.height, maxSize);
     mTileTextures.resize(tileCount);
 
     for (uint32_t i = 0; i < tileCount; i++) {
       IntRect tileRect = GetTileRect(i);
       unsigned char* data = surf->Data() +
                             tileRect.y * surf->Stride() +
                             tileRect.x * bpp;
       mTileTextures[i] = DataToTexture(mDevice,
                                        data,
                                        surf->Stride(),
-                                       LayerIntSize(tileRect.width, tileRect.height),
+                                       gfxIntSize(tileRect.width, tileRect.height),
                                        format,
                                        bpp);
     }
   }
 }
 
 IntRect
 DeprecatedTextureHostD3D9::GetTileRect(uint32_t aID) const
@@ -344,19 +342,19 @@ void
 DeprecatedTextureHostYCbCrD3D9::UpdateImpl(const SurfaceDescriptor& aImage,
                                  nsIntRegion *aRegion,
                                  nsIntPoint *aOffset)
 {
   MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TYCbCrImage);
 
   YCbCrImageDataDeserializer yuvDeserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
 
-  LayerIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
-  LayerIntSize size = yuvDeserializer.GetYSize();
-  mSize = size.ToUnknownSize();
+  gfxIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
+  gfxIntSize size = yuvDeserializer.GetYSize();
+  mSize = IntSize(size.width, size.height);
   mStereoMode = yuvDeserializer.GetStereoMode();
 
   mTextures[0] = DataToTexture(mDevice,
                                yuvDeserializer.GetYData(),
                                yuvDeserializer.GetYStride(),
                                size,
                                D3DFMT_L8, 1);
   mTextures[1] = DataToTexture(mDevice,
@@ -455,17 +453,17 @@ DeprecatedTextureHostSystemMemD3D9::Upda
       d3dTileRect.top = tileRect.y;
       d3dTileRect.right = tileRect.XMost();
       d3dTileRect.bottom = tileRect.YMost();
       D3DLOCKED_RECT lockedRect;
       texture->LockRect(0, &lockedRect, &d3dTileRect, 0);
       mTileTextures[i] = DataToTexture(mDevice,
                                        reinterpret_cast<unsigned char*>(lockedRect.pBits),
                                        lockedRect.Pitch,
-                                       LayerIntSize(tileRect.width, tileRect.height),
+                                       gfxIntSize(tileRect.width, tileRect.height),
                                        format,
                                        bpp);
       texture->UnlockRect(0);
       if (!mTileTextures[i]) {
         NS_WARNING("Could not upload texture");
         mSize.width = 0;
         mSize.height = 0;
         mIsTiled = false;
@@ -565,17 +563,17 @@ DeprecatedTextureHostDIB::UpdateImpl(con
       IntRect tileRect = GetTileRect(i);
       nsRefPtr<gfxImageSurface> imgSurface = surf->GetAsImageSurface();
       unsigned char* data = imgSurface->Data() +
                             tileRect.y * imgSurface->Stride() +
                             tileRect.x * bpp;
       mTileTextures[i] = DataToTexture(mDevice,
                                        data,
                                        imgSurface->Stride(),
-                                       LayerIntSize(tileRect.width, tileRect.height),
+                                       gfxIntSize(tileRect.width, tileRect.height),
                                        format,
                                        bpp);
     }
   }
 }
 
 DeprecatedTextureClientD3D9::DeprecatedTextureClientD3D9(CompositableForwarder* aCompositableForwarder,
                                      const TextureInfo& aTextureInfo)
--- a/gfx/layers/ipc/ISurfaceAllocator.cpp
+++ b/gfx/layers/ipc/ISurfaceAllocator.cpp
@@ -13,17 +13,16 @@
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
 #include "ShadowLayerUtils.h"
 #include "mozilla/mozalloc.h"           // for operator delete[], etc
 #include "nsAutoPtr.h"                  // for nsRefPtr, getter_AddRefs, etc
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT
 #include "nsXULAppAPI.h"                // for XRE_GetProcessType, etc
-#include "gfx2DGlue.h"
 #ifdef DEBUG
 #include "prenv.h"
 #endif
 
 using namespace mozilla::ipc;
 
 namespace mozilla {
 namespace layers {
@@ -36,43 +35,43 @@ SharedMemory::SharedMemoryType OptimalSh
 bool
 IsSurfaceDescriptorValid(const SurfaceDescriptor& aSurface)
 {
   return aSurface.type() != SurfaceDescriptor::T__None &&
          aSurface.type() != SurfaceDescriptor::Tnull_t;
 }
 
 bool
-ISurfaceAllocator::AllocSharedImageSurface(const gfx::IntSize& aSize,
+ISurfaceAllocator::AllocSharedImageSurface(const gfxIntSize& aSize,
                                gfxContentType aContent,
                                gfxSharedImageSurface** aBuffer)
 {
   SharedMemory::SharedMemoryType shmemType = OptimalShmemType();
   gfxImageFormat format = gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent);
 
   nsRefPtr<gfxSharedImageSurface> back =
-    gfxSharedImageSurface::CreateUnsafe(this, ThebesIntSize(aSize), format, shmemType);
+    gfxSharedImageSurface::CreateUnsafe(this, aSize, format, shmemType);
   if (!back)
     return false;
 
   *aBuffer = nullptr;
   back.swap(*aBuffer);
   return true;
 }
 
 bool
-ISurfaceAllocator::AllocSurfaceDescriptor(const gfx::IntSize& aSize,
+ISurfaceAllocator::AllocSurfaceDescriptor(const gfxIntSize& aSize,
                                           gfxContentType aContent,
                                           SurfaceDescriptor* aBuffer)
 {
   return AllocSurfaceDescriptorWithCaps(aSize, aContent, DEFAULT_BUFFER_CAPS, aBuffer);
 }
 
 bool
-ISurfaceAllocator::AllocSurfaceDescriptorWithCaps(const gfx::IntSize& aSize,
+ISurfaceAllocator::AllocSurfaceDescriptorWithCaps(const gfxIntSize& aSize,
                                                   gfxContentType aContent,
                                                   uint32_t aCaps,
                                                   SurfaceDescriptor* aBuffer)
 {
   bool tryPlatformSurface = true;
 #ifdef DEBUG
   tryPlatformSurface = !PR_GetEnv("MOZ_LAYERS_FORCE_SHMEM_SURFACES");
 #endif
@@ -91,17 +90,17 @@ ISurfaceAllocator::AllocSurfaceDescripto
     }
 #ifdef XP_MACOSX
     // Workaround a bug in Quartz where drawing an a8 surface to another a8
     // surface with OPERATOR_SOURCE still requires the destination to be clear.
     if (format == gfxImageFormatA8) {
       memset(data, 0, stride * aSize.height);
     }
 #endif
-    *aBuffer = MemoryImage((uintptr_t)data, ThebesIntSize(aSize), stride, format);
+    *aBuffer = MemoryImage((uintptr_t)data, aSize, stride, format);
     return true;
   }
 
   nsRefPtr<gfxSharedImageSurface> buffer;
   if (!AllocSharedImageSurface(aSize, aContent,
                                getter_AddRefs(buffer))) {
     return false;
   }
@@ -144,17 +143,17 @@ ISurfaceAllocator::DestroySharedSurface(
     default:
       NS_RUNTIMEABORT("surface type not implemented!");
   }
   *aSurface = SurfaceDescriptor();
 }
 
 #if !defined(MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS)
 bool
-ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfx::IntSize&,
+ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfxIntSize&,
                                                   gfxContentType,
                                                   uint32_t,
                                                   SurfaceDescriptor*)
 {
   return false;
 }
 #endif
 
--- a/gfx/layers/ipc/ISurfaceAllocator.h
+++ b/gfx/layers/ipc/ISurfaceAllocator.h
@@ -4,19 +4,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_LAYERS_ISURFACEDEALLOCATOR
 #define GFX_LAYERS_ISURFACEDEALLOCATOR
 
 #include <stddef.h>                     // for size_t
 #include <stdint.h>                     // for uint32_t
 #include "gfxTypes.h"
+#include "gfxPoint.h"                   // for gfxIntSize
 #include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
 #include "mozilla/WeakPtr.h"
-#include "mozilla/gfx/Point.h"
 
 /*
  * FIXME [bjacob] *** PURE CRAZYNESS WARNING ***
  *
  * This #define is actually needed here, because subclasses of ISurfaceAllocator,
  * namely ShadowLayerForwarder, will or will not override AllocGrallocBuffer
  * depending on whether MOZ_HAVE_SURFACEDESCRIPTORGRALLOC is defined.
  */
@@ -91,45 +91,45 @@ ISurfaceAllocator() {}
                                 ipc::SharedMemory::SharedMemoryType aType,
                                 ipc::Shmem* aShmem) = 0;
   /**
    * Deallocate memory allocated by either AllocShmem or AllocUnsafeShmem.
    */
   virtual void DeallocShmem(ipc::Shmem& aShmem) = 0;
 
   // was AllocBuffer
-  virtual bool AllocSharedImageSurface(const gfx::IntSize& aSize,
+  virtual bool AllocSharedImageSurface(const gfxIntSize& aSize,
                                        gfxContentType aContent,
                                        gfxSharedImageSurface** aBuffer);
-  virtual bool AllocSurfaceDescriptor(const gfx::IntSize& aSize,
+  virtual bool AllocSurfaceDescriptor(const gfxIntSize& aSize,
                                       gfxContentType aContent,
                                       SurfaceDescriptor* aBuffer);
 
   // was AllocBufferWithCaps
-  virtual bool AllocSurfaceDescriptorWithCaps(const gfx::IntSize& aSize,
+  virtual bool AllocSurfaceDescriptorWithCaps(const gfxIntSize& aSize,
                                               gfxContentType aContent,
                                               uint32_t aCaps,
                                               SurfaceDescriptor* aBuffer);
 
   virtual void DestroySharedSurface(SurfaceDescriptor* aSurface);
 
   // method that does the actual allocation work
-  virtual PGrallocBufferChild* AllocGrallocBuffer(const gfx::IntSize& aSize,
+  virtual PGrallocBufferChild* AllocGrallocBuffer(const gfxIntSize& aSize,
                                                   uint32_t aFormat,
                                                   uint32_t aUsage,
                                                   MaybeMagicGrallocBufferHandle* aHandle)
   {
     return nullptr;
   }
 protected:
   // this method is needed for a temporary fix, will be removed after
   // DeprecatedTextureClient/Host rework.
   virtual bool IsOnCompositorSide() const = 0;
   static bool PlatformDestroySharedSurface(SurfaceDescriptor* aSurface);
-  virtual bool PlatformAllocSurfaceDescriptor(const gfx::IntSize& aSize,
+  virtual bool PlatformAllocSurfaceDescriptor(const gfxIntSize& aSize,
                                               gfxContentType aContent,
                                               uint32_t aCaps,
                                               SurfaceDescriptor* aBuffer);
 
 
   ~ISurfaceAllocator() {}
 };
 
--- a/gfx/layers/ipc/ImageBridgeChild.cpp
+++ b/gfx/layers/ipc/ImageBridgeChild.cpp
@@ -688,17 +688,17 @@ ImageBridgeChild::CreateImageClientNow(C
   MOZ_ASSERT(client, "failed to create ImageClient");
   if (client) {
     client->Connect();
   }
   return client.forget();
 }
 
 PGrallocBufferChild*
-ImageBridgeChild::AllocPGrallocBufferChild(const gfx::IntSize&, const uint32_t&, const uint32_t&,
+ImageBridgeChild::AllocPGrallocBufferChild(const gfxIntSize&, const uint32_t&, const uint32_t&,
                                            MaybeMagicGrallocBufferHandle*)
 {
 #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
   return GrallocBufferActor::Create();
 #else
   NS_RUNTIMEABORT("No gralloc buffers for you");
   return nullptr;
 #endif
@@ -919,17 +919,17 @@ ImageBridgeChild::DeallocShmem(ipc::Shme
                                                    &done));
     while (!done) {
       barrier.Wait();
     }
   }
 }
 
 PGrallocBufferChild*
-ImageBridgeChild::AllocGrallocBuffer(const gfx::IntSize& aSize,
+ImageBridgeChild::AllocGrallocBuffer(const gfxIntSize& aSize,
                                      uint32_t aFormat,
                                      uint32_t aUsage,
                                      MaybeMagicGrallocBufferHandle* aHandle)
 {
 #ifdef MOZ_WIDGET_GONK
   return SendPGrallocBufferConstructor(aSize,
                                        aFormat,
                                        aUsage,
--- a/gfx/layers/ipc/ImageBridgeChild.h
+++ b/gfx/layers/ipc/ImageBridgeChild.h
@@ -184,17 +184,17 @@ public:
 
   /**
    * This must be called by the static function DeleteImageBridgeSync defined
    * in ImageBridgeChild.cpp ONLY.
    */
   ~ImageBridgeChild();
 
   virtual PGrallocBufferChild*
-  AllocPGrallocBufferChild(const gfx::IntSize&, const uint32_t&, const uint32_t&,
+  AllocPGrallocBufferChild(const gfxIntSize&, const uint32_t&, const uint32_t&,
                            MaybeMagicGrallocBufferHandle*) MOZ_OVERRIDE;
 
   virtual bool
   DeallocPGrallocBufferChild(PGrallocBufferChild* actor) MOZ_OVERRIDE;
 
   /**
    * Allocate a gralloc SurfaceDescriptor remotely.
    */
@@ -383,17 +383,17 @@ protected:
   bool DispatchAllocShmemInternal(size_t aSize,
                                   SharedMemory::SharedMemoryType aType,
                                   Shmem* aShmem,
                                   bool aUnsafe);
 
   CompositableTransaction* mTxn;
 
   // ISurfaceAllocator
-  virtual PGrallocBufferChild* AllocGrallocBuffer(const gfx::IntSize& aSize,
+  virtual PGrallocBufferChild* AllocGrallocBuffer(const gfxIntSize& aSize,
                                                   uint32_t aFormat, uint32_t aUsage,
                                                   MaybeMagicGrallocBufferHandle* aHandle) MOZ_OVERRIDE;
 };
 
 } // layers
 } // mozilla
 
 #endif
--- a/gfx/layers/ipc/ImageBridgeParent.cpp
+++ b/gfx/layers/ipc/ImageBridgeParent.cpp
@@ -25,17 +25,16 @@
 #include "mozilla/layers/Compositor.h"
 #include "mozilla/mozalloc.h"           // for operator new, etc
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT, etc
 #include "nsISupportsImpl.h"            // for ImageBridgeParent::Release, etc
 #include "nsTArray.h"                   // for nsTArray, nsTArray_Impl
 #include "nsTArrayForwardDeclare.h"     // for InfallibleTArray
 #include "nsXULAppAPI.h"                // for XRE_GetIOMessageLoop
-#include "gfx2DGlue.h"
 
 using namespace base;
 using namespace mozilla::ipc;
 
 namespace mozilla {
 namespace layers {
 
 class PGrallocBufferParent;
@@ -134,23 +133,23 @@ bool ImageBridgeParent::RecvStop()
 static  uint64_t GenImageContainerID() {
   static uint64_t sNextImageID = 1;
 
   ++sNextImageID;
   return sNextImageID;
 }
 
 PGrallocBufferParent*
-ImageBridgeParent::AllocPGrallocBufferParent(const gfx::IntSize& aSize,
+ImageBridgeParent::AllocPGrallocBufferParent(const gfxIntSize& aSize,
                                              const uint32_t& aFormat,
                                              const uint32_t& aUsage,
                                              MaybeMagicGrallocBufferHandle* aOutHandle)
 {
 #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  return GrallocBufferActor::Create(ThebesIntSize(aSize), aFormat, aUsage, aOutHandle);
+  return GrallocBufferActor::Create(aSize, aFormat, aUsage, aOutHandle);
 #else
   NS_RUNTIMEABORT("No gralloc buffers for you");
   return nullptr;
 #endif
 }
 
 bool
 ImageBridgeParent::DeallocPGrallocBufferParent(PGrallocBufferParent* actor)
--- a/gfx/layers/ipc/ImageBridgeParent.h
+++ b/gfx/layers/ipc/ImageBridgeParent.h
@@ -43,17 +43,17 @@ public:
   ~ImageBridgeParent();
 
   virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
 
   static PImageBridgeParent*
   Create(Transport* aTransport, ProcessId aOtherProcess);
 
   virtual PGrallocBufferParent*
-  AllocPGrallocBufferParent(const gfx::IntSize&, const uint32_t&, const uint32_t&,
+  AllocPGrallocBufferParent(const gfxIntSize&, const uint32_t&, const uint32_t&,
                             MaybeMagicGrallocBufferHandle*) MOZ_OVERRIDE;
 
   virtual bool
   DeallocPGrallocBufferParent(PGrallocBufferParent* actor) MOZ_OVERRIDE;
 
   // PImageBridge
   virtual bool RecvUpdate(const EditArray& aEdits, EditReplyArray* aReply);
   virtual bool RecvUpdateNoSwap(const EditArray& aEdits);
--- a/gfx/layers/ipc/LayerTransactionChild.cpp
+++ b/gfx/layers/ipc/LayerTransactionChild.cpp
@@ -24,17 +24,17 @@ LayerTransactionChild::Destroy()
 {
   NS_ABORT_IF_FALSE(0 == ManagedPLayerChild().Length(),
                     "layers should have been cleaned up by now");
   PLayerTransactionChild::Send__delete__(this);
   // WARNING: |this| has gone to the great heap in the sky
 }
 
 PGrallocBufferChild*
-LayerTransactionChild::AllocPGrallocBufferChild(const gfx::IntSize&,
+LayerTransactionChild::AllocPGrallocBufferChild(const gfxIntSize&,
                                            const uint32_t&,
                                            const uint32_t&,
                                            MaybeMagicGrallocBufferHandle*)
 {
 #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
   return GrallocBufferActor::Create();
 #else
   NS_RUNTIMEABORT("No gralloc buffers for you");
--- a/gfx/layers/ipc/LayerTransactionChild.h
+++ b/gfx/layers/ipc/LayerTransactionChild.h
@@ -29,17 +29,17 @@ public:
    * It is expected (checked with an assert) that all shadow layers
    * created by this have already been destroyed and
    * Send__delete__()d by the time this method is called.
    */
   void Destroy();
 
 protected:
   virtual PGrallocBufferChild*
-  AllocPGrallocBufferChild(const gfx::IntSize&,
+  AllocPGrallocBufferChild(const gfxIntSize&,
                       const uint32_t&, const uint32_t&,
                       MaybeMagicGrallocBufferHandle*) MOZ_OVERRIDE;
   virtual bool
   DeallocPGrallocBufferChild(PGrallocBufferChild* actor) MOZ_OVERRIDE;
 
   virtual PLayerChild* AllocPLayerChild() MOZ_OVERRIDE;
   virtual bool DeallocPLayerChild(PLayerChild* actor) MOZ_OVERRIDE;
 
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -34,17 +34,16 @@
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT
 #include "nsISupportsImpl.h"            // for Layer::Release, etc
 #include "nsLayoutUtils.h"              // for nsLayoutUtils
 #include "nsMathUtils.h"                // for NS_round
 #include "nsPoint.h"                    // for nsPoint
 #include "nsTArray.h"                   // for nsTArray, nsTArray_Impl, etc
 #include "nsTraceRefcnt.h"              // for MOZ_COUNT_CTOR, etc
 #include "GeckoProfiler.h"
-#include "gfx2DGlue.h"
 
 typedef std::vector<mozilla::layers::EditReply> EditReplyVector;
 
 using mozilla::layout::RenderFrameParent;
 
 namespace mozilla {
 namespace layers {
 
@@ -539,23 +538,23 @@ LayerTransactionParent::RecvClearCachedR
     // context, it's just a subtree root.  We need to scope the clear
     // of resources to exactly that subtree, so we specify it here.
     mLayerManager->ClearCachedResources(mRoot);
   }
   return true;
 }
 
 PGrallocBufferParent*
-LayerTransactionParent::AllocPGrallocBufferParent(const gfx::IntSize& aSize,
+LayerTransactionParent::AllocPGrallocBufferParent(const gfxIntSize& aSize,
                                             const uint32_t& aFormat,
                                             const uint32_t& aUsage,
                                             MaybeMagicGrallocBufferHandle* aOutHandle)
 {
 #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  return GrallocBufferActor::Create(ThebesIntSize(aSize), aFormat, aUsage, aOutHandle);
+  return GrallocBufferActor::Create(aSize, aFormat, aUsage, aOutHandle);
 #else
   NS_RUNTIMEABORT("No gralloc buffers for you");
   return nullptr;
 #endif
 }
 
 bool
 LayerTransactionParent::DeallocPGrallocBufferParent(PGrallocBufferParent* actor)
--- a/gfx/layers/ipc/LayerTransactionParent.h
+++ b/gfx/layers/ipc/LayerTransactionParent.h
@@ -89,17 +89,17 @@ protected:
 
   virtual bool RecvClearCachedResources() MOZ_OVERRIDE;
   virtual bool RecvGetOpacity(PLayerParent* aParent,
                               float* aOpacity) MOZ_OVERRIDE;
   virtual bool RecvGetTransform(PLayerParent* aParent,
                                 gfx3DMatrix* aTransform) MOZ_OVERRIDE;
 
   virtual PGrallocBufferParent*
-  AllocPGrallocBufferParent(const gfx::IntSize& aSize,
+  AllocPGrallocBufferParent(const gfxIntSize& aSize,
                       const uint32_t& aFormat, const uint32_t& aUsage,
                       MaybeMagicGrallocBufferHandle* aOutHandle) MOZ_OVERRIDE;
   virtual bool
   DeallocPGrallocBufferParent(PGrallocBufferParent* actor) MOZ_OVERRIDE;
 
   virtual PLayerParent* AllocPLayerParent() MOZ_OVERRIDE;
   virtual bool DeallocPLayerParent(PLayerParent* actor) MOZ_OVERRIDE;
 
--- a/gfx/layers/ipc/LayersMessages.ipdlh
+++ b/gfx/layers/ipc/LayersMessages.ipdlh
@@ -31,17 +31,16 @@ using mozilla::ScreenRotation;
 using nsCSSProperty;
 using mozilla::dom::ScreenOrientation;
 using mozilla::layers::TextureInfo;
 using mozilla::LayerMargin;
 using mozilla::LayerPoint;
 using mozilla::LayerRect;
 using mozilla::layers::ScaleMode;
 using mozilla::layers::DiagnosticTypes;
-using mozilla::gfx::IntSize;
 
 namespace mozilla {
 namespace layers {
 
 struct TargetConfig {
   nsIntRect naturalBounds;
   ScreenRotation rotation;
   nsIntRect clientBounds;
@@ -211,17 +210,17 @@ struct ContainerLayerAttributes {
   float preXScale;
   float preYScale;
   float inheritedXScale;
   float inheritedYScale;
 };
 struct ColorLayerAttributes     { LayerColor color; nsIntRect bounds; };
 struct CanvasLayerAttributes    { GraphicsFilterType filter; nsIntRect bounds; };
 struct RefLayerAttributes       { int64_t id; };
-struct ImageLayerAttributes     { GraphicsFilterType filter; IntSize scaleToSize; ScaleMode scaleMode; };
+struct ImageLayerAttributes     { GraphicsFilterType filter; gfxIntSize scaleToSize; ScaleMode scaleMode; };
 
 union SpecificLayerAttributes {
   null_t;
   ThebesLayerAttributes;
   ContainerLayerAttributes;
   ColorLayerAttributes;
   CanvasLayerAttributes;
   RefLayerAttributes;
--- a/gfx/layers/ipc/LayersSurfaces.ipdlh
+++ b/gfx/layers/ipc/LayersSurfaces.ipdlh
@@ -49,17 +49,17 @@ struct SurfaceDescriptorDIB {
 struct SurfaceDescriptorD3D10 {
   WindowsHandle handle;
   bool hasAlpha;
 };
 
 struct SharedTextureDescriptor {
   SharedTextureShareType shareType;
   SharedTextureHandle handle;
-  IntSize size;
+  nsIntSize size;
   bool inverted;
 };
 
 struct BasicShmTileDescriptor {
   Shmem reusableSurface;
 };
 
 struct BasicTileDescriptor {
--- a/gfx/layers/ipc/PImageBridge.ipdl
+++ b/gfx/layers/ipc/PImageBridge.ipdl
@@ -9,17 +9,16 @@ include protocol PGrallocBuffer;
 include protocol PCompositable;
 include ProtocolTypes;
 
 include "mozilla/layers/CompositorTypes.h";
 include "mozilla/GfxMessageUtils.h";
 
 using ImageHandle;
 using mozilla::layers::TextureInfo;
-using mozilla::gfx::IntSize;
 
 namespace mozilla {
 namespace layers {
 
 /**
  * The PImageBridge protocol is used to allow isolated threads or processes to push
  * frames directly to the compositor thread/process without relying on the main thread
  * which might be too busy dealing with content script.
@@ -34,17 +33,17 @@ parent:
   sync Update(CompositableOperation[] ops) returns (EditReply[] reply);
   async UpdateNoSwap(CompositableOperation[] ops);
 
   // Allocates a gralloc buffer that may not suitable to use with
   // gfxImageSurface but allows hardware decoder to write to the
   // buffer directly. The format is a enum defined in
   // system/graphics.h and the usage is the GraphicBuffer usage
   // flag. See GraphicBuffer.h and gralloc.h.
-  sync PGrallocBuffer(IntSize size, uint32_t format, uint32_t usage)
+  sync PGrallocBuffer(gfxIntSize size, uint32_t format, uint32_t usage)
     returns (MaybeMagicGrallocBufferHandle handle);
 
   // First step of the destruction sequence. This puts all the ImageContainerParents
   // in a state in which they can't send asynchronous messages to their child
   // counterpart so as to not race with the upcomming __delete__ message.
   // In the child side, the __delete__ messages are not sent right after Stop,
   // they are scheduled in the ImageBridgeChild's message queue in order to ensure
   // that all the messages from the parent side have been received and processed
--- a/gfx/layers/ipc/PLayerTransaction.ipdl
+++ b/gfx/layers/ipc/PLayerTransaction.ipdl
@@ -15,17 +15,16 @@ include protocol PRenderFrame;
 
 include "mozilla/WidgetUtils.h";
 include "mozilla/dom/ScreenOrientation.h";
 include "nsCSSProperty.h";
 include "gfxipc/ShadowLayerUtils.h";
 include "mozilla/GfxMessageUtils.h";
 
 using mozilla::layers::TextureInfo;
-using mozilla::gfx::IntSize;
 
 /**
  * The layers protocol is spoken between thread contexts that manage
  * layer (sub)trees.  The protocol comprises atomically publishing
  * layer subtrees to a "shadow" thread context (which grafts the
  * subtree into its own tree), and atomically updating a published
  * subtree.  ("Atomic" in this sense is wrt painting.)
  */
@@ -62,17 +61,17 @@ parent:
    * commonly used USAGE flags are:
    *   USAGE_SW_READ_OFTEN | USAGE_SW_WRITE_OFTEN | USAGE_HW_TEXTURE
    *     - used for software rendering to a buffer which the compositor
    *       treats as a texture
    *   USAGE_HW_RENDER | USAGE_HW_TEXTURE
    *     - used for GL rendering to a buffer which the compositor
    *       treats as a texture
    */
-  sync PGrallocBuffer(IntSize size, uint32_t format, uint32_t usage)
+  sync PGrallocBuffer(gfxIntSize size, uint32_t format, uint32_t usage)
     returns (MaybeMagicGrallocBufferHandle handle);
   async PLayer();
   async PCompositable(TextureInfo aTextureInfo);
 
   // The isFirstPaint flag can be used to indicate that this is the first update
   // for a particular document.
   sync Update(Edit[] cset, TargetConfig targetConfig, bool isFirstPaint)
     returns (EditReply[] reply);
--- a/gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp
@@ -15,17 +15,17 @@
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
 // Platform-specific shadow-layers interfaces.  See ShadowLayers.h.
 // D3D10 doesn't need all these yet.
 bool
-ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfx::IntSize&,
+ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfxIntSize&,
                                                   gfxContentType,
                                                   uint32_t,
                                                   SurfaceDescriptor*)
 {
   return false;
 }
 
 /*static*/ already_AddRefed<gfxASurface>
--- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
@@ -24,17 +24,16 @@
 #include "gfxPlatform.h"
 #include "GLContext.h"
 
 #include "GeckoProfiler.h"
 
 #include "cutils/properties.h"
 
 #include "MainThreadUtils.h"
-#include "gfx2DGlue.h"
 
 using namespace android;
 using namespace base;
 using namespace mozilla::layers;
 using namespace mozilla::gl;
 
 namespace IPC {
 
@@ -354,26 +353,26 @@ GrallocBufferActor::InitFromHandle(const
 {
   MOZ_ASSERT(!mGraphicBuffer.get());
   MOZ_ASSERT(aHandle.mGraphicBuffer.get());
 
   mGraphicBuffer = aHandle.mGraphicBuffer;
 }
 
 PGrallocBufferChild*
-ShadowLayerForwarder::AllocGrallocBuffer(const gfx::IntSize& aSize,
+ShadowLayerForwarder::AllocGrallocBuffer(const gfxIntSize& aSize,
                                          uint32_t aFormat,
                                          uint32_t aUsage,
                                          MaybeMagicGrallocBufferHandle* aHandle)
 {
   return mShadowManager->SendPGrallocBufferConstructor(aSize, aFormat, aUsage, aHandle);
 }
 
 bool
-ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfx::IntSize& aSize,
+ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfxIntSize& aSize,
                                                   gfxContentType aContent,
                                                   uint32_t aCaps,
                                                   SurfaceDescriptor* aBuffer)
 {
 
   // Check for devices that have problems with gralloc. We only check for
   // this on ICS or earlier, in hopes that JB will work.
 #if ANDROID_VERSION <= 15
@@ -443,17 +442,17 @@ ISurfaceAllocator::PlatformAllocSurfaceD
     NS_ERROR("GrallocBufferConstructor failed by returning handle with type Tnull_t");
     PGrallocBufferChild::Send__delete__(gc);
     return false;
   }
 
   GrallocBufferActor* gba = static_cast<GrallocBufferActor*>(gc);
   gba->InitFromHandle(handle.get_MagicGrallocBufferHandle());
 
-  *aBuffer = SurfaceDescriptorGralloc(nullptr, gc, ThebesIntSize(aSize),
+  *aBuffer = SurfaceDescriptorGralloc(nullptr, gc, aSize,
                                       /* external */ false,
                                       defaultRBSwap);
   return true;
 }
 
 //-----------------------------------------------------------------------------
 // Both processes
 
--- a/gfx/layers/ipc/ShadowLayerUtilsMac.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsMac.cpp
@@ -15,17 +15,17 @@
 #include "gfxSharedQuartzSurface.h"
 
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
 bool
-ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfx::IntSize& aSize,
+ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfxIntSize& aSize,
                                                   gfxContentType aContent,
                                                   uint32_t aCaps,
                                                   SurfaceDescriptor* aBuffer)
 {
   return false;
 }
 
 /*static*/ already_AddRefed<gfxASurface>
--- a/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
@@ -24,17 +24,16 @@
 #include "mozilla/layers/LayerManagerComposite.h"
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
 #include "mozilla/layers/ShadowLayers.h"  // for ShadowLayerForwarder, etc
 #include "mozilla/mozalloc.h"           // for operator new
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_ERROR
 #include "prenv.h"                      // for PR_GetEnv
-#include "gfx2DGlue.h"
 
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace gl {
 class GLContext;
 class TextureImage;
 }
@@ -111,17 +110,17 @@ SurfaceDescriptorX11::OpenForeign() cons
       return nullptr;
 
     surf = new gfxXlibSurface(display, mId, visual, mSize);
   }
   return surf->CairoStatus() ? nullptr : surf.forget();
 }
 
 bool
-ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfx::IntSize& aSize,
+ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfxIntSize& aSize,
                                                   gfxContentType aContent,
                                                   uint32_t aCaps,
                                                   SurfaceDescriptor* aBuffer)
 {
   if (!UsingXCompositing()) {
     // If we're not using X compositing, we're probably compositing on
     // the client side, in which case X surfaces would just slow
     // things down.  Use Shmem instead.
@@ -129,18 +128,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(ThebesIntSize(aSize),
-                                                                  aContent);
+  nsRefPtr<gfxASurface> buffer = platform->CreateOffscreenSurface(aSize, aContent);
   if (!buffer ||
       buffer->GetType() != gfxSurfaceTypeXlib) {
     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/layers/ipc/ShadowLayers.h
+++ b/gfx/layers/ipc/ShadowLayers.h
@@ -418,17 +418,17 @@ protected:
 #else
   void CheckSurfaceDescriptor(const SurfaceDescriptor* aDescriptor) const {}
 #endif
 
   PLayerTransactionChild* mShadowManager;
 
 #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
   // from ISurfaceAllocator
-  virtual PGrallocBufferChild* AllocGrallocBuffer(const gfx::IntSize& aSize,
+  virtual PGrallocBufferChild* AllocGrallocBuffer(const gfxIntSize& aSize,
                                                   uint32_t aFormat,
                                                   uint32_t aUsage,
                                                   MaybeMagicGrallocBufferHandle* aHandle) MOZ_OVERRIDE;
 #endif
 
 private:
   /**
    * Try to query the content type efficiently, but at worst map the
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
@@ -98,17 +98,17 @@ SharedPlanarYCbCrImage::SetData(const Pl
     return;
   }
 
   // do not set mBuffer like in PlanarYCbCrImage because the later
   // will try to manage this memory without knowing it belongs to a
   // shmem.
   mBufferSize = YCbCrImageDataSerializer::ComputeMinBufferSize(mData.mYSize,
                                                                mData.mCbCrSize);
-  mSize = mData.mPicSize.ToUnknownSize();
+  mSize = mData.mPicSize;
 
   YCbCrImageDataSerializer serializer(mTextureClient->GetBuffer());
   mData.mYChannel = serializer.GetYData();
   mData.mCbChannel = serializer.GetCbData();
   mData.mCrChannel = serializer.GetCrData();
   mTextureClient->MarkImmutable();
 }
 
@@ -129,17 +129,17 @@ SharedPlanarYCbCrImage::AllocateAndGetNe
 
   return serializer.GetData();
 }
 
 void
 SharedPlanarYCbCrImage::SetDataNoCopy(const Data &aData)
 {
   mData = aData;
-  mSize = aData.mPicSize.ToUnknownSize();
+  mSize = aData.mPicSize;
   YCbCrImageDataSerializer serializer(mTextureClient->GetBuffer());
   serializer.InitializeBufferInfo(aData.mYSize,
                                   aData.mCbCrSize,
                                   aData.mStereoMode);
 }
 
 uint8_t*
 SharedPlanarYCbCrImage::AllocateBuffer(uint32_t aSize)
@@ -214,17 +214,17 @@ DeprecatedSharedPlanarYCbCrImage::SetDat
     }
   }
 
   // do not set mBuffer like in PlanarYCbCrImage because the later
   // will try to manage this memory without knowing it belongs to a
   // shmem.
   mBufferSize = YCbCrImageDataSerializer::ComputeMinBufferSize(mData.mYSize,
                                                                mData.mCbCrSize);
-  mSize = mData.mPicSize.ToUnknownSize();
+  mSize = mData.mPicSize;
 
   YCbCrImageDataSerializer serializer(mShmem.get<uint8_t>());
   MOZ_ASSERT(aData.mCbSkip == aData.mCrSkip);
   if (!serializer.CopyData(aData.mYChannel, aData.mCbChannel, aData.mCrChannel,
                           aData.mYSize, aData.mYStride,
                           aData.mCbCrSize, aData.mCbCrStride,
                           aData.mYSkip, aData.mCbSkip)) {
     NS_WARNING("Failed to copy image data!");
@@ -251,17 +251,17 @@ DeprecatedSharedPlanarYCbCrImage::Alloca
   return serializer.GetData();
 }
 
 
 void
 DeprecatedSharedPlanarYCbCrImage::SetDataNoCopy(const Data &aData)
 {
   mData = aData;
-  mSize = aData.mPicSize.ToUnknownSize();
+  mSize = aData.mPicSize;
   YCbCrImageDataSerializer serializer(mShmem.get<uint8_t>());
   serializer.InitializeBufferInfo(aData.mYSize,
                                   aData.mCbCrSize,
                                   aData.mStereoMode);
 }
 
 uint8_t* 
 DeprecatedSharedPlanarYCbCrImage::AllocateBuffer(uint32_t aSize)
--- a/gfx/layers/ipc/SharedRGBImage.cpp
+++ b/gfx/layers/ipc/SharedRGBImage.cpp
@@ -95,17 +95,17 @@ DeprecatedSharedRGBImage::GetBuffer()
 }
 
 size_t
 DeprecatedSharedRGBImage::GetBufferSize()
 {
   return mSize.width * mSize.height * gfxASurface::BytesPerPixel(mImageFormat);
 }
 
-  gfx::IntSize
+gfxIntSize
 DeprecatedSharedRGBImage::GetSize()
 {
   return mSize;
 }
 
 bool
 DeprecatedSharedRGBImage::AllocateBuffer(nsIntSize aSize, gfxImageFormat aImageFormat)
 {
@@ -202,20 +202,20 @@ SharedRGBImage::Allocate(gfx::IntSize aS
 
 uint8_t*
 SharedRGBImage::GetBuffer()
 {
   return mTextureClient ? mTextureClient->GetBuffer()
                         : nullptr;
 }
 
-gfx::IntSize
+gfxIntSize
 SharedRGBImage::GetSize()
 {
-  return mSize;
+  return ThebesIntSize(mSize);
 }
 
 size_t
 SharedRGBImage::GetBufferSize()
 {
   return mTextureClient ? mTextureClient->GetBufferSize()
                         : 0;
 }
--- a/gfx/layers/ipc/SharedRGBImage.h
+++ b/gfx/layers/ipc/SharedRGBImage.h
@@ -52,17 +52,17 @@ public:
 
   DeprecatedSharedRGBImage(ISurfaceAllocator *aAllocator);
   ~DeprecatedSharedRGBImage();
 
   virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
 
   virtual uint8_t *GetBuffer() MOZ_OVERRIDE;
 
-  gfx::IntSize GetSize();
+  gfxIntSize GetSize();
   size_t GetBufferSize();
 
   static uint8_t BytesPerPixel(gfxImageFormat aImageFormat);
   already_AddRefed<gfxASurface> GetAsSurface();
 
   /**
    * Setup the Surface descriptor to contain this image's shmem, while keeping
    * ownership of the shmem.
@@ -84,17 +84,17 @@ public:
    */
   static DeprecatedSharedRGBImage* FromSurfaceDescriptor(const SurfaceDescriptor& aDescriptor);
 
   bool AllocateBuffer(nsIntSize aSize, gfxImageFormat aImageFormat);
 
   TextureClient* GetTextureClient() MOZ_OVERRIDE { return nullptr; }
 
 protected:
-  gfx::IntSize mSize;
+  gfxIntSize mSize;
   gfxImageFormat mImageFormat;
   ISurfaceAllocator* mSurfaceAllocator;
 
   bool mAllocated;
   ipc::Shmem *mShmem;
 };
 
 /**
@@ -109,17 +109,17 @@ public:
   ~SharedRGBImage();
 
   virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
 
   virtual TextureClient* GetTextureClient() MOZ_OVERRIDE;
 
   virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
 
-  gfx::IntSize GetSize();
+  gfxIntSize GetSize();
 
   size_t GetBufferSize();
 
   already_AddRefed<gfxASurface> GetAsSurface();
 
   bool Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
 private:
   gfx::IntSize mSize;
--- a/gfx/layers/opengl/CanvasLayerOGL.cpp
+++ b/gfx/layers/opengl/CanvasLayerOGL.cpp
@@ -16,17 +16,16 @@
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/gfx/Types.h"          // for SurfaceFormat, etc
 #include "nsDebug.h"                    // for NS_ABORT_IF_FALSE, etc
 #include "nsPoint.h"                    // for nsIntPoint
 #include "nsRect.h"                     // for nsIntRect
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nsSize.h"                     // for nsIntSize
 #include "LayerManagerOGL.h"            // for LayerOGL::GLContext, etc
-#include "gfx2DGlue.h"
 
 #ifdef XP_MACOSX
 #include "mozilla/gfx/MacIOSurface.h"
 #include "SharedSurfaceIO.h"
 #endif
 
 #ifdef XP_WIN
 #include "gfxWindowsSurface.h"
@@ -380,24 +379,23 @@ CanvasLayerOGL::CleanupResources()
   if (mUploadTexture) {
     gl()->MakeCurrent();
     gl()->fDeleteTextures(1, &mUploadTexture);
     mUploadTexture = 0;
   }
 }
 
 gfxImageSurface*
-CanvasLayerOGL::GetTempSurface(const LayerIntSize& aSize,
+CanvasLayerOGL::GetTempSurface(const gfxIntSize& aSize,
                                const gfxImageFormat aFormat)
 {
   if (!mCachedTempSurface ||
       aSize.width != mCachedSize.width ||
       aSize.height != mCachedSize.height ||
       aFormat != mCachedFormat)
   {
-    mCachedTempSurface = new gfxImageSurface(ThebesIntSize(aSize.ToUnknownSize()),
-                                             aFormat);
+    mCachedTempSurface = new gfxImageSurface(aSize, aFormat);
     mCachedSize = aSize;
     mCachedFormat = aFormat;
   }
 
   return mCachedTempSurface;
 }
--- a/gfx/layers/opengl/CanvasLayerOGL.h
+++ b/gfx/layers/opengl/CanvasLayerOGL.h
@@ -6,16 +6,17 @@
 #ifndef GFX_CANVASLAYEROGL_H
 #define GFX_CANVASLAYEROGL_H
 
 #include "GLContextTypes.h"             // for GLContext
 #include "GLDefs.h"                     // for GLuint, LOCAL_GL_TEXTURE_2D
 #include "LayerManagerOGL.h"            // for LayerOGL::GLContext, etc
 #include "Layers.h"                     // for CanvasLayer, etc
 #include "gfxTypes.h"
+#include "gfxPoint.h"                   // for gfxIntSize
 #include "mozilla/Preferences.h"        // for Preferences
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "mozilla/gfx/2D.h"             // for DrawTarget
 #include "mozilla/mozalloc.h"           // for operator delete, etc
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "opengl/LayerManagerOGLProgram.h"  // for ShaderProgramType, etc
 #if defined(GL_PROVIDER_GLX)
 #include "GLXLibrary.h"
@@ -63,20 +64,20 @@ protected:
   bool mNeedsYFlip;
   bool mForceReadback;
   GLuint mUploadTexture;
 #if defined(GL_PROVIDER_GLX)
   GLXPixmap mPixmap;
 #endif
 
   nsRefPtr<gfxImageSurface> mCachedTempSurface;
-  LayerIntSize mCachedSize;
+  gfxIntSize mCachedSize;
   gfxImageFormat mCachedFormat;
 
-  gfxImageSurface* GetTempSurface(const LayerIntSize& aSize,
+  gfxImageSurface* GetTempSurface(const gfxIntSize& aSize,
                                   const gfxImageFormat aFormat);
 
   void DiscardTempSurface() {
     mCachedTempSurface = nullptr;
   }
 };
 
 } /* layers */
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -49,16 +49,20 @@
 namespace mozilla {
 
 using namespace gfx;
 
 namespace layers {
 
 using namespace mozilla::gl;
 
+static inline IntSize ns2gfxSize(const nsIntSize& s) {
+  return IntSize(s.width, s.height);
+}
+
 // Draw the given quads with the already selected shader. Texture coordinates
 // are supplied if the shader requires them.
 static void
 DrawQuads(GLContext *aGLContext,
           VBOArena &aVBOs,
           ShaderProgramOGL *aProg,
           GLContext::RectTriangles &aRects)
 {
--- a/gfx/layers/opengl/CompositorOGL.h
+++ b/gfx/layers/opengl/CompositorOGL.h
@@ -99,22 +99,22 @@ public:
                         const gfx::Point& aOffset) MOZ_OVERRIDE;
 
   virtual void EndFrame() MOZ_OVERRIDE;
   virtual void EndFrameForExternalComposition(const gfxMatrix& aTransform) MOZ_OVERRIDE;
   virtual void AbortFrame() MOZ_OVERRIDE;
 
   virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE;
 
-  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) MOZ_OVERRIDE
+  virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE
   {
     if (!mGLContext)
       return false;
     int32_t maxSize = GetMaxTextureSize();
-    return aSize <= LayerIntSize(maxSize, maxSize);
+    return aSize <= gfx::IntSize(maxSize, maxSize);
   }
 
   virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE;
 
   /**
    * Set the size of the EGL surface we're rendering to, if we're rendering to
    * an EGL surface.
    */
--- a/gfx/layers/opengl/GrallocTextureClient.cpp
+++ b/gfx/layers/opengl/GrallocTextureClient.cpp
@@ -218,38 +218,36 @@ GrallocTextureClientOGL::AllocateForSurf
     NS_WARNING("Unsupported surface format");
     return false;
   }
 
   return AllocateGralloc(aSize, format, usage);
 }
 
 bool
-GrallocTextureClientOGL::AllocateForYCbCr(LayerIntSize aYSize,
-                                          LayerIntSize aCbCrSize,
-                                          StereoMode aStereoMode)
+GrallocTextureClientOGL::AllocateForYCbCr(gfx::IntSize aYSize, gfx::IntSize aCbCrSize, StereoMode aStereoMode)
 {
   MOZ_ASSERT(IsValid());
-  return AllocateGralloc(aYSize.ToUnknownSize(),
+  return AllocateGralloc(aYSize,
                          HAL_PIXEL_FORMAT_YV12,
                          android::GraphicBuffer::USAGE_SW_READ_OFTEN);
 }
 
 bool
 GrallocTextureClientOGL::AllocateGralloc(gfx::IntSize aSize,
                                          uint32_t aAndroidFormat,
                                          uint32_t aUsage)
 {
   MOZ_ASSERT(IsValid());
   MOZ_ASSERT(mCompositable);
   ISurfaceAllocator* allocator = mCompositable->GetForwarder();
 
   MaybeMagicGrallocBufferHandle handle;
   PGrallocBufferChild* actor =
-    allocator->AllocGrallocBuffer(aSize,
+    allocator->AllocGrallocBuffer(gfx::ThebesIntSize(aSize),
                                   aAndroidFormat,
                                   aUsage,
                                   &handle);
   if (!actor) {
     return false;
   }
   GrallocBufferActor* gba = static_cast<GrallocBufferActor*>(actor);
   gba->InitFromHandle(handle.get_MagicGrallocBufferHandle());
--- a/gfx/layers/opengl/GrallocTextureClient.h
+++ b/gfx/layers/opengl/GrallocTextureClient.h
@@ -77,18 +77,18 @@ public:
   {
     mGrallocFlags = aFlags;
   }
 
   virtual uint8_t* GetBuffer() const MOZ_OVERRIDE;
 
   virtual bool AllocateForSurface(gfx::IntSize aSize) MOZ_OVERRIDE;
 
-  virtual bool AllocateForYCbCr(LayerIntSize aYSize,
-                                LayerIntSize aCbCrSize,
+  virtual bool AllocateForYCbCr(gfx::IntSize aYSize,
+                                gfx::IntSize aCbCrSize,
                                 StereoMode aStereoMode) MOZ_OVERRIDE;
 
   bool AllocateGralloc(gfx::IntSize aYSize, uint32_t aAndroidFormat, uint32_t aUsage);
 
   virtual bool Allocate(uint32_t aSize) MOZ_OVERRIDE;
 
   virtual size_t GetBufferSize() const MOZ_OVERRIDE;
 
--- a/gfx/layers/opengl/ImageLayerOGL.cpp
+++ b/gfx/layers/opengl/ImageLayerOGL.cpp
@@ -22,17 +22,16 @@
 #include "nsDebug.h"                    // for NS_ASSERTION, NS_ERROR
 #include "nsIRunnable.h"                // for nsIRunnable
 #include "nsPoint.h"                    // for nsIntPoint
 #include "nsRect.h"                     // for nsIntRect
 #include "nsSize.h"                     // for nsIntSize
 #include "nsThreadUtils.h"              // for nsRunnable
 #include "nscore.h"                     // for NS_IMETHOD
 #include "LayerManagerOGL.h"            // for LayerOGL::GLContext, etc
-#include "gfx2DGlue.h"
 #if defined(GL_PROVIDER_GLX)
 # include "GLXLibrary.h"
 # include "gfxXlibSurface.h"
 #endif
 
 using namespace mozilla::gfx;
 using namespace mozilla::gl;
 
@@ -136,32 +135,32 @@ GLTexture::Release()
 
 TextureRecycleBin::TextureRecycleBin()
   : mLock("mozilla.layers.TextureRecycleBin.mLock")
 {
 }
 
 void
 TextureRecycleBin::RecycleTexture(GLTexture *aTexture, TextureType aType,
-                           const LayerIntSize& aSize)
+                           const gfxIntSize& aSize)
 {
   MutexAutoLock lock(mLock);
 
   if (!aTexture->IsAllocated())
     return;
 
   if (!mRecycledTextures[aType].IsEmpty() && aSize != mRecycledTextureSizes[aType]) {
     mRecycledTextures[aType].Clear();
   }
   mRecycledTextureSizes[aType] = aSize;
   mRecycledTextures[aType].AppendElement()->TakeFrom(aTexture);
 }
 
 void
-TextureRecycleBin::GetTexture(TextureType aType, const LayerIntSize& aSize,
+TextureRecycleBin::GetTexture(TextureType aType, const gfxIntSize& aSize,
                        GLContext *aContext, GLTexture *aOutTexture)
 {
   MutexAutoLock lock(mLock);
 
   if (mRecycledTextures[aType].IsEmpty() || mRecycledTextureSizes[aType] != aSize) {
     aOutTexture->Allocate(aContext);
     return;
   }
@@ -370,17 +369,17 @@ ImageLayerOGL::RenderLayer(int,
     gl()->fBindTexture(handleDetails.mTarget, backendData->mTexture.GetTextureID());
 
     if (!gl()->AttachSharedHandle(data->mShareType, data->mHandle)) {
       NS_ERROR("Failed to bind shared texture handle");
       return;
     }
 
     gl()->ApplyFilterToBoundTexture(handleDetails.mTarget, mFilter);
-    program->SetLayerQuadRect(gfx::Rect(0, 0, data->mSize.width, data->mSize.height));
+    program->SetLayerQuadRect(nsIntRect(nsIntPoint(0, 0), data->mSize));
     mOGLManager->BindAndDrawQuad(program, data->mInverted);
     gl()->fBindTexture(handleDetails.mTarget, 0);
     gl()->DetachSharedHandle(data->mShareType, data->mHandle);
   }
   GetContainer()->NotifyPaintedImage(image);
 }
 
 static void
@@ -395,32 +394,32 @@ static void
 UploadYUVToTexture(GLContext* gl, const PlanarYCbCrData& aData, 
                    GLTexture* aYTexture,
                    GLTexture* aUTexture,
                    GLTexture* aVTexture)
 {
   nsIntRect size(0, 0, aData.mYSize.width, aData.mYSize.height);
   GLuint texture = aYTexture->GetTextureID();
   nsRefPtr<gfxASurface> surf = new gfxImageSurface(aData.mYChannel,
-                                                   ThebesIntSize(aData.mYSize.ToUnknownSize()),
+                                                   aData.mYSize,
                                                    aData.mYStride,
                                                    gfxImageFormatA8);
   gl->UploadSurfaceToTexture(surf, size, texture, true);
   
   size = nsIntRect(0, 0, aData.mCbCrSize.width, aData.mCbCrSize.height);
   texture = aUTexture->GetTextureID();
   surf = new gfxImageSurface(aData.mCbChannel,
-                             ThebesIntSize(aData.mCbCrSize.ToUnknownSize()),
+                             aData.mCbCrSize,
                              aData.mCbCrStride,
                              gfxImageFormatA8);
   gl->UploadSurfaceToTexture(surf, size, texture, true);
 
   texture = aVTexture->GetTextureID();
   surf = new gfxImageSurface(aData.mCrChannel,
-                             ThebesIntSize(aData.mCbCrSize.ToUnknownSize()),
+                             aData.mCbCrSize,
                              aData.mCbCrStride,
                              gfxImageFormatA8);
   gl->UploadSurfaceToTexture(surf, size, texture, true);
 }
 
 ImageLayerOGL::ImageLayerOGL(LayerManagerOGL *aManager)
   : ImageLayer(aManager, nullptr)
   , LayerOGL(aManager)
@@ -511,27 +510,27 @@ ImageLayerOGL::AllocateTexturesCairo(Cai
 }
 
 /*
  * Returns a size that is larger than and closest to aSize where both
  * width and height are powers of two.
  * If the OpenGL setup is capable of using non-POT textures, then it
  * will just return aSize.
  */
-static gfx::IntSize
-CalculatePOTSize(const gfx::IntSize& aSize, GLContext* gl)
+static gfxIntSize
+CalculatePOTSize(const gfxIntSize& aSize, GLContext* gl)
 {
   if (gl->CanUploadNonPowerOfTwo())
     return aSize;
 
-  return gfx::IntSize(NextPowerOfTwo(aSize.width), NextPowerOfTwo(aSize.height));
+  return gfxIntSize(NextPowerOfTwo(aSize.width), NextPowerOfTwo(aSize.height));
 }
 
 bool
-ImageLayerOGL::LoadAsTexture(GLuint aTextureUnit, gfx::IntSize* aSize)
+ImageLayerOGL::LoadAsTexture(GLuint aTextureUnit, gfxIntSize* aSize)
 {
   // this method shares a lot of code with RenderLayer, but it doesn't seem
   // to be possible to factor it out into a helper method
 
   if (!GetContainer()) {
     return false;
   }
 
--- a/gfx/layers/opengl/ImageLayerOGL.h
+++ b/gfx/layers/opengl/ImageLayerOGL.h
@@ -5,16 +5,17 @@
 
 #ifndef GFX_IMAGELAYEROGL_H
 #define GFX_IMAGELAYEROGL_H
 
 #include "GLContextTypes.h"             // for GLContext, GLuint
 #include "ImageContainer.h"             // for ImageBackendData, etc
 #include "ImageLayers.h"                // for ImageLayer
 #include "LayerManagerOGL.h"            // for LayerOGL
+#include "gfxPoint.h"                   // for gfxIntSize
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
 #include "mozilla/Mutex.h"              // for Mutex
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsISupportsImpl.h"            // for TextureRecycleBin::Release, etc
 #include "nsTArray.h"                   // for nsTArray
 #include "opengl/LayerManagerOGLProgram.h"  // for ShaderProgramType, etc
 
@@ -83,42 +84,42 @@ public:
   TextureRecycleBin();
 
   enum TextureType {
     TEXTURE_Y,
     TEXTURE_C
   };
 
   void RecycleTexture(GLTexture *aTexture, TextureType aType,
-                      const LayerIntSize& aSize);
-  void GetTexture(TextureType aType, const LayerIntSize& aSize,
+                      const gfxIntSize& aSize);
+  void GetTexture(TextureType aType, const gfxIntSize& aSize,
                   GLContext *aContext, GLTexture *aOutTexture);
 
 private:
   typedef mozilla::Mutex Mutex;
 
   // This protects mRecycledBuffers, mRecycledBufferSize, mRecycledTextures
   // and mRecycledTextureSizes
   Mutex mLock;
 
   nsTArray<GLTexture> mRecycledTextures[2];
-  LayerIntSize mRecycledTextureSizes[2];
+  gfxIntSize mRecycledTextureSizes[2];
 };
 
 class ImageLayerOGL : public ImageLayer,
                       public LayerOGL
 {
 public:
   ImageLayerOGL(LayerManagerOGL *aManager);
   ~ImageLayerOGL() { Destroy(); }
 
   // LayerOGL Implementation
   virtual void Destroy() { mDestroyed = true; }
   virtual Layer* GetLayer();
-  virtual bool LoadAsTexture(GLuint aTextureUnit, gfx::IntSize* aSize);
+  virtual bool LoadAsTexture(GLuint aTextureUnit, gfxIntSize* aSize);
 
   virtual void RenderLayer(int aPreviousFrameBuffer,
                            const nsIntPoint& aOffset);
   virtual void CleanupResources() {}
 
 
   void AllocateTexturesYCbCr(PlanarYCbCrImage *aImage);
   void AllocateTexturesCairo(CairoImage *aImage);
@@ -140,24 +141,24 @@ struct PlanarYCbCrOGLBackendData : publi
 
   bool HasTextures()
   {
     return mTextures[0].IsAllocated() && mTextures[1].IsAllocated() &&
            mTextures[2].IsAllocated();
   }
 
   GLTexture mTextures[3];
-  LayerIntSize mYSize, mCbCrSize;
+  gfxIntSize mYSize, mCbCrSize;
   nsRefPtr<TextureRecycleBin> mTextureRecycleBin;
 };
 
 
 struct CairoOGLBackendData : public ImageBackendData
 {
   CairoOGLBackendData() : mLayerProgram(RGBALayerProgramType) {}
   GLTexture mTexture;
   ShaderProgramType mLayerProgram;
-  gfx::IntSize mTextureSize;
+  gfxIntSize mTextureSize;
 };
 
 } /* layers */
 } /* mozilla */
 #endif /* GFX_IMAGELAYEROGL_H */
--- a/gfx/layers/opengl/LayerManagerOGL.h
+++ b/gfx/layers/opengl/LayerManagerOGL.h
@@ -106,21 +106,21 @@ public:
 
   virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT);
   virtual void EndTransaction(DrawThebesLayerCallback aCallback,
                               void* aCallbackData,
                               EndTransactionFlags aFlags = END_DEFAULT);
 
   virtual void SetRoot(Layer* aLayer) { mRoot = aLayer; }
 
-  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) {
+  virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) {
     if (!mGLContext)
       return false;
     int32_t maxSize = GetMaxTextureSize();
-    return aSize <= LayerIntSize(maxSize, maxSize);
+    return aSize <= gfxIntSize(maxSize, maxSize);
   }
 
   virtual int32_t GetMaxTextureSize() const;
 
   virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
 
   virtual already_AddRefed<ContainerLayer> CreateContainerLayer();
 
@@ -488,17 +488,17 @@ public:
    * Will try to use an existing texture if possible, or a temporary
    * one if not. It is the callee's responsibility to release the texture.
    * Will return true if a texture could be constructed and loaded, false otherwise.
    * The texture will not be transformed, i.e., it will be in the same coord
    * space as this.
    * Any layer that can be used as a mask layer should override this method.
    * aSize will contain the size of the image.
    */
-  virtual bool LoadAsTexture(GLuint aTextureUnit, gfx::IntSize* aSize)
+  virtual bool LoadAsTexture(GLuint aTextureUnit, gfxIntSize* aSize)
   {
     NS_WARNING("LoadAsTexture called without being overriden");
     return false;
   }
 
 protected:
   LayerManagerOGL *mOGLManager;
   bool mDestroyed;
--- a/gfx/layers/opengl/LayerManagerOGLProgram.cpp
+++ b/gfx/layers/opengl/LayerManagerOGLProgram.cpp
@@ -441,30 +441,30 @@ ShaderProgramOGL::CreateProgram(const ch
 
 bool
 ShaderProgramOGL::LoadMask(Layer* aMaskLayer)
 {
   if (!aMaskLayer) {
     return false;
   }
 
-  gfx::IntSize size;
+  gfxIntSize size;
   if (!static_cast<LayerOGL*>(aMaskLayer->ImplData())
         ->LoadAsTexture(LOCAL_GL_TEXTURE0 + mProfile.mTextureCount - 1, &size)){
     return false;
   }
 
   SetUniform(mProfile.LookupUniformLocation("uMaskTexture"),
               (GLint)(mProfile.mTextureCount - 1));
 
   gfxMatrix maskTransform;
   mozilla::DebugOnly<bool> isMask2D =
     aMaskLayer->GetEffectiveTransform().CanDraw2D(&maskTransform);
   NS_ASSERTION(isMask2D, "How did we end up with a 3D transform here?!");
-  gfxRect bounds = gfxRect(0, 0, size.width, size.height);
+  gfxRect bounds = gfxRect(gfxPoint(), size);
   bounds = maskTransform.TransformBounds(bounds);
 
   gfx3DMatrix m;
   m._11 = 1.0f/bounds.width;
   m._22 = 1.0f/bounds.height;
   m._41 = float(-bounds.x)/bounds.width;
   m._42 = float(-bounds.y)/bounds.height;
 
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -95,17 +95,17 @@ CreateTextureHostOGL(uint64_t aID,
                                                    aDeallocator, aFlags);
       break;
     }
     case SurfaceDescriptor::TSharedTextureDescriptor: {
       const SharedTextureDescriptor& desc = aDesc.get_SharedTextureDescriptor();
       result = new SharedTextureHostOGL(aID, aFlags,
                                         desc.shareType(),
                                         desc.handle(),
-                                        desc.size(),
+                                        gfx::ToIntSize(desc.size()),
                                         desc.inverted());
       break;
     }
 #ifdef MOZ_WIDGET_GONK
     case SurfaceDescriptor::TNewSurfaceDescriptorGralloc: {
       const NewSurfaceDescriptorGralloc& desc =
         aDesc.get_NewSurfaceDescriptorGralloc();
       result = new GrallocTextureHostOGL(aID, aFlags, desc);
@@ -612,17 +612,18 @@ SharedDeprecatedTextureHostOGL::SwapText
                                        nsIntRegion* aRegion)
 {
   NS_ASSERTION(aImage.type() == SurfaceDescriptor::TSharedTextureDescriptor,
               "Invalid descriptor");
 
   SharedTextureDescriptor texture = aImage.get_SharedTextureDescriptor();
 
   SharedTextureHandle newHandle = texture.handle();
-  mSize = texture.size();
+  nsIntSize size = texture.size();
+  mSize = gfx::IntSize(size.width, size.height);
   if (texture.inverted()) {
     mFlags |= TEXTURE_NEEDS_Y_FLIP;
   }
 
   if (mSharedHandle && mSharedHandle != newHandle) {
     mGL->ReleaseSharedHandle(mShareType, mSharedHandle);
   }
 
@@ -841,34 +842,34 @@ YCbCrDeprecatedTextureHostOGL::UpdateImp
 {
   if (!mGL) {
     return;
   }
   NS_ASSERTION(aImage.type() == SurfaceDescriptor::TYCbCrImage, "SurfaceDescriptor mismatch");
 
   YCbCrImageDataDeserializer deserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
 
-  LayerIntSize gfxSize = deserializer.GetYSize();
-  LayerIntSize gfxCbCrSize = deserializer.GetCbCrSize();
+  gfxIntSize gfxSize = deserializer.GetYSize();
+  gfxIntSize gfxCbCrSize = deserializer.GetCbCrSize();
 
-  if (!mYTexture->mTexImage || mYTexture->mTexImage->GetSize() != gfxSize.ToUnknownSize()) {
+  if (!mYTexture->mTexImage || mYTexture->mTexImage->GetSize() != gfxSize) {
     mYTexture->mTexImage = CreateBasicTextureImage(mGL,
                                                    gfxSize,
                                                    GFX_CONTENT_ALPHA,
                                                    WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
                                                    FlagsToGLFlags(mFlags));
   }
-  if (!mCbTexture->mTexImage || mCbTexture->mTexImage->GetSize() != gfxCbCrSize.ToUnknownSize()) {
+  if (!mCbTexture->mTexImage || mCbTexture->mTexImage->GetSize() != gfxCbCrSize) {
     mCbTexture->mTexImage = CreateBasicTextureImage(mGL,
                                                     gfxCbCrSize,
                                                     GFX_CONTENT_ALPHA,
                                                     WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
                                                     FlagsToGLFlags(mFlags));
   }
-  if (!mCrTexture->mTexImage || mCrTexture->mTexImage->GetSize() != gfxCbCrSize.ToUnknownSize()) {
+  if (!mCrTexture->mTexImage || mCrTexture->mTexImage->GetSize() != gfxCbCrSize) {
     mCrTexture->mTexImage = CreateBasicTextureImage(mGL,
                                                     gfxCbCrSize,
                                                     GFX_CONTENT_ALPHA,
                                                     WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
                                                     FlagsToGLFlags(mFlags));
   }
 
   RefPtr<gfxImageSurface> tempY = new gfxImageSurface(deserializer.GetYData(),
--- a/gfx/tests/gtest/TestTextures.cpp
+++ b/gfx/tests/gtest/TestTextures.cpp
@@ -146,18 +146,18 @@ void TestTextureClientSurface(TextureCli
 }
 
 // Same as above, for YCbCr surfaces
 void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) {
 
   // client allocation
   ASSERT_TRUE(client->AsTextureClientYCbCr() != nullptr);
   TextureClientYCbCr* texture = client->AsTextureClientYCbCr();
-  texture->AllocateForYCbCr(ycbcrData.mYSize,
-                            ycbcrData.mCbCrSize,
+  texture->AllocateForYCbCr(ToIntSize(ycbcrData.mYSize),
+                            ToIntSize(ycbcrData.mCbCrSize),
                             ycbcrData.mStereoMode);
   ASSERT_TRUE(client->IsAllocated());
 
   // client painting
   texture->UpdateYCbCr(ycbcrData);
 
   ASSERT_TRUE(client->Lock(OPEN_READ_ONLY));
   client->Unlock();
@@ -244,22 +244,19 @@ TEST(Layers, TextureYCbCrSerialization) 
   SetupSurface(ySurface.get());
   SetupSurface(cbSurface.get());
   SetupSurface(crSurface.get());
 
   PlanarYCbCrData clientData;
   clientData.mYChannel = ySurface->Data();
   clientData.mCbChannel = cbSurface->Data();
   clientData.mCrChannel = crSurface->Data();
-  clientData.mYSize = LayerIntSize(ySurface->GetSize().width,
-                                   ySurface->GetSize().height);
-  clientData.mPicSize = LayerIntSize(ySurface->GetSize().width,
-                                     ySurface->GetSize().height);
-  clientData.mCbCrSize = LayerIntSize(cbSurface->GetSize().width,
-                                      cbSurface->GetSize().height);
+  clientData.mYSize = ySurface->GetSize();
+  clientData.mPicSize = ySurface->GetSize();
+  clientData.mCbCrSize = cbSurface->GetSize();
   clientData.mYStride = ySurface->Stride();
   clientData.mCbCrStride = cbSurface->Stride();
   clientData.mStereoMode = STEREO_MODE_MONO;
   clientData.mYSkip = 0;
   clientData.mCbSkip = 0;
   clientData.mCrSkip = 0;
   clientData.mCrSkip = 0;
   clientData.mPicX = 0;
--- a/gfx/thebes/gfxImageSurface.cpp
+++ b/gfx/thebes/gfxImageSurface.cpp
@@ -39,22 +39,16 @@ gfxImageSurface::InitFromSurface(cairo_s
 }
 
 gfxImageSurface::gfxImageSurface(unsigned char *aData, const gfxIntSize& aSize,
                                  long aStride, gfxImageFormat aFormat)
 {
     InitWithData(aData, aSize, aStride, aFormat);
 }
 
-gfxImageSurface::gfxImageSurface(unsigned char *aData, const mozilla::LayerIntSize& aSize,
-                                 long aStride, gfxImageFormat aFormat)
-{
-    InitWithData(aData, gfxIntSize(aSize.width, aSize.height), aStride, aFormat);
-}
-
 void
 gfxImageSurface::MakeInvalid()
 {
     mSize = gfxIntSize(-1, -1);
     mData = nullptr;
     mStride = 0;
 }
 
--- a/gfx/thebes/gfxImageSurface.h
+++ b/gfx/thebes/gfxImageSurface.h
@@ -5,17 +5,16 @@
 
 #ifndef GFX_IMAGESURFACE_H
 #define GFX_IMAGESURFACE_H
 
 #include "mozilla/MemoryReporting.h"
 #include "gfxASurface.h"
 #include "nsAutoPtr.h"
 #include "nsSize.h"
-#include "Units.h"
 
 // ARGB -- raw buffer.. wont be changed.. good for storing data.
 
 class gfxSubimageSurface;
 
 namespace mozilla {
 namespace gfx {
 class SourceSurface;
@@ -35,18 +34,16 @@ public:
      * @param aSize The size of the buffer
      * @param aStride The stride of the buffer
      * @param format Format of the data
      *
      * @see gfxImageFormat
      */
     gfxImageSurface(unsigned char *aData, const gfxIntSize& aSize,
                     long aStride, gfxImageFormat aFormat);
-    gfxImageSurface(unsigned char *aData, const mozilla::LayerIntSize& aSize,
-                    long aStride, gfxImageFormat aFormat);
 
     /**
      * Construct an image surface.
      * @param aSize The size of the buffer
      * @param format Format of the data
      *
      * @see gfxImageFormat
      */
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -680,17 +680,17 @@ gfxUtils::GfxRectToIntRect(const gfxRect
   *aOut = nsIntRect(int32_t(aIn.X()), int32_t(aIn.Y()),
   int32_t(aIn.Width()), int32_t(aIn.Height()));
   return gfxRect(aOut->x, aOut->y, aOut->width, aOut->height).IsEqualEdges(aIn);
 }
 
 void
 gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrData& aData,
                                          gfxImageFormat& aSuggestedFormat,
-                                         LayerIntSize& aSuggestedSize)
+                                         gfxIntSize& aSuggestedSize)
 {
   gfx::YUVType yuvtype =
     gfx::TypeFromSize(aData.mYSize.width,
                       aData.mYSize.height,
                       aData.mCbCrSize.width,
                       aData.mCbCrSize.height);
 
   // 'prescale' is true if the scaling is to be done as part of the
@@ -734,17 +734,17 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize
   if (!prescale) {
     aSuggestedSize = aData.mPicSize;
   }
 }
 
 void
 gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData,
                             const gfxImageFormat& aDestFormat,
-                            const LayerIntSize& aDestSize,
+                            const gfxIntSize& aDestSize,
                             unsigned char* aDestBuffer,
                             int32_t aStride)
 {
   // ConvertYCbCrToRGB et al. assume the chroma planes are rounded up if the
   // luma plane is odd sized.
   MOZ_ASSERT((aData.mCbCrSize.width == aData.mYSize.width ||
               aData.mCbCrSize.width == (aData.mYSize.width + 1) >> 1) &&
              (aData.mCbCrSize.height == aData.mYSize.height ||
--- a/gfx/thebes/gfxUtils.h
+++ b/gfx/thebes/gfxUtils.h
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_UTILS_H
 #define GFX_UTILS_H
 
 #include "gfxTypes.h"
 #include "GraphicsFilter.h"
 #include "imgIContainer.h"
-#include "Units.h"
 
 class gfxDrawable;
 class nsIntRegion;
 struct nsIntRect;
 
 namespace mozilla {
 namespace layers {
 class PlanarYCbCrData;
@@ -130,27 +129,27 @@ public:
      *   if the desired format is not supported.
      * @param aSuggestedSize will be set to the picture size from aData
      *   if either the suggested size was {0,0}
      *   or simultaneous scaling and conversion is not supported.
      */
     static void
     GetYCbCrToRGBDestFormatAndSize(const mozilla::layers::PlanarYCbCrData& aData,
                                    gfxImageFormat& aSuggestedFormat,
-                                   mozilla::LayerIntSize& aSuggestedSize);
+                                   gfxIntSize& aSuggestedSize);
 
     /**
      * Convert YCbCrImage into RGB aDestBuffer
      * Format and Size parameters must have
      *   been passed to GetYCbCrToRGBDestFormatAndSize
      */
     static void
     ConvertYCbCrToRGB(const mozilla::layers::PlanarYCbCrData& aData,
                       const gfxImageFormat& aDestFormat,
-                      const mozilla::LayerIntSize& aDestSize,
+                      const gfxIntSize& aDestSize,
                       unsigned char* aDestBuffer,
                       int32_t aStride);
 
     static const uint8_t sUnpremultiplyTable[256*256];
     static const uint8_t sPremultiplyTable[256*256];
 #ifdef MOZ_DUMP_PAINTING
     /**
      * Writes a binary PNG file.
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1945,17 +1945,17 @@ nsDisplayBackgroundImage::GetLayerState(
     }
   }
 
   if (!TryOptimizeToImageLayer(aManager, aBuilder)) {
     return LAYER_NONE;
   }
 
   if (!animated) {
-    mozilla::gfx::IntSize imageSize = mImageContainer->GetCurrentSize();
+    gfxSize imageSize = mImageContainer->GetCurrentSize();
     NS_ASSERTION(imageSize.width != 0 && imageSize.height != 0, "Invalid image size!");
 
     gfxRect destRect = mDestRect;
 
     destRect.width *= aParameters.mXScale;
     destRect.height *= aParameters.mYScale;
 
     // Calculate the scaling factor for the frame.
@@ -1992,17 +1992,17 @@ nsDisplayBackgroundImage::BuildLayer(nsD
   return layer.forget();
 }
 
 void
 nsDisplayBackgroundImage::ConfigureLayer(ImageLayer* aLayer, const nsIntPoint& aOffset)
 {
   aLayer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(mFrame));
 
-  mozilla::gfx::IntSize imageSize = mImageContainer->GetCurrentSize();
+  gfxIntSize imageSize = mImageContainer->GetCurrentSize();
   NS_ASSERTION(imageSize.width != 0 && imageSize.height != 0, "Invalid image size!");
 
   gfxMatrix transform;
   transform.Translate(mDestRect.TopLeft() + aOffset);
   transform.Scale(mDestRect.width/imageSize.width,
                   mDestRect.height/imageSize.height);
   aLayer->SetBaseTransform(gfx3DMatrix::From2D(transform));
   aLayer->SetVisibleRegion(nsIntRect(0, 0, imageSize.width, imageSize.height));
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -77,17 +77,16 @@
 #ifdef MOZ_XUL
 #include "nsXULPopupManager.h"
 #endif
 
 #include "GeckoProfiler.h"
 #include "nsAnimationManager.h"
 #include "nsTransitionManager.h"
 #include "RestyleManager.h"
-#include "gfx2DGlue.h"
 
 using namespace mozilla;
 using namespace mozilla::css;
 using namespace mozilla::dom;
 using namespace mozilla::layers;
 using namespace mozilla::layout;
 
 using mozilla::image::Angle;
@@ -4895,35 +4894,34 @@ nsLayoutUtils::SurfaceFromElement(HTMLVi
   nsCOMPtr<nsIPrincipal> principal = aElement->GetCurrentPrincipal();
   if (!principal)
     return result;
 
   ImageContainer *container = aElement->GetImageContainer();
   if (!container)
     return result;
 
-  gfx::IntSize size;
+  gfxIntSize size;
   nsRefPtr<gfxASurface> surf = container->GetCurrentAsSurface(&size);
   if (!surf)
     return result;
 
-  gfxIntSize gfxSize = ThebesIntSize(size);
   if (wantImageSurface && surf->GetType() != gfxSurfaceTypeImage) {
     nsRefPtr<gfxImageSurface> imgSurf =
-      new gfxImageSurface(gfxSize, gfxImageFormatARGB32);
+      new gfxImageSurface(size, gfxImageFormatARGB32);
 
     nsRefPtr<gfxContext> ctx = new gfxContext(imgSurf);
     ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
-    ctx->DrawSurface(surf, gfxSize);
+    ctx->DrawSurface(surf, size);
     surf = imgSurf;
   }
 
   result.mCORSUsed = aElement->GetCORSMode() != CORS_NONE;
   result.mSurface = surf;
-  result.mSize = gfxSize;
+  result.mSize = size;
   result.mPrincipal = principal.forget();
   result.mIsWriteOnly = false;
 
   return result;
 }
 
 nsLayoutUtils::SurfaceFromElementResult
 nsLayoutUtils::SurfaceFromElement(dom::Element* aElement,
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -1522,17 +1522,17 @@ nsObjectFrame::BuildLayer(nsDisplayListB
     return nullptr;
 
   // window is in "display pixels", but size needs to be in device pixels
   double scaleFactor = 1.0;
   if (NS_FAILED(mInstanceOwner->GetContentsScaleFactor(&scaleFactor))) {
     scaleFactor = 1.0;
   }
   int intScaleFactor = ceil(scaleFactor);
-  gfx::IntSize size(window->width * intScaleFactor, window->height * intScaleFactor);
+  gfxIntSize size(window->width * intScaleFactor, window->height * intScaleFactor);
 
   nsRect area = GetContentRectRelativeToSelf() + aItem->ToReferenceFrame();
   gfxRect r = nsLayoutUtils::RectToGfxRect(area, PresContext()->AppUnitsPerDevPixel());
   // to provide crisper and faster drawing.
   r.Round();
   nsRefPtr<Layer> layer =
     (aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));
 
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -179,20 +179,20 @@ nsVideoFrame::BuildLayer(nsDisplayListBu
   nsIntSize videoSize;
   if (NS_FAILED(element->GetVideoSize(&videoSize)) || area.IsEmpty()) {
     return nullptr;
   }
 
   nsRefPtr<ImageContainer> container = element->GetImageContainer();
   if (!container)
     return nullptr;
-
+  
   // Retrieve the size of the decoded video frame, before being scaled
   // by pixel aspect ratio.
-  gfx::IntSize frameSize = container->GetCurrentSize();
+  gfxIntSize frameSize = container->GetCurrentSize();
   if (frameSize.width == 0 || frameSize.height == 0) {
     // No image, or zero-sized image. No point creating a layer.
     return nullptr;
   }
 
   // Compute the rectangle in which to paint the video. We need to use
   // the largest rectangle that fills our content-box and has the
   // correct aspect ratio.
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -832,17 +832,17 @@ void MediaPipelineTransmit::PipelineList
   layers::Image *img = chunk.mFrame.GetImage();
 
   // We now need to send the video frame to the other side
   if (!img) {
     // segment.AppendFrame() allows null images, which show up here as null
     return;
   }
 
-  gfx::IntSize size = img->GetSize();
+  gfxIntSize size = img->GetSize();
   if ((size.width & 1) != 0 || (size.height & 1) != 0) {
     MOZ_ASSERT(false, "Can't handle odd-sized images");
     return;
   }
 
   if (chunk.mFrame.GetForceBlack()) {
     uint32_t yPlaneLen = size.width*size.height;
     uint32_t cbcrPlaneLen = yPlaneLen/2;
@@ -1143,25 +1143,25 @@ void MediaPipelineReceiveVideo::Pipeline
 
   layers::PlanarYCbCrImage* videoImage = static_cast<layers::PlanarYCbCrImage*>(image.get());
   uint8_t* frame = const_cast<uint8_t*>(static_cast<const uint8_t*> (buffer));
   const uint8_t lumaBpp = 8;
   const uint8_t chromaBpp = 4;
 
   layers::PlanarYCbCrData data;
   data.mYChannel = frame;
-  data.mYSize = LayerIntSize(width_, height_);
+  data.mYSize = gfxIntSize(width_, height_);
   data.mYStride = width_ * lumaBpp/ 8;
   data.mCbCrStride = width_ * chromaBpp / 8;
   data.mCbChannel = frame + height_ * data.mYStride;
   data.mCrChannel = data.mCbChannel + height_ * data.mCbCrStride / 2;
-  data.mCbCrSize = LayerIntSize(width_/ 2, height_/ 2);
+  data.mCbCrSize = gfxIntSize(width_/ 2, height_/ 2);
   data.mPicX = 0;
   data.mPicY = 0;
-  data.mPicSize = LayerIntSize(width_, height_);
+  data.mPicSize = gfxIntSize(width_, height_);
   data.mStereoMode = STEREO_MODE_MONO;
 
   videoImage->SetData(data);
 
   image_ = image.forget();
 #endif
 }
 
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
@@ -34,17 +34,16 @@ namespace mozilla {
   class DataChannel;
 }
 #endif
 
 #include "nricectx.h"
 #include "nriceresolver.h"
 #include "nricemediastream.h"
 #include "MediaPipeline.h"
-#include "Units.h"
 
 namespace sipcc {
 
 class PeerConnectionImpl;
 class PeerConnectionMedia;
 
 /* Temporary for providing audio data */
 class Fake_AudioGenerator {
@@ -127,25 +126,25 @@ class Fake_VideoGenerator {
     ++gen->mCount;
     memset(frame, (gen->mCount / 8) & 0xff, len); // Rotating colors
 
     const uint8_t lumaBpp = 8;
     const uint8_t chromaBpp = 4;
 
     mozilla::layers::PlanarYCbCrData data;
     data.mYChannel = frame;
-    data.mYSize = mozilla::LayerIntSize(WIDTH, HEIGHT);
+    data.mYSize = gfxIntSize(WIDTH, HEIGHT);
     data.mYStride = (int32_t) (WIDTH * lumaBpp / 8.0);
     data.mCbCrStride = (int32_t) (WIDTH * chromaBpp / 8.0);
     data.mCbChannel = frame + HEIGHT * data.mYStride;
     data.mCrChannel = data.mCbChannel + HEIGHT * data.mCbCrStride / 2;
-    data.mCbCrSize = mozilla::LayerIntSize(WIDTH / 2, HEIGHT / 2);
+    data.mCbCrSize = gfxIntSize(WIDTH / 2, HEIGHT / 2);
     data.mPicX = 0;
     data.mPicY = 0;
-    data.mPicSize = mozilla::LayerIntSize(WIDTH, HEIGHT);
+    data.mPicSize = gfxIntSize(WIDTH, HEIGHT);
     data.mStereoMode = mozilla::STEREO_MODE_MONO;
 
     // SetData copies data, so we can free the frame
     planar->SetData(data);
     PR_Free(frame);
 
     // AddTrack takes ownership of segment
     mozilla::VideoSegment *segment = new mozilla::VideoSegment();
--- a/widget/android/nsScreenManagerAndroid.cpp
+++ b/widget/android/nsScreenManagerAndroid.cpp
@@ -3,32 +3,31 @@
  * 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/. */
 
 #define MOZ_FATAL_ASSERTIONS_FOR_THREAD_SAFETY
 
 #include "nsScreenManagerAndroid.h"
 #include "nsWindow.h"
 #include "AndroidBridge.h"
-#include "mozilla/gfx/Point.h"
 
 using namespace mozilla;
 
 nsScreenAndroid::nsScreenAndroid(void *nativeScreen)
 {
 }
 
 nsScreenAndroid::~nsScreenAndroid()
 {
 }
 
 NS_IMETHODIMP
 nsScreenAndroid::GetRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
 {
-    gfx::IntSize sz = nsWindow::GetAndroidScreenBounds();
+    gfxIntSize sz = nsWindow::GetAndroidScreenBounds();
 
     *outLeft = 0;
     *outTop = 0;
 
     *outWidth = sz.width;
     *outHeight = sz.height;
 
     return NS_OK;
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -53,28 +53,27 @@ using mozilla::unused;
 
 #include "AndroidBridge.h"
 #include "android_npapi.h"
 
 #include "imgIEncoder.h"
 
 #include "nsString.h"
 #include "GeckoProfiler.h" // For PROFILER_LABEL
-#include "mozilla/gfx/Point.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::widget;
 using namespace mozilla::layers;
 
 NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget)
 
 // The dimensions of the current android view
 static gfxIntSize gAndroidBounds = gfxIntSize(0, 0);
-static mozilla::gfx::IntSize gAndroidScreenBounds;
+static gfxIntSize gAndroidScreenBounds;
 
 #include "mozilla/layers/AsyncPanZoomController.h"
 #include "mozilla/layers/CompositorChild.h"
 #include "mozilla/layers/CompositorParent.h"
 #include "mozilla/layers/LayerTransactionParent.h"
 #include "mozilla/Mutex.h"
 #include "nsThreadUtils.h"
 
@@ -1137,17 +1136,17 @@ nsWindow::InitEvent(WidgetGUIEvent& even
     } else {
         event.refPoint.x = 0;
         event.refPoint.y = 0;
     }
 
     event.time = PR_Now() / 1000;
 }
 
-mozilla::gfx::IntSize
+gfxIntSize
 nsWindow::GetAndroidScreenBounds()
 {
     if (XRE_GetProcessType() == GeckoProcessType_Content) {
         return ContentChild::GetSingleton()->GetScreenSize();
     }
     return gAndroidScreenBounds;
 }
 
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -2,17 +2,17 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef NSWINDOW_H_
 #define NSWINDOW_H_
 
 #include "nsBaseWidget.h"
-#include "mozilla/gfx/Point.h"
+#include "gfxPoint.h"
 #include "nsIIdleServiceInternal.h"
 #include "nsTArray.h"
 #include "AndroidJavaWrappers.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/TextRange.h"
 
 class gfxASurface;
@@ -37,17 +37,17 @@ public:
     using nsBaseWidget::GetLayerManager;
 
     nsWindow();
     virtual ~nsWindow();
 
     NS_DECL_ISUPPORTS_INHERITED
 
     static void OnGlobalAndroidEvent(mozilla::AndroidGeckoEvent *ae);
-    static mozilla::gfx::IntSize GetAndroidScreenBounds();
+    static gfxIntSize GetAndroidScreenBounds();
     static nsWindow* TopWindow();
 
     nsWindow* FindWindowForPoint(const nsIntPoint& pt);
 
     void OnAndroidEvent(mozilla::AndroidGeckoEvent *ae);
     void OnDraw(mozilla::AndroidGeckoEvent *ae);
     bool OnMultitouchEvent(mozilla::AndroidGeckoEvent *ae);
     void OnNativeGestureEvent(mozilla::AndroidGeckoEvent *ae);
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -1413,17 +1413,17 @@ DEFINE_REGISTER_SIZE_OF_TAB(NonJS);
 
 }
 
 #if defined(MOZ_DMD)
 
 namespace mozilla {
 namespace dmd {
 
-class NullReporterCallback MOZ_FINAL : public nsIMemoryReporterCallback
+class NullReporterCallback : public nsIMemoryReporterCallback
 {
 public:
     NS_DECL_ISUPPORTS
 
     NS_IMETHOD Callback(const nsACString& aProcess, const nsACString& aPath,
                         int32_t aKind, int32_t aUnits, int64_t aAmount,
                         const nsACString& aDescription,
                         nsISupports* aData)