Bug 1239530 (part 2) - Use LayoutDevice coordinates in {Start,End}RemoteDrawingInRegion() and related functions. r=kats.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 02 Dec 2015 22:29:54 -0800
changeset 280121 8cdc38ea4f6da3f5585c1525e29299a86ad89866
parent 280120 64fd6e1c4fc16f434417634f96041bdfd080640a
child 280122 3f8b80d42f00d37a6fe6a36039b1db8be75339c6
push id17038
push usercbook@mozilla.com
push dateFri, 15 Jan 2016 10:50:02 +0000
treeherderfx-team@5fb09f6e31fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1239530
milestone46.0a1
Bug 1239530 (part 2) - Use LayoutDevice coordinates in {Start,End}RemoteDrawingInRegion() and related functions. r=kats.
gfx/layers/Compositor.h
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicCompositor.h
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/CompositorD3D11.h
gfx/layers/d3d9/CompositorD3D9.cpp
gfx/layers/d3d9/CompositorD3D9.h
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/CompositorOGL.h
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
widget/gtk/nsWindow.cpp
widget/gtk/nsWindow.h
widget/nsIWidget.h
widget/nsShmImage.cpp
widget/nsShmImage.h
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -527,17 +527,17 @@ protected:
    * current frame. This value is an approximation and is not accurate,
    * especially in the presence of transforms.
    */
   size_t mPixelsPerFrame;
   size_t mPixelsFilled;
 
   ScreenRotation mScreenRotation;
 
-  virtual gfx::IntSize GetWidgetSize() const = 0;
+  virtual LayoutDeviceIntSize GetWidgetSize() const = 0;
 
   RefPtr<gfx::DrawTarget> mTarget;
   gfx::IntRect mTargetBounds;
 
 #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
   FenceHandle mReleaseFenceHandle;
 #endif
 
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -515,29 +515,30 @@ BasicCompositor::ClearRect(const gfx::Re
 
 void
 BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
                             const gfx::Rect *aClipRectIn,
                             const gfx::Rect& aRenderBounds,
                             gfx::Rect *aClipRectOut /* = nullptr */,
                             gfx::Rect *aRenderBoundsOut /* = nullptr */)
 {
-  mWidgetSize = mWidget->GetClientSize().ToUnknownSize();
-  IntRect intRect = gfx::IntRect(IntPoint(), mWidgetSize);
+  mWidgetSize = mWidget->GetClientSize();
+  LayoutDeviceIntRect intRect(LayoutDeviceIntPoint(), mWidgetSize);
   Rect rect = Rect(0, 0, intRect.width, intRect.height);
 
-  nsIntRegion invalidRegionSafe;
+  LayoutDeviceIntRegion invalidRegionSafe;
   if (mDidExternalComposition) {
     // We do not know rendered region during external composition, just redraw
     // whole widget.
     invalidRegionSafe = intRect;
     mDidExternalComposition = false;
   } else {
     // Sometimes the invalid region is larger than we want to draw.
-    invalidRegionSafe.And(aInvalidRegion, intRect);
+    invalidRegionSafe.And(
+      LayoutDeviceIntRegion::FromUnknownRegion(aInvalidRegion), intRect);
   }
 
   mInvalidRegion = invalidRegionSafe;
   mInvalidRect = mInvalidRegion.GetBounds();
 
   if (aRenderBoundsOut) {
     *aRenderBoundsOut = Rect();
   }
@@ -557,31 +558,33 @@ BasicCompositor::BeginFrame(const nsIntR
   }
 
   if (!mDrawTarget || mInvalidRect.IsEmpty()) {
     return;
   }
 
   // Setup an intermediate render target to buffer all compositing. We will
   // copy this into mDrawTarget (the widget), and/or mTarget in EndFrame()
-  RefPtr<CompositingRenderTarget> target = CreateRenderTarget(mInvalidRect, INIT_MODE_CLEAR);
+  RefPtr<CompositingRenderTarget> target =
+    CreateRenderTarget(mInvalidRect.ToUnknownRect(), INIT_MODE_CLEAR);
   if (!target) {
     if (!mTarget) {
       mWidget->EndRemoteDrawingInRegion(mDrawTarget, mInvalidRegion);
     }
     return;
   }
   SetRenderTarget(target);
 
   // We only allocate a surface sized to the invalidated region, so we need to
   // translate future coordinates.
   mRenderTarget->mDrawTarget->SetTransform(Matrix::Translation(-mInvalidRect.x,
                                                                -mInvalidRect.y));
 
-  gfxUtils::ClipToRegion(mRenderTarget->mDrawTarget, mInvalidRegion);
+  gfxUtils::ClipToRegion(mRenderTarget->mDrawTarget,
+                         mInvalidRegion.ToUnknownRegion());
 
   if (aRenderBoundsOut) {
     *aRenderBoundsOut = rect;
   }
 
   if (aClipRectIn) {
     mRenderTarget->mDrawTarget->PushClipRect(*aClipRectIn);
   } else {
@@ -598,35 +601,36 @@ BasicCompositor::EndFrame()
   // Pop aClipRectIn/bounds rect
   mRenderTarget->mDrawTarget->PopClip();
 
   if (gfxPrefs::WidgetUpdateFlashing()) {
     float r = float(rand()) / RAND_MAX;
     float g = float(rand()) / RAND_MAX;
     float b = float(rand()) / RAND_MAX;
     // We're still clipped to mInvalidRegion, so just fill the bounds.
-    mRenderTarget->mDrawTarget->FillRect(IntRectToRect(mInvalidRegion.GetBounds()),
-                                         ColorPattern(Color(r, g, b, 0.2f)));
+    mRenderTarget->mDrawTarget->FillRect(
+      IntRectToRect(mInvalidRegion.GetBounds()).ToUnknownRect(),
+      ColorPattern(Color(r, g, b, 0.2f)));
   }
 
   // Pop aInvalidregion
   mRenderTarget->mDrawTarget->PopClip();
 
   // Note: Most platforms require us to buffer drawing to the widget surface.
   // That's why we don't draw to mDrawTarget directly.
   RefPtr<SourceSurface> source = mRenderTarget->mDrawTarget->Snapshot();
   RefPtr<DrawTarget> dest(mTarget ? mTarget : mDrawTarget);
 
   nsIntPoint offset = mTarget ? mTargetBounds.TopLeft() : nsIntPoint();
 
   // The source DrawTarget is clipped to the invalidation region, so we have
   // to copy the individual rectangles in the region or else we'll draw blank
   // pixels.
-  nsIntRegionRectIterator iter(mInvalidRegion);
-  for (const IntRect *r = iter.Next(); r; r = iter.Next()) {
+  LayoutDeviceIntRegion::RectIterator iter(mInvalidRegion);
+  for (const LayoutDeviceIntRect *r = iter.Next(); r; r = iter.Next()) {
     dest->CopySurface(source,
                       IntRect(r->x - mInvalidRect.x, r->y - mInvalidRect.y, r->width, r->height),
                       IntPoint(r->x - offset.x, r->y - offset.y));
   }
   if (!mTarget) {
     mWidget->EndRemoteDrawingInRegion(mDrawTarget, mInvalidRegion);
   }
 
--- a/gfx/layers/basic/BasicCompositor.h
+++ b/gfx/layers/basic/BasicCompositor.h
@@ -111,29 +111,29 @@ public:
   }
 
   virtual nsIWidget* GetWidget() const override { return mWidget; }
 
   gfx::DrawTarget *GetDrawTarget() { return mDrawTarget; }
 
 private:
 
-  virtual gfx::IntSize GetWidgetSize() const override { return mWidgetSize; }
+  virtual LayoutDeviceIntSize GetWidgetSize() const override { return mWidgetSize; }
 
   // Widget associated with this compositor
   nsIWidget *mWidget;
-  gfx::IntSize mWidgetSize;
+  LayoutDeviceIntSize mWidgetSize;
 
   // The final destination surface
   RefPtr<gfx::DrawTarget> mDrawTarget;
   // The current render target for drawing
   RefPtr<BasicCompositingRenderTarget> mRenderTarget;
 
-  gfx::IntRect mInvalidRect;
-  nsIntRegion mInvalidRegion;
+  LayoutDeviceIntRect mInvalidRect;
+  LayoutDeviceIntRegion mInvalidRegion;
   bool mDidExternalComposition;
 
   uint32_t mMaxTextureSize;
 };
 
 } // namespace layers
 } // namespace mozilla
 
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -1032,33 +1032,33 @@ CompositorD3D11::BeginFrame(const nsIntR
   // this is important because resizing our buffers when mimised will fail and
   // cause a crash when we're restored.
   NS_ASSERTION(mHwnd, "Couldn't find an HWND when initialising?");
   if (::IsIconic(mHwnd) || mDevice->GetDeviceRemovedReason() != S_OK) {
     *aRenderBoundsOut = Rect();
     return;
   }
 
-  IntSize oldSize = mSize;
+  LayoutDeviceIntSize oldSize = mSize;
 
   // Failed to create a render target or the view.
   if (!UpdateRenderTarget() || !mDefaultRT || !mDefaultRT->mRTView ||
       mSize.width <= 0 || mSize.height <= 0) {
     *aRenderBoundsOut = Rect();
     return;
   }
 
   mContext->IASetInputLayout(mAttachments->mInputLayout);
 
   ID3D11Buffer* buffer = mAttachments->mVertexBuffer;
   UINT size = sizeof(Vertex);
   UINT offset = 0;
   mContext->IASetVertexBuffers(0, 1, &buffer, &size, &offset);
 
-  IntRect intRect = IntRect(IntPoint(0, 0), mSize);
+  IntRect intRect = IntRect(IntPoint(0, 0), mSize.ToUnknownSize());
   // Sometimes the invalid region is larger than we want to draw.
   nsIntRegion invalidRegionSafe;
 
   if (mSize != oldSize) {
     invalidRegionSafe = intRect;
   } else {
     invalidRegionSafe.And(aInvalidRegion, intRect);
   }
@@ -1103,17 +1103,17 @@ CompositorD3D11::BeginFrame(const nsIntR
 
 void
 CompositorD3D11::EndFrame()
 {
   if (!mDefaultRT) {
     return;
   }
 
-  IntSize oldSize = mSize;
+  LayoutDeviceIntSize oldSize = mSize;
   EnsureSize();
   if (mSize.width <= 0 || mSize.height <= 0) {
     return;
   }
 
   UINT presentInterval = 0;
 
   if (gfxWindowsPlatform::GetPlatform()->IsWARP()) {
@@ -1201,17 +1201,17 @@ CompositorD3D11::PrepareViewport(const g
 }
 
 void
 CompositorD3D11::EnsureSize()
 {
   LayoutDeviceIntRect rect;
   mWidget->GetClientBounds(rect);
 
-  mSize = rect.Size().ToUnknownSize();
+  mSize = rect.Size();
 }
 
 bool
 CompositorD3D11::VerifyBufferSize()
 {
   DXGI_SWAP_CHAIN_DESC swapDesc;
   HRESULT hr;
 
@@ -1317,17 +1317,17 @@ CompositorD3D11::UpdateRenderTarget()
   }
   if (FAILED(hr)) {
     gfxCriticalNote << "Failed in UpdateRenderTarget " << hexa(hr) << ", " << mSize << ", " << (int)mVerifyBuffersFailed;
     HandleError(hr);
     return false;
   }
 
   mDefaultRT = new CompositingRenderTargetD3D11(backBuf, IntPoint(0, 0));
-  mDefaultRT->SetSize(mSize);
+  mDefaultRT->SetSize(mSize.ToUnknownSize());
 
   return true;
 }
 
 bool
 DeviceAttachmentsD3D11::InitSyncObject()
 {
   // Sync object is not supported on WARP.
--- a/gfx/layers/d3d11/CompositorD3D11.h
+++ b/gfx/layers/d3d11/CompositorD3D11.h
@@ -166,29 +166,29 @@ private:
   void EnsureSize();
   bool VerifyBufferSize();
   bool UpdateRenderTarget();
   bool UpdateConstantBuffers();
   void SetSamplerForFilter(gfx::Filter aFilter);
   void SetPSForEffect(Effect *aEffect, MaskType aMaskType, gfx::SurfaceFormat aFormat);
   void PaintToTarget();
 
-  virtual gfx::IntSize GetWidgetSize() const override { return mSize; }
+  virtual LayoutDeviceIntSize GetWidgetSize() const override { return mSize; }
 
   RefPtr<ID3D11DeviceContext> mContext;
   RefPtr<ID3D11Device> mDevice;
   RefPtr<IDXGISwapChain> mSwapChain;
   RefPtr<CompositingRenderTargetD3D11> mDefaultRT;
   RefPtr<CompositingRenderTargetD3D11> mCurrentRT;
 
   DeviceAttachmentsD3D11* mAttachments;
 
   nsIWidget* mWidget;
 
-  gfx::IntSize mSize;
+  LayoutDeviceIntSize mSize;
 
   HWND mHwnd;
 
   D3D_FEATURE_LEVEL mFeatureLevel;
 
   VertexShaderConstants mVSConstants;
   PixelShaderConstants mPSConstants;
   bool mDisableSequenceForNextFrame;
--- a/gfx/layers/d3d9/CompositorD3D9.cpp
+++ b/gfx/layers/d3d9/CompositorD3D9.cpp
@@ -658,17 +658,17 @@ CompositorD3D9::BeginFrame(const nsIntRe
 }
 
 void
 CompositorD3D9::EndFrame()
 {
   if (mDeviceManager) {
     device()->EndScene();
 
-    IntSize oldSize = mSize;
+    LayoutDeviceIntSize oldSize = mSize;
     EnsureSize();
     if (oldSize == mSize) {
       if (mTarget) {
         PaintToTarget();
       } else {
         mSwapChain->Present();
       }
     }
@@ -700,17 +700,17 @@ CompositorD3D9::PrepareViewport(const gf
 }
 
 void
 CompositorD3D9::EnsureSize()
 {
   LayoutDeviceIntRect rect;
   mWidget->GetClientBounds(rect);
 
-  mSize = rect.Size().ToUnknownSize();
+  mSize = rect.Size();
 }
 
 void
 CompositorD3D9::SetSamplerForFilter(Filter aFilter)
 {
   switch (aFilter) {
   case Filter::LINEAR:
     device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
--- a/gfx/layers/d3d9/CompositorD3D9.h
+++ b/gfx/layers/d3d9/CompositorD3D9.h
@@ -147,34 +147,34 @@ private:
    * the cpp file).
    */
   void CheckResetCount();
 
   void FailedToResetDevice();
 
   void ReportFailure(const nsACString &aMsg, HRESULT aCode);
 
-  virtual gfx::IntSize GetWidgetSize() const override
+  virtual LayoutDeviceIntSize GetWidgetSize() const override
   {
     return mSize;
   }
 
   /* Device manager instance for this compositor */
   RefPtr<DeviceManagerD3D9> mDeviceManager;
 
   /* Swap chain associated with this compositor */
   RefPtr<SwapChainD3D9> mSwapChain;
 
   /* Widget associated with this layer manager */
   nsIWidget *mWidget;
 
   RefPtr<CompositingRenderTargetD3D9> mDefaultRT;
   RefPtr<CompositingRenderTargetD3D9> mCurrentRT;
 
-  gfx::IntSize mSize;
+  LayoutDeviceIntSize mSize;
 
   uint32_t mDeviceResetCount;
   uint32_t mFailedResetAttempts;
 };
 
 }
 }
 
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -674,18 +674,19 @@ CompositorOGL::BeginFrame(const nsIntReg
                                  LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA);
   mGLContext->fEnable(LOCAL_GL_BLEND);
 
   // Make sure SCISSOR is enabled before setting the render target, since the RT
   // assumes scissor is enabled while it does clears.
   mGLContext->fEnable(LOCAL_GL_SCISSOR_TEST);
 
   // Prefer the native windowing system's provided window size for the viewport.
-  IntSize viewportSize = mGLContext->GetTargetSize().valueOr(mWidgetSize);
-  if (viewportSize != mWidgetSize) {
+  IntSize viewportSize =
+    mGLContext->GetTargetSize().valueOr(mWidgetSize.ToUnknownSize());
+  if (viewportSize != mWidgetSize.ToUnknownSize()) {
     mGLContext->fScissor(0, 0, viewportSize.width, viewportSize.height);
   }
 
   RefPtr<CompositingRenderTargetOGL> rt =
     CompositingRenderTargetOGL::RenderTargetForWindow(this, viewportSize);
   SetRenderTarget(rt);
 
 #ifdef DEBUG
--- a/gfx/layers/opengl/CompositorOGL.h
+++ b/gfx/layers/opengl/CompositorOGL.h
@@ -300,17 +300,17 @@ public:
     return gfx::IntSize (mSurfaceSize.width, mSurfaceSize.height);
   }
 
   const ScreenPoint& GetScreenRenderOffset() const {
     return mRenderOffset;
   }
 
 private:
-  virtual gfx::IntSize GetWidgetSize() const override
+  virtual LayoutDeviceIntSize GetWidgetSize() const override
   {
     return mWidgetSize;
   }
 
   bool InitializeVR();
   void DestroyVR(GLContext *gl);
 
   void DrawVRDistortion(const gfx::Rect& aRect,
@@ -318,17 +318,17 @@ private:
                         const EffectChain& aEffectChain,
                         gfx::Float aOpacity,
                         const gfx::Matrix4x4& aTransform);
 
   void PrepareViewport(CompositingRenderTargetOGL *aRenderTarget);
 
   /** Widget associated with this compositor */
   nsIWidget *mWidget;
-  gfx::IntSize mWidgetSize;
+  LayoutDeviceIntSize mWidgetSize;
   RefPtr<GLContext> mGLContext;
   UniquePtr<GLBlitTextureImageHelper> mBlitTextureImageHelper;
   gfx::Matrix4x4 mProjMatrix;
 
   /** The size of the surface we are rendering to */
   gfx::IntSize mSurfaceSize;
 
   ScreenPoint mRenderOffset;
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -539,17 +539,17 @@ public:
   // to DevPixelsToCocoaPoints().
   NSRect            UntypedDevPixelsToCocoaPoints(const nsIntRect& aRect) const {
     return nsCocoaUtils::UntypedDevPixelsToCocoaPoints(aRect, BackingScaleFactor());
   }
   NSRect            DevPixelsToCocoaPoints(const LayoutDeviceIntRect& aRect) const {
     return nsCocoaUtils::DevPixelsToCocoaPoints(aRect, BackingScaleFactor());
   }
 
-  already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion) override;
+  already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion) override;
   void EndRemoteDrawing() override;
   void CleanupRemoteDrawing() override;
   bool InitCompositor(mozilla::layers::Compositor* aCompositor) override;
 
   APZCTreeManager* APZCTM() { return mAPZC ; }
 
   NS_IMETHOD StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
                             int32_t aPanelX, int32_t aPanelY,
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2632,46 +2632,46 @@ nsChildView::TrackScrollEventAsSwipe(con
 
 void
 nsChildView::SwipeFinished()
 {
   mSwipeTracker = nullptr;
 }
 
 already_AddRefed<gfx::DrawTarget>
-nsChildView::StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion)
+nsChildView::StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion)
 {
   // should have created the GLPresenter in InitCompositor.
   MOZ_ASSERT(mGLPresenter);
   if (!mGLPresenter) {
     mGLPresenter = GLPresenter::CreateForWindow(this);
 
     if (!mGLPresenter) {
       return nullptr;
     }
   }
 
-  LayoutDeviceIntRegion dirtyRegion(LayoutDeviceIntRegion::FromUnknownRegion(aInvalidRegion));
+  LayoutDeviceIntRegion dirtyRegion(aInvalidRegion);
   LayoutDeviceIntSize renderSize =
     LayoutDeviceIntSize::FromUnknownSize(mBounds.Size());
 
   if (!mBasicCompositorImage) {
     mBasicCompositorImage = new RectTextureImage(mGLPresenter->gl());
   }
 
   RefPtr<gfx::DrawTarget> drawTarget =
     mBasicCompositorImage->BeginUpdate(renderSize, dirtyRegion);
 
   if (!drawTarget) {
     // Composite unchanged textures.
     DoRemoteComposition(LayoutDeviceIntRect::FromUnknownRect(mBounds));
     return nullptr;
   }
 
-  aInvalidRegion = mBasicCompositorImage->GetUpdateRegion().ToUnknownRegion();
+  aInvalidRegion = mBasicCompositorImage->GetUpdateRegion();
 
   return drawTarget.forget();
 }
 
 void
 nsChildView::EndRemoteDrawing()
 {
   mBasicCompositorImage->EndUpdate(true);
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2223,17 +2223,17 @@ nsWindow::OnExposeEvent(cairo_t *cr)
 
     // If this widget uses OMTC...
     if (GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
         listener->PaintWindow(this, region);
         listener->DidPaintWindow();
         return TRUE;
     }
 
-    RefPtr<DrawTarget> dt = GetDrawTarget(region.ToUnknownRegion());
+    RefPtr<DrawTarget> dt = GetDrawTarget(region);
     if (!dt) {
         return FALSE;
     }
     RefPtr<gfxContext> ctx;
 
 #ifdef MOZ_X11
     nsIntRect boundsRect; // for shaped only
 
@@ -2307,17 +2307,17 @@ nsWindow::OnExposeEvent(cairo_t *cr)
         }
     }
 
     ctx = nullptr;
     dt->PopClip();
 
 #  ifdef MOZ_HAVE_SHMIMAGE
     if (mShmImage && MOZ_LIKELY(!mIsDestroyed)) {
-      mShmImage->Put(mXDisplay, mXWindow, region.ToUnknownRegion());
+      mShmImage->Put(mXDisplay, mXWindow, region);
     }
 #  endif  // MOZ_HAVE_SHMIMAGE
 #endif // MOZ_X11
 
     listener->DidPaintWindow();
 
     // Synchronously flush any new dirty areas
 #if (MOZ_WIDGET_GTK == 2)
@@ -6457,57 +6457,57 @@ nsWindow::GetSurfaceForGdkDrawable(GdkDr
                                     IntSize(aSize.width, aSize.height));
     }
 
     return result.forget();
 }
 #endif
 
 already_AddRefed<DrawTarget>
-nsWindow::GetDrawTarget(const nsIntRegion& aRegion)
+nsWindow::GetDrawTarget(const LayoutDeviceIntRegion& aRegion)
 {
   if (!mGdkWindow) {
     return nullptr;
   }
 
-  nsIntRect bounds = aRegion.GetBounds();
-  IntSize size(bounds.XMost(), bounds.YMost());
+  LayoutDeviceIntRect bounds = aRegion.GetBounds();
+  LayoutDeviceIntSize size(bounds.XMost(), bounds.YMost());
   if (size.width <= 0 || size.height <= 0) {
     return nullptr;
   }
 
   RefPtr<DrawTarget> dt;
 
 #ifdef MOZ_X11
 #  ifdef MOZ_HAVE_SHMIMAGE
   if (nsShmImage::UseShm()) {
     dt = nsShmImage::EnsureShmImage(size,
-                                    mXDisplay, mXVisual, mXDepth,
-                                    mShmImage);
+                                    mXDisplay, mXVisual, mXDepth, mShmImage);
   }
 #  endif  // MOZ_HAVE_SHMIMAGE
   if (!dt) {
-    RefPtr<gfxXlibSurface> surf = new gfxXlibSurface(mXDisplay, mXWindow, mXVisual, size);
+    RefPtr<gfxXlibSurface> surf = new gfxXlibSurface(mXDisplay, mXWindow, mXVisual, size.ToUnknownSize());
     if (!surf->CairoStatus()) {
       dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(surf.get(), surf->GetSize());
     }
   }
 #endif // MOZ_X11
 
   return dt.forget();
 }
 
 already_AddRefed<DrawTarget>
-nsWindow::StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion)
+nsWindow::StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion)
 {
   return GetDrawTarget(aInvalidRegion);
 }
 
 void
-nsWindow::EndRemoteDrawingInRegion(DrawTarget* aDrawTarget, nsIntRegion& aInvalidRegion)
+nsWindow::EndRemoteDrawingInRegion(DrawTarget* aDrawTarget,
+                                   LayoutDeviceIntRegion& aInvalidRegion)
 {
 #ifdef MOZ_X11
 #  ifdef MOZ_HAVE_SHMIMAGE
   if (!mGdkWindow || !mShmImage) {
     return;
   }
 
   mShmImage->Put(mXDisplay, mXWindow, aInvalidRegion);
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -210,19 +210,19 @@ public:
                                                gpointer         aData);
     gboolean           OnPropertyNotifyEvent(GtkWidget *aWidget,
                                              GdkEventProperty *aEvent);
 #if GTK_CHECK_VERSION(3,4,0)
     gboolean           OnTouchEvent(GdkEventTouch* aEvent);
 #endif
 
     virtual already_AddRefed<mozilla::gfx::DrawTarget>
-                       StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion) override;
+                       StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion) override;
     virtual void       EndRemoteDrawingInRegion(mozilla::gfx::DrawTarget* aDrawTarget,
-                                                nsIntRegion& aInvalidRegion) override;
+                                                LayoutDeviceIntRegion& aInvalidRegion) override;
 
 private:
     void               UpdateAlpha(mozilla::gfx::SourceSurface* aSourceSurface, nsIntRect aBoundsRect);
 
     void               NativeMove();
     void               NativeResize();
     void               NativeMoveResize();
 
@@ -303,17 +303,17 @@ public:
     void               ApplyTransparencyBitmap();
     void               ClearTransparencyBitmap();
 
    virtual void        SetTransparencyMode(nsTransparencyMode aMode) override;
    virtual nsTransparencyMode GetTransparencyMode() override;
    virtual nsresult    ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
    nsresult            UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect,
                                                             uint8_t* aAlphas, int32_t aStride);
-    virtual already_AddRefed<mozilla::gfx::DrawTarget> GetDrawTarget(const nsIntRegion& aRegion);
+    virtual already_AddRefed<mozilla::gfx::DrawTarget> GetDrawTarget(const LayoutDeviceIntRegion& aRegion);
 
 #if (MOZ_WIDGET_GTK == 2)
     static already_AddRefed<gfxASurface> GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,
                                                                   const nsIntSize& aSize);
 #endif
     NS_IMETHOD         ReparentNativeWidget(nsIWidget* aNewParent) override;
 
     virtual nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -1283,29 +1283,29 @@ class nsIWidget : public nsISupports {
 
     /**
      * Return a DrawTarget for the window which can be composited into.
      *
      * Called by BasicCompositor on the compositor thread for OMTC drawing
      * before each composition.
      */
     virtual already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawing() = 0;
-    virtual already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion) {
+    virtual already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion) {
       return StartRemoteDrawing();
     }
 
     /**
      * Ensure that what was painted into the DrawTarget returned from
      * StartRemoteDrawing reaches the screen.
      *
      * Called by BasicCompositor on the compositor thread for OMTC drawing
      * after each composition.
      */
     virtual void EndRemoteDrawing() = 0;
-    virtual void EndRemoteDrawingInRegion(mozilla::gfx::DrawTarget* aDrawTarget, nsIntRegion& aInvalidRegion) {
+    virtual void EndRemoteDrawingInRegion(mozilla::gfx::DrawTarget* aDrawTarget, LayoutDeviceIntRegion& aInvalidRegion) {
       EndRemoteDrawing();
     }
 
     /**
      * A hook for the widget to prepare a Compositor, during the latter's initialization.
      *
      * If this method returns true, it means that the widget will be able to
      * present frames from the compoositor.
--- a/widget/nsShmImage.cpp
+++ b/widget/nsShmImage.cpp
@@ -41,17 +41,17 @@ TrapShmError(Display* aDisplay, XErrorEv
 {
     // store the error code and ignore the error
     gShmError = aEvent->error_code;
     return 0;
 }
 #endif
 
 already_AddRefed<nsShmImage>
-nsShmImage::Create(const IntSize& aSize,
+nsShmImage::Create(const LayoutDeviceIntSize& aSize,
                    Display* aDisplay, Visual* aVisual, unsigned int aDepth)
 {
     RefPtr<nsShmImage> shm = new nsShmImage();
     shm->mDisplay = aDisplay;
     shm->mImage = XShmCreateImage(aDisplay, aVisual, aDepth,
                                   ZPixmap, nullptr,
                                   &(shm->mInfo),
                                   aSize.width, aSize.height);
@@ -123,30 +123,32 @@ nsShmImage::Create(const IntSize& aSize,
     return shm.forget();
 }
 
 already_AddRefed<DrawTarget>
 nsShmImage::CreateDrawTarget()
 {
   return gfxPlatform::GetPlatform()->CreateDrawTargetForData(
     static_cast<unsigned char*>(mSegment->memory()),
-    mSize,
+    mSize.ToUnknownSize(),
     mImage->bytes_per_line,
     mFormat);
 }
 
 #ifdef MOZ_WIDGET_GTK
 void
-nsShmImage::Put(Display* aDisplay, Drawable aWindow, const nsIntRegion& aRegion)
+nsShmImage::Put(Display* aDisplay, Drawable aWindow,
+                const LayoutDeviceIntRegion& aRegion)
 {
     GC gc = XCreateGC(aDisplay, aWindow, 0, nullptr);
-    nsIntRegion bounded;
-    bounded.And(aRegion, nsIntRect(0, 0, mImage->width, mImage->height));
-    nsIntRegionRectIterator iter(bounded);
-    for (const nsIntRect *r = iter.Next(); r; r = iter.Next()) {
+    LayoutDeviceIntRegion bounded;
+    bounded.And(aRegion,
+                LayoutDeviceIntRect(0, 0, mImage->width, mImage->height));
+    LayoutDeviceIntRegion::RectIterator iter(bounded);
+    for (const LayoutDeviceIntRect *r = iter.Next(); r; r = iter.Next()) {
         XShmPutImage(aDisplay, aWindow, gc, mImage,
                      r->x, r->y,
                      r->x, r->y,
                      r->width, r->height,
                      False);
     }
 
     XFreeGC(aDisplay, gc);
@@ -175,17 +177,17 @@ nsShmImage::Put(QWindow* aWindow, QRect&
                  inter.x(), inter.y(),
                  inter.width(), inter.height(),
                  False);
     XFreeGC(dpy, gc);
 }
 #endif
 
 already_AddRefed<DrawTarget>
-nsShmImage::EnsureShmImage(const IntSize& aSize,
+nsShmImage::EnsureShmImage(const LayoutDeviceIntSize& aSize,
                            Display* aDisplay, Visual* aVisual, unsigned int aDepth,
                            RefPtr<nsShmImage>& aImage)
 {
     if (!aImage || aImage->Size() != aSize) {
         // Because we XSync() after XShmAttach() to trap errors, we
         // know that the X server has the old image's memory mapped
         // into its address space, so it's OK to destroy the old image
         // here even if there are outstanding Puts.  The Detach is
--- a/widget/nsShmImage.h
+++ b/widget/nsShmImage.h
@@ -33,20 +33,20 @@ class nsShmImage {
     // bug 1168843, compositor thread may create shared memory instances that are destroyed by main thread on shutdown, so this must use thread-safe RC to avoid hitting assertion
     NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsShmImage)
 
     typedef mozilla::ipc::SharedMemorySysV SharedMemorySysV;
 
 public:
     static bool UseShm();
     static already_AddRefed<nsShmImage>
-        Create(const mozilla::gfx::IntSize& aSize,
+        Create(const mozilla::LayoutDeviceIntSize& aSize,
                Display* aDisplay, Visual* aVisual, unsigned int aDepth);
     static already_AddRefed<mozilla::gfx::DrawTarget>
-        EnsureShmImage(const mozilla::gfx::IntSize& aSize,
+        EnsureShmImage(const mozilla::LayoutDeviceIntSize& aSize,
                        Display* aDisplay, Visual* aVisual, unsigned int aDepth,
                        RefPtr<nsShmImage>& aImage);
 
 private:
     ~nsShmImage() {
         if (mImage) {
             mozilla::FinishX(mDisplay);
             if (mXAttached) {
@@ -55,35 +55,36 @@ private:
             XDestroyImage(mImage);
         }
     }
 
 public:
     already_AddRefed<mozilla::gfx::DrawTarget> CreateDrawTarget();
 
 #ifdef MOZ_WIDGET_GTK
-    void Put(Display* aDisplay, Drawable aWindow, const nsIntRegion& aRegion);
+    void Put(Display* aDisplay, Drawable aWindow,
+             const LayoutDeviceIntRegion& aRegion);
 #elif defined(MOZ_WIDGET_QT)
     void Put(QWindow* aWindow, QRect& aRect);
 #endif
 
-    mozilla::gfx::IntSize Size() const { return mSize; }
+    mozilla::LayoutDeviceIntSize Size() const { return mSize; }
 
 private:
     nsShmImage()
         : mImage(nullptr)
         , mDisplay(nullptr)
         , mFormat(mozilla::gfx::SurfaceFormat::UNKNOWN)
         , mXAttached(false)
     { mInfo.shmid = SharedMemorySysV::NULLHandle(); }
 
     RefPtr<SharedMemorySysV>   mSegment;
     XImage*                      mImage;
     Display*                     mDisplay;
     XShmSegmentInfo              mInfo;
-    mozilla::gfx::IntSize        mSize;
+    mozilla::LayoutDeviceIntSize mSize;
     mozilla::gfx::SurfaceFormat  mFormat;
     bool                         mXAttached;
 };
 
 #endif // MOZ_HAVE_SHMIMAGE
 
 #endif