2727#include < common/FlagManager.h>
2828#include < common/trace.h>
2929#include < ftl/small_map.h>
30+ #include < math/vec2.h>
3031#include < ui/DisplayMap.h>
3132#include < ui/FloatRect.h>
3233
@@ -934,7 +935,8 @@ void LayerSnapshotBuilder::updateSnapshot(LayerSnapshot& snapshot, const Args& a
934935
935936 if (forceUpdate || snapshot.clientChanges & layer_state_t ::eCornerRadiusChanged ||
936937 snapshot.changes .any (RequestedLayerState::Changes::Geometry |
937- RequestedLayerState::Changes::BufferUsageFlags)) {
938+ RequestedLayerState::Changes::BufferUsageFlags) ||
939+ snapshot.clientChanges & layer_state_t ::eClientDrawnCornerRadiusChanged) {
938940 updateRoundedCorner (snapshot, requested, parentSnapshot, args);
939941 }
940942
@@ -974,7 +976,7 @@ void LayerSnapshotBuilder::updateRoundedCorner(LayerSnapshot& snapshot,
974976 }
975977 snapshot.roundedCorner = RoundedCornerState ();
976978 RoundedCornerState parentRoundedCorner;
977- if (parentSnapshot.roundedCorner .hasRoundedCorners ()) {
979+ if (parentSnapshot.roundedCorner .hasRequestedRadius ()) {
978980 parentRoundedCorner = parentSnapshot.roundedCorner ;
979981 ui::Transform t = snapshot.localTransform .inverse ();
980982 parentRoundedCorner.cropRect = t.transform (parentRoundedCorner.cropRect );
@@ -983,10 +985,16 @@ void LayerSnapshotBuilder::updateRoundedCorner(LayerSnapshot& snapshot,
983985 }
984986
985987 FloatRect layerCropRect = snapshot.croppedBufferSize ;
986- const vec2 radius (requested.cornerRadius , requested.cornerRadius );
987- RoundedCornerState layerSettings (layerCropRect, radius);
988- const bool layerSettingsValid = layerSettings.hasRoundedCorners () && !layerCropRect.isEmpty ();
989- const bool parentRoundedCornerValid = parentRoundedCorner.hasRoundedCorners ();
988+ const vec2 requestedRadius (requested.cornerRadius , requested.cornerRadius );
989+ const vec2 clientDrawnRadius (requested.clientDrawnCornerRadius ,
990+ requested.clientDrawnCornerRadius );
991+ RoundedCornerState layerSettings;
992+ layerSettings.cropRect = layerCropRect;
993+ layerSettings.requestedRadius = requestedRadius;
994+ layerSettings.clientDrawnRadius = clientDrawnRadius;
995+
996+ const bool layerSettingsValid = layerSettings.hasRequestedRadius () && !layerCropRect.isEmpty ();
997+ const bool parentRoundedCornerValid = parentRoundedCorner.hasRequestedRadius ();
990998 if (layerSettingsValid && parentRoundedCornerValid) {
991999 // If the parent and the layer have rounded corner settings, use the parent settings if
9921000 // the parent crop is entirely inside the layer crop. This has limitations and cause
@@ -1004,6 +1012,14 @@ void LayerSnapshotBuilder::updateRoundedCorner(LayerSnapshot& snapshot,
10041012 } else if (parentRoundedCornerValid) {
10051013 snapshot.roundedCorner = parentRoundedCorner;
10061014 }
1015+
1016+ if (snapshot.roundedCorner .requestedRadius .x == requested.clientDrawnCornerRadius ) {
1017+ // If the client drawn radius matches the requested radius, then surfaceflinger
1018+ // does not need to draw rounded corners for this layer
1019+ snapshot.roundedCorner .radius = vec2 (0 .f , 0 .f );
1020+ } else {
1021+ snapshot.roundedCorner .radius = snapshot.roundedCorner .requestedRadius ;
1022+ }
10071023}
10081024
10091025/* *
0 commit comments