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

Commit 41b08b5e authored by Robert Carr's avatar Robert Carr
Browse files

SurfaceFlinger: Fix final cropping of child layers.

Straightforward mistake documented by the test case. Not sure how it
made it this long.

Test: Included in Transaction_test.cpp. Manual from bug. go/wm-smoke.
Bug: 37511473
Change-Id: I87a57825cca879c5519fe72fef199168f7c23479
parent 98b0fd5f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -399,6 +399,10 @@ Rect Layer::computeScreenBounds(bool reduceTransparentRegion) const {
    Transform t = getTransform();
    win = t.transform(win);

    if (!s.finalCrop.isEmpty()) {
        win.intersect(s.finalCrop, &win);
    }

    const sp<Layer>& p = getParent();
    // Now we need to calculate the parent bounds, so we can clip ourselves to those.
    // When calculating the parent bounds for purposes of clipping,
+32 −0
Original line number Diff line number Diff line
@@ -834,6 +834,38 @@ TEST_F(ChildLayerTest, ChildLayerPositioning) {
    }
}

TEST_F(ChildLayerTest, ChildLayerCropping) {
    SurfaceComposerClient::openGlobalTransaction();
    mChild->show();
    mChild->setPosition(0, 0);
    mFGSurfaceControl->setPosition(0, 0);
    mFGSurfaceControl->setCrop(Rect(0, 0, 5, 5));
    SurfaceComposerClient::closeGlobalTransaction(true);

    {
        ScreenCapture::captureScreen(&mCapture);
        mCapture->expectChildColor(0, 0);
        mCapture->expectChildColor(4, 4);
        mCapture->expectBGColor(5, 5);
    }
}

TEST_F(ChildLayerTest, ChildLayerFinalCropping) {
    SurfaceComposerClient::openGlobalTransaction();
    mChild->show();
    mChild->setPosition(0, 0);
    mFGSurfaceControl->setPosition(0, 0);
    mFGSurfaceControl->setFinalCrop(Rect(0, 0, 5, 5));
    SurfaceComposerClient::closeGlobalTransaction(true);

    {
        ScreenCapture::captureScreen(&mCapture);
        mCapture->expectChildColor(0, 0);
        mCapture->expectChildColor(4, 4);
        mCapture->expectBGColor(5, 5);
    }
}

TEST_F(ChildLayerTest, ChildLayerConstraints) {
    SurfaceComposerClient::openGlobalTransaction();
    mChild->show();