diff options
author | Romain Guy <romainguy@google.com> | 2012-09-23 15:00:46 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-23 15:00:46 -0700 |
commit | d392b87e3d30cd4f0836623d848019c5724efce8 (patch) | |
tree | e1ebbf8d24d2ef4963f212c0f13bbf06fabeaa20 /libs/hwui/font | |
parent | c0e1f268451550368d1d3d3558f8ce2459ed5713 (diff) | |
parent | 4285de3c8bc77856a2df98894f74bb7333f1d348 (diff) | |
download | frameworks_base-d392b87e3d30cd4f0836623d848019c5724efce8.zip frameworks_base-d392b87e3d30cd4f0836623d848019c5724efce8.tar.gz frameworks_base-d392b87e3d30cd4f0836623d848019c5724efce8.tar.bz2 |
Merge changes Ib0a0b7d1,Ibec4b2aa into jb-mr1-dev
* changes:
Fix overdraw debug on QCOM
Make sure we never bind to texture #0 Bug #7195815
Diffstat (limited to 'libs/hwui/font')
-rw-r--r-- | libs/hwui/font/CacheTexture.h | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/libs/hwui/font/CacheTexture.h b/libs/hwui/font/CacheTexture.h index 800bfc4..fdd1623 100644 --- a/libs/hwui/font/CacheTexture.h +++ b/libs/hwui/font/CacheTexture.h @@ -78,12 +78,7 @@ public: } ~CacheTexture() { - if (mTexture) { - delete[] mTexture; - } - if (mTextureId) { - glDeleteTextures(1, &mTextureId); - } + releaseTexture(); reset(); } @@ -106,38 +101,40 @@ public: void releaseTexture() { if (mTexture) { - glDeleteTextures(1, &mTextureId); delete[] mTexture; mTexture = NULL; + } + if (mTextureId) { + glDeleteTextures(1, &mTextureId); mTextureId = 0; } + mDirty = false; } /** * This method assumes that the proper texture unit is active. */ void allocateTexture() { - int width = mWidth; - int height = mHeight; - - mTexture = new uint8_t[width * height]; + if (!mTexture) { + mTexture = new uint8_t[mWidth * mHeight]; + } if (!mTextureId) { glGenTextures(1, &mTextureId); - } - glBindTexture(GL_TEXTURE_2D, mTextureId); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - // Initialize texture dimensions - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, - GL_ALPHA, GL_UNSIGNED_BYTE, 0); + glBindTexture(GL_TEXTURE_2D, mTextureId); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + // Initialize texture dimensions + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, mWidth, mHeight, 0, + GL_ALPHA, GL_UNSIGNED_BYTE, 0); - const GLenum filtering = getLinearFiltering() ? GL_LINEAR : GL_NEAREST; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); + const GLenum filtering = getLinearFiltering() ? GL_LINEAR : GL_NEAREST; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } } bool fitBitmap(const SkGlyph& glyph, uint32_t* retOriginX, uint32_t* retOriginY); @@ -158,7 +155,8 @@ public: return mTexture; } - inline GLuint getTextureId() const { + GLuint getTextureId() { + allocateTexture(); return mTextureId; } |