Bug 1898238 - Don't call TexTypeForWebgl when initializing offscreen canvas. r=aosmond,jgilbert
This is only used if the OffscreenCanvas has a webgl context, in which case it forwards the tex type to WebGLContext::PresentFrontBuffer(). A later patch in this series will make TexTypeForWebgl() return a different value depending on whether the webgl context is in-process or remote, which is something that cannot be known when the OffscreenCanvas is initialized. This patch therefore removes the field from OffscreenCanvas and makes WebGLContext::PresentFrontBuffer() call TexTypeForWebgl() itself. Differential Revision: https://phabricator.services.mozilla.com/D211289
This commit is contained in:
@@ -587,8 +587,9 @@ Maybe<layers::SurfaceDescriptor> ClientWebGLContext::GetFrontBuffer(
|
||||
}
|
||||
|
||||
Maybe<layers::SurfaceDescriptor> ClientWebGLContext::PresentFrontBuffer(
|
||||
WebGLFramebufferJS* const fb, const layers::TextureType type, bool webvr) {
|
||||
Present(fb, type, webvr);
|
||||
WebGLFramebufferJS* const fb, bool webvr) {
|
||||
const auto texType = GetTexTypeForSwapChain();
|
||||
Present(fb, texType, webvr);
|
||||
return GetFrontBuffer(fb, webvr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1088,8 +1088,7 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
Maybe<layers::SurfaceDescriptor> GetFrontBuffer(
|
||||
WebGLFramebufferJS*, const bool webvr = false) override;
|
||||
Maybe<layers::SurfaceDescriptor> PresentFrontBuffer(
|
||||
WebGLFramebufferJS*, layers::TextureType,
|
||||
const bool webvr = false) override;
|
||||
WebGLFramebufferJS*, const bool webvr = false) override;
|
||||
RefPtr<gfx::SourceSurface> GetFrontBufferSnapshot(
|
||||
bool requireAlphaPremult = true) override;
|
||||
already_AddRefed<layers::FwdTransactionTracker> UseCompositableForwarder(
|
||||
|
||||
@@ -34,13 +34,12 @@ namespace mozilla::dom {
|
||||
|
||||
OffscreenCanvasCloneData::OffscreenCanvasCloneData(
|
||||
OffscreenCanvasDisplayHelper* aDisplay, uint32_t aWidth, uint32_t aHeight,
|
||||
layers::LayersBackend aCompositorBackend, layers::TextureType aTextureType,
|
||||
bool aNeutered, bool aIsWriteOnly, nsIPrincipal* aExpandedReader)
|
||||
layers::LayersBackend aCompositorBackend, bool aNeutered, bool aIsWriteOnly,
|
||||
nsIPrincipal* aExpandedReader)
|
||||
: mDisplay(aDisplay),
|
||||
mWidth(aWidth),
|
||||
mHeight(aHeight),
|
||||
mCompositorBackendType(aCompositorBackend),
|
||||
mTextureType(aTextureType),
|
||||
mNeutered(aNeutered),
|
||||
mIsWriteOnly(aIsWriteOnly),
|
||||
mExpandedReader(aExpandedReader) {}
|
||||
@@ -56,13 +55,12 @@ OffscreenCanvas::OffscreenCanvas(nsIGlobalObject* aGlobal, uint32_t aWidth,
|
||||
|
||||
OffscreenCanvas::OffscreenCanvas(
|
||||
nsIGlobalObject* aGlobal, uint32_t aWidth, uint32_t aHeight,
|
||||
layers::LayersBackend aCompositorBackend, layers::TextureType aTextureType,
|
||||
layers::LayersBackend aCompositorBackend,
|
||||
already_AddRefed<OffscreenCanvasDisplayHelper> aDisplay)
|
||||
: DOMEventTargetHelper(aGlobal),
|
||||
mWidth(aWidth),
|
||||
mHeight(aHeight),
|
||||
mCompositorBackendType(aCompositorBackend),
|
||||
mTextureType(aTextureType),
|
||||
mDisplay(aDisplay) {}
|
||||
|
||||
OffscreenCanvas::~OffscreenCanvas() {
|
||||
@@ -321,7 +319,7 @@ void OffscreenCanvas::DequeueCommitToCompositor() {
|
||||
MOZ_ASSERT(mPendingCommit);
|
||||
mPendingCommit = nullptr;
|
||||
Maybe<OffscreenCanvasDisplayData> update = std::move(mPendingUpdate);
|
||||
mDisplay->CommitFrameToCompositor(mCurrentContext, mTextureType, update);
|
||||
mDisplay->CommitFrameToCompositor(mCurrentContext, update);
|
||||
}
|
||||
|
||||
void OffscreenCanvas::CommitFrameToCompositor() {
|
||||
@@ -338,7 +336,7 @@ void OffscreenCanvas::CommitFrameToCompositor() {
|
||||
}
|
||||
|
||||
Maybe<OffscreenCanvasDisplayData> update = std::move(mPendingUpdate);
|
||||
mDisplay->CommitFrameToCompositor(mCurrentContext, mTextureType, update);
|
||||
mDisplay->CommitFrameToCompositor(mCurrentContext, update);
|
||||
}
|
||||
|
||||
UniquePtr<OffscreenCanvasCloneData> OffscreenCanvas::ToCloneData(
|
||||
@@ -374,8 +372,8 @@ UniquePtr<OffscreenCanvasCloneData> OffscreenCanvas::ToCloneData(
|
||||
}
|
||||
|
||||
auto cloneData = MakeUnique<OffscreenCanvasCloneData>(
|
||||
mDisplay, mWidth, mHeight, mCompositorBackendType, mTextureType,
|
||||
mNeutered, mIsWriteOnly, mExpandedReader);
|
||||
mDisplay, mWidth, mHeight, mCompositorBackendType, mNeutered,
|
||||
mIsWriteOnly, mExpandedReader);
|
||||
SetNeutered();
|
||||
return cloneData;
|
||||
}
|
||||
@@ -598,7 +596,7 @@ already_AddRefed<OffscreenCanvas> OffscreenCanvas::CreateFromCloneData(
|
||||
MOZ_ASSERT(aData);
|
||||
RefPtr<OffscreenCanvas> wc = new OffscreenCanvas(
|
||||
aGlobal, aData->mWidth, aData->mHeight, aData->mCompositorBackendType,
|
||||
aData->mTextureType, aData->mDisplay.forget());
|
||||
aData->mDisplay.forget());
|
||||
if (aData->mNeutered) {
|
||||
wc->SetNeutered();
|
||||
}
|
||||
|
||||
@@ -48,15 +48,14 @@ struct OffscreenCanvasCloneData final {
|
||||
OffscreenCanvasCloneData(OffscreenCanvasDisplayHelper* aDisplay,
|
||||
uint32_t aWidth, uint32_t aHeight,
|
||||
layers::LayersBackend aCompositorBackend,
|
||||
layers::TextureType aTextureType, bool aNeutered,
|
||||
bool aIsWriteOnly, nsIPrincipal* aExpandedReader);
|
||||
bool aNeutered, bool aIsWriteOnly,
|
||||
nsIPrincipal* aExpandedReader);
|
||||
~OffscreenCanvasCloneData();
|
||||
|
||||
RefPtr<OffscreenCanvasDisplayHelper> mDisplay;
|
||||
uint32_t mWidth;
|
||||
uint32_t mHeight;
|
||||
layers::LayersBackend mCompositorBackendType;
|
||||
layers::TextureType mTextureType;
|
||||
bool mNeutered;
|
||||
bool mIsWriteOnly;
|
||||
RefPtr<nsIPrincipal> mExpandedReader;
|
||||
@@ -76,7 +75,6 @@ class OffscreenCanvas final : public DOMEventTargetHelper,
|
||||
|
||||
OffscreenCanvas(nsIGlobalObject* aGlobal, uint32_t aWidth, uint32_t aHeight,
|
||||
layers::LayersBackend aCompositorBackend,
|
||||
layers::TextureType aTextureType,
|
||||
already_AddRefed<OffscreenCanvasDisplayHelper> aDisplay);
|
||||
|
||||
void Destroy();
|
||||
@@ -195,7 +193,6 @@ class OffscreenCanvas final : public DOMEventTargetHelper,
|
||||
|
||||
layers::LayersBackend mCompositorBackendType =
|
||||
layers::LayersBackend::LAYERS_NONE;
|
||||
layers::TextureType mTextureType = layers::TextureType::Unknown;
|
||||
|
||||
RefPtr<OffscreenCanvasDisplayHelper> mDisplay;
|
||||
RefPtr<CancelableRunnable> mPendingCommit;
|
||||
|
||||
@@ -171,7 +171,6 @@ void OffscreenCanvasDisplayHelper::FlushForDisplay() {
|
||||
|
||||
bool OffscreenCanvasDisplayHelper::CommitFrameToCompositor(
|
||||
nsICanvasRenderingContextInternal* aContext,
|
||||
layers::TextureType aTextureType,
|
||||
const Maybe<OffscreenCanvasDisplayData>& aData) {
|
||||
auto endTransaction = MakeScopeExit([&]() {
|
||||
if (auto* cm = gfx::CanvasManagerChild::Get()) {
|
||||
@@ -242,7 +241,7 @@ bool OffscreenCanvasDisplayHelper::CommitFrameToCompositor(
|
||||
aContext->OnBeforePaintTransaction();
|
||||
}
|
||||
|
||||
desc = aContext->PresentFrontBuffer(nullptr, aTextureType);
|
||||
desc = aContext->PresentFrontBuffer(nullptr);
|
||||
if (desc) {
|
||||
hasRemoteTextureDesc =
|
||||
desc->type() ==
|
||||
|
||||
@@ -51,7 +51,6 @@ class OffscreenCanvasDisplayHelper final {
|
||||
void FlushForDisplay();
|
||||
|
||||
bool CommitFrameToCompositor(nsICanvasRenderingContextInternal* aContext,
|
||||
layers::TextureType aTextureType,
|
||||
const Maybe<OffscreenCanvasDisplayData>& aData);
|
||||
|
||||
void DestroyCanvas();
|
||||
|
||||
@@ -210,8 +210,7 @@ class nsICanvasRenderingContextInternal : public nsISupports,
|
||||
}
|
||||
|
||||
virtual mozilla::Maybe<mozilla::layers::SurfaceDescriptor> PresentFrontBuffer(
|
||||
mozilla::WebGLFramebufferJS* fb, mozilla::layers::TextureType,
|
||||
const bool webvr = false) {
|
||||
mozilla::WebGLFramebufferJS* fb, const bool webvr = false) {
|
||||
return GetFrontBuffer(fb, webvr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1039,22 +1039,19 @@ OffscreenCanvas* HTMLCanvasElement::TransferControlToOffscreen(
|
||||
}
|
||||
|
||||
LayersBackend backend = LayersBackend::LAYERS_NONE;
|
||||
TextureType textureType = TextureType::Unknown;
|
||||
nsIWidget* docWidget = nsContentUtils::WidgetForDocument(OwnerDoc());
|
||||
if (docWidget) {
|
||||
WindowRenderer* renderer = docWidget->GetWindowRenderer();
|
||||
if (renderer) {
|
||||
backend = renderer->GetCompositorBackendType();
|
||||
textureType = TexTypeForWebgl(renderer->AsKnowsCompositor());
|
||||
}
|
||||
}
|
||||
|
||||
CSSIntSize sz = GetWidthHeight();
|
||||
mOffscreenDisplay =
|
||||
MakeRefPtr<OffscreenCanvasDisplayHelper>(this, sz.width, sz.height);
|
||||
mOffscreenCanvas =
|
||||
new OffscreenCanvas(win->AsGlobal(), sz.width, sz.height, backend,
|
||||
textureType, do_AddRef(mOffscreenDisplay));
|
||||
mOffscreenCanvas = new OffscreenCanvas(win->AsGlobal(), sz.width, sz.height,
|
||||
backend, do_AddRef(mOffscreenDisplay));
|
||||
if (mWriteOnly) {
|
||||
mOffscreenCanvas->SetWriteOnly(mExpandedReader);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user