Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 17 | #include <android-base/stringprintf.h> |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 18 | #include <compositionengine/DisplayColorProfile.h> |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 19 | #include <compositionengine/Layer.h> |
| 20 | #include <compositionengine/LayerFE.h> |
Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 21 | #include <compositionengine/LayerFECompositionState.h> |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 22 | #include <compositionengine/Output.h> |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 23 | #include <compositionengine/impl/OutputCompositionState.h> |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 24 | #include <compositionengine/impl/OutputLayer.h> |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 25 | #include <compositionengine/impl/OutputLayerCompositionState.h> |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 26 | |
Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 27 | #include "DisplayHardware/HWComposer.h" |
| 28 | |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 29 | namespace android::compositionengine { |
| 30 | |
| 31 | OutputLayer::~OutputLayer() = default; |
| 32 | |
| 33 | namespace impl { |
| 34 | |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 35 | namespace { |
| 36 | |
| 37 | FloatRect reduce(const FloatRect& win, const Region& exclude) { |
| 38 | if (CC_LIKELY(exclude.isEmpty())) { |
| 39 | return win; |
| 40 | } |
| 41 | // Convert through Rect (by rounding) for lack of FloatRegion |
| 42 | return Region(Rect{win}).subtract(exclude).getBounds().toFloatRect(); |
| 43 | } |
| 44 | |
| 45 | } // namespace |
| 46 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 47 | std::unique_ptr<OutputLayer> createOutputLayer( |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 48 | const compositionengine::Output& output, |
| 49 | const std::shared_ptr<compositionengine::Layer>& layer, |
| 50 | const sp<compositionengine::LayerFE>& layerFE) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 51 | return createOutputLayerTemplated<OutputLayer>(output, layer, layerFE); |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 52 | } |
| 53 | |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 54 | OutputLayer::~OutputLayer() = default; |
| 55 | |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 56 | void OutputLayer::setHwcLayer(std::shared_ptr<HWC2::Layer> hwcLayer) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 57 | auto& state = editState(); |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 58 | if (hwcLayer) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 59 | state.hwc.emplace(std::move(hwcLayer)); |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 60 | } else { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 61 | state.hwc.reset(); |
Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 62 | } |
Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 63 | } |
| 64 | |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 65 | Rect OutputLayer::calculateInitialCrop() const { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 66 | const auto& layerState = getLayer().getFEState(); |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 67 | |
| 68 | // apply the projection's clipping to the window crop in |
| 69 | // layerstack space, and convert-back to layer space. |
| 70 | // if there are no window scaling involved, this operation will map to full |
| 71 | // pixels in the buffer. |
| 72 | |
| 73 | FloatRect activeCropFloat = |
Lloyd Pique | c668734 | 2019-03-07 21:34:57 -0800 | [diff] [blame] | 74 | reduce(layerState.geomLayerBounds, layerState.transparentRegionHint); |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 75 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 76 | const Rect& viewport = getOutput().getState().viewport; |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 77 | const ui::Transform& layerTransform = layerState.geomLayerTransform; |
| 78 | const ui::Transform& inverseLayerTransform = layerState.geomInverseLayerTransform; |
| 79 | // Transform to screen space. |
| 80 | activeCropFloat = layerTransform.transform(activeCropFloat); |
| 81 | activeCropFloat = activeCropFloat.intersect(viewport.toFloatRect()); |
| 82 | // Back to layer space to work with the content crop. |
| 83 | activeCropFloat = inverseLayerTransform.transform(activeCropFloat); |
| 84 | |
| 85 | // This needs to be here as transform.transform(Rect) computes the |
| 86 | // transformed rect and then takes the bounding box of the result before |
| 87 | // returning. This means |
| 88 | // transform.inverse().transform(transform.transform(Rect)) != Rect |
| 89 | // in which case we need to make sure the final rect is clipped to the |
| 90 | // display bounds. |
| 91 | Rect activeCrop{activeCropFloat}; |
| 92 | if (!activeCrop.intersect(layerState.geomBufferSize, &activeCrop)) { |
| 93 | activeCrop.clear(); |
| 94 | } |
| 95 | return activeCrop; |
| 96 | } |
| 97 | |
| 98 | FloatRect OutputLayer::calculateOutputSourceCrop() const { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 99 | const auto& layerState = getLayer().getFEState(); |
| 100 | const auto& outputState = getOutput().getState(); |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 101 | |
| 102 | if (!layerState.geomUsesSourceCrop) { |
| 103 | return {}; |
| 104 | } |
| 105 | |
| 106 | // the content crop is the area of the content that gets scaled to the |
| 107 | // layer's size. This is in buffer space. |
| 108 | FloatRect crop = layerState.geomContentCrop.toFloatRect(); |
| 109 | |
| 110 | // In addition there is a WM-specified crop we pull from our drawing state. |
| 111 | Rect activeCrop = calculateInitialCrop(); |
| 112 | const Rect& bufferSize = layerState.geomBufferSize; |
| 113 | |
| 114 | int winWidth = bufferSize.getWidth(); |
| 115 | int winHeight = bufferSize.getHeight(); |
| 116 | |
| 117 | // The bufferSize for buffer state layers can be unbounded ([0, 0, -1, -1]) |
| 118 | // if display frame hasn't been set and the parent is an unbounded layer. |
| 119 | if (winWidth < 0 && winHeight < 0) { |
| 120 | return crop; |
| 121 | } |
| 122 | |
| 123 | // Transform the window crop to match the buffer coordinate system, |
| 124 | // which means using the inverse of the current transform set on the |
| 125 | // SurfaceFlingerConsumer. |
| 126 | uint32_t invTransform = layerState.geomBufferTransform; |
| 127 | if (layerState.geomBufferUsesDisplayInverseTransform) { |
| 128 | /* |
| 129 | * the code below applies the primary display's inverse transform to the |
| 130 | * buffer |
| 131 | */ |
| 132 | uint32_t invTransformOrient = outputState.orientation; |
| 133 | // calculate the inverse transform |
| 134 | if (invTransformOrient & HAL_TRANSFORM_ROT_90) { |
| 135 | invTransformOrient ^= HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_FLIP_H; |
| 136 | } |
| 137 | // and apply to the current transform |
| 138 | invTransform = |
| 139 | (ui::Transform(invTransformOrient) * ui::Transform(invTransform)).getOrientation(); |
| 140 | } |
| 141 | |
| 142 | if (invTransform & HAL_TRANSFORM_ROT_90) { |
| 143 | // If the activeCrop has been rotate the ends are rotated but not |
| 144 | // the space itself so when transforming ends back we can't rely on |
| 145 | // a modification of the axes of rotation. To account for this we |
| 146 | // need to reorient the inverse rotation in terms of the current |
| 147 | // axes of rotation. |
| 148 | bool is_h_flipped = (invTransform & HAL_TRANSFORM_FLIP_H) != 0; |
| 149 | bool is_v_flipped = (invTransform & HAL_TRANSFORM_FLIP_V) != 0; |
| 150 | if (is_h_flipped == is_v_flipped) { |
| 151 | invTransform ^= HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_FLIP_H; |
| 152 | } |
| 153 | std::swap(winWidth, winHeight); |
| 154 | } |
| 155 | const Rect winCrop = |
| 156 | activeCrop.transform(invTransform, bufferSize.getWidth(), bufferSize.getHeight()); |
| 157 | |
| 158 | // below, crop is intersected with winCrop expressed in crop's coordinate space |
| 159 | float xScale = crop.getWidth() / float(winWidth); |
| 160 | float yScale = crop.getHeight() / float(winHeight); |
| 161 | |
| 162 | float insetL = winCrop.left * xScale; |
| 163 | float insetT = winCrop.top * yScale; |
| 164 | float insetR = (winWidth - winCrop.right) * xScale; |
| 165 | float insetB = (winHeight - winCrop.bottom) * yScale; |
| 166 | |
| 167 | crop.left += insetL; |
| 168 | crop.top += insetT; |
| 169 | crop.right -= insetR; |
| 170 | crop.bottom -= insetB; |
| 171 | |
| 172 | return crop; |
| 173 | } |
| 174 | |
| 175 | Rect OutputLayer::calculateOutputDisplayFrame() const { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 176 | const auto& layerState = getLayer().getFEState(); |
| 177 | const auto& outputState = getOutput().getState(); |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 178 | |
| 179 | // apply the layer's transform, followed by the display's global transform |
| 180 | // here we're guaranteed that the layer's transform preserves rects |
Lloyd Pique | c668734 | 2019-03-07 21:34:57 -0800 | [diff] [blame] | 181 | Region activeTransparentRegion = layerState.transparentRegionHint; |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 182 | const ui::Transform& layerTransform = layerState.geomLayerTransform; |
| 183 | const ui::Transform& inverseLayerTransform = layerState.geomInverseLayerTransform; |
| 184 | const Rect& bufferSize = layerState.geomBufferSize; |
| 185 | Rect activeCrop = layerState.geomCrop; |
| 186 | if (!activeCrop.isEmpty() && bufferSize.isValid()) { |
| 187 | activeCrop = layerTransform.transform(activeCrop); |
| 188 | if (!activeCrop.intersect(outputState.viewport, &activeCrop)) { |
| 189 | activeCrop.clear(); |
| 190 | } |
| 191 | activeCrop = inverseLayerTransform.transform(activeCrop, true); |
| 192 | // This needs to be here as transform.transform(Rect) computes the |
| 193 | // transformed rect and then takes the bounding box of the result before |
| 194 | // returning. This means |
| 195 | // transform.inverse().transform(transform.transform(Rect)) != Rect |
| 196 | // in which case we need to make sure the final rect is clipped to the |
| 197 | // display bounds. |
| 198 | if (!activeCrop.intersect(bufferSize, &activeCrop)) { |
| 199 | activeCrop.clear(); |
| 200 | } |
| 201 | // mark regions outside the crop as transparent |
| 202 | activeTransparentRegion.orSelf(Rect(0, 0, bufferSize.getWidth(), activeCrop.top)); |
| 203 | activeTransparentRegion.orSelf( |
| 204 | Rect(0, activeCrop.bottom, bufferSize.getWidth(), bufferSize.getHeight())); |
| 205 | activeTransparentRegion.orSelf(Rect(0, activeCrop.top, activeCrop.left, activeCrop.bottom)); |
| 206 | activeTransparentRegion.orSelf( |
| 207 | Rect(activeCrop.right, activeCrop.top, bufferSize.getWidth(), activeCrop.bottom)); |
| 208 | } |
| 209 | |
| 210 | // reduce uses a FloatRect to provide more accuracy during the |
| 211 | // transformation. We then round upon constructing 'frame'. |
| 212 | Rect frame{ |
| 213 | layerTransform.transform(reduce(layerState.geomLayerBounds, activeTransparentRegion))}; |
| 214 | if (!frame.intersect(outputState.viewport, &frame)) { |
| 215 | frame.clear(); |
| 216 | } |
| 217 | const ui::Transform displayTransform{outputState.transform}; |
| 218 | |
| 219 | return displayTransform.transform(frame); |
| 220 | } |
| 221 | |
| 222 | uint32_t OutputLayer::calculateOutputRelativeBufferTransform() const { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 223 | const auto& layerState = getLayer().getFEState(); |
| 224 | const auto& outputState = getOutput().getState(); |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 225 | |
| 226 | /* |
| 227 | * Transformations are applied in this order: |
| 228 | * 1) buffer orientation/flip/mirror |
| 229 | * 2) state transformation (window manager) |
| 230 | * 3) layer orientation (screen orientation) |
| 231 | * (NOTE: the matrices are multiplied in reverse order) |
| 232 | */ |
| 233 | const ui::Transform& layerTransform = layerState.geomLayerTransform; |
| 234 | const ui::Transform displayTransform{outputState.orientation}; |
| 235 | const ui::Transform bufferTransform{layerState.geomBufferTransform}; |
| 236 | ui::Transform transform(displayTransform * layerTransform * bufferTransform); |
| 237 | |
| 238 | if (layerState.geomBufferUsesDisplayInverseTransform) { |
| 239 | /* |
| 240 | * the code below applies the primary display's inverse transform to the |
| 241 | * buffer |
| 242 | */ |
| 243 | uint32_t invTransform = outputState.orientation; |
| 244 | // calculate the inverse transform |
| 245 | if (invTransform & HAL_TRANSFORM_ROT_90) { |
| 246 | invTransform ^= HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_FLIP_H; |
| 247 | } |
| 248 | |
| 249 | /* |
| 250 | * Here we cancel out the orientation component of the WM transform. |
| 251 | * The scaling and translate components are already included in our bounds |
| 252 | * computation so it's enough to just omit it in the composition. |
| 253 | * See comment in BufferLayer::prepareClientLayer with ref to b/36727915 for why. |
| 254 | */ |
Lloyd Pique | 546a245 | 2019-03-18 20:53:27 +0000 | [diff] [blame] | 255 | transform = ui::Transform(invTransform) * displayTransform * bufferTransform; |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | // this gives us only the "orientation" component of the transform |
| 259 | return transform.getOrientation(); |
| 260 | } // namespace impl |
| 261 | |
Lloyd Pique | 7a23491 | 2019-10-03 11:54:27 -0700 | [diff] [blame^] | 262 | void OutputLayer::updateCompositionState(bool includeGeometry, bool forceClientComposition) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 263 | const auto& layerFEState = getLayer().getFEState(); |
| 264 | const auto& outputState = getOutput().getState(); |
| 265 | const auto& profile = *getOutput().getDisplayColorProfile(); |
| 266 | auto& state = editState(); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 267 | |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 268 | if (includeGeometry) { |
Lloyd Pique | fe67102 | 2019-09-24 10:43:03 -0700 | [diff] [blame] | 269 | // Clear the forceClientComposition flag before it is set for any |
| 270 | // reason. Note that since it can be set by some checks below when |
| 271 | // updating the geometry state, we only clear it when updating the |
| 272 | // geometry since those conditions for forcing client composition won't |
| 273 | // go away otherwise. |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 274 | state.forceClientComposition = false; |
Lloyd Pique | fe67102 | 2019-09-24 10:43:03 -0700 | [diff] [blame] | 275 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 276 | state.displayFrame = calculateOutputDisplayFrame(); |
| 277 | state.sourceCrop = calculateOutputSourceCrop(); |
| 278 | state.bufferTransform = |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 279 | static_cast<Hwc2::Transform>(calculateOutputRelativeBufferTransform()); |
| 280 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 281 | if ((layerFEState.isSecure && !outputState.isSecure) || |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 282 | (state.bufferTransform & ui::Transform::ROT_INVALID)) { |
| 283 | state.forceClientComposition = true; |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 284 | } |
| 285 | } |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 286 | |
| 287 | // Determine the output dependent dataspace for this layer. If it is |
| 288 | // colorspace agnostic, it just uses the dataspace chosen for the output to |
| 289 | // avoid the need for color conversion. |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 290 | state.dataspace = layerFEState.isColorspaceAgnostic && |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 291 | outputState.targetDataspace != ui::Dataspace::UNKNOWN |
| 292 | ? outputState.targetDataspace |
| 293 | : layerFEState.dataspace; |
| 294 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 295 | // These are evaluated every frame as they can potentially change at any |
| 296 | // time. |
Lloyd Pique | 7a23491 | 2019-10-03 11:54:27 -0700 | [diff] [blame^] | 297 | if (layerFEState.forceClientComposition || !profile.isDataspaceSupported(state.dataspace) || |
| 298 | forceClientComposition) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 299 | state.forceClientComposition = true; |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 300 | } |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 301 | } |
| 302 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 303 | void OutputLayer::writeStateToHWC(bool includeGeometry) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 304 | const auto& state = getState(); |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 305 | // Skip doing this if there is no HWC interface |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 306 | if (!state.hwc) { |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 307 | return; |
| 308 | } |
| 309 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 310 | auto& hwcLayer = (*state.hwc).hwcLayer; |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 311 | if (!hwcLayer) { |
| 312 | ALOGE("[%s] failed to write composition state to HWC -- no hwcLayer for output %s", |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 313 | getLayerFE().getDebugName(), getOutput().getName().c_str()); |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 314 | return; |
| 315 | } |
| 316 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 317 | const auto& outputIndependentState = getLayer().getFEState(); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 318 | auto requestedCompositionType = outputIndependentState.compositionType; |
| 319 | |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 320 | if (includeGeometry) { |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 321 | writeOutputDependentGeometryStateToHWC(hwcLayer.get(), requestedCompositionType); |
| 322 | writeOutputIndependentGeometryStateToHWC(hwcLayer.get(), outputIndependentState); |
| 323 | } |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 324 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 325 | writeOutputDependentPerFrameStateToHWC(hwcLayer.get()); |
| 326 | writeOutputIndependentPerFrameStateToHWC(hwcLayer.get(), outputIndependentState); |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 327 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 328 | writeCompositionTypeToHWC(hwcLayer.get(), requestedCompositionType); |
| 329 | } |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 330 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 331 | void OutputLayer::writeOutputDependentGeometryStateToHWC( |
| 332 | HWC2::Layer* hwcLayer, Hwc2::IComposerClient::Composition requestedCompositionType) { |
| 333 | const auto& outputDependentState = getState(); |
| 334 | |
| 335 | if (auto error = hwcLayer->setDisplayFrame(outputDependentState.displayFrame); |
| 336 | error != HWC2::Error::None) { |
| 337 | ALOGE("[%s] Failed to set display frame [%d, %d, %d, %d]: %s (%d)", |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 338 | getLayerFE().getDebugName(), outputDependentState.displayFrame.left, |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 339 | outputDependentState.displayFrame.top, outputDependentState.displayFrame.right, |
| 340 | outputDependentState.displayFrame.bottom, to_string(error).c_str(), |
| 341 | static_cast<int32_t>(error)); |
| 342 | } |
| 343 | |
| 344 | if (auto error = hwcLayer->setSourceCrop(outputDependentState.sourceCrop); |
| 345 | error != HWC2::Error::None) { |
| 346 | ALOGE("[%s] Failed to set source crop [%.3f, %.3f, %.3f, %.3f]: " |
| 347 | "%s (%d)", |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 348 | getLayerFE().getDebugName(), outputDependentState.sourceCrop.left, |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 349 | outputDependentState.sourceCrop.top, outputDependentState.sourceCrop.right, |
| 350 | outputDependentState.sourceCrop.bottom, to_string(error).c_str(), |
| 351 | static_cast<int32_t>(error)); |
| 352 | } |
| 353 | |
| 354 | if (auto error = hwcLayer->setZOrder(outputDependentState.z); error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 355 | ALOGE("[%s] Failed to set Z %u: %s (%d)", getLayerFE().getDebugName(), |
| 356 | outputDependentState.z, to_string(error).c_str(), static_cast<int32_t>(error)); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | // Solid-color layers should always use an identity transform. |
| 360 | const auto bufferTransform = |
| 361 | requestedCompositionType != Hwc2::IComposerClient::Composition::SOLID_COLOR |
| 362 | ? outputDependentState.bufferTransform |
| 363 | : static_cast<Hwc2::Transform>(0); |
| 364 | if (auto error = hwcLayer->setTransform(static_cast<HWC2::Transform>(bufferTransform)); |
| 365 | error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 366 | ALOGE("[%s] Failed to set transform %s: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 367 | toString(outputDependentState.bufferTransform).c_str(), to_string(error).c_str(), |
| 368 | static_cast<int32_t>(error)); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | void OutputLayer::writeOutputIndependentGeometryStateToHWC( |
| 373 | HWC2::Layer* hwcLayer, const LayerFECompositionState& outputIndependentState) { |
| 374 | if (auto error = hwcLayer->setBlendMode( |
| 375 | static_cast<HWC2::BlendMode>(outputIndependentState.blendMode)); |
| 376 | error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 377 | ALOGE("[%s] Failed to set blend mode %s: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 378 | toString(outputIndependentState.blendMode).c_str(), to_string(error).c_str(), |
| 379 | static_cast<int32_t>(error)); |
| 380 | } |
| 381 | |
| 382 | if (auto error = hwcLayer->setPlaneAlpha(outputIndependentState.alpha); |
| 383 | error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 384 | ALOGE("[%s] Failed to set plane alpha %.3f: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 385 | outputIndependentState.alpha, to_string(error).c_str(), static_cast<int32_t>(error)); |
| 386 | } |
| 387 | |
| 388 | if (auto error = hwcLayer->setInfo(outputIndependentState.type, outputIndependentState.appId); |
| 389 | error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 390 | ALOGE("[%s] Failed to set info %s (%d)", getLayerFE().getDebugName(), |
| 391 | to_string(error).c_str(), static_cast<int32_t>(error)); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 392 | } |
| 393 | } |
| 394 | |
| 395 | void OutputLayer::writeOutputDependentPerFrameStateToHWC(HWC2::Layer* hwcLayer) { |
| 396 | const auto& outputDependentState = getState(); |
| 397 | |
Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 398 | // TODO(lpique): b/121291683 outputSpaceVisibleRegion is output-dependent geometry |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 399 | // state and should not change every frame. |
Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 400 | if (auto error = hwcLayer->setVisibleRegion(outputDependentState.outputSpaceVisibleRegion); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 401 | error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 402 | ALOGE("[%s] Failed to set visible region: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 403 | to_string(error).c_str(), static_cast<int32_t>(error)); |
Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 404 | outputDependentState.outputSpaceVisibleRegion.dump(LOG_TAG); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | if (auto error = hwcLayer->setDataspace(outputDependentState.dataspace); |
| 408 | error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 409 | ALOGE("[%s] Failed to set dataspace %d: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 410 | outputDependentState.dataspace, to_string(error).c_str(), |
| 411 | static_cast<int32_t>(error)); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | void OutputLayer::writeOutputIndependentPerFrameStateToHWC( |
| 416 | HWC2::Layer* hwcLayer, const LayerFECompositionState& outputIndependentState) { |
| 417 | switch (auto error = hwcLayer->setColorTransform(outputIndependentState.colorTransform)) { |
| 418 | case HWC2::Error::None: |
| 419 | break; |
| 420 | case HWC2::Error::Unsupported: |
| 421 | editState().forceClientComposition = true; |
| 422 | break; |
| 423 | default: |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 424 | ALOGE("[%s] Failed to set color transform: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 425 | to_string(error).c_str(), static_cast<int32_t>(error)); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 426 | } |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 427 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 428 | if (auto error = hwcLayer->setSurfaceDamage(outputIndependentState.surfaceDamage); |
| 429 | error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 430 | ALOGE("[%s] Failed to set surface damage: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 431 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 432 | outputIndependentState.surfaceDamage.dump(LOG_TAG); |
| 433 | } |
| 434 | |
| 435 | // Content-specific per-frame state |
| 436 | switch (outputIndependentState.compositionType) { |
| 437 | case Hwc2::IComposerClient::Composition::SOLID_COLOR: |
| 438 | writeSolidColorStateToHWC(hwcLayer, outputIndependentState); |
| 439 | break; |
| 440 | case Hwc2::IComposerClient::Composition::SIDEBAND: |
| 441 | writeSidebandStateToHWC(hwcLayer, outputIndependentState); |
| 442 | break; |
| 443 | case Hwc2::IComposerClient::Composition::CURSOR: |
| 444 | case Hwc2::IComposerClient::Composition::DEVICE: |
| 445 | writeBufferStateToHWC(hwcLayer, outputIndependentState); |
| 446 | break; |
| 447 | case Hwc2::IComposerClient::Composition::INVALID: |
| 448 | case Hwc2::IComposerClient::Composition::CLIENT: |
| 449 | // Ignored |
| 450 | break; |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | void OutputLayer::writeSolidColorStateToHWC(HWC2::Layer* hwcLayer, |
| 455 | const LayerFECompositionState& outputIndependentState) { |
| 456 | hwc_color_t color = {static_cast<uint8_t>(std::round(255.0f * outputIndependentState.color.r)), |
| 457 | static_cast<uint8_t>(std::round(255.0f * outputIndependentState.color.g)), |
| 458 | static_cast<uint8_t>(std::round(255.0f * outputIndependentState.color.b)), |
| 459 | 255}; |
| 460 | |
| 461 | if (auto error = hwcLayer->setColor(color); error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 462 | ALOGE("[%s] Failed to set color: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 463 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | void OutputLayer::writeSidebandStateToHWC(HWC2::Layer* hwcLayer, |
| 468 | const LayerFECompositionState& outputIndependentState) { |
| 469 | if (auto error = hwcLayer->setSidebandStream(outputIndependentState.sidebandStream->handle()); |
| 470 | error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 471 | ALOGE("[%s] Failed to set sideband stream %p: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 472 | outputIndependentState.sidebandStream->handle(), to_string(error).c_str(), |
| 473 | static_cast<int32_t>(error)); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | void OutputLayer::writeBufferStateToHWC(HWC2::Layer* hwcLayer, |
| 478 | const LayerFECompositionState& outputIndependentState) { |
| 479 | auto supportedPerFrameMetadata = |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 480 | getOutput().getDisplayColorProfile()->getSupportedPerFrameMetadata(); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 481 | if (auto error = hwcLayer->setPerFrameMetadata(supportedPerFrameMetadata, |
| 482 | outputIndependentState.hdrMetadata); |
| 483 | error != HWC2::Error::None && error != HWC2::Error::Unsupported) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 484 | ALOGE("[%s] Failed to set hdrMetadata: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 485 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 486 | } |
| 487 | |
| 488 | uint32_t hwcSlot = 0; |
| 489 | sp<GraphicBuffer> hwcBuffer; |
| 490 | // We need access to the output-dependent state for the buffer cache there, |
| 491 | // though otherwise the buffer is not output-dependent. |
| 492 | editState().hwc->hwcBufferCache.getHwcBuffer(outputIndependentState.bufferSlot, |
| 493 | outputIndependentState.buffer, &hwcSlot, |
| 494 | &hwcBuffer); |
| 495 | |
| 496 | if (auto error = hwcLayer->setBuffer(hwcSlot, hwcBuffer, outputIndependentState.acquireFence); |
| 497 | error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 498 | ALOGE("[%s] Failed to set buffer %p: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 499 | outputIndependentState.buffer->handle, to_string(error).c_str(), |
| 500 | static_cast<int32_t>(error)); |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | void OutputLayer::writeCompositionTypeToHWC( |
| 505 | HWC2::Layer* hwcLayer, Hwc2::IComposerClient::Composition requestedCompositionType) { |
| 506 | auto& outputDependentState = editState(); |
| 507 | |
| 508 | // If we are forcing client composition, we need to tell the HWC |
| 509 | if (outputDependentState.forceClientComposition) { |
| 510 | requestedCompositionType = Hwc2::IComposerClient::Composition::CLIENT; |
| 511 | } |
| 512 | |
| 513 | // Set the requested composition type with the HWC whenever it changes |
| 514 | if (outputDependentState.hwc->hwcCompositionType != requestedCompositionType) { |
| 515 | outputDependentState.hwc->hwcCompositionType = requestedCompositionType; |
| 516 | |
| 517 | if (auto error = hwcLayer->setCompositionType( |
| 518 | static_cast<HWC2::Composition>(requestedCompositionType)); |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 519 | error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 520 | ALOGE("[%s] Failed to set composition type %s: %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 521 | toString(requestedCompositionType).c_str(), to_string(error).c_str(), |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 522 | static_cast<int32_t>(error)); |
| 523 | } |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 524 | } |
| 525 | } |
| 526 | |
Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 527 | void OutputLayer::writeCursorPositionToHWC() const { |
| 528 | // Skip doing this if there is no HWC interface |
| 529 | auto hwcLayer = getHwcLayer(); |
| 530 | if (!hwcLayer) { |
| 531 | return; |
| 532 | } |
| 533 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 534 | const auto& layerFEState = getLayer().getFEState(); |
| 535 | const auto& outputState = getOutput().getState(); |
Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 536 | |
| 537 | Rect frame = layerFEState.cursorFrame; |
| 538 | frame.intersect(outputState.viewport, &frame); |
| 539 | Rect position = outputState.transform.transform(frame); |
| 540 | |
| 541 | if (auto error = hwcLayer->setCursorPosition(position.left, position.top); |
| 542 | error != HWC2::Error::None) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 543 | ALOGE("[%s] Failed to set cursor position to (%d, %d): %s (%d)", |
| 544 | getLayerFE().getDebugName(), position.left, position.top, to_string(error).c_str(), |
| 545 | static_cast<int32_t>(error)); |
Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 546 | } |
| 547 | } |
| 548 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 549 | HWC2::Layer* OutputLayer::getHwcLayer() const { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 550 | const auto& state = getState(); |
| 551 | return state.hwc ? state.hwc->hwcLayer.get() : nullptr; |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | bool OutputLayer::requiresClientComposition() const { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 555 | const auto& state = getState(); |
| 556 | return !state.hwc || |
| 557 | state.hwc->hwcCompositionType == Hwc2::IComposerClient::Composition::CLIENT; |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 558 | } |
| 559 | |
Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 560 | bool OutputLayer::isHardwareCursor() const { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 561 | const auto& state = getState(); |
| 562 | return state.hwc && state.hwc->hwcCompositionType == Hwc2::IComposerClient::Composition::CURSOR; |
Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 563 | } |
| 564 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 565 | void OutputLayer::detectDisallowedCompositionTypeChange( |
| 566 | Hwc2::IComposerClient::Composition from, Hwc2::IComposerClient::Composition to) const { |
| 567 | bool result = false; |
| 568 | switch (from) { |
| 569 | case Hwc2::IComposerClient::Composition::INVALID: |
| 570 | case Hwc2::IComposerClient::Composition::CLIENT: |
| 571 | result = false; |
| 572 | break; |
| 573 | |
| 574 | case Hwc2::IComposerClient::Composition::DEVICE: |
| 575 | case Hwc2::IComposerClient::Composition::SOLID_COLOR: |
| 576 | result = (to == Hwc2::IComposerClient::Composition::CLIENT); |
| 577 | break; |
| 578 | |
| 579 | case Hwc2::IComposerClient::Composition::CURSOR: |
| 580 | case Hwc2::IComposerClient::Composition::SIDEBAND: |
| 581 | result = (to == Hwc2::IComposerClient::Composition::CLIENT || |
| 582 | to == Hwc2::IComposerClient::Composition::DEVICE); |
| 583 | break; |
| 584 | } |
| 585 | |
| 586 | if (!result) { |
| 587 | ALOGE("[%s] Invalid device requested composition type change: %s (%d) --> %s (%d)", |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 588 | getLayerFE().getDebugName(), toString(from).c_str(), static_cast<int>(from), |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 589 | toString(to).c_str(), static_cast<int>(to)); |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | void OutputLayer::applyDeviceCompositionTypeChange( |
| 594 | Hwc2::IComposerClient::Composition compositionType) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 595 | auto& state = editState(); |
| 596 | LOG_FATAL_IF(!state.hwc); |
| 597 | auto& hwcState = *state.hwc; |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 598 | |
| 599 | detectDisallowedCompositionTypeChange(hwcState.hwcCompositionType, compositionType); |
| 600 | |
| 601 | hwcState.hwcCompositionType = compositionType; |
| 602 | } |
| 603 | |
| 604 | void OutputLayer::prepareForDeviceLayerRequests() { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 605 | auto& state = editState(); |
| 606 | state.clearClientTarget = false; |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | void OutputLayer::applyDeviceLayerRequest(Hwc2::IComposerClient::LayerRequest request) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 610 | auto& state = editState(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 611 | switch (request) { |
| 612 | case Hwc2::IComposerClient::LayerRequest::CLEAR_CLIENT_TARGET: |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 613 | state.clearClientTarget = true; |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 614 | break; |
| 615 | |
| 616 | default: |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 617 | ALOGE("[%s] Unknown device layer request %s (%d)", getLayerFE().getDebugName(), |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 618 | toString(request).c_str(), static_cast<int>(request)); |
| 619 | break; |
| 620 | } |
| 621 | } |
| 622 | |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 623 | bool OutputLayer::needsFiltering() const { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 624 | const auto& state = getState(); |
| 625 | const auto& displayFrame = state.displayFrame; |
| 626 | const auto& sourceCrop = state.sourceCrop; |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 627 | return sourceCrop.getHeight() != displayFrame.getHeight() || |
| 628 | sourceCrop.getWidth() != displayFrame.getWidth(); |
| 629 | } |
| 630 | |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 631 | void OutputLayer::dump(std::string& out) const { |
| 632 | using android::base::StringAppendF; |
| 633 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 634 | StringAppendF(&out, " - Output Layer %p (Composition layer %p) (%s)\n", this, &getLayer(), |
| 635 | getLayerFE().getDebugName()); |
| 636 | dumpState(out); |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 637 | } |
| 638 | |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 639 | } // namespace impl |
| 640 | } // namespace android::compositionengine |