OSDN Git Service

Fix MosaicDisplay.
[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 namespace hwcomposer {
23
24 // Some of the structs are adopted from drm_hwcomposer
25 template <typename TFloat>
26 struct Rect {
27   union {
28     struct {
29       TFloat left, top, right, bottom;
30     };
31     TFloat bounds[4];
32   };
33   typedef TFloat TNum;
34   Rect() {
35   }
36   Rect(TFloat left_, TFloat top_, TFloat right_, TFloat bottom_)
37       : left(left_), top(top_), right(right_), bottom(bottom_) {
38   }
39   template <typename T>
40   Rect(const Rect<T> &rhs) {
41     for (int i = 0; i < 4; i++)
42       bounds[i] = rhs.bounds[i];
43   }
44   template <typename T>
45   Rect<TFloat> &operator=(const Rect<T> &rhs) {
46     for (int i = 0; i < 4; i++)
47       bounds[i] = rhs.bounds[i];
48     return *this;
49   }
50   bool operator==(const Rect &rhs) const {
51     for (int i = 0; i < 4; i++) {
52       if (bounds[i] != rhs.bounds[i])
53         return false;
54     }
55     return true;
56   }
57
58   bool empty() const {
59     for (int i = 0; i < 4; i++) {
60       if (bounds[i] != 0)
61         return false;
62     }
63     return true;
64   }
65 };
66
67 }  // namespace hwcomposer
68
69 #endif  // PUBLIC_HWCRECT_H_