Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 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 | |
Lloyd Pique | 6818fa5 | 2019-12-03 12:32:13 -0800 | [diff] [blame] | 19 | #include <iosfwd> |
| 20 | |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 21 | #include <math/mat4.h> |
| 22 | #include <ui/GraphicTypes.h> |
| 23 | #include <ui/Rect.h> |
| 24 | #include <ui/Region.h> |
Peiyong Lin | b192596 | 2019-04-01 16:37:10 -0700 | [diff] [blame] | 25 | #include <ui/Transform.h> |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 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. |
Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 35 | Rect physicalDisplay = Rect::INVALID_RECT; |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 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. |
Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 41 | Rect clip = Rect::INVALID_RECT; |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 42 | |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 43 | // Maximum luminance pulled from the display's HDR capabilities. |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 44 | float maxLuminance = 1.0f; |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 45 | |
| 46 | // Output dataspace that will be populated if wide color gamut is used, or |
| 47 | // DataSpace::UNKNOWN otherwise. |
Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 48 | ui::Dataspace outputDataspace = ui::Dataspace::UNKNOWN; |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 49 | |
Alec Mouri | b34f0b7 | 2020-10-02 13:18:34 -0700 | [diff] [blame] | 50 | // Additional color transform to apply after transforming to the output |
| 51 | // dataspace, in non-linear space. |
Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 52 | mat4 colorTransform = mat4(); |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 53 | |
Alec Mouri | ac33553 | 2018-11-12 15:01:33 -0800 | [diff] [blame] | 54 | // Region that will be cleared to (0, 0, 0, 1) prior to rendering. |
Alec Mouri | d4bf795 | 2020-04-06 20:28:16 -0700 | [diff] [blame] | 55 | // This is specified in layer-stack space. |
Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 56 | Region clearRegion = Region::INVALID_REGION; |
Peiyong Lin | b192596 | 2019-04-01 16:37:10 -0700 | [diff] [blame] | 57 | |
Alec Mouri | 5a6d857 | 2020-03-23 23:56:15 -0700 | [diff] [blame] | 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. |
Peiyong Lin | b192596 | 2019-04-01 16:37:10 -0700 | [diff] [blame] | 62 | uint32_t orientation = ui::Transform::ROT_0; |
John Reck | ac09e45 | 2021-04-07 16:35:37 -0400 | [diff] [blame^] | 63 | |
| 64 | // SDR white point, -1f if unknown |
| 65 | float sdrWhitePointNits = -1.f; |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
Lloyd Pique | 6818fa5 | 2019-12-03 12:32:13 -0800 | [diff] [blame] | 68 | static inline bool operator==(const DisplaySettings& lhs, const DisplaySettings& rhs) { |
| 69 | return lhs.physicalDisplay == rhs.physicalDisplay && lhs.clip == rhs.clip && |
Alec Mouri | d4bf795 | 2020-04-06 20:28:16 -0700 | [diff] [blame] | 70 | lhs.maxLuminance == rhs.maxLuminance && lhs.outputDataspace == rhs.outputDataspace && |
Lloyd Pique | 6818fa5 | 2019-12-03 12:32:13 -0800 | [diff] [blame] | 71 | lhs.colorTransform == rhs.colorTransform && |
| 72 | lhs.clearRegion.hasSameRects(rhs.clearRegion) && lhs.orientation == rhs.orientation; |
| 73 | } |
| 74 | |
| 75 | // Defining PrintTo helps with Google Tests. |
| 76 | static inline void PrintTo(const DisplaySettings& settings, ::std::ostream* os) { |
| 77 | *os << "DisplaySettings {"; |
| 78 | *os << "\n .physicalDisplay = "; |
| 79 | PrintTo(settings.physicalDisplay, os); |
| 80 | *os << "\n .clip = "; |
| 81 | PrintTo(settings.clip, os); |
Lloyd Pique | 6818fa5 | 2019-12-03 12:32:13 -0800 | [diff] [blame] | 82 | *os << "\n .maxLuminance = " << settings.maxLuminance; |
| 83 | *os << "\n .outputDataspace = "; |
| 84 | PrintTo(settings.outputDataspace, os); |
| 85 | *os << "\n .colorTransform = " << settings.colorTransform; |
| 86 | *os << "\n .clearRegion = "; |
| 87 | PrintTo(settings.clearRegion, os); |
| 88 | *os << "\n .orientation = " << settings.orientation; |
| 89 | *os << "\n}"; |
| 90 | } |
| 91 | |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 92 | } // namespace renderengine |
| 93 | } // namespace android |