Merge "Ensure Texture always binds to self"

This commit is contained in:
John Reck
2016-01-21 17:21:05 +00:00
committed by Android (Google) Code Review

View File

@@ -95,28 +95,21 @@ bool Texture::updateSize(uint32_t width, uint32_t height, GLint format) {
void Texture::upload(GLint internalformat, uint32_t width, uint32_t height,
GLenum format, GLenum type, const void* pixels) {
GL_CHECKPOINT();
bool needsAlloc = updateSize(width, height, internalformat);
if (!needsAlloc && !pixels) {
return;
}
mCaches.textureState().activateTexture(0);
GL_CHECKPOINT();
bool needsAlloc = updateSize(width, height, internalformat);
if (!mId) {
glGenTextures(1, &mId);
needsAlloc = true;
}
GL_CHECKPOINT();
mCaches.textureState().bindTexture(GL_TEXTURE_2D, mId);
GL_CHECKPOINT();
if (needsAlloc) {
glTexImage2D(GL_TEXTURE_2D, 0, mFormat, mWidth, mHeight, 0,
format, type, pixels);
GL_CHECKPOINT();
} else {
} else if (pixels) {
glTexSubImage2D(GL_TEXTURE_2D, 0, mFormat, mWidth, mHeight, 0,
format, type, pixels);
GL_CHECKPOINT();
}
GL_CHECKPOINT();
}
static void uploadToTexture(bool resize, GLenum format, GLenum type, GLsizei stride, GLsizei bpp,