summaryrefslogtreecommitdiff
path: root/image
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-01-21 13:58:20 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-01-21 13:58:20 +0100
commit64d65e096bd762bfa54c362a83edd8dcd5ba2e53 (patch)
tree288c5dd4f3be98bfe6eb38bb775eacd84ac10592 /image
parentd1a0bfe221b91ea37a34d0b0360f347d2a6394e5 (diff)
downloaduxp-64d65e096bd762bfa54c362a83edd8dcd5ba2e53.tar.gz
Make resuming of decoding work for anonymous decoders.
Diffstat (limited to 'image')
-rw-r--r--image/IDecodingTask.cpp15
-rw-r--r--image/IDecodingTask.h8
-rw-r--r--image/ImageOps.cpp2
3 files changed, 18 insertions, 7 deletions
diff --git a/image/IDecodingTask.cpp b/image/IDecodingTask.cpp
index a067e7a7d1..6e2f039be1 100644
--- a/image/IDecodingTask.cpp
+++ b/image/IDecodingTask.cpp
@@ -142,8 +142,10 @@ MetadataDecodingTask::Run()
// AnonymousDecodingTask implementation.
///////////////////////////////////////////////////////////////////////////////
-AnonymousDecodingTask::AnonymousDecodingTask(NotNull<Decoder*> aDecoder)
+AnonymousDecodingTask::AnonymousDecodingTask(NotNull<Decoder*> aDecoder,
+ bool aResumable)
: mDecoder(aDecoder)
+ , mResumable(aResumable)
{ }
void
@@ -168,5 +170,16 @@ AnonymousDecodingTask::Run()
}
}
+void
+AnonymousDecodingTask::Resume()
+{
+ // Anonymous decoders normally get all their data at once. We have some situations
+ // where they don't. If explicitly requested, resuming should be supported.
+ if (mResumable) {
+ RefPtr<AnonymousDecodingTask> self(this);
+ NS_DispatchToMainThread(NS_NewRunnableFunction([self]() -> void { self->Run(); }));
+ }
+}
+
} // namespace image
} // namespace mozilla
diff --git a/image/IDecodingTask.h b/image/IDecodingTask.h
index 196ce5fdc4..3cbab5006f 100644
--- a/image/IDecodingTask.h
+++ b/image/IDecodingTask.h
@@ -102,22 +102,20 @@ class AnonymousDecodingTask final : public IDecodingTask
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AnonymousDecodingTask, override)
- explicit AnonymousDecodingTask(NotNull<Decoder*> aDecoder);
+ explicit AnonymousDecodingTask(NotNull<Decoder*> aDecoder, bool aResumable);
void Run() override;
bool ShouldPreferSyncRun() const override { return true; }
TaskPriority Priority() const override { return TaskPriority::eLow; }
- // Anonymous decoders normally get all their data at once. We have tests where
- // they don't; in these situations, the test re-runs them manually. So no
- // matter what, we don't want to resume by posting a task to the DecodePool.
- void Resume() override { }
+ void Resume() override;
private:
virtual ~AnonymousDecodingTask() { }
NotNull<RefPtr<Decoder>> mDecoder;
+ bool mResumable;
};
} // namespace image
diff --git a/image/ImageOps.cpp b/image/ImageOps.cpp
index addee7f155..ddd2f200e5 100644
--- a/image/ImageOps.cpp
+++ b/image/ImageOps.cpp
@@ -126,7 +126,7 @@ ImageOps::DecodeToSurface(nsIInputStream* aInputStream,
}
// Run the decoder synchronously.
- RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
+ RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
task->Run();
if (!decoder->GetDecodeDone() || decoder->HasError()) {
return nullptr;