Bug 1688020 - Release image of SurfaceDescriptorD3D10 after WebGLContext::TexImage() also with in-process WebGL r=gfx-reviewers,lsalzman

Like Bug 1798624, image of SurfaceDescriptorD3D10  needs to be kept alive until WebGLContext::TexImage() call with in-process WebGL.

Differential Revision: https://phabricator.services.mozilla.com/D165109
This commit is contained in:
sotaro
2022-12-20 04:25:15 +00:00
parent 9996d2f9d7
commit 51aa6c3acf

View File

@@ -4246,8 +4246,8 @@ void ClientWebGLContext::TexImage(uint8_t funcDims, GLenum imageTarget,
// -
mozilla::ipc::Shmem* pShmem = nullptr;
// Image to release after Ping response.
RefPtr<layers::Image> imageWaitPingResponse;
// Image to release after WebGLContext::TexImage().
RefPtr<layers::Image> keepAliveImage;
if (desc->sd) {
const auto& sd = *(desc->sd);
@@ -4279,10 +4279,9 @@ void ClientWebGLContext::TexImage(uint8_t funcDims, GLenum imageTarget,
if (sdType == layers::SurfaceDescriptor::TSurfaceDescriptorD3D10) {
const auto& sdD3D = sd.get_SurfaceDescriptorD3D10();
const auto& inProcess = mNotLost->inProcess;
if (!inProcess) {
MOZ_ASSERT(desc->image);
imageWaitPingResponse = desc->image;
}
MOZ_ASSERT(desc->image);
keepAliveImage = desc->image;
if (sdD3D.gpuProcessTextureId().isSome() && inProcess) {
return Some(
std::string{"gpuProcessTextureId works only in GPU process."});
@@ -4387,11 +4386,11 @@ void ClientWebGLContext::TexImage(uint8_t funcDims, GLenum imageTarget,
(void)child->SendTexImage(static_cast<uint32_t>(level), respecFormat,
CastUvec3(offset), pi, std::move(*desc));
if (tempShmem || imageWaitPingResponse) {
if (tempShmem || keepAliveImage) {
const auto eventTarget = GetCurrentSerialEventTarget();
MOZ_ASSERT(eventTarget);
child->SendPing()->Then(eventTarget, __func__,
[tempShmem, imageWaitPingResponse]() {
[tempShmem, keepAliveImage]() {
// Cleans up when (our copy of)
// sendableShmem/image goes out of scope.
});