2525#include < common/FlagManager.h>
2626#include < common/trace.h>
2727#include < ftl/small_map.h>
28+ #include < math/vec2.h>
2829#include < ui/DisplayMap.h>
2930#include < ui/FloatRect.h>
3031
@@ -932,7 +933,8 @@ void LayerSnapshotBuilder::updateSnapshot(LayerSnapshot& snapshot, const Args& a
932933
933934 if (forceUpdate || snapshot.clientChanges & layer_state_t ::eCornerRadiusChanged ||
934935 snapshot.changes .any (RequestedLayerState::Changes::Geometry |
935- RequestedLayerState::Changes::BufferUsageFlags)) {
936+ RequestedLayerState::Changes::BufferUsageFlags) ||
937+ snapshot.clientChanges & layer_state_t ::eClientDrawnCornerRadiusChanged) {
936938 updateRoundedCorner (snapshot, requested, parentSnapshot, args);
937939 }
938940
@@ -972,7 +974,7 @@ void LayerSnapshotBuilder::updateRoundedCorner(LayerSnapshot& snapshot,
972974 }
973975 snapshot.roundedCorner = RoundedCornerState ();
974976 RoundedCornerState parentRoundedCorner;
975- if (parentSnapshot.roundedCorner .hasRoundedCorners ()) {
977+ if (parentSnapshot.roundedCorner .hasRequestedRadius ()) {
976978 parentRoundedCorner = parentSnapshot.roundedCorner ;
977979 ui::Transform t = snapshot.localTransform .inverse ();
978980 parentRoundedCorner.cropRect = t.transform (parentRoundedCorner.cropRect );
@@ -981,10 +983,16 @@ void LayerSnapshotBuilder::updateRoundedCorner(LayerSnapshot& snapshot,
981983 }
982984
983985 FloatRect layerCropRect = snapshot.croppedBufferSize ;
984- const vec2 radius (requested.cornerRadius , requested.cornerRadius );
985- RoundedCornerState layerSettings (layerCropRect, radius);
986- const bool layerSettingsValid = layerSettings.hasRoundedCorners () && !layerCropRect.isEmpty ();
987- const bool parentRoundedCornerValid = parentRoundedCorner.hasRoundedCorners ();
986+ const vec2 requestedRadius (requested.cornerRadius , requested.cornerRadius );
987+ const vec2 clientDrawnRadius (requested.clientDrawnCornerRadius ,
988+ requested.clientDrawnCornerRadius );
989+ RoundedCornerState layerSettings;
990+ layerSettings.cropRect = layerCropRect;
991+ layerSettings.requestedRadius = requestedRadius;
992+ layerSettings.clientDrawnRadius = clientDrawnRadius;
993+
994+ const bool layerSettingsValid = layerSettings.hasRequestedRadius () && !layerCropRect.isEmpty ();
995+ const bool parentRoundedCornerValid = parentRoundedCorner.hasRequestedRadius ();
988996 if (layerSettingsValid && parentRoundedCornerValid) {
989997 // If the parent and the layer have rounded corner settings, use the parent settings if
990998 // the parent crop is entirely inside the layer crop. This has limitations and cause
@@ -1002,6 +1010,14 @@ void LayerSnapshotBuilder::updateRoundedCorner(LayerSnapshot& snapshot,
10021010 } else if (parentRoundedCornerValid) {
10031011 snapshot.roundedCorner = parentRoundedCorner;
10041012 }
1013+
1014+ if (snapshot.roundedCorner .requestedRadius .x == requested.clientDrawnCornerRadius ) {
1015+ // If the client drawn radius matches the requested radius, then surfaceflinger
1016+ // does not need to draw rounded corners for this layer
1017+ snapshot.roundedCorner .radius = vec2 (0 .f , 0 .f );
1018+ } else {
1019+ snapshot.roundedCorner .radius = snapshot.roundedCorner .requestedRadius ;
1020+ }
10051021}
10061022
10071023/* *
0 commit comments