diff options
| author | 2022-03-19 22:47:46 -0700 | |
|---|---|---|
| committer | 2022-03-24 18:13:33 -0700 | |
| commit | 4d9488033f849132446ffb7840f1309fa38be8fd (patch) | |
| tree | a8737261a62a54962acb4957b1a72c2a9e0c3eea /src/core | |
| parent | hle: nvflinger: buffer_queue_core: Declare default dtor. (diff) | |
| download | yuzu-4d9488033f849132446ffb7840f1309fa38be8fd.tar.gz yuzu-4d9488033f849132446ffb7840f1309fa38be8fd.tar.xz yuzu-4d9488033f849132446ffb7840f1309fa38be8fd.zip | |
hle: nvflinger: Merge Rect with Common::Rectangle.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/buffer_item.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/buffer_queue_producer.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/graphic_buffer_producer.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/ui/rect.h | 75 |
5 files changed, 9 insertions, 85 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ff8adfc55..6536d0544 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -563,7 +563,6 @@ add_library(core STATIC | |||
| 563 | hle/service/nvflinger/status.h | 563 | hle/service/nvflinger/status.h |
| 564 | hle/service/nvflinger/ui/fence.h | 564 | hle/service/nvflinger/ui/fence.h |
| 565 | hle/service/nvflinger/ui/graphic_buffer.h | 565 | hle/service/nvflinger/ui/graphic_buffer.h |
| 566 | hle/service/nvflinger/ui/rect.h | ||
| 567 | hle/service/nvflinger/window.h | 566 | hle/service/nvflinger/window.h |
| 568 | hle/service/olsc/olsc.cpp | 567 | hle/service/olsc/olsc.cpp |
| 569 | hle/service/olsc/olsc.h | 568 | hle/service/olsc/olsc.h |
diff --git a/src/core/hle/service/nvflinger/buffer_item.h b/src/core/hle/service/nvflinger/buffer_item.h index d60719065..64b82b851 100644 --- a/src/core/hle/service/nvflinger/buffer_item.h +++ b/src/core/hle/service/nvflinger/buffer_item.h | |||
| @@ -9,8 +9,8 @@ | |||
| 9 | #include <memory> | 9 | #include <memory> |
| 10 | 10 | ||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/math_util.h" | ||
| 12 | #include "core/hle/service/nvflinger/ui/fence.h" | 13 | #include "core/hle/service/nvflinger/ui/fence.h" |
| 13 | #include "core/hle/service/nvflinger/ui/rect.h" | ||
| 14 | #include "core/hle/service/nvflinger/window.h" | 14 | #include "core/hle/service/nvflinger/window.h" |
| 15 | 15 | ||
| 16 | namespace Service::android { | 16 | namespace Service::android { |
| @@ -23,7 +23,7 @@ public: | |||
| 23 | 23 | ||
| 24 | std::shared_ptr<GraphicBuffer> graphic_buffer; | 24 | std::shared_ptr<GraphicBuffer> graphic_buffer; |
| 25 | Fence fence; | 25 | Fence fence; |
| 26 | Rect crop; | 26 | Common::Rectangle<s32> crop; |
| 27 | NativeWindowTransform transform{}; | 27 | NativeWindowTransform transform{}; |
| 28 | u32 scaling_mode{}; | 28 | u32 scaling_mode{}; |
| 29 | s64 timestamp{}; | 29 | s64 timestamp{}; |
diff --git a/src/core/hle/service/nvflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvflinger/buffer_queue_producer.cpp index 99f7ec1ac..5ea48431f 100644 --- a/src/core/hle/service/nvflinger/buffer_queue_producer.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue_producer.cpp | |||
| @@ -441,7 +441,7 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input, | |||
| 441 | QueueBufferOutput* output) { | 441 | QueueBufferOutput* output) { |
| 442 | s64 timestamp{}; | 442 | s64 timestamp{}; |
| 443 | bool is_auto_timestamp{}; | 443 | bool is_auto_timestamp{}; |
| 444 | Rect crop; | 444 | Common::Rectangle<s32> crop; |
| 445 | NativeWindowScalingMode scaling_mode{}; | 445 | NativeWindowScalingMode scaling_mode{}; |
| 446 | NativeWindowTransform transform; | 446 | NativeWindowTransform transform; |
| 447 | u32 sticky_transform_{}; | 447 | u32 sticky_transform_{}; |
| @@ -509,9 +509,9 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input, | |||
| 509 | crop.Bottom(), transform, scaling_mode); | 509 | crop.Bottom(), transform, scaling_mode); |
| 510 | 510 | ||
| 511 | const std::shared_ptr<GraphicBuffer>& graphic_buffer(slots[slot].graphic_buffer); | 511 | const std::shared_ptr<GraphicBuffer>& graphic_buffer(slots[slot].graphic_buffer); |
| 512 | Rect buffer_rect(graphic_buffer->Width(), graphic_buffer->Height()); | 512 | Common::Rectangle<s32> buffer_rect(graphic_buffer->Width(), graphic_buffer->Height()); |
| 513 | Rect cropped_rect; | 513 | Common::Rectangle<s32> cropped_rect; |
| 514 | crop.Intersect(buffer_rect, &cropped_rect); | 514 | [[maybe_unused]] const bool unused = crop.Intersect(buffer_rect, &cropped_rect); |
| 515 | 515 | ||
| 516 | if (cropped_rect != crop) { | 516 | if (cropped_rect != crop) { |
| 517 | LOG_ERROR(Service_NVFlinger, "crop rect is not contained within the buffer in slot {}", | 517 | LOG_ERROR(Service_NVFlinger, "crop rect is not contained within the buffer in slot {}", |
diff --git a/src/core/hle/service/nvflinger/graphic_buffer_producer.h b/src/core/hle/service/nvflinger/graphic_buffer_producer.h index 58763cf08..98d27871c 100644 --- a/src/core/hle/service/nvflinger/graphic_buffer_producer.h +++ b/src/core/hle/service/nvflinger/graphic_buffer_producer.h | |||
| @@ -8,8 +8,8 @@ | |||
| 8 | 8 | ||
| 9 | #include "common/common_funcs.h" | 9 | #include "common/common_funcs.h" |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/math_util.h" | ||
| 11 | #include "core/hle/service/nvflinger/ui/fence.h" | 12 | #include "core/hle/service/nvflinger/ui/fence.h" |
| 12 | #include "core/hle/service/nvflinger/ui/rect.h" | ||
| 13 | #include "core/hle/service/nvflinger/window.h" | 13 | #include "core/hle/service/nvflinger/window.h" |
| 14 | 14 | ||
| 15 | namespace Service::android { | 15 | namespace Service::android { |
| @@ -20,7 +20,7 @@ class Parcel; | |||
| 20 | struct QueueBufferInput final { | 20 | struct QueueBufferInput final { |
| 21 | explicit QueueBufferInput(Parcel& parcel); | 21 | explicit QueueBufferInput(Parcel& parcel); |
| 22 | 22 | ||
| 23 | void Deflate(s64* timestamp_, bool* is_auto_timestamp_, Rect* crop_, | 23 | void Deflate(s64* timestamp_, bool* is_auto_timestamp_, Common::Rectangle<s32>* crop_, |
| 24 | NativeWindowScalingMode* scaling_mode_, NativeWindowTransform* transform_, | 24 | NativeWindowScalingMode* scaling_mode_, NativeWindowTransform* transform_, |
| 25 | u32* sticky_transform_, bool* async_, s32* swap_interval_, Fence* fence_) const { | 25 | u32* sticky_transform_, bool* async_, s32* swap_interval_, Fence* fence_) const { |
| 26 | *timestamp_ = timestamp; | 26 | *timestamp_ = timestamp; |
| @@ -37,7 +37,7 @@ struct QueueBufferInput final { | |||
| 37 | private: | 37 | private: |
| 38 | s64 timestamp{}; | 38 | s64 timestamp{}; |
| 39 | s32 is_auto_timestamp{}; | 39 | s32 is_auto_timestamp{}; |
| 40 | Rect crop{}; | 40 | Common::Rectangle<s32> crop{}; |
| 41 | NativeWindowScalingMode scaling_mode{}; | 41 | NativeWindowScalingMode scaling_mode{}; |
| 42 | NativeWindowTransform transform{}; | 42 | NativeWindowTransform transform{}; |
| 43 | u32 sticky_transform{}; | 43 | u32 sticky_transform{}; |
diff --git a/src/core/hle/service/nvflinger/ui/rect.h b/src/core/hle/service/nvflinger/ui/rect.h deleted file mode 100644 index c7b5f1815..000000000 --- a/src/core/hle/service/nvflinger/ui/rect.h +++ /dev/null | |||
| @@ -1,75 +0,0 @@ | |||
| 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 | |||
| 14 | namespace Service::android { | ||
| 15 | |||
| 16 | class Rect final { | ||
| 17 | public: | ||
| 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 | |||
| 67 | private: | ||
| 68 | s32 left{}; | ||
| 69 | s32 top{}; | ||
| 70 | s32 right{}; | ||
| 71 | s32 bottom{}; | ||
| 72 | }; | ||
| 73 | static_assert(sizeof(Rect) == 16, "Rect has wrong size"); | ||
| 74 | |||
| 75 | } // namespace Service::android | ||