Commit 15ad7260 authored by sotaro's avatar sotaro
Browse files

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
parent eea7eafa
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -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;
+8 −0
Original line number Diff line number Diff line
@@ -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() {}
+0 −6
Original line number Diff line number Diff line
@@ -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) {}