1 /*
2 * Copyright 2018 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 <iosfwd>
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 namespace renderengine {
29
30 // DisplaySettings contains the settings that are applicable when drawing all
31 // layers for a given display.
32 struct DisplaySettings {
33 // Rectangle describing the physical display. We will project from the
34 // logical clip onto this rectangle.
35 Rect physicalDisplay = Rect::INVALID_RECT;
36
37 // Rectangle bounded by the x,y- clipping planes in the logical display, so
38 // that the orthographic projection matrix can be computed. When
39 // constructing this matrix, z-coordinate bound are assumed to be at z=0 and
40 // z=1.
41 Rect clip = Rect::INVALID_RECT;
42
43 // Maximum luminance pulled from the display's HDR capabilities.
44 float maxLuminance = 1.0f;
45
46 // Output dataspace that will be populated if wide color gamut is used, or
47 // DataSpace::UNKNOWN otherwise.
48 ui::Dataspace outputDataspace = ui::Dataspace::UNKNOWN;
49
50 // Additional color transform to apply in linear space after transforming
51 // to the output dataspace.
52 mat4 colorTransform = mat4();
53
54 // Region that will be cleared to (0, 0, 0, 1) prior to rendering.
55 // This is specified in layer-stack space.
56 Region clearRegion = Region::INVALID_REGION;
57
58 // An additional orientation flag to be applied after clipping the output.
59 // By way of example, this may be used for supporting fullscreen screenshot
60 // capture of a device in landscape while the buffer is in portrait
61 // orientation.
62 uint32_t orientation = ui::Transform::ROT_0;
63 };
64
65 static inline bool operator==(const DisplaySettings& lhs, const DisplaySettings& rhs) {
66 return lhs.physicalDisplay == rhs.physicalDisplay && lhs.clip == rhs.clip &&
67 lhs.maxLuminance == rhs.maxLuminance && lhs.outputDataspace == rhs.outputDataspace &&
68 lhs.colorTransform == rhs.colorTransform &&
69 lhs.clearRegion.hasSameRects(rhs.clearRegion) && lhs.orientation == rhs.orientation;
70 }
71
72 // Defining PrintTo helps with Google Tests.
PrintTo(const DisplaySettings & settings,::std::ostream * os)73 static inline void PrintTo(const DisplaySettings& settings, ::std::ostream* os) {
74 *os << "DisplaySettings {";
75 *os << "\n .physicalDisplay = ";
76 PrintTo(settings.physicalDisplay, os);
77 *os << "\n .clip = ";
78 PrintTo(settings.clip, os);
79 *os << "\n .maxLuminance = " << settings.maxLuminance;
80 *os << "\n .outputDataspace = ";
81 PrintTo(settings.outputDataspace, os);
82 *os << "\n .colorTransform = " << settings.colorTransform;
83 *os << "\n .clearRegion = ";
84 PrintTo(settings.clearRegion, os);
85 *os << "\n .orientation = " << settings.orientation;
86 *os << "\n}";
87 }
88
89 } // namespace renderengine
90 } // namespace android
91