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 | |
| 43 | // Global transform to apply to all layers. |
Alec Mouri | 5a6d857 | 2020-03-23 23:56:15 -0700 | [diff] [blame^] | 44 | // 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 Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 51 | mat4 globalTransform = mat4(); |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 52 | |
| 53 | // Maximum luminance pulled from the display's HDR capabilities. |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 54 | float maxLuminance = 1.0f; |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 55 | |
| 56 | // Output dataspace that will be populated if wide color gamut is used, or |
| 57 | // DataSpace::UNKNOWN otherwise. |
Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 58 | ui::Dataspace outputDataspace = ui::Dataspace::UNKNOWN; |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 59 | |
| 60 | // Additional color transform to apply in linear space after transforming |
| 61 | // to the output dataspace. |
Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 62 | mat4 colorTransform = mat4(); |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 63 | |
Alec Mouri | ac33553 | 2018-11-12 15:01:33 -0800 | [diff] [blame] | 64 | // 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 Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 68 | Region clearRegion = Region::INVALID_REGION; |
Peiyong Lin | b192596 | 2019-04-01 16:37:10 -0700 | [diff] [blame] | 69 | |
Alec Mouri | 5a6d857 | 2020-03-23 23:56:15 -0700 | [diff] [blame^] | 70 | // 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 Lin | b192596 | 2019-04-01 16:37:10 -0700 | [diff] [blame] | 74 | uint32_t orientation = ui::Transform::ROT_0; |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Lloyd Pique | 6818fa5 | 2019-12-03 12:32:13 -0800 | [diff] [blame] | 77 | static 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. |
| 86 | static 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 Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 103 | } // namespace renderengine |
| 104 | } // namespace android |