rasterizer_cache: SurfaceParams interface cleanup

This commit is contained in:
emufan4568 2022-08-20 12:22:45 +03:00
parent cb0816c987
commit 22acfe4d41

View File

@ -17,17 +17,30 @@ using Surface = std::shared_ptr<CachedSurface>;
using SurfaceInterval = boost::icl::right_open_interval<PAddr>; using SurfaceInterval = boost::icl::right_open_interval<PAddr>;
struct SurfaceParams { class SurfaceParams {
unsigned int GetFormatBpp() const { public:
return OpenGL::GetFormatBpp(pixel_format); // Surface match traits
} bool ExactMatch(const SurfaceParams& other_surface) const;
bool CanSubRect(const SurfaceParams& sub_surface) const;
bool CanExpand(const SurfaceParams& expanded_surface) const;
bool CanTexCopy(const SurfaceParams& texcopy_params) const;
/// Update the params "size", "end" and "type" from the already set "addr", "width", "height" Common::Rectangle<u32> GetSubRect(const SurfaceParams& sub_surface) const;
/// and "pixel_format" Common::Rectangle<u32> GetScaledSubRect(const SurfaceParams& sub_surface) const;
// Returns the outer rectangle containing "interval"
SurfaceParams FromInterval(SurfaceInterval interval) const;
SurfaceInterval GetSubRectInterval(Common::Rectangle<u32> unscaled_rect) const;
// Returns the region of the biggest valid rectange within interval
SurfaceInterval GetCopyableInterval(const Surface& src_surface) const;
/// Updates remaining members from the already set addr, width, height and pixel_format
void UpdateParams() { void UpdateParams() {
if (stride == 0) { if (stride == 0) {
stride = width; stride = width;
} }
type = GetFormatType(pixel_format); type = GetFormatType(pixel_format);
size = !is_tiled ? BytesInPixels(stride * (height - 1) + width) size = !is_tiled ? BytesInPixels(stride * (height - 1) + width)
: BytesInPixels(stride * 8 * (height / 8 - 1) + width * 8); : BytesInPixels(stride * 8 * (height / 8 - 1) + width * 8);
@ -38,13 +51,9 @@ struct SurfaceParams {
return SurfaceInterval(addr, end); return SurfaceInterval(addr, end);
} }
// Returns the outer rectangle containing "interval" u32 GetFormatBpp() const {
SurfaceParams FromInterval(SurfaceInterval interval) const; return OpenGL::GetFormatBpp(pixel_format);
}
SurfaceInterval GetSubRectInterval(Common::Rectangle<u32> unscaled_rect) const;
// Returns the region of the biggest valid rectange within interval
SurfaceInterval GetCopyableInterval(const Surface& src_surface) const;
u32 GetScaledWidth() const { u32 GetScaledWidth() const {
return width * res_scale; return width * res_scale;
@ -70,14 +79,7 @@ struct SurfaceParams {
return pixels * GetFormatBpp() / 8; return pixels * GetFormatBpp() / 8;
} }
bool ExactMatch(const SurfaceParams& other_surface) const; public:
bool CanSubRect(const SurfaceParams& sub_surface) const;
bool CanExpand(const SurfaceParams& expanded_surface) const;
bool CanTexCopy(const SurfaceParams& texcopy_params) const;
Common::Rectangle<u32> GetSubRect(const SurfaceParams& sub_surface) const;
Common::Rectangle<u32> GetScaledSubRect(const SurfaceParams& sub_surface) const;
PAddr addr = 0; PAddr addr = 0;
PAddr end = 0; PAddr end = 0;
u32 size = 0; u32 size = 0;