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

Commit 89561e6e authored by sergeyv's avatar sergeyv
Browse files

HWUI: Fix snapping in path rendering

bug:30444274
Change-Id: Ib10058659af47625b366c26e0b872fa3f1854cd0
parent d93b9bde
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -127,8 +127,8 @@ static void computePathBounds(const SkPath* path, const SkPaint* paint, PathText
    const float pathWidth = std::max(bounds.width(), 1.0f);
    const float pathHeight = std::max(bounds.height(), 1.0f);

    texture->left = bounds.fLeft;
    texture->top = bounds.fTop;
    texture->left = floorf(bounds.fLeft);
    texture->top = floorf(bounds.fTop);

    texture->offset = (int) floorf(std::max(paint->getStrokeWidth(), 1.0f) * 1.5f + 0.5f);

+15 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@

#include <SkBlurDrawLooper.h>
#include <SkDashPathEffect.h>
#include <SkPath.h>

using namespace android::uirenderer;

@@ -273,3 +274,17 @@ RENDERTHREAD_TEST(BakedOpDispatcher, layerUpdateProperties) {
        }
    }
}

RENDERTHREAD_TEST(BakedOpDispatcher, pathTextureSnapping) {
    Rect bounds(10, 15, 20, 25);
    SkPaint paint;
    SkPath path;
    path.addRect(SkRect::MakeXYWH(1.5, 3.8, 100, 90));
    PathOp op(bounds, Matrix4::identity(), nullptr, &paint, &path);
    testUnmergedGlopDispatch(renderThread, &op, [] (const Glop& glop) {
        auto texture = glop.fill.texture.texture;
        ASSERT_NE(nullptr, texture);
        EXPECT_EQ(1, reinterpret_cast<PathTexture*>(texture)->left);
        EXPECT_EQ(3, reinterpret_cast<PathTexture*>(texture)->top);
    });
}
 No newline at end of file