Bug 1908585 - Disable overlay only for slow present video r=gfx-reviewers,lsalzman

The change disables video overlay only for the slow present video, instead of disabling overlay in system wide.

Disabling the overlay is decided by DCSurfaceVideo. And controlling overlay usage is done by AsyncImagePipelineManager. To deliver the decision, RenderTextureHostUsageInfo is used. RenderTextureHostUsageInfo is shared among, DCSurfaceVideo, RenderTextureHost, AsyncImagePipelineManager and WebRenderImageHost.

Then if RenderTextureHostUsageInfo::DisableVideoOverlay() is called by DCSurfaceVideo, AsyncImagePipelineManager could know if overlay is disabled for TextureHost by RenderTextureHostUsageInfo::DisableVideoOverlay().

WebRenderImageHost retains the RenderTextureHostUsageInfo returned by RenderTextureHost and reuses the returned RenderTextureHostUsageInfo. And if the video overlay is disabled, the disabled overlay is retained for the lifetime of WebRenderImageHost.

There is a case that RenderTextureHost::GetOrMergeUsageInfo() needs to merge 2 RenderTextureHostUsageInfos to one RenderTextureHostUsageInfo. It happens when one TextureHost is used by multiple WebRenderImageHosts.

Differential Revision: https://phabricator.services.mozilla.com/D217355
This commit is contained in:
sotaro 2024-07-24 00:21:16 +00:00
parent 61754b1086
commit 0b06ae83bf
17 changed files with 272 additions and 23 deletions

View File

@ -216,6 +216,13 @@ BufferTextureHost* GPUVideoTextureHost::AsBufferTextureHost() {
return nullptr;
}
DXGITextureHostD3D11* GPUVideoTextureHost::AsDXGITextureHostD3D11() {
if (EnsureWrappedTextureHost()) {
return EnsureWrappedTextureHost()->AsDXGITextureHostD3D11();
}
return nullptr;
}
bool GPUVideoTextureHost::IsWrappingSurfaceTextureHost() {
if (EnsureWrappedTextureHost()) {
return EnsureWrappedTextureHost()->IsWrappingSurfaceTextureHost();

View File

@ -67,6 +67,8 @@ class GPUVideoTextureHost : public TextureHost {
BufferTextureHost* AsBufferTextureHost() override;
DXGITextureHostD3D11* AsDXGITextureHostD3D11() override;
bool IsWrappingSurfaceTextureHost() override;
TextureHostType GetTextureHostType() override;

View File

@ -670,6 +670,9 @@ class TextureHost : public AtomicRefCountedWithFinalize<TextureHost> {
// Passed in the RenderCompositor supports BufferTextureHosts
// being used directly as external compositor surfaces.
SUPPORTS_EXTERNAL_BUFFER_TEXTURES,
// Passed if the caller wants to disable external compositing of TextureHost
EXTERNAL_COMPOSITING_DISABLED,
};
using PushDisplayItemFlagSet = EnumSet<PushDisplayItemFlag>;

View File

@ -1221,17 +1221,23 @@ void DXGITextureHostD3D11::PushDisplayItems(
return;
}
bool preferExternalCompositing =
SupportsExternalCompositing(aBuilder.GetBackendType());
if (aFlags.contains(PushDisplayItemFlag::EXTERNAL_COMPOSITING_DISABLED)) {
MOZ_ASSERT(aBuilder.GetBackendType() != WebRenderBackend::SOFTWARE);
preferExternalCompositing = false;
}
switch (GetFormat()) {
case gfx::SurfaceFormat::R8G8B8X8:
case gfx::SurfaceFormat::R8G8B8A8:
case gfx::SurfaceFormat::B8G8R8A8:
case gfx::SurfaceFormat::B8G8R8X8: {
MOZ_ASSERT(aImageKeys.length() == 1);
aBuilder.PushImage(
aBounds, aClip, true, false, aFilter, aImageKeys[0],
!(mFlags & TextureFlags::NON_PREMULTIPLIED),
wr::ColorF{1.0f, 1.0f, 1.0f, 1.0f}, preferCompositorSurface,
SupportsExternalCompositing(aBuilder.GetBackendType()));
aBuilder.PushImage(aBounds, aClip, true, false, aFilter, aImageKeys[0],
!(mFlags & TextureFlags::NON_PREMULTIPLIED),
wr::ColorF{1.0f, 1.0f, 1.0f, 1.0f},
preferCompositorSurface, preferExternalCompositing);
break;
}
case gfx::SurfaceFormat::P010:
@ -1249,7 +1255,7 @@ void DXGITextureHostD3D11::PushDisplayItems(
: wr::ColorDepth::Color16,
wr::ToWrYuvColorSpace(ToYUVColorSpace(mColorSpace)),
wr::ToWrColorRange(mColorRange), aFilter, preferCompositorSurface,
SupportsExternalCompositing(aBuilder.GetBackendType()));
preferExternalCompositing);
break;
}
default: {

View File

@ -142,6 +142,10 @@ class TextureHostWrapperD3D11 : public TextureHost {
TextureHostWrapperD3D11* AsTextureHostWrapperD3D11() override { return this; }
DXGITextureHostD3D11* AsDXGITextureHostD3D11() override {
return mTextureHostD3D11;
}
void PostTask();
bool UpdateTextureData();

View File

@ -18,6 +18,7 @@
#include "mozilla/layers/SharedSurfacesParent.h"
#include "mozilla/layers/WebRenderImageHost.h"
#include "mozilla/layers/WebRenderTextureHost.h"
#include "mozilla/webrender/RenderTextureHost.h"
#include "mozilla/webrender/RenderThread.h"
#include "mozilla/webrender/WebRenderAPI.h"
#include "mozilla/webrender/WebRenderTypes.h"
@ -35,13 +36,15 @@ AsyncImagePipelineManager::ForwardingExternalImage::~ForwardingExternalImage() {
}
AsyncImagePipelineManager::AsyncImagePipeline::AsyncImagePipeline(
wr::PipelineId aPipelineId, layers::WebRenderBackend aBackend)
wr::PipelineId aPipelineId, layers::WebRenderBackend aBackend,
WebRenderImageHost* aImageHost)
: mInitialised(false),
mIsChanged(false),
mUseExternalImage(false),
mRotation(wr::WrRotation::Degree0),
mFilter(wr::ImageRendering::Auto),
mMixBlendMode(wr::MixBlendMode::Normal),
mImageHost(aImageHost),
mDLBuilder(aPipelineId, aBackend) {}
AsyncImagePipelineManager::AsyncImagePipelineManager(
@ -168,9 +171,8 @@ void AsyncImagePipelineManager::AddAsyncImagePipeline(
uint64_t id = wr::AsUint64(aPipelineId);
MOZ_ASSERT(!mAsyncImagePipelines.Contains(id));
auto holder =
MakeUnique<AsyncImagePipeline>(aPipelineId, mApi->GetBackendType());
holder->mImageHost = aImageHost;
auto holder = MakeUnique<AsyncImagePipeline>(
aPipelineId, mApi->GetBackendType(), aImageHost);
mAsyncImagePipelines.InsertOrUpdate(id, std::move(holder));
AddPipeline(aPipelineId, /* aWrBridge */ nullptr);
}
@ -264,6 +266,23 @@ Maybe<TextureHost::ResourceUpdateOp> AsyncImagePipelineManager::UpdateImageKeys(
// If we already had a texture and the format hasn't changed, better to reuse
// the image keys than create new ones.
auto backend = aSceneBuilderTxn.GetBackendType();
bool videoOverlayDisabled = false;
RefPtr<wr::RenderTextureHostUsageInfo> usageInfo;
// video overlay of DXGITextureHostD3D11 may be disabled dynamically
const bool checkVideoOverlayDisabled = !!aTexture->AsDXGITextureHostD3D11();
if (checkVideoOverlayDisabled) {
auto externalImageKey = wrTexture->GetExternalImageKey();
usageInfo = wr::RenderThread::Get()->GetOrMergeUsageInfo(
externalImageKey,
aPipeline->mImageHost->GetRenderTextureHostUsageInfo());
if (usageInfo) {
videoOverlayDisabled = usageInfo->VideoOverlayDisabled();
aPipeline->mImageHost->SetRenderTextureHostUsageInfo(usageInfo);
}
}
MOZ_ASSERT_IF(aPipeline->mVideoOverlayDisabled, videoOverlayDisabled);
bool canUpdate =
!!previousTexture &&
previousTexture->GetTextureHostType() == aTexture->GetTextureHostType() &&
@ -273,7 +292,13 @@ Maybe<TextureHost::ResourceUpdateOp> AsyncImagePipelineManager::UpdateImageKeys(
previousTexture->NeedsYFlip() == aTexture->NeedsYFlip() &&
previousTexture->SupportsExternalCompositing(backend) ==
aTexture->SupportsExternalCompositing(backend) &&
aPipeline->mKeys.Length() == numKeys;
aPipeline->mKeys.Length() == numKeys &&
aPipeline->mVideoOverlayDisabled == videoOverlayDisabled;
if (videoOverlayDisabled) {
MOZ_ASSERT(usageInfo);
aPipeline->mVideoOverlayDisabled = true;
}
if (!canUpdate) {
for (auto key : aPipeline->mKeys) {
@ -462,6 +487,12 @@ void AsyncImagePipelineManager::ApplyAsyncImageForPipeline(
Range<wr::ImageKey> range_keys(&keys[0], keys.Length());
TextureHost::PushDisplayItemFlagSet flags;
flags += TextureHost::PushDisplayItemFlag::PREFER_COMPOSITOR_SURFACE;
if (aPipeline->mVideoOverlayDisabled &&
aPipeline->mDLBuilder.GetBackendType() !=
WebRenderBackend::SOFTWARE) {
flags +=
TextureHost::PushDisplayItemFlag::EXTERNAL_COMPOSITING_DISABLED;
}
if (mApi->SupportsExternalBufferTextures()) {
flags +=
TextureHost::PushDisplayItemFlag::SUPPORTS_EXTERNAL_BUFFER_TEXTURES;

View File

@ -23,6 +23,7 @@ namespace mozilla {
namespace wr {
class DisplayListBuilder;
class RenderTextureHostUsageInfo;
class WebRenderAPI;
class WebRenderPipelineInfo;
} // namespace wr
@ -196,7 +197,8 @@ class AsyncImagePipelineManager final {
struct AsyncImagePipeline {
AsyncImagePipeline(wr::PipelineId aPipelineId,
layers::WebRenderBackend aBackend);
layers::WebRenderBackend aBackend,
WebRenderImageHost* aImageHost);
void Update(const LayoutDeviceRect& aScBounds, wr::WrRotation aRotation,
const wr::ImageRendering& aFilter,
const wr::MixBlendMode& aMixBlendMode) {
@ -216,10 +218,11 @@ class AsyncImagePipelineManager final {
wr::WrRotation mRotation;
wr::ImageRendering mFilter;
wr::MixBlendMode mMixBlendMode;
RefPtr<WebRenderImageHost> mImageHost;
const RefPtr<WebRenderImageHost> mImageHost;
CompositableTextureHostRef mCurrentTexture;
nsTArray<wr::ImageKey> mKeys;
wr::DisplayListBuilder mDLBuilder;
bool mVideoOverlayDisabled = false;
};
void ApplyAsyncImageForPipeline(const wr::Epoch& aEpoch,

View File

@ -13,6 +13,7 @@
#include "CompositableHost.h" // for CompositableHost
#include "mozilla/layers/ImageComposite.h" // for ImageComposite
#include "mozilla/WeakPtr.h"
#include "mozilla/webrender/RenderTextureHost.h"
namespace mozilla {
namespace layers {
@ -62,6 +63,14 @@ class WebRenderImageHost : public CompositableHost, public ImageComposite {
TextureHost* GetCurrentTextureHost() { return mCurrentTextureHost; }
void SetRenderTextureHostUsageInfo(
RefPtr<wr::RenderTextureHostUsageInfo> aUsageInfo) {
mRenderTextureHostUsageInfo = aUsageInfo;
}
RefPtr<wr::RenderTextureHostUsageInfo> GetRenderTextureHostUsageInfo() const {
return mRenderTextureHostUsageInfo;
}
protected:
// ImageComposite
TimeStamp GetCompositionTime() const override;
@ -81,6 +90,8 @@ class WebRenderImageHost : public CompositableHost, public ImageComposite {
bool mWaitingReadyCallback = false;
bool mWaitForRemoteTextureOwner = true;
RefPtr<wr::RenderTextureHostUsageInfo> mRenderTextureHostUsageInfo;
#if XP_WIN
RefPtr<TextureWrapperD3D11Allocator> mTextureAllocator;
#endif

View File

@ -68,6 +68,10 @@ class WebRenderTextureHost : public TextureHost {
return mWrappedTextureHost->AsBufferTextureHost();
}
DXGITextureHostD3D11* AsDXGITextureHostD3D11() override {
return mWrappedTextureHost->AsDXGITextureHostD3D11();
}
bool IsWrappingSurfaceTextureHost() override;
virtual void PrepareForUse() override;

View File

@ -674,15 +674,24 @@ void DCLayerTree::CompositorEndFrame() {
return;
}
for (auto it = mDCSurfaces.begin(); it != mDCSurfaces.end(); it++) {
auto* surfaceVideo = it->second->AsDCSurfaceVideo();
if (surfaceVideo) {
surfaceVideo->DisableVideoOverlay();
}
}
if (mUsedOverlayTypesInFrame & DCompOverlayTypes::SOFTWARE_DECODED_VIDEO) {
gfxCriticalNoteOnce << "Sw video swapchain present is slow";
RenderThread::Get()->NotifyWebRenderError(
wr::WebRenderError::VIDEO_SW_OVERLAY);
nsPrintfCString marker("Sw video swapchain present is slow");
PROFILER_MARKER_TEXT("DisableOverlay", GRAPHICS, {}, marker);
}
if (mUsedOverlayTypesInFrame & DCompOverlayTypes::HARDWARE_DECODED_VIDEO) {
gfxCriticalNoteOnce << "Hw video swapchain present is slow";
RenderThread::Get()->NotifyWebRenderError(
wr::WebRenderError::VIDEO_HW_OVERLAY);
nsPrintfCString marker("Hw video swapchain present is slow");
PROFILER_MARKER_TEXT("DisableOverlay", GRAPHICS, {}, marker);
}
}
@ -1353,10 +1362,14 @@ bool IsYUVSwapChainFormat(DXGI_FORMAT aFormat) {
}
void DCSurfaceVideo::AttachExternalImage(wr::ExternalImageId aExternalImage) {
RenderTextureHost* texture =
RenderThread::Get()->GetRenderTexture(aExternalImage);
auto [texture, usageInfo] =
RenderThread::Get()->GetRenderTextureAndUsageInfo(aExternalImage);
MOZ_RELEASE_ASSERT(texture);
if (usageInfo) {
mRenderTextureHostUsageInfo = usageInfo;
}
if (mPrevTexture == texture) {
return;
}
@ -1618,15 +1631,24 @@ void DCSurfaceVideo::PresentVideo() {
if (overlayType == DCompOverlayTypes::SOFTWARE_DECODED_VIDEO) {
gfxCriticalNoteOnce << "Sw video swapchain present is slow";
RenderThread::Get()->NotifyWebRenderError(
wr::WebRenderError::VIDEO_SW_OVERLAY);
nsPrintfCString marker("Sw video swapchain present is slow");
PROFILER_MARKER_TEXT("DisableOverlay", GRAPHICS, {}, marker);
} else {
gfxCriticalNoteOnce << "Hw video swapchain present is slow";
RenderThread::Get()->NotifyWebRenderError(
wr::WebRenderError::VIDEO_HW_OVERLAY);
nsPrintfCString marker("Hw video swapchain present is slow");
PROFILER_MARKER_TEXT("DisableOverlay", GRAPHICS, {}, marker);
}
}
void DCSurfaceVideo::DisableVideoOverlay() {
if (!mRenderTextureHostUsageInfo) {
return;
}
mRenderTextureHostUsageInfo->DisableVideoOverlay();
}
DXGI_FORMAT DCSurfaceVideo::GetSwapChainFormat(bool aUseVpAutoHDR) {
if (aUseVpAutoHDR) {
return DXGI_FORMAT_R16G16B16A16_FLOAT;

View File

@ -63,6 +63,7 @@ class DCSurface;
class DCSurfaceVideo;
class DCSurfaceHandle;
class RenderTextureHost;
class RenderTextureHostUsageInfo;
class RenderDcompSurfaceTextureHost;
struct GpuOverlayInfo {
@ -394,6 +395,8 @@ class DCSurfaceVideo : public DCSurface {
DCSurfaceVideo* AsDCSurfaceVideo() override { return this; }
void DisableVideoOverlay();
protected:
virtual ~DCSurfaceVideo();
@ -414,6 +417,7 @@ class DCSurfaceVideo : public DCSurface {
bool mFailedYuvSwapChain = false;
RefPtr<RenderTextureHost> mRenderTextureHost;
RefPtr<RenderTextureHost> mPrevTexture;
RefPtr<RenderTextureHostUsageInfo> mRenderTextureHostUsageInfo;
int mSlowPresentCount = 0;
bool mFirstPresent = true;
const UINT mSwapChainBufferCount;

View File

@ -7,6 +7,7 @@
#include "RenderTextureHost.h"
#include "GLContext.h"
#include "mozilla/layers/CompositorThread.h"
#include "RenderThread.h"
namespace mozilla {
@ -54,5 +55,59 @@ void RenderTextureHost::Destroy() {
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
}
RefPtr<RenderTextureHostUsageInfo> RenderTextureHost::GetOrMergeUsageInfo(
const MutexAutoLock& aProofOfMapLock,
RefPtr<RenderTextureHostUsageInfo> aUsageInfo) {
MOZ_ASSERT(layers::CompositorThreadHolder::IsInCompositorThread());
if (mRenderTextureHostUsageInfo && aUsageInfo) {
if (mRenderTextureHostUsageInfo == aUsageInfo) {
return mRenderTextureHostUsageInfo;
}
// Merge 2 RenderTextureHostUsageInfos to one RenderTextureHostUsageInfo.
const bool overlayDisabled =
mRenderTextureHostUsageInfo->VideoOverlayDisabled() ||
aUsageInfo->VideoOverlayDisabled();
// If mRenderTextureHostUsageInfo and aUsageInfo are different objects, keep
// the older one.
RefPtr<RenderTextureHostUsageInfo> usageInfo = [&]() {
if (aUsageInfo->mCreationTimeStamp <
mRenderTextureHostUsageInfo->mCreationTimeStamp) {
return aUsageInfo;
}
return mRenderTextureHostUsageInfo;
}();
// Merge info.
if (overlayDisabled) {
usageInfo->DisableVideoOverlay();
}
mRenderTextureHostUsageInfo = usageInfo;
} else if (aUsageInfo && !mRenderTextureHostUsageInfo) {
mRenderTextureHostUsageInfo = aUsageInfo;
}
if (!mRenderTextureHostUsageInfo) {
MOZ_ASSERT(!aUsageInfo);
mRenderTextureHostUsageInfo = new RenderTextureHostUsageInfo;
}
MOZ_ASSERT(mRenderTextureHostUsageInfo);
MOZ_ASSERT_IF(aUsageInfo && aUsageInfo->VideoOverlayDisabled(),
mRenderTextureHostUsageInfo->VideoOverlayDisabled());
return mRenderTextureHostUsageInfo;
}
RefPtr<RenderTextureHostUsageInfo> RenderTextureHost::GetTextureHostUsageInfo(
const MutexAutoLock& aProofOfMapLock) {
MOZ_ASSERT(RenderThread::IsInRenderThread());
return mRenderTextureHostUsageInfo;
}
} // namespace wr
} // namespace mozilla

View File

@ -10,6 +10,7 @@
#include "GLConsts.h"
#include "GLTypes.h"
#include "nsISupportsImpl.h"
#include "mozilla/Atomics.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/layers/LayersSurfaces.h"
#include "mozilla/RefPtr.h"
@ -43,6 +44,27 @@ class RenderTextureHostWrapper;
void ActivateBindAndTexParameteri(gl::GLContext* aGL, GLenum aActiveTexture,
GLenum aBindTarget, GLuint aBindTexture);
// RenderTextureHostUsageInfo holds information about how the RenderTextureHost
// is used. It is used by AsyncImagePipelineManager to determine how to render
// TextureHost.
class RenderTextureHostUsageInfo final {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RenderTextureHostUsageInfo)
RenderTextureHostUsageInfo() : mCreationTimeStamp(TimeStamp::Now()) {}
bool VideoOverlayDisabled() { return mVideoOverlayDisabled; }
void DisableVideoOverlay() { mVideoOverlayDisabled = true; }
const TimeStamp mCreationTimeStamp;
protected:
~RenderTextureHostUsageInfo() = default;
// RenderTextureHost prefers to disable video overlay.
Atomic<bool> mVideoOverlayDisabled{false};
};
class RenderTextureHost {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RenderTextureHost)
@ -134,6 +156,16 @@ class RenderTextureHost {
return false;
}
// Get RenderTextureHostUsageInfo of the RenderTextureHost.
// If mRenderTextureHostUsageInfo and aUsageInfo are different, merge them to
// one RenderTextureHostUsageInfo.
virtual RefPtr<RenderTextureHostUsageInfo> GetOrMergeUsageInfo(
const MutexAutoLock& aProofOfMapLock,
RefPtr<RenderTextureHostUsageInfo> aUsageInfo);
virtual RefPtr<RenderTextureHostUsageInfo> GetTextureHostUsageInfo(
const MutexAutoLock& aProofOfMapLock);
protected:
virtual ~RenderTextureHost();
@ -146,6 +178,9 @@ class RenderTextureHost {
bool mIsFromDRMSource;
// protected by RenderThread::mRenderTextureMapLock
RefPtr<RenderTextureHostUsageInfo> mRenderTextureHostUsageInfo;
friend class RenderTextureHostWrapper;
};

View File

@ -181,6 +181,25 @@ bool RenderTextureHostWrapper::IsSoftwareDecodedVideo() {
return mTextureHost->IsSoftwareDecodedVideo();
}
RefPtr<RenderTextureHostUsageInfo>
RenderTextureHostWrapper::GetOrMergeUsageInfo(
const MutexAutoLock& aProofOfMapLock,
RefPtr<RenderTextureHostUsageInfo> aUsageInfo) {
if (!mTextureHost) {
return nullptr;
}
return mTextureHost->GetOrMergeUsageInfo(aProofOfMapLock, aUsageInfo);
}
RefPtr<RenderTextureHostUsageInfo>
RenderTextureHostWrapper::GetTextureHostUsageInfo(
const MutexAutoLock& aProofOfMapLock) {
if (!mTextureHost) {
return nullptr;
}
return mTextureHost->GetTextureHostUsageInfo(aProofOfMapLock);
}
size_t RenderTextureHostWrapper::GetPlaneCount() const {
if (RenderTextureHostSWGL* swglHost = EnsureRenderTextureHostSWGL()) {
return swglHost->GetPlaneCount();

View File

@ -49,6 +49,11 @@ class RenderTextureHostWrapper final : public RenderTextureHostSWGL {
RenderTextureHostSWGL* AsRenderTextureHostSWGL() override;
void SetIsSoftwareDecodedVideo() override;
bool IsSoftwareDecodedVideo() override;
RefPtr<RenderTextureHostUsageInfo> GetOrMergeUsageInfo(
const MutexAutoLock& aProofOfMapLock,
RefPtr<RenderTextureHostUsageInfo> aUsageInfo) override;
RefPtr<RenderTextureHostUsageInfo> GetTextureHostUsageInfo(
const MutexAutoLock& aProofOfMapLock) override;
// RenderTextureHostSWGL
size_t GetPlaneCount() const override;

View File

@ -1163,6 +1163,22 @@ void RenderThread::HandleRenderTextureOps() {
}
}
RefPtr<RenderTextureHostUsageInfo> RenderThread::GetOrMergeUsageInfo(
const wr::ExternalImageId& aExternalImageId,
RefPtr<RenderTextureHostUsageInfo> aUsageInfo) {
MutexAutoLock lock(mRenderTextureMapLock);
if (mHasShutdown) {
return nullptr;
}
auto it = mRenderTextures.find(aExternalImageId);
if (it == mRenderTextures.end()) {
return nullptr;
}
auto& texture = it->second;
return texture->GetOrMergeUsageInfo(lock, aUsageInfo);
}
void RenderThread::UnregisterExternalImageDuringShutdown(
const wr::ExternalImageId& aExternalImageId) {
MOZ_ASSERT(IsInRenderThread());
@ -1193,6 +1209,18 @@ RenderTextureHost* RenderThread::GetRenderTexture(
return it->second;
}
std::tuple<RenderTextureHost*, RefPtr<RenderTextureHostUsageInfo>>
RenderThread::GetRenderTextureAndUsageInfo(
const wr::ExternalImageId& aExternalImageId) {
MutexAutoLock lock(mRenderTextureMapLock);
auto it = mRenderTextures.find(aExternalImageId);
MOZ_ASSERT(it != mRenderTextures.end());
if (it == mRenderTextures.end()) {
return {};
}
return {it->second, it->second->GetTextureHostUsageInfo(lock)};
}
void RenderThread::InitDeviceTask() {
MOZ_ASSERT(IsInRenderThread());
MOZ_ASSERT(!mSingletonGL);

View File

@ -45,6 +45,7 @@ typedef MozPromise<MemoryReport, bool, true> MemoryReportPromise;
class RendererOGL;
class RenderTextureHost;
class RenderTextureHostUsageInfo;
class RenderThread;
/// A rayon thread pool that is shared by all WebRender instances within a
@ -231,6 +232,11 @@ class RenderThread final {
void HandleRenderTextureOps();
/// Can be called from any thread.
RefPtr<RenderTextureHostUsageInfo> GetOrMergeUsageInfo(
const wr::ExternalImageId& aExternalImageId,
RefPtr<RenderTextureHostUsageInfo> aUsageInfo);
/// Can only be called from the render thread.
void UnregisterExternalImageDuringShutdown(
const wr::ExternalImageId& aExternalImageId);
@ -239,6 +245,10 @@ class RenderThread final {
RenderTextureHost* GetRenderTexture(
const wr::ExternalImageId& aExternalImageId);
/// Can only be called from the render thread.
std::tuple<RenderTextureHost*, RefPtr<RenderTextureHostUsageInfo>>
GetRenderTextureAndUsageInfo(const wr::ExternalImageId& aExternalImageId);
/// Can be called from any thread.
bool IsDestroyed(wr::WindowId aWindowId);
/// Can be called from any thread.