2 // Copyright (c) 2016 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef COMMON_UTILS_DISJOINT_LAYERS_H_
18 #define COMMON_UTILS_DISJOINT_LAYERS_H_
26 namespace hwcomposer {
28 // Some of the structs are adopted from drm_hwcomposer
33 RectIDs() : bitset(0) {
36 explicit RectIDs(TId id) : bitset(0) {
41 bitset |= ((uint64_t)1) << id;
44 void subtract(TId id) {
45 bitset &= ~(((uint64_t)1) << id);
48 bool isEmpty() const {
52 uint64_t getBits() const {
56 bool operator==(const RectIDs &rhs) const {
57 return bitset == rhs.bitset;
60 bool operator<(const RectIDs &rhs) const {
61 return bitset < rhs.bitset;
64 RectIDs operator|(const RectIDs &rhs) const {
66 ret.bitset = bitset | rhs.bitset;
70 RectIDs operator|(TId id) const {
77 static const int max_elements = sizeof(TId) * 8;
83 template <typename TNum>
88 RectSet(const RectIDs &i, const Rect<TNum> &r) : id_set(i), rect(r) {
91 bool operator==(const RectSet<TNum> &rhs) const {
92 return (id_set == rhs.id_set) && (rect == rhs.rect);
96 void get_draw_regions(const std::vector<Rect<int>> &in,
97 std::vector<RectSet<int>> *out);
98 } // namespace hwcomposer
100 #endif // COMMON_UTILS_DISJOINT_LAYERS_H_