diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index f74ff53b0953..990d8914331e 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -1062,7 +1062,8 @@ void WebGLContext::Present(WebGLFramebuffer* const xrFb, void WebGLContext::CopyToSwapChain(WebGLFramebuffer* const srcFb, const layers::TextureType consumerType, - const webgl::SwapChainOptions& options) { + const webgl::SwapChainOptions& options, + base::ProcessId pid) { const FuncScope funcScope(*this, ""); if (IsContextLost()) return; @@ -1085,7 +1086,7 @@ void WebGLContext::CopyToSwapChain(WebGLFramebuffer* const srcFb, // read back the WebGL framebuffer into and push it as a remote texture. if (useAsync && srcFb->mSwapChain.mFactory->GetConsumerType() == layers::TextureType::Unknown) { - PushRemoteTexture(srcFb, srcFb->mSwapChain, nullptr, options); + PushRemoteTexture(srcFb, srcFb->mSwapChain, nullptr, options, pid); return; } @@ -1109,14 +1110,15 @@ void WebGLContext::CopyToSwapChain(WebGLFramebuffer* const srcFb, if (useAsync) { PushRemoteTexture(srcFb, srcFb->mSwapChain, srcFb->mSwapChain.FrontBuffer(), - options); + options, pid); } } bool WebGLContext::PushRemoteTexture(WebGLFramebuffer* fb, gl::SwapChain& swapChain, std::shared_ptr surf, - const webgl::SwapChainOptions& options) { + const webgl::SwapChainOptions& options, + base::ProcessId pid) { const auto onFailure = [&]() -> bool { GenerateWarning("Remote texture creation failed."); LoseContext(); @@ -1130,11 +1132,12 @@ bool WebGLContext::PushRemoteTexture(WebGLFramebuffer* fb, if (!mRemoteTextureOwner) { // Ensure we have a remote texture owner client for WebGLParent. const auto* outOfProcess = mHost ? mHost->mOwnerData.outOfProcess : nullptr; - if (!outOfProcess) { + if (outOfProcess) { + pid = outOfProcess->OtherPid(); + } else if (pid == base::kInvalidProcessId) { return onFailure(); } - mRemoteTextureOwner = - MakeRefPtr(outOfProcess->OtherPid()); + mRemoteTextureOwner = MakeRefPtr(pid); } layers::RemoteTextureOwnerId ownerId = options.remoteTextureOwnerId; diff --git a/dom/canvas/WebGLContext.h b/dom/canvas/WebGLContext.h index bef79201e1c9..e61e8343ee88 100644 --- a/dom/canvas/WebGLContext.h +++ b/dom/canvas/WebGLContext.h @@ -500,7 +500,8 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr { // without need to set the preserveDrawingBuffer option. void CopyToSwapChain( WebGLFramebuffer*, layers::TextureType, - const webgl::SwapChainOptions& options = webgl::SwapChainOptions()); + const webgl::SwapChainOptions& options = webgl::SwapChainOptions(), + base::ProcessId pid = base::kInvalidProcessId); // In use cases where a framebuffer is used as an offscreen framebuffer and // does not need to be committed to the swap chain, it may still be useful // for the implementation to delineate distinct frames, such as when sharing @@ -1261,7 +1262,8 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr { bool PushRemoteTexture(WebGLFramebuffer*, gl::SwapChain&, std::shared_ptr, - const webgl::SwapChainOptions& options); + const webgl::SwapChainOptions& options, + base::ProcessId pid = base::kInvalidProcessId); // --