From 8cbdbb0cb2ff3739b4ae98b2829c70b74da57f64 Mon Sep 17 00:00:00 2001 From: sotaro Date: Fri, 6 Dec 2019 06:53:57 +0000 Subject: [PATCH] Bug 1601531 - Tag image descriptors with PREFER_COMPOSITOR_SURFACE where appropriate r=gw Differential Revision: https://phabricator.services.mozilla.com/D55922 --HG-- extra : moz-landing-system : lando --- gfx/layers/composite/GPUVideoTextureHost.cpp | 7 ++--- gfx/layers/composite/GPUVideoTextureHost.h | 3 ++- gfx/layers/composite/TextureHost.cpp | 11 +++++--- gfx/layers/composite/TextureHost.h | 6 +++-- gfx/layers/d3d11/TextureD3D11.cpp | 26 ++++++++++++------- gfx/layers/d3d11/TextureD3D11.h | 6 +++-- .../opengl/MacIOSurfaceTextureHostOGL.cpp | 13 ++++++---- .../opengl/MacIOSurfaceTextureHostOGL.h | 3 ++- gfx/layers/opengl/TextureHostOGL.cpp | 12 ++++++--- gfx/layers/opengl/TextureHostOGL.h | 6 +++-- .../opengl/WaylandDMABUFTextureHostOGL.cpp | 6 +++-- .../opengl/WaylandDMABUFTextureHostOGL.h | 3 ++- gfx/layers/wr/AsyncImagePipelineManager.cpp | 3 ++- gfx/layers/wr/WebRenderBridgeParent.cpp | 3 ++- gfx/layers/wr/WebRenderTextureHost.cpp | 6 +++-- gfx/layers/wr/WebRenderTextureHost.h | 3 ++- gfx/webrender_bindings/WebRenderTypes.h | 13 +++++++--- gfx/webrender_bindings/src/bindings.rs | 5 ++++ 18 files changed, 91 insertions(+), 44 deletions(-) diff --git a/gfx/layers/composite/GPUVideoTextureHost.cpp b/gfx/layers/composite/GPUVideoTextureHost.cpp index 621d7ee14089..a6e217b5a5c5 100644 --- a/gfx/layers/composite/GPUVideoTextureHost.cpp +++ b/gfx/layers/composite/GPUVideoTextureHost.cpp @@ -137,13 +137,14 @@ uint32_t GPUVideoTextureHost::NumSubTextures() { void GPUVideoTextureHost::PushResourceUpdates( wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, - const Range& aImageKeys, const wr::ExternalImageId& aExtID) { + const Range& aImageKeys, const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) { MOZ_ASSERT(EnsureWrappedTextureHost()); if (!EnsureWrappedTextureHost()) { return; } - EnsureWrappedTextureHost()->PushResourceUpdates(aResources, aOp, aImageKeys, - aExtID); + EnsureWrappedTextureHost()->PushResourceUpdates( + aResources, aOp, aImageKeys, aExtID, aPreferCompositorSurface); } void GPUVideoTextureHost::PushDisplayItems( diff --git a/gfx/layers/composite/GPUVideoTextureHost.h b/gfx/layers/composite/GPUVideoTextureHost.h index 32dc133907a5..383099169cb9 100644 --- a/gfx/layers/composite/GPUVideoTextureHost.h +++ b/gfx/layers/composite/GPUVideoTextureHost.h @@ -56,7 +56,8 @@ class GPUVideoTextureHost : public TextureHost { void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, const Range& aImageKeys, - const wr::ExternalImageId& aExtID) override; + const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) override; void PushDisplayItems(wr::DisplayListBuilder& aBuilder, const wr::LayoutRect& aBounds, diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index 7685a0eee8b8..53538a4d9596 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -605,7 +605,8 @@ uint32_t BufferTextureHost::NumSubTextures() { void BufferTextureHost::PushResourceUpdates( wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, - const Range& aImageKeys, const wr::ExternalImageId& aExtID) { + const Range& aImageKeys, const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) { auto method = aOp == TextureHost::ADD_IMAGE ? &wr::TransactionBuilder::AddExternalImage : &wr::TransactionBuilder::UpdateExternalImage; @@ -617,7 +618,7 @@ void BufferTextureHost::PushResourceUpdates( wr::ImageDescriptor descriptor( GetSize(), ImageDataSerializer::ComputeRGBStride(GetFormat(), GetSize().width), - GetFormat()); + GetFormat(), aPreferCompositorSurface); (aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0); } else { MOZ_ASSERT(aImageKeys.length() == 3); @@ -625,10 +626,12 @@ void BufferTextureHost::PushResourceUpdates( const layers::YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor(); wr::ImageDescriptor yDescriptor( desc.ySize(), desc.yStride(), - SurfaceFormatForColorDepth(desc.colorDepth())); + SurfaceFormatForColorDepth(desc.colorDepth()), + aPreferCompositorSurface); wr::ImageDescriptor cbcrDescriptor( desc.cbCrSize(), desc.cbCrStride(), - SurfaceFormatForColorDepth(desc.colorDepth())); + SurfaceFormatForColorDepth(desc.colorDepth()), + aPreferCompositorSurface); (aResources.*method)(aImageKeys[0], yDescriptor, aExtID, imageType, 0); (aResources.*method)(aImageKeys[1], cbcrDescriptor, aExtID, imageType, 1); (aResources.*method)(aImageKeys[2], cbcrDescriptor, aExtID, imageType, 2); diff --git a/gfx/layers/composite/TextureHost.h b/gfx/layers/composite/TextureHost.h index d7e19f31f6f3..e63b23c8df82 100644 --- a/gfx/layers/composite/TextureHost.h +++ b/gfx/layers/composite/TextureHost.h @@ -661,7 +661,8 @@ class TextureHost : public AtomicRefCountedWithFinalize { virtual void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, const Range& aImageKeys, - const wr::ExternalImageId& aExtID) { + const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) { MOZ_ASSERT_UNREACHABLE("Unimplemented"); } @@ -792,7 +793,8 @@ class BufferTextureHost : public TextureHost { void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, const Range& aImageKeys, - const wr::ExternalImageId& aExtID) override; + const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) override; void PushDisplayItems(wr::DisplayListBuilder& aBuilder, const wr::LayoutRect& aBounds, diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index 6d331bce2f66..be9d10833847 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -1012,7 +1012,8 @@ uint32_t DXGITextureHostD3D11::NumSubTextures() { void DXGITextureHostD3D11::PushResourceUpdates( wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, - const Range& aImageKeys, const wr::ExternalImageId& aExtID) { + const Range& aImageKeys, const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) { if (!gfx::gfxVars::UseWebRenderANGLE()) { MOZ_ASSERT_UNREACHABLE("unexpected to be called without ANGLE"); return; @@ -1029,7 +1030,8 @@ void DXGITextureHostD3D11::PushResourceUpdates( case gfx::SurfaceFormat::B8G8R8X8: { MOZ_ASSERT(aImageKeys.length() == 1); - wr::ImageDescriptor descriptor(mSize, GetFormat()); + wr::ImageDescriptor descriptor(mSize, GetFormat(), + aPreferCompositorSurface); auto imageType = wr::ExternalImageType::TextureHandle(wr::TextureTarget::External); (aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0); @@ -1042,13 +1044,16 @@ void DXGITextureHostD3D11::PushResourceUpdates( MOZ_ASSERT(mSize.width % 2 == 0); MOZ_ASSERT(mSize.height % 2 == 0); - wr::ImageDescriptor descriptor0(mSize, mFormat == gfx::SurfaceFormat::NV12 - ? gfx::SurfaceFormat::A8 - : gfx::SurfaceFormat::A16); + wr::ImageDescriptor descriptor0(mSize, + mFormat == gfx::SurfaceFormat::NV12 + ? gfx::SurfaceFormat::A8 + : gfx::SurfaceFormat::A16, + aPreferCompositorSurface); wr::ImageDescriptor descriptor1(mSize / 2, mFormat == gfx::SurfaceFormat::NV12 ? gfx::SurfaceFormat::R8G8 - : gfx::SurfaceFormat::R16G16); + : gfx::SurfaceFormat::R16G16, + aPreferCompositorSurface); auto imageType = wr::ExternalImageType::TextureHandle(wr::TextureTarget::External); (aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0); @@ -1259,7 +1264,8 @@ uint32_t DXGIYCbCrTextureHostD3D11::NumSubTextures() { void DXGIYCbCrTextureHostD3D11::PushResourceUpdates( wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, - const Range& aImageKeys, const wr::ExternalImageId& aExtID) { + const Range& aImageKeys, const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) { if (!gfx::gfxVars::UseWebRenderANGLE()) { MOZ_ASSERT_UNREACHABLE("unexpected to be called without ANGLE"); return; @@ -1280,9 +1286,11 @@ void DXGIYCbCrTextureHostD3D11::PushResourceUpdates( wr::ExternalImageType::TextureHandle(wr::TextureTarget::External); // y - wr::ImageDescriptor descriptor0(mSize, gfx::SurfaceFormat::A8); + wr::ImageDescriptor descriptor0(mSize, gfx::SurfaceFormat::A8, + aPreferCompositorSurface); // cb and cr - wr::ImageDescriptor descriptor1(mSizeCbCr, gfx::SurfaceFormat::A8); + wr::ImageDescriptor descriptor1(mSizeCbCr, gfx::SurfaceFormat::A8, + aPreferCompositorSurface); (aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0); (aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1); (aResources.*method)(aImageKeys[2], descriptor1, aExtID, imageType, 2); diff --git a/gfx/layers/d3d11/TextureD3D11.h b/gfx/layers/d3d11/TextureD3D11.h index 72920ee1f1f8..d31e4da38a08 100644 --- a/gfx/layers/d3d11/TextureD3D11.h +++ b/gfx/layers/d3d11/TextureD3D11.h @@ -354,7 +354,8 @@ class DXGITextureHostD3D11 : public TextureHost { void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, const Range& aImageKeys, - const wr::ExternalImageId& aExtID) override; + const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) override; void PushDisplayItems(wr::DisplayListBuilder& aBuilder, const wr::LayoutRect& aBounds, @@ -422,7 +423,8 @@ class DXGIYCbCrTextureHostD3D11 : public TextureHost { void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, const Range& aImageKeys, - const wr::ExternalImageId& aExtID) override; + const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) override; void PushDisplayItems(wr::DisplayListBuilder& aBuilder, const wr::LayoutRect& aBounds, diff --git a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp index 1d40c36ffc45..31f89c516e68 100644 --- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp +++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp @@ -160,7 +160,8 @@ uint32_t MacIOSurfaceTextureHostOGL::NumSubTextures() { void MacIOSurfaceTextureHostOGL::PushResourceUpdates( wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, - const Range& aImageKeys, const wr::ExternalImageId& aExtID) { + const Range& aImageKeys, const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) { MOZ_ASSERT(mSurface); auto method = aOp == TextureHost::ADD_IMAGE @@ -179,7 +180,8 @@ void MacIOSurfaceTextureHostOGL::PushResourceUpdates( auto format = GetFormat() == gfx::SurfaceFormat::R8G8B8A8 ? gfx::SurfaceFormat::B8G8R8A8 : gfx::SurfaceFormat::B8G8R8X8; - wr::ImageDescriptor descriptor(GetSize(), format); + wr::ImageDescriptor descriptor(GetSize(), format, + aPreferCompositorSurface); (aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0); break; } @@ -190,7 +192,8 @@ void MacIOSurfaceTextureHostOGL::PushResourceUpdates( // and YCbCr at OpenGL 3.1) MOZ_ASSERT(aImageKeys.length() == 1); MOZ_ASSERT(mSurface->GetPlaneCount() == 0); - wr::ImageDescriptor descriptor(GetSize(), gfx::SurfaceFormat::B8G8R8X8); + wr::ImageDescriptor descriptor(GetSize(), gfx::SurfaceFormat::B8G8R8X8, + aPreferCompositorSurface); (aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0); break; } @@ -200,11 +203,11 @@ void MacIOSurfaceTextureHostOGL::PushResourceUpdates( wr::ImageDescriptor descriptor0( gfx::IntSize(mSurface->GetDevicePixelWidth(0), mSurface->GetDevicePixelHeight(0)), - gfx::SurfaceFormat::A8); + gfx::SurfaceFormat::A8, aPreferCompositorSurface); wr::ImageDescriptor descriptor1( gfx::IntSize(mSurface->GetDevicePixelWidth(1), mSurface->GetDevicePixelHeight(1)), - gfx::SurfaceFormat::R8G8); + gfx::SurfaceFormat::R8G8, aPreferCompositorSurface); (aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0); (aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1); break; diff --git a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h index 47f7ebfcb3ac..6688f864ce58 100644 --- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h +++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h @@ -71,7 +71,8 @@ class MacIOSurfaceTextureHostOGL : public TextureHost { void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, const Range& aImageKeys, - const wr::ExternalImageId& aExtID) override; + const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) override; void PushDisplayItems(wr::DisplayListBuilder& aBuilder, const wr::LayoutRect& aBounds, diff --git a/gfx/layers/opengl/TextureHostOGL.cpp b/gfx/layers/opengl/TextureHostOGL.cpp index 25acfc679056..bbb864aff53f 100644 --- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -648,7 +648,8 @@ void SurfaceTextureHost::CreateRenderTexture( void SurfaceTextureHost::PushResourceUpdates( wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, - const Range& aImageKeys, const wr::ExternalImageId& aExtID) { + const Range& aImageKeys, const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) { auto method = aOp == TextureHost::ADD_IMAGE ? &wr::TransactionBuilder::AddExternalImage : &wr::TransactionBuilder::UpdateExternalImage; @@ -665,7 +666,8 @@ void SurfaceTextureHost::PushResourceUpdates( auto format = GetFormat() == gfx::SurfaceFormat::R8G8B8A8 ? gfx::SurfaceFormat::B8G8R8A8 : gfx::SurfaceFormat::B8G8R8X8; - wr::ImageDescriptor descriptor(GetSize(), format); + wr::ImageDescriptor descriptor(GetSize(), format, + aPreferCompositorSurface); (aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0); break; } @@ -854,7 +856,8 @@ void EGLImageTextureHost::CreateRenderTexture( void EGLImageTextureHost::PushResourceUpdates( wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, - const Range& aImageKeys, const wr::ExternalImageId& aExtID) { + const Range& aImageKeys, const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) { auto method = aOp == TextureHost::ADD_IMAGE ? &wr::TransactionBuilder::AddExternalImage : &wr::TransactionBuilder::UpdateExternalImage; @@ -870,7 +873,8 @@ void EGLImageTextureHost::PushResourceUpdates( auto formatTmp = format == gfx::SurfaceFormat::R8G8B8A8 ? gfx::SurfaceFormat::B8G8R8A8 : gfx::SurfaceFormat::B8G8R8X8; - wr::ImageDescriptor descriptor(GetSize(), formatTmp); + wr::ImageDescriptor descriptor(GetSize(), formatTmp, + aPreferCompositorSurface); (aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0); } diff --git a/gfx/layers/opengl/TextureHostOGL.h b/gfx/layers/opengl/TextureHostOGL.h index 0d335671a87f..fbe8698e5aac 100644 --- a/gfx/layers/opengl/TextureHostOGL.h +++ b/gfx/layers/opengl/TextureHostOGL.h @@ -433,7 +433,8 @@ class SurfaceTextureHost : public TextureHost { void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, const Range& aImageKeys, - const wr::ExternalImageId& aExtID) override; + const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) override; void PushDisplayItems(wr::DisplayListBuilder& aBuilder, const wr::LayoutRect& aBounds, @@ -538,7 +539,8 @@ class EGLImageTextureHost final : public TextureHost { void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, const Range& aImageKeys, - const wr::ExternalImageId& aExtID) override; + const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) override; void PushDisplayItems(wr::DisplayListBuilder& aBuilder, const wr::LayoutRect& aBounds, diff --git a/gfx/layers/opengl/WaylandDMABUFTextureHostOGL.cpp b/gfx/layers/opengl/WaylandDMABUFTextureHostOGL.cpp index 3f076516a5cf..aa86a9bb9f72 100644 --- a/gfx/layers/opengl/WaylandDMABUFTextureHostOGL.cpp +++ b/gfx/layers/opengl/WaylandDMABUFTextureHostOGL.cpp @@ -101,7 +101,8 @@ void WaylandDMABUFTextureHostOGL::CreateRenderTexture( void WaylandDMABUFTextureHostOGL::PushResourceUpdates( wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, - const Range& aImageKeys, const wr::ExternalImageId& aExtID) { + const Range& aImageKeys, const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) { MOZ_ASSERT(mSurface); auto method = aOp == TextureHost::ADD_IMAGE @@ -120,7 +121,8 @@ void WaylandDMABUFTextureHostOGL::PushResourceUpdates( auto formatTmp = format == gfx::SurfaceFormat::R8G8B8A8 ? gfx::SurfaceFormat::B8G8R8A8 : gfx::SurfaceFormat::B8G8R8X8; - wr::ImageDescriptor descriptor(GetSize(), formatTmp); + wr::ImageDescriptor descriptor(GetSize(), formatTmp, + aPreferCompositorSurface); (aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0); } diff --git a/gfx/layers/opengl/WaylandDMABUFTextureHostOGL.h b/gfx/layers/opengl/WaylandDMABUFTextureHostOGL.h index b334be94e23a..cfbdc7576387 100644 --- a/gfx/layers/opengl/WaylandDMABUFTextureHostOGL.h +++ b/gfx/layers/opengl/WaylandDMABUFTextureHostOGL.h @@ -58,7 +58,8 @@ class WaylandDMABUFTextureHostOGL : public TextureHost { void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, const Range& aImageKeys, - const wr::ExternalImageId& aExtID) override; + const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) override; void PushDisplayItems(wr::DisplayListBuilder& aBuilder, const wr::LayoutRect& aBounds, diff --git a/gfx/layers/wr/AsyncImagePipelineManager.cpp b/gfx/layers/wr/AsyncImagePipelineManager.cpp index 9e15d0da5632..a3e50502eefa 100644 --- a/gfx/layers/wr/AsyncImagePipelineManager.cpp +++ b/gfx/layers/wr/AsyncImagePipelineManager.cpp @@ -266,7 +266,8 @@ Maybe AsyncImagePipelineManager::UpdateImageKeys( Range keys(&aKeys[0], aKeys.Length()); auto externalImageKey = wrTexture->GetExternalImageKey(); - wrTexture->PushResourceUpdates(aMaybeFastTxn, op, keys, externalImageKey); + wrTexture->PushResourceUpdates(aMaybeFastTxn, op, keys, externalImageKey, + /* aPreferCompositorSurface */ true); return Some(op); } diff --git a/gfx/layers/wr/WebRenderBridgeParent.cpp b/gfx/layers/wr/WebRenderBridgeParent.cpp index 78993c6b25f2..1bacad667f22 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.cpp +++ b/gfx/layers/wr/WebRenderBridgeParent.cpp @@ -828,7 +828,8 @@ bool WebRenderBridgeParent::PushExternalImageForTexture( WebRenderTextureHost* wrTexture = aTexture->AsWebRenderTextureHost(); if (wrTexture) { wrTexture->PushResourceUpdates(aResources, op, keys, - wrTexture->GetExternalImageKey()); + wrTexture->GetExternalImageKey(), + /* aPreferCompositorSurface */ false); auto it = mTextureHosts.find(wr::AsUint64(aKey)); MOZ_ASSERT((it == mTextureHosts.end() && !aIsUpdate) || (it != mTextureHosts.end() && aIsUpdate)); diff --git a/gfx/layers/wr/WebRenderTextureHost.cpp b/gfx/layers/wr/WebRenderTextureHost.cpp index a6fc746852fb..aec3d4dc8385 100644 --- a/gfx/layers/wr/WebRenderTextureHost.cpp +++ b/gfx/layers/wr/WebRenderTextureHost.cpp @@ -197,11 +197,13 @@ uint32_t WebRenderTextureHost::NumSubTextures() { void WebRenderTextureHost::PushResourceUpdates( wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, - const Range& aImageKeys, const wr::ExternalImageId& aExtID) { + const Range& aImageKeys, const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) { MOZ_ASSERT(mWrappedTextureHost); MOZ_ASSERT(mExternalImageId == aExtID); - mWrappedTextureHost->PushResourceUpdates(aResources, aOp, aImageKeys, aExtID); + mWrappedTextureHost->PushResourceUpdates(aResources, aOp, aImageKeys, aExtID, + aPreferCompositorSurface); } void WebRenderTextureHost::PushDisplayItems( diff --git a/gfx/layers/wr/WebRenderTextureHost.h b/gfx/layers/wr/WebRenderTextureHost.h index 2bd04a87a879..844b629723d3 100644 --- a/gfx/layers/wr/WebRenderTextureHost.h +++ b/gfx/layers/wr/WebRenderTextureHost.h @@ -75,7 +75,8 @@ class WebRenderTextureHost : public TextureHost { void PushResourceUpdates(wr::TransactionBuilder& aResources, ResourceUpdateOp aOp, const Range& aImageKeys, - const wr::ExternalImageId& aExtID) override; + const wr::ExternalImageId& aExtID, + const bool aPreferCompositorSurface) override; void PushDisplayItems(wr::DisplayListBuilder& aBuilder, const wr::LayoutRect& aBounds, diff --git a/gfx/webrender_bindings/WebRenderTypes.h b/gfx/webrender_bindings/WebRenderTypes.h index dfbbe0469658..7f9da9197244 100644 --- a/gfx/webrender_bindings/WebRenderTypes.h +++ b/gfx/webrender_bindings/WebRenderTypes.h @@ -197,34 +197,41 @@ struct ImageDescriptor : public wr::WrImageDescriptor { height = 0; stride = 0; opacity = OpacityType::HasAlphaChannel; + prefer_compositor_surface = false; } - ImageDescriptor(const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat) { + ImageDescriptor(const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat, + bool aPreferCompositorSurface = false) { format = wr::SurfaceFormatToImageFormat(aFormat).value(); width = aSize.width; height = aSize.height; stride = 0; opacity = gfx::IsOpaque(aFormat) ? OpacityType::Opaque : OpacityType::HasAlphaChannel; + prefer_compositor_surface = aPreferCompositorSurface; } ImageDescriptor(const gfx::IntSize& aSize, uint32_t aByteStride, - gfx::SurfaceFormat aFormat) { + gfx::SurfaceFormat aFormat, + bool aPreferCompositorSurface = false) { format = wr::SurfaceFormatToImageFormat(aFormat).value(); width = aSize.width; height = aSize.height; stride = aByteStride; opacity = gfx::IsOpaque(aFormat) ? OpacityType::Opaque : OpacityType::HasAlphaChannel; + prefer_compositor_surface = aPreferCompositorSurface; } ImageDescriptor(const gfx::IntSize& aSize, uint32_t aByteStride, - gfx::SurfaceFormat aFormat, OpacityType aOpacity) { + gfx::SurfaceFormat aFormat, OpacityType aOpacity, + bool aPreferCompositorSurface = false) { format = wr::SurfaceFormatToImageFormat(aFormat).value(); width = aSize.width; height = aSize.height; stride = aByteStride; opacity = aOpacity; + prefer_compositor_surface = aPreferCompositorSurface; } }; diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs index 9803fc28f1eb..83c9b14853f3 100644 --- a/gfx/webrender_bindings/src/bindings.rs +++ b/gfx/webrender_bindings/src/bindings.rs @@ -352,6 +352,7 @@ pub struct WrImageDescriptor { pub height: i32, pub stride: i32, pub opacity: OpacityType, + pub prefer_compositor_surface: bool, } impl<'a> Into for &'a WrImageDescriptor { @@ -362,6 +363,10 @@ impl<'a> Into for &'a WrImageDescriptor { flags |= ImageDescriptorFlags::IS_OPAQUE; } + if self.prefer_compositor_surface { + flags |= ImageDescriptorFlags::PREFER_COMPOSITOR_SURFACE; + } + ImageDescriptor { size: DeviceIntSize::new(self.width, self.height), stride: if self.stride != 0 {