Add target to texture
Test: refactoring cl.
bug:32413624
Change-Id: I94b1c31cd4e0712dfcfd7777a0012424c1bf0dca
diff --git a/libs/hwui/Texture.cpp b/libs/hwui/Texture.cpp
index 09e107e..c4a65f6 100644
--- a/libs/hwui/Texture.cpp
+++ b/libs/hwui/Texture.cpp
@@ -48,37 +48,34 @@
}
}
-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 @@
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::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 @@
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::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);
}