static void NotifyProgress(NotNull<Decoder*> aDecoder) { MOZ_ASSERT(aDecoder->HasProgress() && !aDecoder->IsMetadataDecode()); Progress progress = aDecoder->TakeProgress(); IntRect invalidRect = aDecoder->TakeInvalidRect(); Maybe<uint32_t> frameCount = aDecoder->TakeCompleteFrameCount(); SurfaceFlags surfaceFlags = aDecoder->GetSurfaceFlags(); // Synchronously notify if we can. if (NS_IsMainThread() && !(aDecoder->GetDecoderFlags() & DecoderFlags::ASYNC_NOTIFY)) { aDecoder->GetImage()->NotifyProgress(progress, invalidRect, frameCount, surfaceFlags); return; } // We're forced to notify asynchronously. NotNull<RefPtr<Decoder>> decoder = aDecoder; NS_DispatchToMainThread(NS_NewRunnableFunction([=]() -> void { decoder->GetImage()->NotifyProgress(progress, invalidRect, frameCount, surfaceFlags); })); }
static void NotifyDecodeComplete(NotNull<Decoder*> aDecoder) { // Synchronously notify if we can. if (NS_IsMainThread() && !(aDecoder->GetDecoderFlags() & DecoderFlags::ASYNC_NOTIFY)) { aDecoder->GetImage()->FinalizeDecoder(aDecoder); return; } // We're forced to notify asynchronously. NotNull<RefPtr<Decoder>> decoder = aDecoder; NS_DispatchToMainThread(NS_NewRunnableFunction([=]() -> void { decoder->GetImage()->FinalizeDecoder(decoder.get()); })); }
/* static */ void IDecodingTask::NotifyProgress(NotNull<Decoder*> aDecoder) { MOZ_ASSERT(aDecoder->HasProgress() && !aDecoder->IsMetadataDecode()); // Synchronously notify if we can. if (NS_IsMainThread() && !(aDecoder->GetDecoderFlags() & DecoderFlags::ASYNC_NOTIFY)) { aDecoder->GetImage()->NotifyProgress(aDecoder->TakeProgress(), aDecoder->TakeInvalidRect(), aDecoder->GetSurfaceFlags()); return; } // We're forced to notify asynchronously. NotNull<RefPtr<Decoder>> decoder = aDecoder; NS_DispatchToMainThread(NS_NewRunnableFunction([=]() -> void { decoder->GetImage()->NotifyProgress(decoder->TakeProgress(), decoder->TakeInvalidRect(), decoder->GetSurfaceFlags()); })); }