1 /*
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 <math/mat4.h>
22 #include <ui/GraphicTypes.h>
23 #include <ui/Rect.h>
24 #include <ui/Region.h>
25 #include <ui/Transform.h>
26 
27 namespace android {
28 
29 namespace compositionengine::impl {
30 
31 struct OutputCompositionState {
32     // If false, composition will not per performed for this display
33     bool isEnabled{false};
34 
35     // If false, this output is not considered secure
36     bool isSecure{false};
37 
38     // If true, this output displays layers that are internal-only
39     bool layerStackInternal{false};
40 
41     // The layer stack to display on this display
42     uint32_t layerStackId{~0u};
43 
44     // The physical space screen bounds
45     Rect bounds;
46 
47     // The logical to physical transformation to use
48     ui::Transform transform;
49 
50     // The physical orientation of the display, expressed as ui::Transform
51     // orientation flags.
52     uint32_t orientation{0};
53 
54     // The logical space user visible bounds
55     Rect frame;
56 
57     // The logical space user viewport rectangle
58     Rect viewport;
59 
60     // The physical space scissor rectangle
61     Rect scissor;
62 
63     // If true, RenderEngine filtering should be enabled
64     bool needsFiltering{false};
65 
66     // The logical coordinates for the dirty region for the display.
67     // dirtyRegion is semi-persistent state. Dirty rectangles are added to it
68     // by the FE until composition happens, at which point it is cleared.
69     Region dirtyRegion;
70 
71     // The logical coordinates for the undefined region for the display.
72     // The undefined region is internal to the composition engine. It is
73     // updated every time the geometry changes.
74     Region undefinedRegion;
75 
76     // True if the last composition frame had visible layers
77     bool lastCompositionHadVisibleLayers{false};
78 
79     // The color transform to apply
80     android_color_transform_t colorTransform{HAL_COLOR_TRANSFORM_IDENTITY};
81 
82     // The color transform matrix to apply, corresponding with colorTransform.
83     mat4 colorTransformMat;
84 
85     // Current active color mode
86     ui::ColorMode colorMode{ui::ColorMode::NATIVE};
87 
88     // Current active render intent
89     ui::RenderIntent renderIntent{ui::RenderIntent::COLORIMETRIC};
90 
91     // Current active dstaspace
92     ui::Dataspace dataspace{ui::Dataspace::UNKNOWN};
93 
94     // Debugging
95     void dump(std::string& result) const;
96 };
97 
98 } // namespace compositionengine::impl
99 } // namespace android
100