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 22 #include "DisplayHardware/DisplayIdentification.h" 23 24 namespace android::compositionengine { 25 26 class CompositionEngine; 27 28 /** 29 * A parameter object for creating Display instances 30 */ 31 struct DisplayCreationArgs { 32 // True if this display is secure 33 bool isSecure = false; 34 35 // True if this display is a virtual display 36 bool isVirtual = false; 37 38 // Identifies the display to the HWC, if composition is supported by it 39 std::optional<DisplayId> displayId; 40 }; 41 42 /** 43 * A helper for setting up a DisplayCreationArgs value in-line. 44 * Prefer this builder over raw structure initialization. 45 * 46 * Instead of: 47 * 48 * DisplayCreationArgs{false, false, displayId} 49 * 50 * Prefer: 51 * 52 * DisplayCreationArgsBuilder().setIsSecure(false).setIsVirtual(false) 53 * .setDisplayId(displayId).build(); 54 */ 55 class DisplayCreationArgsBuilder { 56 public: build()57 DisplayCreationArgs build() { return std::move(mArgs); } 58 setIsSecure(bool isSecure)59 DisplayCreationArgsBuilder& setIsSecure(bool isSecure) { 60 mArgs.isSecure = isSecure; 61 return *this; 62 } setIsVirtual(bool isVirtual)63 DisplayCreationArgsBuilder& setIsVirtual(bool isVirtual) { 64 mArgs.isVirtual = isVirtual; 65 return *this; 66 } setDisplayId(std::optional<DisplayId> displayId)67 DisplayCreationArgsBuilder& setDisplayId(std::optional<DisplayId> displayId) { 68 mArgs.displayId = displayId; 69 return *this; 70 } 71 72 private: 73 DisplayCreationArgs mArgs; 74 }; 75 76 } // namespace android::compositionengine 77