• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>
21 #include <string>
22 
23 #include <ui/DisplayId.h>
24 #include <ui/Size.h>
25 #include <ui/StaticDisplayInfo.h>
26 
27 #include "DisplayHardware/PowerAdvisor.h"
28 
29 namespace android::compositionengine {
30 
31 class CompositionEngine;
32 
33 /**
34  * A parameter object for creating Display instances
35  */
36 struct DisplayCreationArgs {
37     DisplayId id;
38 
39     // Size of the display in pixels
40     ui::Size pixels = ui::kInvalidSize;
41 
42     // True if this display should be considered secure
43     bool isSecure = false;
44 
45     // Optional pointer to the power advisor interface, if one is needed for
46     // this display.
47     Hwc2::PowerAdvisor* powerAdvisor = nullptr;
48 
49     // Debugging. Human readable name for the display.
50     std::string name;
51 };
52 
53 /**
54  * A helper for setting up a DisplayCreationArgs value in-line.
55  * Prefer this builder over raw structure initialization.
56  */
57 class DisplayCreationArgsBuilder {
58 public:
build()59     DisplayCreationArgs build() { return std::move(mArgs); }
60 
setId(DisplayId id)61     DisplayCreationArgsBuilder& setId(DisplayId id) {
62         mArgs.id = id;
63         return *this;
64     }
65 
setPixels(ui::Size pixels)66     DisplayCreationArgsBuilder& setPixels(ui::Size pixels) {
67         mArgs.pixels = pixels;
68         return *this;
69     }
70 
setIsSecure(bool isSecure)71     DisplayCreationArgsBuilder& setIsSecure(bool isSecure) {
72         mArgs.isSecure = isSecure;
73         return *this;
74     }
75 
setPowerAdvisor(Hwc2::PowerAdvisor * powerAdvisor)76     DisplayCreationArgsBuilder& setPowerAdvisor(Hwc2::PowerAdvisor* powerAdvisor) {
77         mArgs.powerAdvisor = powerAdvisor;
78         return *this;
79     }
80 
setName(std::string name)81     DisplayCreationArgsBuilder& setName(std::string name) {
82         mArgs.name = std::move(name);
83         return *this;
84     }
85 
86 private:
87     DisplayCreationArgs mArgs;
88 };
89 
90 } // namespace android::compositionengine
91