1 /*
2 * Copyright 2023 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
21 #include <ftl/flags.h>
22 #include <ui/DisplayId.h>
23 #include <ui/DisplayMap.h>
24
25 namespace android {
26
27 // Whether composition was covered by HWC and/or GPU.
28 enum class CompositionCoverage : std::uint8_t {
29 Hwc = 1 << 0,
30
31 // Mutually exclusive: The composition either used the GPU, or reused a buffer that had been
32 // composited on the GPU.
33 Gpu = 1 << 1,
34 GpuReuse = 1 << 2,
35 };
36
37 using CompositionCoverageFlags = ftl::Flags<CompositionCoverage>;
38
39 using CompositionCoveragePerDisplay = ui::DisplayMap<DisplayId, CompositionCoverageFlags>;
40
multiDisplayUnion(const CompositionCoveragePerDisplay & displays)41 inline CompositionCoverageFlags multiDisplayUnion(const CompositionCoveragePerDisplay& displays) {
42 CompositionCoverageFlags coverage;
43 for (const auto& [id, flags] : displays) {
44 coverage |= flags;
45 }
46 return coverage;
47 }
48
49 } // namespace android
50