Bug 1829026 - Allow WebGLContext::PushRemoteTexture to specify an explicit pid. r=aosmond

Since we're not using WebGL remoting, we no longer have direct knowledge of the pid across
the IPDL gap inside WebGLContext. This must be explicitly passed in.

Differential Revision: https://phabricator.services.mozilla.com/D194348
This commit is contained in:
Lee Salzman 2023-12-12 07:35:01 +00:00
Родитель 2b9ebd56de
Коммит cf3beedd47
2 изменённых файлов: 14 добавлений и 9 удалений

Просмотреть файл

@ -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, "<CopyToSwapChain>");
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<gl::SharedSurface> 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<layers::RemoteTextureOwnerClient>(outOfProcess->OtherPid());
mRemoteTextureOwner = MakeRefPtr<layers::RemoteTextureOwnerClient>(pid);
}
layers::RemoteTextureOwnerId ownerId = options.remoteTextureOwnerId;

Просмотреть файл

@ -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<gl::SharedSurface>,
const webgl::SwapChainOptions& options);
const webgl::SwapChainOptions& options,
base::ProcessId pid = base::kInvalidProcessId);
// --