summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar bunnei2021-11-11 18:10:29 -0800
committerGravatar bunnei2022-03-24 18:13:32 -0700
commitd47575f2c5b125426e9d81a10bd7ce3d7e813dbf (patch)
treea26e0cf0c04f34fce107eb3b29e2cf2377f18eec /src/core
parentcommon: logging: Add a logger for NVFlinger. (diff)
downloadyuzu-d47575f2c5b125426e9d81a10bd7ce3d7e813dbf.tar.gz
yuzu-d47575f2c5b125426e9d81a10bd7ce3d7e813dbf.tar.xz
yuzu-d47575f2c5b125426e9d81a10bd7ce3d7e813dbf.zip
hle: nvflinger: Add implementation for Rect class.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt1
-rw-r--r--src/core/hle/service/nvflinger/ui/rect.h75
2 files changed, 76 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index a6f442316..49a49acdf 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -539,6 +539,7 @@ add_library(core STATIC
539 hle/service/nvflinger/buffer_queue.h 539 hle/service/nvflinger/buffer_queue.h
540 hle/service/nvflinger/nvflinger.cpp 540 hle/service/nvflinger/nvflinger.cpp
541 hle/service/nvflinger/nvflinger.h 541 hle/service/nvflinger/nvflinger.h
542 hle/service/nvflinger/ui/rect.h
542 hle/service/olsc/olsc.cpp 543 hle/service/olsc/olsc.cpp
543 hle/service/olsc/olsc.h 544 hle/service/olsc/olsc.h
544 hle/service/pcie/pcie.cpp 545 hle/service/pcie/pcie.cpp
diff --git a/src/core/hle/service/nvflinger/ui/rect.h b/src/core/hle/service/nvflinger/ui/rect.h
new file mode 100644
index 000000000..847f6f4ae
--- /dev/null
+++ b/src/core/hle/service/nvflinger/ui/rect.h
@@ -0,0 +1,75 @@
1// SPDX-License-Identifier: GPL-3.0-or-later
2// Copyright 2021 yuzu Emulator Project
3// Copyright 2006 The Android Open Source Project
4// Parts of this implementation were base on:
5// https://cs.android.com/android/platform/superproject/+/android-5.1.1_r38:frameworks/native/include/ui/Rect.h
6
7#pragma once
8
9#include <cstdint>
10#include <utility>
11
12#include "common/common_types.h"
13
14namespace android {
15
16class Rect final {
17public:
18 constexpr Rect() = default;
19
20 constexpr Rect(s32 width_, s32 height_) : right{width_}, bottom{height_} {}
21
22 constexpr s32 Left() const {
23 return left;
24 }
25
26 constexpr s32 Top() const {
27 return top;
28 }
29
30 constexpr s32 Right() const {
31 return right;
32 }
33
34 constexpr s32 Bottom() const {
35 return bottom;
36 }
37
38 constexpr bool IsEmpty() const {
39 return (GetWidth() <= 0) || (GetHeight() <= 0);
40 }
41
42 constexpr s32 GetWidth() const {
43 return right - left;
44 }
45
46 constexpr s32 GetHeight() const {
47 return bottom - top;
48 }
49
50 constexpr bool operator==(const Rect& rhs) const {
51 return (left == rhs.left) && (top == rhs.top) && (right == rhs.right) &&
52 (bottom == rhs.bottom);
53 }
54
55 constexpr bool operator!=(const Rect& rhs) const {
56 return !operator==(rhs);
57 }
58
59 constexpr bool Intersect(const Rect& with, Rect* result) const {
60 result->left = std::max(left, with.left);
61 result->top = std::max(top, with.top);
62 result->right = std::min(right, with.right);
63 result->bottom = std::min(bottom, with.bottom);
64 return !result->IsEmpty();
65 }
66
67private:
68 s32 left{};
69 s32 top{};
70 s32 right{};
71 s32 bottom{};
72};
73static_assert(sizeof(Rect) == 16, "Rect has wrong size");
74
75} // namespace android