• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 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 #include <android-base/stringprintf.h>
18 #include <compositionengine/LayerFECompositionState.h>
19 #include <compositionengine/impl/DumpHelpers.h>
20 
21 namespace android::compositionengine {
22 
23 namespace {
24 
25 using android::compositionengine::impl::dumpVal;
26 
dumpVal(std::string & out,const char * name,half4 value)27 void dumpVal(std::string& out, const char* name, half4 value) {
28     using android::base::StringAppendF;
29     StringAppendF(&out, "%s=[%f %f %f] ", name, static_cast<float>(value.r),
30                   static_cast<float>(value.g), static_cast<float>(value.b));
31 }
32 
33 } // namespace
34 
dumpAsString() const35 std::string GenericLayerMetadataEntry::dumpAsString() const {
36     using android::base::StringAppendF;
37     std::string out;
38 
39     out.append("GenericLayerMetadataEntry{mandatory: ");
40     StringAppendF(&out, "%d", mandatory);
41     out.append(" value: ");
42     for (uint8_t byte : value) {
43         StringAppendF(&out, "0x08%" PRIx8 " ", byte);
44     }
45     out.append("]}");
46     return out;
47 }
48 
49 LayerFECompositionState::~LayerFECompositionState() = default;
50 
dump(std::string & out) const51 void LayerFECompositionState::dump(std::string& out) const {
52     out.append("      ");
53     dumpVal(out, "isSecure", isSecure);
54     dumpVal(out, "geomUsesSourceCrop", geomUsesSourceCrop);
55     dumpVal(out, "geomBufferUsesDisplayInverseTransform", geomBufferUsesDisplayInverseTransform);
56     dumpVal(out, "geomLayerTransform", geomLayerTransform);
57 
58     out.append("\n      ");
59     dumpVal(out, "geomBufferSize", geomBufferSize);
60     dumpVal(out, "geomContentCrop", geomContentCrop);
61     dumpVal(out, "geomCrop", geomCrop);
62     dumpVal(out, "geomBufferTransform", geomBufferTransform);
63 
64     out.append("\n      ");
65     dumpVal(out, "transparentRegionHint", transparentRegionHint);
66 
67     out.append("      ");
68     dumpVal(out, "geomLayerBounds", geomLayerBounds);
69 
70     out.append("      ");
71     dumpVal(out, "shadowLength", shadowSettings.length);
72 
73     out.append("\n      ");
74     dumpVal(out, "blend", toString(blendMode), blendMode);
75     dumpVal(out, "alpha", alpha);
76     dumpVal(out, "backgroundBlurRadius", backgroundBlurRadius);
77     if (stretchEffect.hasEffect()) {
78         dumpVal(out, "stretchEffect", stretchEffect);
79     }
80 
81     if (!blurRegions.empty()) {
82         out.append("\n      blurRegions {");
83         for (const auto& region : blurRegions) {
84             out.append("\n           ");
85             base::StringAppendF(&out,
86                                 "{radius=%du, cornerRadii=[%f, %f, %f, %f], alpha=%f, rect=[%d, "
87                                 "%d, %d, %d]",
88                                 region.blurRadius, region.cornerRadiusTL, region.cornerRadiusTR,
89                                 region.cornerRadiusBL, region.cornerRadiusBR, region.alpha,
90                                 region.left, region.top, region.right, region.bottom);
91         }
92         out.append("\n      }\n      ");
93     }
94 
95     if (!metadata.empty()) {
96         out.append("\n      metadata {");
97         for (const auto& [key, entry] : metadata) {
98             out.append("\n           ");
99             out.append(key);
100             out.append("=");
101             out.append(entry.dumpAsString());
102         }
103         out.append("\n      }\n      ");
104     }
105 
106     dumpVal(out, "composition type", toString(compositionType), compositionType);
107 
108     out.append("\n      buffer: ");
109     dumpVal(out, "buffer", buffer.get());
110 
111     out.append("\n      ");
112     dumpVal(out, "sideband stream", sidebandStream.get());
113 
114     out.append("\n      ");
115     dumpVal(out, "color", color);
116 
117     out.append("\n      ");
118     dumpVal(out, "isOpaque", isOpaque);
119     dumpVal(out, "hasProtectedContent", hasProtectedContent);
120     dumpVal(out, "isColorspaceAgnostic", isColorspaceAgnostic);
121     dumpVal(out, "dataspace", toString(dataspace), dataspace);
122     dumpVal(out, "hdr metadata types", hdrMetadata.validTypes);
123     dumpVal(out, "dimming enabled", dimmingEnabled);
124     if (currentHdrSdrRatio > 1.01f || desiredHdrSdrRatio > 1.01f) {
125         dumpVal(out, "current hdr/sdr ratio", currentHdrSdrRatio);
126         dumpVal(out, "desired hdr/sdr ratio", desiredHdrSdrRatio);
127     }
128     dumpVal(out, "colorTransform", colorTransform);
129     dumpVal(out, "caching hint", toString(cachingHint));
130 
131     out.append("\n");
132 }
133 
134 } // namespace android::compositionengine
135