Bug 1271002. Notify right away after getting the first frame of an animated image. r=seth

The decoding loop in Decoder::Decode only pauses to report progress when it runs out of bytes to decode. So for long animated images where the network is keeping up with decoding it will be a relatively long time until we deliver the first frame complete notification and corresponding invalidation. In most cases this shouldn't be too expensive as it is just dispatching a runnable to the main thread from the decoding thread.
This commit is contained in:
Timothy Nikkel
2016-05-13 16:19:55 -05:00
parent ec48e677ef
commit 33e0f788db
3 changed files with 12 additions and 1 deletions

View File

@@ -469,6 +469,7 @@ void
DecodePool::NotifyProgress(Decoder* aDecoder)
{
MOZ_ASSERT(aDecoder);
MOZ_ASSERT(aDecoder->HasProgress() && !aDecoder->IsMetadataDecode());
if (!NS_IsMainThread() ||
(aDecoder->GetDecoderFlags() & DecoderFlags::ASYNC_NOTIFY)) {

View File

@@ -79,6 +79,11 @@ public:
*/
already_AddRefed<nsIEventTarget> GetIOEventTarget();
/**
* Notify about progress on aDecoder.
*/
void NotifyProgress(Decoder* aDecoder);
private:
friend class DecodePoolWorker;
@@ -87,7 +92,6 @@ private:
void Decode(Decoder* aDecoder);
void NotifyDecodeComplete(Decoder* aDecoder);
void NotifyProgress(Decoder* aDecoder);
static StaticRefPtr<DecodePool> sSingleton;
static uint32_t sNumCores;

View File

@@ -449,6 +449,12 @@ Decoder::PostFrameStop(Opacity aFrameOpacity
mInvalidRect.UnionRect(mInvalidRect,
gfx::IntRect(gfx::IntPoint(0, 0), GetSize()));
}
// If we are going to keep decoding we should notify now about the first frame being done.
if (mFrameCount == 1 && HasAnimation()) {
MOZ_ASSERT(HasProgress());
DecodePool::Singleton()->NotifyProgress(this);
}
}
void