Backed out changeset 6c8bf287d25b (bug 1462431) for web platform reftest failure. r=aosmond

This commit is contained in:
Andrew Osmond 2018-05-18 08:59:26 -04:00
parent f3770eb5fc
commit fd436b732a
5 changed files with 33 additions and 33 deletions

View File

@ -340,7 +340,8 @@ RasterImage::LookupFrame(const IntSize& aSize,
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);
@ -637,7 +638,11 @@ RasterImage::GetImageContainerSize(LayerManager* aManager,
return IntSize(0, 0);
}
return GetDownscaleDecodeSize(aSize, aFlags);
if (!CanDownscaleDuringDecode(aSize, aFlags)) {
return mSize;
}
return aSize;
}
NS_IMETHODIMP_(bool)
@ -1367,46 +1372,39 @@ HaveSkia()
#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
@ -1436,8 +1434,7 @@ RasterImage::DrawInternal(DrawableSurface&& aSurface,
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)) {
@ -1862,12 +1859,15 @@ RasterImage::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame,
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

View File

@ -435,9 +435,9 @@ private: // data
// 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.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -545,7 +545,7 @@ encodedBytes = streamToArray(istream);
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.