blob: d96d58c1faf434555291df2ea5d14e50c7668271 [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 Pique0b785d82018-12-04 17:25:27 -080043 /*
Lloyd Piquea83776c2019-01-29 18:42:32 -080044 * Geometry state
45 */
46
47 bool isSecure{false};
48 bool geomUsesSourceCrop{false};
49 bool geomBufferUsesDisplayInverseTransform{false};
50 uint32_t geomBufferTransform{0};
51 ui::Transform geomLayerTransform;
52 ui::Transform geomInverseLayerTransform;
53 Rect geomBufferSize;
54 Rect geomContentCrop;
55 Rect geomCrop;
56 Region geomActiveTransparentRegion;
57 FloatRect geomLayerBounds;
58
Lloyd Piquef5275482019-01-29 18:42:42 -080059 // TODO(lpique): b/121291683 Remove this one we are sure we don't need the
60 // value recomputed / set every frame.
61 Region geomVisibleRegion;
62
Lloyd Piquea83776c2019-01-29 18:42:32 -080063 /*
Lloyd Pique0b785d82018-12-04 17:25:27 -080064 * Presentation
65 */
66
67 // The blend mode for this layer
68 Hwc2::IComposerClient::BlendMode blendMode{Hwc2::IComposerClient::BlendMode::INVALID};
69
70 // The alpha value for this layer
71 float alpha{1.f};
72
73 /*
74 * Extra metadata
75 */
76
77 // The type for this layer
78 int type{0};
79
80 // The appId for this layer
81 int appId{0};
82
83 /*
84 * Per-frame content
85 */
86
87 // The type of composition for this layer
88 Hwc2::IComposerClient::Composition compositionType{Hwc2::IComposerClient::Composition::INVALID};
89
90 // The buffer and related state
91 sp<GraphicBuffer> buffer;
92 int bufferSlot{BufferQueue::INVALID_BUFFER_SLOT};
93 sp<Fence> acquireFence;
94 Region surfaceDamage;
95
96 // The handle to use for a sideband stream for this layer
97 sp<NativeHandle> sidebandStream;
98
99 // The color for this layer
Lloyd Piquef5275482019-01-29 18:42:42 -0800100 half4 color;
Lloyd Pique0b785d82018-12-04 17:25:27 -0800101
102 /*
103 * Per-frame presentation state
104 */
105
Lloyd Piquef5275482019-01-29 18:42:42 -0800106 // If true, this layer will use the dataspace chosen for the output and
107 // ignore the dataspace value just below
108 bool isColorspaceAgnostic{false};
109
Lloyd Pique0b785d82018-12-04 17:25:27 -0800110 // The dataspace for this layer
111 ui::Dataspace dataspace{ui::Dataspace::UNKNOWN};
112
113 // The metadata for this layer
114 HdrMetadata hdrMetadata;
115
116 // The color transform
117 mat4 colorTransform;
Lloyd Piquef5275482019-01-29 18:42:42 -0800118 bool colorTransformIsIdentity{true};
Lloyd Pique0b785d82018-12-04 17:25:27 -0800119};
120
121} // namespace android::compositionengine