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

Commit 1e79386b authored by Romain Guy's avatar Romain Guy
Browse files

Optimize textures binding.

The renderer is still changing textures' wrap modes every time, this will require
a latter optimization.

Change-Id: I3eb92cb8c886c4a692b7f0ca759911f9371d4d2c
parent 079ba2c8
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -115,7 +115,6 @@ Layer* LayerCache::get(LayerSize& size, GLuint previousFbo) {

        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width, size.height, 0,
                GL_RGBA, GL_UNSIGNED_BYTE, NULL);
        glBindTexture(GL_TEXTURE_2D, 0);

        // Bind texture to FBO
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+7 −4
Original line number Diff line number Diff line
@@ -132,6 +132,8 @@ OpenGLRenderer::OpenGLRenderer():
    mShaderMatrix = NULL;
    mShaderBitmap = NULL;

    mLastTexture = 0;

    memcpy(mDrawTextureVertices, gDrawTextureVertices, sizeof(gDrawTextureVertices));
}

@@ -650,8 +652,11 @@ void OpenGLRenderer::drawTextureMesh(float left, float top, float right, float b

    chooseBlending(blend || alpha < 1.0f, mode);

    // TODO: Only bind/set parameters when needed
    if (texture != mLastTexture) {
        glBindTexture(GL_TEXTURE_2D, texture);
        mLastTexture = texture;
    }
    // TODO: Don't set the texture parameters every time
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, gTileModes[mShaderTileX]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, gTileModes[mShaderTileY]);

@@ -668,8 +673,6 @@ void OpenGLRenderer::drawTextureMesh(float left, float top, float right, float b
    } else {
        glDrawElements(GL_TRIANGLES, elementsCount, GL_UNSIGNED_SHORT, indices);
    }

    glBindTexture(GL_TEXTURE_2D, 0);
}

void OpenGLRenderer::chooseBlending(bool blend, SkXfermode::Mode mode, bool isPremultiplied) {
+3 −0
Original line number Diff line number Diff line
@@ -311,6 +311,9 @@ private:
    // Used to draw textured quads
    TextureVertex mDrawTextureVertices[4];

    // Current texture state
    GLuint mLastTexture;

    // Last known blend state
    bool mBlend;
    GLenum mLastSrcMode;
+0 −2
Original line number Diff line number Diff line
@@ -146,8 +146,6 @@ void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture, bool rege

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    glBindTexture(GL_TEXTURE_2D, 0);
}

}; // namespace uirenderer