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

Commit b1154d14 authored by chaviw's avatar chaviw
Browse files

Compute crop using all ancestors, not just immediate parent

The current computeCrop function only handles intersecting with
the parent's crop and not traversing to the top most parent. This change
will recurse and intersect all the ancestor's crop with the current
layer's crop.

Test: Created a parent layer several layer's above the current layer that
had a crop. Before, the content would stretch. With the change, the
content is the correct size.

Change-Id: I592e0afdfc9db574c5ccc79aacedfbd42357c8f7
parent cd8ad332
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -546,6 +546,13 @@ Rect Layer::computeInitialCrop(const sp<const DisplayDevice>& hw) const {
            activeCrop.clear();
        }
    }

    const auto& p = mDrawingParent.promote();
    if (p != nullptr) {
        auto parentCrop = p->computeInitialCrop(hw);
        activeCrop.intersect(parentCrop, &activeCrop);
    }

    return activeCrop;
}

@@ -559,11 +566,6 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {

    // Screen space to make reduction to parent crop clearer.
    Rect activeCrop = computeInitialCrop(hw);
    const auto& p = mDrawingParent.promote();
    if (p != nullptr) {
        auto parentCrop = p->computeInitialCrop(hw);
        activeCrop.intersect(parentCrop, &activeCrop);
    }
    Transform t = getTransform();
    // Back to layer space to work with the content crop.
    activeCrop = t.inverse().transform(activeCrop);