Bug 1490938. Pass the high quality scaling flag when we request decode of images in most cases. r=aosmond

If we do not pass the high quality scaling flag than the resulting surface will be marked as cannot substitute, which is not accurate, so we don't want.

The only place that actually tries to be smart about the size is nsImageFrame::MaybeDecodeForPredictedSize. All other cases just ask for the intrinsic size.

The two most likely cases are that there are no decoded copies of the image, or there is one decoded (or in progress) copy of the image.

In the first case we will request decode at the instrinsic size, and then if we draw at a different size that draw will request the proper size. This doesn't change with this patch.

In the second case there is a decoded copy already available, this is likely from a draw call on the image, and that is the surface size that we want. So we save a decode. If we are actually drawing the image at two different sizes the second size will be slightly delayed, but we have the wrongly sized copy of the image that we can draw until then. This seems like a good tradeoff to avoid always decoding an instrinic size copy of images.
This commit is contained in:
Timothy Nikkel 2018-09-27 18:30:17 -05:00
parent a8157bb89d
commit 1438d13673
6 changed files with 15 additions and 8 deletions

View File

@ -82,7 +82,8 @@ public:
// Request decoding at the intrinsic size.
mImage->RequestDecodeForSize(IntSize(width, height),
imgIContainer::DECODE_FLAGS_DEFAULT);
imgIContainer::DECODE_FLAGS_DEFAULT |
imgIContainer::FLAG_HIGH_QUALITY_SCALING);
// If there's already an error, we may never get a FRAME_COMPLETE
// notification, so go ahead and notify our owner right away.

View File

@ -1136,7 +1136,8 @@ RasterImage::StartDecoding(uint32_t aFlags)
return NS_OK;
}
uint32_t flags = (aFlags & FLAG_ASYNC_NOTIFY) | FLAG_SYNC_DECODE_IF_FAST;
uint32_t flags =
(aFlags & FLAG_ASYNC_NOTIFY) | FLAG_SYNC_DECODE_IF_FAST | FLAG_HIGH_QUALITY_SCALING;
return RequestDecodeForSize(mSize, flags);
}
@ -1152,7 +1153,8 @@ RasterImage::StartDecodingWithResult(uint32_t aFlags)
return false;
}
uint32_t flags = (aFlags & FLAG_ASYNC_NOTIFY) | FLAG_SYNC_DECODE_IF_FAST;
uint32_t flags =
(aFlags & FLAG_ASYNC_NOTIFY) | FLAG_SYNC_DECODE_IF_FAST | FLAG_HIGH_QUALITY_SCALING;
DrawableSurface surface = RequestDecodeForSizeInternal(mSize, flags);
return surface && surface->IsFinished();
}
@ -1814,7 +1816,7 @@ RasterImage::NotifyDecodeComplete(const DecoderFinalStatus& aStatus,
// If we were a metadata decode and a full decode was requested, do it.
if (mWantFullDecode) {
mWantFullDecode = false;
RequestDecodeForSize(mSize, DECODE_FLAGS_DEFAULT);
RequestDecodeForSize(mSize, DECODE_FLAGS_DEFAULT | FLAG_HIGH_QUALITY_SCALING);
}
}
}

View File

@ -1186,7 +1186,8 @@ nsBulletFrame::Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aDa
// Request a decode at that size.
container->RequestDecodeForSize(IntSize(width, height),
imgIContainer::DECODE_FLAGS_DEFAULT);
imgIContainer::DECODE_FLAGS_DEFAULT |
imgIContainer::FLAG_HIGH_QUALITY_SCALING);
}
InvalidateFrame();

View File

@ -2558,7 +2558,8 @@ nsImageFrame::IconLoad::Notify(imgIRequest* aRequest,
// Request a decode at that size.
image->RequestDecodeForSize(IntSize(width, height),
imgIContainer::DECODE_FLAGS_DEFAULT);
imgIContainer::DECODE_FLAGS_DEFAULT |
imgIContainer::FLAG_HIGH_QUALITY_SCALING);
}
nsTObserverArray<nsImageFrame*>::ForwardIterator iter(mIconObservers);

View File

@ -251,7 +251,8 @@ AlertImageRequest::Notify(imgIRequest* aRequest, int32_t aType,
int32_t width = 0, height = 0;
image->GetWidth(&width);
image->GetHeight(&height);
image->RequestDecodeForSize(gfx::IntSize(width, height), imgIContainer::FLAG_NONE);
image->RequestDecodeForSize(gfx::IntSize(width, height),
imgIContainer::FLAG_HIGH_QUALITY_SCALING);
}
return NS_OK;
}

View File

@ -289,7 +289,8 @@ nsMenuItemIconX::Notify(imgIRequest* aRequest,
int32_t width = 0, height = 0;
image->GetWidth(&width);
image->GetHeight(&height);
image->RequestDecodeForSize(nsIntSize(width, height), imgIContainer::FLAG_NONE);
image->RequestDecodeForSize(nsIntSize(width, height),
imgIContainer::FLAG_HIGH_QUALITY_SCALING);
}
if (aType == imgINotificationObserver::FRAME_COMPLETE) {