blob: 2ba781d9244f5be820cec696d67ca9aafbf98303 [file] [log] [blame]
Lloyd Pique0b785d82018-12-04 17:25:27 -08001/*
2 * Copyright 2019 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 <cstdint>
20
21#include <gui/BufferQueue.h>
22#include <gui/HdrMetadata.h>
23#include <math/mat4.h>
24#include <ui/FloatRect.h>
25#include <ui/GraphicBuffer.h>
26#include <ui/GraphicTypes.h>
27#include <ui/Rect.h>
28#include <ui/Region.h>
29#include <ui/Transform.h>
30
31#include "DisplayHardware/ComposerHal.h"
32
33namespace android::compositionengine {
34
35/*
36 * Used by LayerFE::getCompositionState
37 */
38struct LayerFECompositionState {
Lloyd Piquef5275482019-01-29 18:42:42 -080039 // If set to true, forces client composition on all output layers until
40 // the next geometry change.
41 bool forceClientComposition{false};
Lloyd Pique07e33212018-12-18 16:33:37 -080042
Lloyd Piquec6687342019-03-07 21:34:57 -080043 // TODO(b/121291683): Reorganize and rename the contents of this structure
44
45 /*
46 * Visibility state
47 */
48 // the layer stack this layer belongs to
49 std::optional<uint32_t> layerStackId;
50
51 // If true, this layer should be only visible on the internal display
52 bool internalOnly{false};
53
54 // If false, this layer should not be considered visible
55 bool isVisible{true};
56
57 // True if the layer is completely opaque
58 bool isOpaque{true};
59
60 // If true, invalidates the entire visible region
61 bool contentDirty{false};
62
63 // The alpha value for this layer
64 float alpha{1.f};
65
66 // The transform from layer local coordinates to composition coordinates
67 ui::Transform geomLayerTransform;
68
69 // The inverse of the layer transform
70 ui::Transform geomInverseLayerTransform;
71
72 // The hint from the layer producer as to what portion of the layer is
73 // transparent.
74 Region transparentRegionHint;
75
76 // The blend mode for this layer
77 Hwc2::IComposerClient::BlendMode blendMode{Hwc2::IComposerClient::BlendMode::INVALID};
78
79 // The bounds of the layer in layer local coordinates
80 FloatRect geomLayerBounds;
81
Lloyd Pique0b785d82018-12-04 17:25:27 -080082 /*
Lloyd Piquea83776c2019-01-29 18:42:32 -080083 * Geometry state
84 */
85
86 bool isSecure{false};
87 bool geomUsesSourceCrop{false};
88 bool geomBufferUsesDisplayInverseTransform{false};
89 uint32_t geomBufferTransform{0};
Lloyd Piquea83776c2019-01-29 18:42:32 -080090 Rect geomBufferSize;
91 Rect geomContentCrop;
92 Rect geomCrop;
Lloyd Pique0b785d82018-12-04 17:25:27 -080093
94 /*
95 * Extra metadata
96 */
97
98 // The type for this layer
99 int type{0};
100
101 // The appId for this layer
102 int appId{0};
103
104 /*
105 * Per-frame content
106 */
107
108 // The type of composition for this layer
109 Hwc2::IComposerClient::Composition compositionType{Hwc2::IComposerClient::Composition::INVALID};
110
111 // The buffer and related state
112 sp<GraphicBuffer> buffer;
113 int bufferSlot{BufferQueue::INVALID_BUFFER_SLOT};
114 sp<Fence> acquireFence;
115 Region surfaceDamage;
116
117 // The handle to use for a sideband stream for this layer
118 sp<NativeHandle> sidebandStream;
119
120 // The color for this layer
Lloyd Piquef5275482019-01-29 18:42:42 -0800121 half4 color;
Lloyd Pique0b785d82018-12-04 17:25:27 -0800122
123 /*
124 * Per-frame presentation state
125 */
126
Lloyd Piquef5275482019-01-29 18:42:42 -0800127 // If true, this layer will use the dataspace chosen for the output and
128 // ignore the dataspace value just below
129 bool isColorspaceAgnostic{false};
130
Lloyd Pique0b785d82018-12-04 17:25:27 -0800131 // The dataspace for this layer
132 ui::Dataspace dataspace{ui::Dataspace::UNKNOWN};
133
134 // The metadata for this layer
135 HdrMetadata hdrMetadata;
136
137 // The color transform
138 mat4 colorTransform;
Lloyd Piquef5275482019-01-29 18:42:42 -0800139 bool colorTransformIsIdentity{true};
Lloyd Pique688abd42019-02-15 15:42:24 -0800140
Lloyd Pique688abd42019-02-15 15:42:24 -0800141 // True if the layer has protected content
142 bool hasProtectedContent{false};
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800143
144 /*
145 * Cursor state
146 */
147
148 // The output-independent frame for the cursor
149 Rect cursorFrame;
Lloyd Pique9755fb72019-03-26 14:44:40 -0700150
151 // Debugging
152 void dump(std::string& out) const;
Lloyd Pique0b785d82018-12-04 17:25:27 -0800153};
154
155} // namespace android::compositionengine