blob: a040c88e7876866c1054d3564ec45ab4640d3444 [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 Qif5f380b2024-11-26 18:16:10 +0000592 if (!outputIndependentState.luts) {
593 return;
Sally Qi36349ac2024-11-25 08:00:26 +0000594 }
Sally Qif5f380b2024-11-26 18:16:10 +0000595 auto& lutFileDescriptor = outputIndependentState.luts->getLutFileDescriptor();
596 auto lutOffsets = outputIndependentState.luts->offsets;
597 auto& lutProperties = outputIndependentState.luts->lutProperties;
598
599 std::vector<LutProperties> aidlProperties;
600 aidlProperties.reserve(lutProperties.size());
601 for (size_t i = 0; i < lutOffsets.size(); i++) {
602 LutProperties properties;
603 properties.dimension = static_cast<LutProperties::Dimension>(lutProperties[i].dimension);
604 properties.size = lutProperties[i].size;
605 properties.samplingKeys = {
606 static_cast<LutProperties::SamplingKey>(lutProperties[i].samplingKey)};
607 aidlProperties.emplace_back(properties);
608 }
609
610 Luts luts;
611 luts.pfd = ndk::ScopedFileDescriptor(dup(lutFileDescriptor.get()));
612 luts.offsets = lutOffsets;
613 luts.lutProperties = std::move(aidlProperties);
Sally Qi0abc4a52024-09-26 16:13:06 -0700614
615 switch (auto error = hwcLayer->setLuts(luts)) {
616 case hal::Error::NONE:
617 break;
618 default:
619 ALOGE("[%s] Failed to set Luts: %s (%d)", getLayerFE().getDebugName(),
620 to_string(error).c_str(), static_cast<int32_t>(error));
621 }
622}
623
Lloyd Piquef5275482019-01-29 18:42:42 -0800624void OutputLayer::writeOutputDependentPerFrameStateToHWC(HWC2::Layer* hwcLayer) {
625 const auto& outputDependentState = getState();
626
Lloyd Piquea2468662019-03-07 21:31:06 -0800627 // TODO(lpique): b/121291683 outputSpaceVisibleRegion is output-dependent geometry
Lloyd Piquef5275482019-01-29 18:42:42 -0800628 // state and should not change every frame.
Alec Mouri464352b2021-03-24 16:33:21 -0700629 Region visibleRegion = outputDependentState.overrideInfo.buffer
630 ? Region(outputDependentState.overrideInfo.visibleRegion)
631 : outputDependentState.outputSpaceVisibleRegion;
632 if (auto error = hwcLayer->setVisibleRegion(visibleRegion); error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700633 ALOGE("[%s] Failed to set visible region: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquef5275482019-01-29 18:42:42 -0800634 to_string(error).c_str(), static_cast<int32_t>(error));
Leon Scroggins IIIf2b8ec42022-01-05 13:23:36 -0500635 visibleRegion.dump(LOG_TAG);
Lloyd Piquef5275482019-01-29 18:42:42 -0800636 }
637
Leon Scroggins III9a0afda2022-01-11 16:53:09 -0500638 if (auto error =
639 hwcLayer->setBlockingRegion(outputDependentState.outputSpaceBlockingRegionHint);
640 error != hal::Error::NONE) {
641 ALOGE("[%s] Failed to set blocking region: %s (%d)", getLayerFE().getDebugName(),
642 to_string(error).c_str(), static_cast<int32_t>(error));
643 outputDependentState.outputSpaceBlockingRegionHint.dump(LOG_TAG);
644 }
645
Alec Mourib7edfc22021-03-17 16:20:26 -0700646 const auto dataspace = outputDependentState.overrideInfo.buffer
647 ? outputDependentState.overrideInfo.dataspace
648 : outputDependentState.dataspace;
649
650 if (auto error = hwcLayer->setDataspace(dataspace); error != hal::Error::NONE) {
651 ALOGE("[%s] Failed to set dataspace %d: %s (%d)", getLayerFE().getDebugName(), dataspace,
652 to_string(error).c_str(), static_cast<int32_t>(error));
Lloyd Piquef5275482019-01-29 18:42:42 -0800653 }
Alec Mouricdf6cbc2021-11-01 17:21:15 -0700654
Alec Mourie8dd3562022-02-11 14:18:57 -0800655 // Cached layers are not dimmed, which means that composer should attempt to dim.
656 // Note that if the dimming ratio is large, then this may cause the cached layer
657 // to kick back into GPU composition :(
658 // Also note that this assumes that there are no HDR layers that are able to be cached.
659 // Otherwise, this could cause HDR layers to be dimmed twice.
660 const auto dimmingRatio = outputDependentState.overrideInfo.buffer
661 ? (getOutput().getState().displayBrightnessNits != 0.f
662 ? std::clamp(getOutput().getState().sdrWhitePointNits /
663 getOutput().getState().displayBrightnessNits,
664 0.f, 1.f)
665 : 1.f)
666 : outputDependentState.dimmingRatio;
Alec Mouricdf6cbc2021-11-01 17:21:15 -0700667
Alec Mouri6da0e272022-02-07 12:45:57 -0800668 if (auto error = hwcLayer->setBrightness(dimmingRatio); error != hal::Error::NONE) {
669 ALOGE("[%s] Failed to set brightness %f: %s (%d)", getLayerFE().getDebugName(),
670 dimmingRatio, to_string(error).c_str(), static_cast<int32_t>(error));
Alec Mouricdf6cbc2021-11-01 17:21:15 -0700671 }
Brian Lindahl1a4ffd82024-10-30 11:00:37 -0600672
673 if (com_android_graphics_libgui_flags_apply_picture_profiles() &&
674 outputDependentState.pictureProfileHandle) {
675 if (auto error =
676 hwcLayer->setPictureProfileHandle(outputDependentState.pictureProfileHandle);
677 error != hal::Error::NONE) {
678 ALOGE("[%s] Failed to set picture profile handle: %s (%d)", getLayerFE().getDebugName(),
679 toString(outputDependentState.pictureProfileHandle).c_str(),
680 static_cast<int32_t>(error));
681 }
682 // Reset the picture profile state, as it needs to be re-committed on each present cycle
683 // when Output decides that the limited picture-processing hardware should be used by this
684 // layer.
685 editState().pictureProfileHandle = PictureProfileHandle::NONE;
686 }
Lloyd Piquef5275482019-01-29 18:42:42 -0800687}
688
689void OutputLayer::writeOutputIndependentPerFrameStateToHWC(
Alec Mouri96ca45c2021-06-09 17:32:26 -0700690 HWC2::Layer* hwcLayer, const LayerFECompositionState& outputIndependentState,
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500691 Composition compositionType, bool skipLayer) {
Lloyd Piquef5275482019-01-29 18:42:42 -0800692 switch (auto error = hwcLayer->setColorTransform(outputIndependentState.colorTransform)) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700693 case hal::Error::NONE:
Lloyd Piquef5275482019-01-29 18:42:42 -0800694 break;
Peiyong Line9d809e2020-04-14 13:10:48 -0700695 case hal::Error::UNSUPPORTED:
Lloyd Piquef5275482019-01-29 18:42:42 -0800696 editState().forceClientComposition = true;
697 break;
698 default:
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700699 ALOGE("[%s] Failed to set color transform: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquea83776c2019-01-29 18:42:32 -0800700 to_string(error).c_str(), static_cast<int32_t>(error));
Lloyd Piquef5275482019-01-29 18:42:42 -0800701 }
Lloyd Piquea83776c2019-01-29 18:42:32 -0800702
Alec Mouri464352b2021-03-24 16:33:21 -0700703 const Region& surfaceDamage = getState().overrideInfo.buffer
704 ? getState().overrideInfo.damageRegion
Alec Mourid1bf1b52021-05-05 18:44:58 -0700705 : (getState().hwc->stateOverridden ? Region::INVALID_REGION
706 : outputIndependentState.surfaceDamage);
Alec Mouri464352b2021-03-24 16:33:21 -0700707
708 if (auto error = hwcLayer->setSurfaceDamage(surfaceDamage); error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700709 ALOGE("[%s] Failed to set surface damage: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquef5275482019-01-29 18:42:42 -0800710 to_string(error).c_str(), static_cast<int32_t>(error));
711 outputIndependentState.surfaceDamage.dump(LOG_TAG);
712 }
713
714 // Content-specific per-frame state
Alec Mouri028676a2021-12-02 15:01:48 -0800715 switch (compositionType) {
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500716 case Composition::SOLID_COLOR:
Lloyd Pique46b72df2019-10-29 13:19:27 -0700717 // For compatibility, should be written AFTER the composition type.
Lloyd Piquef5275482019-01-29 18:42:42 -0800718 break;
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500719 case Composition::SIDEBAND:
Lloyd Piquef5275482019-01-29 18:42:42 -0800720 writeSidebandStateToHWC(hwcLayer, outputIndependentState);
721 break;
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500722 case Composition::CURSOR:
723 case Composition::DEVICE:
Leon Scroggins III09c25412021-12-02 14:49:56 -0500724 case Composition::DISPLAY_DECORATION:
ramindanic1945cb2023-02-03 13:28:15 -0800725 case Composition::REFRESH_RATE_INDICATOR:
Alec Mouri96ca45c2021-06-09 17:32:26 -0700726 writeBufferStateToHWC(hwcLayer, outputIndependentState, skipLayer);
Lloyd Piquef5275482019-01-29 18:42:42 -0800727 break;
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500728 case Composition::INVALID:
729 case Composition::CLIENT:
Lloyd Piquef5275482019-01-29 18:42:42 -0800730 // Ignored
731 break;
732 }
733}
734
735void OutputLayer::writeSolidColorStateToHWC(HWC2::Layer* hwcLayer,
736 const LayerFECompositionState& outputIndependentState) {
Ady Abraham6e60b142022-01-06 18:10:35 -0800737 aidl::android::hardware::graphics::composer3::Color color = {outputIndependentState.color.r,
738 outputIndependentState.color.g,
739 outputIndependentState.color.b,
740 1.0f};
Lloyd Piquef5275482019-01-29 18:42:42 -0800741
Peiyong Line9d809e2020-04-14 13:10:48 -0700742 if (auto error = hwcLayer->setColor(color); error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700743 ALOGE("[%s] Failed to set color: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquef5275482019-01-29 18:42:42 -0800744 to_string(error).c_str(), static_cast<int32_t>(error));
745 }
746}
747
748void OutputLayer::writeSidebandStateToHWC(HWC2::Layer* hwcLayer,
749 const LayerFECompositionState& outputIndependentState) {
750 if (auto error = hwcLayer->setSidebandStream(outputIndependentState.sidebandStream->handle());
Peiyong Line9d809e2020-04-14 13:10:48 -0700751 error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700752 ALOGE("[%s] Failed to set sideband stream %p: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquef5275482019-01-29 18:42:42 -0800753 outputIndependentState.sidebandStream->handle(), to_string(error).c_str(),
754 static_cast<int32_t>(error));
755 }
756}
757
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700758void OutputLayer::uncacheBuffers(const std::vector<uint64_t>& bufferIdsToUncache) {
Brian Lindahl439afad2022-11-14 11:16:55 -0700759 auto& state = editState();
760 // Skip doing this if there is no HWC interface
761 if (!state.hwc) {
762 return;
763 }
764
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700765 // Uncache the active buffer last so that it's the first buffer to be purged from the cache
766 // next time a buffer is sent to this layer.
767 bool uncacheActiveBuffer = false;
768
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700769 std::vector<uint32_t> slotsToClear;
770 for (uint64_t bufferId : bufferIdsToUncache) {
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700771 if (bufferId == state.hwc->activeBufferId) {
772 uncacheActiveBuffer = true;
773 } else {
774 uint32_t slot = state.hwc->hwcBufferCache.uncache(bufferId);
775 if (slot != UINT32_MAX) {
776 slotsToClear.push_back(slot);
777 }
Brian Lindahl90553da2022-12-06 13:36:30 -0700778 }
Brian Lindahl439afad2022-11-14 11:16:55 -0700779 }
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700780 if (uncacheActiveBuffer) {
781 slotsToClear.push_back(state.hwc->hwcBufferCache.uncache(state.hwc->activeBufferId));
782 }
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700783
784 hal::Error error =
785 state.hwc->hwcLayer->setBufferSlotsToClear(slotsToClear, state.hwc->activeBufferSlot);
786 if (error != hal::Error::NONE) {
787 ALOGE("[%s] Failed to clear buffer slots: %s (%d)", getLayerFE().getDebugName(),
788 to_string(error).c_str(), static_cast<int32_t>(error));
789 }
Brian Lindahl439afad2022-11-14 11:16:55 -0700790}
791
Brian Lindahl1a4ffd82024-10-30 11:00:37 -0600792int64_t OutputLayer::getPictureProfilePriority() const {
793 const auto* layerState = getLayerFE().getCompositionState();
794 return layerState ? layerState->pictureProfilePriority : 0;
795}
796
797const PictureProfileHandle& OutputLayer::getPictureProfileHandle() const {
798 const auto* layerState = getLayerFE().getCompositionState();
799 return layerState ? layerState->pictureProfileHandle : PictureProfileHandle::NONE;
800}
801
Lloyd Piquef5275482019-01-29 18:42:42 -0800802void OutputLayer::writeBufferStateToHWC(HWC2::Layer* hwcLayer,
Alec Mouri96ca45c2021-06-09 17:32:26 -0700803 const LayerFECompositionState& outputIndependentState,
804 bool skipLayer) {
Huihong Luo5e161962023-08-18 14:26:32 -0700805 if (skipLayer && outputIndependentState.buffer == nullptr) {
806 return;
807 }
Lloyd Piquef5275482019-01-29 18:42:42 -0800808 auto supportedPerFrameMetadata =
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700809 getOutput().getDisplayColorProfile()->getSupportedPerFrameMetadata();
Lloyd Piquef5275482019-01-29 18:42:42 -0800810 if (auto error = hwcLayer->setPerFrameMetadata(supportedPerFrameMetadata,
811 outputIndependentState.hdrMetadata);
Peiyong Line9d809e2020-04-14 13:10:48 -0700812 error != hal::Error::NONE && error != hal::Error::UNSUPPORTED) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700813 ALOGE("[%s] Failed to set hdrMetadata: %s (%d)", getLayerFE().getDebugName(),
Lloyd Piquef5275482019-01-29 18:42:42 -0800814 to_string(error).c_str(), static_cast<int32_t>(error));
815 }
816
Brian Lindahl439afad2022-11-14 11:16:55 -0700817 HwcSlotAndBuffer hwcSlotAndBuffer;
818 sp<Fence> hwcFence;
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700819 {
820 // Editing the state only because we update the HWC buffer cache and active buffer.
821 auto& state = editState();
822 // Override buffers use a special cache slot so that they don't evict client buffers.
823 if (state.overrideInfo.buffer != nullptr && !skipLayer) {
824 hwcSlotAndBuffer = state.hwc->hwcBufferCache.getOverrideHwcSlotAndBuffer(
825 state.overrideInfo.buffer->getBuffer());
826 hwcFence = state.overrideInfo.acquireFence;
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700827 // Keep track of the active buffer ID so when it's discarded we uncache it last so its
828 // slot will be used first, allowing the memory to be freed as soon as possible.
829 state.hwc->activeBufferId = state.overrideInfo.buffer->getBuffer()->getId();
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700830 } else {
831 hwcSlotAndBuffer =
832 state.hwc->hwcBufferCache.getHwcSlotAndBuffer(outputIndependentState.buffer);
833 hwcFence = outputIndependentState.acquireFence;
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700834 // Keep track of the active buffer ID so when it's discarded we uncache it last so its
835 // slot will be used first, allowing the memory to be freed as soon as possible.
836 state.hwc->activeBufferId = outputIndependentState.buffer->getId();
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700837 }
Brian Lindahlb158a5c2022-12-15 15:21:13 -0700838 // Keep track of the active buffer slot, so we can restore it after clearing other buffer
839 // slots.
Brian Lindahl3e1e1e62022-12-21 14:28:58 -0700840 state.hwc->activeBufferSlot = hwcSlotAndBuffer.slot;
Dan Stoza6166c312021-01-15 16:34:05 -0800841 }
842
Brian Lindahl439afad2022-11-14 11:16:55 -0700843 if (auto error = hwcLayer->setBuffer(hwcSlotAndBuffer.slot, hwcSlotAndBuffer.buffer, hwcFence);
Peiyong Line9d809e2020-04-14 13:10:48 -0700844 error != hal::Error::NONE) {
Brian Lindahl439afad2022-11-14 11:16:55 -0700845 ALOGE("[%s] Failed to set buffer %p: %s (%d)", getLayerFE().getDebugName(),
846 hwcSlotAndBuffer.buffer->handle, to_string(error).c_str(),
847 static_cast<int32_t>(error));
Lloyd Piquef5275482019-01-29 18:42:42 -0800848 }
849}
850
Peiyong Line9d809e2020-04-14 13:10:48 -0700851void OutputLayer::writeCompositionTypeToHWC(HWC2::Layer* hwcLayer,
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500852 Composition requestedCompositionType,
Alec Mourid1bf1b52021-05-05 18:44:58 -0700853 bool isPeekingThrough, bool skipLayer) {
Lloyd Piquef5275482019-01-29 18:42:42 -0800854 auto& outputDependentState = editState();
855
Alec Mourid1bf1b52021-05-05 18:44:58 -0700856 if (isClientCompositionForced(isPeekingThrough)) {
857 // If we are forcing client composition, we need to tell the HWC
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500858 requestedCompositionType = Composition::CLIENT;
Lloyd Piquef5275482019-01-29 18:42:42 -0800859 }
860
861 // Set the requested composition type with the HWC whenever it changes
Alec Mourid1bf1b52021-05-05 18:44:58 -0700862 // We also resend the composition type when this layer was previously skipped, to ensure that
863 // the composition type is up-to-date.
864 if (outputDependentState.hwc->hwcCompositionType != requestedCompositionType ||
865 (outputDependentState.hwc->layerSkipped && !skipLayer)) {
Lloyd Piquef5275482019-01-29 18:42:42 -0800866 outputDependentState.hwc->hwcCompositionType = requestedCompositionType;
867
Peiyong Line9d809e2020-04-14 13:10:48 -0700868 if (auto error = hwcLayer->setCompositionType(requestedCompositionType);
869 error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700870 ALOGE("[%s] Failed to set composition type %s: %s (%d)", getLayerFE().getDebugName(),
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500871 to_string(requestedCompositionType).c_str(), to_string(error).c_str(),
Lloyd Piquea83776c2019-01-29 18:42:32 -0800872 static_cast<int32_t>(error));
873 }
Lloyd Piquea83776c2019-01-29 18:42:32 -0800874 }
875}
876
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800877void OutputLayer::writeCursorPositionToHWC() const {
878 // Skip doing this if there is no HWC interface
879 auto hwcLayer = getHwcLayer();
880 if (!hwcLayer) {
881 return;
882 }
883
Brian Lindahl1a4ffd82024-10-30 11:00:37 -0600884 const auto* layerState = getLayerFE().getCompositionState();
885 if (!layerState) {
Lloyd Piquede196652020-01-22 17:29:58 -0800886 return;
887 }
888
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700889 const auto& outputState = getOutput().getState();
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800890
Brian Lindahl1a4ffd82024-10-30 11:00:37 -0600891 Rect frame = layerState->cursorFrame;
Angel Aguayob084e0c2021-08-04 23:27:28 +0000892 frame.intersect(outputState.layerStackSpace.getContent(), &frame);
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800893 Rect position = outputState.transform.transform(frame);
894
895 if (auto error = hwcLayer->setCursorPosition(position.left, position.top);
Peiyong Line9d809e2020-04-14 13:10:48 -0700896 error != hal::Error::NONE) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700897 ALOGE("[%s] Failed to set cursor position to (%d, %d): %s (%d)",
898 getLayerFE().getDebugName(), position.left, position.top, to_string(error).c_str(),
899 static_cast<int32_t>(error));
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800900 }
901}
902
Lloyd Pique66d68602019-02-13 14:23:31 -0800903HWC2::Layer* OutputLayer::getHwcLayer() const {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700904 const auto& state = getState();
905 return state.hwc ? state.hwc->hwcLayer.get() : nullptr;
Lloyd Pique66d68602019-02-13 14:23:31 -0800906}
907
908bool OutputLayer::requiresClientComposition() const {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700909 const auto& state = getState();
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500910 return !state.hwc || state.hwc->hwcCompositionType == Composition::CLIENT;
Lloyd Pique66d68602019-02-13 14:23:31 -0800911}
912
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800913bool OutputLayer::isHardwareCursor() const {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700914 const auto& state = getState();
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500915 return state.hwc && state.hwc->hwcCompositionType == Composition::CURSOR;
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800916}
917
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500918void OutputLayer::detectDisallowedCompositionTypeChange(Composition from, Composition to) const {
Lloyd Pique66d68602019-02-13 14:23:31 -0800919 bool result = false;
920 switch (from) {
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500921 case Composition::INVALID:
922 case Composition::CLIENT:
Lloyd Pique66d68602019-02-13 14:23:31 -0800923 result = false;
924 break;
925
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500926 case Composition::DEVICE:
927 case Composition::SOLID_COLOR:
928 result = (to == Composition::CLIENT);
Lloyd Pique66d68602019-02-13 14:23:31 -0800929 break;
930
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500931 case Composition::CURSOR:
932 case Composition::SIDEBAND:
Leon Scroggins7fd536f2021-12-28 14:43:12 +0000933 case Composition::DISPLAY_DECORATION:
ramindanic1945cb2023-02-03 13:28:15 -0800934 case Composition::REFRESH_RATE_INDICATOR:
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500935 result = (to == Composition::CLIENT || to == Composition::DEVICE);
Lloyd Pique66d68602019-02-13 14:23:31 -0800936 break;
937 }
938
939 if (!result) {
940 ALOGE("[%s] Invalid device requested composition type change: %s (%d) --> %s (%d)",
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500941 getLayerFE().getDebugName(), to_string(from).c_str(), static_cast<int>(from),
942 to_string(to).c_str(), static_cast<int>(to));
Lloyd Pique66d68602019-02-13 14:23:31 -0800943 }
944}
945
Alec Mourid1bf1b52021-05-05 18:44:58 -0700946bool OutputLayer::isClientCompositionForced(bool isPeekingThrough) const {
947 return getState().forceClientComposition ||
948 (!isPeekingThrough && getLayerFE().hasRoundedCorners());
949}
950
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500951void OutputLayer::applyDeviceCompositionTypeChange(Composition compositionType) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700952 auto& state = editState();
953 LOG_FATAL_IF(!state.hwc);
954 auto& hwcState = *state.hwc;
Lloyd Pique66d68602019-02-13 14:23:31 -0800955
Alec Mourid1bf1b52021-05-05 18:44:58 -0700956 // Only detected disallowed changes if this was not a skip layer, because the
957 // validated composition type may be arbitrary (usually DEVICE, to reflect that there were
958 // fewer GPU layers)
959 if (!hwcState.layerSkipped) {
960 detectDisallowedCompositionTypeChange(hwcState.hwcCompositionType, compositionType);
961 }
Lloyd Pique66d68602019-02-13 14:23:31 -0800962
963 hwcState.hwcCompositionType = compositionType;
964}
965
966void OutputLayer::prepareForDeviceLayerRequests() {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700967 auto& state = editState();
968 state.clearClientTarget = false;
Lloyd Pique66d68602019-02-13 14:23:31 -0800969}
970
Peiyong Line9d809e2020-04-14 13:10:48 -0700971void OutputLayer::applyDeviceLayerRequest(hal::LayerRequest request) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700972 auto& state = editState();
Lloyd Pique66d68602019-02-13 14:23:31 -0800973 switch (request) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700974 case hal::LayerRequest::CLEAR_CLIENT_TARGET:
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700975 state.clearClientTarget = true;
Lloyd Pique66d68602019-02-13 14:23:31 -0800976 break;
977
978 default:
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700979 ALOGE("[%s] Unknown device layer request %s (%d)", getLayerFE().getDebugName(),
Lloyd Pique66d68602019-02-13 14:23:31 -0800980 toString(request).c_str(), static_cast<int>(request));
981 break;
982 }
983}
984
Sally Qi0abc4a52024-09-26 16:13:06 -0700985void OutputLayer::applyDeviceLayerLut(
986 ndk::ScopedFileDescriptor lutFileDescriptor,
987 std::vector<std::pair<int, LutProperties>> lutOffsetsAndProperties) {
988 auto& state = editState();
989 LOG_FATAL_IF(!state.hwc);
990 auto& hwcState = *state.hwc;
991 std::vector<int32_t> offsets;
992 std::vector<int32_t> dimensions;
993 std::vector<int32_t> sizes;
994 std::vector<int32_t> samplingKeys;
995 for (const auto& [offset, properties] : lutOffsetsAndProperties) {
996 // The Lut(s) that comes back through CommandResultPayload should be
997 // only one sampling key.
998 if (properties.samplingKeys.size() == 1) {
999 offsets.emplace_back(offset);
1000 dimensions.emplace_back(static_cast<int32_t>(properties.dimension));
1001 sizes.emplace_back(static_cast<int32_t>(properties.size));
1002 samplingKeys.emplace_back(static_cast<int32_t>(properties.samplingKeys[0]));
1003 }
1004 }
1005 hwcState.luts = std::make_shared<gui::DisplayLuts>(base::unique_fd(lutFileDescriptor.release()),
1006 std::move(offsets), std::move(dimensions),
1007 std::move(sizes), std::move(samplingKeys));
Sally Qi95f669a2024-08-27 11:31:42 -07001008}
1009
Lloyd Pique688abd42019-02-15 15:42:24 -08001010bool OutputLayer::needsFiltering() const {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001011 const auto& state = getState();
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001012 const auto& sourceCrop = state.sourceCrop;
Alec Mourib6d78932023-09-20 16:05:42 +00001013 auto displayFrameWidth = static_cast<float>(state.displayFrame.getWidth());
1014 auto displayFrameHeight = static_cast<float>(state.displayFrame.getHeight());
1015
1016 if (state.bufferTransform & HAL_TRANSFORM_ROT_90) {
1017 std::swap(displayFrameWidth, displayFrameHeight);
1018 }
1019
1020 return sourceCrop.getHeight() != displayFrameHeight ||
1021 sourceCrop.getWidth() != displayFrameWidth;
Lloyd Pique688abd42019-02-15 15:42:24 -08001022}
1023
Patrick Williams16d8b2c2022-08-08 17:29:05 +00001024std::optional<LayerFE::LayerSettings> OutputLayer::getOverrideCompositionSettings() const {
Dan Stoza6166c312021-01-15 16:34:05 -08001025 if (getState().overrideInfo.buffer == nullptr) {
1026 return {};
1027 }
1028
Alec Mouri7be6c0a2021-03-19 15:22:01 -07001029 // Compute the geometry boundaries in layer stack space: we need to transform from the
1030 // framebuffer space of the override buffer to layer space.
1031 const ProjectionSpace& layerSpace = getOutput().getState().layerStackSpace;
1032 const ui::Transform transform = getState().overrideInfo.displaySpace.getTransform(layerSpace);
Wiwit Rifa'i50abed02022-05-24 02:24:33 +00001033 const Rect boundaries = transform.transform(getState().overrideInfo.displayFrame);
Alec Mouri7be6c0a2021-03-19 15:22:01 -07001034
Dan Stoza6166c312021-01-15 16:34:05 -08001035 LayerFE::LayerSettings settings;
1036 settings.geometry = renderengine::Geometry{
Alec Mouri7be6c0a2021-03-19 15:22:01 -07001037 .boundaries = boundaries.toFloatRect(),
Dan Stoza6166c312021-01-15 16:34:05 -08001038 };
Alec Mouria90a5702021-04-16 16:36:21 +00001039 settings.bufferId = getState().overrideInfo.buffer->getBuffer()->getId();
Alec Mouri7be6c0a2021-03-19 15:22:01 -07001040 settings.source = renderengine::PixelSource{
1041 .buffer = renderengine::Buffer{
1042 .buffer = getState().overrideInfo.buffer,
1043 .fence = getState().overrideInfo.acquireFence,
1044 // If the transform from layer space to display space contains a rotation, we
1045 // need to undo the rotation in the texture transform
1046 .textureTransform =
1047 ui::Transform(transform.inverse().getOrientation(), 1, 1).asMatrix4(),
1048 }};
Alec Mouri9c8fce02021-03-12 18:30:42 -08001049 settings.sourceDataspace = getState().overrideInfo.dataspace;
Dan Stoza6166c312021-01-15 16:34:05 -08001050 settings.alpha = 1.0f;
Alec Mourie8dd3562022-02-11 14:18:57 -08001051 settings.whitePointNits = getOutput().getState().sdrWhitePointNits;
Dan Stoza6166c312021-01-15 16:34:05 -08001052
Patrick Williams16d8b2c2022-08-08 17:29:05 +00001053 return settings;
Dan Stoza6166c312021-01-15 16:34:05 -08001054}
1055
Lloyd Pique37c2c9b2018-12-04 17:25:10 -08001056void OutputLayer::dump(std::string& out) const {
1057 using android::base::StringAppendF;
1058
Lloyd Piquede196652020-01-22 17:29:58 -08001059 StringAppendF(&out, " - Output Layer %p(%s)\n", this, getLayerFE().getDebugName());
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001060 dumpState(out);
Lloyd Pique37c2c9b2018-12-04 17:25:10 -08001061}
1062
Lloyd Piquecc01a452018-12-04 17:24:00 -08001063} // namespace impl
1064} // namespace android::compositionengine