diff options
Diffstat (limited to 'libs/hwui/Caches.cpp')
-rw-r--r-- | libs/hwui/Caches.cpp | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp index 4bbe6ed..107eb08 100644 --- a/libs/hwui/Caches.cpp +++ b/libs/hwui/Caches.cpp @@ -21,6 +21,7 @@ #include "Caches.h" #include "DisplayListRenderer.h" +#include "GammaFontRenderer.h" #include "Properties.h" #include "LayerRenderer.h" #include "ShadowTessellator.h" @@ -28,10 +29,8 @@ namespace android { -#ifdef USE_OPENGL_RENDERER using namespace uirenderer; ANDROID_SINGLETON_STATIC_INSTANCE(Caches); -#endif namespace uirenderer { @@ -50,7 +49,7 @@ namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// Caches::Caches(): Singleton<Caches>(), - mExtensions(Extensions::getInstance()), mInitialized(false), mRenderState(NULL) { + mExtensions(Extensions::getInstance()), mInitialized(false), mRenderState(nullptr) { init(); initFont(); initConstraints(); @@ -88,13 +87,13 @@ bool Caches::init() { glActiveTexture(gTextureUnits[0]); mTextureUnit = 0; - mRegionMesh = NULL; + mRegionMesh = nullptr; mMeshIndices = 0; mShadowStripsIndices = 0; blend = false; lastSrcMode = GL_ZERO; lastDstMode = GL_ZERO; - currentProgram = NULL; + currentProgram = nullptr; mFunctorsCount = 0; @@ -164,7 +163,7 @@ bool Caches::initProperties() { StencilClipDebug prevDebugStencilClip = debugStencilClip; char property[PROPERTY_VALUE_MAX]; - if (property_get(PROPERTY_DEBUG_LAYERS_UPDATES, property, NULL) > 0) { + if (property_get(PROPERTY_DEBUG_LAYERS_UPDATES, property, nullptr) > 0) { INIT_LOGD(" Layers updates debug enabled: %s", property); debugLayersUpdates = !strcmp(property, "true"); } else { @@ -172,7 +171,7 @@ bool Caches::initProperties() { } debugOverdraw = false; - if (property_get(PROPERTY_DEBUG_OVERDRAW, property, NULL) > 0) { + if (property_get(PROPERTY_DEBUG_OVERDRAW, property, nullptr) > 0) { INIT_LOGD(" Overdraw debug enabled: %s", property); if (!strcmp(property, "show")) { debugOverdraw = true; @@ -184,7 +183,7 @@ bool Caches::initProperties() { } // See Properties.h for valid values - if (property_get(PROPERTY_DEBUG_STENCIL_CLIP, property, NULL) > 0) { + if (property_get(PROPERTY_DEBUG_STENCIL_CLIP, property, nullptr) > 0) { INIT_LOGD(" Stencil clip debug enabled: %s", property); if (!strcmp(property, "hide")) { debugStencilClip = kStencilHide; @@ -225,9 +224,8 @@ void Caches::terminate() { mCurrentBuffer = 0; glDeleteBuffers(1, &mMeshIndices); - delete[] mRegionMesh; mMeshIndices = 0; - mRegionMesh = NULL; + mRegionMesh.release(); glDeleteBuffers(1, &mShadowStripsIndices); mShadowStripsIndices = 0; @@ -235,7 +233,7 @@ void Caches::terminate() { fboCache.clear(); programCache.clear(); - currentProgram = NULL; + currentProgram = nullptr; patchCache.clear(); @@ -407,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; @@ -422,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; } @@ -433,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; } @@ -688,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(); } /////////////////////////////////////////////////////////////////////////////// |