diff options
Diffstat (limited to 'libs/hwui/Texture.cpp')
-rw-r--r-- | libs/hwui/Texture.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/libs/hwui/Texture.cpp b/libs/hwui/Texture.cpp index 09e107eae132..c4a65f6fd545 100644 --- a/libs/hwui/Texture.cpp +++ b/libs/hwui/Texture.cpp @@ -48,37 +48,34 @@ static int bytesPerPixel(GLint glFormat) { } } -void Texture::setWrapST(GLenum wrapS, GLenum wrapT, bool bindTexture, bool force, - GLenum renderTarget) { +void Texture::setWrapST(GLenum wrapS, GLenum wrapT, bool bindTexture, bool force) { if (force || wrapS != mWrapS || wrapT != mWrapT) { mWrapS = wrapS; mWrapT = wrapT; if (bindTexture) { - mCaches.textureState().bindTexture(renderTarget, mId); + mCaches.textureState().bindTexture(mTarget, mId); } - glTexParameteri(renderTarget, GL_TEXTURE_WRAP_S, wrapS); - glTexParameteri(renderTarget, GL_TEXTURE_WRAP_T, wrapT); + glTexParameteri(mTarget, GL_TEXTURE_WRAP_S, wrapS); + glTexParameteri(mTarget, GL_TEXTURE_WRAP_T, wrapT); } } -void Texture::setFilterMinMag(GLenum min, GLenum mag, bool bindTexture, bool force, - GLenum renderTarget) { - +void Texture::setFilterMinMag(GLenum min, GLenum mag, bool bindTexture, bool force) { if (force || min != mMinFilter || mag != mMagFilter) { mMinFilter = min; mMagFilter = mag; if (bindTexture) { - mCaches.textureState().bindTexture(renderTarget, mId); + mCaches.textureState().bindTexture(mTarget, mId); } if (mipMap && min == GL_LINEAR) min = GL_LINEAR_MIPMAP_LINEAR; - glTexParameteri(renderTarget, GL_TEXTURE_MIN_FILTER, min); - glTexParameteri(renderTarget, GL_TEXTURE_MAG_FILTER, mag); + glTexParameteri(mTarget, GL_TEXTURE_MIN_FILTER, min); + glTexParameteri(mTarget, GL_TEXTURE_MAG_FILTER, mag); } } @@ -87,15 +84,20 @@ void Texture::deleteTexture() { mId = 0; } -bool Texture::updateSize(uint32_t width, uint32_t height, GLint internalFormat, GLint format) { - if (mWidth == width && mHeight == height && - mFormat == format && mInternalFormat == internalFormat) { +bool Texture::updateSize(uint32_t width, uint32_t height, GLint internalFormat, + GLint format, GLenum target) { + if (mWidth == width + && mHeight == height + && mFormat == format + && mInternalFormat == internalFormat + && mTarget == target) { return false; } mWidth = width; mHeight = height; mFormat = format; mInternalFormat = internalFormat; + mTarget = target; notifySizeChanged(mWidth * mHeight * bytesPerPixel(internalFormat)); return true; } @@ -110,7 +112,7 @@ void Texture::resetCachedParams() { void Texture::upload(GLint internalFormat, uint32_t width, uint32_t height, GLenum format, GLenum type, const void* pixels) { GL_CHECKPOINT(MODERATE); - bool needsAlloc = updateSize(width, height, internalFormat, format); + bool needsAlloc = updateSize(width, height, internalFormat, format, GL_TEXTURE_2D); if (!mId) { glGenTextures(1, &mId); needsAlloc = true; @@ -241,7 +243,7 @@ void Texture::upload(Bitmap& bitmap) { GLint internalFormat, format, type; colorTypeToGlFormatAndType(mCaches, bitmap.colorType(), needSRGB, &internalFormat, &format, &type); - if (updateSize(bitmap.width(), bitmap.height(), internalFormat, format)) { + if (updateSize(bitmap.width(), bitmap.height(), internalFormat, format, GL_TEXTURE_2D)) { needsAlloc = true; } @@ -286,12 +288,14 @@ void Texture::upload(Bitmap& bitmap) { } } -void Texture::wrap(GLuint id, uint32_t width, uint32_t height, GLint internalFormat, GLint format) { +void Texture::wrap(GLuint id, uint32_t width, uint32_t height, + GLint internalFormat, GLint format, GLenum target) { mId = id; mWidth = width; mHeight = height; mFormat = format; mInternalFormat = internalFormat; + mTarget = target; // We're wrapping an existing texture, so don't double count this memory notifySizeChanged(0); } |