blob: a63779626748062581a1ab52dade8a65a6905076 [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
Alec Mouri6e57f682018-09-29 20:45:08 -070043 // Maximum luminance pulled from the display's HDR capabilities.
Alec Mouri1089aed2018-10-25 21:33:57 -070044 float maxLuminance = 1.0f;
Alec Mouri6e57f682018-09-29 20:45:08 -070045
46 // Output dataspace that will be populated if wide color gamut is used, or
47 // DataSpace::UNKNOWN otherwise.
Alec Mouri1441bf72018-12-03 19:55:28 -080048 ui::Dataspace outputDataspace = ui::Dataspace::UNKNOWN;
Alec Mouri6e57f682018-09-29 20:45:08 -070049
Alec Mourib34f0b72020-10-02 13:18:34 -070050 // Additional color transform to apply after transforming to the output
51 // dataspace, in non-linear space.
Alec Mouri1441bf72018-12-03 19:55:28 -080052 mat4 colorTransform = mat4();
Alec Mouri6e57f682018-09-29 20:45:08 -070053
Alec Mouriac335532018-11-12 15:01:33 -080054 // Region that will be cleared to (0, 0, 0, 1) prior to rendering.
Alec Mourid4bf7952020-04-06 20:28:16 -070055 // This is specified in layer-stack space.
Alec Mouri1441bf72018-12-03 19:55:28 -080056 Region clearRegion = Region::INVALID_REGION;
Peiyong Linb1925962019-04-01 16:37:10 -070057
Alec Mouri5a6d8572020-03-23 23:56:15 -070058 // 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.
Peiyong Linb1925962019-04-01 16:37:10 -070062 uint32_t orientation = ui::Transform::ROT_0;
Alec Mouri6e57f682018-09-29 20:45:08 -070063};
64
Lloyd Pique6818fa52019-12-03 12:32:13 -080065static inline bool operator==(const DisplaySettings& lhs, const DisplaySettings& rhs) {
66 return lhs.physicalDisplay == rhs.physicalDisplay && lhs.clip == rhs.clip &&
Alec Mourid4bf7952020-04-06 20:28:16 -070067 lhs.maxLuminance == rhs.maxLuminance && lhs.outputDataspace == rhs.outputDataspace &&
Lloyd Pique6818fa52019-12-03 12:32:13 -080068 lhs.colorTransform == rhs.colorTransform &&
69 lhs.clearRegion.hasSameRects(rhs.clearRegion) && lhs.orientation == rhs.orientation;
70}
71
72// Defining PrintTo helps with Google Tests.
73static 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);
Lloyd Pique6818fa52019-12-03 12:32:13 -080079 *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
Alec Mouri6e57f682018-09-29 20:45:08 -070089} // namespace renderengine
90} // namespace android