Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 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 <cstdint> |
| 20 | #include <optional> |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 21 | #include <string> |
| 22 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 23 | #include <ui/DisplayId.h> |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 24 | #include <ui/Size.h> |
Marin Shalamanov | 228f46b | 2021-01-28 21:11:45 +0100 | [diff] [blame] | 25 | #include <ui/StaticDisplayInfo.h> |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 26 | |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 27 | #include "DisplayHardware/PowerAdvisor.h" |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 28 | |
| 29 | namespace android::compositionengine { |
| 30 | |
| 31 | class CompositionEngine; |
| 32 | |
| 33 | /** |
| 34 | * A parameter object for creating Display instances |
| 35 | */ |
| 36 | struct DisplayCreationArgs { |
Dominik Laskowski | 3dce4f4 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 37 | DisplayId id; |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 38 | |
Dominik Laskowski | 3dce4f4 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 39 | // Unset for virtual displays |
| 40 | std::optional<ui::DisplayConnectionType> connectionType; |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 41 | |
| 42 | // Size of the display in pixels |
Dominik Laskowski | 6d043c5 | 2021-03-09 16:15:10 -0800 | [diff] [blame] | 43 | ui::Size pixels = ui::kInvalidSize; |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 44 | |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 45 | // True if this display should be considered secure |
| 46 | bool isSecure = false; |
| 47 | |
| 48 | // Gives the initial layer stack id to be used for the display |
| 49 | uint32_t layerStackId = ~0u; |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 50 | |
| 51 | // Optional pointer to the power advisor interface, if one is needed for |
| 52 | // this display. |
| 53 | Hwc2::PowerAdvisor* powerAdvisor = nullptr; |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 54 | |
| 55 | // Debugging. Human readable name for the display. |
| 56 | std::string name; |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | /** |
| 60 | * A helper for setting up a DisplayCreationArgs value in-line. |
| 61 | * Prefer this builder over raw structure initialization. |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 62 | */ |
| 63 | class DisplayCreationArgsBuilder { |
| 64 | public: |
| 65 | DisplayCreationArgs build() { return std::move(mArgs); } |
| 66 | |
Dominik Laskowski | 3dce4f4 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 67 | DisplayCreationArgsBuilder& setId(DisplayId id) { |
| 68 | mArgs.id = id; |
| 69 | return *this; |
| 70 | } |
| 71 | |
| 72 | DisplayCreationArgsBuilder& setConnectionType(ui::DisplayConnectionType connectionType) { |
| 73 | mArgs.connectionType = connectionType; |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 74 | return *this; |
| 75 | } |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 76 | |
| 77 | DisplayCreationArgsBuilder& setPixels(ui::Size pixels) { |
| 78 | mArgs.pixels = pixels; |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 79 | return *this; |
| 80 | } |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 81 | |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 82 | DisplayCreationArgsBuilder& setIsSecure(bool isSecure) { |
| 83 | mArgs.isSecure = isSecure; |
| 84 | return *this; |
| 85 | } |
| 86 | |
| 87 | DisplayCreationArgsBuilder& setLayerStackId(uint32_t layerStackId) { |
| 88 | mArgs.layerStackId = layerStackId; |
| 89 | return *this; |
| 90 | } |
| 91 | |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 92 | DisplayCreationArgsBuilder& setPowerAdvisor(Hwc2::PowerAdvisor* powerAdvisor) { |
| 93 | mArgs.powerAdvisor = powerAdvisor; |
| 94 | return *this; |
| 95 | } |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 96 | |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 97 | DisplayCreationArgsBuilder& setName(std::string name) { |
| 98 | mArgs.name = std::move(name); |
| 99 | return *this; |
| 100 | } |
| 101 | |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 102 | private: |
| 103 | DisplayCreationArgs mArgs; |
| 104 | }; |
| 105 | |
| 106 | } // namespace android::compositionengine |