Backed out changeset 6c8bf287d25b (bug 1462431) for web platform reftest failure. r=aosmond
authorAndrew Osmond <aosmond@mozilla.com>
Fri, 18 May 2018 08:59:26 -0400
changeset 418878 3880e9b11a7a0c8321baf6ab0bc86d3748e7d854
parent 418877 6c8bf287d25b8d1ebc0392812b9328d57744233c
child 418879 84a09a4a0dc2dac930cf8f531b010c403c07fd73
push id103401
push useraosmond@gmail.com
push dateFri, 18 May 2018 12:59:36 +0000
treeherdermozilla-inbound@3880e9b11a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond
bugs1462431
milestone62.0a1
backs out6c8bf287d25b8d1ebc0392812b9328d57744233c
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
Backed out changeset 6c8bf287d25b (bug 1462431) for web platform reftest failure. r=aosmond
image/RasterImage.cpp
image/RasterImage.h
image/test/unit/image2jpg16x32scaled.jpg
image/test/unit/image2jpg32x16scaled.jpg
image/test/unit/test_imgtools.js
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -335,17 +335,18 @@ RasterImage::LookupFrame(const IntSize& 
   MOZ_ASSERT(NS_IsMainThread());
 
   // If we're opaque, we don't need to care about premultiplied alpha, because
   // that can only matter for frames with transparency.
   if (IsOpaque()) {
     aFlags &= ~FLAG_DECODE_NO_PREMULTIPLY_ALPHA;
   }
 
-  IntSize requestedSize = GetDownscaleDecodeSize(aSize, aFlags);
+  IntSize requestedSize = CanDownscaleDuringDecode(aSize, aFlags)
+                        ? aSize : mSize;
   if (requestedSize.IsEmpty()) {
     // Can't decode to a surface of zero size.
     return LookupResult(MatchType::NOT_FOUND);
   }
 
   LookupResult result =
     LookupFrameInternal(requestedSize, aFlags, aPlaybackType);
 
@@ -632,17 +633,21 @@ IntSize
 RasterImage::GetImageContainerSize(LayerManager* aManager,
                                    const IntSize& aSize,
                                    uint32_t aFlags)
 {
   if (!IsImageContainerAvailableAtSize(aManager, aSize, aFlags)) {
     return IntSize(0, 0);
   }
 
-  return GetDownscaleDecodeSize(aSize, aFlags);
+  if (!CanDownscaleDuringDecode(aSize, aFlags)) {
+    return mSize;
+  }
+
+  return aSize;
 }
 
 NS_IMETHODIMP_(bool)
 RasterImage::IsImageContainerAvailable(LayerManager* aManager, uint32_t aFlags)
 {
   return IsImageContainerAvailableAtSize(aManager, mSize, aFlags);
 }
 
@@ -1362,56 +1367,49 @@ HaveSkia()
 {
 #ifdef MOZ_ENABLE_SKIA
   return true;
 #else
   return false;
 #endif
 }
 
-IntSize
-RasterImage::GetDownscaleDecodeSize(const IntSize& aSize, uint32_t aFlags)
+bool
+RasterImage::CanDownscaleDuringDecode(const IntSize& aSize, uint32_t aFlags)
 {
   // Check basic requirements: downscale-during-decode is enabled, Skia is
   // available, this image isn't transient, we have all the source data and know
   // our size, and the flags allow us to do it.
-  if (!mHasSize || mTransient || !HaveSkia() || aSize == mSize ||
+  if (!mHasSize || mTransient || !HaveSkia() ||
       !gfxPrefs::ImageDownscaleDuringDecodeEnabled() ||
       !(aFlags & imgIContainer::FLAG_HIGH_QUALITY_SCALING)) {
-    return mSize;
+    return false;
   }
 
   // We don't downscale animated images during decode.
   if (mAnimationState) {
-    return mSize;
+    return false;
+  }
+
+  // Never upscale.
+  if (aSize.width >= mSize.width || aSize.height >= mSize.height) {
+    return false;
   }
 
   // Zero or negative width or height is unacceptable.
   if (aSize.width < 1 || aSize.height < 1) {
-    return mSize;
-  }
-
-  // We never upscale, but we may partially downscale nearer to the desired
-  // size if only one of the dimensions exceeds the native size.
-  IntSize decodeSize(aSize);
-  if (aSize.width > mSize.width) {
-    if (aSize.height > mSize.height) {
-      return mSize;
-    }
-    decodeSize.width = mSize.width;
-  } else if (aSize.height > mSize.height) {
-    decodeSize.height = mSize.height;
+    return false;
   }
 
   // There's no point in scaling if we can't store the result.
-  if (!SurfaceCache::CanHold(decodeSize)) {
-    return mSize;
+  if (!SurfaceCache::CanHold(aSize)) {
+    return false;
   }
 
-  return decodeSize;
+  return true;
 }
 
 ImgDrawResult
 RasterImage::DrawInternal(DrawableSurface&& aSurface,
                           gfxContext* aContext,
                           const IntSize& aSize,
                           const ImageRegion& aRegion,
                           SamplingFilter aSamplingFilter,
@@ -1431,18 +1429,17 @@ RasterImage::DrawInternal(DrawableSurfac
   IntSize finalSize = aSurface->GetImageSize();
   bool couldRedecodeForBetterFrame = false;
   if (finalSize != aSize) {
     gfx::Size scale(double(aSize.width) / finalSize.width,
                     double(aSize.height) / finalSize.height);
     aContext->Multiply(gfxMatrix::Scaling(scale.width, scale.height));
     region.Scale(1.0 / scale.width, 1.0 / scale.height);
 
-    couldRedecodeForBetterFrame =
-      GetDownscaleDecodeSize(aSize, aFlags) != mSize;
+    couldRedecodeForBetterFrame = CanDownscaleDuringDecode(aSize, aFlags);
   }
 
   if (!aSurface->Draw(aContext, region, aSamplingFilter, aFlags, aOpacity)) {
     RecoverFromInvalidFrames(aSize, aFlags);
     return ImgDrawResult::TEMPORARY_ERROR;
   }
   if (!frameIsFinished) {
     return ImgDrawResult::INCOMPLETE;
@@ -1857,18 +1854,21 @@ RasterImage::OptimalImageSizeForDest(con
   MOZ_ASSERT(aDest.width >= 0 || ceil(aDest.width) <= INT32_MAX ||
              aDest.height >= 0 || ceil(aDest.height) <= INT32_MAX,
              "Unexpected destination size");
 
   if (mSize.IsEmpty() || aDest.IsEmpty()) {
     return IntSize(0, 0);
   }
 
-  if (aSamplingFilter != SamplingFilter::GOOD) {
-    return mSize;
+  IntSize destSize = IntSize::Ceil(aDest.width, aDest.height);
+
+  if (aSamplingFilter == SamplingFilter::GOOD &&
+      CanDownscaleDuringDecode(destSize, aFlags)) {
+    return destSize;
   }
 
-  IntSize destSize = IntSize::Ceil(aDest.width, aDest.height);
-  return GetDownscaleDecodeSize(destSize, aFlags);
+  // We can't scale to this size. Use our intrinsic size for now.
+  return mSize;
 }
 
 } // namespace image
 } // namespace mozilla
--- a/image/RasterImage.h
+++ b/image/RasterImage.h
@@ -430,19 +430,19 @@ private: // data
 
   TimeStamp mDrawStartTime;
 
 
   //////////////////////////////////////////////////////////////////////////////
   // Scaling.
   //////////////////////////////////////////////////////////////////////////////
 
-  // Determines the decode size depending on whether we can downscale during
-  // decode with the given parameters.
-  gfx::IntSize GetDownscaleDecodeSize(const nsIntSize& aSize, uint32_t aFlags);
+  // Determines whether we can downscale during decode with the given
+  // parameters.
+  bool CanDownscaleDuringDecode(const nsIntSize& aSize, uint32_t aFlags);
 
 
   // Error handling.
   void DoError();
 
   class HandleErrorWorker : public Runnable
   {
   public:
index f5ff04a59356a0e3a3dc4e1cbb134ddb8094c39b..6abef0f99b48386abe1744744a8b7d6ab7200d62
GIT binary patch
literal 1219
zc%1ux<NpH&0WUXCHwH#V1_nkTWcYuZ!I^=X2?RhSGZ3(_v48*v8yhPdCkGc7CkH1d
z7Y{!V7dIa_Cnv8UFCV{vfS>>ukC3pCfH06P05XITq?4J21E^7eo0D6BWbpq0gCGZk
z0)qfEqaXv5AS1IN<NqTJ@<4a8GJ*jE6fiO|v#_$Ub8vET0~Kr)U|<5;&BVgY%F4n5
zl&uBIGq4D<3Mm>ovIz$!vMUve7&T5@$f4}C@t|nX#SbdRNkvVZTw>x9l2WQ_>Kd9_
zCZ=ZQ7M51dF0O9w9-dyoA)#U65s^{JDXD4c8JStdC8cHM6_r)ZEv;?s9i3g1CQq3<
zZTgIvvlcC0vUJ(<6)RV5+Pr1!w(UE1?mBe%$kAiRPn<k;>GGAU*RJ2VdF$b$$4{O<
zd;a3(tB;>PfBE|D`;VW$K>lK6U}l5?to{N90wWU(Fi6=!{$gY*2PqI_VO2C_6LJh>
zPb?HxGHT=yahkYr<3Ubk<Dd_sNktdA#8gZks(u7{4eT@GJk~^(&)^<I`0Ew}4>Kb$
z@|Xn~>=}Mte{}xXUH^!WuPfNSCx=}!@l|`8uy60yi4SU>9-p~&@wiEf)sn=b-yAA)
zghc(`ZklsiceT1((cW}*QMqg3IiGhlG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%&rLi@o6~A2F>?i)R|FHWZ>x)Y!XZ60j
zPWQQ#llyk<lkBOVp6=-4xGH4QzN%@J=sX`o>4w1F+Mj9+4@yqcH~e?={G{Nwi|eg3
Y_6t8Rwz)S&bB!MF@9z8`#s6;t05}Nj>i_@%
--- a/image/test/unit/test_imgtools.js
+++ b/image/test/unit/test_imgtools.js
@@ -540,17 +540,17 @@ testdesc = "test scaling a JPG without a
 // we'll reuse the container from the previous test
 istream = imgTools.encodeScaledImage(container, "image/jpeg", 0, 16);
 encodedBytes = streamToArray(istream);
 
 // Get bytes for exected result
 refName = "image2jpg32x16scaled.jpg";
 refFile = do_get_file(refName);
 istream = getFileInputStream(refFile);
-Assert.equal(istream.available(), 1222);
+Assert.equal(istream.available(), 1227);
 referenceBytes = streamToArray(istream);
 
 // compare the encoder's output to the reference file.
 compareArrays(encodedBytes, referenceBytes);
 
 
 /* ========== 21 ========== */
 testnum++;