Bug 1781122 Part 2: Make TextureHost aware of DRM Images, and set this on macOS. r=gfx-reviewers,sotaro

At point of display, we need the TextureHost to know whether or not its
texture was created from a DRM Image. The throughline of data is:

Image -> TextureClient -> TextureHost

The TextureClient is generated by the Image, so it has access to the DRM
state of the Image, but the TextureHost is built from the raw texture data
and from TextureFlags. This patch updates TextureFlags to include a
DRM_SOURCE bit for use by the TextureHost.

The TextureClient and TextureHost are platform-specific classes. The
creation of the TextureClient by the Image is done in a platform-specific
subclass of Image. This patch only implements this pipeline for macOS.
There doesn't seem to be a way to do this in cross-platform classes, but
other platforms can follow the pattern used here.

Depends on D155295

Differential Revision: https://phabricator.services.mozilla.com/D155296
This commit is contained in:
Brad Werth 2022-09-07 18:51:12 +00:00
Родитель 2725370634
Коммит 62b54b0774
5 изменённых файлов: 18 добавлений и 4 удалений

Просмотреть файл

@ -90,9 +90,11 @@ enum class TextureFlags : uint32_t {
BORROWED_EXTERNAL_ID = 1 << 19, BORROWED_EXTERNAL_ID = 1 << 19,
// The texture is used for remote texture. // The texture is used for remote texture.
REMOTE_TEXTURE = 1 << 20, REMOTE_TEXTURE = 1 << 20,
// The texture is from a DRM source.
DRM_SOURCE = 1 << 21,
// OR union of all valid bits // OR union of all valid bits
ALL_BITS = (1 << 21) - 1, ALL_BITS = (1 << 22) - 1,
// the default flags // the default flags
DEFAULT = NO_FLAGS DEFAULT = NO_FLAGS
}; };

Просмотреть файл

@ -23,9 +23,11 @@ TextureClient* MacIOSurfaceImage::GetTextureClient(
KnowsCompositor* aKnowsCompositor) { KnowsCompositor* aKnowsCompositor) {
if (!mTextureClient) { if (!mTextureClient) {
BackendType backend = BackendType::NONE; BackendType backend = BackendType::NONE;
TextureFlags flags =
IsDRM() ? TextureFlags::DRM_SOURCE : TextureFlags::DEFAULT;
mTextureClient = TextureClient::CreateWithData( mTextureClient = TextureClient::CreateWithData(
MacIOSurfaceTextureData::Create(mSurface, backend), MacIOSurfaceTextureData::Create(mSurface, backend), flags,
TextureFlags::DEFAULT, aKnowsCompositor->GetTextureForwarder()); aKnowsCompositor->GetTextureForwarder());
} }
return mTextureClient; return mTextureClient;
} }

Просмотреть файл

@ -75,6 +75,9 @@ void MacIOSurfaceTextureHostOGL::CreateRenderTexture(
RefPtr<wr::RenderTextureHost> texture = RefPtr<wr::RenderTextureHost> texture =
new wr::RenderMacIOSurfaceTextureHost(GetMacIOSurface()); new wr::RenderMacIOSurfaceTextureHost(GetMacIOSurface());
bool isDRM = (bool)(mFlags & TextureFlags::DRM_SOURCE);
texture->SetIsFromDRMSource(isDRM);
wr::RenderThread::Get()->RegisterExternalImage(aExternalImageId, wr::RenderThread::Get()->RegisterExternalImage(aExternalImageId,
texture.forget()); texture.forget());
} }

Просмотреть файл

@ -28,7 +28,7 @@ void ActivateBindAndTexParameteri(gl::GLContext* aGL, GLenum aActiveTexture,
} }
RenderTextureHost::RenderTextureHost() RenderTextureHost::RenderTextureHost()
: mCachedRendering(wr::ImageRendering::Auto) { : mCachedRendering(wr::ImageRendering::Auto), mIsFromDRMSource(false) {
MOZ_COUNT_CTOR(RenderTextureHost); MOZ_COUNT_CTOR(RenderTextureHost);
} }

Просмотреть файл

@ -71,6 +71,11 @@ class RenderTextureHost {
// Returns true when RenderTextureHost needs SyncObjectHost::Synchronize() // Returns true when RenderTextureHost needs SyncObjectHost::Synchronize()
// call, before its usage. // call, before its usage.
virtual bool SyncObjectNeeded() { return false; } virtual bool SyncObjectNeeded() { return false; }
// Returns true when this texture was generated from a DRM-protected source.
bool IsFromDRMSource() { return mIsFromDRMSource; }
void SetIsFromDRMSource(bool aIsFromDRMSource) {
mIsFromDRMSource = aIsFromDRMSource;
}
virtual size_t Bytes() = 0; virtual size_t Bytes() = 0;
@ -106,6 +111,8 @@ class RenderTextureHost {
gfx::IntSize aTextureSize) const; gfx::IntSize aTextureSize) const;
wr::ImageRendering mCachedRendering; wr::ImageRendering mCachedRendering;
bool mIsFromDRMSource;
}; };
} // namespace wr } // namespace wr