Bug 929513 Part 3: Use some LayerIntSize in gfx/layers r=nical
authorDavid Zbarsky <dzbarsky@gmail.com>
Sun, 27 Oct 2013 17:53:27 -0400
changeset 166236 02bc8f1178a6d4bd6f17804dcb524e7493bf0415
parent 166235 6efcb3826227bd99b3d28c895f7a731279a91f37
child 166237 0fbcde0e9bbdd70b93afed9392c3beb36cf6faa5
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)
reviewersnical
bugs929513
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 929513 Part 3: Use some LayerIntSize in gfx/layers r=nical
content/media/MediaDecoderReader.cpp
content/media/MediaStreamGraph.cpp
content/media/webrtc/MediaEngineDefault.cpp
content/media/webrtc/MediaEngineWebRTCVideo.cpp
gfx/layers/GrallocImages.cpp
gfx/layers/ImageContainer.cpp
gfx/layers/ImageContainer.h
gfx/layers/YCbCrImageDataSerializer.cpp
gfx/layers/YCbCrImageDataSerializer.h
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicImages.cpp
gfx/layers/client/ImageClient.cpp
gfx/layers/client/TextureClient.cpp
gfx/layers/client/TextureClient.h
gfx/layers/composite/TextureHost.cpp
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d9/TextureD3D9.cpp
gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
gfx/layers/opengl/CanvasLayerOGL.cpp
gfx/layers/opengl/CanvasLayerOGL.h
gfx/layers/opengl/GrallocTextureClient.cpp
gfx/layers/opengl/GrallocTextureClient.h
gfx/layers/opengl/ImageLayerOGL.cpp
gfx/layers/opengl/ImageLayerOGL.h
gfx/layers/opengl/TextureHostOGL.cpp
gfx/tests/gtest/TestTextures.cpp
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
--- 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 = gfxIntSize(Y.mWidth, Y.mHeight);
+  data.mYSize = LayerIntSize(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 = gfxIntSize(Cb.mWidth, Cb.mHeight);
+  data.mCbCrSize = LayerIntSize(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 = gfxIntSize(aPicture.width, aPicture.height);
+  data.mPicSize = LayerIntSize(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 = gfxIntSize(1, 1);
+  data.mPicSize = data.mYSize = data.mCbCrSize = LayerIntSize(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/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 = gfxIntSize(aWidth, aHeight);
+  aData.mYSize = LayerIntSize(aWidth, aHeight);
   aData.mYStride = aWidth;
   aData.mCbCrStride = aWidth>>1;
   aData.mCbChannel = frame + yLen;
   aData.mCrChannel = aData.mCbChannel + cbLen;
-  aData.mCbCrSize = gfxIntSize(aWidth>>1, aHeight>>1);
+  aData.mCbCrSize = LayerIntSize(aWidth>>1, aHeight>>1);
   aData.mPicX = 0;
   aData.mPicY = 0;
-  aData.mPicSize = gfxIntSize(aWidth, aHeight);
+  aData.mPicSize = LayerIntSize(aWidth, aHeight);
   aData.mStereoMode = STEREO_MODE_MONO;
 }
 
 static void ReleaseFrame(layers::PlanarYCbCrData& aData)
 {
   PR_Free(aData.mYChannel);
 }
 
--- 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 = gfxIntSize(mWidth, mHeight);
+  data.mYSize = LayerIntSize(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 = gfxIntSize(mWidth/ 2, mHeight/ 2);
+  data.mCbCrSize = LayerIntSize(mWidth/ 2, mHeight/ 2);
   data.mPicX = 0;
   data.mPicY = 0;
-  data.mPicSize = gfxIntSize(mWidth, mHeight);
+  data.mPicSize = LayerIntSize(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/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;
+  mSize = aData.mPicSize.ToUnknownSize();
 
   if (!mGraphicBuffer.get()) {
 
     SurfaceDescriptor desc;
     ImageBridgeChild *ibc = ImageBridgeChild::GetSingleton();
-    ibc->AllocSurfaceDescriptorGralloc(aData.mYSize,
+    ibc->AllocSurfaceDescriptorGralloc(ThebesIntSize(aData.mYSize.ToUnknownSize()),
                                        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);
   }
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -446,17 +446,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 gfxIntSize &aSize, int32_t aStride, int32_t aSkip)
+          const LayerIntSize &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 +493,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;
+  mSize = aData.mPicSize.ToUnknownSize();
 }
 
 void
 PlanarYCbCrImage::SetData(const Data &aData)
 {
   CopyData(aData);
 }
 
@@ -514,17 +514,17 @@ PlanarYCbCrImage::GetOffscreenFormat()
     gfxPlatform::GetPlatform()->GetOffscreenFormat() :
     mOffscreenFormat;
 }
 
 void
 PlanarYCbCrImage::SetDataNoCopy(const Data &aData)
 {
   mData = aData;
-  mSize = aData.mPicSize;
+  mSize = aData.mPicSize.ToUnknownSize();
 }
 
 uint8_t*
 PlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
 {
   // update buffer size
   mBufferSize = aSize;
 
@@ -537,28 +537,29 @@ already_AddRefed<gfxASurface>
 PlanarYCbCrImage::GetAsSurface()
 {
   if (mSurface) {
     nsRefPtr<gfxASurface> result = mSurface.get();
     return result.forget();
   }
 
   gfxImageFormat format = GetOffscreenFormat();
-  gfx::IntSize size(mSize);
+  LayerIntSize size(mSize.width, mSize.height);
   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);
 
-  gfxUtils::ConvertYCbCrToRGB(mData, format, mSize,
+  size = LayerIntSize(mSize.width, mSize.height);
+  gfxUtils::ConvertYCbCrToRGB(mData, format, size,
                               imageSurface->Data(),
                               imageSurface->Stride());
 
   mSurface = imageSurface;
 
   return imageSurface.forget();
 }
 
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -22,16 +22,17 @@
 #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.
@@ -700,29 +701,29 @@ private:
   nsRefPtr<Image> mImage;
   gfx::IntSize mSize;
 };
 
 struct PlanarYCbCrData {
   // Luminance buffer
   uint8_t* mYChannel;
   int32_t mYStride;
-  gfxIntSize mYSize;
+  LayerIntSize mYSize;
   int32_t mYSkip;
   // Chroma buffers
   uint8_t* mCbChannel;
   uint8_t* mCrChannel;
   int32_t mCbCrStride;
-  gfxIntSize mCbCrSize;
+  LayerIntSize mCbCrSize;
   int32_t mCbSkip;
   int32_t mCrSkip;
   // Picture region
   uint32_t mPicX;
   uint32_t mPicY;
-  gfxIntSize mPicSize;
+  LayerIntSize mPicSize;
   StereoMode mStereoMode;
 
   nsIntRect GetPictureRect() const {
     return nsIntRect(mPicX, mPicY,
                      mPicSize.width,
                      mPicSize.height);
   }
 
--- a/gfx/layers/YCbCrImageDataSerializer.cpp
+++ b/gfx/layers/YCbCrImageDataSerializer.cpp
@@ -90,76 +90,76 @@ uint32_t YCbCrImageDataDeserializerBase:
 }
 
 uint32_t YCbCrImageDataDeserializerBase::GetCbCrStride()
 {
   YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
   return info->mCbCrWidth;
 }
 
-gfxIntSize YCbCrImageDataDeserializerBase::GetYSize()
+LayerIntSize YCbCrImageDataDeserializerBase::GetYSize()
 {
   YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
-  return gfxIntSize(info->mYWidth, info->mYHeight);
+  return LayerIntSize(info->mYWidth, info->mYHeight);
 }
 
-gfxIntSize YCbCrImageDataDeserializerBase::GetCbCrSize()
+LayerIntSize YCbCrImageDataDeserializerBase::GetCbCrSize()
 {
   YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
-  return gfxIntSize(info->mCbCrWidth, info->mCbCrHeight);
+  return LayerIntSize(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 gfx::IntSize& aYSize,
-                                               const gfx::IntSize& aCbCrSize)
+YCbCrImageDataSerializer::ComputeMinBufferSize(const LayerIntSize& aYSize,
+                                               const LayerIntSize& 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));
+  return ComputeMinBufferSize(LayerIntSize(aYSize.width, aYSize.height),
+                              LayerIntSize(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 gfx::IntSize& aYSize,
-                                               const gfx::IntSize& aCbCrSize,
+YCbCrImageDataSerializer::InitializeBufferInfo(const LayerIntSize& aYSize,
+                                               const LayerIntSize& 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);
@@ -171,34 +171,34 @@ YCbCrImageDataSerializer::InitializeBuff
   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),
+  InitializeBufferInfo(LayerIntSize(aYSize.width, aYSize.height),
+                       LayerIntSize(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,
-                                   gfxIntSize aYSize, uint32_t aYStride,
-                                   gfxIntSize aCbCrSize, uint32_t aCbCrStride,
+                                   LayerIntSize aYSize, uint32_t aYStride,
+                                   LayerIntSize 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
@@ -233,17 +233,17 @@ YCbCrImageDataSerializer::CopyData(const
   }
   return true;
 }
 
 TemporaryRef<gfx::DataSourceSurface>
 YCbCrImageDataDeserializer::ToDataSourceSurface()
 {
   RefPtr<gfx::DataSourceSurface> result =
-    gfx::Factory::CreateDataSourceSurface(ToIntSize(GetYSize()), gfx::FORMAT_R8G8B8X8);
+    gfx::Factory::CreateDataSourceSurface(GetYSize().ToUnknownSize(), 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,16 +8,17 @@
 
 #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 {
 
@@ -53,22 +54,22 @@ public:
   /**
    * Returns the stride of the Cb and Cr channels.
    */
   uint32_t GetCbCrStride();
 
   /**
    * Returns the dimensions of the Y Channel.
    */
-  gfxIntSize GetYSize();
+  LayerIntSize GetYSize();
 
   /**
    * Returns the dimensions of the Cb and Cr Channel.
    */
-  gfxIntSize GetCbCrSize();
+  LayerIntSize GetCbCrSize();
 
   /**
    * Stereo mode for the image.
    */
   StereoMode GetStereoMode();
 
   /**
    * Return a pointer to the begining of the data buffer.
@@ -98,38 +99,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 gfx::IntSize& aYSize,
-                                     const gfx::IntSize& aCbCrSize);
+  static size_t ComputeMinBufferSize(const LayerIntSize& aYSize,
+                                     const LayerIntSize& 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 gfx::IntSize& aYSize,
-                            const gfx::IntSize& aCbCrSize,
+  void InitializeBufferInfo(const LayerIntSize& aYSize,
+                            const LayerIntSize& 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,
-                gfxIntSize aYSize, uint32_t aYStride,
-                gfxIntSize aCbCrSize, uint32_t aCbCrStride,
+                LayerIntSize aYSize, uint32_t aYStride,
+                LayerIntSize 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;
-    gfx::IntSize size;
+    LayerIntSize 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), format);
+      new gfxImageSurface(ThebesIntSize(size.ToUnknownSize()), 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/BasicImages.cpp
+++ b/gfx/layers/basic/BasicImages.cpp
@@ -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();
 
-  gfx::IntSize size(mScaleHint);
+  LayerIntSize size(mScaleHint.width, mScaleHint.height);
   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;
+  mSize = size.ToUnknownSize();
 }
 
 static cairo_user_data_key_t imageSurfaceDataKey;
 
 static void
 DestroyBuffer(void* aBuffer)
 {
   delete[] static_cast<uint8_t*>(aBuffer);
--- 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);
-      gfx::IntSize ySize(data->mYSize.width, data->mYSize.height);
-      gfx::IntSize cbCrSize(data->mCbCrSize.width, data->mCbCrSize.height);
+      LayerIntSize ySize(data->mYSize.width, data->mYSize.height);
+      LayerIntSize 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 = aSize;
+  mSize = LayerIntSize(aSize.width, aSize.height);
   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(gfx::IntSize aYSize,
-                                      gfx::IntSize aCbCrSize,
+BufferTextureClient::AllocateForYCbCr(LayerIntSize aYSize,
+                                      LayerIntSize aCbCrSize,
                                       StereoMode aStereoMode)
 {
   MOZ_ASSERT(IsValid());
 
   size_t bufSize = YCbCrImageDataSerializer::ComputeMinBufferSize(aYSize,
                                                                   aCbCrSize);
   if (!Allocate(bufSize)) {
     return false;
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -19,16 +19,17 @@
 #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 {
 
@@ -61,18 +62,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(gfx::IntSize aYSize,
-                                gfx::IntSize aCbCrSize,
+  virtual bool AllocateForYCbCr(LayerIntSize aYSize,
+                                LayerIntSize 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
@@ -245,17 +246,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; }
+  virtual gfx::IntSize GetSize() const { return mSize.ToUnknownSize(); }
 
   // TextureClientSurface
 
   virtual TextureClientSurface* AsTextureClientSurface() MOZ_OVERRIDE { return this; }
 
   virtual bool UpdateSurface(gfxASurface* aSurface) MOZ_OVERRIDE;
 
   virtual already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
@@ -263,34 +264,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(gfx::IntSize aYSize,
-                                gfx::IntSize aCbCrSize,
+  virtual bool AllocateForYCbCr(LayerIntSize aYSize,
+                                LayerIntSize 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;
-  gfx::IntSize mSize;
+  LayerIntSize mSize;
 };
 
 /**
  * TextureClient that wraps shared memory.
  * the corresponding texture on the host side is ShmemTextureHost.
  */
 class ShmemTextureClient : public BufferTextureClient
 {
--- 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(),
-                                                    gfx::ToIntSize(yuvDeserializer.GetYSize()),
+                                                    yuvDeserializer.GetYSize().ToUnknownSize(),
                                                     gfx::FORMAT_A8);
     RefPtr<gfx::DataSourceSurface> tempCb =
       gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCbData(),
                                                     yuvDeserializer.GetCbCrStride(),
-                                                    gfx::ToIntSize(yuvDeserializer.GetCbCrSize()),
+                                                    yuvDeserializer.GetCbCrSize().ToUnknownSize(),
                                                     gfx::FORMAT_A8);
     RefPtr<gfx::DataSourceSurface> tempCr =
       gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCrData(),
                                                     yuvDeserializer.GetCbCrStride(),
-                                                    gfx::ToIntSize(yuvDeserializer.GetCbCrSize()),
+                                                    yuvDeserializer.GetCbCrSize().ToUnknownSize(),
                                                     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(),
-                                 yuvDeserializer.GetYSize(),
+                                 ThebesIntSize(yuvDeserializer.GetYSize().ToUnknownSize()),
                                  yuvDeserializer.GetYStride(),
                                  gfxImageFormatA8);
   } else {
     ImageDataDeserializer deserializer(GetBuffer());
     if (!deserializer.IsValid()) {
       return nullptr;
     }
     RefPtr<gfxImageSurface> surf = deserializer.GetAsThebesSurface();
--- 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>());
 
-  gfxIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
+  LayerIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
 
-  gfxIntSize size = yuvDeserializer.GetYSize();
+  LayerIntSize 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 = yuvDeserializer.GetCbCrSize().width;
-  desc.Height = yuvDeserializer.GetCbCrSize().height;
+  desc.Width = gfxCbCrSize.width;
+  desc.Height = gfxCbCrSize.height;
 
   mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[1]));
 
   initData.pSysMem = yuvDeserializer.GetCrData();
   mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[2]));
 
-  mSize = IntSize(size.width, size.height);
+  mSize = size.ToUnknownSize();
 }
 
 }
 }
--- a/gfx/layers/d3d9/TextureD3D9.cpp
+++ b/gfx/layers/d3d9/TextureD3D9.cpp
@@ -210,26 +210,26 @@ FinishTextures(IDirect3DDevice9* aDevice
     aTexture->UnlockRect(0);
   }
 }
 
 static TemporaryRef<IDirect3DTexture9>
 DataToTexture(IDirect3DDevice9 *aDevice,
               unsigned char *aData,
               int aStride,
-              const gfxIntSize &aSize,
+              const LayerIntSize &aSize,
               _D3DFORMAT aFormat,
               uint32_t aBPP)
 {
   RefPtr<IDirect3DTexture9> texture;
   RefPtr<IDirect3DSurface9> surface;
   D3DLOCKED_RECT lockedRect;
   bool usingD3D9Ex;
 
-  if (!InitTextures(aDevice, aSize, aFormat,
+  if (!InitTextures(aDevice, ThebesIntSize(aSize.ToUnknownSize()), 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,
@@ -280,34 +280,35 @@ 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(),
-                                 size, format, bpp);
+                                 LayerIntSize(size.width, size.height),
+                                 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(),
-                                       gfxIntSize(tileRect.width, tileRect.height),
+                                       LayerIntSize(tileRect.width, tileRect.height),
                                        format,
                                        bpp);
     }
   }
 }
 
 IntRect
 DeprecatedTextureHostD3D9::GetTileRect(uint32_t aID) const
@@ -342,19 +343,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>());
 
-  gfxIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
-  gfxIntSize size = yuvDeserializer.GetYSize();
-  mSize = IntSize(size.width, size.height);
+  LayerIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
+  LayerIntSize size = yuvDeserializer.GetYSize();
+  mSize = size.ToUnknownSize();
   mStereoMode = yuvDeserializer.GetStereoMode();
 
   mTextures[0] = DataToTexture(mDevice,
                                yuvDeserializer.GetYData(),
                                yuvDeserializer.GetYStride(),
                                size,
                                D3DFMT_L8, 1);
   mTextures[1] = DataToTexture(mDevice,
@@ -453,17 +454,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,
-                                       gfxIntSize(tileRect.width, tileRect.height),
+                                       LayerIntSize(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;
@@ -563,17 +564,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(),
-                                       gfxIntSize(tileRect.width, tileRect.height),
+                                       LayerIntSize(tileRect.width, tileRect.height),
                                        format,
                                        bpp);
     }
   }
 }
 
 DeprecatedTextureClientD3D9::DeprecatedTextureClientD3D9(CompositableForwarder* aCompositableForwarder,
                                      const TextureInfo& aTextureInfo)
--- 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;
+  mSize = mData.mPicSize.ToUnknownSize();
 
   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;
+  mSize = aData.mPicSize.ToUnknownSize();
   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;
+  mSize = mData.mPicSize.ToUnknownSize();
 
   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;
+  mSize = aData.mPicSize.ToUnknownSize();
   YCbCrImageDataSerializer serializer(mShmem.get<uint8_t>());
   serializer.InitializeBufferInfo(aData.mYSize,
                                   aData.mCbCrSize,
                                   aData.mStereoMode);
 }
 
 uint8_t* 
 DeprecatedSharedPlanarYCbCrImage::AllocateBuffer(uint32_t aSize)
--- a/gfx/layers/opengl/CanvasLayerOGL.cpp
+++ b/gfx/layers/opengl/CanvasLayerOGL.cpp
@@ -16,16 +16,17 @@
 #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"
@@ -379,23 +380,24 @@ CanvasLayerOGL::CleanupResources()
   if (mUploadTexture) {
     gl()->MakeCurrent();
     gl()->fDeleteTextures(1, &mUploadTexture);
     mUploadTexture = 0;
   }
 }
 
 gfxImageSurface*
-CanvasLayerOGL::GetTempSurface(const gfxIntSize& aSize,
+CanvasLayerOGL::GetTempSurface(const LayerIntSize& aSize,
                                const gfxImageFormat aFormat)
 {
   if (!mCachedTempSurface ||
       aSize.width != mCachedSize.width ||
       aSize.height != mCachedSize.height ||
       aFormat != mCachedFormat)
   {
-    mCachedTempSurface = new gfxImageSurface(aSize, aFormat);
+    mCachedTempSurface = new gfxImageSurface(ThebesIntSize(aSize.ToUnknownSize()),
+                                             aFormat);
     mCachedSize = aSize;
     mCachedFormat = aFormat;
   }
 
   return mCachedTempSurface;
 }
--- a/gfx/layers/opengl/CanvasLayerOGL.h
+++ b/gfx/layers/opengl/CanvasLayerOGL.h
@@ -6,17 +6,16 @@
 #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"
@@ -64,20 +63,20 @@ protected:
   bool mNeedsYFlip;
   bool mForceReadback;
   GLuint mUploadTexture;
 #if defined(GL_PROVIDER_GLX)
   GLXPixmap mPixmap;
 #endif
 
   nsRefPtr<gfxImageSurface> mCachedTempSurface;
-  gfxIntSize mCachedSize;
+  LayerIntSize mCachedSize;
   gfxImageFormat mCachedFormat;
 
-  gfxImageSurface* GetTempSurface(const gfxIntSize& aSize,
+  gfxImageSurface* GetTempSurface(const LayerIntSize& aSize,
                                   const gfxImageFormat aFormat);
 
   void DiscardTempSurface() {
     mCachedTempSurface = nullptr;
   }
 };
 
 } /* layers */
--- a/gfx/layers/opengl/GrallocTextureClient.cpp
+++ b/gfx/layers/opengl/GrallocTextureClient.cpp
@@ -218,20 +218,22 @@ GrallocTextureClientOGL::AllocateForSurf
     NS_WARNING("Unsupported surface format");
     return false;
   }
 
   return AllocateGralloc(aSize, format, usage);
 }
 
 bool
-GrallocTextureClientOGL::AllocateForYCbCr(gfx::IntSize aYSize, gfx::IntSize aCbCrSize, StereoMode aStereoMode)
+GrallocTextureClientOGL::AllocateForYCbCr(LayerIntSize aYSize,
+                                          LayerIntSize aCbCrSize,
+                                          StereoMode aStereoMode)
 {
   MOZ_ASSERT(IsValid());
-  return AllocateGralloc(aYSize,
+  return AllocateGralloc(aYSize.ToUnknownSize(),
                          HAL_PIXEL_FORMAT_YV12,
                          android::GraphicBuffer::USAGE_SW_READ_OFTEN);
 }
 
 bool
 GrallocTextureClientOGL::AllocateGralloc(gfx::IntSize aSize,
                                          uint32_t aAndroidFormat,
                                          uint32_t aUsage)
--- 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(gfx::IntSize aYSize,
-                                gfx::IntSize aCbCrSize,
+  virtual bool AllocateForYCbCr(LayerIntSize aYSize,
+                                LayerIntSize 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,16 +22,17 @@
 #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;
 
@@ -135,32 +136,32 @@ GLTexture::Release()
 
 TextureRecycleBin::TextureRecycleBin()
   : mLock("mozilla.layers.TextureRecycleBin.mLock")
 {
 }
 
 void
 TextureRecycleBin::RecycleTexture(GLTexture *aTexture, TextureType aType,
-                           const gfxIntSize& aSize)
+                           const LayerIntSize& 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 gfxIntSize& aSize,
+TextureRecycleBin::GetTexture(TextureType aType, const LayerIntSize& aSize,
                        GLContext *aContext, GLTexture *aOutTexture)
 {
   MutexAutoLock lock(mLock);
 
   if (mRecycledTextures[aType].IsEmpty() || mRecycledTextureSizes[aType] != aSize) {
     aOutTexture->Allocate(aContext);
     return;
   }
@@ -394,32 +395,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,
-                                                   aData.mYSize,
+                                                   ThebesIntSize(aData.mYSize.ToUnknownSize()),
                                                    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,
-                             aData.mCbCrSize,
+                             ThebesIntSize(aData.mCbCrSize.ToUnknownSize()),
                              aData.mCbCrStride,
                              gfxImageFormatA8);
   gl->UploadSurfaceToTexture(surf, size, texture, true);
 
   texture = aVTexture->GetTextureID();
   surf = new gfxImageSurface(aData.mCrChannel,
-                             aData.mCbCrSize,
+                             ThebesIntSize(aData.mCbCrSize.ToUnknownSize()),
                              aData.mCbCrStride,
                              gfxImageFormatA8);
   gl->UploadSurfaceToTexture(surf, size, texture, true);
 }
 
 ImageLayerOGL::ImageLayerOGL(LayerManagerOGL *aManager)
   : ImageLayer(aManager, nullptr)
   , LayerOGL(aManager)
--- a/gfx/layers/opengl/ImageLayerOGL.h
+++ b/gfx/layers/opengl/ImageLayerOGL.h
@@ -5,17 +5,16 @@
 
 #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
 
@@ -84,29 +83,29 @@ public:
   TextureRecycleBin();
 
   enum TextureType {
     TEXTURE_Y,
     TEXTURE_C
   };
 
   void RecycleTexture(GLTexture *aTexture, TextureType aType,
-                      const gfxIntSize& aSize);
-  void GetTexture(TextureType aType, const gfxIntSize& aSize,
+                      const LayerIntSize& aSize);
+  void GetTexture(TextureType aType, const LayerIntSize& aSize,
                   GLContext *aContext, GLTexture *aOutTexture);
 
 private:
   typedef mozilla::Mutex Mutex;
 
   // This protects mRecycledBuffers, mRecycledBufferSize, mRecycledTextures
   // and mRecycledTextureSizes
   Mutex mLock;
 
   nsTArray<GLTexture> mRecycledTextures[2];
-  gfxIntSize mRecycledTextureSizes[2];
+  LayerIntSize mRecycledTextureSizes[2];
 };
 
 class ImageLayerOGL : public ImageLayer,
                       public LayerOGL
 {
 public:
   ImageLayerOGL(LayerManagerOGL *aManager);
   ~ImageLayerOGL() { Destroy(); }
@@ -141,17 +140,17 @@ struct PlanarYCbCrOGLBackendData : publi
 
   bool HasTextures()
   {
     return mTextures[0].IsAllocated() && mTextures[1].IsAllocated() &&
            mTextures[2].IsAllocated();
   }
 
   GLTexture mTextures[3];
-  gfxIntSize mYSize, mCbCrSize;
+  LayerIntSize mYSize, mCbCrSize;
   nsRefPtr<TextureRecycleBin> mTextureRecycleBin;
 };
 
 
 struct CairoOGLBackendData : public ImageBackendData
 {
   CairoOGLBackendData() : mLayerProgram(RGBALayerProgramType) {}
   GLTexture mTexture;
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -841,18 +841,18 @@ YCbCrDeprecatedTextureHostOGL::UpdateImp
 {
   if (!mGL) {
     return;
   }
   NS_ASSERTION(aImage.type() == SurfaceDescriptor::TYCbCrImage, "SurfaceDescriptor mismatch");
 
   YCbCrImageDataDeserializer deserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
 
-  gfxIntSize gfxSize = deserializer.GetYSize();
-  gfxIntSize gfxCbCrSize = deserializer.GetCbCrSize();
+  gfxIntSize gfxSize = ThebesIntSize(deserializer.GetYSize().ToUnknownSize());
+  gfxIntSize gfxCbCrSize = ThebesIntSize(deserializer.GetCbCrSize().ToUnknownSize());
 
   if (!mYTexture->mTexImage || mYTexture->mTexImage->GetSize() != gfxSize) {
     mYTexture->mTexImage = CreateBasicTextureImage(mGL,
                                                    gfxSize,
                                                    GFX_CONTENT_ALPHA,
                                                    WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
                                                    FlagsToGLFlags(mFlags));
   }
--- 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(ToIntSize(ycbcrData.mYSize),
-                            ToIntSize(ycbcrData.mCbCrSize),
+  texture->AllocateForYCbCr(ycbcrData.mYSize,
+                            ycbcrData.mCbCrSize,
                             ycbcrData.mStereoMode);
   ASSERT_TRUE(client->IsAllocated());
 
   // client painting
   texture->UpdateYCbCr(ycbcrData);
 
   ASSERT_TRUE(client->Lock(OPEN_READ_ONLY));
   client->Unlock();
@@ -244,19 +244,22 @@ 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 = ySurface->GetSize();
-  clientData.mPicSize = ySurface->GetSize();
-  clientData.mCbCrSize = cbSurface->GetSize();
+  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.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/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,
-                                         gfx::IntSize& aSuggestedSize)
+                                         LayerIntSize& 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 gfx::IntSize& aDestSize,
+                            const LayerIntSize& 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,16 +4,17 @@
  * 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;
@@ -129,27 +130,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::gfx::IntSize& aSuggestedSize);
+                                   mozilla::LayerIntSize& 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::gfx::IntSize& aDestSize,
+                      const mozilla::LayerIntSize& 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/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -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 = gfxIntSize(width_, height_);
+  data.mYSize = LayerIntSize(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 = gfxIntSize(width_/ 2, height_/ 2);
+  data.mCbCrSize = LayerIntSize(width_/ 2, height_/ 2);
   data.mPicX = 0;
   data.mPicY = 0;
-  data.mPicSize = gfxIntSize(width_, height_);
+  data.mPicSize = LayerIntSize(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,16 +34,17 @@ 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 {
@@ -126,25 +127,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 = gfxIntSize(WIDTH, HEIGHT);
+    data.mYSize = mozilla::LayerIntSize(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 = gfxIntSize(WIDTH / 2, HEIGHT / 2);
+    data.mCbCrSize = mozilla::LayerIntSize(WIDTH / 2, HEIGHT / 2);
     data.mPicX = 0;
     data.mPicY = 0;
-    data.mPicSize = gfxIntSize(WIDTH, HEIGHT);
+    data.mPicSize = mozilla::LayerIntSize(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();