Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +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 | */ |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame] | 16 | // #define LOG_NDEBUG 0 |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 17 | |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 18 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 19 | #undef LOG_TAG |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame] | 20 | #define LOG_TAG "SurfaceFlinger" |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 21 | |
Vishnu Nair | be0ad90 | 2024-06-27 23:38:43 +0000 | [diff] [blame] | 22 | #include <common/trace.h> |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 23 | #include <log/log.h> |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 24 | #include <private/android_filesystem_config.h> |
| 25 | #include <sys/types.h> |
| 26 | |
Rachel Lee | ce6e004 | 2023-06-27 11:22:54 -0700 | [diff] [blame] | 27 | #include <scheduler/Fps.h> |
| 28 | |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 29 | #include "Layer.h" |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 30 | #include "LayerCreationArgs.h" |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 31 | #include "LayerLog.h" |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 32 | #include "RequestedLayerState.h" |
| 33 | |
| 34 | namespace android::surfaceflinger::frontend { |
| 35 | using ftl::Flags; |
| 36 | using namespace ftl::flag_operators; |
| 37 | |
| 38 | namespace { |
Vishnu Nair | a9c4376 | 2023-01-27 19:10:25 +0000 | [diff] [blame] | 39 | std::string layerIdsToString(const std::vector<uint32_t>& layerIds) { |
| 40 | std::stringstream stream; |
| 41 | stream << "{"; |
| 42 | for (auto layerId : layerIds) { |
| 43 | stream << layerId << ","; |
| 44 | } |
| 45 | stream << "}"; |
| 46 | return stream.str(); |
| 47 | } |
| 48 | |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 49 | } // namespace |
| 50 | |
| 51 | RequestedLayerState::RequestedLayerState(const LayerCreationArgs& args) |
| 52 | : id(args.sequence), |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 53 | name(args.name + "#" + std::to_string(args.sequence)), |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 54 | canBeRoot(args.addToRoot), |
| 55 | layerCreationFlags(args.flags), |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 56 | ownerUid(args.ownerUid), |
Vishnu Nair | 1391de2 | 2023-03-05 19:56:14 -0800 | [diff] [blame] | 57 | ownerPid(args.ownerPid), |
| 58 | parentId(args.parentId), |
Melody Hsu | 1635578 | 2024-10-09 08:56:28 +0000 | [diff] [blame] | 59 | layerIdToMirror(args.layerIdToMirror), |
| 60 | pendingBuffers(args.pendingBuffers) { |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 61 | layerId = static_cast<int32_t>(args.sequence); |
| 62 | changes |= RequestedLayerState::Changes::Created; |
| 63 | metadata.merge(args.metadata); |
| 64 | changes |= RequestedLayerState::Changes::Metadata; |
| 65 | handleAlive = true; |
Wenhui Yang | ab89d81 | 2024-09-11 23:21:38 +0000 | [diff] [blame] | 66 | // TODO: b/305254099 remove once we don't pass invisible windows to input |
| 67 | windowInfoHandle = nullptr; |
Vishnu Nair | 1391de2 | 2023-03-05 19:56:14 -0800 | [diff] [blame] | 68 | if (parentId != UNASSIGNED_LAYER_ID) { |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 69 | canBeRoot = false; |
| 70 | } |
Vishnu Nair | a9c4376 | 2023-01-27 19:10:25 +0000 | [diff] [blame] | 71 | if (layerIdToMirror != UNASSIGNED_LAYER_ID) { |
| 72 | changes |= RequestedLayerState::Changes::Mirror; |
| 73 | } else if (args.layerStackToMirror != ui::INVALID_LAYER_STACK) { |
| 74 | layerStackToMirror = args.layerStackToMirror; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 75 | changes |= RequestedLayerState::Changes::Mirror; |
| 76 | } |
| 77 | |
| 78 | flags = 0; |
| 79 | if (args.flags & ISurfaceComposerClient::eHidden) flags |= layer_state_t::eLayerHidden; |
| 80 | if (args.flags & ISurfaceComposerClient::eOpaque) flags |= layer_state_t::eLayerOpaque; |
| 81 | if (args.flags & ISurfaceComposerClient::eSecure) flags |= layer_state_t::eLayerSecure; |
| 82 | if (args.flags & ISurfaceComposerClient::eSkipScreenshot) { |
| 83 | flags |= layer_state_t::eLayerSkipScreenshot; |
| 84 | } |
| 85 | premultipliedAlpha = !(args.flags & ISurfaceComposerClient::eNonPremultiplied); |
| 86 | potentialCursor = args.flags & ISurfaceComposerClient::eCursorWindow; |
| 87 | protectedByApp = args.flags & ISurfaceComposerClient::eProtectedByApp; |
| 88 | if (args.flags & ISurfaceComposerClient::eNoColorFill) { |
| 89 | // Set an invalid color so there is no color fill. |
| 90 | // (b/259981098) use an explicit flag instead of relying on invalid values. |
| 91 | color.r = -1.0_hf; |
| 92 | color.g = -1.0_hf; |
| 93 | color.b = -1.0_hf; |
| 94 | } else { |
| 95 | color.rgb = {0.0_hf, 0.0_hf, 0.0_hf}; |
| 96 | } |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 97 | LLOGV(layerId, "Created %s flags=%d", getDebugString().c_str(), flags); |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 98 | color.a = 1.0f; |
| 99 | |
Vishnu Nair | a9123c8 | 2024-10-03 03:56:44 +0000 | [diff] [blame] | 100 | crop = {0, 0, -1, -1}; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 101 | z = 0; |
| 102 | layerStack = ui::DEFAULT_LAYER_STACK; |
| 103 | transformToDisplayInverse = false; |
Alec Mouri | 1b0d4e1 | 2024-02-12 22:27:19 +0000 | [diff] [blame] | 104 | desiredHdrSdrRatio = -1.f; |
Sally Qi | 963049b | 2023-03-23 14:06:21 -0700 | [diff] [blame] | 105 | currentHdrSdrRatio = 1.f; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 106 | dataspaceRequested = false; |
| 107 | hdrMetadata.validTypes = 0; |
| 108 | surfaceDamageRegion = Region::INVALID_REGION; |
| 109 | cornerRadius = 0.0f; |
| 110 | backgroundBlurRadius = 0; |
| 111 | api = -1; |
| 112 | hasColorTransform = false; |
| 113 | bufferTransform = 0; |
| 114 | requestedTransform.reset(); |
| 115 | bufferData = std::make_shared<BufferData>(); |
| 116 | bufferData->frameNumber = 0; |
| 117 | bufferData->acquireFence = sp<Fence>::make(-1); |
| 118 | acquireFenceTime = std::make_shared<FenceTime>(bufferData->acquireFence); |
| 119 | colorSpaceAgnostic = false; |
| 120 | frameRateSelectionPriority = Layer::PRIORITY_UNSET; |
| 121 | shadowRadius = 0.f; |
| 122 | fixedTransformHint = ui::Transform::ROT_INVALID; |
| 123 | destinationFrame.makeInvalid(); |
Vishnu Nair | 9e0017e | 2024-05-22 19:02:44 +0000 | [diff] [blame] | 124 | trustedOverlay = gui::TrustedOverlay::UNSET; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 125 | dropInputMode = gui::DropInputMode::NONE; |
| 126 | dimmingEnabled = true; |
Vishnu Nair | 3fbe326 | 2023-09-29 17:07:00 -0700 | [diff] [blame] | 127 | defaultFrameRateCompatibility = static_cast<int8_t>(scheduler::FrameRateCompatibility::Default); |
Rachel Lee | ce6e004 | 2023-06-27 11:22:54 -0700 | [diff] [blame] | 128 | frameRateCategory = static_cast<int8_t>(FrameRateCategory::Default); |
Rachel Lee | 67afbea | 2023-09-28 15:35:07 -0700 | [diff] [blame] | 129 | frameRateCategorySmoothSwitchOnly = false; |
Rachel Lee | 58cc90d | 2023-09-05 18:50:20 -0700 | [diff] [blame] | 130 | frameRateSelectionStrategy = |
Rachel Lee | 70f7b69 | 2023-11-22 11:24:02 -0800 | [diff] [blame] | 131 | static_cast<int8_t>(scheduler::LayerInfo::FrameRateSelectionStrategy::Propagate); |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 132 | dataspace = ui::Dataspace::V0_SRGB; |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 133 | gameMode = gui::GameMode::Unsupported; |
| 134 | requestedFrameRate = {}; |
Alec Mouri | f4af03e | 2023-02-11 00:25:24 +0000 | [diff] [blame] | 135 | cachingHint = gui::CachingHint::Enabled; |
Vishnu Nair | 3cc15a4 | 2023-06-30 06:20:22 +0000 | [diff] [blame] | 136 | |
| 137 | if (name.length() > 77) { |
| 138 | std::string shortened; |
| 139 | shortened.append(name, 0, 36); |
| 140 | shortened.append("[...]"); |
| 141 | shortened.append(name, name.length() - 36); |
| 142 | debugName = std::move(shortened); |
| 143 | } else { |
| 144 | debugName = name; |
| 145 | } |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerState) { |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 149 | const uint32_t oldFlags = flags; |
| 150 | const half oldAlpha = color.a; |
Vishnu Nair | 7ee4f46 | 2023-04-19 09:54:09 -0700 | [diff] [blame] | 151 | const bool hadBuffer = externalTexture != nullptr; |
Vishnu Nair | d1f7498 | 2023-06-15 20:16:51 -0700 | [diff] [blame] | 152 | uint64_t oldFramenumber = hadBuffer ? bufferData->frameNumber : 0; |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame] | 153 | const ui::Size oldBufferSize = hadBuffer |
| 154 | ? ui::Size(externalTexture->getWidth(), externalTexture->getHeight()) |
| 155 | : ui::Size(); |
Vishnu Nair | 0808ae6 | 2023-08-07 21:42:42 -0700 | [diff] [blame] | 156 | const uint64_t oldUsageFlags = hadBuffer ? externalTexture->getUsage() : 0; |
Vishnu Nair | 61ff12a | 2023-08-30 21:41:46 -0700 | [diff] [blame] | 157 | const bool oldBufferFormatOpaque = LayerSnapshot::isOpaqueFormat( |
| 158 | externalTexture ? externalTexture->getPixelFormat() : PIXEL_FORMAT_NONE); |
Vishnu Nair | 0808ae6 | 2023-08-07 21:42:42 -0700 | [diff] [blame] | 159 | |
Vishnu Nair | 7ee4f46 | 2023-04-19 09:54:09 -0700 | [diff] [blame] | 160 | const bool hadSideStream = sidebandStream != nullptr; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 161 | const layer_state_t& clientState = resolvedComposerState.state; |
Vishnu Nair | 854ce1c | 2023-08-19 15:00:13 -0700 | [diff] [blame] | 162 | const bool hadSomethingToDraw = hasSomethingToDraw(); |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 163 | uint64_t clientChanges = what | layer_state_t::diff(clientState); |
| 164 | layer_state_t::merge(clientState); |
| 165 | what = clientChanges; |
Sally Qi | ef00658 | 2024-10-11 13:23:09 -0700 | [diff] [blame] | 166 | LLOGV(layerId, "requested=%" PRIu64 " flags=%" PRIu64 " ", clientState.what, clientChanges); |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 167 | |
| 168 | if (clientState.what & layer_state_t::eFlagsChanged) { |
Patrick Williams | d8edec0 | 2024-03-11 18:14:48 -0500 | [diff] [blame] | 169 | if ((oldFlags ^ flags) & |
| 170 | (layer_state_t::eLayerHidden | layer_state_t::eLayerOpaque | |
| 171 | layer_state_t::eLayerSecure)) { |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 172 | changes |= RequestedLayerState::Changes::Visibility | |
| 173 | RequestedLayerState::Changes::VisibleRegion; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 174 | } |
| 175 | if ((oldFlags ^ flags) & layer_state_t::eIgnoreDestinationFrame) { |
| 176 | changes |= RequestedLayerState::Changes::Geometry; |
| 177 | } |
Vishnu Nair | 59a6be3 | 2024-01-29 10:26:21 -0800 | [diff] [blame] | 178 | if ((oldFlags ^ flags) & layer_state_t::eCanOccludePresentation) { |
| 179 | changes |= RequestedLayerState::Changes::Input; |
| 180 | } |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 181 | } |
Vishnu Nair | d1f7498 | 2023-06-15 20:16:51 -0700 | [diff] [blame] | 182 | |
Vishnu Nair | 7ee4f46 | 2023-04-19 09:54:09 -0700 | [diff] [blame] | 183 | if (clientState.what & layer_state_t::eBufferChanged) { |
| 184 | externalTexture = resolvedComposerState.externalTexture; |
Vishnu Nair | 7ee4f46 | 2023-04-19 09:54:09 -0700 | [diff] [blame] | 185 | const bool hasBuffer = externalTexture != nullptr; |
| 186 | if (hasBuffer || hasBuffer != hadBuffer) { |
| 187 | changes |= RequestedLayerState::Changes::Buffer; |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame] | 188 | const ui::Size newBufferSize = hasBuffer |
| 189 | ? ui::Size(externalTexture->getWidth(), externalTexture->getHeight()) |
| 190 | : ui::Size(); |
| 191 | if (oldBufferSize != newBufferSize) { |
| 192 | changes |= RequestedLayerState::Changes::BufferSize; |
| 193 | changes |= RequestedLayerState::Changes::Geometry; |
| 194 | } |
Vishnu Nair | 0808ae6 | 2023-08-07 21:42:42 -0700 | [diff] [blame] | 195 | const uint64_t usageFlags = hasBuffer ? externalTexture->getUsage() : 0; |
| 196 | if (oldUsageFlags != usageFlags) { |
| 197 | changes |= RequestedLayerState::Changes::BufferUsageFlags; |
| 198 | } |
Vishnu Nair | 7ee4f46 | 2023-04-19 09:54:09 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | if (hasBuffer != hadBuffer) { |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 202 | changes |= RequestedLayerState::Changes::Geometry | |
| 203 | RequestedLayerState::Changes::VisibleRegion | |
Vishnu Nair | d47bcee | 2023-02-24 18:08:51 +0000 | [diff] [blame] | 204 | RequestedLayerState::Changes::Visibility | RequestedLayerState::Changes::Input; |
| 205 | } |
Vishnu Nair | d1f7498 | 2023-06-15 20:16:51 -0700 | [diff] [blame] | 206 | |
| 207 | if (hasBuffer) { |
| 208 | const bool frameNumberChanged = |
| 209 | bufferData->flags.test(BufferData::BufferDataChange::frameNumberChanged); |
| 210 | const uint64_t frameNumber = |
| 211 | frameNumberChanged ? bufferData->frameNumber : oldFramenumber + 1; |
| 212 | bufferData->frameNumber = frameNumber; |
| 213 | |
| 214 | if ((barrierProducerId > bufferData->producerId) || |
| 215 | ((barrierProducerId == bufferData->producerId) && |
| 216 | (barrierFrameNumber > bufferData->frameNumber))) { |
| 217 | ALOGE("Out of order buffers detected for %s producedId=%d frameNumber=%" PRIu64 |
| 218 | " -> producedId=%d frameNumber=%" PRIu64, |
Patrick Williams | 0db92f1 | 2023-10-18 12:02:06 -0500 | [diff] [blame] | 219 | getDebugString().c_str(), barrierProducerId, barrierFrameNumber, |
Vishnu Nair | d1f7498 | 2023-06-15 20:16:51 -0700 | [diff] [blame] | 220 | bufferData->producerId, frameNumber); |
| 221 | TransactionTraceWriter::getInstance().invoke("out_of_order_buffers_", |
| 222 | /*overwrite=*/false); |
| 223 | } |
| 224 | |
| 225 | barrierProducerId = std::max(bufferData->producerId, barrierProducerId); |
| 226 | barrierFrameNumber = std::max(bufferData->frameNumber, barrierFrameNumber); |
| 227 | } |
Vishnu Nair | 61ff12a | 2023-08-30 21:41:46 -0700 | [diff] [blame] | 228 | |
| 229 | const bool newBufferFormatOpaque = LayerSnapshot::isOpaqueFormat( |
| 230 | externalTexture ? externalTexture->getPixelFormat() : PIXEL_FORMAT_NONE); |
| 231 | if (newBufferFormatOpaque != oldBufferFormatOpaque) { |
| 232 | changes |= RequestedLayerState::Changes::Visibility | |
| 233 | RequestedLayerState::Changes::VisibleRegion; |
| 234 | } |
Vishnu Nair | 6322121 | 2023-04-06 15:17:37 -0700 | [diff] [blame] | 235 | } |
Vishnu Nair | 7ee4f46 | 2023-04-19 09:54:09 -0700 | [diff] [blame] | 236 | |
Vishnu Nair | 6322121 | 2023-04-06 15:17:37 -0700 | [diff] [blame] | 237 | if (clientState.what & layer_state_t::eSidebandStreamChanged) { |
| 238 | changes |= RequestedLayerState::Changes::SidebandStream; |
Vishnu Nair | 7ee4f46 | 2023-04-19 09:54:09 -0700 | [diff] [blame] | 239 | const bool hasSideStream = sidebandStream != nullptr; |
| 240 | if (hasSideStream != hadSideStream) { |
| 241 | changes |= RequestedLayerState::Changes::Geometry | |
| 242 | RequestedLayerState::Changes::VisibleRegion | |
| 243 | RequestedLayerState::Changes::Visibility | RequestedLayerState::Changes::Input; |
| 244 | } |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 245 | } |
| 246 | if (what & (layer_state_t::eAlphaChanged)) { |
| 247 | if (oldAlpha == 0 || color.a == 0) { |
Vishnu Nair | 93e26b9 | 2023-10-16 21:36:51 -0700 | [diff] [blame] | 248 | changes |= RequestedLayerState::Changes::Visibility; |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 249 | } |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 250 | } |
Vishnu Nair | 854ce1c | 2023-08-19 15:00:13 -0700 | [diff] [blame] | 251 | |
| 252 | if (hadSomethingToDraw != hasSomethingToDraw()) { |
| 253 | changes |= RequestedLayerState::Changes::Visibility | |
| 254 | RequestedLayerState::Changes::VisibleRegion; |
Vishnu Nair | 80a5a70 | 2023-02-11 01:21:51 +0000 | [diff] [blame] | 255 | } |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 256 | if (clientChanges & layer_state_t::HIERARCHY_CHANGES) |
| 257 | changes |= RequestedLayerState::Changes::Hierarchy; |
| 258 | if (clientChanges & layer_state_t::CONTENT_CHANGES) |
| 259 | changes |= RequestedLayerState::Changes::Content; |
| 260 | if (clientChanges & layer_state_t::GEOMETRY_CHANGES) |
| 261 | changes |= RequestedLayerState::Changes::Geometry; |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 262 | if (clientChanges & layer_state_t::AFFECTS_CHILDREN) |
| 263 | changes |= RequestedLayerState::Changes::AffectsChildren; |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 264 | if (clientChanges & layer_state_t::INPUT_CHANGES) |
| 265 | changes |= RequestedLayerState::Changes::Input; |
| 266 | if (clientChanges & layer_state_t::VISIBLE_REGION_CHANGES) |
| 267 | changes |= RequestedLayerState::Changes::VisibleRegion; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 268 | if (clientState.what & layer_state_t::eColorTransformChanged) { |
| 269 | static const mat4 identityMatrix = mat4(); |
| 270 | hasColorTransform = colorTransform != identityMatrix; |
| 271 | } |
Vishnu Nair | d47bcee | 2023-02-24 18:08:51 +0000 | [diff] [blame] | 272 | if (clientState.what & |
| 273 | (layer_state_t::eLayerChanged | layer_state_t::eRelativeLayerChanged | |
| 274 | layer_state_t::eLayerStackChanged)) { |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 275 | changes |= RequestedLayerState::Changes::Z; |
| 276 | } |
| 277 | if (clientState.what & layer_state_t::eReparent) { |
| 278 | changes |= RequestedLayerState::Changes::Parent; |
Vishnu Nair | 1391de2 | 2023-03-05 19:56:14 -0800 | [diff] [blame] | 279 | parentId = resolvedComposerState.parentId; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 280 | parentSurfaceControlForChild = nullptr; |
Vishnu Nair | 04f8969 | 2022-11-16 23:21:05 +0000 | [diff] [blame] | 281 | // Once a layer has be reparented, it cannot be placed at the root. It sounds odd |
| 282 | // but thats the existing logic and until we make this behavior more explicit, we need |
| 283 | // to maintain this logic. |
| 284 | canBeRoot = false; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 285 | } |
| 286 | if (clientState.what & layer_state_t::eRelativeLayerChanged) { |
| 287 | changes |= RequestedLayerState::Changes::RelativeParent; |
Vishnu Nair | 1391de2 | 2023-03-05 19:56:14 -0800 | [diff] [blame] | 288 | relativeParentId = resolvedComposerState.relativeParentId; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 289 | isRelativeOf = true; |
| 290 | relativeLayerSurfaceControl = nullptr; |
| 291 | } |
| 292 | if ((clientState.what & layer_state_t::eLayerChanged || |
| 293 | (clientState.what & layer_state_t::eReparent && parentId == UNASSIGNED_LAYER_ID)) && |
| 294 | isRelativeOf) { |
| 295 | // clear out relz data |
| 296 | relativeParentId = UNASSIGNED_LAYER_ID; |
| 297 | isRelativeOf = false; |
| 298 | changes |= RequestedLayerState::Changes::RelativeParent; |
| 299 | } |
| 300 | if (clientState.what & layer_state_t::eReparent && parentId == relativeParentId) { |
| 301 | // provide a hint that we are are now a direct child and not a relative child. |
| 302 | changes |= RequestedLayerState::Changes::RelativeParent; |
| 303 | } |
| 304 | if (clientState.what & layer_state_t::eInputInfoChanged) { |
Vishnu Nair | 1391de2 | 2023-03-05 19:56:14 -0800 | [diff] [blame] | 305 | touchCropId = resolvedComposerState.touchCropId; |
| 306 | windowInfoHandle->editInfo()->touchableRegionCropHandle.clear(); |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 307 | } |
| 308 | if (clientState.what & layer_state_t::eStretchChanged) { |
| 309 | stretchEffect.sanitize(); |
| 310 | } |
| 311 | |
| 312 | if (clientState.what & layer_state_t::eHasListenerCallbacksChanged) { |
| 313 | // TODO(b/238781169) handle callbacks |
| 314 | } |
| 315 | |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 316 | if (clientState.what & layer_state_t::ePositionChanged) { |
| 317 | requestedTransform.set(x, y); |
| 318 | } |
| 319 | |
| 320 | if (clientState.what & layer_state_t::eMatrixChanged) { |
| 321 | requestedTransform.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy); |
| 322 | } |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 323 | if (clientState.what & layer_state_t::eMetadataChanged) { |
| 324 | const int32_t requestedGameMode = |
| 325 | clientState.metadata.getInt32(gui::METADATA_GAME_MODE, -1); |
| 326 | if (requestedGameMode != -1) { |
| 327 | // The transaction will be received on the Task layer and needs to be applied to all |
| 328 | // child layers. |
| 329 | if (static_cast<int32_t>(gameMode) != requestedGameMode) { |
| 330 | gameMode = static_cast<gui::GameMode>(requestedGameMode); |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame] | 331 | changes |= RequestedLayerState::Changes::GameMode; |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 332 | } |
| 333 | } |
Nergi Rahardi | 27613c3 | 2024-05-23 06:57:02 +0000 | [diff] [blame] | 334 | changes |= RequestedLayerState::Changes::Metadata; |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 335 | } |
| 336 | if (clientState.what & layer_state_t::eFrameRateChanged) { |
| 337 | const auto compatibility = |
| 338 | Layer::FrameRate::convertCompatibility(clientState.frameRateCompatibility); |
| 339 | const auto strategy = Layer::FrameRate::convertChangeFrameRateStrategy( |
| 340 | clientState.changeFrameRateStrategy); |
Rachel Lee | ce6e004 | 2023-06-27 11:22:54 -0700 | [diff] [blame] | 341 | requestedFrameRate.vote = |
| 342 | Layer::FrameRate::FrameRateVote(Fps::fromValue(clientState.frameRate), |
| 343 | compatibility, strategy); |
| 344 | changes |= RequestedLayerState::Changes::FrameRate; |
| 345 | } |
| 346 | if (clientState.what & layer_state_t::eFrameRateCategoryChanged) { |
| 347 | const auto category = Layer::FrameRate::convertCategory(clientState.frameRateCategory); |
| 348 | requestedFrameRate.category = category; |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 349 | changes |= RequestedLayerState::Changes::FrameRate; |
| 350 | } |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 353 | ui::Size RequestedLayerState::getUnrotatedBufferSize(uint32_t displayRotationFlags) const { |
| 354 | uint32_t bufferWidth = externalTexture->getWidth(); |
| 355 | uint32_t bufferHeight = externalTexture->getHeight(); |
| 356 | // Undo any transformations on the buffer. |
| 357 | if (bufferTransform & ui::Transform::ROT_90) { |
| 358 | std::swap(bufferWidth, bufferHeight); |
| 359 | } |
| 360 | if (transformToDisplayInverse) { |
| 361 | if (displayRotationFlags & ui::Transform::ROT_90) { |
| 362 | std::swap(bufferWidth, bufferHeight); |
| 363 | } |
| 364 | } |
| 365 | return {bufferWidth, bufferHeight}; |
| 366 | } |
| 367 | |
| 368 | ui::Transform RequestedLayerState::getTransform(uint32_t displayRotationFlags) const { |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 369 | if ((flags & layer_state_t::eIgnoreDestinationFrame) || destinationFrame.isEmpty()) { |
| 370 | // If destination frame is not set, use the requested transform set via |
| 371 | // Transaction::setPosition and Transaction::setMatrix. |
| 372 | return requestedTransform; |
| 373 | } |
| 374 | |
| 375 | Rect destRect = destinationFrame; |
| 376 | int32_t destW = destRect.width(); |
| 377 | int32_t destH = destRect.height(); |
| 378 | if (destRect.left < 0) { |
| 379 | destRect.left = 0; |
| 380 | destRect.right = destW; |
| 381 | } |
| 382 | if (destRect.top < 0) { |
| 383 | destRect.top = 0; |
| 384 | destRect.bottom = destH; |
| 385 | } |
| 386 | |
| 387 | if (!externalTexture) { |
| 388 | ui::Transform transform; |
| 389 | transform.set(static_cast<float>(destRect.left), static_cast<float>(destRect.top)); |
| 390 | return transform; |
| 391 | } |
| 392 | |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 393 | ui::Size bufferSize = getUnrotatedBufferSize(displayRotationFlags); |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 394 | |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 395 | float sx = static_cast<float>(destW) / static_cast<float>(bufferSize.width); |
| 396 | float sy = static_cast<float>(destH) / static_cast<float>(bufferSize.height); |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 397 | ui::Transform transform; |
| 398 | transform.set(sx, 0, 0, sy); |
| 399 | transform.set(static_cast<float>(destRect.left), static_cast<float>(destRect.top)); |
| 400 | return transform; |
| 401 | } |
| 402 | |
| 403 | std::string RequestedLayerState::getDebugString() const { |
Vishnu Nair | 80a5a70 | 2023-02-11 01:21:51 +0000 | [diff] [blame] | 404 | std::stringstream debug; |
Vishnu Nair | 444f395 | 2023-04-11 13:01:02 -0700 | [diff] [blame] | 405 | debug << "RequestedLayerState{" << name; |
| 406 | if (parentId != UNASSIGNED_LAYER_ID) debug << " parentId=" << parentId; |
| 407 | if (relativeParentId != UNASSIGNED_LAYER_ID) debug << " relativeParentId=" << relativeParentId; |
| 408 | if (!mirrorIds.empty()) debug << " mirrorId=" << layerIdsToString(mirrorIds); |
| 409 | if (!handleAlive) debug << " !handle"; |
| 410 | if (z != 0) debug << " z=" << z; |
| 411 | if (layerStack.id != 0) debug << " layerStack=" << layerStack.id; |
Patrick Williams | 0db92f1 | 2023-10-18 12:02:06 -0500 | [diff] [blame] | 412 | debug << "}"; |
Vishnu Nair | 80a5a70 | 2023-02-11 01:21:51 +0000 | [diff] [blame] | 413 | return debug.str(); |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 414 | } |
| 415 | |
Ady Abraham | 4cb525b | 2023-09-22 17:34:45 -0700 | [diff] [blame] | 416 | std::ostream& operator<<(std::ostream& out, const scheduler::LayerInfo::FrameRate& obj) { |
| 417 | out << obj.vote.rate; |
| 418 | out << " " << ftl::enum_string_full(obj.vote.type); |
| 419 | out << " " << ftl::enum_string_full(obj.category); |
| 420 | return out; |
| 421 | } |
| 422 | |
Vishnu Nair | 3cc15a4 | 2023-06-30 06:20:22 +0000 | [diff] [blame] | 423 | std::ostream& operator<<(std::ostream& out, const RequestedLayerState& obj) { |
| 424 | out << obj.debugName; |
| 425 | if (obj.relativeParentId != UNASSIGNED_LAYER_ID) out << " parent=" << obj.parentId; |
| 426 | if (!obj.handleAlive) out << " handleNotAlive"; |
Ady Abraham | 4cb525b | 2023-09-22 17:34:45 -0700 | [diff] [blame] | 427 | if (obj.requestedFrameRate.isValid()) |
| 428 | out << " requestedFrameRate: {" << obj.requestedFrameRate << "}"; |
Vishnu Nair | f13c898 | 2023-12-02 11:26:09 -0800 | [diff] [blame] | 429 | if (obj.dropInputMode != gui::DropInputMode::NONE) |
| 430 | out << " dropInputMode=" << static_cast<uint32_t>(obj.dropInputMode); |
Vishnu Nair | 3cc15a4 | 2023-06-30 06:20:22 +0000 | [diff] [blame] | 431 | return out; |
| 432 | } |
| 433 | |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 434 | std::string RequestedLayerState::getDebugStringShort() const { |
| 435 | return "[" + std::to_string(id) + "]" + name; |
| 436 | } |
| 437 | |
| 438 | bool RequestedLayerState::canBeDestroyed() const { |
| 439 | return !handleAlive && parentId == UNASSIGNED_LAYER_ID; |
| 440 | } |
| 441 | bool RequestedLayerState::isRoot() const { |
| 442 | return canBeRoot && parentId == UNASSIGNED_LAYER_ID; |
| 443 | } |
| 444 | bool RequestedLayerState::isHiddenByPolicy() const { |
| 445 | return (flags & layer_state_t::eLayerHidden) == layer_state_t::eLayerHidden; |
| 446 | }; |
| 447 | half4 RequestedLayerState::getColor() const { |
Vishnu Nair | a02943f | 2023-06-03 13:44:46 -0700 | [diff] [blame] | 448 | if (sidebandStream || externalTexture) { |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 449 | return {0._hf, 0._hf, 0._hf, color.a}; |
| 450 | } |
| 451 | return color; |
| 452 | } |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 453 | Rect RequestedLayerState::getBufferSize(uint32_t displayRotationFlags) const { |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 454 | // for buffer state layers we use the display frame size as the buffer size. |
| 455 | if (!externalTexture) { |
| 456 | return Rect::INVALID_RECT; |
| 457 | } |
| 458 | |
| 459 | uint32_t bufWidth = externalTexture->getWidth(); |
| 460 | uint32_t bufHeight = externalTexture->getHeight(); |
| 461 | |
| 462 | // Undo any transformations on the buffer and return the result. |
| 463 | if (bufferTransform & ui::Transform::ROT_90) { |
| 464 | std::swap(bufWidth, bufHeight); |
| 465 | } |
| 466 | |
| 467 | if (transformToDisplayInverse) { |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 468 | uint32_t invTransform = displayRotationFlags; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 469 | if (invTransform & ui::Transform::ROT_90) { |
| 470 | std::swap(bufWidth, bufHeight); |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | return Rect(0, 0, static_cast<int32_t>(bufWidth), static_cast<int32_t>(bufHeight)); |
| 475 | } |
| 476 | |
Vishnu Nair | a9123c8 | 2024-10-03 03:56:44 +0000 | [diff] [blame] | 477 | FloatRect RequestedLayerState::getCroppedBufferSize(const Rect& bufferSize) const { |
| 478 | FloatRect size = bufferSize.toFloatRect(); |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 479 | if (!crop.isEmpty() && size.isValid()) { |
Vishnu Nair | a9123c8 | 2024-10-03 03:56:44 +0000 | [diff] [blame] | 480 | size = size.intersect(crop); |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 481 | } else if (!crop.isEmpty()) { |
| 482 | size = crop; |
| 483 | } |
| 484 | return size; |
| 485 | } |
| 486 | |
| 487 | Rect RequestedLayerState::getBufferCrop() const { |
| 488 | // this is the crop rectangle that applies to the buffer |
| 489 | // itself (as opposed to the window) |
Chavi Weingarten | 0759734 | 2023-09-14 21:10:59 +0000 | [diff] [blame] | 490 | if (!bufferCrop.isEmpty() && externalTexture != nullptr) { |
| 491 | // if the buffer crop is defined and there's a valid buffer, intersect buffer size and crop |
| 492 | // since the crop should never exceed the size of the buffer. |
| 493 | Rect sizeAndCrop; |
| 494 | externalTexture->getBounds().intersect(bufferCrop, &sizeAndCrop); |
| 495 | return sizeAndCrop; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 496 | } else if (externalTexture != nullptr) { |
| 497 | // otherwise we use the whole buffer |
| 498 | return externalTexture->getBounds(); |
Chavi Weingarten | 0759734 | 2023-09-14 21:10:59 +0000 | [diff] [blame] | 499 | } else if (!bufferCrop.isEmpty()) { |
| 500 | // if the buffer crop is defined, we use that |
| 501 | return bufferCrop; |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 502 | } else { |
| 503 | // if we don't have a buffer yet, we use an empty/invalid crop |
| 504 | return Rect(); |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | aidl::android::hardware::graphics::composer3::Composition RequestedLayerState::getCompositionType() |
| 509 | const { |
| 510 | using aidl::android::hardware::graphics::composer3::Composition; |
| 511 | // TODO(b/238781169) check about sidestream ready flag |
| 512 | if (sidebandStream.get()) { |
| 513 | return Composition::SIDEBAND; |
| 514 | } |
| 515 | if (!externalTexture) { |
| 516 | return Composition::SOLID_COLOR; |
| 517 | } |
| 518 | if (flags & layer_state_t::eLayerIsDisplayDecoration) { |
| 519 | return Composition::DISPLAY_DECORATION; |
| 520 | } |
Vishnu Nair | bd51f95 | 2023-08-31 22:50:14 -0700 | [diff] [blame] | 521 | if (flags & layer_state_t::eLayerIsRefreshRateIndicator) { |
| 522 | return Composition::REFRESH_RATE_INDICATOR; |
| 523 | } |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 524 | if (potentialCursor) { |
| 525 | return Composition::CURSOR; |
| 526 | } |
| 527 | return Composition::DEVICE; |
| 528 | } |
| 529 | |
| 530 | Rect RequestedLayerState::reduce(const Rect& win, const Region& exclude) { |
| 531 | if (CC_LIKELY(exclude.isEmpty())) { |
| 532 | return win; |
| 533 | } |
| 534 | if (exclude.isRect()) { |
| 535 | return win.reduce(exclude.getBounds()); |
| 536 | } |
| 537 | return Region(win).subtract(exclude).getBounds(); |
| 538 | } |
| 539 | |
Vishnu Nair | 04f8969 | 2022-11-16 23:21:05 +0000 | [diff] [blame] | 540 | // Returns true if the layer has a relative parent that is not its own parent. This is an input |
| 541 | // error from the client, and this check allows us to handle it gracefully. If both parentId and |
| 542 | // relativeParentId is unassigned then the layer does not have a valid relative parent. |
| 543 | // If the relative parentid is unassigned, the layer will be considered relative but won't be |
| 544 | // reachable. |
| 545 | bool RequestedLayerState::hasValidRelativeParent() const { |
Vishnu Nair | cfb2d25 | 2023-01-19 04:44:02 +0000 | [diff] [blame] | 546 | return isRelativeOf && |
| 547 | (parentId != relativeParentId || relativeParentId == UNASSIGNED_LAYER_ID); |
Vishnu Nair | 04f8969 | 2022-11-16 23:21:05 +0000 | [diff] [blame] | 548 | } |
| 549 | |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 550 | bool RequestedLayerState::hasInputInfo() const { |
| 551 | if (!windowInfoHandle) { |
| 552 | return false; |
| 553 | } |
| 554 | const auto windowInfo = windowInfoHandle->getInfo(); |
| 555 | return windowInfo->token != nullptr || |
| 556 | windowInfo->inputConfig.test(gui::WindowInfo::InputConfig::NO_INPUT_CHANNEL); |
| 557 | } |
| 558 | |
Wenhui Yang | ab89d81 | 2024-09-11 23:21:38 +0000 | [diff] [blame] | 559 | bool RequestedLayerState::needsInputInfo() const { |
| 560 | if (potentialCursor) { |
| 561 | return false; |
| 562 | } |
| 563 | |
| 564 | if ((sidebandStream != nullptr) || (externalTexture != nullptr)) { |
| 565 | return true; |
| 566 | } |
| 567 | |
| 568 | if (!windowInfoHandle) { |
| 569 | return false; |
| 570 | } |
| 571 | |
| 572 | const auto windowInfo = windowInfoHandle->getInfo(); |
| 573 | return windowInfo->token != nullptr || |
| 574 | windowInfo->inputConfig.test(gui::WindowInfo::InputConfig::NO_INPUT_CHANNEL); |
| 575 | } |
| 576 | |
Vishnu Nair | 80a5a70 | 2023-02-11 01:21:51 +0000 | [diff] [blame] | 577 | bool RequestedLayerState::hasBlur() const { |
| 578 | return backgroundBlurRadius > 0 || blurRegions.size() > 0; |
| 579 | } |
| 580 | |
Vishnu Nair | d47bcee | 2023-02-24 18:08:51 +0000 | [diff] [blame] | 581 | bool RequestedLayerState::hasFrameUpdate() const { |
| 582 | return what & layer_state_t::CONTENT_DIRTY && |
| 583 | (externalTexture || bgColorLayerId != UNASSIGNED_LAYER_ID); |
| 584 | } |
| 585 | |
| 586 | bool RequestedLayerState::hasReadyFrame() const { |
| 587 | return hasFrameUpdate() || changes.test(Changes::SidebandStream) || autoRefresh; |
| 588 | } |
| 589 | |
| 590 | bool RequestedLayerState::hasSidebandStreamFrame() const { |
| 591 | return hasFrameUpdate() && sidebandStream.get(); |
| 592 | } |
| 593 | |
Vishnu Nair | 7ee4f46 | 2023-04-19 09:54:09 -0700 | [diff] [blame] | 594 | bool RequestedLayerState::willReleaseBufferOnLatch() const { |
| 595 | return changes.test(Changes::Buffer) && !externalTexture; |
| 596 | } |
| 597 | |
Vishnu Nair | 4d9cef9 | 2023-06-24 22:34:41 +0000 | [diff] [blame] | 598 | bool RequestedLayerState::backpressureEnabled() const { |
| 599 | return flags & layer_state_t::eEnableBackpressure; |
| 600 | } |
| 601 | |
| 602 | bool RequestedLayerState::isSimpleBufferUpdate(const layer_state_t& s) const { |
| 603 | static constexpr uint64_t requiredFlags = layer_state_t::eBufferChanged; |
| 604 | if ((s.what & requiredFlags) != requiredFlags) { |
Vishnu Nair | be0ad90 | 2024-06-27 23:38:43 +0000 | [diff] [blame] | 605 | SFTRACE_FORMAT_INSTANT("%s: false [missing required flags 0x%" PRIx64 "]", __func__, |
| 606 | (s.what | requiredFlags) & ~s.what); |
Vishnu Nair | 4d9cef9 | 2023-06-24 22:34:41 +0000 | [diff] [blame] | 607 | return false; |
| 608 | } |
| 609 | |
Ady Abraham | bb1ad76 | 2024-03-27 18:31:28 -0700 | [diff] [blame] | 610 | const uint64_t deniedFlags = layer_state_t::eProducerDisconnect | layer_state_t::eLayerChanged | |
| 611 | layer_state_t::eRelativeLayerChanged | layer_state_t::eTransparentRegionChanged | |
Vishnu Nair | c5545d5 | 2024-05-22 17:28:49 -0700 | [diff] [blame] | 612 | layer_state_t::eBlurRegionsChanged | layer_state_t::eLayerStackChanged | |
| 613 | layer_state_t::eReparent | |
Ady Abraham | bb1ad76 | 2024-03-27 18:31:28 -0700 | [diff] [blame] | 614 | (FlagManager::getInstance().latch_unsignaled_with_auto_refresh_changed() |
| 615 | ? 0 |
Vishnu Nair | c5545d5 | 2024-05-22 17:28:49 -0700 | [diff] [blame] | 616 | : (layer_state_t::eAutoRefreshChanged | layer_state_t::eFlagsChanged)); |
Vishnu Nair | 4d9cef9 | 2023-06-24 22:34:41 +0000 | [diff] [blame] | 617 | if (s.what & deniedFlags) { |
Vishnu Nair | be0ad90 | 2024-06-27 23:38:43 +0000 | [diff] [blame] | 618 | SFTRACE_FORMAT_INSTANT("%s: false [has denied flags 0x%" PRIx64 "]", __func__, |
| 619 | s.what & deniedFlags); |
Vishnu Nair | 4d9cef9 | 2023-06-24 22:34:41 +0000 | [diff] [blame] | 620 | return false; |
| 621 | } |
| 622 | |
Vishnu Nair | c5545d5 | 2024-05-22 17:28:49 -0700 | [diff] [blame] | 623 | const uint64_t changedFlags = diff(s); |
| 624 | const uint64_t deniedChanges = layer_state_t::ePositionChanged | layer_state_t::eAlphaChanged | |
| 625 | layer_state_t::eColorTransformChanged | layer_state_t::eBackgroundColorChanged | |
| 626 | layer_state_t::eMatrixChanged | layer_state_t::eCornerRadiusChanged | |
| 627 | layer_state_t::eBackgroundBlurRadiusChanged | layer_state_t::eBufferTransformChanged | |
Vishnu Nair | 4d9cef9 | 2023-06-24 22:34:41 +0000 | [diff] [blame] | 628 | layer_state_t::eTransformToDisplayInverseChanged | layer_state_t::eCropChanged | |
| 629 | layer_state_t::eDataspaceChanged | layer_state_t::eHdrMetadataChanged | |
| 630 | layer_state_t::eSidebandStreamChanged | layer_state_t::eColorSpaceAgnosticChanged | |
| 631 | layer_state_t::eShadowRadiusChanged | layer_state_t::eFixedTransformHintChanged | |
| 632 | layer_state_t::eTrustedOverlayChanged | layer_state_t::eStretchChanged | |
Marzia Favaro | dcc9d9b | 2024-01-10 10:17:00 +0000 | [diff] [blame] | 633 | layer_state_t::eEdgeExtensionChanged | layer_state_t::eBufferCropChanged | |
| 634 | layer_state_t::eDestinationFrameChanged | layer_state_t::eDimmingEnabledChanged | |
| 635 | layer_state_t::eExtendedRangeBrightnessChanged | |
Sally Qi | ef00658 | 2024-10-11 13:23:09 -0700 | [diff] [blame] | 636 | layer_state_t::eDesiredHdrHeadroomChanged | layer_state_t::eLutsChanged | |
Vishnu Nair | c5545d5 | 2024-05-22 17:28:49 -0700 | [diff] [blame] | 637 | (FlagManager::getInstance().latch_unsignaled_with_auto_refresh_changed() |
| 638 | ? layer_state_t::eFlagsChanged |
| 639 | : 0); |
Vishnu Nair | 4d9cef9 | 2023-06-24 22:34:41 +0000 | [diff] [blame] | 640 | if (changedFlags & deniedChanges) { |
Vishnu Nair | be0ad90 | 2024-06-27 23:38:43 +0000 | [diff] [blame] | 641 | SFTRACE_FORMAT_INSTANT("%s: false [has denied changes flags 0x%" PRIx64 "]", __func__, |
| 642 | changedFlags & deniedChanges); |
Vishnu Nair | 4d9cef9 | 2023-06-24 22:34:41 +0000 | [diff] [blame] | 643 | return false; |
| 644 | } |
| 645 | |
| 646 | return true; |
| 647 | } |
| 648 | |
Vishnu Nair | 0808ae6 | 2023-08-07 21:42:42 -0700 | [diff] [blame] | 649 | bool RequestedLayerState::isProtected() const { |
| 650 | return externalTexture && externalTexture->getUsage() & GRALLOC_USAGE_PROTECTED; |
| 651 | } |
| 652 | |
Vishnu Nair | 854ce1c | 2023-08-19 15:00:13 -0700 | [diff] [blame] | 653 | bool RequestedLayerState::hasSomethingToDraw() const { |
| 654 | return externalTexture != nullptr || sidebandStream != nullptr || shadowRadius > 0.f || |
| 655 | backgroundBlurRadius > 0 || blurRegions.size() > 0 || |
| 656 | (color.r >= 0.0_hf && color.g >= 0.0_hf && color.b >= 0.0_hf); |
| 657 | } |
| 658 | |
Vishnu Nair | d47bcee | 2023-02-24 18:08:51 +0000 | [diff] [blame] | 659 | void RequestedLayerState::clearChanges() { |
| 660 | what = 0; |
| 661 | changes.clear(); |
| 662 | } |
| 663 | |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 664 | } // namespace android::surfaceflinger::frontend |