Vishnu Nair | 532d645 | 2024-07-14 22:05:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2024 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 | #pragma once |
| 18 | |
| 19 | #include <gui/fake/BufferData.h> |
| 20 | #include <renderengine/mock/FakeExternalTexture.h> |
| 21 | #include <ui/ShadowSettings.h> |
| 22 | |
| 23 | #include <Client.h> // temporarily needed for LayerCreationArgs |
| 24 | #include <FrontEnd/LayerCreationArgs.h> |
| 25 | #include <FrontEnd/LayerHierarchy.h> |
| 26 | #include <FrontEnd/LayerLifecycleManager.h> |
| 27 | #include <FrontEnd/LayerSnapshotBuilder.h> |
| 28 | |
| 29 | namespace android::surfaceflinger::frontend { |
| 30 | |
| 31 | class LayerLifecycleManagerHelper { |
| 32 | public: |
| 33 | LayerLifecycleManagerHelper(LayerLifecycleManager& layerLifecycleManager) |
| 34 | : mLifecycleManager(layerLifecycleManager) {} |
| 35 | ~LayerLifecycleManagerHelper() = default; |
| 36 | |
| 37 | static LayerCreationArgs createArgs(uint32_t id, bool canBeRoot, uint32_t parentId, |
| 38 | uint32_t layerIdToMirror) { |
| 39 | LayerCreationArgs args(std::make_optional(id)); |
| 40 | args.name = "testlayer"; |
| 41 | args.addToRoot = canBeRoot; |
| 42 | args.parentId = parentId; |
| 43 | args.layerIdToMirror = layerIdToMirror; |
| 44 | return args; |
| 45 | } |
| 46 | |
| 47 | static LayerCreationArgs createDisplayMirrorArgs(uint32_t id, |
| 48 | ui::LayerStack layerStackToMirror) { |
| 49 | LayerCreationArgs args(std::make_optional(id)); |
| 50 | args.name = "testlayer"; |
| 51 | args.addToRoot = true; |
| 52 | args.layerStackToMirror = layerStackToMirror; |
| 53 | return args; |
| 54 | } |
| 55 | |
| 56 | static std::unique_ptr<RequestedLayerState> rootLayer(uint32_t id) { |
| 57 | return std::make_unique<RequestedLayerState>(createArgs(/*id=*/id, /*canBeRoot=*/true, |
| 58 | /*parent=*/UNASSIGNED_LAYER_ID, |
| 59 | /*mirror=*/UNASSIGNED_LAYER_ID)); |
| 60 | } |
| 61 | |
| 62 | static std::unique_ptr<RequestedLayerState> childLayer(uint32_t id, uint32_t parentId) { |
| 63 | return std::make_unique<RequestedLayerState>(createArgs(/*id=*/id, /*canBeRoot=*/false, |
| 64 | parentId, |
| 65 | /*mirror=*/UNASSIGNED_LAYER_ID)); |
| 66 | } |
| 67 | |
| 68 | static std::vector<TransactionState> setZTransaction(uint32_t id, int32_t z) { |
| 69 | std::vector<TransactionState> transactions; |
| 70 | transactions.emplace_back(); |
| 71 | transactions.back().states.push_back({}); |
| 72 | |
| 73 | transactions.back().states.front().state.what = layer_state_t::eLayerChanged; |
| 74 | transactions.back().states.front().layerId = id; |
| 75 | transactions.back().states.front().state.z = z; |
| 76 | return transactions; |
| 77 | } |
| 78 | |
| 79 | void createRootLayer(uint32_t id) { |
| 80 | std::vector<std::unique_ptr<RequestedLayerState>> layers; |
| 81 | layers.emplace_back(std::make_unique<RequestedLayerState>( |
| 82 | createArgs(/*id=*/id, /*canBeRoot=*/true, /*parent=*/UNASSIGNED_LAYER_ID, |
| 83 | /*mirror=*/UNASSIGNED_LAYER_ID))); |
| 84 | mLifecycleManager.addLayers(std::move(layers)); |
| 85 | } |
| 86 | |
| 87 | void createDisplayMirrorLayer(uint32_t id, ui::LayerStack layerStack) { |
| 88 | std::vector<std::unique_ptr<RequestedLayerState>> layers; |
| 89 | layers.emplace_back(std::make_unique<RequestedLayerState>( |
| 90 | createDisplayMirrorArgs(/*id=*/id, layerStack))); |
| 91 | mLifecycleManager.addLayers(std::move(layers)); |
| 92 | } |
| 93 | |
| 94 | void createLayer(uint32_t id, uint32_t parentId) { |
| 95 | std::vector<std::unique_ptr<RequestedLayerState>> layers; |
| 96 | layers.emplace_back(std::make_unique<RequestedLayerState>( |
| 97 | createArgs(/*id=*/id, /*canBeRoot=*/false, /*parent=*/parentId, |
| 98 | /*mirror=*/UNASSIGNED_LAYER_ID))); |
| 99 | mLifecycleManager.addLayers(std::move(layers)); |
| 100 | } |
| 101 | |
| 102 | std::vector<TransactionState> reparentLayerTransaction(uint32_t id, uint32_t newParentId) { |
| 103 | std::vector<TransactionState> transactions; |
| 104 | transactions.emplace_back(); |
| 105 | transactions.back().states.push_back({}); |
| 106 | transactions.back().states.front().parentId = newParentId; |
| 107 | transactions.back().states.front().state.what = layer_state_t::eReparent; |
| 108 | transactions.back().states.front().relativeParentId = UNASSIGNED_LAYER_ID; |
| 109 | transactions.back().states.front().layerId = id; |
| 110 | return transactions; |
| 111 | } |
| 112 | |
| 113 | void reparentLayer(uint32_t id, uint32_t newParentId) { |
| 114 | mLifecycleManager.applyTransactions(reparentLayerTransaction(id, newParentId)); |
| 115 | } |
| 116 | |
| 117 | std::vector<TransactionState> relativeLayerTransaction(uint32_t id, uint32_t relativeParentId) { |
| 118 | std::vector<TransactionState> transactions; |
| 119 | transactions.emplace_back(); |
| 120 | transactions.back().states.push_back({}); |
| 121 | transactions.back().states.front().relativeParentId = relativeParentId; |
| 122 | transactions.back().states.front().state.what = layer_state_t::eRelativeLayerChanged; |
| 123 | transactions.back().states.front().layerId = id; |
| 124 | return transactions; |
| 125 | } |
| 126 | |
| 127 | void reparentRelativeLayer(uint32_t id, uint32_t relativeParentId) { |
| 128 | mLifecycleManager.applyTransactions(relativeLayerTransaction(id, relativeParentId)); |
| 129 | } |
| 130 | |
| 131 | void removeRelativeZ(uint32_t id) { |
| 132 | std::vector<TransactionState> transactions; |
| 133 | transactions.emplace_back(); |
| 134 | transactions.back().states.push_back({}); |
| 135 | transactions.back().states.front().state.what = layer_state_t::eLayerChanged; |
| 136 | transactions.back().states.front().layerId = id; |
| 137 | mLifecycleManager.applyTransactions(transactions); |
| 138 | } |
| 139 | |
| 140 | void setPosition(uint32_t id, float x, float y) { |
| 141 | std::vector<TransactionState> transactions; |
| 142 | transactions.emplace_back(); |
| 143 | transactions.back().states.push_back({}); |
| 144 | transactions.back().states.front().state.what = layer_state_t::ePositionChanged; |
| 145 | transactions.back().states.front().state.x = x; |
| 146 | transactions.back().states.front().state.y = y; |
| 147 | transactions.back().states.front().layerId = id; |
| 148 | mLifecycleManager.applyTransactions(transactions); |
| 149 | } |
| 150 | |
| 151 | void mirrorLayer(uint32_t id, uint32_t parentId, uint32_t layerIdToMirror) { |
| 152 | std::vector<std::unique_ptr<RequestedLayerState>> layers; |
| 153 | layers.emplace_back(std::make_unique<RequestedLayerState>( |
| 154 | createArgs(/*id=*/id, /*canBeRoot=*/false, /*parent=*/parentId, |
| 155 | /*mirror=*/layerIdToMirror))); |
| 156 | mLifecycleManager.addLayers(std::move(layers)); |
| 157 | } |
| 158 | |
| 159 | void updateBackgroundColor(uint32_t id, half alpha) { |
| 160 | std::vector<TransactionState> transactions; |
| 161 | transactions.emplace_back(); |
| 162 | transactions.back().states.push_back({}); |
| 163 | transactions.back().states.front().state.what = layer_state_t::eBackgroundColorChanged; |
| 164 | transactions.back().states.front().state.bgColor.a = alpha; |
| 165 | transactions.back().states.front().layerId = id; |
| 166 | mLifecycleManager.applyTransactions(transactions); |
| 167 | } |
| 168 | |
| 169 | void destroyLayerHandle(uint32_t id) { mLifecycleManager.onHandlesDestroyed({{id, "test"}}); } |
| 170 | |
| 171 | void setZ(uint32_t id, int32_t z) { |
| 172 | mLifecycleManager.applyTransactions(setZTransaction(id, z)); |
| 173 | } |
| 174 | |
| 175 | void setCrop(uint32_t id, const Rect& crop) { |
| 176 | std::vector<TransactionState> transactions; |
| 177 | transactions.emplace_back(); |
| 178 | transactions.back().states.push_back({}); |
| 179 | |
| 180 | transactions.back().states.front().state.what = layer_state_t::eCropChanged; |
| 181 | transactions.back().states.front().layerId = id; |
| 182 | transactions.back().states.front().state.crop = crop; |
| 183 | mLifecycleManager.applyTransactions(transactions); |
| 184 | } |
| 185 | |
| 186 | void setFlags(uint32_t id, uint32_t mask, uint32_t flags) { |
| 187 | std::vector<TransactionState> transactions; |
| 188 | transactions.emplace_back(); |
| 189 | transactions.back().states.push_back({}); |
| 190 | |
| 191 | transactions.back().states.front().state.what = layer_state_t::eFlagsChanged; |
| 192 | transactions.back().states.front().state.flags = flags; |
| 193 | transactions.back().states.front().state.mask = mask; |
| 194 | transactions.back().states.front().layerId = id; |
| 195 | mLifecycleManager.applyTransactions(transactions); |
| 196 | } |
| 197 | |
| 198 | void setAlpha(uint32_t id, float alpha) { |
| 199 | std::vector<TransactionState> transactions; |
| 200 | transactions.emplace_back(); |
| 201 | transactions.back().states.push_back({}); |
| 202 | |
| 203 | transactions.back().states.front().state.what = layer_state_t::eAlphaChanged; |
| 204 | transactions.back().states.front().layerId = id; |
| 205 | transactions.back().states.front().state.color.a = static_cast<half>(alpha); |
| 206 | mLifecycleManager.applyTransactions(transactions); |
| 207 | } |
| 208 | |
| 209 | void hideLayer(uint32_t id) { |
| 210 | setFlags(id, layer_state_t::eLayerHidden, layer_state_t::eLayerHidden); |
| 211 | } |
| 212 | |
| 213 | void showLayer(uint32_t id) { setFlags(id, layer_state_t::eLayerHidden, 0); } |
| 214 | |
| 215 | void setColor(uint32_t id, half3 rgb = half3(1._hf, 1._hf, 1._hf)) { |
| 216 | std::vector<TransactionState> transactions; |
| 217 | transactions.emplace_back(); |
| 218 | transactions.back().states.push_back({}); |
| 219 | transactions.back().states.front().state.what = layer_state_t::eColorChanged; |
| 220 | transactions.back().states.front().state.color.rgb = rgb; |
| 221 | transactions.back().states.front().layerId = id; |
| 222 | mLifecycleManager.applyTransactions(transactions); |
| 223 | } |
| 224 | |
| 225 | void setLayerStack(uint32_t id, int32_t layerStack) { |
| 226 | std::vector<TransactionState> transactions; |
| 227 | transactions.emplace_back(); |
| 228 | transactions.back().states.push_back({}); |
| 229 | |
| 230 | transactions.back().states.front().state.what = layer_state_t::eLayerStackChanged; |
| 231 | transactions.back().states.front().layerId = id; |
| 232 | transactions.back().states.front().state.layerStack = ui::LayerStack::fromValue(layerStack); |
| 233 | mLifecycleManager.applyTransactions(transactions); |
| 234 | } |
| 235 | |
| 236 | void setTouchableRegion(uint32_t id, Region region) { |
| 237 | std::vector<TransactionState> transactions; |
| 238 | transactions.emplace_back(); |
| 239 | transactions.back().states.push_back({}); |
| 240 | |
| 241 | transactions.back().states.front().state.what = layer_state_t::eInputInfoChanged; |
| 242 | transactions.back().states.front().layerId = id; |
| 243 | transactions.back().states.front().state.windowInfoHandle = |
| 244 | sp<gui::WindowInfoHandle>::make(); |
| 245 | auto inputInfo = transactions.back().states.front().state.windowInfoHandle->editInfo(); |
| 246 | inputInfo->touchableRegion = region; |
| 247 | inputInfo->token = sp<BBinder>::make(); |
| 248 | mLifecycleManager.applyTransactions(transactions); |
| 249 | } |
| 250 | |
| 251 | void setInputInfo(uint32_t id, std::function<void(gui::WindowInfo&)> configureInput) { |
| 252 | std::vector<TransactionState> transactions; |
| 253 | transactions.emplace_back(); |
| 254 | transactions.back().states.push_back({}); |
| 255 | |
| 256 | transactions.back().states.front().state.what = layer_state_t::eInputInfoChanged; |
| 257 | transactions.back().states.front().layerId = id; |
| 258 | transactions.back().states.front().state.windowInfoHandle = |
| 259 | sp<gui::WindowInfoHandle>::make(); |
| 260 | auto inputInfo = transactions.back().states.front().state.windowInfoHandle->editInfo(); |
| 261 | if (!inputInfo->token) { |
| 262 | inputInfo->token = sp<BBinder>::make(); |
| 263 | } |
| 264 | configureInput(*inputInfo); |
| 265 | |
| 266 | mLifecycleManager.applyTransactions(transactions); |
| 267 | } |
| 268 | |
| 269 | void setTouchableRegionCrop(uint32_t id, Region region, uint32_t touchCropId, |
| 270 | bool replaceTouchableRegionWithCrop) { |
| 271 | std::vector<TransactionState> transactions; |
| 272 | transactions.emplace_back(); |
| 273 | transactions.back().states.push_back({}); |
| 274 | |
| 275 | transactions.back().states.front().state.what = layer_state_t::eInputInfoChanged; |
| 276 | transactions.back().states.front().layerId = id; |
| 277 | transactions.back().states.front().state.windowInfoHandle = |
| 278 | sp<gui::WindowInfoHandle>::make(); |
| 279 | auto inputInfo = transactions.back().states.front().state.windowInfoHandle->editInfo(); |
| 280 | inputInfo->touchableRegion = region; |
| 281 | inputInfo->replaceTouchableRegionWithCrop = replaceTouchableRegionWithCrop; |
| 282 | transactions.back().states.front().touchCropId = touchCropId; |
| 283 | |
| 284 | inputInfo->token = sp<BBinder>::make(); |
| 285 | mLifecycleManager.applyTransactions(transactions); |
| 286 | } |
| 287 | |
| 288 | void setBackgroundBlurRadius(uint32_t id, uint32_t backgroundBlurRadius) { |
| 289 | std::vector<TransactionState> transactions; |
| 290 | transactions.emplace_back(); |
| 291 | transactions.back().states.push_back({}); |
| 292 | |
| 293 | transactions.back().states.front().state.what = layer_state_t::eBackgroundBlurRadiusChanged; |
| 294 | transactions.back().states.front().layerId = id; |
| 295 | transactions.back().states.front().state.backgroundBlurRadius = backgroundBlurRadius; |
| 296 | mLifecycleManager.applyTransactions(transactions); |
| 297 | } |
| 298 | |
| 299 | void setFrameRateSelectionPriority(uint32_t id, int32_t priority) { |
| 300 | std::vector<TransactionState> transactions; |
| 301 | transactions.emplace_back(); |
| 302 | transactions.back().states.push_back({}); |
| 303 | |
| 304 | transactions.back().states.front().state.what = layer_state_t::eFrameRateSelectionPriority; |
| 305 | transactions.back().states.front().layerId = id; |
| 306 | transactions.back().states.front().state.frameRateSelectionPriority = priority; |
| 307 | mLifecycleManager.applyTransactions(transactions); |
| 308 | } |
| 309 | |
| 310 | void setFrameRate(uint32_t id, float frameRate, int8_t compatibility, |
| 311 | int8_t changeFrameRateStrategy) { |
| 312 | std::vector<TransactionState> transactions; |
| 313 | transactions.emplace_back(); |
| 314 | transactions.back().states.push_back({}); |
| 315 | |
| 316 | transactions.back().states.front().state.what = layer_state_t::eFrameRateChanged; |
| 317 | transactions.back().states.front().layerId = id; |
| 318 | transactions.back().states.front().state.frameRate = frameRate; |
| 319 | transactions.back().states.front().state.frameRateCompatibility = compatibility; |
| 320 | transactions.back().states.front().state.changeFrameRateStrategy = changeFrameRateStrategy; |
| 321 | mLifecycleManager.applyTransactions(transactions); |
| 322 | } |
| 323 | |
| 324 | void setFrameRateCategory(uint32_t id, int8_t frameRateCategory) { |
| 325 | std::vector<TransactionState> transactions; |
| 326 | transactions.emplace_back(); |
| 327 | transactions.back().states.push_back({}); |
| 328 | |
| 329 | transactions.back().states.front().state.what = layer_state_t::eFrameRateCategoryChanged; |
| 330 | transactions.back().states.front().layerId = id; |
| 331 | transactions.back().states.front().state.frameRateCategory = frameRateCategory; |
| 332 | mLifecycleManager.applyTransactions(transactions); |
| 333 | } |
| 334 | |
| 335 | void setFrameRateSelectionStrategy(uint32_t id, int8_t strategy) { |
| 336 | std::vector<TransactionState> transactions; |
| 337 | transactions.emplace_back(); |
| 338 | transactions.back().states.push_back({}); |
| 339 | |
| 340 | transactions.back().states.front().state.what = |
| 341 | layer_state_t::eFrameRateSelectionStrategyChanged; |
| 342 | transactions.back().states.front().layerId = id; |
| 343 | transactions.back().states.front().state.frameRateSelectionStrategy = strategy; |
| 344 | mLifecycleManager.applyTransactions(transactions); |
| 345 | } |
| 346 | |
| 347 | void setDefaultFrameRateCompatibility(uint32_t id, int8_t defaultFrameRateCompatibility) { |
| 348 | std::vector<TransactionState> transactions; |
| 349 | transactions.emplace_back(); |
| 350 | transactions.back().states.push_back({}); |
| 351 | |
| 352 | transactions.back().states.front().state.what = |
| 353 | layer_state_t::eDefaultFrameRateCompatibilityChanged; |
| 354 | transactions.back().states.front().layerId = id; |
| 355 | transactions.back().states.front().state.defaultFrameRateCompatibility = |
| 356 | defaultFrameRateCompatibility; |
| 357 | mLifecycleManager.applyTransactions(transactions); |
| 358 | } |
| 359 | |
| 360 | void setRoundedCorners(uint32_t id, float radius) { |
| 361 | std::vector<TransactionState> transactions; |
| 362 | transactions.emplace_back(); |
| 363 | transactions.back().states.push_back({}); |
| 364 | |
| 365 | transactions.back().states.front().state.what = layer_state_t::eCornerRadiusChanged; |
| 366 | transactions.back().states.front().layerId = id; |
| 367 | transactions.back().states.front().state.cornerRadius = radius; |
| 368 | mLifecycleManager.applyTransactions(transactions); |
| 369 | } |
| 370 | |
| 371 | void setBuffer(uint32_t id, std::shared_ptr<renderengine::ExternalTexture> texture) { |
| 372 | std::vector<TransactionState> transactions; |
| 373 | transactions.emplace_back(); |
| 374 | transactions.back().states.push_back({}); |
| 375 | |
| 376 | transactions.back().states.front().state.what = layer_state_t::eBufferChanged; |
| 377 | transactions.back().states.front().layerId = id; |
| 378 | transactions.back().states.front().externalTexture = texture; |
| 379 | transactions.back().states.front().state.bufferData = |
| 380 | std::make_shared<fake::BufferData>(texture->getId(), texture->getWidth(), |
| 381 | texture->getHeight(), texture->getPixelFormat(), |
| 382 | texture->getUsage()); |
| 383 | mLifecycleManager.applyTransactions(transactions); |
| 384 | } |
| 385 | |
| 386 | void setBuffer(uint32_t id) { |
| 387 | static uint64_t sBufferId = 1; |
| 388 | setBuffer(id, |
| 389 | std::make_shared<renderengine::mock:: |
| 390 | FakeExternalTexture>(1U /*width*/, 1U /*height*/, |
| 391 | sBufferId++, |
| 392 | HAL_PIXEL_FORMAT_RGBA_8888, |
| 393 | GRALLOC_USAGE_PROTECTED /*usage*/)); |
| 394 | } |
| 395 | |
| 396 | void setBufferCrop(uint32_t id, const Rect& bufferCrop) { |
| 397 | std::vector<TransactionState> transactions; |
| 398 | transactions.emplace_back(); |
| 399 | transactions.back().states.push_back({}); |
| 400 | |
| 401 | transactions.back().states.front().state.what = layer_state_t::eBufferCropChanged; |
| 402 | transactions.back().states.front().layerId = id; |
| 403 | transactions.back().states.front().state.bufferCrop = bufferCrop; |
| 404 | mLifecycleManager.applyTransactions(transactions); |
| 405 | } |
| 406 | |
| 407 | void setDamageRegion(uint32_t id, const Region& damageRegion) { |
| 408 | std::vector<TransactionState> transactions; |
| 409 | transactions.emplace_back(); |
| 410 | transactions.back().states.push_back({}); |
| 411 | |
| 412 | transactions.back().states.front().state.what = layer_state_t::eSurfaceDamageRegionChanged; |
| 413 | transactions.back().states.front().layerId = id; |
| 414 | transactions.back().states.front().state.surfaceDamageRegion = damageRegion; |
| 415 | mLifecycleManager.applyTransactions(transactions); |
| 416 | } |
| 417 | |
| 418 | void setDataspace(uint32_t id, ui::Dataspace dataspace) { |
| 419 | std::vector<TransactionState> transactions; |
| 420 | transactions.emplace_back(); |
| 421 | transactions.back().states.push_back({}); |
| 422 | |
| 423 | transactions.back().states.front().state.what = layer_state_t::eDataspaceChanged; |
| 424 | transactions.back().states.front().layerId = id; |
| 425 | transactions.back().states.front().state.dataspace = dataspace; |
| 426 | mLifecycleManager.applyTransactions(transactions); |
| 427 | } |
| 428 | |
| 429 | void setMatrix(uint32_t id, float dsdx, float dtdx, float dtdy, float dsdy) { |
| 430 | layer_state_t::matrix22_t matrix{dsdx, dtdx, dtdy, dsdy}; |
| 431 | |
| 432 | std::vector<TransactionState> transactions; |
| 433 | transactions.emplace_back(); |
| 434 | transactions.back().states.push_back({}); |
| 435 | |
| 436 | transactions.back().states.front().state.what = layer_state_t::eMatrixChanged; |
| 437 | transactions.back().states.front().layerId = id; |
| 438 | transactions.back().states.front().state.matrix = matrix; |
| 439 | mLifecycleManager.applyTransactions(transactions); |
| 440 | } |
| 441 | |
| 442 | void setShadowRadius(uint32_t id, float shadowRadius) { |
| 443 | std::vector<TransactionState> transactions; |
| 444 | transactions.emplace_back(); |
| 445 | transactions.back().states.push_back({}); |
| 446 | |
| 447 | transactions.back().states.front().state.what = layer_state_t::eShadowRadiusChanged; |
| 448 | transactions.back().states.front().layerId = id; |
| 449 | transactions.back().states.front().state.shadowRadius = shadowRadius; |
| 450 | mLifecycleManager.applyTransactions(transactions); |
| 451 | } |
| 452 | |
| 453 | void setTrustedOverlay(uint32_t id, gui::TrustedOverlay trustedOverlay) { |
| 454 | std::vector<TransactionState> transactions; |
| 455 | transactions.emplace_back(); |
| 456 | transactions.back().states.push_back({}); |
| 457 | |
| 458 | transactions.back().states.front().state.what = layer_state_t::eTrustedOverlayChanged; |
| 459 | transactions.back().states.front().layerId = id; |
| 460 | transactions.back().states.front().state.trustedOverlay = trustedOverlay; |
| 461 | mLifecycleManager.applyTransactions(transactions); |
| 462 | } |
| 463 | |
| 464 | void setDropInputMode(uint32_t id, gui::DropInputMode dropInputMode) { |
| 465 | std::vector<TransactionState> transactions; |
| 466 | transactions.emplace_back(); |
| 467 | transactions.back().states.push_back({}); |
| 468 | |
| 469 | transactions.back().states.front().state.what = layer_state_t::eDropInputModeChanged; |
| 470 | transactions.back().states.front().layerId = id; |
| 471 | transactions.back().states.front().state.dropInputMode = dropInputMode; |
| 472 | mLifecycleManager.applyTransactions(transactions); |
| 473 | } |
| 474 | |
Vishnu Nair | 39a74a9 | 2024-07-29 19:01:50 +0000 | [diff] [blame] | 475 | void setGameMode(uint32_t id, gui::GameMode gameMode) { |
| 476 | std::vector<TransactionState> transactions; |
| 477 | transactions.emplace_back(); |
| 478 | transactions.back().states.push_back({}); |
| 479 | transactions.back().states.front().state.what = layer_state_t::eMetadataChanged; |
| 480 | transactions.back().states.front().state.metadata = LayerMetadata(); |
| 481 | transactions.back().states.front().state.metadata.setInt32(METADATA_GAME_MODE, |
| 482 | static_cast<int32_t>(gameMode)); |
| 483 | transactions.back().states.front().layerId = id; |
| 484 | mLifecycleManager.applyTransactions(transactions); |
| 485 | } |
| 486 | |
Vishnu Nair | 532d645 | 2024-07-14 22:05:12 -0700 | [diff] [blame] | 487 | private: |
| 488 | LayerLifecycleManager& mLifecycleManager; |
| 489 | }; |
| 490 | |
| 491 | } // namespace android::surfaceflinger::frontend |