blob: c0766ab5b31295609b6b058897d424cfc1e25f0f [file] [log] [blame]
Alec Mouri6e57f682018-09-29 20:45:08 -07001/*
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
Lloyd Pique6818fa52019-12-03 12:32:13 -080019#include <iosfwd>
20
Alec Mouri6e57f682018-09-29 20:45:08 -070021#include <math/mat4.h>
22#include <ui/GraphicTypes.h>
23#include <ui/Rect.h>
24#include <ui/Region.h>
Peiyong Linb1925962019-04-01 16:37:10 -070025#include <ui/Transform.h>
Alec Mouri6e57f682018-09-29 20:45:08 -070026
27namespace android {
28namespace renderengine {
29
30// DisplaySettings contains the settings that are applicable when drawing all
31// layers for a given display.
32struct DisplaySettings {
33 // Rectangle describing the physical display. We will project from the
34 // logical clip onto this rectangle.
Alec Mouri1441bf72018-12-03 19:55:28 -080035 Rect physicalDisplay = Rect::INVALID_RECT;
Alec Mouri6e57f682018-09-29 20:45:08 -070036
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.
Alec Mouri1441bf72018-12-03 19:55:28 -080041 Rect clip = Rect::INVALID_RECT;
Alec Mouri6e57f682018-09-29 20:45:08 -070042
43 // Global transform to apply to all layers.
Alec Mouri5a6d8572020-03-23 23:56:15 -070044 // The global transform is assumed to automatically apply when projecting
45 // the clip rectangle onto the physical display; however, this should be
46 // explicitly provided to perform CPU-side optimizations such as computing
47 // scissor rectangles for rounded corners which require transformation to
48 // the phsical display space.
49 //
50 // This transform is also assumed to include the orientation flag below.
Alec Mouri1441bf72018-12-03 19:55:28 -080051 mat4 globalTransform = mat4();
Alec Mouri6e57f682018-09-29 20:45:08 -070052
53 // Maximum luminance pulled from the display's HDR capabilities.
Alec Mouri1089aed2018-10-25 21:33:57 -070054 float maxLuminance = 1.0f;
Alec Mouri6e57f682018-09-29 20:45:08 -070055
56 // Output dataspace that will be populated if wide color gamut is used, or
57 // DataSpace::UNKNOWN otherwise.
Alec Mouri1441bf72018-12-03 19:55:28 -080058 ui::Dataspace outputDataspace = ui::Dataspace::UNKNOWN;
Alec Mouri6e57f682018-09-29 20:45:08 -070059
60 // Additional color transform to apply in linear space after transforming
61 // to the output dataspace.
Alec Mouri1441bf72018-12-03 19:55:28 -080062 mat4 colorTransform = mat4();
Alec Mouri6e57f682018-09-29 20:45:08 -070063
Alec Mouriac335532018-11-12 15:01:33 -080064 // Region that will be cleared to (0, 0, 0, 1) prior to rendering.
65 // RenderEngine will transform the clearRegion passed in here, by
66 // globalTransform, so that it will be in the same coordinate space as the
67 // rendered layers.
Alec Mouri1441bf72018-12-03 19:55:28 -080068 Region clearRegion = Region::INVALID_REGION;
Peiyong Linb1925962019-04-01 16:37:10 -070069
Alec Mouri5a6d8572020-03-23 23:56:15 -070070 // An additional orientation flag to be applied after clipping the output.
71 // By way of example, this may be used for supporting fullscreen screenshot
72 // capture of a device in landscape while the buffer is in portrait
73 // orientation.
Peiyong Linb1925962019-04-01 16:37:10 -070074 uint32_t orientation = ui::Transform::ROT_0;
Alec Mouri6e57f682018-09-29 20:45:08 -070075};
76
Lloyd Pique6818fa52019-12-03 12:32:13 -080077static inline bool operator==(const DisplaySettings& lhs, const DisplaySettings& rhs) {
78 return lhs.physicalDisplay == rhs.physicalDisplay && lhs.clip == rhs.clip &&
79 lhs.globalTransform == rhs.globalTransform && lhs.maxLuminance == rhs.maxLuminance &&
80 lhs.outputDataspace == rhs.outputDataspace &&
81 lhs.colorTransform == rhs.colorTransform &&
82 lhs.clearRegion.hasSameRects(rhs.clearRegion) && lhs.orientation == rhs.orientation;
83}
84
85// Defining PrintTo helps with Google Tests.
86static inline void PrintTo(const DisplaySettings& settings, ::std::ostream* os) {
87 *os << "DisplaySettings {";
88 *os << "\n .physicalDisplay = ";
89 PrintTo(settings.physicalDisplay, os);
90 *os << "\n .clip = ";
91 PrintTo(settings.clip, os);
92 *os << "\n .globalTransform = " << settings.globalTransform;
93 *os << "\n .maxLuminance = " << settings.maxLuminance;
94 *os << "\n .outputDataspace = ";
95 PrintTo(settings.outputDataspace, os);
96 *os << "\n .colorTransform = " << settings.colorTransform;
97 *os << "\n .clearRegion = ";
98 PrintTo(settings.clearRegion, os);
99 *os << "\n .orientation = " << settings.orientation;
100 *os << "\n}";
101}
102
Alec Mouri6e57f682018-09-29 20:45:08 -0700103} // namespace renderengine
104} // namespace android