Bug 1284292 - Allow GLScreenBuffer::CreateFactory to work without a CompositableForwarder draft
authorkearwood
Mon, 04 Jul 2016 11:13:15 -0700
changeset 383645 58a698078f9d71108352c525b0ce8ceebcf061d8
parent 383613 f378a56b25ce2a2997b263c1857629f3f18d7400
child 524525 797d7a48876b20d88f5817b6f310541ba8883ad5
push id22071
push userkgilbert@mozilla.com
push dateMon, 04 Jul 2016 18:16:41 +0000
bugs1284292, 1250244
milestone50.0a1
Bug 1284292 - Allow GLScreenBuffer::CreateFactory to work without a CompositableForwarder - GLScreenBuffer::CreateFactory has been overloaded to accept either a CompositableForwarder or a ClientIPCAllocator. - WebVR 1.0 API implementation in Bug 1250244 uses GLScreenBuffer without a CompositableForwarder. MozReview-Commit-ID: GWR1XuIgPBT
gfx/gl/GLScreenBuffer.cpp
gfx/gl/GLScreenBuffer.h
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -67,62 +67,72 @@ GLScreenBuffer::Create(GLContext* gl,
 }
 
 /* static */ UniquePtr<SurfaceFactory>
 GLScreenBuffer::CreateFactory(GLContext* gl,
                               const SurfaceCaps& caps,
                               const RefPtr<layers::CompositableForwarder>& forwarder,
                               const layers::TextureFlags& flags)
 {
+  return CreateFactory(gl, caps, forwarder, forwarder->GetCompositorBackendType(), flags);
+}
+
+/* static */ UniquePtr<SurfaceFactory>
+GLScreenBuffer::CreateFactory(GLContext* gl,
+                              const SurfaceCaps& caps,
+                              const RefPtr<layers::ClientIPCAllocator>& allocator,
+                              const mozilla::layers::LayersBackend backend,
+                              const layers::TextureFlags& flags)
+{
     UniquePtr<SurfaceFactory> factory = nullptr;
     if (!gfxPrefs::WebGLForceLayersReadback()) {
-        switch (forwarder->GetCompositorBackendType()) {
+        switch (backend) {
             case mozilla::layers::LayersBackend::LAYERS_OPENGL: {
 #if defined(XP_MACOSX)
-                factory = SurfaceFactory_IOSurface::Create(gl, caps, forwarder, flags);
+                factory = SurfaceFactory_IOSurface::Create(gl, caps, allocator, flags);
 #elif defined(MOZ_WIDGET_GONK)
-                factory = MakeUnique<SurfaceFactory_Gralloc>(gl, caps, forwarder, flags);
+                factory = MakeUnique<SurfaceFactory_Gralloc>(gl, caps, allocator, flags);
 #elif defined(GL_PROVIDER_GLX)
                 if (sGLXLibrary.UseTextureFromPixmap())
-                  factory = SurfaceFactory_GLXDrawable::Create(gl, caps, forwarder, flags);
+                  factory = SurfaceFactory_GLXDrawable::Create(gl, caps, allocator, flags);
 #elif defined(MOZ_WIDGET_UIKIT)
-                factory = MakeUnique<SurfaceFactory_GLTexture>(mGLContext, caps, forwarder, mFlags);
+                factory = MakeUnique<SurfaceFactory_GLTexture>(mGLContext, caps, allocator, mFlags);
 #else
                 if (gl->GetContextType() == GLContextType::EGL) {
                     if (XRE_IsParentProcess()) {
-                        factory = SurfaceFactory_EGLImage::Create(gl, caps, forwarder, flags);
+                        factory = SurfaceFactory_EGLImage::Create(gl, caps, allocator, flags);
                     }
                 }
 #endif
                 break;
             }
             case mozilla::layers::LayersBackend::LAYERS_D3D11: {
 #ifdef XP_WIN
                 // Enable surface sharing only if ANGLE and compositing devices
                 // are both WARP or both not WARP
                 if (gl->IsANGLE() &&
                     (gl->IsWARP() == gfxWindowsPlatform::GetPlatform()->IsWARP()) &&
                     gfxWindowsPlatform::GetPlatform()->CompositorD3D11TextureSharingWorks())
                 {
-                    factory = SurfaceFactory_ANGLEShareHandle::Create(gl, caps, forwarder, flags);
+                    factory = SurfaceFactory_ANGLEShareHandle::Create(gl, caps, allocator, flags);
                 }
 
                 if (!factory && gfxPrefs::WebGLDXGLEnabled()) {
-                  factory = SurfaceFactory_D3D11Interop::Create(gl, caps, forwarder, flags);
+                  factory = SurfaceFactory_D3D11Interop::Create(gl, caps, allocator, flags);
                 }
 #endif
               break;
             }
             default:
               break;
         }
 
 #ifdef GL_PROVIDER_GLX
         if (!factory && sGLXLibrary.UseTextureFromPixmap()) {
-            factory = SurfaceFactory_GLXDrawable::Create(gl, caps, forwarder, flags);
+            factory = SurfaceFactory_GLXDrawable::Create(gl, caps, allocator, flags);
         }
 #endif
     }
 
     return factory;
 }
 
 GLScreenBuffer::GLScreenBuffer(GLContext* gl,
--- a/gfx/gl/GLScreenBuffer.h
+++ b/gfx/gl/GLScreenBuffer.h
@@ -134,16 +134,22 @@ public:
                                             const gfx::IntSize& size,
                                             const SurfaceCaps& caps);
 
     static UniquePtr<SurfaceFactory>
     CreateFactory(GLContext* gl,
                   const SurfaceCaps& caps,
                   const RefPtr<layers::CompositableForwarder>& forwarder,
                   const layers::TextureFlags& flags);
+    static UniquePtr<SurfaceFactory>
+    CreateFactory(GLContext* gl,
+                  const SurfaceCaps& caps,
+                  const RefPtr<layers::ClientIPCAllocator>& allocator,
+                  const mozilla::layers::LayersBackend backend,
+                  const layers::TextureFlags& flags);
 
 protected:
     GLContext* const mGL; // Owns us.
 public:
     const SurfaceCaps mCaps;
 protected:
     UniquePtr<SurfaceFactory> mFactory;