diff options
author | bunnei <bunneidev@gmail.com> | 2021-11-12 03:10:29 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2022-03-25 02:13:32 +0100 |
commit | d47575f2c5b125426e9d81a10bd7ce3d7e813dbf (patch) | |
tree | a26e0cf0c04f34fce107eb3b29e2cf2377f18eec /src/core | |
parent | common: logging: Add a logger for NVFlinger. (diff) | |
download | yuzu-d47575f2c5b125426e9d81a10bd7ce3d7e813dbf.tar yuzu-d47575f2c5b125426e9d81a10bd7ce3d7e813dbf.tar.gz yuzu-d47575f2c5b125426e9d81a10bd7ce3d7e813dbf.tar.bz2 yuzu-d47575f2c5b125426e9d81a10bd7ce3d7e813dbf.tar.lz yuzu-d47575f2c5b125426e9d81a10bd7ce3d7e813dbf.tar.xz yuzu-d47575f2c5b125426e9d81a10bd7ce3d7e813dbf.tar.zst yuzu-d47575f2c5b125426e9d81a10bd7ce3d7e813dbf.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/core/hle/service/nvflinger/ui/rect.h | 75 |
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 hle/service/nvflinger/buffer_queue.h hle/service/nvflinger/nvflinger.cpp hle/service/nvflinger/nvflinger.h + hle/service/nvflinger/ui/rect.h hle/service/olsc/olsc.cpp hle/service/olsc/olsc.h 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 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2021 yuzu Emulator Project +// Copyright 2006 The Android Open Source Project +// Parts of this implementation were base on: +// https://cs.android.com/android/platform/superproject/+/android-5.1.1_r38:frameworks/native/include/ui/Rect.h + +#pragma once + +#include <cstdint> +#include <utility> + +#include "common/common_types.h" + +namespace android { + +class Rect final { +public: + constexpr Rect() = default; + + constexpr Rect(s32 width_, s32 height_) : right{width_}, bottom{height_} {} + + constexpr s32 Left() const { + return left; + } + + constexpr s32 Top() const { + return top; + } + + constexpr s32 Right() const { + return right; + } + + constexpr s32 Bottom() const { + return bottom; + } + + constexpr bool IsEmpty() const { + return (GetWidth() <= 0) || (GetHeight() <= 0); + } + + constexpr s32 GetWidth() const { + return right - left; + } + + constexpr s32 GetHeight() const { + return bottom - top; + } + + constexpr bool operator==(const Rect& rhs) const { + return (left == rhs.left) && (top == rhs.top) && (right == rhs.right) && + (bottom == rhs.bottom); + } + + constexpr bool operator!=(const Rect& rhs) const { + return !operator==(rhs); + } + + constexpr bool Intersect(const Rect& with, Rect* result) const { + result->left = std::max(left, with.left); + result->top = std::max(top, with.top); + result->right = std::min(right, with.right); + result->bottom = std::min(bottom, with.bottom); + return !result->IsEmpty(); + } + +private: + s32 left{}; + s32 top{}; + s32 right{}; + s32 bottom{}; +}; +static_assert(sizeof(Rect) == 16, "Rect has wrong size"); + +} // namespace android |