From da4c7e7ed675c3bf405668739c3012d140856109 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:42 +0200 Subject: Adding upstream version 126.0. Signed-off-by: Daniel Baumann --- dom/webgpu/CanvasContext.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'dom/webgpu/CanvasContext.cpp') diff --git a/dom/webgpu/CanvasContext.cpp b/dom/webgpu/CanvasContext.cpp index 49f34196c4..46633d9160 100644 --- a/dom/webgpu/CanvasContext.cpp +++ b/dom/webgpu/CanvasContext.cpp @@ -10,6 +10,7 @@ #include "nsDisplayList.h" #include "mozilla/dom/HTMLCanvasElement.h" #include "mozilla/gfx/CanvasManagerChild.h" +#include "mozilla/gfx/gfxVars.h" #include "mozilla/layers/CanvasRenderer.h" #include "mozilla/layers/CompositableForwarder.h" #include "mozilla/layers/ImageDataSerializer.h" @@ -125,6 +126,17 @@ void CanvasContext::Configure(const dom::GPUCanvasConfiguration& aConfig) { mUseExternalTextureInSwapChain = wgpu_client_use_external_texture_in_swapChain( aConfig.mDevice->mId, ConvertTextureFormat(aConfig.mFormat)); + if (!gfx::gfxVars::AllowWebGPUPresentWithoutReadback()) { + mUseExternalTextureInSwapChain = false; + } +#ifdef XP_WIN + // When WebRender does not use hardware acceleration, disable external texture + // in swap chain. Since compositor device might not exist. + if (gfx::gfxVars::UseSoftwareWebRender() && + !gfx::gfxVars::AllowSoftwareWebRenderD3D11()) { + mUseExternalTextureInSwapChain = false; + } +#endif mTexture = aConfig.mDevice->InitSwapChain( mConfig.get(), mRemoteTextureOwnerId.ref(), mUseExternalTextureInSwapChain, mGfxFormat, mCanvasSize); @@ -143,7 +155,7 @@ void CanvasContext::Configure(const dom::GPUCanvasConfiguration& aConfig) { } void CanvasContext::Unconfigure() { - if (mBridge && mBridge->IsOpen() && mRemoteTextureOwnerId) { + if (mBridge && mBridge->CanSend() && mRemoteTextureOwnerId) { mBridge->SendSwapChainDrop( *mRemoteTextureOwnerId, layers::ToRemoteTextureTxnType(mFwdTransactionTracker), @@ -213,7 +225,7 @@ void CanvasContext::MaybeQueueSwapChainPresent() { Maybe CanvasContext::SwapChainPresent() { mPendingSwapChainPresent = false; - if (!mBridge || !mBridge->IsOpen() || mRemoteTextureOwnerId.isNothing() || + if (!mBridge || !mBridge->CanSend() || mRemoteTextureOwnerId.isNothing() || !mTexture) { return Nothing(); } @@ -325,7 +337,7 @@ already_AddRefed CanvasContext::GetSurfaceSnapshot( return nullptr; } - if (!mBridge || !mBridge->IsOpen() || mRemoteTextureOwnerId.isNothing()) { + if (!mBridge || !mBridge->CanSend() || mRemoteTextureOwnerId.isNothing()) { return nullptr; } -- cgit v1.2.3