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 <unordered_map> 21 #include <vector> 22 23 // TODO(b/129481165): remove the #pragma below and fix conversion issues 24 #pragma clang diagnostic push 25 #pragma clang diagnostic ignored "-Wconversion" 26 #pragma clang diagnostic ignored "-Wextra" 27 28 #include <ui/GraphicTypes.h> 29 30 // TODO(b/129481165): remove the #pragma below and fix conversion issues 31 #pragma clang diagnostic pop // ignored "-Wconversion -Wextra" 32 33 #include <ui/HdrCapabilities.h> 34 35 namespace android::compositionengine { 36 37 /** 38 * A parameter object for creating DisplayColorProfile instances 39 */ 40 struct DisplayColorProfileCreationArgs { 41 using HwcColorModes = std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>; 42 43 // True if this display supports a wide color gamut 44 bool hasWideColorGamut; 45 46 // The HDR capabilities supported by the HWC 47 HdrCapabilities hdrCapabilities; 48 49 // The per-frame metadata supported by the HWC 50 int32_t supportedPerFrameMetadata; 51 52 // The mapping of color modes and render intents supported by the HWC 53 HwcColorModes hwcColorModes; 54 }; 55 56 /** 57 * A helper for setting up a DisplayColorProfileCreationArgs value in-line. 58 * 59 * Prefer this builder over raw structure initialization. 60 * 61 * Instead of: 62 * 63 * DisplayColorProfileCreationArgs{false, HdrCapabilities(), 0, 64 * HwcColorModes()} 65 * 66 * Prefer: 67 * 68 * DisplayColorProfileCreationArgsBuilder().setHasWideColorGamut(false) 69 * .setIsVirtual(false).setDisplayId(displayId).Build(); 70 */ 71 class DisplayColorProfileCreationArgsBuilder { 72 public: Build()73 DisplayColorProfileCreationArgs Build() { return std::move(mArgs); } 74 setHasWideColorGamut(bool hasWideColorGamut)75 DisplayColorProfileCreationArgsBuilder& setHasWideColorGamut(bool hasWideColorGamut) { 76 mArgs.hasWideColorGamut = hasWideColorGamut; 77 return *this; 78 } setHdrCapabilities(HdrCapabilities && hdrCapabilities)79 DisplayColorProfileCreationArgsBuilder& setHdrCapabilities(HdrCapabilities&& hdrCapabilities) { 80 mArgs.hdrCapabilities = std::move(hdrCapabilities); 81 return *this; 82 } setSupportedPerFrameMetadata(int32_t supportedPerFrameMetadata)83 DisplayColorProfileCreationArgsBuilder& setSupportedPerFrameMetadata( 84 int32_t supportedPerFrameMetadata) { 85 mArgs.supportedPerFrameMetadata = supportedPerFrameMetadata; 86 return *this; 87 } setHwcColorModes(DisplayColorProfileCreationArgs::HwcColorModes && hwcColorModes)88 DisplayColorProfileCreationArgsBuilder& setHwcColorModes( 89 DisplayColorProfileCreationArgs::HwcColorModes&& hwcColorModes) { 90 mArgs.hwcColorModes = std::move(hwcColorModes); 91 return *this; 92 } 93 94 private: 95 DisplayColorProfileCreationArgs mArgs; 96 }; 97 98 } // namespace android::compositionengine 99