Bug 1613364 [Wayland] Update gfx code to derived WaylandDMABufSurfaceRGBA class, r=sotaro
authorMartin Stransky <stransky@redhat.com>
Wed, 12 Feb 2020 22:35:02 +0000
changeset 513637 e4383c8d1123da7eabe9c42042839cfc9eb2820d
parent 513636 cdab069b9ed9530c5bf018288dcf6ff69c175aa4
child 513638 4e6ca0999851751754fa160e425bb0b28d070df3
push id37118
push userrmaries@mozilla.com
push dateThu, 13 Feb 2020 03:57:45 +0000
treeherdermozilla-central@2f6870dd1b99 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1613364
milestone75.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1613364 [Wayland] Update gfx code to derived WaylandDMABufSurfaceRGBA class, r=sotaro WaylandDMABufSurface/WaylandDMABufSurfaceRGBA uses textures interface instead of EGLImages so we need to update gfx code accordingly: - rename CreateEGLImage() -> CreateTexture() - rename ReleaseEGLImage() -> ReleaseTextures() - rename GetGLTexture() -> GetTexture() - rename WaylandDMABufSurface::CreateDMABufSurface() to WaylandDMABufSurfaceRGBA::CreateDMABufSurface() Differential Revision: https://phabricator.services.mozilla.com/D62005
gfx/gl/SharedSurfaceDMABUF.cpp
gfx/gl/SharedSurfaceDMABUF.h
gfx/layers/opengl/WaylandDMABUFTextureHostOGL.cpp
widget/gtk/WaylandDMABufSurface.h
--- a/gfx/gl/SharedSurfaceDMABUF.cpp
+++ b/gfx/gl/SharedSurfaceDMABUF.cpp
@@ -15,18 +15,19 @@ UniquePtr<SharedSurface_DMABUF> SharedSu
     bool hasAlpha) {
   auto flags = static_cast<WaylandDMABufSurfaceFlags>(DMABUF_TEXTURE |
                                                       DMABUF_USE_MODIFIERS);
   if (hasAlpha) {
     flags = static_cast<WaylandDMABufSurfaceFlags>(flags | DMABUF_ALPHA);
   }
 
   RefPtr<WaylandDMABufSurface> surface =
-      WaylandDMABufSurface::CreateDMABufSurface(size.width, size.height, flags);
-  if (!surface || !surface->CreateEGLImage(prodGL)) {
+      WaylandDMABufSurfaceRGBA::CreateDMABufSurface(size.width, size.height,
+                                                    flags);
+  if (!surface || !surface->CreateTexture(prodGL)) {
     return nullptr;
   }
 
   UniquePtr<SharedSurface_DMABUF> ret;
   ret.reset(new SharedSurface_DMABUF(prodGL, size, hasAlpha, surface));
   return ret;
 }
 
@@ -36,17 +37,17 @@ SharedSurface_DMABUF::SharedSurface_DMAB
     : SharedSurface(SharedSurfaceType::EGLSurfaceDMABUF,
                     AttachmentType::GLTexture, gl, size, hasAlpha, true),
       mSurface(aSurface) {}
 
 SharedSurface_DMABUF::~SharedSurface_DMABUF() {
   if (!mGL || !mGL->MakeCurrent()) {
     return;
   }
-  mSurface->ReleaseEGLImage();
+  mSurface->ReleaseTextures();
 }
 
 void SharedSurface_DMABUF::ProducerReleaseImpl() {
   mGL->MakeCurrent();
   // We don't have a better sync mechanism here so use glFinish() at least.
   mGL->fFinish();
 }
 
--- a/gfx/gl/SharedSurfaceDMABUF.h
+++ b/gfx/gl/SharedSurfaceDMABUF.h
@@ -46,17 +46,17 @@ class SharedSurface_DMABUF final : publi
   // Non-exclusive Content/WebGL lock/unlock of surface for write
   virtual void ProducerAcquireImpl() override {}
   virtual void ProducerReleaseImpl() override;
 
   // Non-exclusive Content/WebGL lock/unlock for read from surface
   virtual void ProducerReadAcquireImpl() override {}
   virtual void ProducerReadReleaseImpl() override {}
 
-  virtual GLuint ProdTexture() override { return mSurface->GetGLTexture(); }
+  virtual GLuint ProdTexture() override { return mSurface->GetTexture(); }
 
   virtual bool ToSurfaceDescriptor(
       layers::SurfaceDescriptor* const out_descriptor) override;
 };
 
 class SurfaceFactory_DMABUF : public SurfaceFactory {
  public:
   SurfaceFactory_DMABUF(GLContext* prodGL, const SurfaceCaps& caps,
--- a/gfx/layers/opengl/WaylandDMABUFTextureHostOGL.cpp
+++ b/gfx/layers/opengl/WaylandDMABUFTextureHostOGL.cpp
@@ -48,17 +48,17 @@ bool WaylandDMABUFTextureHostOGL::Lock()
   if (!gl() || !gl()->MakeCurrent() || !mSurface) {
     return false;
   }
 
   if (!mTextureSource) {
     mTextureSource = CreateTextureSourceForPlane(0);
 
     RefPtr<TextureSource> prev = mTextureSource;
-    for (size_t i = 1; i < mSurface->GetPlaneCount(); i++) {
+    for (size_t i = 1; i < mSurface->GetTextureCount(); i++) {
       RefPtr<TextureSource> next = CreateTextureSourceForPlane(i);
       prev->SetNextSibling(next);
       prev = next;
     }
   }
   return true;
 }
 
@@ -97,17 +97,17 @@ gfx::ColorRange WaylandDMABUFTextureHost
   if (!mSurface) {
     return gfx::ColorRange::LIMITED;
   }
   return mSurface->IsFullRange() ? gfx::ColorRange::FULL
                                  : gfx::ColorRange::LIMITED;
 }
 
 uint32_t WaylandDMABUFTextureHostOGL::NumSubTextures() {
-  return mSurface->GetPlaneCount();
+  return mSurface->GetTextureCount();
 }
 
 gfx::IntSize WaylandDMABUFTextureHostOGL::GetSize() const {
   if (!mSurface) {
     return gfx::IntSize();
   }
   return gfx::IntSize(mSurface->GetWidth(), mSurface->GetHeight());
 }
@@ -146,17 +146,17 @@ void WaylandDMABUFTextureHostOGL::PushRe
       // With BGRA format setting, rendering works without problem.
       wr::ImageDescriptor descriptor(GetSize(), mSurface->GetFormat(),
                                      aPreferCompositorSurface);
       (aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0);
       break;
     }
     case gfx::SurfaceFormat::NV12: {
       MOZ_ASSERT(aImageKeys.length() == 2);
-      MOZ_ASSERT(mSurface->GetPlaneCount() == 2);
+      MOZ_ASSERT(mSurface->GetTextureCount() == 2);
       wr::ImageDescriptor descriptor0(
           gfx::IntSize(mSurface->GetWidth(0), mSurface->GetHeight(0)),
           gfx::SurfaceFormat::A8, aPreferCompositorSurface);
       wr::ImageDescriptor descriptor1(
           gfx::IntSize(mSurface->GetWidth(1), mSurface->GetHeight(1)),
           gfx::SurfaceFormat::R8G8, aPreferCompositorSurface);
       (aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0);
       (aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1);
@@ -179,17 +179,17 @@ void WaylandDMABUFTextureHostOGL::PushDi
     case gfx::SurfaceFormat::B8G8R8X8: {
       MOZ_ASSERT(aImageKeys.length() == 1);
       aBuilder.PushImage(aBounds, aClip, true, aFilter, aImageKeys[0],
                          !(mFlags & TextureFlags::NON_PREMULTIPLIED));
       break;
     }
     case gfx::SurfaceFormat::NV12: {
       MOZ_ASSERT(aImageKeys.length() == 2);
-      MOZ_ASSERT(mSurface->GetPlaneCount() == 2);
+      MOZ_ASSERT(mSurface->GetTextureCount() == 2);
       // Those images can only be generated at present by the VAAPI H264 decoder
       // which only supports 8 bits color depth.
       aBuilder.PushNV12Image(aBounds, aClip, true, aImageKeys[0], aImageKeys[1],
                              wr::ColorDepth::Color8,
                              wr::ToWrYuvColorSpace(GetYUVColorSpace()),
                              wr::ToWrColorRange(GetColorRange()), aFilter);
       break;
     }
--- a/widget/gtk/WaylandDMABufSurface.h
+++ b/widget/gtk/WaylandDMABufSurface.h
@@ -63,17 +63,17 @@ class WaylandDMABufSurface {
 
   virtual bool CreateTexture(mozilla::gl::GLContext* aGLContext,
                              int aPlane = 0) = 0;
   virtual void ReleaseTextures() = 0;
   virtual GLuint GetTexture(int aPlane = 0) = 0;
   virtual EGLImageKHR GetEGLImage(int aPlane = 0) = 0;
 
   SurfaceType GetSurfaceType() { return mSurfaceType; };
-  virtual uint32_t GetPlaneCount() = 0;
+  virtual uint32_t GetTextureCount() = 0;
 
   virtual WaylandDMABufSurfaceRGBA* GetAsWaylandDMABufSurfaceRGBA() {
     return nullptr;
   }
 
   virtual mozilla::gfx::YUVColorSpace GetYUVColorSpace() {
     return mozilla::gfx::YUVColorSpace::UNKNOWN;
   };
@@ -127,17 +127,17 @@ class WaylandDMABufSurfaceRGBA : public 
   bool IsMapped() { return (mMappedRegion != nullptr); };
   void Unmap();
 
   bool CreateTexture(mozilla::gl::GLContext* aGLContext, int aPlane = 0);
   void ReleaseTextures();
   GLuint GetTexture(int aPlane = 0) { return mTexture; };
   EGLImageKHR GetEGLImage(int aPlane = 0) { return mEGLImage; };
 
-  uint32_t GetPlaneCount() { return mBufferPlaneCount; };
+  uint32_t GetTextureCount() { return 1; };
 
   void SetWLBuffer(struct wl_buffer* aWLBuffer);
   wl_buffer* GetWLBuffer();
   void WLBufferDetach() { mWLBufferAttached = false; };
   bool WLBufferIsAttached() { return mWLBufferAttached; };
   void WLBufferSetAttached() { mWLBufferAttached = true; };
 
   WaylandDMABufSurfaceRGBA();
@@ -191,17 +191,17 @@ class WaylandDMABufSurfaceNV12 : public 
   int GetHeight(int aPlane = 0) { return mHeight[aPlane]; }
   mozilla::gfx::SurfaceFormat GetFormat();
   mozilla::gfx::SurfaceFormat GetFormatGL();
 
   bool CreateTexture(mozilla::gl::GLContext* aGLContext, int aPlane = 0);
   void ReleaseTextures();
   GLuint GetTexture(int aPlane = 0) { return mTexture[aPlane]; };
 
-  uint32_t GetPlaneCount();
+  uint32_t GetTextureCount() { return 2; };
 
   void SetYUVColorSpace(mozilla::gfx::YUVColorSpace aColorSpace) {
     mColorSpace = aColorSpace;
   }
   mozilla::gfx::YUVColorSpace GetYUVColorSpace() { return mColorSpace; }
 
   bool IsFullRange() { return true; }