зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1128223 (Part 4) - Remove DecodeStrategy and WantDecodedFrames. r=tn
This commit is contained in:
Родитель
93452dd653
Коммит
8c97bc6222
|
@ -330,7 +330,7 @@ RasterImage::Init(const char* aMimeType,
|
|||
}
|
||||
|
||||
// Create the initial size decoder.
|
||||
nsresult rv = Decode(DecodeStrategy::ASYNC, Nothing(), DECODE_FLAGS_DEFAULT);
|
||||
nsresult rv = Decode(Nothing(), DECODE_FLAGS_DEFAULT);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ RasterImage::LookupFrame(uint32_t aFrameNum,
|
|||
// The OS threw this frame away. We need to redecode if we can.
|
||||
MOZ_ASSERT(!mAnim, "Animated frames should be locked");
|
||||
|
||||
WantDecodedFrames(ThebesIntSize(requestedSize), aFlags);
|
||||
Decode(Some(ThebesIntSize(requestedSize)), aFlags);
|
||||
|
||||
// If we can sync decode, we should already have the frame.
|
||||
if (aFlags & FLAG_SYNC_DECODE) {
|
||||
|
@ -1132,7 +1132,7 @@ RasterImage::OnImageDataComplete(nsIRequest*, nsISupports*, nsresult aStatus,
|
|||
// We need to guarantee that we've gotten the image's size, or at least
|
||||
// determined that we won't be able to get it, before we deliver the load
|
||||
// event. That means we have to do a synchronous size decode here.
|
||||
Decode(DecodeStrategy::SYNC_IF_POSSIBLE, Nothing(), DECODE_FLAGS_DEFAULT);
|
||||
Decode(Nothing(), FLAG_SYNC_DECODE);
|
||||
}
|
||||
|
||||
// Determine our final status, giving precedence to Necko failure codes. We
|
||||
|
@ -1399,30 +1399,6 @@ RasterImage::CreateDecoder(const Maybe<nsIntSize>& aSize, uint32_t aFlags)
|
|||
return decoder.forget();
|
||||
}
|
||||
|
||||
void
|
||||
RasterImage::WantDecodedFrames(const nsIntSize& aSize, uint32_t aFlags)
|
||||
{
|
||||
if (mDownscaleDuringDecode) {
|
||||
// We're about to decode again, which may mean that some of the previous
|
||||
// sizes we've decoded at aren't useful anymore. We can allow them to
|
||||
// expire from the cache by unlocking them here. When the decode finishes,
|
||||
// it will send an invalidation that will cause all instances of this image
|
||||
// to redraw. If this image is locked, any surfaces that are still useful
|
||||
// will become locked again when LookupFrame touches them, and the remainder
|
||||
// will eventually expire.
|
||||
SurfaceCache::UnlockSurfaces(ImageKey(this));
|
||||
}
|
||||
|
||||
DecodeStrategy strategy = DecodeStrategy::ASYNC;
|
||||
if (aFlags & FLAG_SYNC_DECODE) {
|
||||
strategy = DecodeStrategy::SYNC_IF_POSSIBLE;
|
||||
} else if (aFlags & FLAG_SYNC_DECODE_IF_FAST) {
|
||||
strategy = DecodeStrategy::SYNC_FOR_SMALL_IMAGES;
|
||||
}
|
||||
|
||||
Decode(strategy, Some(aSize), aFlags);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void requestDecode() */
|
||||
NS_IMETHODIMP
|
||||
|
@ -1496,9 +1472,7 @@ RasterImage::IsDecoded()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RasterImage::Decode(DecodeStrategy aStrategy,
|
||||
const Maybe<nsIntSize>& aSize,
|
||||
uint32_t aFlags)
|
||||
RasterImage::Decode(const Maybe<nsIntSize>& aSize, uint32_t aFlags)
|
||||
{
|
||||
MOZ_ASSERT(!aSize || NS_IsMainThread());
|
||||
|
||||
|
@ -1518,6 +1492,17 @@ RasterImage::Decode(DecodeStrategy aStrategy,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mDownscaleDuringDecode && aSize) {
|
||||
// We're about to decode again, which may mean that some of the previous
|
||||
// sizes we've decoded at aren't useful anymore. We can allow them to
|
||||
// expire from the cache by unlocking them here. When the decode finishes,
|
||||
// it will send an invalidation that will cause all instances of this image
|
||||
// to redraw. If this image is locked, any surfaces that are still useful
|
||||
// will become locked again when LookupFrame touches them, and the remainder
|
||||
// will eventually expire.
|
||||
SurfaceCache::UnlockSurfaces(ImageKey(this));
|
||||
}
|
||||
|
||||
if (aSize) {
|
||||
// This isn't a size decode (which doesn't send any early notifications), so
|
||||
// send out notifications right away.
|
||||
|
@ -1528,19 +1513,19 @@ RasterImage::Decode(DecodeStrategy aStrategy,
|
|||
|
||||
if (mHasSourceData) {
|
||||
// If we have all the data, we can sync decode if requested.
|
||||
if (aStrategy == DecodeStrategy::SYNC_FOR_SMALL_IMAGES) {
|
||||
PROFILER_LABEL_PRINTF("DecodePool", "SyncDecodeIfSmall",
|
||||
js::ProfileEntry::Category::GRAPHICS, "%s", GetURIString().get());
|
||||
DecodePool::Singleton()->SyncDecodeIfSmall(decoder);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aStrategy == DecodeStrategy::SYNC_IF_POSSIBLE) {
|
||||
if (aFlags & FLAG_SYNC_DECODE) {
|
||||
PROFILER_LABEL_PRINTF("DecodePool", "SyncDecodeIfPossible",
|
||||
js::ProfileEntry::Category::GRAPHICS, "%s", GetURIString().get());
|
||||
DecodePool::Singleton()->SyncDecodeIfPossible(decoder);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aFlags & FLAG_SYNC_DECODE_IF_FAST) {
|
||||
PROFILER_LABEL_PRINTF("DecodePool", "SyncDecodeIfSmall",
|
||||
js::ProfileEntry::Category::GRAPHICS, "%s", GetURIString().get());
|
||||
DecodePool::Singleton()->SyncDecodeIfSmall(decoder);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Perform an async decode. We also take this path if we don't have all the
|
||||
|
|
|
@ -133,12 +133,6 @@ class Decoder;
|
|||
class FrameAnimator;
|
||||
class SourceBuffer;
|
||||
|
||||
enum class DecodeStrategy : uint8_t {
|
||||
ASYNC,
|
||||
SYNC_FOR_SMALL_IMAGES,
|
||||
SYNC_IF_POSSIBLE
|
||||
};
|
||||
|
||||
/**
|
||||
* Given a set of imgIContainer FLAG_* flags, returns those flags that can
|
||||
* affect the output of decoders.
|
||||
|
@ -337,13 +331,11 @@ private:
|
|||
|
||||
/**
|
||||
* Creates and runs a decoder, either synchronously or asynchronously
|
||||
* according to @aStrategy. Passes the provided target size @aSize and decode
|
||||
* according to @aFlags. Passes the provided target size @aSize and decode
|
||||
* flags @aFlags to CreateDecoder. If a size decode is desired, pass Nothing
|
||||
* for @aSize.
|
||||
*/
|
||||
NS_IMETHOD Decode(DecodeStrategy aStrategy,
|
||||
const Maybe<nsIntSize>& aSize,
|
||||
uint32_t aFlags);
|
||||
NS_IMETHOD Decode(const Maybe<nsIntSize>& aSize, uint32_t aFlags);
|
||||
|
||||
/**
|
||||
* Creates a new decoder with a target size of @aSize and decode flags
|
||||
|
@ -353,8 +345,6 @@ private:
|
|||
already_AddRefed<Decoder> CreateDecoder(const Maybe<nsIntSize>& aSize,
|
||||
uint32_t aFlags);
|
||||
|
||||
void WantDecodedFrames(const nsIntSize& aSize, uint32_t aFlags);
|
||||
|
||||
private: // data
|
||||
nsIntSize mSize;
|
||||
Orientation mOrientation;
|
||||
|
|
Загрузка…
Ссылка в новой задаче