Bug 1835814 - Move GetFormat() and GetYUVColorSpace() to RenderTextureHost r=gfx-reviewers,lsalzman

By moving GetFormat() and GetYUVColorSpace() to RenderTextureHost, we could reduce cast to RenderTextureHostSWGL.

It is preparation for Bug 1834039.

Differential Revision: https://phabricator.services.mozilla.com/D179435
This commit is contained in:
sotaro 2023-05-30 14:43:22 +00:00
Родитель eea7eafab2
Коммит 15ad7260c1
3 изменённых файлов: 10 добавлений и 11 удалений

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

@ -616,8 +616,6 @@ DCSurface* DCExternalSurfaceWrapper::EnsureSurfaceForExternalImage(
<< gfx::hexa(texture);
return nullptr;
}
const auto textureSwgl = texture->AsRenderTextureHostSWGL();
MOZ_ASSERT(textureSwgl); // Covered above.
// Add surface's visual which will contain video data to our root visual.
const auto surfaceVisual = mSurface->GetVisual();
@ -641,7 +639,7 @@ DCSurface* DCExternalSurfaceWrapper::EnsureSurfaceForExternalImage(
// -
const auto cspace = [&]() {
const auto rangedCspace = textureSwgl->GetYUVColorSpace();
const auto rangedCspace = texture->GetYUVColorSpace();
const auto info = FromYUVRangedColorSpace(rangedCspace);
auto ret = ToColorSpace2(info.space);
if (ret == gfx::ColorSpace2::Display && cmsMode == CMSMode::All) {
@ -1115,8 +1113,7 @@ void DCSurfaceVideo::AttachExternalImage(wr::ExternalImageId aExternalImage) {
// XXX if software decoded video frame format is nv12, it could be used as
// video overlay.
if (!texture || !texture->AsRenderDXGITextureHost() ||
texture->AsRenderDXGITextureHost()->GetFormat() !=
gfx::SurfaceFormat::NV12) {
texture->GetFormat() != gfx::SurfaceFormat::NV12) {
gfxCriticalNote << "Unsupported RenderTexture for overlay: "
<< gfx::hexa(texture);
return;

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

@ -44,6 +44,14 @@ class RenderTextureHost {
public:
RenderTextureHost();
virtual gfx::SurfaceFormat GetFormat() const {
return gfx::SurfaceFormat::UNKNOWN;
}
virtual gfx::YUVRangedColorSpace GetYUVColorSpace() const {
return gfx::YUVRangedColorSpace::Default;
}
virtual wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL);
virtual void Unlock() {}

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

@ -26,16 +26,10 @@ class RenderTextureHostSWGL : public RenderTextureHost {
virtual size_t GetPlaneCount() const = 0;
virtual gfx::SurfaceFormat GetFormat() const = 0;
virtual gfx::ColorDepth GetColorDepth() const {
return gfx::ColorDepth::COLOR_8;
}
virtual gfx::YUVRangedColorSpace GetYUVColorSpace() const {
return gfx::YUVRangedColorSpace::Default;
}
struct PlaneInfo {
explicit PlaneInfo(GLuint aTexture) : mTexture(aTexture) {}