blob: 3dbd25e1731fefcf533ef9d15b4567aa56cace8e [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
Lucas Dupin19c8f0e2019-11-25 17:55:44 -080066 // Background blur in pixels
67 int backgroundBlurRadius{0};
68
Lloyd Piquec6687342019-03-07 21:34:57 -080069 // The transform from layer local coordinates to composition coordinates
70 ui::Transform geomLayerTransform;
71
72 // The inverse of the layer transform
73 ui::Transform geomInverseLayerTransform;
74
75 // The hint from the layer producer as to what portion of the layer is
76 // transparent.
77 Region transparentRegionHint;
78
79 // The blend mode for this layer
80 Hwc2::IComposerClient::BlendMode blendMode{Hwc2::IComposerClient::BlendMode::INVALID};
81
82 // The bounds of the layer in layer local coordinates
83 FloatRect geomLayerBounds;
84
Vishnu Naira483b4a2019-12-12 15:07:52 -080085 // length of the shadow in screen space
86 float shadowRadius;
87
Lloyd Pique0b785d82018-12-04 17:25:27 -080088 /*
Lloyd Piquea83776c2019-01-29 18:42:32 -080089 * Geometry state
90 */
91
92 bool isSecure{false};
93 bool geomUsesSourceCrop{false};
94 bool geomBufferUsesDisplayInverseTransform{false};
95 uint32_t geomBufferTransform{0};
Lloyd Piquea83776c2019-01-29 18:42:32 -080096 Rect geomBufferSize;
97 Rect geomContentCrop;
98 Rect geomCrop;
Lloyd Pique0b785d82018-12-04 17:25:27 -080099
100 /*
101 * Extra metadata
102 */
103
104 // The type for this layer
105 int type{0};
106
107 // The appId for this layer
108 int appId{0};
109
110 /*
111 * Per-frame content
112 */
113
114 // The type of composition for this layer
115 Hwc2::IComposerClient::Composition compositionType{Hwc2::IComposerClient::Composition::INVALID};
116
117 // The buffer and related state
118 sp<GraphicBuffer> buffer;
119 int bufferSlot{BufferQueue::INVALID_BUFFER_SLOT};
120 sp<Fence> acquireFence;
121 Region surfaceDamage;
122
123 // The handle to use for a sideband stream for this layer
124 sp<NativeHandle> sidebandStream;
125
126 // The color for this layer
Lloyd Piquef5275482019-01-29 18:42:42 -0800127 half4 color;
Lloyd Pique0b785d82018-12-04 17:25:27 -0800128
129 /*
130 * Per-frame presentation state
131 */
132
Lloyd Piquef5275482019-01-29 18:42:42 -0800133 // If true, this layer will use the dataspace chosen for the output and
134 // ignore the dataspace value just below
135 bool isColorspaceAgnostic{false};
136
Lloyd Pique0b785d82018-12-04 17:25:27 -0800137 // The dataspace for this layer
138 ui::Dataspace dataspace{ui::Dataspace::UNKNOWN};
139
140 // The metadata for this layer
141 HdrMetadata hdrMetadata;
142
143 // The color transform
144 mat4 colorTransform;
Lloyd Piquef5275482019-01-29 18:42:42 -0800145 bool colorTransformIsIdentity{true};
Lloyd Pique688abd42019-02-15 15:42:24 -0800146
Lloyd Pique688abd42019-02-15 15:42:24 -0800147 // True if the layer has protected content
148 bool hasProtectedContent{false};
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800149
150 /*
151 * Cursor state
152 */
153
154 // The output-independent frame for the cursor
155 Rect cursorFrame;
Lloyd Pique9755fb72019-03-26 14:44:40 -0700156
157 // Debugging
158 void dump(std::string& out) const;
Lloyd Pique0b785d82018-12-04 17:25:27 -0800159};
160
161} // namespace android::compositionengine