1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/*
* Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <aidl/android/hardware/graphics/composer3/Composition.h>
#include <ftl/flags.h>
#include <gui/LayerState.h>
#include <renderengine/ExternalTexture.h>
#include "Scheduler/LayerInfo.h"
#include "LayerCreationArgs.h"
#include "QueuedTransactionState.h"
namespace android::surfaceflinger::frontend {
using namespace ftl::flag_operators;
// Stores client requested states for a layer.
// This struct does not store any other states or states pertaining to
// other layers. Links to other layers that are part of the client
// requested state such as parent are translated to layer id so
// we can avoid extending the lifetime of layer handles.
struct RequestedLayerState : layer_state_t {
// Changes in state after merging with new state. This includes additional state
// changes found in layer_state_t::what.
enum class Changes : uint32_t {
Created = 1u << 0,
Destroyed = 1u << 1,
Hierarchy = 1u << 2,
Geometry = 1u << 3,
Content = 1u << 4,
Input = 1u << 5,
Z = 1u << 6,
Mirror = 1u << 7,
Parent = 1u << 8,
RelativeParent = 1u << 9,
Metadata = 1u << 10,
Visibility = 1u << 11,
AffectsChildren = 1u << 12,
FrameRate = 1u << 13,
VisibleRegion = 1u << 14,
Buffer = 1u << 15,
SidebandStream = 1u << 16,
Animation = 1u << 17,
BufferSize = 1u << 18,
GameMode = 1u << 19,
BufferUsageFlags = 1u << 20,
};
static constexpr ftl::Flags<Changes> kMustComposite = Changes::Created | Changes::Destroyed |
Changes::Hierarchy | Changes::Geometry | Changes::Content | Changes::Input |
Changes::Z | Changes::Mirror | Changes::Parent | Changes::RelativeParent |
Changes::Metadata | Changes::Visibility | Changes::VisibleRegion | Changes::Buffer |
Changes::SidebandStream | Changes::Animation | Changes::BufferSize | Changes::GameMode |
Changes::BufferUsageFlags;
static Rect reduce(const Rect& win, const Region& exclude);
RequestedLayerState(const LayerCreationArgs&);
void merge(const ResolvedComposerState&);
void clearChanges();
// Currently we only care about the primary display
ui::Transform getTransform(uint32_t displayRotationFlags) const;
ui::Size getUnrotatedBufferSize(uint32_t displayRotationFlags) const;
bool canBeDestroyed() const;
bool isRoot() const;
bool isHiddenByPolicy() const;
half4 getColor() const;
Rect getBufferSize(uint32_t displayRotationFlags) const;
FloatRect getCroppedBufferSize(const Rect& bufferSize) const;
Rect getBufferCrop() const;
std::string getDebugString() const;
std::string getDebugStringShort() const;
friend std::ostream& operator<<(std::ostream& os, const RequestedLayerState& obj);
aidl::android::hardware::graphics::composer3::Composition getCompositionType() const;
bool hasValidRelativeParent() const;
bool hasInputInfo() const;
bool needsInputInfo() const;
bool hasBufferOrSidebandStream() const;
bool fillsColor() const;
bool hasBlur() const;
bool hasFrameUpdate() const;
bool hasReadyFrame() const;
bool hasSidebandStreamFrame() const;
bool willReleaseBufferOnLatch() const;
bool backpressureEnabled() const;
bool isSimpleBufferUpdate(const layer_state_t&) const;
bool isProtected() const;
bool hasSomethingToDraw() const;
// Layer serial number. This gives layers an explicit ordering, so we
// have a stable sort order when their layer stack and Z-order are
// the same.
const uint32_t id;
const std::string name;
bool canBeRoot = false;
const uint32_t layerCreationFlags;
// The owner of the layer. If created from a non system process, it will be the calling uid.
// If created from a system process, the value can be passed in.
const gui::Uid ownerUid;
// The owner pid of the layer. If created from a non system process, it will be the calling pid.
// If created from a system process, the value can be passed in.
const gui::Pid ownerPid;
bool dataspaceRequested;
bool hasColorTransform;
bool transformIsValid = true;
bool premultipliedAlpha{true};
// This layer can be a cursor on some displays.
bool potentialCursor{false};
bool protectedByApp{false}; // application requires protected path to external sink
ui::Transform requestedTransform;
std::shared_ptr<FenceTime> acquireFenceTime;
std::shared_ptr<renderengine::ExternalTexture> externalTexture;
gui::GameMode gameMode;
scheduler::LayerInfo::FrameRate requestedFrameRate;
uint32_t parentId = UNASSIGNED_LAYER_ID;
uint32_t relativeParentId = UNASSIGNED_LAYER_ID;
uint32_t layerIdToMirror = UNASSIGNED_LAYER_ID;
ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK;
uint32_t touchCropId = UNASSIGNED_LAYER_ID;
uint32_t bgColorLayerId = UNASSIGNED_LAYER_ID;
uint64_t barrierFrameNumber = 0;
uint32_t barrierProducerId = 0;
std::string debugName;
std::atomic<int32_t>* pendingBuffers = 0;
// book keeping states
bool handleAlive = true;
bool isRelativeOf = false;
std::vector<uint32_t> mirrorIds{};
ftl::Flags<RequestedLayerState::Changes> changes;
bool bgColorLayer = false;
};
} // namespace android::surfaceflinger::frontend
|