blob: 143c1926861547c17c3f2e96c7f9cef512cdb9ac [file] [log] [blame]
Lloyd Piquecc01a452018-12-04 17:24:00 -08001/*
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 */
Brian Lindahl1a4ffd82024-10-30 11:00:37 -060016
Alec Mourid1bf1b52021-05-05 18:44:58 -070017#include <DisplayHardware/Hal.h>
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080018#include <android-base/stringprintf.h>
Lloyd Piquef5275482019-01-29 18:42:42 -080019#include <compositionengine/DisplayColorProfile.h>
Lloyd Pique9755fb72019-03-26 14:44:40 -070020#include <compositionengine/LayerFECompositionState.h>
Lloyd Piquecc01a452018-12-04 17:24:00 -080021#include <compositionengine/Output.h>
Alec Mourie7cc1c22021-04-27 15:23:26 -070022#include <compositionengine/impl/HwcBufferCache.h>
Lloyd Piquea83776c2019-01-29 18:42:32 -080023#include <compositionengine/impl/OutputCompositionState.h>
Lloyd Piquecc01a452018-12-04 17:24:00 -080024#include <compositionengine/impl/OutputLayer.h>
Lloyd Piquea83776c2019-01-29 18:42:32 -080025#include <compositionengine/impl/OutputLayerCompositionState.h>
Brian Lindahl1a4ffd82024-10-30 11:00:37 -060026#include <ui/FloatRect.h>
27#include <ui/HdrRenderTypeUtils.h>
Leon Scroggins IIIe2ee0402021-04-02 16:59:37 -040028#include <cstdint>
Alec Mouri8face532024-11-09 22:15:32 +000029#include <limits>
Alec Mouricdf6cbc2021-11-01 17:21:15 -070030#include "system/graphics-base-v1.0.h"
31
Brian Lindahl1a4ffd82024-10-30 11:00:37 -060032#include <com_android_graphics_libgui_flags.h>
Lloyd Piquecc01a452018-12-04 17:24:00 -080033
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080034// TODO(b/129481165): remove the #pragma below and fix conversion issues
35#pragma clang diagnostic push
36#pragma clang diagnostic ignored "-Wconversion"
37
Lloyd Pique07e33212018-12-18 16:33:37 -080038#include "DisplayHardware/HWComposer.h"
39
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080040// TODO(b/129481165): remove the #pragma below and fix conversion issues
41#pragma clang diagnostic pop // ignored "-Wconversion"
42
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050043using aidl::android::hardware::graphics::composer3::Composition;
Sally Qi0abc4a52024-09-26 16:13:06 -070044using aidl::android::hardware::graphics::composer3::Luts;
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050045
Lloyd Piquecc01a452018-12-04 17:24:00 -080046namespace android::compositionengine {
47
48OutputLayer::~OutputLayer() = default;
49
50namespace impl {
51
Lloyd Piquea83776c2019-01-29 18:42:32 -080052namespace {
53
54FloatRect reduce(const FloatRect& win, const Region& exclude) {
55 if (CC_LIKELY(exclude.isEmpty())) {
56 return win;
57 }
58 // Convert through Rect (by rounding) for lack of FloatRegion
59 return Region(Rect{win}).subtract(exclude).getBounds().toFloatRect();
60}
61
62} // namespace
63
Lloyd Piquede196652020-01-22 17:29:58 -080064std::unique_ptr<OutputLayer> createOutputLayer(const compositionengine::Output& output,
65 const sp<compositionengine::LayerFE>& layerFE) {
66 return createOutputLayerTemplated<OutputLayer>(output, layerFE);
Lloyd Piquecc01a452018-12-04 17:24:00 -080067}
68
Lloyd Piquecc01a452018-12-04 17:24:00 -080069OutputLayer::~OutputLayer() = default;
70
Lloyd Piquedf336d92019-03-07 21:38:42 -080071void OutputLayer::setHwcLayer(std::shared_ptr<HWC2::Layer> hwcLayer) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -070072 auto& state = editState();
Lloyd Piquedf336d92019-03-07 21:38:42 -080073 if (hwcLayer) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -070074 state.hwc.emplace(std::move(hwcLayer));
Lloyd Piquedf336d92019-03-07 21:38:42 -080075 } else {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -070076 state.hwc.reset();
Lloyd Pique07e33212018-12-18 16:33:37 -080077 }
Lloyd Pique07e33212018-12-18 16:33:37 -080078}
79
Lloyd Piquea83776c2019-01-29 18:42:32 -080080Rect OutputLayer::calculateInitialCrop() const {
Lloyd Piquede196652020-01-22 17:29:58 -080081 const auto& layerState = *getLayerFE().getCompositionState();
Lloyd Piquea83776c2019-01-29 18:42:32 -080082
83 // apply the projection's clipping to the window crop in
84 // layerstack space, and convert-back to layer space.
85 // if there are no window scaling involved, this operation will map to full
86 // pixels in the buffer.
87
88 FloatRect activeCropFloat =
Lloyd Piquec6687342019-03-07 21:34:57 -080089 reduce(layerState.geomLayerBounds, layerState.transparentRegionHint);
Lloyd Piquea83776c2019-01-29 18:42:32 -080090
Angel Aguayob084e0c2021-08-04 23:27:28 +000091 const Rect& viewport = getOutput().getState().layerStackSpace.getContent();
Lloyd Piquea83776c2019-01-29 18:42:32 -080092 const ui::Transform& layerTransform = layerState.geomLayerTransform;
93 const ui::Transform& inverseLayerTransform = layerState.geomInverseLayerTransform;
94 // Transform to screen space.
95 activeCropFloat = layerTransform.transform(activeCropFloat);
96 activeCropFloat = activeCropFloat.intersect(viewport.toFloatRect());
97 // Back to layer space to work with the content crop.
98 activeCropFloat = inverseLayerTransform.transform(activeCropFloat);
99
100 // This needs to be here as transform.transform(Rect) computes the
101 // transformed rect and then takes the bounding box of the result before
102 // returning. This means
103 // transform.inverse().transform(transform.transform(Rect)) != Rect
104 // in which case we need to make sure the final rect is clipped to the
105 // display bounds.
106 Rect activeCrop{activeCropFloat};
107 if (!activeCrop.intersect(layerState.geomBufferSize, &activeCrop)) {
108 activeCrop.clear();
109 }
110 return activeCrop;
111}
112
ramindani2c043be2022-04-19 20:11:10 +0000113FloatRect OutputLayer::calculateOutputSourceCrop(uint32_t internalDisplayRotationFlags) const {
Lloyd Piquede196652020-01-22 17:29:58 -0800114 const auto& layerState = *getLayerFE().getCompositionState();
Lloyd Piquea83776c2019-01-29 18:42:32 -0800115
116 if (!layerState.geomUsesSourceCrop) {
117 return {};
118 }
119
120 // the content crop is the area of the content that gets scaled to the
121 // layer's size. This is in buffer space.
122 FloatRect crop = layerState.geomContentCrop.toFloatRect();
123
124 // In addition there is a WM-specified crop we pull from our drawing state.
125 Rect activeCrop = calculateInitialCrop();
126 const Rect& bufferSize = layerState.geomBufferSize;
127
128 int winWidth = bufferSize.getWidth();
129 int winHeight = bufferSize.getHeight();
130
131 // The bufferSize for buffer state layers can be unbounded ([0, 0, -1, -1])
132 // if display frame hasn't been set and the parent is an unbounded layer.
133 if (winWidth < 0 && winHeight < 0) {
134 return crop;
135 }
136
137 // Transform the window crop to match the buffer coordinate system,
138 // which means using the inverse of the current transform set on the
139 // SurfaceFlingerConsumer.
140 uint32_t invTransform = layerState.geomBufferTransform;
141 if (layerState.geomBufferUsesDisplayInverseTransform) {
142 /*
143 * the code below applies the primary display's inverse transform to the
144 * buffer
145 */
ramindani2c043be2022-04-19 20:11:10 +0000146 uint32_t invTransformOrient = internalDisplayRotationFlags;
Lloyd Piquea83776c2019-01-29 18:42:32 -0800147 // calculate the inverse transform
148 if (invTransformOrient & HAL_TRANSFORM_ROT_90) {
149 invTransformOrient ^= HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_FLIP_H;
150 }
151 // and apply to the current transform
152 invTransform =
153 (ui::Transform(invTransformOrient) * ui::Transform(invTransform)).getOrientation();
154 }
155
156 if (invTransform & HAL_TRANSFORM_ROT_90) {
157 // If the activeCrop has been rotate the ends are rotated but not
158 // the space itself so when transforming ends back we can't rely on
159 // a modification of the axes of rotation. To account for this we
160 // need to reorient the inverse rotation in terms of the current
161 // axes of rotation.
Marin Shalamanovcfeebd42020-05-15 15:23:49 +0200162 bool isHFlipped = (invTransform & HAL_TRANSFORM_FLIP_H) != 0;
163 bool isVFlipped = (invTransform & HAL_TRANSFORM_FLIP_V) != 0;
164 if (isHFlipped == isVFlipped) {
Lloyd Piquea83776c2019-01-29 18:42:32 -0800165 invTransform ^= HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_FLIP_H;
166 }
167 std::swap(winWidth, winHeight);
168 }
169 const Rect winCrop =
170 activeCrop.transform(invTransform, bufferSize.getWidth(), bufferSize.getHeight());
171
172 // below, crop is intersected with winCrop expressed in crop's coordinate space
Marin Shalamanovcfeebd42020-05-15 15:23:49 +0200173 const float xScale = crop.getWidth() / float(winWidth);
174 const float yScale = crop.getHeight() / float(winHeight);
Lloyd Piquea83776c2019-01-29 18:42:32 -0800175
Marin Shalamanovcfeebd42020-05-15 15:23:49 +0200176 const float insetLeft = winCrop.left * xScale;
177 const float insetTop = winCrop.top * yScale;
178 const float insetRight = (winWidth - winCrop.right) * xScale;
179 const float insetBottom = (winHeight - winCrop.bottom) * yScale;
Lloyd Piquea83776c2019-01-29 18:42:32 -0800180
Marin Shalamanovcfeebd42020-05-15 15:23:49 +0200181 crop.left += insetLeft;
182 crop.top += insetTop;
183 crop.right -= insetRight;
184 crop.bottom -= insetBottom;
Lloyd Piquea83776c2019-01-29 18:42:32 -0800185
186 return crop;
187}
188
189Rect OutputLayer::calculateOutputDisplayFrame() const {
Lloyd Piquede196652020-01-22 17:29:58 -0800190 const auto& layerState = *getLayerFE().getCompositionState();
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700191 const auto& outputState = getOutput().getState();
Lloyd Piquea83776c2019-01-29 18:42:32 -0800192
Vishnu Naira9123c82024-10-03 03:56:44 +0000193 // Convert from layer space to layerStackSpace
Lloyd Piquea83776c2019-01-29 18:42:32 -0800194 // apply the layer's transform, followed by the display's global transform
195 // here we're guaranteed that the layer's transform preserves rects
Lloyd Piquea83776c2019-01-29 18:42:32 -0800196 const ui::Transform& layerTransform = layerState.geomLayerTransform;
Vishnu Naira9123c82024-10-03 03:56:44 +0000197 Region activeTransparentRegion = layerTransform.transform(layerState.transparentRegionHint);
198 if (!layerState.geomCrop.isEmpty() && layerState.geomBufferSize.isValid()) {
199 FloatRect activeCrop = layerTransform.transform(layerState.geomCrop);
200 activeCrop = activeCrop.intersect(outputState.layerStackSpace.getContent().toFloatRect());
201 const FloatRect& bufferSize =
202 layerTransform.transform(layerState.geomBufferSize.toFloatRect());
203 activeCrop = activeCrop.intersect(bufferSize);
204
Lloyd Piquea83776c2019-01-29 18:42:32 -0800205 // mark regions outside the crop as transparent
Vishnu Naira9123c82024-10-03 03:56:44 +0000206 Rect topRegion = Rect(layerTransform.transform(
207 FloatRect(0, 0, layerState.geomBufferSize.getWidth(), layerState.geomCrop.top)));
208 Rect bottomRegion = Rect(layerTransform.transform(
209 FloatRect(0, layerState.geomCrop.bottom, layerState.geomBufferSize.getWidth(),
210 layerState.geomBufferSize.getHeight())));
211 Rect leftRegion = Rect(layerTransform.transform(FloatRect(0, layerState.geomCrop.top,
212 layerState.geomCrop.left,
213 layerState.geomCrop.bottom)));
214 Rect rightRegion = Rect(layerTransform.transform(
215 FloatRect(layerState.geomCrop.right, layerState.geomCrop.top,
216 layerState.geomBufferSize.getWidth(), layerState.geomCrop.bottom)));
217
218 activeTransparentRegion.orSelf(topRegion);
219 activeTransparentRegion.orSelf(bottomRegion);
220 activeTransparentRegion.orSelf(leftRegion);
221 activeTransparentRegion.orSelf(rightRegion);
Lloyd Piquea83776c2019-01-29 18:42:32 -0800222 }
223
224 // reduce uses a FloatRect to provide more accuracy during the
225 // transformation. We then round upon constructing 'frame'.
Leon Scroggins IIId394d3c2021-06-24 11:30:32 -0400226 FloatRect geomLayerBounds = layerState.geomLayerBounds;
227
228 // Some HWCs may clip client composited input to its displayFrame. Make sure
229 // that this does not cut off the shadow.
Vishnu Naird9e4f462023-10-06 04:05:45 +0000230 if (layerState.forceClientComposition && layerState.shadowSettings.length > 0.0f) {
Alec Mourida128512024-09-28 23:46:58 +0000231 // RenderEngine currently blurs shadows to smooth out edges, so outset by
232 // 2x the length instead of 1x to compensate
233 const auto outset = layerState.shadowSettings.length * 2;
Leon Scroggins IIId394d3c2021-06-24 11:30:32 -0400234 geomLayerBounds.left -= outset;
235 geomLayerBounds.top -= outset;
236 geomLayerBounds.right += outset;
237 geomLayerBounds.bottom += outset;
238 }
Lloyd Piquea83776c2019-01-29 18:42:32 -0800239
Vishnu Naira9123c82024-10-03 03:56:44 +0000240 geomLayerBounds = layerTransform.transform(geomLayerBounds);
241 FloatRect frame = reduce(geomLayerBounds, activeTransparentRegion);
242 frame = frame.intersect(outputState.layerStackSpace.getContent().toFloatRect());
243
244 // convert from layerStackSpace to displaySpace
245 const ui::Transform displayTransform{outputState.transform};
246 return Rect(displayTransform.transform(frame));
Lloyd Piquea83776c2019-01-29 18:42:32 -0800247}
248
Snild Dolkow9e217d62020-04-22 15:53:42 +0200249uint32_t OutputLayer::calculateOutputRelativeBufferTransform(
250 uint32_t internalDisplayRotationFlags) const {
Lloyd Piquede196652020-01-22 17:29:58 -0800251 const auto& layerState = *getLayerFE().getCompositionState();
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700252 const auto& outputState = getOutput().getState();
Lloyd Piquea83776c2019-01-29 18:42:32 -0800253
254 /*
255 * Transformations are applied in this order:
256 * 1) buffer orientation/flip/mirror
257 * 2) state transformation (window manager)
258 * 3) layer orientation (screen orientation)
259 * (NOTE: the matrices are multiplied in reverse order)
260 */
261 const ui::Transform& layerTransform = layerState.geomLayerTransform;
Rashed Abdel-Tawab6643cd82019-10-29 10:01:56 -0700262 const ui::Transform displayTransform{outputState.transform};
Lloyd Piquea83776c2019-01-29 18:42:32 -0800263 const ui::Transform bufferTransform{layerState.geomBufferTransform};
264 ui::Transform transform(displayTransform * layerTransform * bufferTransform);
265
266 if (layerState.geomBufferUsesDisplayInverseTransform) {
267 /*
Snild Dolkow9e217d62020-04-22 15:53:42 +0200268 * We must apply the internal display's inverse transform to the buffer
269 * transform, and not the one for the output this layer is on.
Lloyd Piquea83776c2019-01-29 18:42:32 -0800270 */
Snild Dolkow9e217d62020-04-22 15:53:42 +0200271 uint32_t invTransform = internalDisplayRotationFlags;
272
Lloyd Piquea83776c2019-01-29 18:42:32 -0800273 // calculate the inverse transform
274 if (invTransform & HAL_TRANSFORM_ROT_90) {
275 invTransform ^= HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_FLIP_H;
276 }
277
278 /*
279 * Here we cancel out the orientation component of the WM transform.
280 * The scaling and translate components are already included in our bounds
281 * computation so it's enough to just omit it in the composition.
282 * See comment in BufferLayer::prepareClientLayer with ref to b/36727915 for why.
283 */
Lloyd Pique546a2452019-03-18 20:53:27 +0000284 transform = ui::Transform(invTransform) * displayTransform * bufferTransform;
Lloyd Piquea83776c2019-01-29 18:42:32 -0800285 }
286
287 // this gives us only the "orientation" component of the transform
288 return transform.getOrientation();
Snild Dolkow9e217d62020-04-22 15:53:42 +0200289}
Lloyd Piquea83776c2019-01-29 18:42:32 -0800290
Sally Qi0abc4a52024-09-26 16:13:06 -0700291void OutputLayer::updateLuts(
Sally Qief006582024-10-11 13:23:09 -0700292 const LayerFECompositionState& layerFEState,
Sally Qi0abc4a52024-09-26 16:13:06 -0700293 const std::optional<std::vector<std::optional<LutProperties>>>& properties) {
Sally Qief006582024-10-11 13:23:09 -0700294 auto& luts = layerFEState.luts;
295 if (!luts) {
296 return;
297 }
298
Sally Qi0abc4a52024-09-26 16:13:06 -0700299 auto& state = editState();
300
301 if (!properties) {
302 // GPU composition if no Hwc Luts
303 state.forceClientComposition = true;
304 return;
305 }
306
307 std::vector<LutProperties> hwcLutProperties;
308 for (auto& p : *properties) {
309 if (p) {
310 hwcLutProperties.emplace_back(*p);
311 }
312 }
313
Sally Qief006582024-10-11 13:23:09 -0700314 for (const auto& inputLut : luts->lutProperties) {
Sally Qi0abc4a52024-09-26 16:13:06 -0700315 bool foundInHwcLuts = false;
316 for (const auto& hwcLut : hwcLutProperties) {
317 if (static_cast<int32_t>(hwcLut.dimension) ==
318 static_cast<int32_t>(inputLut.dimension) &&
319 hwcLut.size == inputLut.size &&
320 std::find(hwcLut.samplingKeys.begin(), hwcLut.samplingKeys.end(),
321 static_cast<LutProperties::SamplingKey>(inputLut.samplingKey)) !=
322 hwcLut.samplingKeys.end()) {
323 foundInHwcLuts = true;
324 break;
325 }
326 }
Sally Qief006582024-10-11 13:23:09 -0700327 // if any lut properties of luts can not be found in hwcLutProperties,
Sally Qi0abc4a52024-09-26 16:13:06 -0700328 // GPU composition instead
329 if (!foundInHwcLuts) {
330 state.forceClientComposition = true;
331 return;
332 }
333 }
334}
335
Snild Dolkow9e217d62020-04-22 15:53:42 +0200336void OutputLayer::updateCompositionState(
337 bool includeGeometry, bool forceClientComposition,
Sally Qi0abc4a52024-09-26 16:13:06 -0700338 ui::Transform::RotationFlags internalDisplayRotationFlags,
339 const std::optional<std::vector<std::optional<LutProperties>>> properties) {
Lloyd Piquede196652020-01-22 17:29:58 -0800340 const auto* layerFEState = getLayerFE().getCompositionState();
341 if (!layerFEState) {
342 return;
343 }
344
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700345 const auto& outputState = getOutput().getState();
346 const auto& profile = *getOutput().getDisplayColorProfile();
347 auto& state = editState();
Lloyd Piquef5275482019-01-29 18:42:42 -0800348
Lloyd Piquea83776c2019-01-29 18:42:32 -0800349 if (includeGeometry) {
Lloyd Piquefe671022019-09-24 10:43:03 -0700350 // Clear the forceClientComposition flag before it is set for any
351 // reason. Note that since it can be set by some checks below when
352 // updating the geometry state, we only clear it when updating the
353 // geometry since those conditions for forcing client composition won't
354 // go away otherwise.
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700355 state.forceClientComposition = false;
Lloyd Piquefe671022019-09-24 10:43:03 -0700356
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700357 state.displayFrame = calculateOutputDisplayFrame();
ramindani2c043be2022-04-19 20:11:10 +0000358 state.sourceCrop = calculateOutputSourceCrop(internalDisplayRotationFlags);
Snild Dolkow9e217d62020-04-22 15:53:42 +0200359 state.bufferTransform = static_cast<Hwc2::Transform>(
360 calculateOutputRelativeBufferTransform(internalDisplayRotationFlags));
Lloyd Piquea83776c2019-01-29 18:42:32 -0800361
Lloyd Piquede196652020-01-22 17:29:58 -0800362 if ((layerFEState->isSecure && !outputState.isSecure) ||
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700363 (state.bufferTransform & ui::Transform::ROT_INVALID)) {
364 state.forceClientComposition = true;
Lloyd Piquea83776c2019-01-29 18:42:32 -0800365 }
366 }
Lloyd Piquef5275482019-01-29 18:42:42 -0800367
Sally Qif6918d42023-08-07 15:28:30 -0700368 auto pixelFormat = layerFEState->buffer ? std::make_optional(static_cast<ui::PixelFormat>(
369 layerFEState->buffer->getPixelFormat()))
370 : std::nullopt;
371
372 auto hdrRenderType =
373 getHdrRenderType(outputState.dataspace, pixelFormat, layerFEState->desiredHdrSdrRatio);
374
Lloyd Piquef5275482019-01-29 18:42:42 -0800375 // Determine the output dependent dataspace for this layer. If it is
376 // colorspace agnostic, it just uses the dataspace chosen for the output to
377 // avoid the need for color conversion.
Alec Mouri88790f32023-07-21 01:25:14 +0000378 // For now, also respect the colorspace agnostic flag if we're drawing to HDR, to avoid drastic
379 // luminance shift. TODO(b/292162273): we should check if that's true though.
Sally Qif6918d42023-08-07 15:28:30 -0700380 state.dataspace = layerFEState->isColorspaceAgnostic && hdrRenderType == HdrRenderType::SDR
Alec Mouri88790f32023-07-21 01:25:14 +0000381 ? outputState.dataspace
Lloyd Piquede196652020-01-22 17:29:58 -0800382 : layerFEState->dataspace;
Lloyd Piquef5275482019-01-29 18:42:42 -0800383
Alec Mouridda07d92022-04-25 22:39:25 +0000384 // Override the dataspace transfer from 170M to sRGB if the device configuration requests this.
385 // We do this here instead of in buffer info so that dumpsys can still report layers that are
386 // using the 170M transfer. Also we only do this if the colorspace is not agnostic for the
387 // layer, in case the color profile uses a 170M transfer function.
388 if (outputState.treat170mAsSrgb && !layerFEState->isColorspaceAgnostic &&
389 (state.dataspace & HAL_DATASPACE_TRANSFER_MASK) == HAL_DATASPACE_TRANSFER_SMPTE_170M) {
390 state.dataspace = static_cast<ui::Dataspace>(
391 (state.dataspace & HAL_DATASPACE_STANDARD_MASK) |
392 (state.dataspace & HAL_DATASPACE_RANGE_MASK) | HAL_DATASPACE_TRANSFER_SRGB);
393 }
394
Sally Qi8f9ed652023-08-17 15:30:29 -0700395 // re-get HdrRenderType after the dataspace gets changed.
396 hdrRenderType =
397 getHdrRenderType(state.dataspace, pixelFormat, layerFEState->desiredHdrSdrRatio);
398
Alec Mouricdf6cbc2021-11-01 17:21:15 -0700399 // For hdr content, treat the white point as the display brightness - HDR content should not be
400 // boosted or dimmed.
Sally Qi81d95e62022-03-21 19:41:33 -0700401 // If the layer explicitly requests to disable dimming, then don't dim either.
Alec Mouri8face532024-11-09 22:15:32 +0000402 if (getOutput().getState().displayBrightnessNits == getOutput().getState().sdrWhitePointNits ||
403 getOutput().getState().displayBrightnessNits <= 0.f || !layerFEState->dimmingEnabled) {
Alec Mouri6da0e272022-02-07 12:45:57 -0800404 state.dimmingRatio = 1.f;
Alec Mouricdf6cbc2021-11-01 17:21:15 -0700405 state.whitePointNits = getOutput().getState().displayBrightnessNits;
Alec Mouri8face532024-11-09 22:15:32 +0000406 } else if (hdrRenderType == HdrRenderType::GENERIC_HDR) {
407 float deviceHeadroom = getOutput().getState().displayBrightnessNits /
408 getOutput().getState().sdrWhitePointNits;
409 float idealizedMaxHeadroom = deviceHeadroom;
410
411 if (FlagManager::getInstance().begone_bright_hlg()) {
412 idealizedMaxHeadroom =
413 std::min(idealizedMaxHeadroom, getIdealizedMaxHeadroom(state.dataspace));
414 }
415
416 state.dimmingRatio = std::min(idealizedMaxHeadroom / deviceHeadroom, 1.0f);
417 state.whitePointNits = getOutput().getState().displayBrightnessNits * state.dimmingRatio;
Alec Mouricdf6cbc2021-11-01 17:21:15 -0700418 } else {
John Reck68796592023-01-25 13:47:12 -0500419 float layerBrightnessNits = getOutput().getState().sdrWhitePointNits;
420 // RANGE_EXTENDED can "self-promote" to HDR, but is still rendered for a particular
421 // range that we may need to re-adjust to the current display conditions
Sally Qif6918d42023-08-07 15:28:30 -0700422 if (hdrRenderType == HdrRenderType::DISPLAY_HDR) {
Sally Qi963049b2023-03-23 14:06:21 -0700423 layerBrightnessNits *= layerFEState->currentHdrSdrRatio;
John Reck68796592023-01-25 13:47:12 -0500424 }
425 state.dimmingRatio =
426 std::clamp(layerBrightnessNits / getOutput().getState().displayBrightnessNits, 0.f,
427 1.f);
428 state.whitePointNits = layerBrightnessNits;
Alec Mouricdf6cbc2021-11-01 17:21:15 -0700429 }
430
Sally Qief006582024-10-11 13:23:09 -0700431 updateLuts(*layerFEState, properties);
Sally Qi0abc4a52024-09-26 16:13:06 -0700432
Lloyd Piquef5275482019-01-29 18:42:42 -0800433 // These are evaluated every frame as they can potentially change at any
434 // time.
Lloyd Piquede196652020-01-22 17:29:58 -0800435 if (layerFEState->forceClientComposition || !profile.isDataspaceSupported(state.dataspace) ||
Lloyd Pique7a234912019-10-03 11:54:27 -0700436 forceClientComposition) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700437 state.forceClientComposition = true;
Lloyd Piquef5275482019-01-29 18:42:42 -0800438 }
Lloyd Piquea83776c2019-01-29 18:42:32 -0800439}
440
Brian Lindahl1a4ffd82024-10-30 11:00:37 -0600441void OutputLayer::commitPictureProfileToCompositionState() {
442 if (!com_android_graphics_libgui_flags_apply_picture_profiles()) {
443 return;
444 }
445 const auto* layerState = getLayerFE().getCompositionState();
446 if (layerState) {
Brian Lindahlf5fdff82024-11-01 09:28:47 -0600447 editState().pictureProfileHandle = layerState->pictureProfileHandle;
Brian Lindahl1a4ffd82024-10-30 11:00:37 -0600448 }
449}
450
Leon Scroggins III9aa25c22021-04-15 15:30:19 -0400451void OutputLayer::writeStateToHWC(bool includeGeometry, bool skipLayer, uint32_t z,
452 bool zIsOverridden, bool isPeekingThrough) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700453 const auto& state = getState();
Lloyd Piquea83776c2019-01-29 18:42:32 -0800454 // Skip doing this if there is no HWC interface
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700455 if (!state.hwc) {
Lloyd Piquea83776c2019-01-29 18:42:32 -0800456 return;
457 }
458
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700459 auto& hwcLayer = (*state.hwc).hwcLayer;
Lloyd Piquea83776c2019-01-29 18:42:32 -0800460 if (!hwcLayer) {
461 ALOGE("[%s] failed to write composition state to HWC -- no hwcLayer for output %s",
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700462 getLayerFE().getDebugName(), getOutput().getName().c_str());
Lloyd Piquea83776c2019-01-29 18:42:32 -0800463 return;
464 }
465
Lloyd Piquede196652020-01-22 17:29:58 -0800466 const auto* outputIndependentState = getLayerFE().getCompositionState();
467 if (!outputIndependentState) {
468 return;
469 }
470
471 auto requestedCompositionType = outputIndependentState->compositionType;
Lloyd Piquef5275482019-01-29 18:42:42 -0800472
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500473 if (requestedCompositionType == Composition::SOLID_COLOR && state.overrideInfo.buffer) {
474 requestedCompositionType = Composition::DEVICE;
Alec Mouri028676a2021-12-02 15:01:48 -0800475 }
476
Yichi Chen413d46a2021-04-07 21:42:09 +0800477 // TODO(b/181172795): We now update geometry for all flattened layers. We should update it
478 // only when the geometry actually changes
Leon Scroggins III9aa25c22021-04-15 15:30:19 -0400479 const bool isOverridden =
480 state.overrideInfo.buffer != nullptr || isPeekingThrough || zIsOverridden;
Yichi Chen413d46a2021-04-07 21:42:09 +0800481 const bool prevOverridden = state.hwc->stateOverridden;
482 if (isOverridden || prevOverridden || skipLayer || includeGeometry) {
Leon Scroggins IIIe2ee0402021-04-02 16:59:37 -0400483 writeOutputDependentGeometryStateToHWC(hwcLayer.get(), requestedCompositionType, z);
Dan Stoza6166c312021-01-15 16:34:05 -0800484 writeOutputIndependentGeometryStateToHWC(hwcLayer.get(), *outputIndependentState,
485 skipLayer);
Lloyd Piquef5275482019-01-29 18:42:42 -0800486 }
Lloyd Piquea83776c2019-01-29 18:42:32 -0800487
Lloyd Piquef5275482019-01-29 18:42:42 -0800488 writeOutputDependentPerFrameStateToHWC(hwcLayer.get());
Alec Mouri028676a2021-12-02 15:01:48 -0800489 writeOutputIndependentPerFrameStateToHWC(hwcLayer.get(), *outputIndependentState,
490 requestedCompositionType, skipLayer);
Lloyd Piquea83776c2019-01-29 18:42:32 -0800491
Alec Mourid1bf1b52021-05-05 18:44:58 -0700492 writeCompositionTypeToHWC(hwcLayer.get(), requestedCompositionType, isPeekingThrough,
493 skipLayer);
Lloyd Pique46b72df2019-10-29 13:19:27 -0700494
Sally Qi0abc4a52024-09-26 16:13:06 -0700495 writeLutToHWC(hwcLayer.get(), *outputIndependentState);
496
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500497 if (requestedCompositionType == Composition::SOLID_COLOR) {
Alec Mouri028676a2021-12-02 15:01:48 -0800498 writeSolidColorStateToHWC(hwcLayer.get(), *outputIndependentState);
499 }
Yichi Chen413d46a2021-04-07 21:42:09 +0800500
501 editState().hwc->stateOverridden = isOverridden;
Alec Mourid1bf1b52021-05-05 18:44:58 -0700502 editState().hwc->layerSkipped = skipLayer;
Lloyd Piquef5275482019-01-29 18:42:42 -0800503}
Lloyd Piquea83776c2019-01-29 18:42:32 -0800504
Leon Scroggins IIIe2ee0402021-04-02 16:59:37 -0400505void OutputLayer::writeOutputDependentGeometryStateToHWC(HWC2::Layer* hwcLayer,
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500506 Composition requestedCompositionType,
Leon Scroggins IIIe2ee0402021-04-02 16:59:37 -0400507 uint32_t z) {
Lloyd Piquef5275482019-01-29 18:42:42 -0800508 const auto& outputDependentState = getState();
509
Dan Stoza6166c312021-01-15 16:34:05 -0800510 Rect displayFrame = outputDependentState.displayFrame;
511 FloatRect sourceCrop = outputDependentState.sourceCrop;
Huihong Luoa5825112021-03-24 12:28:29 -0700512
Alec Mouri464352b2021-03-24 16:33:21 -0700513 if (outputDependentState.overrideInfo.buffer != nullptr) {
Dan Stoza6166c312021-01-15 16:34:05 -0800514 displayFrame = outputDependentState.overrideInfo.displayFrame;
Wiwit Rifa'i50abed02022-05-24 02:24:33 +0000515 sourceCrop =
516 FloatRect(0.f, 0.f,
517 static_cast<float>(outputDependentState.overrideInfo.buffer->getBuffer()
518 ->getWidth()),
519 static_cast<float>(outputDependentState.overrideInfo.buffer->getBuffer()
520 ->getHeight()));
Lloyd Piquef5275482019-01-29 18:42:42 -0800521 }
522
Dan Stoza6166c312021-01-15 16:34:05 -0800523 ALOGV("Writing display frame [%d, %d, %d, %d]", displayFrame.left, displayFrame.top,
524 displayFrame.right, displayFrame.bottom);
525
526 if (auto error = hwcLayer->setDisplayFrame(displayFrame); error != hal::Error::NONE) {
527 ALOGE("[%s] Failed to set display frame [%d, %d, %d, %d]: %s (%d)",
528 getLayerFE().getDebugName(), displayFrame.left, displayFrame.top, displayFrame.right,
529 displayFrame.bottom, to_string(error).c_str(), static_cast<int32_t>(error));
530 }
531
532 if (auto error = hwcLayer->setSourceCrop(sourceCrop); error != hal::Error::NONE) {
Lloyd Piquef5275482019-01-29 18:42:42 -0800533 ALOGE("[%s] Failed to set source crop [%.3f, %.3f, %.3f, %.3f]: "
534 "%s (%d)",
Dan Stoza6166c312021-01-15 16:34:05 -0800535 getLayerFE().getDebugName(), sourceCrop.left, sourceCrop.top, sourceCrop.right,
536 sourceCrop.bottom, to_string(error).c_str(), static_cast<int32_t>(error));
Lloyd Piquef5275482019-01-29 18:42:42 -0800537 }
538
Leon Scroggins IIIe2ee0402021-04-02 16:59:37 -0400539 if (auto error = hwcLayer->setZOrder(z); error != hal::Error::NONE) {
540 ALOGE("[%s] Failed to set Z %u: %s (%d)", getLayerFE().getDebugName(), z,
541 to_string(error).c_str(), static_cast<int32_t>(error));
Lloyd Piquef5275482019-01-29 18:42:42 -0800542 }
543
Alec Mouri7be6c0a2021-03-19 15:22:01 -0700544 // Solid-color layers and overridden buffers should always use an identity transform.
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500545 const auto bufferTransform = (requestedCompositionType != Composition::SOLID_COLOR &&
Alec Mouri7be6c0a2021-03-19 15:22:01 -0700546 getState().overrideInfo.buffer == nullptr)
Lloyd Piquef5275482019-01-29 18:42:42 -0800547 ? outputDependentState.bufferTransform
Peiyong Line9d809e2020-04-14 13:10:48 -0700548 : static_cast<hal::Transform>(0);
549 if (auto error = hwcLayer->setTransform(static_cast<hal::Transform>(bufferTransform));
550 error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700551 ALOGE("[%s] Failed to set transform %s: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquef5275482019-01-29 18:42:42 -0800552 toString(outputDependentState.bufferTransform).c_str(), to_string(error).c_str(),
553 static_cast<int32_t>(error));
554 }
555}
556
557void OutputLayer::writeOutputIndependentGeometryStateToHWC(
Dan Stoza6166c312021-01-15 16:34:05 -0800558 HWC2::Layer* hwcLayer, const LayerFECompositionState& outputIndependentState,
559 bool skipLayer) {
Leon Scroggins IIIe2ee0402021-04-02 16:59:37 -0400560 // If there is a peekThroughLayer, then this layer has a hole in it. We need to use
561 // PREMULTIPLIED so it will peek through.
562 const auto& overrideInfo = getState().overrideInfo;
563 const auto blendMode = overrideInfo.buffer || overrideInfo.peekThroughLayer
Alec Mouriee69a592021-03-23 15:00:45 -0700564 ? hardware::graphics::composer::hal::BlendMode::PREMULTIPLIED
565 : outputIndependentState.blendMode;
566 if (auto error = hwcLayer->setBlendMode(blendMode); error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700567 ALOGE("[%s] Failed to set blend mode %s: %s (%d)", getLayerFE().getDebugName(),
Alec Mouriee69a592021-03-23 15:00:45 -0700568 toString(blendMode).c_str(), to_string(error).c_str(), static_cast<int32_t>(error));
Lloyd Piquef5275482019-01-29 18:42:42 -0800569 }
570
Alec Mouriee69a592021-03-23 15:00:45 -0700571 const float alpha = skipLayer
572 ? 0.0f
573 : (getState().overrideInfo.buffer ? 1.0f : outputIndependentState.alpha);
Dan Stoza6166c312021-01-15 16:34:05 -0800574 ALOGV("Writing alpha %f", alpha);
575
576 if (auto error = hwcLayer->setPlaneAlpha(alpha); error != hal::Error::NONE) {
577 ALOGE("[%s] Failed to set plane alpha %.3f: %s (%d)", getLayerFE().getDebugName(), alpha,
578 to_string(error).c_str(), static_cast<int32_t>(error));
Lloyd Piquef5275482019-01-29 18:42:42 -0800579 }
580
Lloyd Pique8d9f8362020-02-11 19:13:09 -0800581 for (const auto& [name, entry] : outputIndependentState.metadata) {
582 if (auto error = hwcLayer->setLayerGenericMetadata(name, entry.mandatory, entry.value);
Peiyong Line9d809e2020-04-14 13:10:48 -0700583 error != hal::Error::NONE) {
Lloyd Pique8d9f8362020-02-11 19:13:09 -0800584 ALOGE("[%s] Failed to set generic metadata %s %s (%d)", getLayerFE().getDebugName(),
585 name.c_str(), to_string(error).c_str(), static_cast<int32_t>(error));
586 }
587 }
Lloyd Piquef5275482019-01-29 18:42:42 -0800588}
589
Sally Qi0abc4a52024-09-26 16:13:06 -0700590void OutputLayer::writeLutToHWC(HWC2::Layer* hwcLayer,
591 const LayerFECompositionState& outputIndependentState) {
Sally Qi0abc4a52024-09-26 16:13:06 -0700592 Luts luts;
Sally Qi36349ac2024-11-25 08:00:26 +0000593 // if outputIndependentState.luts is nullptr, it means we want to clear the LUTs
594 // and we pass an empty Luts object to the HWC.
595 if (outputIndependentState.luts) {
596 auto& lutFileDescriptor = outputIndependentState.luts->getLutFileDescriptor();
597 auto lutOffsets = outputIndependentState.luts->offsets;
598 auto& lutProperties = outputIndependentState.luts->lutProperties;
599
600 std::vector<LutProperties> aidlProperties;
601 aidlProperties.reserve(lutProperties.size());
602 for (size_t i = 0; i < lutOffsets.size(); i++) {
603 LutProperties properties;
604 properties.dimension = static_cast<LutProperties::Dimension>(lutProperties[i].dimension);
605 properties.size = lutProperties[i].size;
606 properties.samplingKeys = {
607 static_cast<LutProperties::SamplingKey>(lutProperties[i].samplingKey)};
608 aidlProperties.emplace_back(properties);
609 }
610
611
612 luts.pfd = ndk::ScopedFileDescriptor(dup(lutFileDescriptor.get()));
613 luts.offsets = lutOffsets;
614 luts.lutProperties = std::move(aidlProperties);
615 }
Sally Qi0abc4a52024-09-26 16:13:06 -0700616
617 switch (auto error = hwcLayer->setLuts(luts)) {
618 case hal::Error::NONE:
619 break;
620 default:
621 ALOGE("[%s] Failed to set Luts: %s (%d)", getLayerFE().getDebugName(),
622 to_string(error).c_str(), static_cast<int32_t>(error));
623 }
624}
625
Lloyd Piquef5275482019-01-29 18:42:42 -0800626void OutputLayer::writeOutputDependentPerFrameStateToHWC(HWC2::Layer* hwcLayer) {
627 const auto& outputDependentState = getState();
628
Lloyd Piquea2468662019-03-07 21:31:06 -0800629 // TODO(lpique): b/121291683 outputSpaceVisibleRegion is output-dependent geometry
Lloyd Piquef5275482019-01-29 18:42:42 -0800630 // state and should not change every frame.
Alec Mouri464352b2021-03-24 16:33:21 -0700631 Region visibleRegion = outputDependentState.overrideInfo.buffer
632 ? Region(outputDependentState.overrideInfo.visibleRegion)
633 : outputDependentState.outputSpaceVisibleRegion;
634 if (auto error = hwcLayer->setVisibleRegion(visibleRegion); error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700635 ALOGE("[%s] Failed to set visible region: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquef5275482019-01-29 18:42:42 -0800636 to_string(error).c_str(), static_cast<int32_t>(error));
Leon Scroggins IIIf2b8ec42022-01-05 13:23:36 -0500637 visibleRegion.dump(LOG_TAG);
Lloyd Piquef5275482019-01-29 18:42:42 -0800638 }
639
Leon Scroggins III9a0afda2022-01-11 16:53:09 -0500640 if (auto error =
641 hwcLayer->setBlockingRegion(outputDependentState.outputSpaceBlockingRegionHint);
642 error != hal::Error::NONE) {
643 ALOGE("[%s] Failed to set blocking region: %s (%d)", getLayerFE().getDebugName(),
644 to_string(error).c_str(), static_cast<int32_t>(error));
645 outputDependentState.outputSpaceBlockingRegionHint.dump(LOG_TAG);
646 }
647
Alec Mourib7edfc22021-03-17 16:20:26 -0700648 const auto dataspace = outputDependentState.overrideInfo.buffer
649 ? outputDependentState.overrideInfo.dataspace
650 : outputDependentState.dataspace;
651
652 if (auto error = hwcLayer->setDataspace(dataspace); error != hal::Error::NONE) {
653 ALOGE("[%s] Failed to set dataspace %d: %s (%d)", getLayerFE().getDebugName(), dataspace,
654 to_string(error).c_str(), static_cast<int32_t>(error));
Lloyd Piquef5275482019-01-29 18:42:42 -0800655 }
Alec Mouricdf6cbc2021-11-01 17:21:15 -0700656
Alec Mourie8dd3562022-02-11 14:18:57 -0800657 // Cached layers are not dimmed, which means that composer should attempt to dim.
658 // Note that if the dimming ratio is large, then this may cause the cached layer
659 // to kick back into GPU composition :(
660 // Also note that this assumes that there are no HDR layers that are able to be cached.
661 // Otherwise, this could cause HDR layers to be dimmed twice.
662 const auto dimmingRatio = outputDependentState.overrideInfo.buffer
663 ? (getOutput().getState().displayBrightnessNits != 0.f
664 ? std::clamp(getOutput().getState().sdrWhitePointNits /
665 getOutput().getState().displayBrightnessNits,
666 0.f, 1.f)
667 : 1.f)
668 : outputDependentState.dimmingRatio;
Alec Mouricdf6cbc2021-11-01 17:21:15 -0700669
Alec Mouri6da0e272022-02-07 12:45:57 -0800670 if (auto error = hwcLayer->setBrightness(dimmingRatio); error != hal::Error::NONE) {
671 ALOGE("[%s] Failed to set brightness %f: %s (%d)", getLayerFE().getDebugName(),
672 dimmingRatio, to_string(error).c_str(), static_cast<int32_t>(error));
Alec Mouricdf6cbc2021-11-01 17:21:15 -0700673 }
Brian Lindahl1a4ffd82024-10-30 11:00:37 -0600674
675 if (com_android_graphics_libgui_flags_apply_picture_profiles() &&
676 outputDependentState.pictureProfileHandle) {
677 if (auto error =
678 hwcLayer->setPictureProfileHandle(outputDependentState.pictureProfileHandle);
679 error != hal::Error::NONE) {
680 ALOGE("[%s] Failed to set picture profile handle: %s (%d)", getLayerFE().getDebugName(),
681 toString(outputDependentState.pictureProfileHandle).c_str(),
682 static_cast<int32_t>(error));
683 }
684 // Reset the picture profile state, as it needs to be re-committed on each present cycle
685 // when Output decides that the limited picture-processing hardware should be used by this
686 // layer.
687 editState().pictureProfileHandle = PictureProfileHandle::NONE;
688 }
Lloyd Piquef5275482019-01-29 18:42:42 -0800689}
690
691void OutputLayer::writeOutputIndependentPerFrameStateToHWC(
Alec Mouri96ca45c2021-06-09 17:32:26 -0700692 HWC2::Layer* hwcLayer, const LayerFECompositionState& outputIndependentState,
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500693 Composition compositionType, bool skipLayer) {
Lloyd Piquef5275482019-01-29 18:42:42 -0800694 switch (auto error = hwcLayer->setColorTransform(outputIndependentState.colorTransform)) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700695 case hal::Error::NONE:
Lloyd Piquef5275482019-01-29 18:42:42 -0800696 break;
Peiyong Line9d809e2020-04-14 13:10:48 -0700697 case hal::Error::UNSUPPORTED:
Lloyd Piquef5275482019-01-29 18:42:42 -0800698 editState().forceClientComposition = true;
699 break;
700 default:
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700701 ALOGE("[%s] Failed to set color transform: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquea83776c2019-01-29 18:42:32 -0800702 to_string(error).c_str(), static_cast<int32_t>(error));
Lloyd Piquef5275482019-01-29 18:42:42 -0800703 }
Lloyd Piquea83776c2019-01-29 18:42:32 -0800704
Alec Mouri464352b2021-03-24 16:33:21 -0700705 const Region& surfaceDamage = getState().overrideInfo.buffer
706 ? getState().overrideInfo.damageRegion
Alec Mourid1bf1b52021-05-05 18:44:58 -0700707 : (getState().hwc->stateOverridden ? Region::INVALID_REGION
708 : outputIndependentState.surfaceDamage);
Alec Mouri464352b2021-03-24 16:33:21 -0700709
710 if (auto error = hwcLayer->setSurfaceDamage(surfaceDamage); error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700711 ALOGE("[%s] Failed to set surface damage: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquef5275482019-01-29 18:42:42 -0800712 to_string(error).c_str(), static_cast<int32_t>(error));
713 outputIndependentState.surfaceDamage.dump(LOG_TAG);
714 }
715
716 // Content-specific per-frame state
Alec Mouri028676a2021-12-02 15:01:48 -0800717 switch (compositionType) {
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500718 case Composition::SOLID_COLOR:
Lloyd Pique46b72df2019-10-29 13:19:27 -0700719 // For compatibility, should be written AFTER the composition type.
Lloyd Piquef5275482019-01-29 18:42:42 -0800720 break;
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500721 case Composition::SIDEBAND:
Lloyd Piquef5275482019-01-29 18:42:42 -0800722 writeSidebandStateToHWC(hwcLayer, outputIndependentState);
723 break;
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500724 case Composition::CURSOR:
725 case Composition::DEVICE:
Leon Scroggins III09c25412021-12-02 14:49:56 -0500726 case Composition::DISPLAY_DECORATION:
ramindanic1945cb2023-02-03 13:28:15 -0800727 case Composition::REFRESH_RATE_INDICATOR:
Alec Mouri96ca45c2021-06-09 17:32:26 -0700728 writeBufferStateToHWC(hwcLayer, outputIndependentState, skipLayer);
Lloyd Piquef5275482019-01-29 18:42:42 -0800729 break;
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500730 case Composition::INVALID:
731 case Composition::CLIENT:
Lloyd Piquef5275482019-01-29 18:42:42 -0800732 // Ignored
733 break;
734 }
735}
736
737void OutputLayer::writeSolidColorStateToHWC(HWC2::Layer* hwcLayer,
738 const LayerFECompositionState& outputIndependentState) {
Ady Abraham6e60b142022-01-06 18:10:35 -0800739 aidl::android::hardware::graphics::composer3::Color color = {outputIndependentState.color.r,
740 outputIndependentState.color.g,
741 outputIndependentState.color.b,
742 1.0f};
Lloyd Piquef5275482019-01-29 18:42:42 -0800743
Peiyong Line9d809e2020-04-14 13:10:48 -0700744 if (auto error = hwcLayer->setColor(color); error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700745 ALOGE("[%s] Failed to set color: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquef5275482019-01-29 18:42:42 -0800746 to_string(error).c_str(), static_cast<int32_t>(error));
747 }
748}
749
750void OutputLayer::writeSidebandStateToHWC(HWC2::Layer* hwcLayer,
751 const LayerFECompositionState& outputIndependentState) {
752 if (auto error = hwcLayer->setSidebandStream(outputIndependentState.sidebandStream->handle());
Peiyong Line9d809e2020-04-14 13:10:48 -0700753 error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700754 ALOGE("[%s] Failed to set sideband stream %p: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquef5275482019-01-29 18:42:42 -0800755 outputIndependentState.sidebandStream->handle(), to_string(error).c_str(),
756 static_cast<int32_t>(error));
757 }
758}
759
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700760void OutputLayer::uncacheBuffers(const std::vector<uint64_t>& bufferIdsToUncache) {
Brian Lindahl439afad2022-11-14 11:16:55 -0700761 auto& state = editState();
762 // Skip doing this if there is no HWC interface
763 if (!state.hwc) {
764 return;
765 }
766
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700767 // Uncache the active buffer last so that it's the first buffer to be purged from the cache
768 // next time a buffer is sent to this layer.
769 bool uncacheActiveBuffer = false;
770
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700771 std::vector<uint32_t> slotsToClear;
772 for (uint64_t bufferId : bufferIdsToUncache) {
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700773 if (bufferId == state.hwc->activeBufferId) {
774 uncacheActiveBuffer = true;
775 } else {
776 uint32_t slot = state.hwc->hwcBufferCache.uncache(bufferId);
777 if (slot != UINT32_MAX) {
778 slotsToClear.push_back(slot);
779 }
Brian Lindahl90553da2022-12-06 13:36:30 -0700780 }
Brian Lindahl439afad2022-11-14 11:16:55 -0700781 }
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700782 if (uncacheActiveBuffer) {
783 slotsToClear.push_back(state.hwc->hwcBufferCache.uncache(state.hwc->activeBufferId));
784 }
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700785
786 hal::Error error =
787 state.hwc->hwcLayer->setBufferSlotsToClear(slotsToClear, state.hwc->activeBufferSlot);
788 if (error != hal::Error::NONE) {
789 ALOGE("[%s] Failed to clear buffer slots: %s (%d)", getLayerFE().getDebugName(),
790 to_string(error).c_str(), static_cast<int32_t>(error));
791 }
Brian Lindahl439afad2022-11-14 11:16:55 -0700792}
793
Brian Lindahl1a4ffd82024-10-30 11:00:37 -0600794int64_t OutputLayer::getPictureProfilePriority() const {
795 const auto* layerState = getLayerFE().getCompositionState();
796 return layerState ? layerState->pictureProfilePriority : 0;
797}
798
799const PictureProfileHandle& OutputLayer::getPictureProfileHandle() const {
800 const auto* layerState = getLayerFE().getCompositionState();
801 return layerState ? layerState->pictureProfileHandle : PictureProfileHandle::NONE;
802}
803
Lloyd Piquef5275482019-01-29 18:42:42 -0800804void OutputLayer::writeBufferStateToHWC(HWC2::Layer* hwcLayer,
Alec Mouri96ca45c2021-06-09 17:32:26 -0700805 const LayerFECompositionState& outputIndependentState,
806 bool skipLayer) {
Huihong Luo5e161962023-08-18 14:26:32 -0700807 if (skipLayer && outputIndependentState.buffer == nullptr) {
808 return;
809 }
Lloyd Piquef5275482019-01-29 18:42:42 -0800810 auto supportedPerFrameMetadata =
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700811 getOutput().getDisplayColorProfile()->getSupportedPerFrameMetadata();
Lloyd Piquef5275482019-01-29 18:42:42 -0800812 if (auto error = hwcLayer->setPerFrameMetadata(supportedPerFrameMetadata,
813 outputIndependentState.hdrMetadata);
Peiyong Line9d809e2020-04-14 13:10:48 -0700814 error != hal::Error::NONE && error != hal::Error::UNSUPPORTED) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700815 ALOGE("[%s] Failed to set hdrMetadata: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquef5275482019-01-29 18:42:42 -0800816 to_string(error).c_str(), static_cast<int32_t>(error));
817 }
818
Brian Lindahl439afad2022-11-14 11:16:55 -0700819 HwcSlotAndBuffer hwcSlotAndBuffer;
820 sp<Fence> hwcFence;
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700821 {
822 // Editing the state only because we update the HWC buffer cache and active buffer.
823 auto& state = editState();
824 // Override buffers use a special cache slot so that they don't evict client buffers.
825 if (state.overrideInfo.buffer != nullptr && !skipLayer) {
826 hwcSlotAndBuffer = state.hwc->hwcBufferCache.getOverrideHwcSlotAndBuffer(
827 state.overrideInfo.buffer->getBuffer());
828 hwcFence = state.overrideInfo.acquireFence;
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700829 // Keep track of the active buffer ID so when it's discarded we uncache it last so its
830 // slot will be used first, allowing the memory to be freed as soon as possible.
831 state.hwc->activeBufferId = state.overrideInfo.buffer->getBuffer()->getId();
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700832 } else {
833 hwcSlotAndBuffer =
834 state.hwc->hwcBufferCache.getHwcSlotAndBuffer(outputIndependentState.buffer);
835 hwcFence = outputIndependentState.acquireFence;
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700836 // Keep track of the active buffer ID so when it's discarded we uncache it last so its
837 // slot will be used first, allowing the memory to be freed as soon as possible.
838 state.hwc->activeBufferId = outputIndependentState.buffer->getId();
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700839 }
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700840 // Keep track of the active buffer slot, so we can restore it after clearing other buffer
841 // slots.
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700842 state.hwc->activeBufferSlot = hwcSlotAndBuffer.slot;
Dan Stoza6166c312021-01-15 16:34:05 -0800843 }
844
Brian Lindahl439afad2022-11-14 11:16:55 -0700845 if (auto error = hwcLayer->setBuffer(hwcSlotAndBuffer.slot, hwcSlotAndBuffer.buffer, hwcFence);
Peiyong Line9d809e2020-04-14 13:10:48 -0700846 error != hal::Error::NONE) {
Brian Lindahl439afad2022-11-14 11:16:55 -0700847 ALOGE("[%s] Failed to set buffer %p: %s (%d)", getLayerFE().getDebugName(),
848 hwcSlotAndBuffer.buffer->handle, to_string(error).c_str(),
849 static_cast<int32_t>(error));
Lloyd Piquef5275482019-01-29 18:42:42 -0800850 }
851}
852
Peiyong Line9d809e2020-04-14 13:10:48 -0700853void OutputLayer::writeCompositionTypeToHWC(HWC2::Layer* hwcLayer,
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500854 Composition requestedCompositionType,
Alec Mourid1bf1b52021-05-05 18:44:58 -0700855 bool isPeekingThrough, bool skipLayer) {
Lloyd Piquef5275482019-01-29 18:42:42 -0800856 auto& outputDependentState = editState();
857
Alec Mourid1bf1b52021-05-05 18:44:58 -0700858 if (isClientCompositionForced(isPeekingThrough)) {
859 // If we are forcing client composition, we need to tell the HWC
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500860 requestedCompositionType = Composition::CLIENT;
Lloyd Piquef5275482019-01-29 18:42:42 -0800861 }
862
863 // Set the requested composition type with the HWC whenever it changes
Alec Mourid1bf1b52021-05-05 18:44:58 -0700864 // We also resend the composition type when this layer was previously skipped, to ensure that
865 // the composition type is up-to-date.
866 if (outputDependentState.hwc->hwcCompositionType != requestedCompositionType ||
867 (outputDependentState.hwc->layerSkipped && !skipLayer)) {
Lloyd Piquef5275482019-01-29 18:42:42 -0800868 outputDependentState.hwc->hwcCompositionType = requestedCompositionType;
869
Peiyong Line9d809e2020-04-14 13:10:48 -0700870 if (auto error = hwcLayer->setCompositionType(requestedCompositionType);
871 error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700872 ALOGE("[%s] Failed to set composition type %s: %s (%d)", getLayerFE().getDebugName(),
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500873 to_string(requestedCompositionType).c_str(), to_string(error).c_str(),
Lloyd Piquea83776c2019-01-29 18:42:32 -0800874 static_cast<int32_t>(error));
875 }
Lloyd Piquea83776c2019-01-29 18:42:32 -0800876 }
877}
878
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800879void OutputLayer::writeCursorPositionToHWC() const {
880 // Skip doing this if there is no HWC interface
881 auto hwcLayer = getHwcLayer();
882 if (!hwcLayer) {
883 return;
884 }
885
Brian Lindahl1a4ffd82024-10-30 11:00:37 -0600886 const auto* layerState = getLayerFE().getCompositionState();
887 if (!layerState) {
Lloyd Piquede196652020-01-22 17:29:58 -0800888 return;
889 }
890
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700891 const auto& outputState = getOutput().getState();
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800892
Brian Lindahl1a4ffd82024-10-30 11:00:37 -0600893 Rect frame = layerState->cursorFrame;
Angel Aguayob084e0c2021-08-04 23:27:28 +0000894 frame.intersect(outputState.layerStackSpace.getContent(), &frame);
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800895 Rect position = outputState.transform.transform(frame);
896
897 if (auto error = hwcLayer->setCursorPosition(position.left, position.top);
Peiyong Line9d809e2020-04-14 13:10:48 -0700898 error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700899 ALOGE("[%s] Failed to set cursor position to (%d, %d): %s (%d)",
900 getLayerFE().getDebugName(), position.left, position.top, to_string(error).c_str(),
901 static_cast<int32_t>(error));
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800902 }
903}
904
Lloyd Pique66d68602019-02-13 14:23:31 -0800905HWC2::Layer* OutputLayer::getHwcLayer() const {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700906 const auto& state = getState();
907 return state.hwc ? state.hwc->hwcLayer.get() : nullptr;
Lloyd Pique66d68602019-02-13 14:23:31 -0800908}
909
910bool OutputLayer::requiresClientComposition() const {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700911 const auto& state = getState();
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500912 return !state.hwc || state.hwc->hwcCompositionType == Composition::CLIENT;
Lloyd Pique66d68602019-02-13 14:23:31 -0800913}
914
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800915bool OutputLayer::isHardwareCursor() const {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700916 const auto& state = getState();
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500917 return state.hwc && state.hwc->hwcCompositionType == Composition::CURSOR;
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800918}
919
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500920void OutputLayer::detectDisallowedCompositionTypeChange(Composition from, Composition to) const {
Lloyd Pique66d68602019-02-13 14:23:31 -0800921 bool result = false;
922 switch (from) {
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500923 case Composition::INVALID:
924 case Composition::CLIENT:
Lloyd Pique66d68602019-02-13 14:23:31 -0800925 result = false;
926 break;
927
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500928 case Composition::DEVICE:
929 case Composition::SOLID_COLOR:
930 result = (to == Composition::CLIENT);
Lloyd Pique66d68602019-02-13 14:23:31 -0800931 break;
932
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500933 case Composition::CURSOR:
934 case Composition::SIDEBAND:
Leon Scroggins7fd536f2021-12-28 14:43:12 +0000935 case Composition::DISPLAY_DECORATION:
ramindanic1945cb2023-02-03 13:28:15 -0800936 case Composition::REFRESH_RATE_INDICATOR:
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500937 result = (to == Composition::CLIENT || to == Composition::DEVICE);
Lloyd Pique66d68602019-02-13 14:23:31 -0800938 break;
939 }
940
941 if (!result) {
942 ALOGE("[%s] Invalid device requested composition type change: %s (%d) --> %s (%d)",
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500943 getLayerFE().getDebugName(), to_string(from).c_str(), static_cast<int>(from),
944 to_string(to).c_str(), static_cast<int>(to));
Lloyd Pique66d68602019-02-13 14:23:31 -0800945 }
946}
947
Alec Mourid1bf1b52021-05-05 18:44:58 -0700948bool OutputLayer::isClientCompositionForced(bool isPeekingThrough) const {
949 return getState().forceClientComposition ||
950 (!isPeekingThrough && getLayerFE().hasRoundedCorners());
951}
952
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500953void OutputLayer::applyDeviceCompositionTypeChange(Composition compositionType) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700954 auto& state = editState();
955 LOG_FATAL_IF(!state.hwc);
956 auto& hwcState = *state.hwc;
Lloyd Pique66d68602019-02-13 14:23:31 -0800957
Alec Mourid1bf1b52021-05-05 18:44:58 -0700958 // Only detected disallowed changes if this was not a skip layer, because the
959 // validated composition type may be arbitrary (usually DEVICE, to reflect that there were
960 // fewer GPU layers)
961 if (!hwcState.layerSkipped) {
962 detectDisallowedCompositionTypeChange(hwcState.hwcCompositionType, compositionType);
963 }
Lloyd Pique66d68602019-02-13 14:23:31 -0800964
965 hwcState.hwcCompositionType = compositionType;
966}
967
968void OutputLayer::prepareForDeviceLayerRequests() {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700969 auto& state = editState();
970 state.clearClientTarget = false;
Lloyd Pique66d68602019-02-13 14:23:31 -0800971}
972
Peiyong Line9d809e2020-04-14 13:10:48 -0700973void OutputLayer::applyDeviceLayerRequest(hal::LayerRequest request) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700974 auto& state = editState();
Lloyd Pique66d68602019-02-13 14:23:31 -0800975 switch (request) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700976 case hal::LayerRequest::CLEAR_CLIENT_TARGET:
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700977 state.clearClientTarget = true;
Lloyd Pique66d68602019-02-13 14:23:31 -0800978 break;
979
980 default:
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700981 ALOGE("[%s] Unknown device layer request %s (%d)", getLayerFE().getDebugName(),
Lloyd Pique66d68602019-02-13 14:23:31 -0800982 toString(request).c_str(), static_cast<int>(request));
983 break;
984 }
985}
986
Sally Qi0abc4a52024-09-26 16:13:06 -0700987void OutputLayer::applyDeviceLayerLut(
988 ndk::ScopedFileDescriptor lutFileDescriptor,
989 std::vector<std::pair<int, LutProperties>> lutOffsetsAndProperties) {
990 auto& state = editState();
991 LOG_FATAL_IF(!state.hwc);
992 auto& hwcState = *state.hwc;
993 std::vector<int32_t> offsets;
994 std::vector<int32_t> dimensions;
995 std::vector<int32_t> sizes;
996 std::vector<int32_t> samplingKeys;
997 for (const auto& [offset, properties] : lutOffsetsAndProperties) {
998 // The Lut(s) that comes back through CommandResultPayload should be
999 // only one sampling key.
1000 if (properties.samplingKeys.size() == 1) {
1001 offsets.emplace_back(offset);
1002 dimensions.emplace_back(static_cast<int32_t>(properties.dimension));
1003 sizes.emplace_back(static_cast<int32_t>(properties.size));
1004 samplingKeys.emplace_back(static_cast<int32_t>(properties.samplingKeys[0]));
1005 }
1006 }
1007 hwcState.luts = std::make_shared<gui::DisplayLuts>(base::unique_fd(lutFileDescriptor.release()),
1008 std::move(offsets), std::move(dimensions),
1009 std::move(sizes), std::move(samplingKeys));
Sally Qi95f669a2024-08-27 11:31:42 -07001010}
1011
Lloyd Pique688abd42019-02-15 15:42:24 -08001012bool OutputLayer::needsFiltering() const {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001013 const auto& state = getState();
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001014 const auto& sourceCrop = state.sourceCrop;
Alec Mourib6d78932023-09-20 16:05:42 +00001015 auto displayFrameWidth = static_cast<float>(state.displayFrame.getWidth());
1016 auto displayFrameHeight = static_cast<float>(state.displayFrame.getHeight());
1017
1018 if (state.bufferTransform & HAL_TRANSFORM_ROT_90) {
1019 std::swap(displayFrameWidth, displayFrameHeight);
1020 }
1021
1022 return sourceCrop.getHeight() != displayFrameHeight ||
1023 sourceCrop.getWidth() != displayFrameWidth;
Lloyd Pique688abd42019-02-15 15:42:24 -08001024}
1025
Patrick Williams16d8b2c2022-08-08 17:29:05 +00001026std::optional<LayerFE::LayerSettings> OutputLayer::getOverrideCompositionSettings() const {
Dan Stoza6166c312021-01-15 16:34:05 -08001027 if (getState().overrideInfo.buffer == nullptr) {
1028 return {};
1029 }
1030
Alec Mouri7be6c0a2021-03-19 15:22:01 -07001031 // Compute the geometry boundaries in layer stack space: we need to transform from the
1032 // framebuffer space of the override buffer to layer space.
1033 const ProjectionSpace& layerSpace = getOutput().getState().layerStackSpace;
1034 const ui::Transform transform = getState().overrideInfo.displaySpace.getTransform(layerSpace);
Wiwit Rifa'i50abed02022-05-24 02:24:33 +00001035 const Rect boundaries = transform.transform(getState().overrideInfo.displayFrame);
Alec Mouri7be6c0a2021-03-19 15:22:01 -07001036
Dan Stoza6166c312021-01-15 16:34:05 -08001037 LayerFE::LayerSettings settings;
1038 settings.geometry = renderengine::Geometry{
Alec Mouri7be6c0a2021-03-19 15:22:01 -07001039 .boundaries = boundaries.toFloatRect(),
Dan Stoza6166c312021-01-15 16:34:05 -08001040 };
Alec Mouria90a5702021-04-16 16:36:21 +00001041 settings.bufferId = getState().overrideInfo.buffer->getBuffer()->getId();
Alec Mouri7be6c0a2021-03-19 15:22:01 -07001042 settings.source = renderengine::PixelSource{
1043 .buffer = renderengine::Buffer{
1044 .buffer = getState().overrideInfo.buffer,
1045 .fence = getState().overrideInfo.acquireFence,
1046 // If the transform from layer space to display space contains a rotation, we
1047 // need to undo the rotation in the texture transform
1048 .textureTransform =
1049 ui::Transform(transform.inverse().getOrientation(), 1, 1).asMatrix4(),
1050 }};
Alec Mouri9c8fce02021-03-12 18:30:42 -08001051 settings.sourceDataspace = getState().overrideInfo.dataspace;
Dan Stoza6166c312021-01-15 16:34:05 -08001052 settings.alpha = 1.0f;
Alec Mourie8dd3562022-02-11 14:18:57 -08001053 settings.whitePointNits = getOutput().getState().sdrWhitePointNits;
Dan Stoza6166c312021-01-15 16:34:05 -08001054
Patrick Williams16d8b2c2022-08-08 17:29:05 +00001055 return settings;
Dan Stoza6166c312021-01-15 16:34:05 -08001056}
1057
Lloyd Pique37c2c9b2018-12-04 17:25:10 -08001058void OutputLayer::dump(std::string& out) const {
1059 using android::base::StringAppendF;
1060
Lloyd Piquede196652020-01-22 17:29:58 -08001061 StringAppendF(&out, " - Output Layer %p(%s)\n", this, getLayerFE().getDebugName());
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001062 dumpState(out);
Lloyd Pique37c2c9b2018-12-04 17:25:10 -08001063}
1064
Lloyd Piquecc01a452018-12-04 17:24:00 -08001065} // namespace impl
1066} // namespace android::compositionengine