Bug 1291045 (Part 2) - Pass the image into NotifyProgress() and NotifyDecodeComplete() explicitly. r=edwin

This commit is contained in:
Seth Fowler
2016-08-04 19:04:14 -07:00
parent 77d123ca25
commit 35e9d64ec9
2 changed files with 16 additions and 15 deletions

View File

@@ -23,7 +23,7 @@ namespace image {
///////////////////////////////////////////////////////////////////////////////
static void
NotifyProgress(NotNull<Decoder*> aDecoder)
NotifyProgress(NotNull<RasterImage*> aImage, NotNull<Decoder*> aDecoder)
{
MOZ_ASSERT(aDecoder->HasProgress() && !aDecoder->IsMetadataDecode());
@@ -41,33 +41,34 @@ NotifyProgress(NotNull<Decoder*> aDecoder)
// Synchronously notify if we can.
if (NS_IsMainThread() &&
!(aDecoder->GetDecoderFlags() & DecoderFlags::ASYNC_NOTIFY)) {
aDecoder->GetImage()->NotifyProgress(progress, invalidRect,
frameCount, surfaceFlags);
aImage->NotifyProgress(progress, invalidRect,
frameCount, surfaceFlags);
return;
}
// We're forced to notify asynchronously.
NotNull<RefPtr<Decoder>> decoder = aDecoder;
NotNull<RefPtr<RasterImage>> image = aImage;
NS_DispatchToMainThread(NS_NewRunnableFunction([=]() -> void {
decoder->GetImage()->NotifyProgress(progress, invalidRect,
frameCount, surfaceFlags);
image->NotifyProgress(progress, invalidRect,
frameCount, surfaceFlags);
}));
}
static void
NotifyDecodeComplete(NotNull<Decoder*> aDecoder)
NotifyDecodeComplete(NotNull<RasterImage*> aImage, NotNull<Decoder*> aDecoder)
{
// Synchronously notify if we can.
if (NS_IsMainThread() &&
!(aDecoder->GetDecoderFlags() & DecoderFlags::ASYNC_NOTIFY)) {
aDecoder->GetImage()->FinalizeDecoder(aDecoder);
aImage->FinalizeDecoder(aDecoder);
return;
}
// We're forced to notify asynchronously.
NotNull<RefPtr<RasterImage>> image = aImage;
NotNull<RefPtr<Decoder>> decoder = aDecoder;
NS_DispatchToMainThread(NS_NewRunnableFunction([=]() -> void {
decoder->GetImage()->FinalizeDecoder(decoder.get());
image->FinalizeDecoder(decoder.get());
}));
}
@@ -103,7 +104,7 @@ DecodingTask::Run()
LexerResult result = mDecoder->Decode(WrapNotNull(this));
if (result.is<TerminalState>()) {
NotifyDecodeComplete(mDecoder);
NotifyDecodeComplete(mDecoder->GetImage(), mDecoder);
return; // We're done.
}
@@ -111,7 +112,7 @@ DecodingTask::Run()
// Notify for the progress we've made so far.
if (mDecoder->HasProgress()) {
NotifyProgress(mDecoder);
NotifyProgress(mDecoder->GetImage(), mDecoder);
}
if (result == LexerResult(Yield::NEED_MORE_DATA)) {
@@ -153,7 +154,7 @@ AnimationDecodingTask::Run()
LexerResult result = mDecoder->Decode(WrapNotNull(this));
if (result.is<TerminalState>()) {
NotifyDecodeComplete(mDecoder);
NotifyDecodeComplete(mDecoder->GetImage(), mDecoder);
return; // We're done.
}
@@ -161,7 +162,7 @@ AnimationDecodingTask::Run()
// Notify for the progress we've made so far.
if (mDecoder->HasProgress()) {
NotifyProgress(mDecoder);
NotifyProgress(mDecoder->GetImage(), mDecoder);
}
if (result == LexerResult(Yield::NEED_MORE_DATA)) {
@@ -200,7 +201,7 @@ MetadataDecodingTask::Run()
LexerResult result = mDecoder->Decode(WrapNotNull(this));
if (result.is<TerminalState>()) {
NotifyDecodeComplete(mDecoder);
NotifyDecodeComplete(mDecoder->GetImage(), mDecoder);
return; // We're done.
}