Bug 953296 - Convert ScopedDeletePtr to UniquePtr in various bits of canvas/graphics/GL code. r=jgilbert
authorJeff Walden <jwalden@mit.edu>
Mon, 06 Jan 2014 09:49:03 -0600
changeset 214878 9ec39bb8c834cc2ed3cef0972aa81e1894d9f2b0
parent 214877 ba853c3d60404339b34dfb3d4671fd61c2be5dbe
child 214879 b140663e36819c718f42671f796e6fa4d5cc89ab
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs953296
milestone33.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 953296 - Convert ScopedDeletePtr to UniquePtr in various bits of canvas/graphics/GL code. r=jgilbert
content/canvas/src/WebGLContext.h
content/canvas/src/WebGLContextDraw.cpp
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxASurface.h
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -2,16 +2,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef WEBGLCONTEXT_H_
 #define WEBGLCONTEXT_H_
 
 #include "mozilla/Attributes.h"
+#include "mozilla/CheckedInt.h"
+#include "mozilla/EnumeratedArray.h"
+#include "mozilla/LinkedList.h"
+#include "mozilla/UniquePtr.h"
+
 #include "GLDefs.h"
 #include "WebGLActiveInfo.h"
 #include "WebGLObjectModel.h"
 #include "WebGLRenderbuffer.h"
 #include <stdarg.h>
 
 #include "nsTArray.h"
 #include "nsCycleCollectionNoteChild.h"
@@ -21,20 +26,16 @@
 #include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsWrapperCache.h"
 #include "nsIObserver.h"
 #include "nsIDOMEventListener.h"
 #include "nsLayoutUtils.h"
 
 #include "GLContextProvider.h"
 
-#include "mozilla/EnumeratedArray.h"
-#include "mozilla/LinkedList.h"
-#include "mozilla/CheckedInt.h"
-#include "mozilla/Scoped.h"
 #include "mozilla/gfx/2D.h"
 
 #ifdef XP_MACOSX
 #include "ForceDiscreteGPUHelperCGL.h"
 #endif
 
 #include "mozilla/dom/TypedArray.h"
 #include "mozilla/ErrorResult.h"
@@ -1202,26 +1203,26 @@ protected:
         GLuint mGLName;
 
     public:
         FakeBlackTexture(gl::GLContext* gl, GLenum target, GLenum format);
         ~FakeBlackTexture();
         GLuint GLName() const { return mGLName; }
     };
 
-    ScopedDeletePtr<FakeBlackTexture> mBlackOpaqueTexture2D,
-                                      mBlackOpaqueTextureCubeMap,
-                                      mBlackTransparentTexture2D,
-                                      mBlackTransparentTextureCubeMap;
+    UniquePtr<FakeBlackTexture> mBlackOpaqueTexture2D,
+                                mBlackOpaqueTextureCubeMap,
+                                mBlackTransparentTexture2D,
+                                mBlackTransparentTextureCubeMap;
 
     void BindFakeBlackTexturesHelper(
         GLenum target,
         const nsTArray<WebGLRefPtr<WebGLTexture> >& boundTexturesArray,
-        ScopedDeletePtr<FakeBlackTexture> & opaqueTextureScopedPtr,
-        ScopedDeletePtr<FakeBlackTexture> & transparentTextureScopedPtr);
+        UniquePtr<FakeBlackTexture> & opaqueTextureScopedPtr,
+        UniquePtr<FakeBlackTexture> & transparentTextureScopedPtr);
 
     GLfloat mVertexAttrib0Vector[4];
     GLfloat mFakeVertexAttrib0BufferObjectVector[4];
     size_t mFakeVertexAttrib0BufferObjectSize;
     GLuint mFakeVertexAttrib0BufferObject;
     WebGLVertexAttrib0Status mFakeVertexAttrib0BufferStatus;
 
     GLint mStencilRefFront, mStencilRefBack;
--- a/content/canvas/src/WebGLContextDraw.cpp
+++ b/content/canvas/src/WebGLContextDraw.cpp
@@ -622,42 +622,41 @@ WebGLContext::ResolvedFakeBlackStatus()
     mFakeBlackStatus = WebGLContextFakeBlackStatus::NotNeeded;
     return mFakeBlackStatus;
 }
 
 void
 WebGLContext::BindFakeBlackTexturesHelper(
     GLenum target,
     const nsTArray<WebGLRefPtr<WebGLTexture> > & boundTexturesArray,
-    ScopedDeletePtr<FakeBlackTexture> & opaqueTextureScopedPtr,
-    ScopedDeletePtr<FakeBlackTexture> & transparentTextureScopedPtr)
+    UniquePtr<FakeBlackTexture> & opaqueTextureScopedPtr,
+    UniquePtr<FakeBlackTexture> & transparentTextureScopedPtr)
 {
     for (int32_t i = 0; i < mGLMaxTextureUnits; ++i) {
         if (!boundTexturesArray[i]) {
             continue;
         }
 
         WebGLTextureFakeBlackStatus s = boundTexturesArray[i]->ResolvedFakeBlackStatus();
         MOZ_ASSERT(s != WebGLTextureFakeBlackStatus::Unknown);
 
         if (MOZ_LIKELY(s == WebGLTextureFakeBlackStatus::NotNeeded)) {
             continue;
         }
 
         bool alpha = s == WebGLTextureFakeBlackStatus::UninitializedImageData &&
                      FormatHasAlpha(boundTexturesArray[i]->ImageInfoBase().WebGLFormat());
-        ScopedDeletePtr<FakeBlackTexture>&
+        UniquePtr<FakeBlackTexture>&
             blackTexturePtr = alpha
                               ? transparentTextureScopedPtr
                               : opaqueTextureScopedPtr;
 
         if (!blackTexturePtr) {
             GLenum format = alpha ? LOCAL_GL_RGBA : LOCAL_GL_RGB;
-            blackTexturePtr
-                = new FakeBlackTexture(gl, target, format);
+            blackTexturePtr = MakeUnique<FakeBlackTexture>(gl, target, format);
         }
 
         gl->fActiveTexture(LOCAL_GL_TEXTURE0 + i);
         gl->fBindTexture(target,
                          blackTexturePtr->GLName());
     }
 }
 
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -2092,40 +2092,40 @@ GLContext::IsOwningThreadCurrent()
 {
   return PlatformThread::CurrentId() == mOwningThreadId;
 }
 
 GLBlitHelper*
 GLContext::BlitHelper()
 {
     if (!mBlitHelper) {
-        mBlitHelper = new GLBlitHelper(this);
+        mBlitHelper = MakeUnique<GLBlitHelper>(this);
     }
 
-    return mBlitHelper;
+    return mBlitHelper.get();
 }
 
 GLBlitTextureImageHelper*
 GLContext::BlitTextureImageHelper()
 {
     if (!mBlitTextureImageHelper) {
-        mBlitTextureImageHelper = new GLBlitTextureImageHelper(this);
+        mBlitTextureImageHelper = MakeUnique<GLBlitTextureImageHelper>(this);
     }
 
-    return mBlitTextureImageHelper;
+    return mBlitTextureImageHelper.get();
 }
 
 GLReadTexImageHelper*
 GLContext::ReadTexImageHelper()
 {
     if (!mReadTexImageHelper) {
-        mReadTexImageHelper = new GLReadTexImageHelper(this);
+        mReadTexImageHelper = MakeUnique<GLReadTexImageHelper>(this);
     }
 
-    return mReadTexImageHelper;
+    return mReadTexImageHelper.get();
 }
 
 bool
 DoesStringMatch(const char* aString, const char *aWantedString)
 {
     if (!aString || !aWantedString)
         return false;
 
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -20,32 +20,33 @@
 #ifdef WIN32
 #include <windows.h>
 #endif
 
 #ifdef GetClassName
 #undef GetClassName
 #endif
 
+#include "mozilla/UniquePtr.h"
+
 #include "GLDefs.h"
 #include "GLLibraryLoader.h"
 #include "gfx3DMatrix.h"
 #include "nsISupportsImpl.h"
 #include "plstr.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsAutoPtr.h"
 #include "GLContextTypes.h"
 #include "GLTextureImage.h"
 #include "SurfaceTypes.h"
 #include "GLScreenBuffer.h"
 #include "GLContextSymbols.h"
 #include "base/platform_thread.h"       // for PlatformThreadId
 #include "mozilla/GenericRefCounted.h"
-#include "mozilla/Scoped.h"
 #include "gfx2DGlue.h"
 
 class nsIntRegion;
 class nsIRunnable;
 class nsIThread;
 
 namespace android {
     class GraphicBuffer;
@@ -2738,19 +2739,19 @@ protected:
     // GLDebugMode will check that we don't send call
     // to a GLContext that isn't current on the current
     // thread.
     // Store the current context when binding to thread local
     // storage to support DebugMode on an arbitrary thread.
     static unsigned sCurrentGLContextTLS;
 #endif
 
-    ScopedDeletePtr<GLBlitHelper> mBlitHelper;
-    ScopedDeletePtr<GLBlitTextureImageHelper> mBlitTextureImageHelper;
-    ScopedDeletePtr<GLReadTexImageHelper> mReadTexImageHelper;
+    UniquePtr<GLBlitHelper> mBlitHelper;
+    UniquePtr<GLBlitTextureImageHelper> mBlitTextureImageHelper;
+    UniquePtr<GLReadTexImageHelper> mReadTexImageHelper;
 
 public:
     GLBlitHelper* BlitHelper();
     GLBlitTextureImageHelper* BlitTextureImageHelper();
     GLReadTexImageHelper* ReadTexImageHelper();
 
     // Assumes shares are created by all sharing with the same global context.
     bool SharesWith(const GLContext* other) const {
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -686,17 +686,17 @@ gfxASurface::BytesPerPixel(gfxImageForma
 void
 gfxASurface::SetOpaqueRect(const gfxRect& aRect)
 {
     if (aRect.IsEmpty()) {
         mOpaqueRect = nullptr;
     } else if (!!mOpaqueRect) {
         *mOpaqueRect = aRect;
     } else {
-        mOpaqueRect = new gfxRect(aRect);
+        mOpaqueRect = MakeUnique<gfxRect>(aRect);
     }
 }
 
 /* static */const gfxRect&
 gfxASurface::GetEmptyOpaqueRect()
 {
   static const gfxRect empty(0, 0, 0, 0);
   return empty;
--- a/gfx/thebes/gfxASurface.h
+++ b/gfx/thebes/gfxASurface.h
@@ -2,18 +2,19 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_ASURFACE_H
 #define GFX_ASURFACE_H
 
 #include "mozilla/MemoryReporting.h"
+#include "mozilla/UniquePtr.h"
+
 #include "gfxTypes.h"
-#include "mozilla/Scoped.h"
 #include "nscore.h"
 #include "nsSize.h"
 
 #ifdef MOZILLA_INTERNAL_API
 #include "nsStringFwd.h"
 #else
 #include "nsStringAPI.h"
 #endif
@@ -204,17 +205,17 @@ protected:
 
     // out-of-line helper to allow GetOpaqueRect() to be inlined
     // without including gfxRect.h here
     static const gfxRect& GetEmptyOpaqueRect();
 
     virtual ~gfxASurface();
 
     cairo_surface_t *mSurface;
-    mozilla::ScopedDeletePtr<gfxRect> mOpaqueRect;
+    mozilla::UniquePtr<gfxRect> mOpaqueRect;
 
 private:
     static void SurfaceDestroyFunc(void *data);
 
     int32_t mFloatingRefs;
     int32_t mBytesRecorded;
 
 protected: