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

Commit 92a5d4b9 authored by sergeyv's avatar sergeyv
Browse files

Stop always set OffsetByFudgeFactor in renderVertexBuffer

bug:27857128
Change-Id: Id92e0a5790b14f76cfa8bb38e8b11ce649775da0
parent 2faac0d7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -344,7 +344,8 @@ static void renderVertexBuffer(BakedOpRenderer& renderer, const BakedOpState& st
        const SkPaint& paint, int vertexBufferRenderFlags) {
    if (CC_LIKELY(vertexBuffer.getVertexCount())) {
        bool shadowInterp = vertexBufferRenderFlags & VertexBufferRenderFlags::ShadowInterp;
        const int transformFlags = TransformFlags::OffsetByFudgeFactor;
        const int transformFlags = vertexBufferRenderFlags & VertexBufferRenderFlags::Offset
                ? TransformFlags::OffsetByFudgeFactor : 0;
        Glop glop;
        GlopBuilder(renderer.renderState(), renderer.caches(), &glop)
                .setRoundRectClipState(state.roundRectClipState)
+34 −0
Original line number Diff line number Diff line
@@ -109,3 +109,37 @@ RENDERTHREAD_TEST(BakedOpDispatcher, onLayerOp_bufferless) {
        EXPECT_FLOAT_EQ(128 / 255.0f, glop.fill.color.a) << "Rect quad should use op alpha";
    });
}

static int getGlopTransformFlags(renderthread::RenderThread& renderThread, RecordedOp* op) {
    int result = 0;
    testUnmergedGlopDispatch(renderThread, op, [&result] (const Glop& glop) {
        result = glop.transform.transformFlags;
    });
    return result;
}

RENDERTHREAD_TEST(BakedOpDispatcher, offsetFlags) {
    Rect bounds(10, 15, 20, 25);
    SkPaint paint;
    SkPaint aaPaint;
    aaPaint.setAntiAlias(true);

    RoundRectOp roundRectOp(bounds, Matrix4::identity(), nullptr, &paint, 0, 270);
    EXPECT_EQ(TransformFlags::None, getGlopTransformFlags(renderThread, &roundRectOp))
            << "Expect no offset for round rect op.";

    const float points[4] = {0.5, 0.5, 1.0, 1.0};
    PointsOp antiAliasedPointsOp(bounds, Matrix4::identity(), nullptr, &aaPaint, points, 4);
    EXPECT_EQ(TransformFlags::None, getGlopTransformFlags(renderThread, &antiAliasedPointsOp))
                << "Expect no offset for AA points.";
    PointsOp pointsOp(bounds, Matrix4::identity(), nullptr, &paint, points, 4);
    EXPECT_EQ(TransformFlags::OffsetByFudgeFactor, getGlopTransformFlags(renderThread, &pointsOp))
            << "Expect an offset for non-AA points.";

    LinesOp antiAliasedLinesOp(bounds, Matrix4::identity(), nullptr, &aaPaint, points, 4);
    EXPECT_EQ(TransformFlags::None, getGlopTransformFlags(renderThread, &antiAliasedLinesOp))
            << "Expect no offset for AA lines.";
    LinesOp linesOp(bounds, Matrix4::identity(), nullptr, &paint, points, 4);
    EXPECT_EQ(TransformFlags::OffsetByFudgeFactor, getGlopTransformFlags(renderThread, &linesOp))
            << "Expect an offset for non-AA lines.";
}
 No newline at end of file