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

Commit 420d6559 authored by Chris Craik's avatar Chris Craik
Browse files

Fix shadow bounds calculation

Change-Id: I78b6aa91d62c3c4838ffc80b380604c7863e8467
parent f158b49c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -71,7 +71,6 @@ ResolvedRenderState::ResolvedRenderState(LinearAllocator& allocator, Snapshot& s
    clipState = snapshot.mutateClipArea().serializeClip(allocator);
    LOG_ALWAYS_FATAL_IF(!clipState, "clipState required");
    clippedBounds = clipState->rect;
    transform.mapRect(clippedBounds);
    clipSideFlags = OpClipSideFlags::Full;
}

+8 −2
Original line number Diff line number Diff line
@@ -199,9 +199,12 @@ TEST(BakedOpState, tryConstruct) {
}

TEST(BakedOpState, tryShadowOpConstruct) {
    Matrix4 translate10x20;
    translate10x20.loadTranslate(10, 20, 0);

    LinearAllocator allocator;
    {
        auto snapshot = TestUtils::makeSnapshot(Matrix4::identity(), Rect()); // Note: empty clip
        auto snapshot = TestUtils::makeSnapshot(translate10x20, Rect()); // Note: empty clip
        BakedOpState* bakedState = BakedOpState::tryShadowOpConstruct(allocator, *snapshot, (ShadowOp*)0x1234);

        EXPECT_EQ(nullptr, bakedState) << "op should be rejected by clip, so not constructed";
@@ -209,11 +212,14 @@ TEST(BakedOpState, tryShadowOpConstruct) {
                "since op is quick rejected based on snapshot clip";
    }
    {
        auto snapshot = TestUtils::makeSnapshot(Matrix4::identity(), Rect(100, 200));
        auto snapshot = TestUtils::makeSnapshot(translate10x20, Rect(100, 200));
        BakedOpState* bakedState = BakedOpState::tryShadowOpConstruct(allocator, *snapshot, (ShadowOp*)0x1234);

        ASSERT_NE(nullptr, bakedState) << "NOT rejected by clip, so op should be constructed";
        EXPECT_LE(64u, allocator.usedSize()) << "relatively large alloc for non-rejected op";

        EXPECT_MATRIX_APPROX_EQ(translate10x20, bakedState->computedState.transform);
        EXPECT_EQ(Rect(100, 200), bakedState->computedState.clippedBounds);
    }
}