blob: 40cd3e0c205a7c813d482c133ca9a1cf1eb34b25 [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
Lloyd Pique0b785d82018-12-04 17:25:27 -080021#include <gui/HdrMetadata.h>
22#include <math/mat4.h>
23#include <ui/FloatRect.h>
Lloyd Pique0b785d82018-12-04 17:25:27 -080024#include <ui/Rect.h>
25#include <ui/Region.h>
26#include <ui/Transform.h>
27
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080028// TODO(b/129481165): remove the #pragma below and fix conversion issues
29#pragma clang diagnostic push
30#pragma clang diagnostic ignored "-Wconversion"
31
32#include <gui/BufferQueue.h>
33#include <ui/GraphicBuffer.h>
34#include <ui/GraphicTypes.h>
35
Lloyd Pique0b785d82018-12-04 17:25:27 -080036#include "DisplayHardware/ComposerHal.h"
37
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080038// TODO(b/129481165): remove the #pragma below and fix conversion issues
39#pragma clang diagnostic pop // ignored "-Wconversion"
40
Lloyd Pique0b785d82018-12-04 17:25:27 -080041namespace android::compositionengine {
42
43/*
44 * Used by LayerFE::getCompositionState
45 */
46struct LayerFECompositionState {
Lloyd Piquef5275482019-01-29 18:42:42 -080047 // If set to true, forces client composition on all output layers until
48 // the next geometry change.
49 bool forceClientComposition{false};
Lloyd Pique07e33212018-12-18 16:33:37 -080050
Lloyd Piquec6687342019-03-07 21:34:57 -080051 // TODO(b/121291683): Reorganize and rename the contents of this structure
52
53 /*
54 * Visibility state
55 */
56 // the layer stack this layer belongs to
57 std::optional<uint32_t> layerStackId;
58
59 // If true, this layer should be only visible on the internal display
60 bool internalOnly{false};
61
62 // If false, this layer should not be considered visible
63 bool isVisible{true};
64
65 // True if the layer is completely opaque
66 bool isOpaque{true};
67
68 // If true, invalidates the entire visible region
69 bool contentDirty{false};
70
71 // The alpha value for this layer
72 float alpha{1.f};
73
Lucas Dupin19c8f0e2019-11-25 17:55:44 -080074 // Background blur in pixels
75 int backgroundBlurRadius{0};
76
Lloyd Piquec6687342019-03-07 21:34:57 -080077 // The transform from layer local coordinates to composition coordinates
78 ui::Transform geomLayerTransform;
79
80 // The inverse of the layer transform
81 ui::Transform geomInverseLayerTransform;
82
83 // The hint from the layer producer as to what portion of the layer is
84 // transparent.
85 Region transparentRegionHint;
86
87 // The blend mode for this layer
88 Hwc2::IComposerClient::BlendMode blendMode{Hwc2::IComposerClient::BlendMode::INVALID};
89
90 // The bounds of the layer in layer local coordinates
91 FloatRect geomLayerBounds;
92
Vishnu Naira483b4a2019-12-12 15:07:52 -080093 // length of the shadow in screen space
94 float shadowRadius;
95
Lloyd Pique0b785d82018-12-04 17:25:27 -080096 /*
Lloyd Piquea83776c2019-01-29 18:42:32 -080097 * Geometry state
98 */
99
100 bool isSecure{false};
101 bool geomUsesSourceCrop{false};
102 bool geomBufferUsesDisplayInverseTransform{false};
103 uint32_t geomBufferTransform{0};
Lloyd Piquea83776c2019-01-29 18:42:32 -0800104 Rect geomBufferSize;
105 Rect geomContentCrop;
106 Rect geomCrop;
Lloyd Pique0b785d82018-12-04 17:25:27 -0800107
108 /*
109 * Extra metadata
110 */
111
112 // The type for this layer
113 int type{0};
114
115 // The appId for this layer
116 int appId{0};
117
118 /*
119 * Per-frame content
120 */
121
122 // The type of composition for this layer
123 Hwc2::IComposerClient::Composition compositionType{Hwc2::IComposerClient::Composition::INVALID};
124
125 // The buffer and related state
126 sp<GraphicBuffer> buffer;
127 int bufferSlot{BufferQueue::INVALID_BUFFER_SLOT};
128 sp<Fence> acquireFence;
129 Region surfaceDamage;
130
131 // The handle to use for a sideband stream for this layer
132 sp<NativeHandle> sidebandStream;
133
134 // The color for this layer
Lloyd Piquef5275482019-01-29 18:42:42 -0800135 half4 color;
Lloyd Pique0b785d82018-12-04 17:25:27 -0800136
137 /*
138 * Per-frame presentation state
139 */
140
Lloyd Piquef5275482019-01-29 18:42:42 -0800141 // If true, this layer will use the dataspace chosen for the output and
142 // ignore the dataspace value just below
143 bool isColorspaceAgnostic{false};
144
Lloyd Pique0b785d82018-12-04 17:25:27 -0800145 // The dataspace for this layer
146 ui::Dataspace dataspace{ui::Dataspace::UNKNOWN};
147
148 // The metadata for this layer
149 HdrMetadata hdrMetadata;
150
151 // The color transform
152 mat4 colorTransform;
Lloyd Piquef5275482019-01-29 18:42:42 -0800153 bool colorTransformIsIdentity{true};
Lloyd Pique688abd42019-02-15 15:42:24 -0800154
Lloyd Pique688abd42019-02-15 15:42:24 -0800155 // True if the layer has protected content
156 bool hasProtectedContent{false};
Lloyd Piquec7b0c752019-03-07 20:59:59 -0800157
158 /*
159 * Cursor state
160 */
161
162 // The output-independent frame for the cursor
163 Rect cursorFrame;
Lloyd Pique9755fb72019-03-26 14:44:40 -0700164
Lloyd Piquede196652020-01-22 17:29:58 -0800165 virtual ~LayerFECompositionState();
166
Lloyd Pique9755fb72019-03-26 14:44:40 -0700167 // Debugging
Lloyd Piquede196652020-01-22 17:29:58 -0800168 virtual void dump(std::string& out) const;
Lloyd Pique0b785d82018-12-04 17:25:27 -0800169};
170
171} // namespace android::compositionengine