Bug 1049957 - Fix compilation errors. - r=kamidphish
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 15 Aug 2014 17:38:08 -0700
changeset 199932 476eb01b1280c6d978911a2892d03f63baff6a71
parent 199931 57a7fffebc80722f508398b8fda26c759f255ba2
child 199933 6007c13f601030d3963cda590ab850a218776ea9
push id9784
push userryanvm@gmail.com
push dateSat, 16 Aug 2014 21:45:40 +0000
treeherderb2g-inbound@94ba78a42305 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskamidphish
bugs1049957
milestone34.0a1
Bug 1049957 - Fix compilation errors. - r=kamidphish
gfx/gl/GLScreenBuffer.cpp
gfx/gl/GLScreenBuffer.h
gfx/gl/SharedSurface.h
gfx/gl/SharedSurfaceANGLE.cpp
gfx/gl/SharedSurfaceEGL.cpp
gfx/gl/SharedSurfaceGL.cpp
gfx/gl/SharedSurfaceGralloc.cpp
gfx/gl/SharedSurfaceGralloc.h
gfx/gl/SharedSurfaceIO.cpp
gfx/gl/SharedSurfaceIO.h
gfx/gl/SurfaceStream.h
gfx/layers/client/ClientCanvasLayer.cpp
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -15,31 +15,33 @@
 #include "SharedSurfaceGralloc.h"
 #include "nsXULAppAPI.h"
 #endif
 #ifdef XP_MACOSX
 #include "SharedSurfaceIO.h"
 #endif
 #include "ScopedGLHelpers.h"
 #include "gfx2DGlue.h"
+#include "../layers/ipc/ShadowLayers.h"
 
 namespace mozilla {
 namespace gl {
 
 using gfx::SurfaceFormat;
 
 UniquePtr<GLScreenBuffer>
 GLScreenBuffer::Create(GLContext* gl,
                        const gfx::IntSize& size,
                        const SurfaceCaps& caps)
 {
+    UniquePtr<GLScreenBuffer> ret;
     if (caps.antialias &&
         !gl->IsSupported(GLFeature::framebuffer_multisample))
     {
-        return nullptr;
+        return Move(ret);
     }
 
     UniquePtr<SurfaceFactory> factory;
 
 #ifdef MOZ_WIDGET_GONK
     /* On B2G, we want a Gralloc factory, and we want one right at the start */
     if (!factory &&
         caps.surfaceAllocator &&
@@ -59,19 +61,17 @@ GLScreenBuffer::Create(GLContext* gl,
         factory = MakeUnique<SurfaceFactory_Basic>(gl, caps);
     }
 
     auto streamType = SurfaceStream::ChooseGLStreamType(SurfaceStream::MainThread,
                                                         caps.preserve);
     RefPtr<SurfaceStream> stream;
     stream = SurfaceStream::CreateForType(streamType, gl, nullptr);
 
-    UniquePtr<GLScreenBuffer> ret( new GLScreenBuffer(gl, caps,
-                                                      Move(factory),
-                                                      stream) );
+    ret.reset( new GLScreenBuffer(gl, caps, Move(factory), stream) );
     return Move(ret);
 }
 
 GLScreenBuffer::~GLScreenBuffer()
 {
     mDraw = nullptr;
     mRead = nullptr;
 
@@ -646,18 +646,19 @@ ReadBuffer::Create(GLContext* gl,
 
     GLuint fb = 0;
     gl->fGenFramebuffers(1, &fb);
     gl->AttachBuffersToFB(colorTex, colorRB, depthRB, stencilRB, fb, target);
     gl->mFBOMapping[fb] = surf;
 
     UniquePtr<ReadBuffer> ret( new ReadBuffer(gl, fb, depthRB,
                                               stencilRB, surf) );
-    if (!gl->IsFramebufferComplete(fb))
-        return nullptr;
+    if (!gl->IsFramebufferComplete(fb)) {
+      ret = nullptr;
+    }
 
     return Move(ret);
 }
 
 ReadBuffer::~ReadBuffer()
 {
     mGL->MakeCurrent();
 
--- a/gfx/gl/GLScreenBuffer.h
+++ b/gfx/gl/GLScreenBuffer.h
@@ -16,16 +16,17 @@
 #define SCREEN_BUFFER_H_
 
 #include "SurfaceTypes.h"
 #include "SurfaceStream.h"
 #include "GLContextTypes.h"
 #include "GLDefs.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/Point.h"
+#include "mozilla/UniquePtr.h"
 
 namespace mozilla {
 namespace gl {
 
 class GLContext;
 class SharedSurface;
 class SurfaceStream;
 
--- a/gfx/gl/SharedSurface.h
+++ b/gfx/gl/SharedSurface.h
@@ -17,16 +17,17 @@
 
 #include <queue>
 #include <stdint.h>
 
 #include "GLContextTypes.h"
 #include "GLDefs.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/gfx/Point.h"
+#include "mozilla/UniquePtr.h"
 #include "mozilla/WeakPtr.h"
 #include "SurfaceTypes.h"
 
 namespace mozilla {
 namespace gl {
 
 class GLContext;
 class SurfaceFactory;
--- a/gfx/gl/SharedSurfaceANGLE.cpp
+++ b/gfx/gl/SharedSurfaceANGLE.cpp
@@ -187,36 +187,38 @@ SharedSurface_ANGLEShareHandle::Create(G
                                              LOCAL_EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE,
                                              &shareHandle);
     if (!ok) {
         egl->fDestroySurface(egl->Display(), pbuffer);
         return nullptr;
     }
 
     typedef SharedSurface_ANGLEShareHandle ptrT;
-    return UniquePtr<ptrT>( new ptrT(gl, egl, size, hasAlpha, context,
-                                     pbuffer, shareHandle) );
+    UniquePtr<ptrT> ret( new ptrT(gl, egl, size, hasAlpha, context,
+                                  pbuffer, shareHandle) );
+    return Move(ret);
 }
 
 /*static*/ UniquePtr<SurfaceFactory_ANGLEShareHandle>
 SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl,
                                         const SurfaceCaps& caps)
 {
     GLLibraryEGL* egl = &sEGLLibrary;
     if (!egl)
         return nullptr;
 
-    if (!egl->IsExtensionSupported(
-            GLLibraryEGL::ANGLE_surface_d3d_texture_2d_share_handle))
+    auto ext = GLLibraryEGL::ANGLE_surface_d3d_texture_2d_share_handle;
+    if (!egl->IsExtensionSupported(ext))
     {
         return nullptr;
     }
 
     typedef SurfaceFactory_ANGLEShareHandle ptrT;
-    return UniquePtr<ptrT>( new ptrT(gl, egl, caps) );
+    UniquePtr<ptrT> ret( new ptrT(gl, egl, caps) );
+    return Move(ret);
 }
 
 SurfaceFactory_ANGLEShareHandle::SurfaceFactory_ANGLEShareHandle(GLContext* gl,
                                                                  GLLibraryEGL* egl,
                                                                  const SurfaceCaps& caps)
     : SurfaceFactory(gl, SharedSurfaceType::EGLSurfaceANGLE, caps)
     , mProdGL(gl)
     , mEGL(egl)
--- a/gfx/gl/SharedSurfaceEGL.cpp
+++ b/gfx/gl/SharedSurfaceEGL.cpp
@@ -22,38 +22,40 @@ SharedSurface_EGLImage::Create(GLContext
                                const gfx::IntSize& size,
                                bool hasAlpha,
                                EGLContext context)
 {
     GLLibraryEGL* egl = &sEGLLibrary;
     MOZ_ASSERT(egl);
     MOZ_ASSERT(context);
 
+    UniquePtr<SharedSurface_EGLImage> ret;
+
     if (!HasExtensions(egl, prodGL)) {
-        return nullptr;
+        return Move(ret);
     }
 
     MOZ_ALWAYS_TRUE(prodGL->MakeCurrent());
     GLuint prodTex = CreateTextureForOffscreen(prodGL, formats, size);
     if (!prodTex) {
-        return nullptr;
+        return Move(ret);
     }
 
     EGLClientBuffer buffer = reinterpret_cast<EGLClientBuffer>(prodTex);
     EGLImage image = egl->fCreateImage(egl->Display(), context,
                                        LOCAL_EGL_GL_TEXTURE_2D, buffer,
                                        nullptr);
     if (!image) {
         prodGL->fDeleteTextures(1, &prodTex);
-        return nullptr;
+        return Move(ret);
     }
 
-    typedef SharedSurface_EGLImage ptrT;
-    return UniquePtr<ptrT>( new ptrT(prodGL, egl, size, hasAlpha,
-                                     formats, prodTex, image) );
+    ret.reset( new SharedSurface_EGLImage(prodGL, egl, size, hasAlpha,
+                                          formats, prodTex, image) );
+    return Move(ret);
 }
 
 bool
 SharedSurface_EGLImage::HasExtensions(GLLibraryEGL* egl, GLContext* gl)
 {
     return egl->HasKHRImageBase() &&
            egl->IsExtensionSupported(GLLibraryEGL::KHR_gl_texture_2D_image) &&
            gl->IsExtensionSupported(GLContext::OES_EGL_image_external);
@@ -216,19 +218,21 @@ SharedSurface_EGLImage::AcquireConsumerT
 
 
 /*static*/ UniquePtr<SurfaceFactory_EGLImage>
 SurfaceFactory_EGLImage::Create(GLContext* prodGL,
                                 const SurfaceCaps& caps)
 {
     EGLContext context = GLContextEGL::Cast(prodGL)->GetEGLContext();
 
+    typedef SurfaceFactory_EGLImage ptrT;
+    UniquePtr<ptrT> ret;
+
     GLLibraryEGL* egl = &sEGLLibrary;
-    if (!SharedSurface_EGLImage::HasExtensions(egl, prodGL)) {
-        return nullptr;
+    if (SharedSurface_EGLImage::HasExtensions(egl, prodGL)) {
+        ret.reset( new ptrT(prodGL, context, caps) );
     }
 
-    typedef SurfaceFactory_EGLImage ptrT;
-    return UniquePtr<ptrT>( new ptrT(prodGL, context, caps) );
+    return Move(ret);
 }
 
 } /* namespace gfx */
 } /* namespace mozilla */
--- a/gfx/gl/SharedSurfaceGL.cpp
+++ b/gfx/gl/SharedSurfaceGL.cpp
@@ -42,17 +42,18 @@ SharedSurface_Basic::Create(GLContext* g
     case LOCAL_GL_RGBA8:
         format = SurfaceFormat::B8G8R8A8;
         break;
     default:
         MOZ_CRASH("Unhandled Tex format.");
     }
 
     typedef SharedSurface_Basic ptrT;
-    return UniquePtr<ptrT>( new ptrT(gl, size, hasAlpha, format, tex) );
+    UniquePtr<ptrT> ret( new ptrT(gl, size, hasAlpha, format, tex) );
+    return Move(ret);
 }
 
 SharedSurface_Basic::SharedSurface_Basic(GLContext* gl,
                                          const IntSize& size,
                                          bool hasAlpha,
                                          SurfaceFormat format,
                                          GLuint tex)
     : SharedSurface(SharedSurfaceType::Basic,
@@ -123,18 +124,19 @@ SharedSurface_GLTexture::Create(GLContex
     bool ownsTex = false;
 
     if (!tex) {
       tex = CreateTextureForOffscreen(prodGL, formats, size);
       ownsTex = true;
     }
 
     typedef SharedSurface_GLTexture ptrT;
-    return UniquePtr<ptrT>( new ptrT(prodGL, consGL, size, hasAlpha,
-                                     tex, ownsTex) );
+    UniquePtr<ptrT> ret( new ptrT(prodGL, consGL, size, hasAlpha, tex,
+                                  ownsTex) );
+    return Move(ret);
 }
 
 SharedSurface_GLTexture::~SharedSurface_GLTexture()
 {
     if (!mGL->MakeCurrent())
         return;
 
     if (mOwnsTex) {
--- a/gfx/gl/SharedSurfaceGralloc.cpp
+++ b/gfx/gl/SharedSurfaceGralloc.cpp
@@ -54,75 +54,78 @@ SharedSurface_Gralloc::Create(GLContext*
                               const GLFormats& formats,
                               const gfx::IntSize& size,
                               bool hasAlpha,
                               ISurfaceAllocator* allocator)
 {
     GLLibraryEGL* egl = &sEGLLibrary;
     MOZ_ASSERT(egl);
 
+    UniquePtr<SharedSurface_Gralloc> ret;
+
     DEBUG_PRINT("SharedSurface_Gralloc::Create -------\n");
 
     if (!HasExtensions(egl, prodGL))
-        return nullptr;
+        return Move(ret);
 
     gfxContentType type = hasAlpha ? gfxContentType::COLOR_ALPHA
                                    : gfxContentType::COLOR;
 
     gfxImageFormat format
       = gfxPlatform::GetPlatform()->OptimalFormatForContent(type);
 
     RefPtr<GrallocTextureClientOGL> grallocTC =
       new GrallocTextureClientOGL(
           allocator,
           gfx::ImageFormatToSurfaceFormat(format),
           gfx::BackendType::NONE, // we don't need to use it with a DrawTarget
           layers::TextureFlags::DEFAULT);
 
     if (!grallocTC->AllocateForGLRendering(size)) {
-      return nullptr;
+      return Move(ret);
     }
 
     sp<GraphicBuffer> buffer = grallocTC->GetGraphicBuffer();
 
     EGLDisplay display = egl->Display();
     EGLClientBuffer clientBuffer = buffer->getNativeBuffer();
     EGLint attrs[] = {
         LOCAL_EGL_NONE, LOCAL_EGL_NONE
     };
     EGLImage image = egl->fCreateImage(display,
                                        EGL_NO_CONTEXT,
                                        LOCAL_EGL_NATIVE_BUFFER_ANDROID,
                                        clientBuffer, attrs);
     if (!image) {
-        return nullptr;
+        return Move(ret);
     }
 
     prodGL->MakeCurrent();
     GLuint prodTex = 0;
     prodGL->fGenTextures(1, &prodTex);
     ScopedBindTexture autoTex(prodGL, prodTex);
 
     prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
     prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
     prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
     prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
 
     prodGL->fEGLImageTargetTexture2D(LOCAL_GL_TEXTURE_2D, image);
 
     egl->fDestroyImage(display, image);
 
+    ret.reset( new SharedSurface_Gralloc(prodGL, size, hasAlpha, egl,
+                                         allocator, grallocTC,
+                                         prodTex) );
 
-    typedef SharedSurface_Gralloc ptrT;
-    UniquePtr<ptrT> surf( new ptrT(prodGL, size, hasAlpha, egl,
-                                   allocator, grallocTC, prodTex) );
+    DEBUG_PRINT("SharedSurface_Gralloc::Create: success -- surface %p,"
+                " GraphicBuffer %p.\n",
+                ret.get(), buffer.get());
 
-    DEBUG_PRINT("SharedSurface_Gralloc::Create: success -- surface %p, GraphicBuffer %p.\n", surf, buffer.get());
-
-    return Move(surf);
+    return Move(ret);
 }
 
 
 SharedSurface_Gralloc::SharedSurface_Gralloc(GLContext* prodGL,
                                              const gfx::IntSize& size,
                                              bool hasAlpha,
                                              GLLibraryEGL* egl,
                                              layers::ISurfaceAllocator* allocator,
--- a/gfx/gl/SharedSurfaceGralloc.h
+++ b/gfx/gl/SharedSurfaceGralloc.h
@@ -81,19 +81,22 @@ protected:
 
 public:
     SurfaceFactory_Gralloc(GLContext* prodGL,
                            const SurfaceCaps& caps,
                            layers::ISurfaceAllocator* allocator = nullptr);
 
     virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
         bool hasAlpha = mReadCaps.alpha;
-        if (!mAllocator) {
-            return nullptr;
+
+        UniquePtr<SharedSurface> ret;
+        if (mAllocator) {
+            ret = SharedSurface_Gralloc::Create(mGL, mFormats, size,
+                                                hasAlpha, mAllocator);
         }
-        return SharedSurface_Gralloc::Create(mGL, mFormats, size, hasAlpha, mAllocator);
+        return Move(ret);
     }
 };
 
 } /* namespace gl */
 } /* namespace mozilla */
 
 #endif /* SHARED_SURFACE_GRALLOC_H_ */
--- a/gfx/gl/SharedSurfaceIO.cpp
+++ b/gfx/gl/SharedSurfaceIO.cpp
@@ -13,23 +13,24 @@
 namespace mozilla {
 namespace gl {
 
 /*static*/ UniquePtr<SharedSurface_IOSurface>
 SharedSurface_IOSurface::Create(const RefPtr<MacIOSurface>& ioSurf,
                                 GLContext* gl,
                                 bool hasAlpha)
 {
-    MOZ_ASSERT(surface);
+    MOZ_ASSERT(ioSurf);
     MOZ_ASSERT(gl);
 
-    gfx::IntSize size(surface->GetWidth(), surface->GetHeight());
+    gfx::IntSize size(ioSurf->GetWidth(), ioSurf->GetHeight());
 
     typedef SharedSurface_IOSurface ptrT;
-    return UniquePtr<ptrT>( new ptrT(ioSurf, gl, size, hasAlpha) );
+    UniquePtr<ptrT> ret( new ptrT(ioSurf, gl, size, hasAlpha) );
+    return Move(ret);
 }
 
 void
 SharedSurface_IOSurface::Fence()
 {
     mGL->MakeCurrent();
     mGL->fFlush();
 }
@@ -102,17 +103,17 @@ SharedSurface_IOSurface::SharedSurface_I
                   hasAlpha)
   , mIOSurf(ioSurf)
   , mCurConsGL(nullptr)
   , mConsTex(0)
 {
     gl->MakeCurrent();
     mProdTex = 0;
     gl->fGenTextures(1, &mProdTex);
-    BackTextureWithIOSurf(gl, mProdTex, surface);
+    BackTextureWithIOSurf(gl, mProdTex, mIOSurf);
 }
 
 GLuint
 SharedSurface_IOSurface::ConsTexture(GLContext* consGL)
 {
     if (!mCurConsGL) {
         mCurConsGL = consGL;
     }
@@ -144,34 +145,35 @@ SharedSurface_IOSurface::~SharedSurface_
 /*static*/ UniquePtr<SurfaceFactory_IOSurface>
 SurfaceFactory_IOSurface::Create(GLContext* gl,
                                  const SurfaceCaps& caps)
 {
     gfx::IntSize maxDims(MacIOSurface::GetMaxWidth(),
                          MacIOSurface::GetMaxHeight());
 
     typedef SurfaceFactory_IOSurface ptrT;
-    return UniquePtr<ptrT>( new ptrT(gl, caps, maxDims) );
+    UniquePtr<ptrT> ret( new ptrT(gl, caps, maxDims) );
+    return Move(ret);
 }
 
 UniquePtr<SharedSurface>
 SurfaceFactory_IOSurface::CreateShared(const gfx::IntSize& size)
 {
     if (size.width > mMaxDims.width ||
         size.height > mMaxDims.height)
     {
         return nullptr;
     }
 
     bool hasAlpha = mReadCaps.alpha;
     RefPtr<MacIOSurface> ioSurf;
     ioSurf = MacIOSurface::CreateIOSurface(size.width, size.height, 1.0,
                                            hasAlpha);
 
-    if (!surf) {
+    if (!ioSurf) {
         NS_WARNING("Failed to create MacIOSurface.");
         return nullptr;
     }
 
     return SharedSurface_IOSurface::Create(ioSurf, mGL, hasAlpha);
 }
 
 }
--- a/gfx/gl/SharedSurfaceIO.h
+++ b/gfx/gl/SharedSurfaceIO.h
@@ -12,17 +12,17 @@
 class MacIOSurface;
 
 namespace mozilla {
 namespace gl {
 
 class SharedSurface_IOSurface : public SharedSurface
 {
 public:
-    static UniquePtr<SharedSurface_IOSurface> Create(MacIOSurface* surface,
+    static UniquePtr<SharedSurface_IOSurface> Create(const RefPtr<MacIOSurface>& ioSurf,
                                                      GLContext* gl,
                                                      bool hasAlpha);
 
     ~SharedSurface_IOSurface();
 
     virtual void LockProdImpl() MOZ_OVERRIDE { }
     virtual void UnlockProdImpl() MOZ_OVERRIDE { }
 
@@ -48,22 +48,23 @@ public:
 
     GLuint ConsTexture(GLContext* consGL);
 
     GLenum ConsTextureTarget() const {
         return LOCAL_GL_TEXTURE_RECTANGLE_ARB;
     }
 
     MacIOSurface* GetIOSurface() const {
-        return mSurface;
+        return mIOSurf;
     }
 
 private:
-    SharedSurface_IOSurface(MacIOSurface* ioSurf, GLContext* gl,
-                            const gfx::IntSize& size, bool hasAlpha);
+    SharedSurface_IOSurface(const RefPtr<MacIOSurface>& ioSurf,
+                            GLContext* gl, const gfx::IntSize& size,
+                            bool hasAlpha);
 
     RefPtr<MacIOSurface> mIOSurf;
     GLuint mProdTex;
     const GLContext* mCurConsGL;
     GLuint mConsTex;
 };
 
 class SurfaceFactory_IOSurface : public SurfaceFactory
--- a/gfx/gl/SurfaceStream.h
+++ b/gfx/gl/SurfaceStream.h
@@ -7,16 +7,17 @@
 #define SURFACESTREAM_H_
 
 #include <stack>
 #include <set>
 #include "mozilla/Monitor.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/gfx/Point.h"
 #include "mozilla/GenericRefCounted.h"
+#include "mozilla/UniquePtr.h"
 #include "SurfaceTypes.h"
 #include "SharedSurface.h"
 
 namespace mozilla {
 
 namespace gl {
 class GLContext;
 class SharedSurface;
--- a/gfx/layers/client/ClientCanvasLayer.cpp
+++ b/gfx/layers/client/ClientCanvasLayer.cpp
@@ -68,17 +68,17 @@ ClientCanvasLayer::Initialize(const Data
     } else {
       caps = screen->mCaps;
     }
     MOZ_ASSERT(caps.alpha == aData.mHasAlpha);
 
     SurfaceStreamType streamType =
         SurfaceStream::ChooseGLStreamType(SurfaceStream::OffMainThread,
                                           screen->PreserveBuffer());
-    UniquePtr<SurfaceFactory> factory = nullptr;
+    UniquePtr<SurfaceFactory> factory;
 
     if (!gfxPrefs::WebGLForceLayersReadback()) {
       switch (ClientManager()->AsShadowForwarder()->GetCompositorBackendType()) {
         case mozilla::layers::LayersBackend::LAYERS_OPENGL: {
           if (mGLContext->GetContextType() == GLContextType::EGL) {
 #ifdef MOZ_WIDGET_GONK
             factory = MakeUnique<SurfaceFactory_Gralloc>(mGLContext,
                                                          caps,