Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66f65cb3 authored by John Reck's avatar John Reck
Browse files

Ensure Texture always binds to self

Bug: 26584230

In the event that Texture decides it doesn't
need to actually call glTexImage2D/glSubTexImage2D
it needs to still activateTexture(0) and bindTexture(mId)
as this is the expected state after Texture::upload()
is called.

Change-Id: I62d689a9057907a10dda2bc8f40c3113e43b93b2
parent 17b179d5
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -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,