summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/CanvasContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/webgpu/CanvasContext.cpp')
-rw-r--r--dom/webgpu/CanvasContext.cpp18
1 files changed, 15 insertions, 3 deletions
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<layers::SurfaceDescriptor> 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<mozilla::gfx::SourceSurface> CanvasContext::GetSurfaceSnapshot(
return nullptr;
}
- if (!mBridge || !mBridge->IsOpen() || mRemoteTextureOwnerId.isNothing()) {
+ if (!mBridge || !mBridge->CanSend() || mRemoteTextureOwnerId.isNothing()) {
return nullptr;
}