@@ -38,21 +38,21 @@ IDecodingTask::NotifyProgress(NotNull<RasterImage*> aImage,
3838 Progress progress = aDecoder->TakeProgress ();
3939 IntRect invalidRect = aDecoder->TakeInvalidRect ();
4040 Maybe<uint32_t > frameCount = aDecoder->TakeCompleteFrameCount ();
41+ DecoderFlags decoderFlags = aDecoder->GetDecoderFlags ();
4142 SurfaceFlags surfaceFlags = aDecoder->GetSurfaceFlags ();
4243
4344 // Synchronously notify if we can.
44- if (NS_IsMainThread() &&
45- !(aDecoder->GetDecoderFlags () & DecoderFlags::ASYNC_NOTIFY )) {
46- aImage->NotifyProgress (progress, invalidRect,
47- frameCount, surfaceFlags);
45+ if (NS_IsMainThread() && !(decoderFlags & DecoderFlags::ASYNC_NOTIFY )) {
46+ aImage->NotifyProgress (progress, invalidRect, frameCount,
47+ decoderFlags, surfaceFlags);
4848 return ;
4949 }
5050
5151 // We're forced to notify asynchronously.
5252 NotNull<RefPtr<RasterImage>> image = aImage;
5353 NS_DispatchToMainThread (NS_NewRunnableFunction([=]() -> void {
54- image->NotifyProgress (progress, invalidRect,
55- frameCount , surfaceFlags);
54+ image->NotifyProgress (progress, invalidRect, frameCount,
55+ decoderFlags , surfaceFlags);
5656 }));
5757}
5858
@@ -70,21 +70,23 @@ IDecodingTask::NotifyDecodeComplete(NotNull<RasterImage*> aImage,
7070 Progress progress = aDecoder->TakeProgress ();
7171 IntRect invalidRect = aDecoder->TakeInvalidRect ();
7272 Maybe<uint32_t > frameCount = aDecoder->TakeCompleteFrameCount ();
73+ DecoderFlags decoderFlags = aDecoder->GetDecoderFlags ();
7374 SurfaceFlags surfaceFlags = aDecoder->GetSurfaceFlags ();
7475
7576 // Synchronously notify if we can.
76- if (NS_IsMainThread() &&
77- !(aDecoder->GetDecoderFlags () & DecoderFlags::ASYNC_NOTIFY )) {
77+ if (NS_IsMainThread() && !(decoderFlags & DecoderFlags::ASYNC_NOTIFY )) {
7878 aImage->NotifyDecodeComplete (finalStatus, metadata, telemetry, progress,
79- invalidRect, frameCount, surfaceFlags);
79+ invalidRect, frameCount, decoderFlags,
80+ surfaceFlags);
8081 return ;
8182 }
8283
8384 // We're forced to notify asynchronously.
8485 NotNull<RefPtr<RasterImage>> image = aImage;
8586 NS_DispatchToMainThread (NS_NewRunnableFunction([=]() -> void {
8687 image->NotifyDecodeComplete (finalStatus, metadata, telemetry, progress,
87- invalidRect, frameCount, surfaceFlags);
88+ invalidRect, frameCount, decoderFlags,
89+ surfaceFlags);
8890 }));
8991}
9092
@@ -100,59 +102,6 @@ IDecodingTask::Resume()
100102}
101103
102104
103- // /////////////////////////////////////////////////////////////////////////////
104- // AnimationDecodingTask implementation.
105- // /////////////////////////////////////////////////////////////////////////////
106-
107- AnimationDecodingTask::AnimationDecodingTask (NotNull<Decoder*> aDecoder)
108- : mMutex (" mozilla::image::AnimationDecodingTask" )
109- , mDecoder (aDecoder)
110- {
111- MOZ_ASSERT (!mDecoder ->IsMetadataDecode (),
112- " Use MetadataDecodingTask for metadata decodes" );
113- MOZ_ASSERT (!mDecoder ->IsFirstFrameDecode (),
114- " Use DecodingTask for single-frame image decodes" );
115- }
116-
117- void
118- AnimationDecodingTask::Run ()
119- {
120- MutexAutoLock lock (mMutex );
121-
122- while (true ) {
123- LexerResult result = mDecoder ->Decode (WrapNotNull (this ));
124-
125- if (result.is <TerminalState>()) {
126- NotifyDecodeComplete (mDecoder ->GetImage (), mDecoder );
127- return ; // We're done.
128- }
129-
130- MOZ_ASSERT (result.is <Yield>());
131-
132- // Notify for the progress we've made so far.
133- if (mDecoder ->HasProgress ()) {
134- NotifyProgress (mDecoder ->GetImage (), mDecoder );
135- }
136-
137- if (result == LexerResult (Yield::NEED_MORE_DATA )) {
138- // We can't make any more progress right now. The decoder itself will
139- // ensure that we get reenqueued when more data is available; just return
140- // for now.
141- return ;
142- }
143-
144- // Right now we don't do anything special for other kinds of yields, so just
145- // keep working.
146- }
147- }
148-
149- bool
150- AnimationDecodingTask::ShouldPreferSyncRun () const
151- {
152- return mDecoder ->ShouldSyncDecode (gfxPrefs::ImageMemDecodeBytesAtATime ());
153- }
154-
155-
156105// /////////////////////////////////////////////////////////////////////////////
157106// MetadataDecodingTask implementation.
158107// /////////////////////////////////////////////////////////////////////////////
0 commit comments