Bug 1067207 - Compute imgFrame padding in unscaled coordinates. r=tn
authorSeth Fowler <seth@mozilla.com>
Tue, 16 Sep 2014 19:02:26 -0700
changeset 205676 4746dd77b34bf391d8c9b100b658d6c3ab124a14
parent 205675 612fedcc26e162d9713e00fd1ed2d3689163709d
child 205677 af081b216b86ad7d74ea8de9cea1678104ecedda
push id49233
push usermfowler@mozilla.com
push dateWed, 17 Sep 2014 02:03:00 +0000
treeherdermozilla-inbound@4746dd77b34b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1067207
milestone35.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 1067207 - Compute imgFrame padding in unscaled coordinates. r=tn
image/src/RasterImage.cpp
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -2626,17 +2626,17 @@ RasterImage::RequestScale(imgFrame* aFra
     }
 
     sScaleWorkerThread->Dispatch(runner, NS_DISPATCH_NORMAL);
   }
 }
 
 void
 RasterImage::DrawWithPreDownscaleIfNeeded(DrawableFrameRef&& aFrameRef,
-                                          gfxContext *aContext,
+                                          gfxContext* aContext,
                                           const nsIntSize& aSize,
                                           const ImageRegion& aRegion,
                                           GraphicsFilter aFilter,
                                           uint32_t aFlags)
 {
   DrawableFrameRef frameRef;
   gfx::Size scale(double(aSize.width) / mSize.width,
                   double(aSize.height) / mSize.height);
@@ -2668,20 +2668,29 @@ RasterImage::DrawWithPreDownscaleIfNeede
   // By now we may have a frame with the requested size. If not, we need to
   // adjust the drawing parameters accordingly.
   nsIntRect finalFrameRect = frameRef->GetRect();
   if (finalFrameRect.Size() != aSize) {
     aContext->Multiply(gfxMatrix::Scaling(scale.width, scale.height));
     region.Scale(1.0 / scale.width, 1.0 / scale.height);
   }
 
-  nsIntMargin padding(finalFrameRect.y,
-                      mSize.width - finalFrameRect.XMost(),
-                      mSize.height - finalFrameRect.YMost(),
-                      finalFrameRect.x);
+  // We can only use padding if we're using the original |aFrameRef|, unscaled.
+  // (If so, we moved it into |frameRef|, so |aFrameRef| is empty.) Because of
+  // this restriction, we don't scale frames that require padding.
+  // XXX(seth): We actually do scale such frames right now though, if a single
+  // frame of a non-animated image requires padding. We'll fix that in bug
+  // 1060200, because dependencies between bugs make it hard to fix here.
+  nsIntMargin padding(0, 0, 0, 0);
+  if (!aFrameRef) {
+    padding = nsIntMargin(finalFrameRect.y,
+                          mSize.width - finalFrameRect.XMost(),
+                          mSize.height - finalFrameRect.YMost(),
+                          finalFrameRect.x);
+  }
 
   frameRef->Draw(aContext, region, padding, aFilter, aFlags);
 }
 
 //******************************************************************************
 /* [noscript] void draw(in gfxContext aContext,
  *                      in gfxGraphicsFilter aFilter,
  *                      [const] in gfxMatrix aUserSpaceToImageSpace,