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

Commit 46813558 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge \"Fix savelayer rounding\" into nyc-mr1-dev am: 754ea612" into nyc-mr1-dev-plus-aosp

parents 568f654a b1d6dd21
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -127,7 +127,8 @@ int RecordingCanvas::saveLayer(float left, float top, float right, float bottom,
    // operations will be able to store and restore the current clip and transform info, and
    // quick rejection will be correct (for display lists)

    const Rect unmappedBounds(left, top, right, bottom);
    Rect unmappedBounds(left, top, right, bottom);
    unmappedBounds.roundOut();

    // determine clipped bounds relative to previous viewport.
    Rect visibleBounds = unmappedBounds;
+30 −0
Original line number Diff line number Diff line
@@ -340,6 +340,36 @@ TEST(RecordingCanvas, saveLayer_simple) {
    EXPECT_EQ(3, count);
}

TEST(RecordingCanvas, saveLayer_rounding) {
    auto dl = TestUtils::createDisplayList<RecordingCanvas>(100, 100, [](RecordingCanvas& canvas) {
            canvas.saveLayerAlpha(10.25f, 10.75f, 89.25f, 89.75f, 128, SaveFlags::ClipToLayer);
            canvas.drawRect(20, 20, 80, 80, SkPaint());
            canvas.restore();
        });
        int count = 0;
        playbackOps(*dl, [&count](const RecordedOp& op) {
            Matrix4 expectedMatrix;
            switch(count++) {
            case 0:
                EXPECT_EQ(RecordedOpId::BeginLayerOp, op.opId);
                EXPECT_EQ(Rect(10, 10, 90, 90), op.unmappedBounds) << "Expect bounds rounded out";
                break;
            case 1:
                EXPECT_EQ(RecordedOpId::RectOp, op.opId);
                expectedMatrix.loadTranslate(-10, -10, 0);
                EXPECT_MATRIX_APPROX_EQ(expectedMatrix, op.localMatrix) << "Expect rounded offset";
                break;
            case 2:
                EXPECT_EQ(RecordedOpId::EndLayerOp, op.opId);
                // Don't bother asserting recording state data - it's not used
                break;
            default:
                ADD_FAILURE();
            }
        });
        EXPECT_EQ(3, count);
}

TEST(RecordingCanvas, saveLayer_missingRestore) {
    auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [](RecordingCanvas& canvas) {
        canvas.saveLayerAlpha(0, 0, 200, 200, 128, SaveFlags::ClipToLayer);