Bug 1223690 - Remove implicit Rect conversions. r=jrmuizel.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 11 Nov 2015 14:23:14 -0800
changeset 272263 ed48eac74e39a37bf9b1fc21e1ae16699965b19f
parent 272262 30f18e492189af365a61cd98e575adaabca7322f
child 272264 3cc3b1968524248450c465c4ea2ee5596ffa65f2
child 272265 18f165e113540ff3dab6fa368e8d9a8b660c453c
push id29665
push usercbook@mozilla.com
push dateThu, 12 Nov 2015 11:01:10 +0000
treeherdermozilla-central@3cc3b1968524 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1223690
milestone45.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 1223690 - Remove implicit Rect conversions. r=jrmuizel. gfxRect can be implicitly constructed from IntRect, which hides a number of implicit conversion points, makes Moz2Dification harder, and has some surprising effects. This patch removes the implicit constructor and replaces it with an explicit conversion function: gfxRect ThebesRect(const IntRect&) This is the obvious outcome of removing the constructor. But there is also a second, less obvious outcome: currently we do a number of IntRect-to-Rect conversions using ToRect(), which (surprisingly) works because it turns into an implicit IntRect-to-gfxRect conversion (via the implicit constructor) combined with an explicit gfxRect-to-Rect conversion (via ToRect()). I.e. we do two conversions, going from a Moz2D type to a Thebes type and back to a Moz2D type! So this patch also changes these conversion. It moves this existing function: Rect ToRect(const IntRect&) from gfx2DGlue.h -- where it doesn't really belong because it doesn't involve any Thebes types -- to gfx/2d/Rect.h, templatifying and renaming it as IntRectToRect() in the process. The rest of the patch deals with fall-out from these changes. The call sites change as follows: - IntRect-to-gfxRect conversions: - old: implicit - new: ThebesRect() - IntRect-to-Rect conversions: - old: ToRect() - new: IntRectToRect()
gfx/2d/Rect.h
gfx/layers/Compositor.cpp
gfx/layers/LayerSorter.cpp
gfx/layers/RotatedBuffer.cpp
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicLayerManager.cpp
gfx/layers/composite/ContainerLayerComposite.cpp
gfx/layers/composite/LayerManagerComposite.cpp
gfx/thebes/gfx2DGlue.h
gfx/thebes/gfxBlur.cpp
gfx/thebes/gfxRect.h
image/imgFrame.cpp
layout/base/FrameLayerBuilder.cpp
layout/svg/nsFilterInstance.cpp
widget/gonk/HwcUtils.cpp
--- a/gfx/2d/Rect.h
+++ b/gfx/2d/Rect.h
@@ -224,12 +224,18 @@ IntRectTyped<units> RoundedOut(const Rec
   RectTyped<units> copy(aRect);
   copy.RoundOut();
   return IntRectTyped<units>(int32_t(copy.x),
                              int32_t(copy.y),
                              int32_t(copy.width),
                              int32_t(copy.height));
 }
 
+template<class units>
+RectTyped<units> IntRectToRect(const IntRectTyped<units>& aRect)
+{
+  return RectTyped<units>(aRect.x, aRect.y, aRect.width, aRect.height);
+}
+
 } // namespace gfx
 } // namespace mozilla
 
 #endif /* MOZILLA_GFX_RECT_H_ */
--- a/gfx/layers/Compositor.cpp
+++ b/gfx/layers/Compositor.cpp
@@ -61,21 +61,22 @@ Compositor::DrawDiagnostics(DiagnosticFl
   }
 
   if (aVisibleRegion.GetNumRects() > 1) {
     nsIntRegionRectIterator screenIter(aVisibleRegion);
 
     while (const gfx::IntRect* rect = screenIter.Next())
     {
       DrawDiagnostics(aFlags | DiagnosticFlags::REGION_RECT,
-                      ToRect(*rect), aClipRect, aTransform, aFlashCounter);
+                      IntRectToRect(*rect), aClipRect, aTransform,
+                      aFlashCounter);
     }
   }
 
-  DrawDiagnostics(aFlags, ToRect(aVisibleRegion.GetBounds()),
+  DrawDiagnostics(aFlags, IntRectToRect(aVisibleRegion.GetBounds()),
                   aClipRect, aTransform, aFlashCounter);
 }
 
 void
 Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
                             const gfx::Rect& aVisibleRect,
                             const gfx::Rect& aClipRect,
                             const gfx::Matrix4x4& aTransform,
--- a/gfx/layers/LayerSorter.cpp
+++ b/gfx/layers/LayerSorter.cpp
@@ -71,18 +71,18 @@ static gfxFloat RecoverZDepth(const Matr
  * depths and use this point to determine an ordering for the two layers.
  * For layers that are intersecting in 3d space, this essentially guesses an 
  * order. In a lot of cases we only intersect right at the edge point (3d cubes
  * in particular) and this generates the 'correct' looking ordering. For planes
  * that truely intersect, then there is no correct ordering and this remains
  * unsolved without changing our rendering code.
  */
 static LayerSortOrder CompareDepth(Layer* aOne, Layer* aTwo) {
-  gfxRect ourRect = aOne->GetEffectiveVisibleRegion().GetBounds();
-  gfxRect otherRect = aTwo->GetEffectiveVisibleRegion().GetBounds();
+  gfxRect ourRect = ThebesRect(aOne->GetEffectiveVisibleRegion().GetBounds());
+  gfxRect otherRect = ThebesRect(aTwo->GetEffectiveVisibleRegion().GetBounds());
 
   MOZ_ASSERT(aOne->GetParent() && aOne->GetParent()->Extend3DContext() &&
              aTwo->GetParent() && aTwo->GetParent()->Extend3DContext());
   // Effective transform of leaves may had been projected to 2D.
   Matrix4x4 ourTransform =
     aOne->GetLocalTransform() * aOne->GetParent()->GetEffectiveTransform();
   Matrix4x4 otherTransform =
     aTwo->GetLocalTransform() * aTwo->GetParent()->GetEffectiveTransform();
--- a/gfx/layers/RotatedBuffer.cpp
+++ b/gfx/layers/RotatedBuffer.cpp
@@ -104,27 +104,27 @@ RotatedBuffer::DrawBufferQuadrant(gfx::D
   // (to avoid flickering) but direct2d is ok since it defers rendering.
   // We should try abstract this logic in a helper when we have other use
   // cases.
   if ((aTarget->GetBackendType() == BackendType::DIRECT2D ||
        aTarget->GetBackendType() == BackendType::DIRECT2D1_1) &&
       aOperator == CompositionOp::OP_SOURCE) {
     aOperator = CompositionOp::OP_OVER;
     if (snapshot->GetFormat() == SurfaceFormat::B8G8R8A8) {
-      aTarget->ClearRect(ToRect(fillRect));
+      aTarget->ClearRect(IntRectToRect(fillRect));
     }
   }
 
   // OP_SOURCE is unbounded in Azure, and we really don't want that behaviour here.
   // We also can't do a ClearRect+FillRect since we need the drawing to happen
   // as an atomic operation (to prevent flickering).
   // We also need this clip in the case where we have a mask, since the mask surface
   // might cover more than fillRect, but we only want to touch the pixels inside
   // fillRect.
-  aTarget->PushClipRect(gfx::ToRect(fillRect));
+  aTarget->PushClipRect(IntRectToRect(fillRect));
 
   if (aMask) {
     Matrix oldTransform = aTarget->GetTransform();
 
     // Transform from user -> buffer space.
     Matrix transform =
       Matrix::Translation(quadrantTranslation.x, quadrantTranslation.y);
 
@@ -144,17 +144,17 @@ RotatedBuffer::DrawBufferQuadrant(gfx::D
     aTarget->MaskSurface(source, aMask, Point(0, 0), DrawOptions(aOpacity, aOperator));
     aTarget->SetTransform(oldTransform);
   } else {
 #ifdef MOZ_GFX_OPTIMIZE_MOBILE
     DrawSurfaceOptions options(Filter::POINT);
 #else
     DrawSurfaceOptions options;
 #endif
-    aTarget->DrawSurface(snapshot, ToRect(fillRect),
+    aTarget->DrawSurface(snapshot, IntRectToRect(fillRect),
                          GetSourceRectangle(aXSide, aYSide),
                          options,
                          DrawOptions(aOpacity, aOperator));
   }
 
   aTarget->PopClip();
 }
 
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -582,17 +582,17 @@ 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(ToRect(mInvalidRegion.GetBounds()),
+    mRenderTarget->mDrawTarget->FillRect(IntRectToRect(mInvalidRegion.GetBounds()),
                                          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.
--- a/gfx/layers/basic/BasicLayerManager.cpp
+++ b/gfx/layers/basic/BasicLayerManager.cpp
@@ -1089,17 +1089,17 @@ BasicLayerManager::PaintLayer(gfxContext
 
       RefPtr<gfxContext> temp = new gfxContext(untransformedDT, Point(bounds.x, bounds.y));
       temp->SetColor(color);
       temp->Paint();
     }
 #endif
     Matrix4x4 effectiveTransform = aLayer->GetEffectiveTransform();
     RefPtr<gfxASurface> result =
-      Transform3D(untransformedDT->Snapshot(), aTarget, bounds,
+      Transform3D(untransformedDT->Snapshot(), aTarget, ThebesRect(bounds),
                   effectiveTransform, destRect);
 
     if (result) {
       aTarget->SetSource(result, destRect.TopLeft());
       // Azure doesn't support EXTEND_NONE, so to avoid extending the edges
       // of the source surface out to the current clip region, clip to
       // the rectangle of the result surface now.
       aTarget->NewPath();
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -221,19 +221,21 @@ ContainerRenderVR(ContainerT* aContainer
       // the eye resolution (that is, returned by the recommended
       // render rect from the HMD device), then we need to scale it
       // up/down.
       Rect layerBounds;
       // XXX this is a hack! Canvas layers aren't reporting the
       // proper bounds here (visible region bounds are 0,0,0,0)
       // and I'm not sure if this is the bounds we want anyway.
       if (layer->GetType() == Layer::TYPE_CANVAS) {
-        layerBounds = ToRect(static_cast<CanvasLayer*>(layer)->GetBounds());
+        layerBounds =
+          IntRectToRect(static_cast<CanvasLayer*>(layer)->GetBounds());
       } else {
-        layerBounds = ToRect(layer->GetEffectiveVisibleRegion().GetBounds());
+        layerBounds =
+          IntRectToRect(layer->GetEffectiveVisibleRegion().GetBounds());
       }
       const gfx::Matrix4x4 childTransform = layer->GetEffectiveTransform();
       layerBounds = childTransform.TransformBounds(layerBounds);
 
       DUMP("  layer %p [type %d] bounds [%f %f %f %f] surfaceRect [%d %d %d %d]\n", layer, (int) layer->GetType(),
            XYWH(layerBounds), XYWH(surfaceRect));
 
       bool restoreTransform = false;
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -1063,17 +1063,17 @@ SubtractTransformedRegion(nsIntRegion& a
   if (aRegionToSubtract.IsEmpty()) {
     return;
   }
 
   // For each rect in the region, find out its bounds in screen space and
   // subtract it from the screen region.
   nsIntRegionRectIterator it(aRegionToSubtract);
   while (const IntRect* rect = it.Next()) {
-    Rect incompleteRect = aTransform.TransformAndClipBounds(ToRect(*rect),
+    Rect incompleteRect = aTransform.TransformAndClipBounds(IntRectToRect(*rect),
                                                             Rect::MaxIntRect());
     aRegion.Sub(aRegion, IntRect(incompleteRect.x,
                                    incompleteRect.y,
                                    incompleteRect.width,
                                    incompleteRect.height));
   }
 }
 
--- a/gfx/thebes/gfx2DGlue.h
+++ b/gfx/thebes/gfx2DGlue.h
@@ -24,21 +24,16 @@ inline Rect ToRect(const gfxRect &aRect)
               Float(aRect.width), Float(aRect.height));
 }
 
 inline RectDouble ToRectDouble(const gfxRect &aRect)
 {
   return RectDouble(aRect.x, aRect.y, aRect.width, aRect.height);
 }
 
-inline Rect ToRect(const IntRect &aRect)
-{
-  return Rect(aRect.x, aRect.y, aRect.width, aRect.height);
-}
-
 inline Matrix ToMatrix(const gfxMatrix &aMatrix)
 {
   return Matrix(Float(aMatrix._11), Float(aMatrix._12), Float(aMatrix._21),
                 Float(aMatrix._22), Float(aMatrix._31), Float(aMatrix._32));
 }
 
 inline gfxMatrix ThebesMatrix(const Matrix &aMatrix)
 {
@@ -66,16 +61,21 @@ inline gfxSize ThebesSize(const Size &aS
   return gfxSize(aSize.width, aSize.height);
 }
 
 inline gfxRect ThebesRect(const Rect &aRect)
 {
   return gfxRect(aRect.x, aRect.y, aRect.width, aRect.height);
 }
 
+inline gfxRect ThebesRect(const IntRect &aRect)
+{
+  return gfxRect(aRect.x, aRect.y, aRect.width, aRect.height);
+}
+
 inline gfxRect ThebesRect(const RectDouble &aRect)
 {
   return gfxRect(aRect.x, aRect.y, aRect.width, aRect.height);
 }
 
 inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat)
 {
   switch (aFormat) {
--- a/gfx/thebes/gfxBlur.cpp
+++ b/gfx/thebes/gfxBlur.cpp
@@ -950,26 +950,27 @@ gfxAlphaBoxBlur::GetInsetBlur(IntMargin&
     RefPtr<SourceSurface> cachedBlur = cached->mBlur;
     return cachedBlur.forget();
   }
 
   // Dirty rect and skip rect are null for the min inset shadow.
   // When rendering inset box shadows, we respect the spread radius by changing
   //  the shape of the unblurred shadow, and can pass a spread radius of zero here.
   IntSize zeroSpread(0, 0);
-  gfxContext* minGfxContext = Init(ThebesRect(ToRect(outerRect)),
+  gfxContext* minGfxContext = Init(ThebesRect(outerRect),
                                    zeroSpread, aBlurRadius, nullptr, nullptr);
   if (!minGfxContext) {
     return nullptr;
   }
 
   DrawTarget* minDrawTarget = minGfxContext->GetDrawTarget();
-  RefPtr<Path> maskPath = GetBoxShadowInsetPath(minDrawTarget, ToRect(outerRect),
-                                                ToRect(innerRect), aHasBorderRadius,
-                                                aInnerClipRadii);
+  RefPtr<Path> maskPath =
+    GetBoxShadowInsetPath(minDrawTarget, IntRectToRect(outerRect),
+                          IntRectToRect(innerRect), aHasBorderRadius,
+                          aInnerClipRadii);
 
   Color black(0.f, 0.f, 0.f, 1.f);
   minGfxContext->SetColor(black);
   minGfxContext->SetPath(maskPath);
   minGfxContext->Fill();
 
   IntPoint topLeft;
   RefPtr<SourceSurface> minMask = DoBlur(minDrawTarget, &topLeft);
--- a/gfx/thebes/gfxRect.h
+++ b/gfx/thebes/gfxRect.h
@@ -66,18 +66,16 @@ struct gfxRect :
     public mozilla::gfx::BaseRect<gfxFloat, gfxRect, gfxPoint, gfxSize, gfxMargin> {
     typedef mozilla::gfx::BaseRect<gfxFloat, gfxRect, gfxPoint, gfxSize, gfxMargin> Super;
 
     gfxRect() : Super() {}
     gfxRect(const gfxPoint& aPos, const gfxSize& aSize) :
         Super(aPos, aSize) {}
     gfxRect(gfxFloat aX, gfxFloat aY, gfxFloat aWidth, gfxFloat aHeight) :
         Super(aX, aY, aWidth, aHeight) {}
-    MOZ_IMPLICIT gfxRect(const mozilla::gfx::IntRect& aRect) :
-        Super(aRect.x, aRect.y, aRect.width, aRect.height) {}
 
     /**
      * Return true if all components of this rect are within
      * aEpsilon of integer coordinates, defined as
      *   |round(coord) - coord| <= |aEpsilon|
      * for x,y,width,height.
      */
     bool WithinEpsilonOfIntegerPixels(gfxFloat aEpsilon) const;
--- a/image/imgFrame.cpp
+++ b/image/imgFrame.cpp
@@ -299,17 +299,17 @@ imgFrame::InitWithDrawable(gfxDrawable* 
     mAborted = true;
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   // Draw using the drawable the caller provided.
   nsIntRect imageRect(0, 0, mSize.width, mSize.height);
   RefPtr<gfxContext> ctx = new gfxContext(target);
   gfxUtils::DrawPixelSnapped(ctx, aDrawable, mSize,
-                             ImageRegion::Create(imageRect),
+                             ImageRegion::Create(ThebesRect(imageRect)),
                              mFormat, aFilter, aImageFlags);
 
   if (canUseDataSurface && !mImageSurface) {
     NS_WARNING("Failed to create VolatileDataSourceSurface");
     mAborted = true;
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -5880,17 +5880,17 @@ FrameLayerBuilder::DrawPaintedLayer(Pain
 
   nsRenderingContext rc(aContext);
 
   if (shouldDrawRectsSeparately) {
     nsIntRegionRectIterator it(aRegionToDraw);
     while (const nsIntRect* iterRect = it.Next()) {
       gfxContextAutoSaveRestore save(aContext);
       aContext->NewPath();
-      aContext->Rectangle(*iterRect);
+      aContext->Rectangle(ThebesRect(*iterRect));
       aContext->Clip();
 
       DrawForcedBackgroundColor(aDrawTarget, aLayer,
                                 userData->mForcedBackgroundColor);
 
       // Apply the residual transform if it has been enabled, to ensure that
       // snapping when we draw into aContext exactly matches the ideal transform.
       // See above for why this is OK.
--- a/layout/svg/nsFilterInstance.cpp
+++ b/layout/svg/nsFilterInstance.cpp
@@ -371,17 +371,17 @@ nsFilterInstance::BuildSourcePaint(Sourc
                   gfxMatrix::Translation(-neededRect.TopLeft()));
     GeneralPattern pattern;
     if (aSource == &mFillPaint) {
       nsSVGUtils::MakeFillPatternFor(mTargetFrame, gfx, &pattern);
     } else if (aSource == &mStrokePaint) {
       nsSVGUtils::MakeStrokePatternFor(mTargetFrame, gfx, &pattern);
     }
     if (pattern.GetPattern()) {
-      offscreenDT->FillRect(ToRect(FilterSpaceToUserSpace(neededRect)),
+      offscreenDT->FillRect(ToRect(FilterSpaceToUserSpace(ThebesRect(neededRect))),
                             pattern);
     }
     gfx->Restore();
   }
 
   aSource->mSourceSurface = offscreenDT->Snapshot();
   aSource->mSurfaceRect = neededRect;
 
@@ -417,17 +417,17 @@ nsFilterInstance::BuildSourceImage(DrawT
 
   RefPtr<DrawTarget> offscreenDT =
     gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
       neededRect.Size(), SurfaceFormat::B8G8R8A8);
   if (!offscreenDT) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  gfxRect r = FilterSpaceToUserSpace(neededRect);
+  gfxRect r = FilterSpaceToUserSpace(ThebesRect(neededRect));
   r.RoundOut();
   nsIntRect dirty;
   if (!gfxUtils::GfxRectToIntRect(r, &dirty))
     return NS_ERROR_FAILURE;
 
   // SVG graphics paint to device space, so we need to set an initial device
   // space to filter space transform on the gfxContext that SourceGraphic
   // and SourceAlpha will paint to.
@@ -479,17 +479,17 @@ nsFilterInstance::Render(gfxContext* aCo
   nsresult rv = BuildSourceImage(dt);
   if (NS_FAILED(rv))
     return rv;
   rv = BuildSourcePaints(dt);
   if (NS_FAILED(rv))
     return rv;
 
   FilterSupport::RenderFilterDescription(
-    dt, mFilterDescription, ToRect(filterRect),
+    dt, mFilterDescription, IntRectToRect(filterRect),
     mSourceGraphic.mSourceSurface, mSourceGraphic.mSurfaceRect,
     mFillPaint.mSourceSurface, mFillPaint.mSurfaceRect,
     mStrokePaint.mSourceSurface, mStrokePaint.mSurfaceRect,
     mInputImages, Point(0, 0));
 
   return NS_OK;
 }
 
--- a/widget/gonk/HwcUtils.cpp
+++ b/widget/gonk/HwcUtils.cpp
@@ -40,32 +40,32 @@ namespace mozilla {
 HwcUtils::PrepareLayerRects(nsIntRect aVisible,
                             const gfx::Matrix& aLayerTransform,
                             const gfx::Matrix& aLayerBufferTransform,
                             nsIntRect aClip, nsIntRect aBufferRect,
                             bool aYFlipped,
                             hwc_rect_t* aSourceCrop, hwc_rect_t* aVisibleRegionScreen) {
 
     gfxMatrix aTransform = gfx::ThebesMatrix(aLayerTransform);
-    gfxRect visibleRect(aVisible);
-    gfxRect clip(aClip);
+    gfxRect visibleRect(ThebesRect(aVisible));
+    gfxRect clip(ThebesRect(aClip));
     gfxRect visibleRectScreen = aTransform.TransformBounds(visibleRect);
     // |clip| is guaranteed to be integer
     visibleRectScreen.IntersectRect(visibleRectScreen, clip);
 
     if (visibleRectScreen.IsEmpty()) {
         return false;
     }
 
     gfxMatrix inverse = gfx::ThebesMatrix(aLayerBufferTransform);
     inverse.Invert();
     gfxRect crop = inverse.TransformBounds(visibleRectScreen);
 
     //clip to buffer size
-    crop.IntersectRect(crop, aBufferRect);
+    crop.IntersectRect(crop, ThebesRect(aBufferRect));
     crop.Round();
 
     if (crop.IsEmpty()) {
         return false;
     }
 
     //propagate buffer clipping back to visible rect
     gfxMatrix layerBufferTransform = gfx::ThebesMatrix(aLayerBufferTransform);
@@ -98,28 +98,29 @@ HwcUtils::PrepareVisibleRegion(const nsI
                                nsIntRect aClip, nsIntRect aBufferRect,
                                RectVector* aVisibleRegionScreen,
                                bool& aIsVisible) {
     const float MIN_SRC_WIDTH = 2.f;
     const float MIN_SRC_HEIGHT = 2.f;
 
     gfxMatrix layerTransform = gfx::ThebesMatrix(aLayerTransform);
     gfxMatrix layerBufferTransform = gfx::ThebesMatrix(aLayerBufferTransform);
-    gfxRect bufferRect = layerBufferTransform.TransformBounds(aBufferRect);
+    gfxRect bufferRect =
+        layerBufferTransform.TransformBounds(ThebesRect(aBufferRect));
     gfxMatrix inverse = gfx::ThebesMatrix(aLayerBufferTransform);
     inverse.Invert();
     nsIntRegionRectIterator rect(aVisible);
     aIsVisible = false;
     while (const nsIntRect* visibleRect = rect.Next()) {
         hwc_rect_t visibleRectScreen;
         gfxRect screenRect;
 
-        screenRect = layerTransform.TransformBounds(gfxRect(*visibleRect));
+        screenRect = layerTransform.TransformBounds(ThebesRect(*visibleRect));
         screenRect.IntersectRect(screenRect, bufferRect);
-        screenRect.IntersectRect(screenRect, aClip);
+        screenRect.IntersectRect(screenRect, ThebesRect(aClip));
         screenRect.Round();
         if (screenRect.IsEmpty()) {
             continue;
         }
         visibleRectScreen.left = screenRect.x;
         visibleRectScreen.top  = screenRect.y;
         visibleRectScreen.right  = screenRect.XMost();
         visibleRectScreen.bottom = screenRect.YMost();
@@ -151,17 +152,17 @@ HwcUtils::CalculateClipRect(const gfx::M
     }
 
     if (aLayerClip->IsEmpty()) {
         return false;
     }
 
     nsIntRect clip = *aLayerClip;
 
-    gfxRect r(clip);
+    gfxRect r = ThebesRect(clip);
     gfxRect trClip = aTransform.TransformBounds(r);
     trClip.Round();
     gfxUtils::GfxRectToIntRect(trClip, &clip);
 
     aRenderClip->IntersectRect(*aRenderClip, clip);
     return true;
 }