diff --git a/dom/canvas/OffscreenCanvas.cpp b/dom/canvas/OffscreenCanvas.cpp index adb666018f88..9fc818e4170d 100644 --- a/dom/canvas/OffscreenCanvas.cpp +++ b/dom/canvas/OffscreenCanvas.cpp @@ -24,12 +24,13 @@ namespace dom { OffscreenCanvasCloneData::OffscreenCanvasCloneData(layers::AsyncCanvasRenderer* aRenderer, uint32_t aWidth, uint32_t aHeight, layers::LayersBackend aCompositorBackend, - bool aNeutered) + bool aNeutered, bool aIsWriteOnly) : mRenderer(aRenderer) , mWidth(aWidth) , mHeight(aHeight) , mCompositorBackendType(aCompositorBackend) , mNeutered(aNeutered) + , mIsWriteOnly(aIsWriteOnly) { } @@ -43,6 +44,7 @@ OffscreenCanvas::OffscreenCanvas(uint32_t aWidth, layers::AsyncCanvasRenderer* aRenderer) : mAttrDirty(false) , mNeutered(false) + , mIsWriteOnly(false) , mWidth(aWidth) , mHeight(aHeight) , mCompositorBackendType(aCompositorBackend) @@ -191,7 +193,7 @@ OffscreenCanvasCloneData* OffscreenCanvas::ToCloneData() { return new OffscreenCanvasCloneData(mCanvasRenderer, mWidth, mHeight, - mCompositorBackendType, mNeutered); + mCompositorBackendType, mNeutered, mIsWriteOnly); } /* static */ already_AddRefed diff --git a/dom/canvas/OffscreenCanvas.h b/dom/canvas/OffscreenCanvas.h index 1c8f57b8f4d4..2bd8f15f9882 100644 --- a/dom/canvas/OffscreenCanvas.h +++ b/dom/canvas/OffscreenCanvas.h @@ -35,7 +35,7 @@ struct OffscreenCanvasCloneData final OffscreenCanvasCloneData(layers::AsyncCanvasRenderer* aRenderer, uint32_t aWidth, uint32_t aHeight, layers::LayersBackend aCompositorBackend, - bool aNeutered); + bool aNeutered, bool aIsWriteOnly); ~OffscreenCanvasCloneData(); RefPtr mRenderer; @@ -43,6 +43,7 @@ struct OffscreenCanvasCloneData final uint32_t mHeight; layers::LayersBackend mCompositorBackendType; bool mNeutered; + bool mIsWriteOnly; }; class OffscreenCanvas final : public DOMEventTargetHelper @@ -147,6 +148,16 @@ public: return mNeutered; } + void SetWriteOnly() + { + mIsWriteOnly = true; + } + + bool IsWriteOnly() const + { + return mIsWriteOnly; + } + layers::LayersBackend GetCompositorBackendType() const { return mCompositorBackendType; @@ -164,6 +175,7 @@ private: bool mAttrDirty; bool mNeutered; + bool mIsWriteOnly; uint32_t mWidth; uint32_t mHeight; diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index 3722d1a0062a..ac6d035778c0 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -783,6 +783,10 @@ HTMLCanvasElement::TransferControlToOffscreen(ErrorResult& aRv) sz.height, GetCompositorBackendType(), renderer); + if (mWriteOnly) { + mOffscreenCanvas->SetWriteOnly(); + } + if (!mContextObserver) { mContextObserver = new HTMLCanvasElementObserver(this); }