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