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

Commit 0c632fa9 authored by Peiyong Lin's avatar Peiyong Lin Committed by Android (Google) Code Review
Browse files

Merge "Revert "[Rounded Corner] Handle ContainerLayer correctly.""

parents c5429c8d 97067b0e
Loading
Loading
Loading
Loading
+0 −28
Original line number Diff line number Diff line
@@ -42,32 +42,4 @@ bool ContainerLayer::canReceiveInput() const {
void ContainerLayer::setPerFrameData(const sp<const DisplayDevice>&, const ui::Transform&,
                                     const Rect&, int32_t, const ui::Dataspace) {}

Layer::RoundedCornerState ContainerLayer::getRoundedCornerStateInternal(
        const FloatRect bounds) const {
    const auto& p = mDrawingParent.promote();
    if (p != nullptr) {
        RoundedCornerState parentState = p->getRoundedCornerStateInternal(bounds);
        if (parentState.radius > 0) {
            ui::Transform t = getActiveTransform(getDrawingState());
            t = t.inverse();
            parentState.cropRect = t.transform(parentState.cropRect);
            // The rounded corners shader only accepts 1 corner radius for performance reasons,
            // but a transform matrix can define horizontal and vertical scales.
            // Let's take the average between both of them and pass into the shader, practically we
            // never do this type of transformation on windows anyway.
            parentState.radius *= (t[0][0] + t[1][1]) / 2.0f;
            return parentState;
        }
    }
    const float radius = getDrawingState().cornerRadius;
    if (radius > 0) {
        const Rect crop = getCrop(getDrawingState());
        if (!crop.isEmpty()) {
            return RoundedCornerState(bounds.intersect(crop.toFloatRect()), radius);
        }
        return RoundedCornerState(bounds, radius);
    }
    return RoundedCornerState();
}

} // namespace android
+0 −1
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ public:
    bool isCreatedFromMainThread() const override { return true; }

    bool onPreComposition(nsecs_t /*refreshStartTime*/) override { return false; }
    Layer::RoundedCornerState getRoundedCornerStateInternal(const FloatRect bounds) const override;

protected:
    bool prepareClientLayer(const RenderArea& renderArea, const Region& clip,
+3 −4
Original line number Diff line number Diff line
@@ -1791,10 +1791,10 @@ Layer::RoundedCornerState Layer::getRoundedCornerState() const {
    return getRoundedCornerStateInternal(mSourceBounds);
}

Layer::RoundedCornerState Layer::getRoundedCornerStateInternal(const FloatRect) const {
Layer::RoundedCornerState Layer::getRoundedCornerStateInternal(const FloatRect bounds) const {
    const auto& p = mDrawingParent.promote();
    if (p != nullptr) {
        RoundedCornerState parentState = p->getRoundedCornerStateInternal(mSourceBounds);
        RoundedCornerState parentState = p->getRoundedCornerStateInternal(bounds);
        if (parentState.radius > 0) {
            ui::Transform t = getActiveTransform(getDrawingState());
            t = t.inverse();
@@ -1809,8 +1809,7 @@ Layer::RoundedCornerState Layer::getRoundedCornerStateInternal(const FloatRect)
    }
    const float radius = getDrawingState().cornerRadius;
    return radius > 0
            ? RoundedCornerState(mSourceBounds.intersect(getCrop(getDrawingState()).toFloatRect()),
                                 radius)
            ? RoundedCornerState(bounds.intersect(getCrop(getDrawingState()).toFloatRect()), radius)
            : RoundedCornerState();
}

+3 −1
Original line number Diff line number Diff line
@@ -452,13 +452,13 @@ public:

    virtual void setPostTime(nsecs_t /*postTime*/) {}
    virtual void setDesiredPresentTime(nsecs_t /*desiredPresentTime*/) {}
    virtual RoundedCornerState getRoundedCornerStateInternal(const FloatRect bounds) const;

protected:
    virtual bool prepareClientLayer(const RenderArea& renderArea, const Region& clip,
                                    bool useIdentityTransform, Region& clearRegion,
                                    const bool supportProtectedContent,
                                    renderengine::LayerSettings& layer);

public:
    /*
     * compositionengine::LayerFE overrides
@@ -908,6 +908,8 @@ private:
     */
    Rect getCroppedBufferSize(const Layer::State& s) const;

    RoundedCornerState getRoundedCornerStateInternal(const FloatRect bounds) const;

    // Cached properties computed from drawing state
    // Effective transform taking into account parent transforms and any parent scaling.
    ui::Transform mEffectiveTransform;