Bug 1530471 - remove layers SkiaGL glue r=jrmuizel
authorLee Salzman <lsalzman@mozilla.com>
Thu, 28 Feb 2019 15:00:06 +0000
changeset 461779 d2af6ff2f10d00f8c03f8924d0d9b3e00ec2e918
parent 461778 6d0e1f99b8acd5baaa7ca194d852c48b4d79ee75
child 461780 484f62205c8daf3510511e60bc331d189321a02a
push id35629
push useropoprus@mozilla.com
push dateFri, 01 Mar 2019 05:20:57 +0000
treeherdermozilla-central@9d39099e5fc5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1530471
milestone67.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 1530471 - remove layers SkiaGL glue r=jrmuizel Depends on D21054 Differential Revision: https://phabricator.services.mozilla.com/D21055
gfx/layers/CanvasRenderer.h
gfx/layers/CopyableCanvasRenderer.cpp
gfx/layers/CopyableCanvasRenderer.h
gfx/layers/ShareableCanvasRenderer.cpp
gfx/layers/client/CanvasClient.cpp
--- a/gfx/layers/CanvasRenderer.h
+++ b/gfx/layers/CanvasRenderer.h
@@ -32,36 +32,32 @@ struct CanvasInitializeData {
   CanvasInitializeData()
       : mBufferProvider(nullptr),
         mGLContext(nullptr),
         mRenderer(nullptr),
         mPreTransCallback(nullptr),
         mPreTransCallbackData(nullptr),
         mDidTransCallback(nullptr),
         mDidTransCallbackData(nullptr),
-        mFrontbufferGLTex(0),
         mSize(0, 0),
         mHasAlpha(false),
         mIsGLAlphaPremult(true) {}
 
   // One of these three must be specified for Canvas2D, but never more than one
   PersistentBufferProvider*
       mBufferProvider;  // A BufferProvider for the Canvas contents
   mozilla::gl::GLContext* mGLContext;  // or this, for GL.
   AsyncCanvasRenderer* mRenderer;      // or this, for OffscreenCanvas
 
   typedef void (*TransactionCallback)(void* closureData);
   TransactionCallback mPreTransCallback;
   void* mPreTransCallbackData;
   TransactionCallback mDidTransCallback;
   void* mDidTransCallbackData;
 
-  // Frontbuffer override
-  uint32_t mFrontbufferGLTex;
-
   // The size of the canvas content
   gfx::IntSize mSize;
 
   // Whether the canvas drawingbuffer has an alpha channel.
   bool mHasAlpha;
 
   // Whether mGLContext contains data that is alpha-premultiplied.
   bool mIsGLAlphaPremult;
--- a/gfx/layers/CopyableCanvasRenderer.cpp
+++ b/gfx/layers/CopyableCanvasRenderer.cpp
@@ -31,17 +31,16 @@ namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 using namespace mozilla::gl;
 
 CopyableCanvasRenderer::CopyableCanvasRenderer()
     : mGLContext(nullptr),
       mBufferProvider(nullptr),
-      mGLFrontbuffer(nullptr),
       mAsyncRenderer(nullptr),
       mIsAlphaPremultiplied(true),
       mOriginPos(gl::OriginPos::TopLeft),
       mOpaque(true),
       mCachedTempSurface(nullptr) {
   MOZ_COUNT_CTOR(CopyableCanvasRenderer);
 }
 
@@ -55,22 +54,16 @@ void CopyableCanvasRenderer::Initialize(
 
   if (aData.mGLContext) {
     mGLContext = aData.mGLContext;
     mIsAlphaPremultiplied = aData.mIsGLAlphaPremult;
     mOriginPos = gl::OriginPos::BottomLeft;
 
     MOZ_ASSERT(mGLContext->IsOffscreen(), "canvas gl context isn't offscreen");
 
-    if (aData.mFrontbufferGLTex) {
-      gfx::IntSize size(aData.mSize.width, aData.mSize.height);
-      mGLFrontbuffer = SharedSurface_Basic::Wrap(
-          aData.mGLContext, size, aData.mHasAlpha, aData.mFrontbufferGLTex);
-      mBufferProvider = aData.mBufferProvider;
-    }
   } else if (aData.mBufferProvider) {
     mBufferProvider = aData.mBufferProvider;
   } else if (aData.mRenderer) {
     mAsyncRenderer = aData.mRenderer;
     mOriginPos = gl::OriginPos::BottomLeft;
   } else {
     MOZ_CRASH(
         "GFX: CanvasRenderer created without BufferProvider, DrawTarget or "
@@ -125,19 +118,17 @@ already_AddRefed<SourceSurface> Copyable
     return mAsyncRenderer->GetSurface();
   }
 
   if (!mGLContext) {
     return nullptr;
   }
 
   SharedSurface* frontbuffer = nullptr;
-  if (mGLFrontbuffer) {
-    frontbuffer = mGLFrontbuffer.get();
-  } else if (mGLContext->Screen()) {
+  if (mGLContext->Screen()) {
     const auto& front = mGLContext->Screen()->Front();
     if (front) {
       frontbuffer = front->Surf();
     }
   }
 
   if (!frontbuffer) {
     NS_WARNING("Null frame received.");
--- a/gfx/layers/CopyableCanvasRenderer.h
+++ b/gfx/layers/CopyableCanvasRenderer.h
@@ -52,17 +52,16 @@ class CopyableCanvasRenderer : public Ca
 
   PersistentBufferProvider* GetBufferProvider() { return mBufferProvider; }
 
   already_AddRefed<gfx::SourceSurface> ReadbackSurface();
 
  protected:
   RefPtr<gl::GLContext> mGLContext;
   RefPtr<PersistentBufferProvider> mBufferProvider;
-  UniquePtr<gl::SharedSurface> mGLFrontbuffer;
   RefPtr<AsyncCanvasRenderer> mAsyncRenderer;
 
   bool mIsAlphaPremultiplied;
   gl::OriginPos mOriginPos;
 
   bool mOpaque;
 
   RefPtr<gfx::DataSourceSurface> mCachedTempSurface;
--- a/gfx/layers/ShareableCanvasRenderer.cpp
+++ b/gfx/layers/ShareableCanvasRenderer.cpp
@@ -36,47 +36,30 @@ ShareableCanvasRenderer::~ShareableCanva
 void ShareableCanvasRenderer::Initialize(const CanvasInitializeData& aData) {
   CopyableCanvasRenderer::Initialize(aData);
 
   mCanvasClient = nullptr;
 
   if (!mGLContext) return;
 
   gl::GLScreenBuffer* screen = mGLContext->Screen();
-
-  gl::SurfaceCaps caps;
-  if (mGLFrontbuffer) {
-    // The screen caps are irrelevant if we're using a separate frontbuffer.
-    caps = mGLFrontbuffer->mHasAlpha ? gl::SurfaceCaps::ForRGBA()
-                                     : gl::SurfaceCaps::ForRGB();
-  } else {
-    MOZ_ASSERT(screen);
-    caps = screen->mCaps;
-  }
+  MOZ_ASSERT(screen);
+  gl::SurfaceCaps caps = screen->mCaps;
 
   auto forwarder = GetForwarder();
 
   mFlags = TextureFlags::ORIGIN_BOTTOM_LEFT;
   if (!aData.mIsGLAlphaPremult) {
     mFlags |= TextureFlags::NON_PREMULTIPLIED;
   }
 
   UniquePtr<gl::SurfaceFactory> factory =
       gl::GLScreenBuffer::CreateFactory(mGLContext, caps, forwarder, mFlags);
-
-  if (mGLFrontbuffer) {
-    // We're using a source other than the one in the default screen.
-    // (SkiaGL)
-    mFactory = std::move(factory);
-    if (!mFactory) {
-      // Absolutely must have a factory here, so create a basic one
-      mFactory = MakeUnique<gl::SurfaceFactory_Basic>(mGLContext, caps, mFlags);
-    }
-  } else {
-    if (factory) screen->Morph(std::move(factory));
+  if (factory) {
+    screen->Morph(std::move(factory));
   }
 }
 
 void ShareableCanvasRenderer::ClearCachedResources() {
   CopyableCanvasRenderer::ClearCachedResources();
 
   if (mCanvasClient) {
     mCanvasClient->Clear();
@@ -117,24 +100,21 @@ bool ShareableCanvasRenderer::UpdateTarg
     }
 
     aDestTarget->CopySurface(surface, IntRect(0, 0, mSize.width, mSize.height),
                              IntPoint(0, 0));
     return true;
   }
 
   gl::SharedSurface* frontbuffer = nullptr;
-  if (mGLFrontbuffer) {
-    frontbuffer = mGLFrontbuffer.get();
-  } else {
-    gl::GLScreenBuffer* screen = mGLContext->Screen();
-    const auto& front = screen->Front();
-    if (front) {
-      frontbuffer = front->Surf();
-    }
+
+  gl::GLScreenBuffer* screen = mGLContext->Screen();
+  const auto& front = screen->Front();
+  if (front) {
+    frontbuffer = front->Surf();
   }
 
   if (!frontbuffer) {
     NS_WARNING("Null frame received.");
     return false;
   }
 
   IntSize readSize(frontbuffer->mSize);
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -380,24 +380,17 @@ void CanvasClientSharedSurface::UpdateRe
     asyncRenderer = aRenderer.ref<AsyncCanvasRenderer*>();
     gl = asyncRenderer->mGLContext;
   }
   if (!gl->MakeCurrent()) return;
 
   RefPtr<TextureClient> newFront;
 
   mShSurfClient = nullptr;
-  if (canvasRenderer && canvasRenderer->mGLFrontbuffer) {
-    mShSurfClient = CloneSurface(canvasRenderer->mGLFrontbuffer.get(),
-                                 canvasRenderer->mFactory.get());
-    if (!mShSurfClient) {
-      gfxCriticalError() << "Invalid canvas front buffer";
-      return;
-    }
-  } else if (gl->Screen()) {
+  if (gl->Screen()) {
     mShSurfClient = gl->Screen()->Front();
     if (mShSurfClient && mShSurfClient->GetAllocator() &&
         mShSurfClient->GetAllocator() !=
             GetForwarder()->GetTextureForwarder()) {
       mShSurfClient =
           CloneSurface(mShSurfClient->Surf(), gl->Screen()->Factory());
     }
   }