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

Commit 7c212b27 authored by Chet Haase's avatar Chet Haase Committed by Android (Google) Code Review
Browse files

Merge "Line endcaps for AA lines are now antialiased."

parents 2542d0cd 99585ade
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -62,8 +62,10 @@ static const TextureVertex gMeshVertices[] = {
static const GLsizei gMeshStride = sizeof(TextureVertex);
static const GLsizei gMeshStride = sizeof(TextureVertex);
static const GLsizei gVertexStride = sizeof(Vertex);
static const GLsizei gVertexStride = sizeof(Vertex);
static const GLsizei gAlphaVertexStride = sizeof(AlphaVertex);
static const GLsizei gAlphaVertexStride = sizeof(AlphaVertex);
static const GLsizei gAAVertexStride = sizeof(AAVertex);
static const GLsizei gMeshTextureOffset = 2 * sizeof(float);
static const GLsizei gMeshTextureOffset = 2 * sizeof(float);
static const GLsizei gVertexAlphaOffset = 2 * sizeof(float);
static const GLsizei gVertexAAWidthOffset = 2 * sizeof(float);
static const GLsizei gVertexAALengthOffset = 3 * sizeof(float);
static const GLsizei gMeshCount = 4;
static const GLsizei gMeshCount = 4;


///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
+60 −32
Original line number Original line Diff line number Diff line
@@ -915,7 +915,7 @@ void OpenGLRenderer::setupDrawWithExternalTexture() {
}
}


void OpenGLRenderer::setupDrawAALine() {
void OpenGLRenderer::setupDrawAALine() {
    mDescription.hasWidth = true;
    mDescription.isAA = true;
}
}


void OpenGLRenderer::setupDrawPoint(float pointSize) {
void OpenGLRenderer::setupDrawPoint(float pointSize) {
@@ -1121,25 +1121,30 @@ void OpenGLRenderer::setupDrawVertices(GLvoid* vertices) {


/**
/**
 * Sets up the shader to draw an AA line. We draw AA lines with quads, where there is an
 * Sets up the shader to draw an AA line. We draw AA lines with quads, where there is an
 * outer boundary that fades out to 0. The variables set in the shader define the width of the
 * outer boundary that fades out to 0. The variables set in the shader define the proportion of
 * core line primitive ("width") and the width of the fading boundary ("boundaryWidth"). The
 * the width and length of the primitive occupied by the AA region. The vtxWidth and vtxLength
 * "vtxDistance" attribute (one per vertex) is a value from zero to one that tells the fragment
 * attributes (one per vertex) are values from zero to one that tells the fragment
 * shader where the fragment is in relation to the line width overall; this value is then used
 * shader where the fragment is in relation to the line width/length overall; these values are
 * to compute the proper color, based on whether the fragment lies in the fading AA region of
 * then used to compute the proper color, based on whether the fragment lies in the fading AA
 * the line.
 * region of the line.
 * Note that we only pass down the width values in this setup function. The length coordinates
 * are set up for each individual segment.
 */
 */
void OpenGLRenderer::setupDrawAALine(GLvoid* vertices, GLvoid* distanceCoords, float strokeWidth) {
void OpenGLRenderer::setupDrawAALine(GLvoid* vertices, GLvoid* widthCoords,
        GLvoid* lengthCoords, float strokeWidth) {
    mCaches.unbindMeshBuffer();
    mCaches.unbindMeshBuffer();
    glVertexAttribPointer(mCaches.currentProgram->position, 2, GL_FLOAT, GL_FALSE,
    glVertexAttribPointer(mCaches.currentProgram->position, 2, GL_FLOAT, GL_FALSE,
            gAlphaVertexStride, vertices);
            gAAVertexStride, vertices);
    int distanceSlot = mCaches.currentProgram->getAttrib("vtxDistance");
    int widthSlot = mCaches.currentProgram->getAttrib("vtxWidth");
    glEnableVertexAttribArray(distanceSlot);
    glEnableVertexAttribArray(widthSlot);
    glVertexAttribPointer(distanceSlot, 1, GL_FLOAT, GL_FALSE, gAlphaVertexStride, distanceCoords);
    glVertexAttribPointer(widthSlot, 1, GL_FLOAT, GL_FALSE, gAAVertexStride, widthCoords);
    int widthSlot = mCaches.currentProgram->getUniform("width");
    int lengthSlot = mCaches.currentProgram->getAttrib("vtxLength");
    glEnableVertexAttribArray(lengthSlot);
    glVertexAttribPointer(lengthSlot, 1, GL_FLOAT, GL_FALSE, gAAVertexStride, lengthCoords);
    int boundaryWidthSlot = mCaches.currentProgram->getUniform("boundaryWidth");
    int boundaryWidthSlot = mCaches.currentProgram->getUniform("boundaryWidth");
    // Setting the inverse value saves computations per-fragment in the shader
    int inverseBoundaryWidthSlot = mCaches.currentProgram->getUniform("inverseBoundaryWidth");
    int inverseBoundaryWidthSlot = mCaches.currentProgram->getUniform("inverseBoundaryWidth");
    float boundaryWidth = (1 - strokeWidth) / 2;
    float boundaryWidth = (1 - strokeWidth) / 2;
    glUniform1f(widthSlot, strokeWidth);
    glUniform1f(boundaryWidthSlot, boundaryWidth);
    glUniform1f(boundaryWidthSlot, boundaryWidth);
    glUniform1f(inverseBoundaryWidthSlot, (1 / boundaryWidth));
    glUniform1f(inverseBoundaryWidthSlot, (1 / boundaryWidth));
}
}
@@ -1480,20 +1485,21 @@ void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
    }
    }
    Vertex lines[verticesCount];
    Vertex lines[verticesCount];
    Vertex* vertices = &lines[0];
    Vertex* vertices = &lines[0];
    AlphaVertex wLines[verticesCount];
    AAVertex wLines[verticesCount];
    AlphaVertex* aaVertices = &wLines[0];
    AAVertex* aaVertices = &wLines[0];
    if (!isAA) {
    if (!isAA) {
        setupDrawVertices(vertices);
        setupDrawVertices(vertices);
    } else {
    } else {
        void* alphaCoords = ((GLbyte*) aaVertices) + gVertexAlphaOffset;
        void* widthCoords = ((GLbyte*) aaVertices) + gVertexAAWidthOffset;
        void* lengthCoords = ((GLbyte*) aaVertices) + gVertexAALengthOffset;
        // innerProportion is the ratio of the inner (non-AA) port of the line to the total
        // innerProportion is the ratio of the inner (non-AA) port of the line to the total
        // AA stroke width (the base stroke width expanded by a half pixel on either side).
        // AA stroke width (the base stroke width expanded by a half pixel on either side).
        // This value is used in the fragment shader to determine how to fill fragments.
        // This value is used in the fragment shader to determine how to fill fragments.
        float innerProportion = fmax(strokeWidth - 1.0f, 0) / (strokeWidth + .5f);
        float innerProportion = fmax(strokeWidth - 1.0f, 0) / (strokeWidth + .5f);
        setupDrawAALine((void*) aaVertices, alphaCoords, innerProportion);
        setupDrawAALine((void*) aaVertices, widthCoords, lengthCoords, innerProportion);
    }
    }


    AlphaVertex *prevAAVertex = NULL;
    AAVertex *prevAAVertex = NULL;
    Vertex *prevVertex = NULL;
    Vertex *prevVertex = NULL;
    float inverseScaleX = 1.0f;
    float inverseScaleX = 1.0f;
    float inverseScaleY = 1.0f;
    float inverseScaleY = 1.0f;
@@ -1516,15 +1522,17 @@ void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
        }
        }
    }
    }


    int boundaryLengthSlot = -1;
    int inverseBoundaryLengthSlot = -1;
    for (int i = 0; i < count; i += 4) {
    for (int i = 0; i < count; i += 4) {
        // a = start point, b = end point
        // a = start point, b = end point
        vec2 a(points[i], points[i + 1]);
        vec2 a(points[i], points[i + 1]);
        vec2 b(points[i + 2], points[i + 3]);
        vec2 b(points[i + 2], points[i + 3]);
        float length = 0;


        // Find the normal to the line
        // Find the normal to the line
        vec2 n = (b - a).copyNormalized() * strokeWidth;
        vec2 n = (b - a).copyNormalized() * strokeWidth;
        if (isHairLine) {
        if (isHairLine) {
            n *= inverseScaleX;
            if (isAA) {
            if (isAA) {
                float wideningFactor;
                float wideningFactor;
                if (fabs(n.x) >= fabs(n.y)) {
                if (fabs(n.x) >= fabs(n.y)) {
@@ -1534,27 +1542,35 @@ void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
                }
                }
                n *= wideningFactor;
                n *= wideningFactor;
            }
            }
            n.x *= inverseScaleX;
            n.y *= inverseScaleY;
        }
        }
        float x = n.x;
        float x = n.x;
        n.x = -n.y;
        n.x = -n.y;
        n.y = x;
        n.y = x;


        // aa lines expand the endpoint vertices to encompass the AA boundary
        if (isAA) {
            vec2 abVector = (b - a);
            length = abVector.length();
            abVector.normalize();
            a -= abVector;
            b += abVector;
        }

        // Four corners of the rectangle defining a thick line
        // Four corners of the rectangle defining a thick line
        vec2 p1 = a - n;
        vec2 p1 = a - n;
        vec2 p2 = a + n;
        vec2 p2 = a + n;
        vec2 p3 = b + n;
        vec2 p3 = b + n;
        vec2 p4 = b - n;
        vec2 p4 = b - n;



        const float left = fmin(p1.x, fmin(p2.x, fmin(p3.x, p4.x)));
        const float left = fmin(p1.x, fmin(p2.x, fmin(p3.x, p4.x)));
        const float right = fmax(p1.x, fmax(p2.x, fmax(p3.x, p4.x)));
        const float right = fmax(p1.x, fmax(p2.x, fmax(p3.x, p4.x)));
        const float top = fmin(p1.y, fmin(p2.y, fmin(p3.y, p4.y)));
        const float top = fmin(p1.y, fmin(p2.y, fmin(p3.y, p4.y)));
        const float bottom = fmax(p1.y, fmax(p2.y, fmax(p3.y, p4.y)));
        const float bottom = fmax(p1.y, fmax(p2.y, fmax(p3.y, p4.y)));


        if (!quickReject(left, top, right, bottom)) {
        if (!quickReject(left, top, right, bottom)) {
            // Draw the line as 2 triangles, could be optimized
            // by using only 4 vertices and the correct indices
            // Also we should probably used non textured vertices
            // when line AA is disabled to save on bandwidth
            if (!isAA) {
            if (!isAA) {
                if (prevVertex != NULL) {
                if (prevVertex != NULL) {
                    // Issue two repeat vertices to create degenerate triangles to bridge
                    // Issue two repeat vertices to create degenerate triangles to bridge
@@ -1572,24 +1588,36 @@ void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
                prevVertex = vertices - 1;
                prevVertex = vertices - 1;
                generatedVerticesCount += 4;
                generatedVerticesCount += 4;
            } else {
            } else {
                if (boundaryLengthSlot < 0) {
                    boundaryLengthSlot = mCaches.currentProgram->getUniform("boundaryLength");
                    inverseBoundaryLengthSlot =
                            mCaches.currentProgram->getUniform("inverseBoundaryLength");
                }
                float innerProportion = (length) / (length + 2);
                float boundaryLength = (1 - innerProportion) / 2;
                glUniform1f(boundaryLengthSlot, boundaryLength);
                glUniform1f(inverseBoundaryLengthSlot, (1 / boundaryLength));

                if (prevAAVertex != NULL) {
                if (prevAAVertex != NULL) {
                    // Issue two repeat vertices to create degenerate triangles to bridge
                    // Issue two repeat vertices to create degenerate triangles to bridge
                    // between the previous line and the new one. This is necessary because
                    // between the previous line and the new one. This is necessary because
                    // we are creating a single triangle_strip which will contain
                    // we are creating a single triangle_strip which will contain
                    // potentially discontinuous line segments.
                    // potentially discontinuous line segments.
                    AlphaVertex::set(aaVertices++,prevAAVertex->position[0],
                    AAVertex::set(aaVertices++,prevAAVertex->position[0],
                            prevAAVertex->position[1], prevAAVertex->alpha);
                            prevAAVertex->position[1], prevAAVertex->width, prevAAVertex->length);
                    AlphaVertex::set(aaVertices++, p4.x, p4.y, 1);
                    AAVertex::set(aaVertices++, p4.x, p4.y, 1, 1);
                    generatedVerticesCount += 2;
                    generatedVerticesCount += 2;
                }
                }
                AlphaVertex::set(aaVertices++, p4.x, p4.y, 1);
                AAVertex::set(aaVertices++, p4.x, p4.y, 1, 1);
                AlphaVertex::set(aaVertices++, p1.x, p1.y, 1);
                AAVertex::set(aaVertices++, p1.x, p1.y, 1, 0);
                AlphaVertex::set(aaVertices++, p3.x, p3.y, 0);
                AAVertex::set(aaVertices++, p3.x, p3.y, 0, 1);
                AlphaVertex::set(aaVertices++, p2.x, p2.y, 0);
                AAVertex::set(aaVertices++, p2.x, p2.y, 0, 0);
                prevAAVertex = aaVertices - 1;
                prevAAVertex = aaVertices - 1;
                generatedVerticesCount += 4;
                generatedVerticesCount += 4;
            }
            }
            dirtyLayer(left, top, right, bottom, *mSnapshot->transform);
            dirtyLayer(a.x == b.x ? left - 1 : left, a.y == b.y ? top - 1 : top,
                    a.x == b.x ? right: right, a.y == b.y ? bottom: bottom,
                    *mSnapshot->transform);
        }
        }
    }
    }
    if (generatedVerticesCount > 0) {
    if (generatedVerticesCount > 0) {
+2 −1
Original line number Original line Diff line number Diff line
@@ -468,7 +468,8 @@ private:
    void setupDrawTextureTransform(mat4& transform);
    void setupDrawTextureTransform(mat4& transform);
    void setupDrawMesh(GLvoid* vertices, GLvoid* texCoords = NULL, GLuint vbo = 0);
    void setupDrawMesh(GLvoid* vertices, GLvoid* texCoords = NULL, GLuint vbo = 0);
    void setupDrawVertices(GLvoid* vertices);
    void setupDrawVertices(GLvoid* vertices);
    void setupDrawAALine(GLvoid* vertices, GLvoid* distanceCoords, float strokeWidth);
    void setupDrawAALine(GLvoid* vertices, GLvoid* distanceCoords, GLvoid* lengthCoords,
            float strokeWidth);
    void finishDrawTexture();
    void finishDrawTexture();


    void drawRegionRects(const Region& region);
    void drawRegionRects(const Region& region);
+36 −27
Original line number Original line Diff line number Diff line
@@ -39,8 +39,9 @@ const char* gVS_Header_Attributes =
        "attribute vec4 position;\n";
        "attribute vec4 position;\n";
const char* gVS_Header_Attributes_TexCoords =
const char* gVS_Header_Attributes_TexCoords =
        "attribute vec2 texCoords;\n";
        "attribute vec2 texCoords;\n";
const char* gVS_Header_Attributes_Distance =
const char* gVS_Header_Attributes_AAParameters =
        "attribute float vtxDistance;\n";
        "attribute float vtxWidth;\n"
        "attribute float vtxLength;\n";
const char* gVS_Header_Uniforms_TextureTransform =
const char* gVS_Header_Uniforms_TextureTransform =
        "uniform mat4 mainTextureTransform;\n";
        "uniform mat4 mainTextureTransform;\n";
const char* gVS_Header_Uniforms =
const char* gVS_Header_Uniforms =
@@ -60,8 +61,9 @@ const char* gVS_Header_Uniforms_HasBitmap =
        "uniform mediump vec2 textureDimension;\n";
        "uniform mediump vec2 textureDimension;\n";
const char* gVS_Header_Varyings_HasTexture =
const char* gVS_Header_Varyings_HasTexture =
        "varying vec2 outTexCoords;\n";
        "varying vec2 outTexCoords;\n";
const char* gVS_Header_Varyings_HasWidth =
const char* gVS_Header_Varyings_IsAA =
        "varying float distance;\n";
        "varying float widthProportion;\n"
        "varying float lengthProportion;\n";
const char* gVS_Header_Varyings_HasBitmap =
const char* gVS_Header_Varyings_HasBitmap =
        "varying vec2 outBitmapTexCoords;\n";
        "varying vec2 outBitmapTexCoords;\n";
const char* gVS_Header_Varyings_PointHasBitmap =
const char* gVS_Header_Varyings_PointHasBitmap =
@@ -96,8 +98,9 @@ const char* gVS_Main_Position =
        "    gl_Position = transform * position;\n";
        "    gl_Position = transform * position;\n";
const char* gVS_Main_PointSize =
const char* gVS_Main_PointSize =
        "    gl_PointSize = pointSize;\n";
        "    gl_PointSize = pointSize;\n";
const char* gVS_Main_Width =
const char* gVS_Main_AA =
        "    distance = vtxDistance;\n";
        "    widthProportion = vtxWidth;\n"
        "    lengthProportion = vtxLength;\n";
const char* gVS_Footer =
const char* gVS_Footer =
        "}\n\n";
        "}\n\n";


@@ -113,10 +116,11 @@ const char* gFS_Header =
        "precision mediump float;\n\n";
        "precision mediump float;\n\n";
const char* gFS_Uniforms_Color =
const char* gFS_Uniforms_Color =
        "uniform vec4 color;\n";
        "uniform vec4 color;\n";
const char* gFS_Uniforms_Width =
const char* gFS_Uniforms_AA =
        "uniform float width;\n"
        "uniform float boundaryWidth;\n"
        "uniform float boundaryWidth;\n"
        "uniform float inverseBoundaryWidth;\n";
        "uniform float inverseBoundaryWidth;\n"
        "uniform float boundaryLength;\n"
        "uniform float inverseBoundaryLength;\n";
const char* gFS_Header_Uniforms_PointHasBitmap =
const char* gFS_Header_Uniforms_PointHasBitmap =
        "uniform vec2 textureDimension;\n"
        "uniform vec2 textureDimension;\n"
        "uniform float pointSize;\n";
        "uniform float pointSize;\n";
@@ -189,11 +193,16 @@ const char* gFS_Main_FetchColor =
        "    fragColor = color;\n";
        "    fragColor = color;\n";
const char* gFS_Main_ModulateColor =
const char* gFS_Main_ModulateColor =
        "    fragColor *= color.a;\n";
        "    fragColor *= color.a;\n";
const char* gFS_Main_AccountForWidth =
const char* gFS_Main_AccountForAA =
        "    if (distance < boundaryWidth) {\n"
        "    if (widthProportion < boundaryWidth) {\n"
        "        fragColor *= (distance * inverseBoundaryWidth);\n"
        "        fragColor *= (widthProportion * inverseBoundaryWidth);\n"
        "    } else if (distance > (1.0 - boundaryWidth)) {\n"
        "    } else if (widthProportion > (1.0 - boundaryWidth)) {\n"
        "        fragColor *= ((1.0 - distance) * inverseBoundaryWidth);\n"
        "        fragColor *= ((1.0 - widthProportion) * inverseBoundaryWidth);\n"
        "    }\n"
        "    if (lengthProportion < boundaryLength) {\n"
        "        fragColor *= (lengthProportion * inverseBoundaryLength);\n"
        "    } else if (lengthProportion > (1.0 - boundaryLength)) {\n"
        "        fragColor *= ((1.0 - lengthProportion) * inverseBoundaryLength);\n"
        "    }\n";
        "    }\n";
const char* gFS_Main_FetchTexture[2] = {
const char* gFS_Main_FetchTexture[2] = {
        // Don't modulate
        // Don't modulate
@@ -380,8 +389,8 @@ String8 ProgramCache::generateVertexShader(const ProgramDescription& description
    if (description.hasTexture || description.hasExternalTexture) {
    if (description.hasTexture || description.hasExternalTexture) {
        shader.append(gVS_Header_Attributes_TexCoords);
        shader.append(gVS_Header_Attributes_TexCoords);
    }
    }
    if (description.hasWidth) {
    if (description.isAA) {
        shader.append(gVS_Header_Attributes_Distance);
        shader.append(gVS_Header_Attributes_AAParameters);
    }
    }
    // Uniforms
    // Uniforms
    shader.append(gVS_Header_Uniforms);
    shader.append(gVS_Header_Uniforms);
@@ -401,8 +410,8 @@ String8 ProgramCache::generateVertexShader(const ProgramDescription& description
    if (description.hasTexture || description.hasExternalTexture) {
    if (description.hasTexture || description.hasExternalTexture) {
        shader.append(gVS_Header_Varyings_HasTexture);
        shader.append(gVS_Header_Varyings_HasTexture);
    }
    }
    if (description.hasWidth) {
    if (description.isAA) {
        shader.append(gVS_Header_Varyings_HasWidth);
        shader.append(gVS_Header_Varyings_IsAA);
    }
    }
    if (description.hasGradient) {
    if (description.hasGradient) {
        shader.append(gVS_Header_Varyings_HasGradient[description.gradientType]);
        shader.append(gVS_Header_Varyings_HasGradient[description.gradientType]);
@@ -421,8 +430,8 @@ String8 ProgramCache::generateVertexShader(const ProgramDescription& description
        if (description.hasExternalTexture) {
        if (description.hasExternalTexture) {
            shader.append(gVS_Main_OutTransformedTexCoords);
            shader.append(gVS_Main_OutTransformedTexCoords);
        }
        }
        if (description.hasWidth) {
        if (description.isAA) {
            shader.append(gVS_Main_Width);
            shader.append(gVS_Main_AA);
        }
        }
        if (description.hasGradient) {
        if (description.hasGradient) {
            shader.append(gVS_Main_OutGradient[description.gradientType]);
            shader.append(gVS_Main_OutGradient[description.gradientType]);
@@ -464,8 +473,8 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti
    if (description.hasTexture || description.hasExternalTexture) {
    if (description.hasTexture || description.hasExternalTexture) {
        shader.append(gVS_Header_Varyings_HasTexture);
        shader.append(gVS_Header_Varyings_HasTexture);
    }
    }
    if (description.hasWidth) {
    if (description.isAA) {
        shader.append(gVS_Header_Varyings_HasWidth);
        shader.append(gVS_Header_Varyings_IsAA);
    }
    }
    if (description.hasGradient) {
    if (description.hasGradient) {
        shader.append(gVS_Header_Varyings_HasGradient[description.gradientType]);
        shader.append(gVS_Header_Varyings_HasGradient[description.gradientType]);
@@ -491,8 +500,8 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti
    if (description.hasExternalTexture) {
    if (description.hasExternalTexture) {
        shader.append(gFS_Uniforms_ExternalTextureSampler);
        shader.append(gFS_Uniforms_ExternalTextureSampler);
    }
    }
    if (description.hasWidth) {
    if (description.isAA) {
        shader.append(gFS_Uniforms_Width);
        shader.append(gFS_Uniforms_AA);
    }
    }
    if (description.hasGradient) {
    if (description.hasGradient) {
        shader.append(gFS_Uniforms_GradientSampler[description.gradientType]);
        shader.append(gFS_Uniforms_GradientSampler[description.gradientType]);
@@ -502,7 +511,7 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti
    }
    }


    // Optimization for common cases
    // Optimization for common cases
    if (!description.hasWidth && !blendFramebuffer &&
    if (!description.isAA && !blendFramebuffer &&
            description.colorOp == ProgramDescription::kColorNone && !description.isPoint) {
            description.colorOp == ProgramDescription::kColorNone && !description.isPoint) {
        bool fast = false;
        bool fast = false;


@@ -587,8 +596,8 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti
                shader.append(gFS_Main_FetchColor);
                shader.append(gFS_Main_FetchColor);
            }
            }
        }
        }
        if (description.hasWidth) {
        if (description.isAA) {
            shader.append(gFS_Main_AccountForWidth);
            shader.append(gFS_Main_AccountForAA);
        }
        }
        if (description.hasGradient) {
        if (description.hasGradient) {
            shader.append(gFS_Main_FetchGradient[description.gradientType]);
            shader.append(gFS_Main_FetchGradient[description.gradientType]);
+4 −4
Original line number Original line Diff line number Diff line
@@ -75,7 +75,7 @@ namespace uirenderer {


#define PROGRAM_IS_POINT_SHIFT 36
#define PROGRAM_IS_POINT_SHIFT 36


#define PROGRAM_HAS_WIDTH_SHIFT 37
#define PROGRAM_HAS_AA_SHIFT 37


#define PROGRAM_HAS_EXTERNAL_TEXTURE_SHIFT 38
#define PROGRAM_HAS_EXTERNAL_TEXTURE_SHIFT 38


@@ -124,7 +124,7 @@ struct ProgramDescription {
    bool hasBitmap;
    bool hasBitmap;
    bool isBitmapNpot;
    bool isBitmapNpot;


    bool hasWidth;
    bool isAA;


    bool hasGradient;
    bool hasGradient;
    Gradient gradientType;
    Gradient gradientType;
@@ -156,7 +156,7 @@ struct ProgramDescription {
        hasAlpha8Texture = false;
        hasAlpha8Texture = false;
        hasExternalTexture = false;
        hasExternalTexture = false;


        hasWidth = false;
        isAA = false;


        modulate = false;
        modulate = false;


@@ -243,7 +243,7 @@ struct ProgramDescription {
        if (swapSrcDst) key |= PROGRAM_KEY_SWAP_SRC_DST;
        if (swapSrcDst) key |= PROGRAM_KEY_SWAP_SRC_DST;
        if (modulate) key |= programid(0x1) << PROGRAM_MODULATE_SHIFT;
        if (modulate) key |= programid(0x1) << PROGRAM_MODULATE_SHIFT;
        if (isPoint) key |= programid(0x1) << PROGRAM_IS_POINT_SHIFT;
        if (isPoint) key |= programid(0x1) << PROGRAM_IS_POINT_SHIFT;
        if (hasWidth) key |= programid(0x1) << PROGRAM_HAS_WIDTH_SHIFT;
        if (isAA) key |= programid(0x1) << PROGRAM_HAS_AA_SHIFT;
        if (hasExternalTexture) key |= programid(0x1) << PROGRAM_HAS_EXTERNAL_TEXTURE_SHIFT;
        if (hasExternalTexture) key |= programid(0x1) << PROGRAM_HAS_EXTERNAL_TEXTURE_SHIFT;
        return key;
        return key;
    }
    }
Loading