blob: 526e7daa801f4dc6a2a486b77b212edb1fe0ffd5 [file] [log] [blame]
Lloyd Pique45a165a2018-10-19 11:54:47 -07001/*
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 Pique9370a482019-10-03 17:58:30 -070021#include <string>
22
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020023#include <ui/DisplayId.h>
Lloyd Pique9370a482019-10-03 17:58:30 -070024#include <ui/Size.h>
Marin Shalamanov228f46b2021-01-28 21:11:45 +010025#include <ui/StaticDisplayInfo.h>
Lloyd Pique45a165a2018-10-19 11:54:47 -070026
Lloyd Pique688abd42019-02-15 15:42:24 -080027#include "DisplayHardware/PowerAdvisor.h"
Lloyd Pique45a165a2018-10-19 11:54:47 -070028
29namespace android::compositionengine {
30
31class CompositionEngine;
32
33/**
34 * A parameter object for creating Display instances
35 */
36struct DisplayCreationArgs {
Dominik Laskowski3dce4f42021-03-08 20:48:28 -080037 DisplayId id;
Lloyd Pique45a165a2018-10-19 11:54:47 -070038
Dominik Laskowski3dce4f42021-03-08 20:48:28 -080039 // Unset for virtual displays
40 std::optional<ui::DisplayConnectionType> connectionType;
Lloyd Pique9370a482019-10-03 17:58:30 -070041
42 // Size of the display in pixels
Dominik Laskowski6d043c52021-03-09 16:15:10 -080043 ui::Size pixels = ui::kInvalidSize;
Lloyd Pique9370a482019-10-03 17:58:30 -070044
Lloyd Pique9370a482019-10-03 17:58:30 -070045 // 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 Pique688abd42019-02-15 15:42:24 -080050
51 // Optional pointer to the power advisor interface, if one is needed for
52 // this display.
53 Hwc2::PowerAdvisor* powerAdvisor = nullptr;
Lloyd Pique9370a482019-10-03 17:58:30 -070054
55 // Debugging. Human readable name for the display.
56 std::string name;
Lloyd Pique45a165a2018-10-19 11:54:47 -070057};
58
59/**
60 * A helper for setting up a DisplayCreationArgs value in-line.
61 * Prefer this builder over raw structure initialization.
Lloyd Pique45a165a2018-10-19 11:54:47 -070062 */
63class DisplayCreationArgsBuilder {
64public:
65 DisplayCreationArgs build() { return std::move(mArgs); }
66
Dominik Laskowski3dce4f42021-03-08 20:48:28 -080067 DisplayCreationArgsBuilder& setId(DisplayId id) {
68 mArgs.id = id;
69 return *this;
70 }
71
72 DisplayCreationArgsBuilder& setConnectionType(ui::DisplayConnectionType connectionType) {
73 mArgs.connectionType = connectionType;
Lloyd Pique45a165a2018-10-19 11:54:47 -070074 return *this;
75 }
Lloyd Pique9370a482019-10-03 17:58:30 -070076
77 DisplayCreationArgsBuilder& setPixels(ui::Size pixels) {
78 mArgs.pixels = pixels;
Lloyd Pique45a165a2018-10-19 11:54:47 -070079 return *this;
80 }
Lloyd Pique9370a482019-10-03 17:58:30 -070081
Lloyd Pique9370a482019-10-03 17:58:30 -070082 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 Pique688abd42019-02-15 15:42:24 -080092 DisplayCreationArgsBuilder& setPowerAdvisor(Hwc2::PowerAdvisor* powerAdvisor) {
93 mArgs.powerAdvisor = powerAdvisor;
94 return *this;
95 }
Lloyd Pique45a165a2018-10-19 11:54:47 -070096
Lloyd Pique9370a482019-10-03 17:58:30 -070097 DisplayCreationArgsBuilder& setName(std::string name) {
98 mArgs.name = std::move(name);
99 return *this;
100 }
101
Lloyd Pique45a165a2018-10-19 11:54:47 -0700102private:
103 DisplayCreationArgs mArgs;
104};
105
106} // namespace android::compositionengine