Bug 1006123 - Part 1: Revert bug 929513's imagelib changes to go back to using double-based gfxSize (instead of float-based gfx::Size) in RasterImage. r=seth, a=sledru
authorDaniel Holbert <dholbert@cs.stanford.edu>
Sun, 11 May 2014 17:14:17 -0700
changeset 199301 f812379f00c036c0fd7cd11b4acec12a62ec6521
parent 199300 34a7efd1ccec2ccce98765628897205e6754521b
child 199302 14b67350d0e98ff8dcf43d310a27a8cc91db382e
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth, sledru
bugs1006123, 929513
milestone31.0a2
Bug 1006123 - Part 1: Revert bug 929513's imagelib changes to go back to using double-based gfxSize (instead of float-based gfx::Size) in RasterImage. r=seth, a=sledru
image/src/RasterImage.cpp
image/src/RasterImage.h
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -177,17 +177,17 @@ DiscardingEnabled()
   }
 
   return enabled;
 }
 
 class ScaleRequest
 {
 public:
-  ScaleRequest(RasterImage* aImage, const gfx::Size& aScale, imgFrame* aSrcFrame)
+  ScaleRequest(RasterImage* aImage, const gfxSize& aScale, imgFrame* aSrcFrame)
     : scale(aScale)
     , dstLocked(false)
     , done(false)
     , stopped(false)
   {
     MOZ_ASSERT(!aSrcFrame->GetIsPaletted());
     MOZ_ASSERT(aScale.width > 0 && aScale.height > 0);
 
@@ -271,17 +271,17 @@ public:
 
   // These values may only be touched on the main thread.
   WeakPtr<RasterImage> weakImage;
   nsAutoPtr<imgFrame> dstFrame;
   nsRefPtr<gfxImageSurface> srcSurface;
   nsRefPtr<gfxImageSurface> dstSurface;
 
   // Below are the values that may be touched on the scaling thread.
-  gfx::Size scale;
+  gfxSize scale;
   uint8_t* srcData;
   uint8_t* dstData;
   nsIntRect srcRect;
   gfxIntSize dstSize;
   uint32_t srcStride;
   uint32_t dstStride;
   mozilla::gfx::SurfaceFormat srcFormat;
   bool dstLocked;
@@ -322,17 +322,17 @@ public:
 
 private: /* members */
   nsAutoPtr<ScaleRequest> mScaleRequest;
 };
 
 class ScaleRunner : public nsRunnable
 {
 public:
-  ScaleRunner(RasterImage* aImage, const gfx::Size& aScale, imgFrame* aSrcFrame)
+  ScaleRunner(RasterImage* aImage, const gfxSize& aScale, imgFrame* aSrcFrame)
   {
     nsAutoPtr<ScaleRequest> request(new ScaleRequest(aImage, aScale, aSrcFrame));
 
     // Destination is unconditionally ARGB32 because that's what the scaler
     // outputs.
     request->dstFrame = new imgFrame();
     nsresult rv = request->dstFrame->Init(0, 0, request->dstSize.width, request->dstSize.height,
                                           gfxImageFormat::ARGB32);
@@ -2501,17 +2501,17 @@ RasterImage::SyncDecode()
     DecodePool::Singleton()->RequestDecode(this);
   }
 
   // All good if no errors!
   return mError ? NS_ERROR_FAILURE : NS_OK;
 }
 
 bool
-RasterImage::CanQualityScale(const gfx::Size& scale)
+RasterImage::CanQualityScale(const gfxSize& scale)
 {
   // If target size is 1:1 with original, don't scale.
   if (scale.width == 1.0 && scale.height == 1.0)
     return false;
 
   // To save memory don't quality upscale images bigger than the limit.
   if (scale.width > 1.0 || scale.height > 1.0) {
     uint32_t scaled_size = static_cast<uint32_t>(mSize.width * mSize.height * scale.width * scale.height);
@@ -2519,17 +2519,17 @@ RasterImage::CanQualityScale(const gfx::
       return false;
   }
 
   return true;
 }
 
 bool
 RasterImage::CanScale(GraphicsFilter aFilter,
-                      gfx::Size aScale, uint32_t aFlags)
+                      gfxSize aScale, uint32_t aFlags)
 {
 // The high-quality scaler requires Skia.
 #ifdef MOZ_ENABLE_SKIA
   // We don't use the scaler for animated or multipart images to avoid doing a
   // bunch of work on an image that just gets thrown away.
   // We only use the scaler when drawing to the window because, if we're not
   // drawing to a window (eg a canvas), updates to that image will be ignored.
   if (gHQDownscaling && aFilter == GraphicsFilter::FILTER_GOOD &&
@@ -2595,17 +2595,17 @@ RasterImage::DrawWithPreDownscaleIfNeede
                                           const nsIntRect &aSubimage,
                                           uint32_t aFlags)
 {
   imgFrame *frame = aFrame;
   nsIntRect framerect = frame->GetRect();
   gfxMatrix userSpaceToImageSpace = aUserSpaceToImageSpace;
   gfxMatrix imageSpaceToUserSpace = aUserSpaceToImageSpace;
   imageSpaceToUserSpace.Invert();
-  gfx::Size scale = ToSize(imageSpaceToUserSpace.ScaleFactors(true));
+  gfxSize scale = imageSpaceToUserSpace.ScaleFactors(true);
   nsIntRect subimage = aSubimage;
   nsRefPtr<gfxASurface> surf;
 
   if (CanScale(aFilter, scale, aFlags) && !frame->IsSinglePixel()) {
     // If scale factor is still the same that we scaled for and
     // ScaleWorker isn't still working, then we can use pre-downscaled frame.
     // If scale factor has changed, order new request.
     // FIXME: Current implementation doesn't support pre-downscale
--- a/image/src/RasterImage.h
+++ b/image/src/RasterImage.h
@@ -724,26 +724,26 @@ private: // data
   nsresult WantDecodedFrames();
   nsresult SyncDecode();
   nsresult InitDecoder(bool aDoSizeDecode);
   nsresult WriteToDecoder(const char *aBuffer, uint32_t aCount, DecodeStrategy aStrategy);
   nsresult DecodeSomeData(uint32_t aMaxBytes, DecodeStrategy aStrategy);
   bool     IsDecodeFinished();
   TimeStamp mDrawStartTime;
 
-  inline bool CanQualityScale(const gfx::Size& scale);
-  inline bool CanScale(GraphicsFilter aFilter, gfx::Size aScale, uint32_t aFlags);
+  inline bool CanQualityScale(const gfxSize& scale);
+  inline bool CanScale(GraphicsFilter aFilter, gfxSize aScale, uint32_t aFlags);
 
   struct ScaleResult
   {
     ScaleResult()
      : status(SCALE_INVALID)
     {}
 
-    gfx::Size scale;
+    gfxSize scale;
     nsAutoPtr<imgFrame> frame;
     ScaleStatus status;
   };
 
   ScaleResult mScaleResult;
 
   // We hold on to a bare pointer to a ScaleRequest while it's outstanding so
   // we can mark it as stopped if necessary. The ScaleWorker/DrawWorker duo