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:
@@ -24,6 +24,17 @@ RenderDMABUFTextureHost::~RenderDMABUFTextureHost() {
|
|||||||
|
|
||||||
wr::WrExternalImage RenderDMABUFTextureHost::Lock(uint8_t aChannelIndex,
|
wr::WrExternalImage RenderDMABUFTextureHost::Lock(uint8_t aChannelIndex,
|
||||||
gl::GLContext* aGL) {
|
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.get() != aGL) {
|
||||||
if (mGL) {
|
if (mGL) {
|
||||||
// This should not happen. EGLImage is created only in
|
// This should not happen. EGLImage is created only in
|
||||||
@@ -50,8 +61,6 @@ wr::WrExternalImage RenderDMABUFTextureHost::Lock(uint8_t aChannelIndex,
|
|||||||
mSurface->MaybeSemaphoreWait(texture);
|
mSurface->MaybeSemaphoreWait(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gfx::IntSize size(mSurface->GetWidth(aChannelIndex),
|
|
||||||
mSurface->GetHeight(aChannelIndex));
|
|
||||||
return NativeTextureToWrExternalImage(
|
return NativeTextureToWrExternalImage(
|
||||||
mSurface->GetTexture(aChannelIndex), 0.0, 0.0,
|
mSurface->GetTexture(aChannelIndex), 0.0, 0.0,
|
||||||
static_cast<float>(size.width), static_cast<float>(size.height));
|
static_cast<float>(size.width), static_cast<float>(size.height));
|
||||||
@@ -81,10 +90,6 @@ void RenderDMABUFTextureHost::ClearCachedResources() {
|
|||||||
mGL = nullptr;
|
mGL = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::SurfaceFormat RenderDMABUFTextureHost::GetFormat() const {
|
|
||||||
return mSurface->GetFormat();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderDMABUFTextureHost::MapPlane(RenderCompositor* aCompositor,
|
bool RenderDMABUFTextureHost::MapPlane(RenderCompositor* aCompositor,
|
||||||
uint8_t aChannelIndex,
|
uint8_t aChannelIndex,
|
||||||
PlaneInfo& aPlaneInfo) {
|
PlaneInfo& aPlaneInfo) {
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ class RenderDMABUFTextureHost final : public RenderTextureHostSWGL {
|
|||||||
RefPtr<DMABufSurface> GetSurface() { return mSurface; }
|
RefPtr<DMABufSurface> GetSurface() { return mSurface; }
|
||||||
|
|
||||||
// RenderTextureHostSWGL
|
// RenderTextureHostSWGL
|
||||||
gfx::SurfaceFormat GetFormat() const override;
|
gfx::SurfaceFormat GetFormat() const override {
|
||||||
|
return mSurface->GetFormat();
|
||||||
|
}
|
||||||
gfx::ColorDepth GetColorDepth() const override {
|
gfx::ColorDepth GetColorDepth() const override {
|
||||||
return gfx::ColorDepth::COLOR_8;
|
return gfx::ColorDepth::COLOR_8;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,16 @@ wr::WrExternalImage wr_renderer_lock_external_image(void* aObj,
|
|||||||
<< AsUint64(aId);
|
<< AsUint64(aId);
|
||||||
return InvalidToWrExternalImage();
|
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()) {
|
if (auto* gl = renderer->gl()) {
|
||||||
return texture->Lock(aChannelIndex, gl);
|
return texture->Lock(aChannelIndex, gl);
|
||||||
} else if (auto* swgl = renderer->swgl()) {
|
} else if (auto* swgl = renderer->swgl()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user