summaryrefslogtreecommitdiffstats
path: root/dom/canvas/OffscreenCanvasDisplayHelper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/canvas/OffscreenCanvasDisplayHelper.cpp')
-rw-r--r--dom/canvas/OffscreenCanvasDisplayHelper.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/dom/canvas/OffscreenCanvasDisplayHelper.cpp b/dom/canvas/OffscreenCanvasDisplayHelper.cpp
index 9e1cbb3e75..972fa468d2 100644
--- a/dom/canvas/OffscreenCanvasDisplayHelper.cpp
+++ b/dom/canvas/OffscreenCanvasDisplayHelper.cpp
@@ -61,6 +61,22 @@ void OffscreenCanvasDisplayHelper::DestroyCanvas() {
mWorkerRef = nullptr;
}
+bool OffscreenCanvasDisplayHelper::CanElementCaptureStream() const {
+ MutexAutoLock lock(mMutex);
+ return !!mWorkerRef;
+}
+
+bool OffscreenCanvasDisplayHelper::UsingElementCaptureStream() const {
+ MutexAutoLock lock(mMutex);
+
+ if (NS_WARN_IF(!NS_IsMainThread())) {
+ MOZ_ASSERT_UNREACHABLE("Should not call off main-thread!");
+ return !!mCanvasElement;
+ }
+
+ return mCanvasElement && mCanvasElement->UsingCaptureStream();
+}
+
CanvasContextType OffscreenCanvasDisplayHelper::GetContextType() const {
MutexAutoLock lock(mMutex);
return mType;
@@ -116,11 +132,11 @@ void OffscreenCanvasDisplayHelper::FlushForDisplay() {
return;
}
- class FlushWorkerRunnable final : public WorkerRunnable {
+ class FlushWorkerRunnable final : public WorkerThreadRunnable {
public:
FlushWorkerRunnable(WorkerPrivate* aWorkerPrivate,
OffscreenCanvasDisplayHelper* aDisplayHelper)
- : WorkerRunnable(aWorkerPrivate, "FlushWorkerRunnable"),
+ : WorkerThreadRunnable("FlushWorkerRunnable"),
mDisplayHelper(aDisplayHelper) {}
bool WorkerRun(JSContext*, WorkerPrivate*) override {
@@ -148,7 +164,7 @@ void OffscreenCanvasDisplayHelper::FlushForDisplay() {
// Otherwise we are calling from the main thread during painting to a canvas
// on a worker thread.
auto task = MakeRefPtr<FlushWorkerRunnable>(mWorkerRef->Private(), this);
- task->Dispatch();
+ task->Dispatch(mWorkerRef->Private());
}
bool OffscreenCanvasDisplayHelper::CommitFrameToCompositor(
@@ -418,7 +434,7 @@ OffscreenCanvasDisplayHelper::GetSurfaceSnapshot() {
public:
SnapshotWorkerRunnable(WorkerPrivate* aWorkerPrivate,
OffscreenCanvasDisplayHelper* aDisplayHelper)
- : MainThreadWorkerRunnable(aWorkerPrivate, "SnapshotWorkerRunnable"),
+ : MainThreadWorkerRunnable("SnapshotWorkerRunnable"),
mMonitor("SnapshotWorkerRunnable::mMonitor"),
mDisplayHelper(aDisplayHelper) {}
@@ -498,7 +514,7 @@ OffscreenCanvasDisplayHelper::GetSurfaceSnapshot() {
if (mWorkerRef) {
workerRunnable =
MakeRefPtr<SnapshotWorkerRunnable>(mWorkerRef->Private(), this);
- workerRunnable->Dispatch();
+ workerRunnable->Dispatch(mWorkerRef->Private());
}
}