Loading libs/hwui/Texture.cpp +13 −10 Original line number Diff line number Diff line Loading @@ -41,9 +41,7 @@ static int bytesPerPixel(GLint glFormat) { void Texture::setWrapST(GLenum wrapS, GLenum wrapT, bool bindTexture, bool force, GLenum renderTarget) { if (mFirstWrap || force || wrapS != mWrapS || wrapT != mWrapT) { mFirstWrap = false; if (force || wrapS != mWrapS || wrapT != mWrapT) { mWrapS = wrapS; mWrapT = wrapT; Loading @@ -59,9 +57,7 @@ void Texture::setWrapST(GLenum wrapS, GLenum wrapT, bool bindTexture, bool force void Texture::setFilterMinMag(GLenum min, GLenum mag, bool bindTexture, bool force, GLenum renderTarget) { if (mFirstFilter || force || min != mMinFilter || mag != mMagFilter) { mFirstFilter = false; if (force || min != mMinFilter || mag != mMagFilter) { mMinFilter = min; mMagFilter = mag; Loading Loading @@ -92,6 +88,13 @@ bool Texture::updateSize(uint32_t width, uint32_t height, GLint format) { return true; } void Texture::resetCachedParams() { mWrapS = GL_REPEAT; mWrapT = GL_REPEAT; mMinFilter = GL_NEAREST_MIPMAP_LINEAR; mMagFilter = GL_LINEAR; } void Texture::upload(GLint internalformat, uint32_t width, uint32_t height, GLenum format, GLenum type, const void* pixels) { GL_CHECKPOINT(); Loading @@ -99,6 +102,7 @@ void Texture::upload(GLint internalformat, uint32_t width, uint32_t height, if (!mId) { glGenTextures(1, &mId); needsAlloc = true; resetCachedParams(); } mCaches.textureState().bindTexture(GL_TEXTURE_2D, mId); if (needsAlloc) { Loading Loading @@ -206,10 +210,12 @@ void Texture::upload(const SkBitmap& bitmap) { // If the texture had mipmap enabled but not anymore, // force a glTexImage2D to discard the mipmap levels bool needsAlloc = canMipMap && mipMap && !bitmap.hasHardwareMipMap(); bool setDefaultParams = false; if (!mId) { glGenTextures(1, &mId); needsAlloc = true; setDefaultParams = true; } GLint format, type; Loading Loading @@ -244,11 +250,8 @@ void Texture::upload(const SkBitmap& bitmap) { } } if (mFirstFilter) { if (setDefaultParams) { setFilter(GL_NEAREST); } if (mFirstWrap) { setWrap(GL_CLAMP_TO_EDGE); } } Loading libs/hwui/Texture.h +9 −13 Original line number Diff line number Diff line Loading @@ -149,26 +149,22 @@ private: // Returns true if the size changed, false if it was the same bool updateSize(uint32_t width, uint32_t height, GLint format); void resetCachedParams(); GLuint mId = 0; uint32_t mWidth = 0; uint32_t mHeight = 0; GLint mFormat = 0; /** * Last wrap modes set on this texture. /* See GLES spec section 3.8.14 * "In the initial state, the value assigned to TEXTURE_MIN_FILTER is * NEAREST_MIPMAP_LINEAR and the value for TEXTURE_MAG_FILTER is LINEAR. * s, t, and r wrap modes are all set to REPEAT." */ GLenum mWrapS = GL_CLAMP_TO_EDGE; GLenum mWrapT = GL_CLAMP_TO_EDGE; /** * Last filters set on this texture. */ GLenum mMinFilter = GL_NEAREST; GLenum mMagFilter = GL_NEAREST; bool mFirstFilter = true; bool mFirstWrap = true; GLenum mWrapS = GL_REPEAT; GLenum mWrapT = GL_REPEAT; GLenum mMinFilter = GL_NEAREST_MIPMAP_LINEAR; GLenum mMagFilter = GL_LINEAR; Caches& mCaches; }; // struct Texture Loading Loading
libs/hwui/Texture.cpp +13 −10 Original line number Diff line number Diff line Loading @@ -41,9 +41,7 @@ static int bytesPerPixel(GLint glFormat) { void Texture::setWrapST(GLenum wrapS, GLenum wrapT, bool bindTexture, bool force, GLenum renderTarget) { if (mFirstWrap || force || wrapS != mWrapS || wrapT != mWrapT) { mFirstWrap = false; if (force || wrapS != mWrapS || wrapT != mWrapT) { mWrapS = wrapS; mWrapT = wrapT; Loading @@ -59,9 +57,7 @@ void Texture::setWrapST(GLenum wrapS, GLenum wrapT, bool bindTexture, bool force void Texture::setFilterMinMag(GLenum min, GLenum mag, bool bindTexture, bool force, GLenum renderTarget) { if (mFirstFilter || force || min != mMinFilter || mag != mMagFilter) { mFirstFilter = false; if (force || min != mMinFilter || mag != mMagFilter) { mMinFilter = min; mMagFilter = mag; Loading Loading @@ -92,6 +88,13 @@ bool Texture::updateSize(uint32_t width, uint32_t height, GLint format) { return true; } void Texture::resetCachedParams() { mWrapS = GL_REPEAT; mWrapT = GL_REPEAT; mMinFilter = GL_NEAREST_MIPMAP_LINEAR; mMagFilter = GL_LINEAR; } void Texture::upload(GLint internalformat, uint32_t width, uint32_t height, GLenum format, GLenum type, const void* pixels) { GL_CHECKPOINT(); Loading @@ -99,6 +102,7 @@ void Texture::upload(GLint internalformat, uint32_t width, uint32_t height, if (!mId) { glGenTextures(1, &mId); needsAlloc = true; resetCachedParams(); } mCaches.textureState().bindTexture(GL_TEXTURE_2D, mId); if (needsAlloc) { Loading Loading @@ -206,10 +210,12 @@ void Texture::upload(const SkBitmap& bitmap) { // If the texture had mipmap enabled but not anymore, // force a glTexImage2D to discard the mipmap levels bool needsAlloc = canMipMap && mipMap && !bitmap.hasHardwareMipMap(); bool setDefaultParams = false; if (!mId) { glGenTextures(1, &mId); needsAlloc = true; setDefaultParams = true; } GLint format, type; Loading Loading @@ -244,11 +250,8 @@ void Texture::upload(const SkBitmap& bitmap) { } } if (mFirstFilter) { if (setDefaultParams) { setFilter(GL_NEAREST); } if (mFirstWrap) { setWrap(GL_CLAMP_TO_EDGE); } } Loading
libs/hwui/Texture.h +9 −13 Original line number Diff line number Diff line Loading @@ -149,26 +149,22 @@ private: // Returns true if the size changed, false if it was the same bool updateSize(uint32_t width, uint32_t height, GLint format); void resetCachedParams(); GLuint mId = 0; uint32_t mWidth = 0; uint32_t mHeight = 0; GLint mFormat = 0; /** * Last wrap modes set on this texture. /* See GLES spec section 3.8.14 * "In the initial state, the value assigned to TEXTURE_MIN_FILTER is * NEAREST_MIPMAP_LINEAR and the value for TEXTURE_MAG_FILTER is LINEAR. * s, t, and r wrap modes are all set to REPEAT." */ GLenum mWrapS = GL_CLAMP_TO_EDGE; GLenum mWrapT = GL_CLAMP_TO_EDGE; /** * Last filters set on this texture. */ GLenum mMinFilter = GL_NEAREST; GLenum mMagFilter = GL_NEAREST; bool mFirstFilter = true; bool mFirstWrap = true; GLenum mWrapS = GL_REPEAT; GLenum mWrapT = GL_REPEAT; GLenum mMinFilter = GL_NEAREST_MIPMAP_LINEAR; GLenum mMagFilter = GL_LINEAR; Caches& mCaches; }; // struct Texture Loading