Don't force client composition when rounded corners are cached

Also tweak client composition summary characters so that all composition types correspond to a unique character.

Example with a few freeform windows open
Before: Layers: 19 [b:brrrr]r[R:rrrrrr]R[R:bbb]
After:  Layers: 19 [b:brrrr]r[r:rrrrrr]R[r:bbb]
There are 2 fewer client composited layers.

See go/shadow-caching for more examples.

Bug: 391428079
Test: Open a few freeform windows and take a perfetto trace. Ensure layers with rounded corners are being
Flag: EXEMPT bug fix
Change-Id: I88752bd6e03f531d3c7ed004cc085a255c4dc67c
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayer.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayer.h
index 0063eee..a1434f2 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayer.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayer.h
@@ -104,7 +104,7 @@
     void detectDisallowedCompositionTypeChange(
             aidl::android::hardware::graphics::composer3::Composition from,
             aidl::android::hardware::graphics::composer3::Composition to) const;
-    bool isClientCompositionForced(bool isPeekingThrough) const;
+    bool isClientCompositionForced(bool isPeekingThrough, bool isCached) const;
     void updateLuts(const LayerFECompositionState&,
                     const std::optional<std::vector<std::optional<LutProperties>>>& properties);
 };
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index 9d67122..d89b52d 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -865,7 +865,8 @@
                                             bool isPeekingThrough, bool skipLayer) {
     auto& outputDependentState = editState();
 
-    if (isClientCompositionForced(isPeekingThrough)) {
+    bool isCached = !skipLayer && outputDependentState.overrideInfo.buffer;
+    if (isClientCompositionForced(isPeekingThrough, isCached)) {
         // If we are forcing client composition, we need to tell the HWC
         requestedCompositionType = Composition::CLIENT;
     }
@@ -955,9 +956,12 @@
     }
 }
 
-bool OutputLayer::isClientCompositionForced(bool isPeekingThrough) const {
+bool OutputLayer::isClientCompositionForced(bool isPeekingThrough, bool isCached) const {
+    // If this layer was flattened into a CachedSet then it is not necessary for
+    // the GPU to compose it.
+    bool requiresClientDrawnRoundedCorners = !isCached && getLayerFE().hasRoundedCorners();
     return getState().forceClientComposition ||
-            (!isPeekingThrough && getLayerFE().hasRoundedCorners());
+            (!isPeekingThrough && requiresClientDrawnRoundedCorners);
 }
 
 void OutputLayer::applyDeviceCompositionTypeChange(Composition compositionType) {
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
index 839bd79..1514340 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
@@ -544,7 +544,7 @@
         case Composition::INVALID:
             return 'i';
         case Composition::SOLID_COLOR:
-            return 'c';
+            return 'e';
         case Composition::CURSOR:
             return 'u';
         case Composition::SIDEBAND:
@@ -552,7 +552,7 @@
         case Composition::DISPLAY_DECORATION:
             return 'a';
         case Composition::REFRESH_RATE_INDICATOR:
-            return 'r';
+            return 'f';
         case Composition::CLIENT:
         case Composition::DEVICE:
             break;