Revert "[Rounded Corner] Handle ContainerLayer correctly."
This reverts commit 05eb5c476f386e1629f1a8dd1514a7c945eb30c1.
Reason for revert: Results in weird crop issues
Below is original commit message:
Previously we always use the source bounds of the child layer, this is correct
until two layers overlapped and form the hierachical structure. In this case we
need to use the source bounds of the parent, however, source bounds on
ContainerLayer usually doesn't make sense, in that case we need to use the
child source bounds.
BUG: b/125916918, b/129062310
Test: Test: Build, flash and boot. Verify with window transition for Youtube and Chrome.
BUG: b/129540451
Change-Id: I0d0bfa45082e5513840555da5575b1a49521905f
diff --git a/services/surfaceflinger/ContainerLayer.cpp b/services/surfaceflinger/ContainerLayer.cpp
index ad08a92..7927fa9 100644
--- a/services/surfaceflinger/ContainerLayer.cpp
+++ b/services/surfaceflinger/ContainerLayer.cpp
@@ -42,32 +42,4 @@
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
diff --git a/services/surfaceflinger/ContainerLayer.h b/services/surfaceflinger/ContainerLayer.h
index cd8e722..7222a3e 100644
--- a/services/surfaceflinger/ContainerLayer.h
+++ b/services/surfaceflinger/ContainerLayer.h
@@ -40,7 +40,6 @@
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,
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 73f27e4..898d37e 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1791,10 +1791,10 @@
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 @@
}
const float radius = getDrawingState().cornerRadius;
return radius > 0
- ? RoundedCornerState(mSourceBounds.intersect(getCrop(getDrawingState()).toFloatRect()),
- radius)
+ ? RoundedCornerState(bounds.intersect(getCrop(getDrawingState()).toFloatRect()), radius)
: RoundedCornerState();
}
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index b9dc7ec..83ff3b6 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -452,13 +452,13 @@
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 @@
*/
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;