hle: nvflinger: Merge Rect with Common::Rectangle.
This commit is contained in:
parent
e524def8c0
commit
4d9488033f
6 changed files with 54 additions and 90 deletions
|
@ -9,8 +9,8 @@
|
|||
#include <memory>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/math_util.h"
|
||||
#include "core/hle/service/nvflinger/ui/fence.h"
|
||||
#include "core/hle/service/nvflinger/ui/rect.h"
|
||||
#include "core/hle/service/nvflinger/window.h"
|
||||
|
||||
namespace Service::android {
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
std::shared_ptr<GraphicBuffer> graphic_buffer;
|
||||
Fence fence;
|
||||
Rect crop;
|
||||
Common::Rectangle<s32> crop;
|
||||
NativeWindowTransform transform{};
|
||||
u32 scaling_mode{};
|
||||
s64 timestamp{};
|
||||
|
|
|
@ -441,7 +441,7 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input,
|
|||
QueueBufferOutput* output) {
|
||||
s64 timestamp{};
|
||||
bool is_auto_timestamp{};
|
||||
Rect crop;
|
||||
Common::Rectangle<s32> crop;
|
||||
NativeWindowScalingMode scaling_mode{};
|
||||
NativeWindowTransform transform;
|
||||
u32 sticky_transform_{};
|
||||
|
@ -509,9 +509,9 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input,
|
|||
crop.Bottom(), transform, scaling_mode);
|
||||
|
||||
const std::shared_ptr<GraphicBuffer>& graphic_buffer(slots[slot].graphic_buffer);
|
||||
Rect buffer_rect(graphic_buffer->Width(), graphic_buffer->Height());
|
||||
Rect cropped_rect;
|
||||
crop.Intersect(buffer_rect, &cropped_rect);
|
||||
Common::Rectangle<s32> buffer_rect(graphic_buffer->Width(), graphic_buffer->Height());
|
||||
Common::Rectangle<s32> cropped_rect;
|
||||
[[maybe_unused]] const bool unused = crop.Intersect(buffer_rect, &cropped_rect);
|
||||
|
||||
if (cropped_rect != crop) {
|
||||
LOG_ERROR(Service_NVFlinger, "crop rect is not contained within the buffer in slot {}",
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/math_util.h"
|
||||
#include "core/hle/service/nvflinger/ui/fence.h"
|
||||
#include "core/hle/service/nvflinger/ui/rect.h"
|
||||
#include "core/hle/service/nvflinger/window.h"
|
||||
|
||||
namespace Service::android {
|
||||
|
@ -20,7 +20,7 @@ class Parcel;
|
|||
struct QueueBufferInput final {
|
||||
explicit QueueBufferInput(Parcel& parcel);
|
||||
|
||||
void Deflate(s64* timestamp_, bool* is_auto_timestamp_, Rect* crop_,
|
||||
void Deflate(s64* timestamp_, bool* is_auto_timestamp_, Common::Rectangle<s32>* crop_,
|
||||
NativeWindowScalingMode* scaling_mode_, NativeWindowTransform* transform_,
|
||||
u32* sticky_transform_, bool* async_, s32* swap_interval_, Fence* fence_) const {
|
||||
*timestamp_ = timestamp;
|
||||
|
@ -37,7 +37,7 @@ struct QueueBufferInput final {
|
|||
private:
|
||||
s64 timestamp{};
|
||||
s32 is_auto_timestamp{};
|
||||
Rect crop{};
|
||||
Common::Rectangle<s32> crop{};
|
||||
NativeWindowScalingMode scaling_mode{};
|
||||
NativeWindowTransform transform{};
|
||||
u32 sticky_transform{};
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
// 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 Service::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 Service::android
|
Loading…
Add table
Add a link
Reference in a new issue