Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 18 | #undef LOG_TAG |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame^] | 19 | #define LOG_TAG "SurfaceFlinger" |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 20 | |
| 21 | #include "LayerSnapshot.h" |
| 22 | |
| 23 | namespace android::surfaceflinger::frontend { |
| 24 | |
| 25 | using namespace ftl::flag_operators; |
| 26 | |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame^] | 27 | namespace { |
| 28 | |
| 29 | void updateSurfaceDamage(const RequestedLayerState& requested, bool hasReadyFrame, |
| 30 | bool forceFullDamage, Region& outSurfaceDamageRegion) { |
| 31 | if (!hasReadyFrame) { |
| 32 | outSurfaceDamageRegion.clear(); |
| 33 | return; |
| 34 | } |
| 35 | if (forceFullDamage) { |
| 36 | outSurfaceDamageRegion = Region::INVALID_REGION; |
| 37 | } else { |
| 38 | outSurfaceDamageRegion = requested.surfaceDamageRegion; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | } // namespace |
| 43 | |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 44 | LayerSnapshot::LayerSnapshot(const RequestedLayerState& state, |
| 45 | const LayerHierarchy::TraversalPath& path) |
| 46 | : path(path) { |
Vishnu Nair | d018360 | 2023-03-16 18:52:15 +0000 | [diff] [blame] | 47 | // Provide a unique id for all snapshots. |
| 48 | // A front end layer can generate multiple snapshots if its mirrored. |
| 49 | // Additionally, if the layer is not reachable, we may choose to destroy |
| 50 | // and recreate the snapshot in which case the unique sequence id will |
| 51 | // change. The consumer shouldn't tie any lifetimes to this unique id but |
| 52 | // register a LayerLifecycleManager::ILifecycleListener or get a list of |
| 53 | // destroyed layers from LayerLifecycleManager. |
Vishnu Nair | 150065b | 2023-04-17 19:14:11 -0700 | [diff] [blame] | 54 | if (path.isClone()) { |
| 55 | uniqueSequence = |
| 56 | LayerCreationArgs::getInternalLayerId(LayerCreationArgs::sInternalSequence++); |
| 57 | } else { |
| 58 | uniqueSequence = state.id; |
| 59 | } |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 60 | sequence = static_cast<int32_t>(state.id); |
| 61 | name = state.name; |
| 62 | textureName = state.textureName; |
| 63 | premultipliedAlpha = state.premultipliedAlpha; |
| 64 | inputInfo.name = state.name; |
Vishnu Nair | 93b8b79 | 2023-02-27 19:40:24 +0000 | [diff] [blame] | 65 | inputInfo.id = static_cast<int32_t>(uniqueSequence); |
Prabir Pradhan | 8a5c41d | 2023-06-08 19:13:46 +0000 | [diff] [blame] | 66 | inputInfo.ownerUid = gui::Uid{state.ownerUid}; |
Prabir Pradhan | e59c6dc | 2023-06-13 19:53:03 +0000 | [diff] [blame] | 67 | inputInfo.ownerPid = gui::Pid{state.ownerPid}; |
Vishnu Nair | 36d5f8e | 2023-03-19 13:31:35 -0700 | [diff] [blame] | 68 | uid = state.ownerUid; |
| 69 | pid = state.ownerPid; |
Vishnu Nair | 92990e2 | 2023-02-24 20:01:05 +0000 | [diff] [blame] | 70 | changes = RequestedLayerState::Changes::Created; |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame^] | 71 | clientChanges = 0; |
Vishnu Nair | 92990e2 | 2023-02-24 20:01:05 +0000 | [diff] [blame] | 72 | mirrorRootPath = path.variant == LayerHierarchy::Variant::Mirror |
| 73 | ? path |
| 74 | : LayerHierarchy::TraversalPath::ROOT; |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame^] | 75 | reachablilty = LayerSnapshot::Reachablilty::Unreachable; |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | // As documented in libhardware header, formats in the range |
| 79 | // 0x100 - 0x1FF are specific to the HAL implementation, and |
| 80 | // are known to have no alpha channel |
| 81 | // TODO: move definition for device-specific range into |
| 82 | // hardware.h, instead of using hard-coded values here. |
| 83 | #define HARDWARE_IS_DEVICE_FORMAT(f) ((f) >= 0x100 && (f) <= 0x1FF) |
| 84 | |
| 85 | bool LayerSnapshot::isOpaqueFormat(PixelFormat format) { |
| 86 | if (HARDWARE_IS_DEVICE_FORMAT(format)) { |
| 87 | return true; |
| 88 | } |
| 89 | switch (format) { |
| 90 | case PIXEL_FORMAT_RGBA_8888: |
| 91 | case PIXEL_FORMAT_BGRA_8888: |
| 92 | case PIXEL_FORMAT_RGBA_FP16: |
| 93 | case PIXEL_FORMAT_RGBA_1010102: |
| 94 | case PIXEL_FORMAT_R_8: |
| 95 | return false; |
| 96 | } |
| 97 | // in all other case, we have no blending (also for unknown formats) |
| 98 | return true; |
| 99 | } |
| 100 | |
| 101 | bool LayerSnapshot::hasBufferOrSidebandStream() const { |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 102 | return ((sidebandStream != nullptr) || (externalTexture != nullptr)); |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | bool LayerSnapshot::drawShadows() const { |
| 106 | return shadowSettings.length > 0.f; |
| 107 | } |
| 108 | |
| 109 | bool LayerSnapshot::fillsColor() const { |
| 110 | return !hasBufferOrSidebandStream() && color.r >= 0.0_hf && color.g >= 0.0_hf && |
| 111 | color.b >= 0.0_hf; |
| 112 | } |
| 113 | |
| 114 | bool LayerSnapshot::hasBlur() const { |
| 115 | return backgroundBlurRadius > 0 || blurRegions.size() > 0; |
| 116 | } |
| 117 | |
| 118 | bool LayerSnapshot::hasEffect() const { |
| 119 | return fillsColor() || drawShadows() || hasBlur(); |
| 120 | } |
| 121 | |
| 122 | bool LayerSnapshot::hasSomethingToDraw() const { |
| 123 | return hasEffect() || hasBufferOrSidebandStream(); |
| 124 | } |
| 125 | |
| 126 | bool LayerSnapshot::isContentOpaque() const { |
| 127 | // if we don't have a buffer or sidebandStream yet, we're translucent regardless of the |
| 128 | // layer's opaque flag. |
| 129 | if (!hasSomethingToDraw()) { |
| 130 | return false; |
| 131 | } |
| 132 | |
| 133 | // if the layer has the opaque flag, then we're always opaque |
| 134 | if (layerOpaqueFlagSet) { |
| 135 | return true; |
| 136 | } |
| 137 | |
| 138 | // If the buffer has no alpha channel, then we are opaque |
| 139 | if (hasBufferOrSidebandStream() && |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 140 | isOpaqueFormat(externalTexture ? externalTexture->getPixelFormat() : PIXEL_FORMAT_NONE)) { |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 141 | return true; |
| 142 | } |
| 143 | |
| 144 | // Lastly consider the layer opaque if drawing a color with alpha == 1.0 |
| 145 | return fillsColor() && color.a == 1.0_hf; |
| 146 | } |
| 147 | |
| 148 | bool LayerSnapshot::isHiddenByPolicy() const { |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 149 | return invalidTransform || isHiddenByPolicyFromParent || isHiddenByPolicyFromRelativeParent; |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | bool LayerSnapshot::getIsVisible() const { |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame^] | 153 | if (reachablilty != LayerSnapshot::Reachablilty::Reachable) { |
| 154 | return false; |
| 155 | } |
| 156 | |
Vishnu Nair | a9c4376 | 2023-01-27 19:10:25 +0000 | [diff] [blame] | 157 | if (handleSkipScreenshotFlag & outputFilter.toInternalDisplay) { |
| 158 | return false; |
| 159 | } |
| 160 | |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 161 | if (!hasSomethingToDraw()) { |
| 162 | return false; |
| 163 | } |
| 164 | |
| 165 | if (isHiddenByPolicy()) { |
| 166 | return false; |
| 167 | } |
| 168 | |
| 169 | return color.a > 0.0f || hasBlur(); |
| 170 | } |
| 171 | |
| 172 | std::string LayerSnapshot::getIsVisibleReason() const { |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 173 | // not visible |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame^] | 174 | if (reachablilty == LayerSnapshot::Reachablilty::Unreachable) |
| 175 | return "layer not reachable from root"; |
| 176 | if (reachablilty == LayerSnapshot::Reachablilty::ReachableByRelativeParent) |
| 177 | return "layer only reachable via relative parent"; |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 178 | if (isHiddenByPolicyFromParent) return "hidden by parent or layer flag"; |
| 179 | if (isHiddenByPolicyFromRelativeParent) return "hidden by relative parent"; |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame^] | 180 | if (handleSkipScreenshotFlag & outputFilter.toInternalDisplay) return "eLayerSkipScreenshot"; |
| 181 | if (invalidTransform) return "invalidTransform"; |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 182 | if (color.a == 0.0f && !hasBlur()) return "alpha = 0 and no blur"; |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame^] | 183 | if (!hasSomethingToDraw()) return "!hasSomethingToDraw"; |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 184 | |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 185 | // visible |
| 186 | std::stringstream reason; |
| 187 | if (sidebandStream != nullptr) reason << " sidebandStream"; |
Vishnu Nair | d47bcee | 2023-02-24 18:08:51 +0000 | [diff] [blame] | 188 | if (externalTexture != nullptr) |
| 189 | reason << " buffer:" << externalTexture->getId() << " frame:" << frameNumber; |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 190 | if (fillsColor() || color.a > 0.0f) reason << " color{" << color << "}"; |
| 191 | if (drawShadows()) reason << " shadowSettings.length=" << shadowSettings.length; |
| 192 | if (backgroundBlurRadius > 0) reason << " backgroundBlurRadius=" << backgroundBlurRadius; |
| 193 | if (blurRegions.size() > 0) reason << " blurRegions.size()=" << blurRegions.size(); |
| 194 | return reason.str(); |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | bool LayerSnapshot::canReceiveInput() const { |
| 198 | return !isHiddenByPolicy() && (!hasBufferOrSidebandStream() || color.a > 0.0f); |
| 199 | } |
| 200 | |
| 201 | bool LayerSnapshot::isTransformValid(const ui::Transform& t) { |
| 202 | float transformDet = t.det(); |
| 203 | return transformDet != 0 && !isinf(transformDet) && !isnan(transformDet); |
| 204 | } |
| 205 | |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 206 | bool LayerSnapshot::hasInputInfo() const { |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame^] | 207 | return (inputInfo.token != nullptr || |
| 208 | inputInfo.inputConfig.test(gui::WindowInfo::InputConfig::NO_INPUT_CHANNEL)) && |
| 209 | reachablilty == Reachablilty::Reachable; |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 210 | } |
| 211 | |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 212 | std::string LayerSnapshot::getDebugString() const { |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 213 | std::stringstream debug; |
| 214 | debug << "Snapshot{" << path.toString() << name << " isVisible=" << isVisible << " {" |
Vishnu Nair | 92990e2 | 2023-02-24 20:01:05 +0000 | [diff] [blame] | 215 | << getIsVisibleReason() << "} changes=" << changes.string() |
Vishnu Nair | 36d5f8e | 2023-03-19 13:31:35 -0700 | [diff] [blame] | 216 | << " layerStack=" << outputFilter.layerStack.id << " geomLayerBounds={" |
| 217 | << geomLayerBounds.left << "," << geomLayerBounds.top << "," << geomLayerBounds.bottom |
| 218 | << "," << geomLayerBounds.right << "}" |
| 219 | << " geomLayerTransform={tx=" << geomLayerTransform.tx() |
| 220 | << ",ty=" << geomLayerTransform.ty() << "}" |
| 221 | << "}"; |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame^] | 222 | if (hasInputInfo()) { |
| 223 | debug << " input{" |
| 224 | << "(" << inputInfo.inputConfig.string() << ")"; |
| 225 | if (touchCropId != UNASSIGNED_LAYER_ID) debug << " touchCropId=" << touchCropId; |
| 226 | if (inputInfo.replaceTouchableRegionWithCrop) debug << " replaceTouchableRegionWithCrop"; |
| 227 | auto touchableRegion = inputInfo.touchableRegion.getBounds(); |
| 228 | debug << " touchableRegion={" << touchableRegion.left << "," << touchableRegion.top << "," |
| 229 | << touchableRegion.bottom << "," << touchableRegion.right << "}" |
| 230 | << "}"; |
| 231 | } |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 232 | return debug.str(); |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 233 | } |
| 234 | |
Vishnu Nair | 781d725 | 2023-01-30 18:16:01 +0000 | [diff] [blame] | 235 | FloatRect LayerSnapshot::sourceBounds() const { |
| 236 | if (!externalTexture) { |
| 237 | return geomLayerBounds; |
| 238 | } |
| 239 | return geomBufferSize.toFloatRect(); |
| 240 | } |
| 241 | |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame^] | 242 | Hwc2::IComposerClient::BlendMode LayerSnapshot::getBlendMode( |
| 243 | const RequestedLayerState& requested) const { |
| 244 | auto blendMode = Hwc2::IComposerClient::BlendMode::NONE; |
| 245 | if (alpha != 1.0f || !contentOpaque) { |
| 246 | blendMode = requested.premultipliedAlpha ? Hwc2::IComposerClient::BlendMode::PREMULTIPLIED |
| 247 | : Hwc2::IComposerClient::BlendMode::COVERAGE; |
| 248 | } |
| 249 | return blendMode; |
| 250 | } |
| 251 | |
| 252 | void LayerSnapshot::merge(const RequestedLayerState& requested, bool forceUpdate, |
| 253 | bool displayChanges, bool forceFullDamage, |
| 254 | uint32_t displayRotationFlags) { |
| 255 | clientChanges = requested.what; |
| 256 | changes = requested.changes; |
| 257 | contentDirty = requested.what & layer_state_t::CONTENT_DIRTY; |
| 258 | // TODO(b/238781169) scope down the changes to only buffer updates. |
| 259 | hasReadyFrame = requested.hasReadyFrame(); |
| 260 | sidebandStreamHasFrame = requested.hasSidebandStreamFrame(); |
| 261 | updateSurfaceDamage(requested, hasReadyFrame, forceFullDamage, surfaceDamage); |
| 262 | |
| 263 | if (forceUpdate || requested.what & layer_state_t::eTransparentRegionChanged) { |
| 264 | transparentRegionHint = requested.transparentRegion; |
| 265 | } |
| 266 | if (forceUpdate || requested.what & layer_state_t::eFlagsChanged) { |
| 267 | layerOpaqueFlagSet = |
| 268 | (requested.flags & layer_state_t::eLayerOpaque) == layer_state_t::eLayerOpaque; |
| 269 | } |
| 270 | if (forceUpdate || requested.what & layer_state_t::eBufferTransformChanged) { |
| 271 | geomBufferTransform = requested.bufferTransform; |
| 272 | } |
| 273 | if (forceUpdate || requested.what & layer_state_t::eTransformToDisplayInverseChanged) { |
| 274 | geomBufferUsesDisplayInverseTransform = requested.transformToDisplayInverse; |
| 275 | } |
| 276 | if (forceUpdate || requested.what & layer_state_t::eDataspaceChanged) { |
| 277 | dataspace = requested.dataspace; |
| 278 | } |
| 279 | if (forceUpdate || requested.what & layer_state_t::eExtendedRangeBrightnessChanged) { |
| 280 | currentHdrSdrRatio = requested.currentHdrSdrRatio; |
| 281 | desiredHdrSdrRatio = requested.desiredHdrSdrRatio; |
| 282 | } |
| 283 | if (forceUpdate || requested.what & layer_state_t::eCachingHintChanged) { |
| 284 | cachingHint = requested.cachingHint; |
| 285 | } |
| 286 | if (forceUpdate || requested.what & layer_state_t::eHdrMetadataChanged) { |
| 287 | hdrMetadata = requested.hdrMetadata; |
| 288 | } |
| 289 | if (forceUpdate || requested.what & layer_state_t::eSidebandStreamChanged) { |
| 290 | sidebandStream = requested.sidebandStream; |
| 291 | } |
| 292 | if (forceUpdate || requested.what & layer_state_t::eShadowRadiusChanged) { |
| 293 | shadowRadius = requested.shadowRadius; |
| 294 | shadowSettings.length = requested.shadowRadius; |
| 295 | } |
| 296 | if (forceUpdate || requested.what & layer_state_t::eFrameRateSelectionPriority) { |
| 297 | frameRateSelectionPriority = requested.frameRateSelectionPriority; |
| 298 | } |
| 299 | if (forceUpdate || requested.what & layer_state_t::eColorSpaceAgnosticChanged) { |
| 300 | isColorspaceAgnostic = requested.colorSpaceAgnostic; |
| 301 | } |
| 302 | if (forceUpdate || requested.what & layer_state_t::eDimmingEnabledChanged) { |
| 303 | dimmingEnabled = requested.dimmingEnabled; |
| 304 | } |
| 305 | if (forceUpdate || requested.what & layer_state_t::eCropChanged) { |
| 306 | geomCrop = requested.crop; |
| 307 | } |
| 308 | |
| 309 | if (forceUpdate || |
| 310 | requested.what & |
| 311 | (layer_state_t::eFlagsChanged | layer_state_t::eBufferChanged | |
| 312 | layer_state_t::eSidebandStreamChanged)) { |
| 313 | compositionType = requested.getCompositionType(); |
| 314 | } |
| 315 | |
| 316 | if (forceUpdate || requested.what & layer_state_t::eInputInfoChanged) { |
| 317 | if (requested.windowInfoHandle) { |
| 318 | inputInfo = *requested.windowInfoHandle->getInfo(); |
| 319 | } else { |
| 320 | inputInfo = {}; |
| 321 | // b/271132344 revisit this and see if we can always use the layers uid/pid |
| 322 | inputInfo.name = requested.name; |
| 323 | inputInfo.ownerUid = requested.ownerUid; |
| 324 | inputInfo.ownerPid = requested.ownerPid; |
| 325 | } |
| 326 | inputInfo.id = static_cast<int32_t>(uniqueSequence); |
| 327 | touchCropId = requested.touchCropId; |
| 328 | } |
| 329 | |
| 330 | if (forceUpdate || |
| 331 | requested.what & |
| 332 | (layer_state_t::eColorChanged | layer_state_t::eBufferChanged | |
| 333 | layer_state_t::eSidebandStreamChanged)) { |
| 334 | color.rgb = requested.getColor().rgb; |
| 335 | } |
| 336 | |
| 337 | if (forceUpdate || requested.what & layer_state_t::eBufferChanged) { |
| 338 | acquireFence = |
| 339 | (requested.externalTexture && |
| 340 | requested.bufferData->flags.test(BufferData::BufferDataChange::fenceChanged)) |
| 341 | ? requested.bufferData->acquireFence |
| 342 | : Fence::NO_FENCE; |
| 343 | buffer = requested.externalTexture ? requested.externalTexture->getBuffer() : nullptr; |
| 344 | externalTexture = requested.externalTexture; |
| 345 | frameNumber = (requested.bufferData) ? requested.bufferData->frameNumber : 0; |
| 346 | hasProtectedContent = requested.externalTexture && |
| 347 | requested.externalTexture->getUsage() & GRALLOC_USAGE_PROTECTED; |
| 348 | geomUsesSourceCrop = hasBufferOrSidebandStream(); |
| 349 | } |
| 350 | |
| 351 | if (forceUpdate || |
| 352 | requested.what & |
| 353 | (layer_state_t::eCropChanged | layer_state_t::eBufferCropChanged | |
| 354 | layer_state_t::eBufferTransformChanged | |
| 355 | layer_state_t::eTransformToDisplayInverseChanged) || |
| 356 | requested.changes.test(RequestedLayerState::Changes::BufferSize) || displayChanges) { |
| 357 | bufferSize = requested.getBufferSize(displayRotationFlags); |
| 358 | geomBufferSize = bufferSize; |
| 359 | croppedBufferSize = requested.getCroppedBufferSize(bufferSize); |
| 360 | geomContentCrop = requested.getBufferCrop(); |
| 361 | } |
| 362 | |
| 363 | if (forceUpdate || |
| 364 | requested.what & |
| 365 | (layer_state_t::eFlagsChanged | layer_state_t::eDestinationFrameChanged | |
| 366 | layer_state_t::ePositionChanged | layer_state_t::eMatrixChanged | |
| 367 | layer_state_t::eBufferTransformChanged | |
| 368 | layer_state_t::eTransformToDisplayInverseChanged) || |
| 369 | requested.changes.test(RequestedLayerState::Changes::BufferSize) || displayChanges) { |
| 370 | localTransform = requested.getTransform(displayRotationFlags); |
| 371 | localTransformInverse = localTransform.inverse(); |
| 372 | } |
| 373 | |
| 374 | if (forceUpdate || requested.what & (layer_state_t::eColorChanged) || |
| 375 | requested.changes.test(RequestedLayerState::Changes::BufferSize)) { |
| 376 | color.rgb = requested.getColor().rgb; |
| 377 | } |
| 378 | |
| 379 | if (forceUpdate || |
| 380 | requested.what & |
| 381 | (layer_state_t::eBufferChanged | layer_state_t::eDataspaceChanged | |
| 382 | layer_state_t::eApiChanged)) { |
| 383 | isHdrY410 = requested.dataspace == ui::Dataspace::BT2020_ITU_PQ && |
| 384 | requested.api == NATIVE_WINDOW_API_MEDIA && |
| 385 | requested.bufferData->getPixelFormat() == HAL_PIXEL_FORMAT_RGBA_1010102; |
| 386 | } |
| 387 | |
| 388 | if (forceUpdate || |
| 389 | requested.what & |
| 390 | (layer_state_t::eBufferChanged | layer_state_t::eDataspaceChanged | |
| 391 | layer_state_t::eApiChanged | layer_state_t::eShadowRadiusChanged | |
| 392 | layer_state_t::eBlurRegionsChanged | layer_state_t::eStretchChanged)) { |
| 393 | forceClientComposition = isHdrY410 || shadowSettings.length > 0 || |
| 394 | requested.blurRegions.size() > 0 || stretchEffect.hasEffect(); |
| 395 | } |
| 396 | |
| 397 | if (forceUpdate || |
| 398 | requested.what & |
| 399 | (layer_state_t::eColorChanged | layer_state_t::eShadowRadiusChanged | |
| 400 | layer_state_t::eBlurRegionsChanged | layer_state_t::eBackgroundBlurRadiusChanged | |
| 401 | layer_state_t::eCornerRadiusChanged | layer_state_t::eAlphaChanged | |
| 402 | layer_state_t::eFlagsChanged | layer_state_t::eBufferChanged | |
| 403 | layer_state_t::eSidebandStreamChanged)) { |
| 404 | contentOpaque = isContentOpaque(); |
| 405 | isOpaque = contentOpaque && !roundedCorner.hasRoundedCorners() && color.a == 1.f; |
| 406 | blendMode = getBlendMode(requested); |
| 407 | } |
| 408 | } |
| 409 | |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 410 | } // namespace android::surfaceflinger::frontend |