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 // True if this display should be considered protected, as in this display should render DRM 46 // content. 47 bool isProtected = false; 48 49 // Optional pointer to the power advisor interface, if one is needed for 50 // this display. 51 Hwc2::PowerAdvisor* powerAdvisor = nullptr; 52 53 // Debugging. Human readable name for the display. 54 std::string name; 55 }; 56 57 /** 58 * A helper for setting up a DisplayCreationArgs value in-line. 59 * Prefer this builder over raw structure initialization. 60 */ 61 class DisplayCreationArgsBuilder { 62 public: build()63 DisplayCreationArgs build() { return std::move(mArgs); } 64 setId(DisplayId id)65 DisplayCreationArgsBuilder& setId(DisplayId id) { 66 mArgs.id = id; 67 return *this; 68 } 69 setPixels(ui::Size pixels)70 DisplayCreationArgsBuilder& setPixels(ui::Size pixels) { 71 mArgs.pixels = pixels; 72 return *this; 73 } 74 setIsSecure(bool isSecure)75 DisplayCreationArgsBuilder& setIsSecure(bool isSecure) { 76 mArgs.isSecure = isSecure; 77 return *this; 78 } 79 setIsProtected(bool isProtected)80 DisplayCreationArgsBuilder& setIsProtected(bool isProtected) { 81 mArgs.isProtected = isProtected; 82 return *this; 83 } 84 setPowerAdvisor(Hwc2::PowerAdvisor * powerAdvisor)85 DisplayCreationArgsBuilder& setPowerAdvisor(Hwc2::PowerAdvisor* powerAdvisor) { 86 mArgs.powerAdvisor = powerAdvisor; 87 return *this; 88 } 89 setName(std::string name)90 DisplayCreationArgsBuilder& setName(std::string name) { 91 mArgs.name = std::move(name); 92 return *this; 93 } 94 95 private: 96 DisplayCreationArgs mArgs; 97 }; 98 99 } // namespace android::compositionengine 100