mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1119774 (Part 2) - Add RequestDecodeForSize to imgIContainer. r=tn
This commit is contained in:
parent
acf495d902
commit
a2717678e6
@ -69,7 +69,7 @@ native nsIntSizeByVal(nsIntSize);
|
||||
*
|
||||
* Internally, imgIContainer also manages animation of images.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(14ea6fa5-183e-4409-ac88-110bd2e05292)]
|
||||
[scriptable, builtinclass, uuid(4adb4c92-284d-4f5a-85e7-e924ec57510f)]
|
||||
interface imgIContainer : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -345,11 +345,27 @@ interface imgIContainer : nsISupports
|
||||
void requestDecode();
|
||||
|
||||
/*
|
||||
* This is equivalent to requestDecode() but it also decodes some of the
|
||||
* image.
|
||||
* This is equivalent to requestDecode() but it also synchronously decodes
|
||||
* images that can be decoded "quickly" according to some heuristic.
|
||||
*/
|
||||
[noscript] void startDecoding();
|
||||
|
||||
/*
|
||||
* This method is equivalent to requestDecode(), but enables the caller to
|
||||
* provide more detailed information about the decode request.
|
||||
*
|
||||
* @param aSize The size to which the image should be scaled while decoding,
|
||||
* if possible. If the image cannot be scaled to this size while
|
||||
* being decoded, it will be decoded at its intrinsic size.
|
||||
* @param aFlags Flags of the FLAG_* variety. Only the decode flags
|
||||
* (FLAG_DECODE_*) and FLAG_SYNC_DECODE (which will
|
||||
* synchronously decode images that can be decoded "quickly",
|
||||
* just like startDecoding() does) are accepted; others will be
|
||||
* ignored.
|
||||
*/
|
||||
[noscript] void requestDecodeForSize([const] in nsIntSize aSize,
|
||||
in uint32_t aFlags);
|
||||
|
||||
/*
|
||||
* Returns true if no more decoding can be performed on this image. Images
|
||||
* with errors return true since they cannot be decoded any further. Note that
|
||||
|
@ -255,6 +255,12 @@ DynamicImage::StartDecoding()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DynamicImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
DynamicImage::IsDecoded()
|
||||
{
|
||||
|
@ -224,6 +224,12 @@ ImageWrapper::StartDecoding()
|
||||
return mInnerImage->StartDecoding();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageWrapper::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
|
||||
{
|
||||
return mInnerImage->RequestDecodeForSize(aSize, aFlags);
|
||||
}
|
||||
|
||||
bool
|
||||
ImageWrapper::IsDecoded()
|
||||
{
|
||||
|
@ -325,7 +325,7 @@ RasterImage::Init(const char* aMimeType,
|
||||
// transient images.
|
||||
MOZ_ASSERT(!(aFlags & INIT_FLAG_TRANSIENT) ||
|
||||
(!(aFlags & INIT_FLAG_DISCARDABLE) &&
|
||||
!(aFlags & INIT_FLAG_DECODE_ON_DRAW),
|
||||
!(aFlags & INIT_FLAG_DECODE_ON_DRAW) &&
|
||||
!(aFlags & INIT_FLAG_DOWNSCALE_DURING_DECODE)),
|
||||
"Illegal init flags for transient image");
|
||||
|
||||
@ -1374,24 +1374,7 @@ RasterImage::WantDecodedFrames(uint32_t aFlags, bool aShouldSyncNotify)
|
||||
NS_IMETHODIMP
|
||||
RasterImage::RequestDecode()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mError) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!mHasSize) {
|
||||
mWantFullDecode = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Look up the first frame of the image, which will implicitly start decoding
|
||||
// if it's not available right now.
|
||||
// XXX(seth): Passing false for aShouldSyncNotify here has the effect of
|
||||
// decoding asynchronously, but that's not obvious from the argument name.
|
||||
// This API needs to be reworked.
|
||||
LookupFrame(0, mSize, DECODE_FLAGS_DEFAULT, /* aShouldSyncNotify = */ false);
|
||||
|
||||
return NS_OK;
|
||||
return RequestDecodeForSize(mSize, DECODE_FLAGS_DEFAULT);
|
||||
}
|
||||
|
||||
/* void startDecode() */
|
||||
@ -1403,20 +1386,38 @@ RasterImage::StartDecoding()
|
||||
NS_NewRunnableMethod(this, &RasterImage::StartDecoding));
|
||||
}
|
||||
|
||||
return RequestDecodeForSize(mSize, FLAG_SYNC_DECODE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RasterImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mError) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!mHasSize) {
|
||||
mWantFullDecode = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Fall back to our intrinsic size if we don't support
|
||||
// downscale-during-decode.
|
||||
nsIntSize targetSize = mDownscaleDuringDecode ? aSize : mSize;
|
||||
|
||||
// Sync decode small images if requested.
|
||||
bool shouldSyncDecodeSmallImages = aFlags & FLAG_SYNC_DECODE;
|
||||
|
||||
// Look up the first frame of the image, which will implicitly start decoding
|
||||
// if it's not available right now.
|
||||
// XXX(seth): Passing true for aShouldSyncNotify here has the effect of
|
||||
// synchronously decoding small images, but that's not obvious from the
|
||||
// argument name. This API needs to be reworked.
|
||||
LookupFrame(0, mSize, DECODE_FLAGS_DEFAULT, /* aShouldSyncNotify = */ true);
|
||||
// synchronously decoding small images, while passing false has the effect of
|
||||
// decoding asynchronously, but that's not obvious from the argument name.
|
||||
// This API needs to be reworked.
|
||||
LookupFrame(0, targetSize, DecodeFlags(aFlags),
|
||||
/* aShouldSyncNotify = */ shouldSyncDecodeSmallImages);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -899,6 +899,15 @@ VectorImage::StartDecoding()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
VectorImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
|
||||
{
|
||||
// Nothing to do for SVG images, though in theory we could rasterize to the
|
||||
// provided size ahead of time if we supported off-main-thread SVG
|
||||
// rasterization...
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
VectorImage::IsDecoded()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user