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

Commit a9f883c6 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Traverse all layers to check if parent exists to add child layer."

parents 4fe5ade7 c9674336
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -2777,7 +2777,14 @@ status_t SurfaceFlinger::addClientLayer(const sp<Client>& client,
        if (parent == nullptr) {
            mCurrentState.layersSortedByZ.add(lbc);
        } else {
            if (mCurrentState.layersSortedByZ.indexOf(parent) < 0) {
            bool found = false;
            mCurrentState.traverseInZOrder([&](Layer* layer) {
                if (layer == parent.get()) {
                    found = true;
                }
            });

            if (!found) {
                ALOGE("addClientLayer called with a removed parent");
                return NAME_NOT_FOUND;
            }
+15 −0
Original line number Diff line number Diff line
@@ -1152,4 +1152,19 @@ TEST_F(ChildLayerTest, ReparentChild) {
    }
}

TEST_F(ChildLayerTest, NestedChildren) {
    sp<SurfaceControl> grandchild = mComposerClient->createSurface(
        String8("Grandchild surface"),
        10, 10, PIXEL_FORMAT_RGBA_8888,
        0, mChild.get());
    fillSurfaceRGBA8(grandchild, 50, 50, 50);

    {
        ScreenCapture::captureScreen(&mCapture);
        // Expect the grandchild to begin at 64, 64 because it's a child of mChild layer
        // which begins at 64, 64
        mCapture->checkPixel(64, 64, 50, 50, 50);
    }
}

}