mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-04-06 06:55:02 +00:00
overlays: Implement SDF config transforms
This commit is contained in:
parent
57e37862f4
commit
5a94adcf26
3 changed files with 40 additions and 0 deletions
|
|
@ -54,6 +54,40 @@ namespace rsx
|
|||
return result;
|
||||
}
|
||||
|
||||
void compiled_resource::sdf_config_t::transform(const areaf& target_viewport, const sizef& virtual_viewport)
|
||||
{
|
||||
const f32 scale_x = target_viewport.width() / virtual_viewport.width;
|
||||
const f32 scale_y = target_viewport.height() / virtual_viewport.height;
|
||||
|
||||
// Ideally the average should match the x and y scaling but arithmetic drift shifts the values around a bit.
|
||||
// Also we need a way to define perfect circles when the aspect ratio is not respected.
|
||||
const f32 scale_av = (scale_x + scale_y) / 2;
|
||||
|
||||
hx *= scale_x;
|
||||
hy *= scale_y;
|
||||
br *= scale_av;
|
||||
bw *= scale_av;
|
||||
|
||||
// Account for flipped viewport
|
||||
if (target_viewport.x2 < target_viewport.x1)
|
||||
{
|
||||
cx = target_viewport.width() - (cx * scale_x) + target_viewport.x2;
|
||||
}
|
||||
else
|
||||
{
|
||||
cx = cx * scale_x + target_viewport.x1;
|
||||
}
|
||||
|
||||
if (target_viewport.y2 < target_viewport.y1)
|
||||
{
|
||||
cy = target_viewport.height() - (cy * scale_y) + target_viewport.y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
cy = cy * scale_y + target_viewport.y1;
|
||||
}
|
||||
}
|
||||
|
||||
image_info::image_info(const std::string& filename, bool grayscaled)
|
||||
{
|
||||
fs::file f(filename, fs::read + fs::isfile);
|
||||
|
|
|
|||
|
|
@ -115,6 +115,11 @@ namespace rsx
|
|||
f32 bw; // Border width
|
||||
|
||||
color4f border_color;
|
||||
|
||||
// Transform a SDF definition from one reference frame to another
|
||||
// Target viewport - your actual render area
|
||||
// Virtual viewport - the internal design viewport
|
||||
void transform(const areaf& target_viewport, const sizef& virtual_viewport);
|
||||
};
|
||||
|
||||
struct command_config
|
||||
|
|
|
|||
|
|
@ -660,6 +660,7 @@ namespace vk
|
|||
m_disable_vertex_snap = command.config.disable_vertex_snap;
|
||||
|
||||
m_sdf_config = command.config.sdf_config;
|
||||
m_sdf_config.transform(static_cast<areaf>(viewport), { m_scale_offset.x, m_scale_offset.y });
|
||||
|
||||
vk::image_view* src = nullptr;
|
||||
switch (command.config.texture_ref)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue