Bug 1959975 [Wayland] Don't create unused textures for DMABuf / Webrender compositor r=gw

Differential Revision: https://phabricator.services.mozilla.com/D245558
This commit is contained in:
stransky
2025-04-16 06:36:26 +00:00
parent 8f860dc91b
commit af7a3e00ff
3 changed files with 24 additions and 7 deletions

View File

@@ -24,6 +24,17 @@ RenderDMABUFTextureHost::~RenderDMABUFTextureHost() {
wr::WrExternalImage RenderDMABUFTextureHost::Lock(uint8_t aChannelIndex,
gl::GLContext* aGL) {
const gfx::IntSize size(mSurface->GetWidth(aChannelIndex),
mSurface->GetHeight(aChannelIndex));
// Wayland native compositor doesn't use textures so pass zero
// there. It saves GPU resources.
if (!aGL) {
return NativeTextureToWrExternalImage(0, 0.0, 0.0,
static_cast<float>(size.width),
static_cast<float>(size.height));
}
if (mGL.get() != aGL) {
if (mGL) {
// This should not happen. EGLImage is created only in
@@ -50,8 +61,6 @@ wr::WrExternalImage RenderDMABUFTextureHost::Lock(uint8_t aChannelIndex,
mSurface->MaybeSemaphoreWait(texture);
}
const gfx::IntSize size(mSurface->GetWidth(aChannelIndex),
mSurface->GetHeight(aChannelIndex));
return NativeTextureToWrExternalImage(
mSurface->GetTexture(aChannelIndex), 0.0, 0.0,
static_cast<float>(size.width), static_cast<float>(size.height));
@@ -81,10 +90,6 @@ void RenderDMABUFTextureHost::ClearCachedResources() {
mGL = nullptr;
}
gfx::SurfaceFormat RenderDMABUFTextureHost::GetFormat() const {
return mSurface->GetFormat();
}
bool RenderDMABUFTextureHost::MapPlane(RenderCompositor* aCompositor,
uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) {

View File

@@ -37,7 +37,9 @@ class RenderDMABUFTextureHost final : public RenderTextureHostSWGL {
RefPtr<DMABufSurface> GetSurface() { return mSurface; }
// RenderTextureHostSWGL
gfx::SurfaceFormat GetFormat() const override;
gfx::SurfaceFormat GetFormat() const override {
return mSurface->GetFormat();
}
gfx::ColorDepth GetColorDepth() const override {
return gfx::ColorDepth::COLOR_8;
}

View File

@@ -69,6 +69,16 @@ wr::WrExternalImage wr_renderer_lock_external_image(void* aObj,
<< AsUint64(aId);
return InvalidToWrExternalImage();
}
#if defined(MOZ_WAYLAND)
// Wayland native compositor doesn't use textures so pass null GL context.
if (texture->AsRenderDMABUFTextureHost() &&
renderer->GetCompositor()->CompositorType() ==
layers::WebRenderCompositor::WAYLAND) {
return texture->Lock(aChannelIndex, nullptr);
}
#endif
if (auto* gl = renderer->gl()) {
return texture->Lock(aChannelIndex, gl);
} else if (auto* swgl = renderer->swgl()) {