OSDN Git Service

Reset cache in case layer z-order has changed.
[android-x86/external-IA-Hardware-Composer.git] / public / hwcrect.h
1 /*
2 // Copyright (c) 2017 Intel Corporation
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 #ifndef PUBLIC_HWCRECT_H_
18 #define PUBLIC_HWCRECT_H_
19
20 #include <stdint.h>
21
22 #include <cstring>
23
24 namespace hwcomposer {
25
26 // Some of the structs are adopted from drm_hwcomposer
27 template <typename TFloat>
28 struct Rect {
29   union {
30     struct {
31       TFloat left, top, right, bottom;
32     };
33     TFloat bounds[4];
34   };
35   typedef TFloat TNum;
36   Rect() {
37     reset();
38   }
39   Rect(TFloat left_, TFloat top_, TFloat right_, TFloat bottom_)
40       : left(left_), top(top_), right(right_), bottom(bottom_) {
41   }
42   template <typename T>
43   Rect(const Rect<T> &rhs) {
44     for (int i = 0; i < 4; i++)
45       bounds[i] = rhs.bounds[i];
46   }
47   template <typename T>
48   Rect<TFloat> &operator=(const Rect<T> &rhs) {
49     for (int i = 0; i < 4; i++)
50       bounds[i] = rhs.bounds[i];
51     return *this;
52   }
53   bool operator==(const Rect &rhs) const {
54     for (int i = 0; i < 4; i++) {
55       if (bounds[i] != rhs.bounds[i])
56         return false;
57     }
58     return true;
59   }
60
61   bool empty() const {
62     for (int i = 0; i < 4; i++) {
63       if (bounds[i] != 0)
64         return false;
65     }
66     return true;
67   }
68
69   void reset() {
70     for (int i = 0; i < 4; i++) {
71       memset(&bounds, 0, sizeof(bounds));
72     }
73   }
74 };
75
76 }  // namespace hwcomposer
77
78 #endif  // PUBLIC_HWCRECT_H_