Bug 953296 - Convert ScopedDeletePtr to UniquePtr in various bits of canvas/graphics/GL code. r=jgilbert

--HG--
extra : rebase_source : cd1e332837ff49199d62805f554bf1123eea334f
This commit is contained in:
Jeff Walden 2014-01-06 09:49:03 -06:00
parent 03e36c69cd
commit 86ea8f6ecd
6 changed files with 30 additions and 28 deletions

View File

@ -7,6 +7,11 @@
#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"
@ -26,10 +31,6 @@
#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
@ -1207,16 +1208,16 @@ protected:
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];

View File

@ -627,8 +627,8 @@ 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]) {
@ -644,15 +644,14 @@ WebGLContext::BindFakeBlackTexturesHelper(
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);

View File

@ -2097,30 +2097,30 @@ 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

View File

@ -25,6 +25,8 @@
#undef GetClassName
#endif
#include "mozilla/UniquePtr.h"
#include "GLDefs.h"
#include "GLLibraryLoader.h"
#include "gfx3DMatrix.h"
@ -40,7 +42,6 @@
#include "GLContextSymbols.h"
#include "base/platform_thread.h" // for PlatformThreadId
#include "mozilla/GenericRefCounted.h"
#include "mozilla/Scoped.h"
#include "gfx2DGlue.h"
class nsIntRegion;
@ -2743,9 +2744,9 @@ protected:
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();

View File

@ -691,7 +691,7 @@ gfxASurface::SetOpaqueRect(const gfxRect& aRect)
} else if (!!mOpaqueRect) {
*mOpaqueRect = aRect;
} else {
mOpaqueRect = new gfxRect(aRect);
mOpaqueRect = MakeUnique<gfxRect>(aRect);
}
}

View File

@ -7,8 +7,9 @@
#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"
@ -209,7 +210,7 @@ protected:
virtual ~gfxASurface();
cairo_surface_t *mSurface;
mozilla::ScopedDeletePtr<gfxRect> mOpaqueRect;
mozilla::UniquePtr<gfxRect> mOpaqueRect;
private:
static void SurfaceDestroyFunc(void *data);