summaryrefslogtreecommitdiff
path: root/libs/hwui/Caches.cpp
diff options
context:
space:
mode:
author Chris Craik <ccraik@google.com> 2014-12-22 17:16:56 -0800
committer Chris Craik <ccraik@google.com> 2014-12-23 16:53:56 -0800
commit51d6a3db97bdd5315f1a17a4b447d10a92217b98 (patch)
tree80803f8d2a5507e2d29bd58c7243a23fca343454 /libs/hwui/Caches.cpp
parente84a208317e0ed388fcdad1e6743c7849acb51b0 (diff)
Cleanup various clang warnings, use unique_ptrs in several places
Change-Id: I347904b25e51fcc7de14b1e72f1acd0f6ba26f3f
Diffstat (limited to 'libs/hwui/Caches.cpp')
-rw-r--r--libs/hwui/Caches.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index bb4ac83ea864..ebeb845e77f6 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -224,9 +224,8 @@ void Caches::terminate() {
mCurrentBuffer = 0;
glDeleteBuffers(1, &mMeshIndices);
- delete[] mRegionMesh;
mMeshIndices = 0;
- mRegionMesh = NULL;
+ mRegionMesh.release();
glDeleteBuffers(1, &mShadowStripsIndices);
mShadowStripsIndices = 0;
@@ -406,7 +405,7 @@ bool Caches::bindIndicesBufferInternal(const GLuint buffer) {
bool Caches::bindQuadIndicesBuffer() {
if (!mMeshIndices) {
- uint16_t* regionIndices = new uint16_t[gMaxNumberOfQuads * 6];
+ std::unique_ptr<uint16_t[]> regionIndices(new uint16_t[gMaxNumberOfQuads * 6]);
for (uint32_t i = 0; i < gMaxNumberOfQuads; i++) {
uint16_t quad = i * 4;
int index = i * 6;
@@ -421,9 +420,7 @@ bool Caches::bindQuadIndicesBuffer() {
glGenBuffers(1, &mMeshIndices);
bool force = bindIndicesBufferInternal(mMeshIndices);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, gMaxNumberOfQuads * 6 * sizeof(uint16_t),
- regionIndices, GL_STATIC_DRAW);
-
- delete[] regionIndices;
+ regionIndices.get(), GL_STATIC_DRAW);
return force;
}
@@ -432,14 +429,12 @@ bool Caches::bindQuadIndicesBuffer() {
bool Caches::bindShadowIndicesBuffer() {
if (!mShadowStripsIndices) {
- uint16_t* shadowIndices = new uint16_t[MAX_SHADOW_INDEX_COUNT];
- ShadowTessellator::generateShadowIndices(shadowIndices);
+ std::unique_ptr<uint16_t[]> shadowIndices(new uint16_t[MAX_SHADOW_INDEX_COUNT]);
+ ShadowTessellator::generateShadowIndices(shadowIndices.get());
glGenBuffers(1, &mShadowStripsIndices);
bool force = bindIndicesBufferInternal(mShadowStripsIndices);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, MAX_SHADOW_INDEX_COUNT * sizeof(uint16_t),
- shadowIndices, GL_STATIC_DRAW);
-
- delete[] shadowIndices;
+ shadowIndices.get(), GL_STATIC_DRAW);
return force;
}
@@ -687,10 +682,10 @@ void Caches::unregisterFunctors(uint32_t functorCount) {
TextureVertex* Caches::getRegionMesh() {
// Create the mesh, 2 triangles and 4 vertices per rectangle in the region
if (!mRegionMesh) {
- mRegionMesh = new TextureVertex[gMaxNumberOfQuads * 4];
+ mRegionMesh.reset(new TextureVertex[gMaxNumberOfQuads * 4]);
}
- return mRegionMesh;
+ return mRegionMesh.get();
}
///////////////////////////////////////////////////////////////////////////////