Bug 1037100 - Remove all ScopedDeleteArray uses from gfx/gl/. r=jgilbert
authorJeff Walden <jwalden@mit.edu>
Thu, 10 Jul 2014 17:43:01 -0700
changeset 204430 49d7327beb307b1a37848f6d6eabf960760f2976
parent 204429 f537219d14fc53998eefa5d565b2c567d2cd6551
child 204431 d3527ee9909dc3c57b076983e503a61e281007dc
push idunknown
push userunknown
push dateunknown
reviewersjgilbert
bugs1037100
milestone33.0a1
Bug 1037100 - Remove all ScopedDeleteArray uses from gfx/gl/. r=jgilbert
gfx/gl/GLContext.h
gfx/gl/ScopedGLHelpers.cpp
gfx/gl/ScopedGLHelpers.h
gfx/gl/SharedSurfaceGralloc.cpp
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -844,19 +844,19 @@ public:
     void fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) {
         raw_fBufferData(target, size, data, usage);
 
         // bug 744888
         if (WorkAroundDriverBugs() &&
             !data &&
             Vendor() == GLVendor::NVIDIA)
         {
-            ScopedDeleteArray<char> buf(new char[1]);
+            UniquePtr<char[]> buf = MakeUnique<char[]>(1);
             buf[0] = 0;
-            fBufferSubData(target, size-1, 1, buf);
+            fBufferSubData(target, size-1, 1, buf.get());
         }
     }
 
     void fBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) {
         ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(data);
         BEFORE_GL_CALL;
         mSymbols.fBufferSubData(target, offset, size, data);
         AFTER_GL_CALL;
--- a/gfx/gl/ScopedGLHelpers.cpp
+++ b/gfx/gl/ScopedGLHelpers.cpp
@@ -1,13 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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/. */
 
+#include "mozilla/UniquePtr.h"
+
 #include "GLContext.h"
 #include "ScopedGLHelpers.h"
 
 namespace mozilla {
 namespace gl {
 
 /* ScopedGLState - Wraps glEnable/glDisable. **********************************/
 
@@ -423,17 +425,17 @@ ScopedGLDrawState::ScopedGLDrawState(GLC
     , stencil     (aGL, LOCAL_GL_STENCIL_TEST,    false)
     , mGL(aGL)
     , packAlign(4)
 {
     mGL->GetUIntegerv(LOCAL_GL_UNPACK_ALIGNMENT, &packAlign);
     mGL->GetUIntegerv(LOCAL_GL_CURRENT_PROGRAM, &boundProgram);
     mGL->GetUIntegerv(LOCAL_GL_ARRAY_BUFFER_BINDING, &boundBuffer);
     mGL->GetUIntegerv(LOCAL_GL_MAX_VERTEX_ATTRIBS, &maxAttrib);
-    attrib_enabled = new GLint[maxAttrib];
+    attrib_enabled = MakeUnique<GLint[]>(maxAttrib);
 
     for (unsigned int i = 0; i < maxAttrib; i++) {
         mGL->fGetVertexAttribiv(i, LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED, &attrib_enabled[i]);
         mGL->fDisableVertexAttribArray(i);
     }
     // Only Attrib0's client side state affected
     mGL->fGetVertexAttribiv(0, LOCAL_GL_VERTEX_ATTRIB_ARRAY_SIZE, &attrib0_size);
     mGL->fGetVertexAttribiv(0, LOCAL_GL_VERTEX_ATTRIB_ARRAY_STRIDE, &attrib0_stride);
--- a/gfx/gl/ScopedGLHelpers.h
+++ b/gfx/gl/ScopedGLHelpers.h
@@ -1,16 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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 SCOPEDGLHELPERS_H_
 #define SCOPEDGLHELPERS_H_
 
+#include "mozilla/UniquePtr.h"
+
 #include "GLContext.h"
 
 namespace mozilla {
 namespace gl {
 
 //RAII via CRTP!
 template <class Derived>
 struct ScopedGLWrapper
@@ -317,17 +319,17 @@ struct ScopedGLDrawState {
     ScopedGLState dither;
     ScopedGLState polyOffsFill;
     ScopedGLState sampleAToC;
     ScopedGLState sampleCover;
     ScopedGLState scissor;
     ScopedGLState stencil;
 
     GLuint maxAttrib;
-    ScopedDeleteArray<GLint> attrib_enabled;
+    UniquePtr<GLint[]> attrib_enabled;
     GLint attrib0_size;
     GLint attrib0_stride;
     GLint attrib0_type;
     GLint attrib0_normalized;
     GLint attrib0_bufferBinding;
     void* attrib0_pointer;
 
     realGLboolean colorMask[4];
--- a/gfx/gl/SharedSurfaceGralloc.cpp
+++ b/gfx/gl/SharedSurfaceGralloc.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
 /* 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/. */
 
 #include "mozilla/Preferences.h"
+#include "mozilla/UniquePtr.h"
 
 #include "SharedSurfaceGralloc.h"
 
 #include "GLContext.h"
 #include "SharedSurface.h"
 #include "GLLibraryEGL.h"
 #include "mozilla/layers/GrallocTextureClient.h"
 #include "mozilla/layers/ShadowLayers.h"
@@ -216,17 +217,17 @@ SharedSurface_Gralloc::Fence()
         }
     }
 
     // We should be able to rely on genlock write locks/read locks.
     // But they're broken on some configs, and even a glFinish doesn't
     // work.  glReadPixels seems to, though.
     if (gfxPrefs::GrallocFenceWithReadPixels()) {
         mGL->MakeCurrent();
-        ScopedDeleteArray<char> buf(new char[4]);
+        UniquePtr<char[]> buf = MakeUnique<char>(4);
         mGL->fReadPixels(0, 0, 1, 1, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE, buf);
     }
 }
 
 bool
 SharedSurface_Gralloc::WaitSync()
 {
     if (!mSync) {