Bug 1376782 - Replace gfxSize with a typedef to SizeDouble. r=jrmuizel
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 28 Jun 2017 11:41:21 -0400
changeset 366474 9b91d24a1e30af6b9d6781c0af3c2cc3f330a96f
parent 366473 8e6b53822f7cff83403d0225be8e305440f952fe
child 366475 5b8646741e8fc38d1db04999c55291a64ac7174a
push id32104
push usercbook@mozilla.com
push dateThu, 29 Jun 2017 13:46:04 +0000
treeherdermozilla-central@d2aff6fc075d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1376782
milestone56.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 1376782 - Replace gfxSize with a typedef to SizeDouble. r=jrmuizel Most of the changes in this patch are just using the explicit constructor from gfx::IntSize to gfx::Size, since gfxSize did that implicitly but gfx::Size doesn't. MozReview-Commit-ID: CzikGjHEXje
dom/ipc/PBrowser.ipdl
gfx/layers/ImageLayers.cpp
gfx/src/nsDeviceContext.cpp
gfx/thebes/gfxPoint.h
image/ClippedImage.cpp
image/DynamicImage.cpp
image/OrientedImage.cpp
image/VectorImage.cpp
image/imgFrame.cpp
layout/svg/nsFilterInstance.cpp
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -29,17 +29,16 @@ include URIParams;
 include PPrintingTypes;
 include PTabContext;
 
 include "mozilla/GfxMessageUtils.h";
 include "mozilla/layers/LayersMessageUtils.h";
 
 using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
 using class mozilla::gfx::Matrix from "mozilla/gfx/Matrix.h";
-using struct gfxSize from "gfxPoint.h";
 using mozilla::LayoutDeviceIntPoint from "Units.h";
 using mozilla::LayoutDevicePoint from "Units.h";
 using mozilla::ScreenIntPoint from "Units.h";
 using ScreenIntSize from "Units.h";
 using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
 using struct mozilla::layers::ScrollableLayerGuid from "FrameMetrics.h";
 using struct mozilla::layers::ZoomConstraints from "FrameMetrics.h";
 using mozilla::layers::MaybeZoomConstraints from "FrameMetrics.h";
--- a/gfx/layers/ImageLayers.cpp
+++ b/gfx/layers/ImageLayers.cpp
@@ -28,17 +28,17 @@ void ImageLayer::SetContainer(ImageConta
 
 void ImageLayer::ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface)
 {
   gfx::Matrix4x4 local = GetLocalTransform();
 
   // Snap image edges to pixel boundaries
   gfxRect sourceRect(0, 0, 0, 0);
   if (mContainer) {
-    sourceRect.SizeTo(mContainer->GetCurrentSize());
+    sourceRect.SizeTo(SizeDouble(mContainer->GetCurrentSize()));
   }
   // Snap our local transform first, and snap the inherited transform as well.
   // This makes our snapping equivalent to what would happen if our content
   // was drawn into a PaintedLayer (gfxContext would snap using the local
   // transform, then we'd snap again when compositing the PaintedLayer).
   mEffectiveTransform =
       SnapTransform(local, sourceRect, nullptr) *
       SnapTransformTranslation(aTransformToSurface, nullptr);
--- a/gfx/src/nsDeviceContext.cpp
+++ b/gfx/src/nsDeviceContext.cpp
@@ -657,17 +657,17 @@ nsDeviceContext::FindScreen(nsIScreen** 
     if (!(*outScreen)) {
         mScreenManager->GetPrimaryScreen(outScreen);
     }
 }
 
 bool
 nsDeviceContext::CalcPrintingSize()
 {
-    gfxSize size = mPrintTarget->GetSize();
+    gfxSize size(mPrintTarget->GetSize());
     // For printing, CSS inches and physical inches are identical
     // so it doesn't matter which we use here
     mWidth = NSToCoordRound(size.width * AppUnitsPerPhysicalInch()
                             / POINTS_PER_INCH_FLOAT);
     mHeight = NSToCoordRound(size.height * AppUnitsPerPhysicalInch()
                              / POINTS_PER_INCH_FLOAT);
 
     return (mWidth > 0 && mHeight > 0);
--- a/gfx/thebes/gfxPoint.h
+++ b/gfx/thebes/gfxPoint.h
@@ -5,28 +5,23 @@
 
 #ifndef GFX_POINT_H
 #define GFX_POINT_H
 
 #include "nsMathUtils.h"
 #include "mozilla/gfx/BaseSize.h"
 #include "mozilla/gfx/BasePoint.h"
 #include "mozilla/gfx/Matrix.h"
+#include "mozilla/gfx/Point.h"
 #include "nsSize.h"
 #include "nsPoint.h"
 
 #include "gfxTypes.h"
 
-struct gfxSize : public mozilla::gfx::BaseSize<gfxFloat, gfxSize> {
-    typedef mozilla::gfx::BaseSize<gfxFloat, gfxSize> Super;
-
-    gfxSize() : Super() {}
-    gfxSize(gfxFloat aWidth, gfxFloat aHeight) : Super(aWidth, aHeight) {}
-    MOZ_IMPLICIT gfxSize(const mozilla::gfx::IntSize& aSize) : Super(aSize.width, aSize.height) {}
-};
+typedef mozilla::gfx::SizeDouble gfxSize;
 
 struct gfxPoint : public mozilla::gfx::BasePoint<gfxFloat, gfxPoint> {
     typedef mozilla::gfx::BasePoint<gfxFloat, gfxPoint> Super;
 
     gfxPoint() : Super() {}
     gfxPoint(gfxFloat aX, gfxFloat aY) : Super(aX, aY) {}
     MOZ_IMPLICIT gfxPoint(const nsIntPoint& aPoint) : Super(aPoint.x, aPoint.y) {}
 
@@ -56,15 +51,9 @@ operator*(const gfxPoint& aPoint, const 
 }
 
 inline gfxPoint
 operator/(const gfxPoint& aPoint, const gfxSize& aSize)
 {
   return gfxPoint(aPoint.x / aSize.width, aPoint.y / aSize.height);
 }
 
-inline gfxSize
-operator/(gfxFloat aValue, const gfxSize& aSize)
-{
-  return gfxSize(aValue / aSize.width, aValue / aSize.height);
-}
-
 #endif /* GFX_POINT_H */
--- a/image/ClippedImage.cpp
+++ b/image/ClippedImage.cpp
@@ -308,17 +308,17 @@ ClippedImage::GetFrameInternal(const nsI
     // Create our callback.
     RefPtr<DrawSingleTileCallback> drawTileCallback =
       new DrawSingleTileCallback(this, aSize, aSVGContext, aWhichFrame, aFlags,
                                  aOpacity);
     RefPtr<gfxDrawable> drawable =
       new gfxCallbackDrawable(drawTileCallback, aSize);
 
     // Actually draw. The callback will end up invoking DrawSingleTile.
-    gfxUtils::DrawPixelSnapped(ctx, drawable, aSize,
+    gfxUtils::DrawPixelSnapped(ctx, drawable, SizeDouble(aSize),
                                ImageRegion::Create(aSize),
                                SurfaceFormat::B8G8R8A8,
                                SamplingFilter::LINEAR,
                                imgIContainer::FLAG_CLAMP);
 
     // Cache the resulting surface.
     mCachedSurface =
       MakeUnique<ClippedImageCachedSurface>(target->Snapshot(), aSize, aSVGContext,
@@ -399,17 +399,17 @@ ClippedImage::Draw(gfxContext* aContext,
       return result;
     }
 
     // Create a drawable from that surface.
     RefPtr<gfxSurfaceDrawable> drawable =
       new gfxSurfaceDrawable(surface, aSize);
 
     // Draw.
-    gfxUtils::DrawPixelSnapped(aContext, drawable, aSize, aRegion,
+    gfxUtils::DrawPixelSnapped(aContext, drawable, SizeDouble(aSize), aRegion,
                                SurfaceFormat::B8G8R8A8, aSamplingFilter,
                                aOpacity);
 
     return result;
   }
 
   return DrawSingleTile(aContext, aSize, aRegion, aWhichFrame,
                         aSamplingFilter, aSVGContext, aFlags, aOpacity);
--- a/image/DynamicImage.cpp
+++ b/image/DynamicImage.cpp
@@ -230,32 +230,32 @@ DynamicImage::Draw(gfxContext* aContext,
                    uint32_t aFlags,
                    float aOpacity)
 {
   MOZ_ASSERT(!aSize.IsEmpty(), "Unexpected empty size");
 
   IntSize drawableSize(mDrawable->Size());
 
   if (aSize == drawableSize) {
-    gfxUtils::DrawPixelSnapped(aContext, mDrawable, drawableSize, aRegion,
+    gfxUtils::DrawPixelSnapped(aContext, mDrawable, SizeDouble(drawableSize), aRegion,
                                SurfaceFormat::B8G8R8A8, aSamplingFilter,
                                aOpacity);
     return DrawResult::SUCCESS;
   }
 
   gfxSize scale(double(aSize.width) / drawableSize.width,
                 double(aSize.height) / drawableSize.height);
 
   ImageRegion region(aRegion);
   region.Scale(1.0 / scale.width, 1.0 / scale.height);
 
   gfxContextMatrixAutoSaveRestore saveMatrix(aContext);
   aContext->Multiply(gfxMatrix::Scaling(scale.width, scale.height));
 
-  gfxUtils::DrawPixelSnapped(aContext, mDrawable, drawableSize, region,
+  gfxUtils::DrawPixelSnapped(aContext, mDrawable, SizeDouble(drawableSize), region,
                              SurfaceFormat::B8G8R8A8, aSamplingFilter,
                              aOpacity);
   return DrawResult::SUCCESS;
 }
 
 NS_IMETHODIMP
 DynamicImage::StartDecoding(uint32_t aFlags)
 {
--- a/image/OrientedImage.cpp
+++ b/image/OrientedImage.cpp
@@ -127,17 +127,17 @@ OrientedImage::GetFrame(uint32_t aWhichF
   NS_ENSURE_TRUE(innerSurface, nullptr);
   RefPtr<gfxDrawable> drawable =
     new gfxSurfaceDrawable(innerSurface, size);
 
   // Draw.
   RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
   MOZ_ASSERT(ctx); // already checked the draw target above
   ctx->Multiply(OrientationMatrix(size));
-  gfxUtils::DrawPixelSnapped(ctx, drawable, size, ImageRegion::Create(size),
+  gfxUtils::DrawPixelSnapped(ctx, drawable, SizeDouble(size), ImageRegion::Create(size),
                              surfaceFormat, SamplingFilter::LINEAR);
 
   return target->Snapshot();
 }
 
 NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
 OrientedImage::GetFrameAtSize(const IntSize& aSize,
                               uint32_t aWhichFrame,
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -1014,17 +1014,17 @@ VectorImage::CreateSurfaceAndShow(const 
 }
 
 
 void
 VectorImage::Show(gfxDrawable* aDrawable, const SVGDrawingParameters& aParams)
 {
   MOZ_ASSERT(aDrawable, "Should have a gfxDrawable by now");
   gfxUtils::DrawPixelSnapped(aParams.context, aDrawable,
-                             aParams.size,
+                             SizeDouble(aParams.size),
                              aParams.region,
                              SurfaceFormat::B8G8R8A8,
                              aParams.samplingFilter,
                              aParams.flags, aParams.opacity);
 
   MOZ_ASSERT(mRenderingObserver, "Should have a rendering observer by now");
   mRenderingObserver->ResumeHonoringInvalidations();
 }
--- a/image/imgFrame.cpp
+++ b/image/imgFrame.cpp
@@ -358,17 +358,17 @@ imgFrame::InitWithDrawable(gfxDrawable* 
   if (!target || !target->IsValid()) {
     mAborted = true;
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   // Draw using the drawable the caller provided.
   RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
   MOZ_ASSERT(ctx);  // Already checked the draw target above.
-  gfxUtils::DrawPixelSnapped(ctx, aDrawable, mFrameRect.Size(),
+  gfxUtils::DrawPixelSnapped(ctx, aDrawable, SizeDouble(mFrameRect.Size()),
                              ImageRegion::Create(ThebesRect(mFrameRect)),
                              mFormat, aSamplingFilter, aImageFlags);
 
   if (canUseDataSurface && !mLockedSurface) {
     NS_WARNING("Failed to create VolatileDataSourceSurface");
     mAborted = true;
     return NS_ERROR_OUT_OF_MEMORY;
   }
--- a/layout/svg/nsFilterInstance.cpp
+++ b/layout/svg/nsFilterInstance.cpp
@@ -340,17 +340,17 @@ nsFilterInstance::BuildPrimitivesForFilt
 
 static void
 UpdateNeededBounds(const nsIntRegion& aRegion, nsIntRect& aBounds)
 {
   aBounds = aRegion.GetBounds();
 
   bool overflow;
   IntSize surfaceSize =
-   nsSVGUtils::ConvertToSurfaceSize(aBounds.Size(), &overflow);
+   nsSVGUtils::ConvertToSurfaceSize(SizeDouble(aBounds.Size()), &overflow);
   if (overflow) {
     aBounds.SizeTo(surfaceSize);
   }
 }
 
 void
 nsFilterInstance::ComputeNeededBoxes()
 {