• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
18 #undef LOG_TAG
19 #define LOG_TAG "SurfaceFlinger"
20 
21 #include <PowerAdvisor/Workload.h>
22 #include <aidl/android/hardware/graphics/composer3/Composition.h>
23 #include <gui/LayerState.h>
24 
25 #include "Layer.h"
26 #include "LayerSnapshot.h"
27 
28 namespace android::surfaceflinger::frontend {
29 
30 using namespace ftl::flag_operators;
31 using namespace aidl::android::hardware::graphics::composer3;
32 
33 namespace {
34 
updateSurfaceDamage(const RequestedLayerState & requested,bool hasReadyFrame,bool forceFullDamage,Region & outSurfaceDamageRegion)35 void updateSurfaceDamage(const RequestedLayerState& requested, bool hasReadyFrame,
36                          bool forceFullDamage, Region& outSurfaceDamageRegion) {
37     if (!hasReadyFrame) {
38         outSurfaceDamageRegion.clear();
39         return;
40     }
41     if (forceFullDamage) {
42         outSurfaceDamageRegion = Region::INVALID_REGION;
43     } else {
44         outSurfaceDamageRegion = requested.getSurfaceDamageRegion();
45     }
46 }
47 
operator <<(std::ostream & os,const ui::Transform & transform)48 std::ostream& operator<<(std::ostream& os, const ui::Transform& transform) {
49     const uint32_t type = transform.getType();
50     const uint32_t orientation = transform.getOrientation();
51     if (type == ui::Transform::IDENTITY) {
52         return os;
53     }
54 
55     if (type & ui::Transform::UNKNOWN) {
56         std::string out;
57         transform.dump(out, "", "");
58         os << out;
59         return os;
60     }
61 
62     if (type & ui::Transform::ROTATE) {
63         switch (orientation) {
64             case ui::Transform::ROT_0:
65                 os << "ROT_0";
66                 break;
67             case ui::Transform::FLIP_H:
68                 os << "FLIP_H";
69                 break;
70             case ui::Transform::FLIP_V:
71                 os << "FLIP_V";
72                 break;
73             case ui::Transform::ROT_90:
74                 os << "ROT_90";
75                 break;
76             case ui::Transform::ROT_180:
77                 os << "ROT_180";
78                 break;
79             case ui::Transform::ROT_270:
80                 os << "ROT_270";
81                 break;
82             case ui::Transform::ROT_INVALID:
83             default:
84                 os << "ROT_INVALID";
85                 break;
86         }
87     }
88 
89     if (type & ui::Transform::SCALE) {
90         std::string out;
91         android::base::StringAppendF(&out, " scale x=%.4f y=%.4f ", transform.getScaleX(),
92                                      transform.getScaleY());
93         os << out;
94     }
95 
96     if (type & ui::Transform::TRANSLATE) {
97         std::string out;
98         android::base::StringAppendF(&out, " tx=%.4f ty=%.4f ", transform.tx(), transform.ty());
99         os << out;
100     }
101 
102     return os;
103 }
104 
105 } // namespace
106 
LayerSnapshot(const RequestedLayerState & state,const LayerHierarchy::TraversalPath & path)107 LayerSnapshot::LayerSnapshot(const RequestedLayerState& state,
108                              const LayerHierarchy::TraversalPath& path)
109       : path(path) {
110     // Provide a unique id for all snapshots.
111     // A front end layer can generate multiple snapshots if its mirrored.
112     // Additionally, if the layer is not reachable, we may choose to destroy
113     // and recreate the snapshot in which case the unique sequence id will
114     // change. The consumer shouldn't tie any lifetimes to this unique id but
115     // register a LayerLifecycleManager::ILifecycleListener or get a list of
116     // destroyed layers from LayerLifecycleManager.
117     if (path.isClone()) {
118         uniqueSequence =
119                 LayerCreationArgs::getInternalLayerId(LayerCreationArgs::sInternalSequence++);
120     } else {
121         uniqueSequence = state.id;
122     }
123     sequence = static_cast<int32_t>(state.id);
124     name = state.name;
125     debugName = state.debugName;
126     premultipliedAlpha = state.premultipliedAlpha;
127     inputInfo.name = state.name;
128     inputInfo.id = static_cast<int32_t>(uniqueSequence);
129     inputInfo.ownerUid = gui::Uid{state.ownerUid};
130     inputInfo.ownerPid = gui::Pid{state.ownerPid};
131     uid = state.ownerUid;
132     pid = state.ownerPid;
133     changes = RequestedLayerState::Changes::Created;
134     clientChanges = 0;
135     mirrorRootPath =
136             LayerHierarchy::isMirror(path.variant) ? path : LayerHierarchy::TraversalPath::ROOT;
137     reachablilty = LayerSnapshot::Reachablilty::Unreachable;
138     frameRateSelectionPriority = state.frameRateSelectionPriority;
139     layerMetadata = state.metadata;
140 }
141 
142 // As documented in libhardware header, formats in the range
143 // 0x100 - 0x1FF are specific to the HAL implementation, and
144 // are known to have no alpha channel
145 // TODO: move definition for device-specific range into
146 // hardware.h, instead of using hard-coded values here.
147 #define HARDWARE_IS_DEVICE_FORMAT(f) ((f) >= 0x100 && (f) <= 0x1FF)
148 
isOpaqueFormat(PixelFormat format)149 bool LayerSnapshot::isOpaqueFormat(PixelFormat format) {
150     if (HARDWARE_IS_DEVICE_FORMAT(format)) {
151         return true;
152     }
153     switch (format) {
154         case PIXEL_FORMAT_RGBA_8888:
155         case PIXEL_FORMAT_BGRA_8888:
156         case PIXEL_FORMAT_RGBA_FP16:
157         case PIXEL_FORMAT_RGBA_1010102:
158         case PIXEL_FORMAT_R_8:
159             return false;
160     }
161     // in all other case, we have no blending (also for unknown formats)
162     return true;
163 }
164 
hasBufferOrSidebandStream() const165 bool LayerSnapshot::hasBufferOrSidebandStream() const {
166     return ((sidebandStream != nullptr) || (externalTexture != nullptr));
167 }
168 
drawShadows() const169 bool LayerSnapshot::drawShadows() const {
170     return shadowSettings.length > 0.f;
171 }
172 
fillsColor() const173 bool LayerSnapshot::fillsColor() const {
174     return !hasBufferOrSidebandStream() && color.r >= 0.0_hf && color.g >= 0.0_hf &&
175             color.b >= 0.0_hf;
176 }
177 
hasBlur() const178 bool LayerSnapshot::hasBlur() const {
179     return backgroundBlurRadius > 0 || blurRegions.size() > 0;
180 }
181 
hasOutline() const182 bool LayerSnapshot::hasOutline() const {
183     return borderSettings.strokeWidth > 0;
184 }
185 
hasEffect() const186 bool LayerSnapshot::hasEffect() const {
187     return fillsColor() || drawShadows() || hasBlur() || hasOutline();
188 }
189 
hasSomethingToDraw() const190 bool LayerSnapshot::hasSomethingToDraw() const {
191     return hasEffect() || hasBufferOrSidebandStream();
192 }
193 
isContentOpaque() const194 bool LayerSnapshot::isContentOpaque() const {
195     // if we don't have a buffer or sidebandStream yet, we're translucent regardless of the
196     // layer's opaque flag.
197     if (!hasSomethingToDraw()) {
198         return false;
199     }
200 
201     // if the layer has the opaque flag, then we're always opaque
202     if (layerOpaqueFlagSet) {
203         return true;
204     }
205 
206     // If the buffer has no alpha channel, then we are opaque
207     if (hasBufferOrSidebandStream() &&
208         isOpaqueFormat(externalTexture ? externalTexture->getPixelFormat() : PIXEL_FORMAT_NONE)) {
209         return true;
210     }
211 
212     // Lastly consider the layer opaque if drawing a color with alpha == 1.0
213     return fillsColor() && color.a == 1.0_hf;
214 }
215 
isHiddenByPolicy() const216 bool LayerSnapshot::isHiddenByPolicy() const {
217     return invalidTransform || isHiddenByPolicyFromParent || isHiddenByPolicyFromRelativeParent;
218 }
219 
getIsVisible() const220 bool LayerSnapshot::getIsVisible() const {
221     if (reachablilty != LayerSnapshot::Reachablilty::Reachable) {
222         return false;
223     }
224 
225     if (handleSkipScreenshotFlag & outputFilter.toInternalDisplay) {
226         return false;
227     }
228 
229     if (!hasSomethingToDraw()) {
230         return false;
231     }
232 
233     if (isHiddenByPolicy()) {
234         return false;
235     }
236 
237     return color.a > 0.0f || hasBlur();
238 }
239 
getIsVisibleReason() const240 std::string LayerSnapshot::getIsVisibleReason() const {
241     // not visible
242     if (reachablilty == LayerSnapshot::Reachablilty::Unreachable)
243         return "layer not reachable from root";
244     if (reachablilty == LayerSnapshot::Reachablilty::ReachableByRelativeParent)
245         return "layer only reachable via relative parent";
246     if (isHiddenByPolicyFromParent) return "hidden by parent or layer flag";
247     if (isHiddenByPolicyFromRelativeParent) return "hidden by relative parent";
248     if (handleSkipScreenshotFlag & outputFilter.toInternalDisplay) return "eLayerSkipScreenshot";
249     if (invalidTransform) return "invalidTransform";
250     if (color.a == 0.0f && !hasBlur()) return "alpha = 0 and no blur";
251     if (!hasSomethingToDraw()) return "nothing to draw";
252 
253     // visible
254     std::stringstream reason;
255     if (sidebandStream != nullptr) reason << " sidebandStream";
256     if (externalTexture != nullptr)
257         reason << " buffer=" << externalTexture->getId() << " frame=" << frameNumber;
258     if (fillsColor() || color.a > 0.0f) reason << " color{" << color << "}";
259     if (drawShadows()) reason << " shadowSettings.length=" << shadowSettings.length;
260     if (hasOutline()) reason << "borderSettings=" << borderSettings.toString();
261     if (backgroundBlurRadius > 0) reason << " backgroundBlurRadius=" << backgroundBlurRadius;
262     if (blurRegions.size() > 0) reason << " blurRegions.size()=" << blurRegions.size();
263     if (contentDirty) reason << " contentDirty";
264     return reason.str();
265 }
266 
canReceiveInput() const267 bool LayerSnapshot::canReceiveInput() const {
268     return !isHiddenByPolicy() && (!hasBufferOrSidebandStream() || color.a > 0.0f);
269 }
270 
isTransformValid(const ui::Transform & t)271 bool LayerSnapshot::isTransformValid(const ui::Transform& t) {
272     float transformDet = t.det();
273     return transformDet != 0 && !isinf(transformDet) && !isnan(transformDet);
274 }
275 
hasInputInfo() const276 bool LayerSnapshot::hasInputInfo() const {
277     return (inputInfo.token != nullptr ||
278             inputInfo.inputConfig.test(gui::WindowInfo::InputConfig::NO_INPUT_CHANNEL)) &&
279             reachablilty == Reachablilty::Reachable;
280 }
281 
getDebugString() const282 std::string LayerSnapshot::getDebugString() const {
283     std::stringstream debug;
284     debug << "Snapshot{" << path.toString() << name << " isVisible=" << isVisible << " {"
285           << getIsVisibleReason() << "} changes=" << changes.string()
286           << " layerStack=" << outputFilter.layerStack.id << " geomLayerBounds={"
287           << geomLayerBounds.left << "," << geomLayerBounds.top << "," << geomLayerBounds.bottom
288           << "," << geomLayerBounds.right << "}"
289           << " geomLayerTransform={tx=" << geomLayerTransform.tx()
290           << ",ty=" << geomLayerTransform.ty() << "}"
291           << "}";
292     if (hasInputInfo()) {
293         debug << " input{"
294               << "(" << inputInfo.inputConfig.string() << ")";
295         if (touchCropId != UNASSIGNED_LAYER_ID) debug << " touchCropId=" << touchCropId;
296         if (inputInfo.replaceTouchableRegionWithCrop) debug << " replaceTouchableRegionWithCrop";
297         auto touchableRegion = inputInfo.touchableRegion.getBounds();
298         debug << " touchableRegion={" << touchableRegion.left << "," << touchableRegion.top << ","
299               << touchableRegion.bottom << "," << touchableRegion.right << "}"
300               << "}";
301     }
302     return debug.str();
303 }
304 
operator <<(std::ostream & out,const LayerSnapshot & obj)305 std::ostream& operator<<(std::ostream& out, const LayerSnapshot& obj) {
306     out << "Layer [" << obj.path.id;
307     if (!obj.path.mirrorRootIds.empty()) {
308         out << " mirrored from ";
309         for (auto rootId : obj.path.mirrorRootIds) {
310             out << rootId << ",";
311         }
312     }
313     out << "] ";
314     if (obj.isSecure) {
315         out << "(Secure) ";
316     }
317     out << obj.name << "\n    " << (obj.isVisible ? "visible" : "invisible")
318         << " reason=" << obj.getIsVisibleReason();
319 
320     if (!obj.geomLayerBounds.isEmpty()) {
321         out << "\n    bounds={" << obj.transformedBounds.left << "," << obj.transformedBounds.top
322             << "," << obj.transformedBounds.bottom << "," << obj.transformedBounds.right << "}";
323     }
324 
325     if (obj.geomLayerTransform.getType() != ui::Transform::IDENTITY) {
326         out << " toDisplayTransform={" << obj.geomLayerTransform << "}";
327     }
328 
329     if (obj.hasInputInfo()) {
330         out << "\n    input{"
331             << "(" << obj.inputInfo.inputConfig.string() << ")";
332         if (obj.inputInfo.canOccludePresentation) out << " canOccludePresentation";
333         if (obj.touchCropId != UNASSIGNED_LAYER_ID) out << " touchCropId=" << obj.touchCropId;
334         if (obj.inputInfo.replaceTouchableRegionWithCrop) out << " replaceTouchableRegionWithCrop";
335         auto touchableRegion = obj.inputInfo.touchableRegion.getBounds();
336         out << " touchableRegion={" << touchableRegion.left << "," << touchableRegion.top << ","
337             << touchableRegion.bottom << "," << touchableRegion.right << "}"
338             << "}";
339     }
340 
341     if (obj.edgeExtensionEffect.hasEffect()) {
342         out << obj.edgeExtensionEffect;
343     }
344     return out;
345 }
346 
sourceBounds() const347 FloatRect LayerSnapshot::sourceBounds() const {
348     if (!externalTexture) {
349         return geomLayerBounds;
350     }
351     return geomBufferSize.toFloatRect();
352 }
353 
isFrontBuffered() const354 bool LayerSnapshot::isFrontBuffered() const {
355     if (!externalTexture) {
356         return false;
357     }
358 
359     return externalTexture->getUsage() & AHARDWAREBUFFER_USAGE_FRONT_BUFFER;
360 }
361 
getBlendMode(const RequestedLayerState & requested) const362 Hwc2::IComposerClient::BlendMode LayerSnapshot::getBlendMode(
363         const RequestedLayerState& requested) const {
364     auto blendMode = Hwc2::IComposerClient::BlendMode::NONE;
365     if (alpha != 1.0f || !contentOpaque) {
366         blendMode = requested.premultipliedAlpha ? Hwc2::IComposerClient::BlendMode::PREMULTIPLIED
367                                                  : Hwc2::IComposerClient::BlendMode::COVERAGE;
368     }
369     return blendMode;
370 }
371 
merge(const RequestedLayerState & requested,bool forceUpdate,bool displayChanges,bool forceFullDamage,uint32_t displayRotationFlags)372 void LayerSnapshot::merge(const RequestedLayerState& requested, bool forceUpdate,
373                           bool displayChanges, bool forceFullDamage,
374                           uint32_t displayRotationFlags) {
375     clientChanges = requested.what;
376     changes = requested.changes;
377     autoRefresh = requested.autoRefresh;
378     contentDirty = requested.what & layer_state_t::CONTENT_DIRTY || autoRefresh;
379     hasReadyFrame = autoRefresh;
380     sidebandStreamHasFrame = requested.hasSidebandStreamFrame();
381     updateSurfaceDamage(requested, requested.hasReadyFrame(), forceFullDamage, surfaceDamage);
382 
383     if (forceUpdate || requested.what & layer_state_t::eTransparentRegionChanged) {
384         transparentRegionHint = requested.getTransparentRegion();
385     }
386     if (forceUpdate || requested.what & layer_state_t::eFlagsChanged) {
387         layerOpaqueFlagSet =
388                 (requested.flags & layer_state_t::eLayerOpaque) == layer_state_t::eLayerOpaque;
389     }
390     if (forceUpdate || requested.what & layer_state_t::eBufferTransformChanged) {
391         geomBufferTransform = requested.bufferTransform;
392     }
393     if (forceUpdate || requested.what & layer_state_t::eTransformToDisplayInverseChanged) {
394         geomBufferUsesDisplayInverseTransform = requested.transformToDisplayInverse;
395     }
396     if (forceUpdate || requested.what & layer_state_t::eDataspaceChanged) {
397         dataspace = Layer::translateDataspace(requested.dataspace);
398     }
399     if (forceUpdate || requested.what & layer_state_t::eExtendedRangeBrightnessChanged) {
400         currentHdrSdrRatio = requested.currentHdrSdrRatio;
401         desiredHdrSdrRatio = requested.desiredHdrSdrRatio;
402     }
403     if (forceUpdate || requested.what & layer_state_t::eDesiredHdrHeadroomChanged) {
404         desiredHdrSdrRatio = requested.desiredHdrSdrRatio;
405     }
406     if (forceUpdate || requested.what & layer_state_t::eCachingHintChanged) {
407         cachingHint = requested.cachingHint;
408     }
409     if (forceUpdate || requested.what & layer_state_t::eHdrMetadataChanged) {
410         hdrMetadata = requested.hdrMetadata;
411     }
412     if (forceUpdate || requested.what & layer_state_t::eSidebandStreamChanged) {
413         sidebandStream = requested.sidebandStream;
414     }
415     if (forceUpdate || requested.what & layer_state_t::eShadowRadiusChanged) {
416         shadowSettings.length = requested.shadowRadius;
417     }
418     if (forceUpdate || requested.what & layer_state_t::eBorderSettingsChanged) {
419         borderSettings = requested.borderSettings;
420     }
421     if (forceUpdate || requested.what & layer_state_t::eFrameRateSelectionPriority) {
422         frameRateSelectionPriority = requested.frameRateSelectionPriority;
423     }
424     if (forceUpdate || requested.what & layer_state_t::eColorSpaceAgnosticChanged) {
425         isColorspaceAgnostic = requested.colorSpaceAgnostic;
426     }
427     if (forceUpdate || requested.what & layer_state_t::eDimmingEnabledChanged) {
428         dimmingEnabled = requested.dimmingEnabled;
429     }
430     if (forceUpdate || requested.what & layer_state_t::eCropChanged) {
431         geomCrop = requested.crop;
432     }
433     if (forceUpdate || requested.what & layer_state_t::ePictureProfileHandleChanged) {
434         pictureProfileHandle = requested.pictureProfileHandle;
435     }
436     if (forceUpdate || requested.what & layer_state_t::eAppContentPriorityChanged) {
437         // TODO(b/337330263): Also consider the system-determined priority of the app
438         pictureProfilePriority = int64_t(requested.appContentPriority) + INT_MAX;
439     }
440 
441     if (forceUpdate || requested.what & layer_state_t::eDefaultFrameRateCompatibilityChanged) {
442         const auto compatibility =
443                 Layer::FrameRate::convertCompatibility(requested.defaultFrameRateCompatibility);
444         if (defaultFrameRateCompatibility != compatibility) {
445             clientChanges |= layer_state_t::eDefaultFrameRateCompatibilityChanged;
446         }
447         defaultFrameRateCompatibility = compatibility;
448     }
449 
450     if (forceUpdate ||
451         requested.what &
452                 (layer_state_t::eFlagsChanged | layer_state_t::eBufferChanged |
453                  layer_state_t::eSidebandStreamChanged)) {
454         compositionType = requested.getCompositionType();
455     }
456 
457     if (forceUpdate || requested.what & layer_state_t::eInputInfoChanged) {
458         inputInfo = requested.getWindowInfo();
459         inputInfo.id = static_cast<int32_t>(uniqueSequence);
460         touchCropId = requested.touchCropId;
461     }
462 
463     if (forceUpdate ||
464         requested.what &
465                 (layer_state_t::eColorChanged | layer_state_t::eBufferChanged |
466                  layer_state_t::eSidebandStreamChanged)) {
467         color.rgb = requested.getColor().rgb;
468     }
469 
470     if (forceUpdate || requested.what & layer_state_t::eBufferChanged) {
471         acquireFence =
472                 (requested.externalTexture &&
473                  requested.bufferData->flags.test(BufferData::BufferDataChange::fenceChanged))
474                 ? requested.bufferData->acquireFence
475                 : Fence::NO_FENCE;
476         buffer = requested.externalTexture ? requested.externalTexture->getBuffer() : nullptr;
477         externalTexture = requested.externalTexture;
478         frameNumber = (requested.bufferData) ? requested.bufferData->frameNumber : 0;
479         hasProtectedContent = requested.externalTexture &&
480                 requested.externalTexture->getUsage() & GRALLOC_USAGE_PROTECTED;
481         geomUsesSourceCrop = hasBufferOrSidebandStream();
482     }
483 
484     if (forceUpdate ||
485         requested.what &
486                 (layer_state_t::eCropChanged | layer_state_t::eBufferCropChanged |
487                  layer_state_t::eBufferTransformChanged |
488                  layer_state_t::eTransformToDisplayInverseChanged) ||
489         requested.changes.test(RequestedLayerState::Changes::BufferSize) || displayChanges) {
490         bufferSize = requested.getBufferSize(displayRotationFlags);
491         geomBufferSize = bufferSize;
492         croppedBufferSize = requested.getCroppedBufferSize(bufferSize);
493         geomContentCrop = requested.getBufferCrop();
494     }
495 
496     if ((forceUpdate ||
497          requested.what &
498                  (layer_state_t::eFlagsChanged | layer_state_t::eDestinationFrameChanged |
499                   layer_state_t::ePositionChanged | layer_state_t::eMatrixChanged |
500                   layer_state_t::eBufferTransformChanged |
501                   layer_state_t::eTransformToDisplayInverseChanged) ||
502          requested.changes.test(RequestedLayerState::Changes::BufferSize) || displayChanges) &&
503         !ignoreLocalTransform) {
504         localTransform = requested.getTransform(displayRotationFlags);
505         localTransformInverse = localTransform.inverse();
506     }
507 
508     if (forceUpdate || requested.what & (layer_state_t::eColorChanged) ||
509         requested.changes.test(RequestedLayerState::Changes::BufferSize)) {
510         color.rgb = requested.getColor().rgb;
511     }
512 
513     if (forceUpdate ||
514         requested.what &
515                 (layer_state_t::eBufferChanged | layer_state_t::eDataspaceChanged |
516                  layer_state_t::eApiChanged | layer_state_t::eShadowRadiusChanged |
517                  layer_state_t::eBlurRegionsChanged | layer_state_t::eStretchChanged |
518                  layer_state_t::eEdgeExtensionChanged | layer_state_t::eBorderSettingsChanged)) {
519         forceClientComposition = shadowSettings.length > 0 || stretchEffect.hasEffect() ||
520                 edgeExtensionEffect.hasEffect() || borderSettings.strokeWidth > 0;
521     }
522 
523     if (forceUpdate ||
524         requested.what &
525                 (layer_state_t::eColorChanged | layer_state_t::eShadowRadiusChanged |
526                  layer_state_t::eBlurRegionsChanged | layer_state_t::eBackgroundBlurRadiusChanged |
527                  layer_state_t::eCornerRadiusChanged | layer_state_t::eAlphaChanged |
528                  layer_state_t::eFlagsChanged | layer_state_t::eBufferChanged |
529                  layer_state_t::eSidebandStreamChanged)) {
530         contentOpaque = isContentOpaque();
531         isOpaque = contentOpaque && !roundedCorner.hasRoundedCorners() && color.a == 1.f;
532         blendMode = getBlendMode(requested);
533     }
534 
535     if (forceUpdate || requested.what & layer_state_t::eLutsChanged) {
536         luts = requested.luts;
537     }
538 }
539 
classifyCompositionForDebug(const compositionengine::LayerFE::HwcLayerDebugState & hwcState) const540 char LayerSnapshot::classifyCompositionForDebug(
541         const compositionengine::LayerFE::HwcLayerDebugState& hwcState) const {
542     if (!isVisible) {
543         return '.';
544     }
545 
546     switch (hwcState.lastCompositionType) {
547         case Composition::INVALID:
548             return 'i';
549         case Composition::SOLID_COLOR:
550             return 'c';
551         case Composition::CURSOR:
552             return 'u';
553         case Composition::SIDEBAND:
554             return 'd';
555         case Composition::DISPLAY_DECORATION:
556             return 'a';
557         case Composition::REFRESH_RATE_INDICATOR:
558             return 'r';
559         case Composition::CLIENT:
560         case Composition::DEVICE:
561             break;
562     }
563 
564     char code = '.'; // Default to invisible
565     if (hasBlur()) {
566         code = 'l'; // Blur
567     } else if (hasProtectedContent) {
568         code = 'p'; // Protected content
569     } else if (roundedCorner.hasRoundedCorners()) {
570         code = 'r'; // Rounded corners
571     } else if (drawShadows()) {
572         code = 's'; // Shadow
573     } else if (fillsColor()) {
574         code = 'c'; // Solid color
575     } else if (hasBufferOrSidebandStream()) {
576         code = 'b';
577     }
578 
579     if (hwcState.lastCompositionType == Composition::CLIENT) {
580         return static_cast<char>(std::toupper(code));
581     } else {
582         return code;
583     }
584 }
585 
586 } // namespace android::surfaceflinger::frontend
587