Loading libs/hwui/Caches.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -386,8 +386,8 @@ bool Caches::bindIndicesBuffer(const GLuint buffer) { bool Caches::bindIndicesBuffer() { if (!mMeshIndices) { uint16_t* regionIndices = new uint16_t[REGION_MESH_QUAD_COUNT * 6]; for (int i = 0; i < REGION_MESH_QUAD_COUNT; i++) { 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; regionIndices[index ] = quad; // top-left Loading @@ -400,7 +400,7 @@ bool Caches::bindIndicesBuffer() { glGenBuffers(1, &mMeshIndices); bool force = bindIndicesBuffer(mMeshIndices); glBufferData(GL_ELEMENT_ARRAY_BUFFER, REGION_MESH_QUAD_COUNT * 6 * sizeof(uint16_t), glBufferData(GL_ELEMENT_ARRAY_BUFFER, gMaxNumberOfQuads * 6 * sizeof(uint16_t), regionIndices, GL_STATIC_DRAW); delete[] regionIndices; Loading Loading @@ -638,7 +638,7 @@ 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[REGION_MESH_QUAD_COUNT * 4]; mRegionMesh = new TextureVertex[gMaxNumberOfQuads * 4]; } return mRegionMesh; Loading libs/hwui/Caches.h +3 −2 Original line number Diff line number Diff line Loading @@ -58,7 +58,8 @@ namespace uirenderer { // GL ES 2.0 defines that at least 16 texture units must be supported #define REQUIRED_TEXTURE_UNITS_COUNT 3 #define REGION_MESH_QUAD_COUNT 512 // Maximum number of quads that pre-allocated meshes can draw static const uint32_t gMaxNumberOfQuads = 2048; // Generates simple and textured vertices #define FV(x, y, u, v) { { x, y }, { u, v } } Loading Loading @@ -181,7 +182,7 @@ public: /** * Binds a global indices buffer that can draw up to * REGION_MESH_QUAD_COUNT quads. * gMaxNumberOfQuads quads. */ bool bindIndicesBuffer(); bool bindIndicesBuffer(const GLuint buffer); Loading libs/hwui/Extensions.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "Debug.h" #include "Extensions.h" #include "Properties.h" namespace android { Loading Loading @@ -63,7 +64,13 @@ Extensions::Extensions(): Singleton<Extensions>() { // Query EGL extensions findExtensions(eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS), mEglExtensionList); mHasNvSystemTime = hasEglExtension("EGL_NV_system_time"); char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_DEBUG_NV_PROFILING, property, NULL) > 0) { mHasNvSystemTime = !strcmp(property, "true") && hasEglExtension("EGL_NV_system_time"); } else { mHasNvSystemTime = false; } const char* version = (const char*) glGetString(GL_VERSION); Loading libs/hwui/FontRenderer.cpp +1 −37 Original line number Diff line number Diff line Loading @@ -64,8 +64,6 @@ FontRenderer::FontRenderer() : mLinearFiltering = false; mIndexBufferID = 0; mSmallCacheWidth = DEFAULT_TEXT_SMALL_CACHE_WIDTH; mSmallCacheHeight = DEFAULT_TEXT_SMALL_CACHE_HEIGHT; mLargeCacheWidth = DEFAULT_TEXT_LARGE_CACHE_WIDTH; Loading Loading @@ -111,12 +109,6 @@ FontRenderer::~FontRenderer() { } mCacheTextures.clear(); if (mInitialized) { // Unbinding the buffer shouldn't be necessary but it crashes with some drivers Caches::getInstance().unbindIndicesBuffer(); glDeleteBuffers(1, &mIndexBufferID); } LruCache<Font::FontDescription, Font*>::Iterator it(mActiveFonts); while (it.next()) { delete it.value(); Loading Loading @@ -319,33 +311,6 @@ void FontRenderer::initTextTexture() { mCurrentCacheTexture = mCacheTextures[0]; } // Avoid having to reallocate memory and render quad by quad void FontRenderer::initVertexArrayBuffers() { uint32_t numIndices = gMaxNumberOfQuads * 6; uint32_t indexBufferSizeBytes = numIndices * sizeof(uint16_t); uint16_t* indexBufferData = (uint16_t*) malloc(indexBufferSizeBytes); // Four verts, two triangles , six indices per quad for (uint32_t i = 0; i < gMaxNumberOfQuads; i++) { int i6 = i * 6; int i4 = i * 4; indexBufferData[i6 + 0] = i4 + 0; indexBufferData[i6 + 1] = i4 + 1; indexBufferData[i6 + 2] = i4 + 2; indexBufferData[i6 + 3] = i4 + 0; indexBufferData[i6 + 4] = i4 + 2; indexBufferData[i6 + 5] = i4 + 3; } glGenBuffers(1, &mIndexBufferID); Caches::getInstance().bindIndicesBuffer(mIndexBufferID); glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexBufferSizeBytes, indexBufferData, GL_STATIC_DRAW); free(indexBufferData); } // We don't want to allocate anything unless we actually draw text void FontRenderer::checkInit() { if (mInitialized) { Loading @@ -353,7 +318,6 @@ void FontRenderer::checkInit() { } initTextTexture(); initVertexArrayBuffers(); mInitialized = true; } Loading Loading @@ -416,7 +380,7 @@ void FontRenderer::issueDrawCommand() { if (mFunctor) (*mFunctor)(0, NULL); checkTextureUpdate(); caches.bindIndicesBuffer(mIndexBufferID); caches.bindIndicesBuffer(); if (!mDrawn) { // If returns true, a VBO was bound and we must Loading libs/hwui/FontRenderer.h +0 −5 Original line number Diff line number Diff line Loading @@ -105,8 +105,6 @@ public: private: friend class Font; static const uint32_t gMaxNumberOfQuads = 2048; const uint8_t* mGammaTable; void allocateTextureMemory(CacheTexture* cacheTexture); Loading @@ -118,7 +116,6 @@ private: CacheTexture* cacheBitmapInTexture(const SkGlyph& glyph, uint32_t* startX, uint32_t* startY); void flushAllAndInvalidate(); void initVertexArrayBuffers(); void checkInit(); void initRender(const Rect* clip, Rect* bounds, Functor* functor); Loading Loading @@ -160,8 +157,6 @@ private: bool mUploadTexture; uint32_t mIndexBufferID; Functor* mFunctor; const Rect* mClip; Rect* mBounds; Loading Loading
libs/hwui/Caches.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -386,8 +386,8 @@ bool Caches::bindIndicesBuffer(const GLuint buffer) { bool Caches::bindIndicesBuffer() { if (!mMeshIndices) { uint16_t* regionIndices = new uint16_t[REGION_MESH_QUAD_COUNT * 6]; for (int i = 0; i < REGION_MESH_QUAD_COUNT; i++) { 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; regionIndices[index ] = quad; // top-left Loading @@ -400,7 +400,7 @@ bool Caches::bindIndicesBuffer() { glGenBuffers(1, &mMeshIndices); bool force = bindIndicesBuffer(mMeshIndices); glBufferData(GL_ELEMENT_ARRAY_BUFFER, REGION_MESH_QUAD_COUNT * 6 * sizeof(uint16_t), glBufferData(GL_ELEMENT_ARRAY_BUFFER, gMaxNumberOfQuads * 6 * sizeof(uint16_t), regionIndices, GL_STATIC_DRAW); delete[] regionIndices; Loading Loading @@ -638,7 +638,7 @@ 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[REGION_MESH_QUAD_COUNT * 4]; mRegionMesh = new TextureVertex[gMaxNumberOfQuads * 4]; } return mRegionMesh; Loading
libs/hwui/Caches.h +3 −2 Original line number Diff line number Diff line Loading @@ -58,7 +58,8 @@ namespace uirenderer { // GL ES 2.0 defines that at least 16 texture units must be supported #define REQUIRED_TEXTURE_UNITS_COUNT 3 #define REGION_MESH_QUAD_COUNT 512 // Maximum number of quads that pre-allocated meshes can draw static const uint32_t gMaxNumberOfQuads = 2048; // Generates simple and textured vertices #define FV(x, y, u, v) { { x, y }, { u, v } } Loading Loading @@ -181,7 +182,7 @@ public: /** * Binds a global indices buffer that can draw up to * REGION_MESH_QUAD_COUNT quads. * gMaxNumberOfQuads quads. */ bool bindIndicesBuffer(); bool bindIndicesBuffer(const GLuint buffer); Loading
libs/hwui/Extensions.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "Debug.h" #include "Extensions.h" #include "Properties.h" namespace android { Loading Loading @@ -63,7 +64,13 @@ Extensions::Extensions(): Singleton<Extensions>() { // Query EGL extensions findExtensions(eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS), mEglExtensionList); mHasNvSystemTime = hasEglExtension("EGL_NV_system_time"); char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_DEBUG_NV_PROFILING, property, NULL) > 0) { mHasNvSystemTime = !strcmp(property, "true") && hasEglExtension("EGL_NV_system_time"); } else { mHasNvSystemTime = false; } const char* version = (const char*) glGetString(GL_VERSION); Loading
libs/hwui/FontRenderer.cpp +1 −37 Original line number Diff line number Diff line Loading @@ -64,8 +64,6 @@ FontRenderer::FontRenderer() : mLinearFiltering = false; mIndexBufferID = 0; mSmallCacheWidth = DEFAULT_TEXT_SMALL_CACHE_WIDTH; mSmallCacheHeight = DEFAULT_TEXT_SMALL_CACHE_HEIGHT; mLargeCacheWidth = DEFAULT_TEXT_LARGE_CACHE_WIDTH; Loading Loading @@ -111,12 +109,6 @@ FontRenderer::~FontRenderer() { } mCacheTextures.clear(); if (mInitialized) { // Unbinding the buffer shouldn't be necessary but it crashes with some drivers Caches::getInstance().unbindIndicesBuffer(); glDeleteBuffers(1, &mIndexBufferID); } LruCache<Font::FontDescription, Font*>::Iterator it(mActiveFonts); while (it.next()) { delete it.value(); Loading Loading @@ -319,33 +311,6 @@ void FontRenderer::initTextTexture() { mCurrentCacheTexture = mCacheTextures[0]; } // Avoid having to reallocate memory and render quad by quad void FontRenderer::initVertexArrayBuffers() { uint32_t numIndices = gMaxNumberOfQuads * 6; uint32_t indexBufferSizeBytes = numIndices * sizeof(uint16_t); uint16_t* indexBufferData = (uint16_t*) malloc(indexBufferSizeBytes); // Four verts, two triangles , six indices per quad for (uint32_t i = 0; i < gMaxNumberOfQuads; i++) { int i6 = i * 6; int i4 = i * 4; indexBufferData[i6 + 0] = i4 + 0; indexBufferData[i6 + 1] = i4 + 1; indexBufferData[i6 + 2] = i4 + 2; indexBufferData[i6 + 3] = i4 + 0; indexBufferData[i6 + 4] = i4 + 2; indexBufferData[i6 + 5] = i4 + 3; } glGenBuffers(1, &mIndexBufferID); Caches::getInstance().bindIndicesBuffer(mIndexBufferID); glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexBufferSizeBytes, indexBufferData, GL_STATIC_DRAW); free(indexBufferData); } // We don't want to allocate anything unless we actually draw text void FontRenderer::checkInit() { if (mInitialized) { Loading @@ -353,7 +318,6 @@ void FontRenderer::checkInit() { } initTextTexture(); initVertexArrayBuffers(); mInitialized = true; } Loading Loading @@ -416,7 +380,7 @@ void FontRenderer::issueDrawCommand() { if (mFunctor) (*mFunctor)(0, NULL); checkTextureUpdate(); caches.bindIndicesBuffer(mIndexBufferID); caches.bindIndicesBuffer(); if (!mDrawn) { // If returns true, a VBO was bound and we must Loading
libs/hwui/FontRenderer.h +0 −5 Original line number Diff line number Diff line Loading @@ -105,8 +105,6 @@ public: private: friend class Font; static const uint32_t gMaxNumberOfQuads = 2048; const uint8_t* mGammaTable; void allocateTextureMemory(CacheTexture* cacheTexture); Loading @@ -118,7 +116,6 @@ private: CacheTexture* cacheBitmapInTexture(const SkGlyph& glyph, uint32_t* startX, uint32_t* startY); void flushAllAndInvalidate(); void initVertexArrayBuffers(); void checkInit(); void initRender(const Rect* clip, Rect* bounds, Functor* functor); Loading Loading @@ -160,8 +157,6 @@ private: bool mUploadTexture; uint32_t mIndexBufferID; Functor* mFunctor; const Rect* mClip; Rect* mBounds; Loading