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

Commit 92d50202 authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Fix 9patch rendering Bug #3253396"

parents 65dd62a3 8ab4079c
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -954,11 +954,11 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int
                mSnapshot->region && mesh->hasEmptyQuads) {
                mSnapshot->region && mesh->hasEmptyQuads) {
            const size_t count = mesh->quads.size();
            const size_t count = mesh->quads.size();
            for (size_t i = 0; i < count; i++) {
            for (size_t i = 0; i < count; i++) {
                Rect bounds = mesh->quads.itemAt(i);
                const Rect& bounds = mesh->quads.itemAt(i);
                if (pureTranslate) {
                if (pureTranslate) {
                    const float x = (int) floorf(bounds.left + 0.5f);
                    const float x = (int) floorf(bounds.left + 0.5f);
                    const float y = (int) floorf(bounds.top + 0.5f);
                    const float y = (int) floorf(bounds.top + 0.5f);
                    dirtyLayer(x, y, x + bounds.getWidth(), y + bounds.getBottom(),
                    dirtyLayer(x, y, x + bounds.getWidth(), y + bounds.getHeight(),
                            *mSnapshot->transform);
                            *mSnapshot->transform);
                } else {
                } else {
                    dirtyLayer(bounds.left, bounds.top, bounds.right, bounds.bottom,
                    dirtyLayer(bounds.left, bounds.top, bounds.right, bounds.bottom,
+4 −4
Original line number Original line Diff line number Diff line
@@ -35,7 +35,7 @@ Patch::Patch(const uint32_t xCount, const uint32_t yCount, const int8_t emptyQua
        mXCount(xCount), mYCount(yCount), mEmptyQuads(emptyQuads) {
        mXCount(xCount), mYCount(yCount), mEmptyQuads(emptyQuads) {
    // Initialized with the maximum number of vertices we will need
    // Initialized with the maximum number of vertices we will need
    // 2 triangles per patch, 3 vertices per triangle
    // 2 triangles per patch, 3 vertices per triangle
    const int maxVertices = ((xCount + 1) * (yCount + 1) - emptyQuads) * 2 * 3;
    uint32_t maxVertices = ((xCount + 1) * (yCount + 1) - emptyQuads) * 2 * 3;
    mVertices = new TextureVertex[maxVertices];
    mVertices = new TextureVertex[maxVertices];
    mUploaded = false;
    mUploaded = false;


@@ -160,7 +160,7 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight,
        float y2 = 0.0f;
        float y2 = 0.0f;
        if (i & 1) {
        if (i & 1) {
            const float segment = stepY - previousStepY;
            const float segment = stepY - previousStepY;
            y2 = y1 + segment * stretchY;
            y2 = y1 + floorf(segment * stretchY + 0.5f);
        } else {
        } else {
            y2 = y1 + stepY - previousStepY;
            y2 = y1 + stepY - previousStepY;
        }
        }
@@ -206,7 +206,7 @@ void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, fl
        float x2 = 0.0f;
        float x2 = 0.0f;
        if (i & 1) {
        if (i & 1) {
            const float segment = stepX - previousStepX;
            const float segment = stepX - previousStepX;
            x2 = x1 + segment * stretchX;
            x2 = x1 + floorf(segment * stretchX + 0.5f);
        } else {
        } else {
            x2 = x1 + stepX - previousStepX;
            x2 = x1 + stepX - previousStepX;
        }
        }
@@ -226,7 +226,7 @@ void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, fl
void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
            float u1, float v1, float u2, float v2, uint32_t& quadCount) {
            float u1, float v1, float u2, float v2, uint32_t& quadCount) {
    const uint32_t oldQuadCount = quadCount;
    const uint32_t oldQuadCount = quadCount;
    const bool valid = fabs(x2 - x1) > 0.9999f && fabs(y2 - y1) > 0.9999f;
    const bool valid = x2 - x1 > 0.9999f && y2 - y1 > 0.9999f;
    if (valid) {
    if (valid) {
        quadCount++;
        quadCount++;
    }
    }
+0 −2
Original line number Original line Diff line number Diff line
@@ -52,9 +52,7 @@ struct Patch {
    GLuint meshBuffer;
    GLuint meshBuffer;
    uint32_t verticesCount;
    uint32_t verticesCount;
    bool hasEmptyQuads;
    bool hasEmptyQuads;
#if RENDER_LAYERS_AS_REGIONS
    Vector<Rect> quads;
    Vector<Rect> quads;
#endif


private:
private:
    TextureVertex* mVertices;
    TextureVertex* mVertices;