Vishnu Nair | cb8be50 | 2022-10-12 19:03:23 +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 | #pragma once |
| 18 | |
| 19 | #include <binder/Binder.h> |
| 20 | #include <gui/LayerMetadata.h> |
Vishnu Nair | a9c4376 | 2023-01-27 19:10:25 +0000 | [diff] [blame] | 21 | #include <ui/LayerStack.h> |
Vishnu Nair | cb8be50 | 2022-10-12 19:03:23 +0000 | [diff] [blame] | 22 | #include <utils/StrongPointer.h> |
| 23 | #include <cstdint> |
| 24 | #include <limits> |
| 25 | #include <optional> |
Vishnu Nair | a9c4376 | 2023-01-27 19:10:25 +0000 | [diff] [blame] | 26 | |
Vishnu Nair | cb8be50 | 2022-10-12 19:03:23 +0000 | [diff] [blame] | 27 | constexpr uint32_t UNASSIGNED_LAYER_ID = std::numeric_limits<uint32_t>::max(); |
Vishnu Nair | d47bcee | 2023-02-24 18:08:51 +0000 | [diff] [blame] | 28 | constexpr uint32_t INTERNAL_LAYER_PREFIX = 1u << 31; |
Vishnu Nair | cb8be50 | 2022-10-12 19:03:23 +0000 | [diff] [blame] | 29 | |
| 30 | namespace android { |
| 31 | class SurfaceFlinger; |
| 32 | class Client; |
| 33 | } // namespace android |
| 34 | |
| 35 | namespace android::surfaceflinger { |
| 36 | |
| 37 | struct LayerCreationArgs { |
| 38 | static std::atomic<uint32_t> sSequence; |
Vishnu Nair | 150065b | 2023-04-17 19:14:11 -0700 | [diff] [blame] | 39 | static std::atomic<uint32_t> sInternalSequence; |
Vishnu Nair | d47bcee | 2023-02-24 18:08:51 +0000 | [diff] [blame] | 40 | static uint32_t getInternalLayerId(uint32_t id); |
Vishnu Nair | 8175062 | 2023-03-08 15:02:06 -0800 | [diff] [blame] | 41 | static LayerCreationArgs fromOtherArgs(const LayerCreationArgs& other); |
Vishnu Nair | cb8be50 | 2022-10-12 19:03:23 +0000 | [diff] [blame] | 42 | |
| 43 | LayerCreationArgs(android::SurfaceFlinger*, sp<android::Client>, std::string name, |
Vishnu Nair | d47bcee | 2023-02-24 18:08:51 +0000 | [diff] [blame] | 44 | uint32_t flags, gui::LayerMetadata, std::optional<uint32_t> id = std::nullopt, |
| 45 | bool internalLayer = false); |
Vishnu Nair | 1391de2 | 2023-03-05 19:56:14 -0800 | [diff] [blame] | 46 | LayerCreationArgs(std::optional<uint32_t> id, bool internalLayer = false); |
Vishnu Nair | 8175062 | 2023-03-08 15:02:06 -0800 | [diff] [blame] | 47 | LayerCreationArgs() = default; // for tracing |
Vishnu Nair | 20e1f96 | 2023-03-29 15:58:34 -0700 | [diff] [blame] | 48 | std::string getDebugString() const; |
Vishnu Nair | cb8be50 | 2022-10-12 19:03:23 +0000 | [diff] [blame] | 49 | |
| 50 | android::SurfaceFlinger* flinger; |
| 51 | sp<android::Client> client; |
| 52 | std::string name; |
| 53 | uint32_t flags; // ISurfaceComposerClient flags |
| 54 | gui::LayerMetadata metadata; |
| 55 | pid_t ownerPid; |
| 56 | uid_t ownerUid; |
Vishnu Nair | cb8be50 | 2022-10-12 19:03:23 +0000 | [diff] [blame] | 57 | uint32_t sequence; |
| 58 | bool addToRoot = true; |
| 59 | wp<IBinder> parentHandle = nullptr; |
| 60 | wp<IBinder> mirrorLayerHandle = nullptr; |
Vishnu Nair | a9c4376 | 2023-01-27 19:10:25 +0000 | [diff] [blame] | 61 | ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK; |
Vishnu Nair | 1391de2 | 2023-03-05 19:56:14 -0800 | [diff] [blame] | 62 | uint32_t parentId = UNASSIGNED_LAYER_ID; |
| 63 | uint32_t layerIdToMirror = UNASSIGNED_LAYER_ID; |
Vishnu Nair | cb8be50 | 2022-10-12 19:03:23 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | } // namespace android::surfaceflinger |