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

Commit cda18512 authored by chilun_huang's avatar chilun_huang Committed by Steve Kondik
Browse files

[HWUI]: Bind wrong VBO when drawing text

Symptom:
We should not set mDrawn to true if we have no GL draw call.

Root Cause:
In some case, issueDrawCommand may executed without GL draw call.
It may miss the unbindMeshBuffer in the next issueDrawCommand and the status of VBO of FontRenderer will incorrect.

Solution:
Add condition to check if have draw call.

Change-Id: I9e96cd0334c515172b0ed6c25b101c81cf6d2e6f
parent f311e198
Loading
Loading
Loading
Loading

libs/hwui/FontRenderer.cpp

100644 → 100755
+8 −1
Original line number Diff line number Diff line
@@ -487,6 +487,7 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) {
    Caches& caches = Caches::getInstance();
    bool first = true;
    bool force = false;
    bool drawn = false;
    for (uint32_t i = 0; i < cacheTextures.size(); i++) {
        CacheTexture* texture = cacheTextures[i];
        if (texture->canDraw()) {
@@ -517,6 +518,7 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) {
            caches.bindPositionVertexPointer(force, &mesh[0].position[0]);
            caches.bindTexCoordsVertexPointer(force, &mesh[0].texture[0]);
            force = false;
            drawn = true;

            glDrawElements(GL_TRIANGLES, texture->meshElementCount(),
                    GL_UNSIGNED_SHORT, texture->indices());
@@ -524,13 +526,18 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) {
            texture->resetMesh();
        }
    }
    if (drawn) {
        mDrawn = true;
    }
}

void FontRenderer::issueDrawCommand() {
    issueDrawCommand(mACacheTextures);
    issueDrawCommand(mRGBACacheTextures);

    mDrawn = true;
    // We should not set mDrawn to true if we have no GL draw call.
    // In some case, issueDrawCommand may executed without GL draw call.
    // It may miss the unbindMeshBuffer in the next issueDrawCommand and the status of VBO of FontRenderer will incorrect.
}

void FontRenderer::appendMeshQuadNoClip(float x1, float y1, float u1, float v1,