diff options
author | Romain Guy <romainguy@google.com> | 2013-06-04 18:00:09 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2013-06-04 18:58:36 -0700 |
commit | 8aa195d7081b889f3a7b1f426cbd8556377aae5e (patch) | |
tree | 6cd0ab4181c25d3113c4e39b49e8f8a0c7d12b8b /libs/hwui/font/CacheTexture.cpp | |
parent | 84f3c5689cffbfc1e45a0101d5bb636323769f54 (diff) | |
download | frameworks_base-8aa195d7081b889f3a7b1f426cbd8556377aae5e.zip frameworks_base-8aa195d7081b889f3a7b1f426cbd8556377aae5e.tar.gz frameworks_base-8aa195d7081b889f3a7b1f426cbd8556377aae5e.tar.bz2 |
Introduce Caches::bindTexture() to reduce glBindTexture calls
Change-Id: Ic345422567c020c0a9035ff51dcf2ae2a1fc59f4
Diffstat (limited to 'libs/hwui/font/CacheTexture.cpp')
-rw-r--r-- | libs/hwui/font/CacheTexture.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libs/hwui/font/CacheTexture.cpp b/libs/hwui/font/CacheTexture.cpp index 6c5267d..2d58338 100644 --- a/libs/hwui/font/CacheTexture.cpp +++ b/libs/hwui/font/CacheTexture.cpp @@ -17,6 +17,7 @@ #include <SkGlyph.h> #include "CacheTexture.h" +#include "../Caches.h" #include "../Debug.h" #include "../Extensions.h" #include "../PixelBuffer.h" @@ -110,7 +111,8 @@ CacheBlock* CacheBlock::removeBlock(CacheBlock* head, CacheBlock* blockToRemove) CacheTexture::CacheTexture(uint16_t width, uint16_t height, uint32_t maxQuadCount) : mTexture(NULL), mTextureId(0), mWidth(width), mHeight(height), mLinearFiltering(false), mDirty(false), mNumGlyphs(0), - mMesh(NULL), mCurrentQuad(0), mMaxQuadCount(maxQuadCount) { + mMesh(NULL), mCurrentQuad(0), mMaxQuadCount(maxQuadCount), + mCaches(Caches::getInstance()) { mCacheBlocks = new CacheBlock(TEXTURE_BORDER_SIZE, TEXTURE_BORDER_SIZE, mWidth - TEXTURE_BORDER_SIZE, mHeight - TEXTURE_BORDER_SIZE, true); @@ -166,7 +168,7 @@ void CacheTexture::setLinearFiltering(bool linearFiltering, bool bind) { mLinearFiltering = linearFiltering; const GLenum filtering = linearFiltering ? GL_LINEAR : GL_NEAREST; - if (bind) glBindTexture(GL_TEXTURE_2D, getTextureId()); + if (bind) mCaches.bindTexture(getTextureId()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); } @@ -186,7 +188,7 @@ void CacheTexture::allocateTexture() { if (!mTextureId) { glGenTextures(1, &mTextureId); - glBindTexture(GL_TEXTURE_2D, mTextureId); + mCaches.bindTexture(mTextureId); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // Initialize texture dimensions glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, mWidth, mHeight, 0, |