mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-15 22:21:25 +00:00
overlays: Refactoring
- Use names for overlay command config and vertex data instead of std::pair. - Make a couple of compiled_resource constructors explicitly named functions.
This commit is contained in:
parent
9d431e77a4
commit
44449dd9e9
@ -529,13 +529,13 @@ namespace gl
|
||||
program_handle.uniforms["time"] = (f32)(get_system_time() / 1000) * 0.005f;
|
||||
for (auto &cmd : ui.get_compiled().draw_commands)
|
||||
{
|
||||
upload_vertex_data((f32*)cmd.second.data(), (u32)cmd.second.size() * 4u);
|
||||
num_drawable_elements = (u32)cmd.second.size();
|
||||
upload_vertex_data((f32*)cmd.verts.data(), (u32)cmd.verts.size() * 4u);
|
||||
num_drawable_elements = (u32)cmd.verts.size();
|
||||
is_font_draw = false;
|
||||
GLint texture_exists = GL_TRUE;
|
||||
|
||||
glActiveTexture(GL_TEXTURE31);
|
||||
switch (cmd.first.texture_ref)
|
||||
switch (cmd.config.texture_ref)
|
||||
{
|
||||
case rsx::overlays::image_resource_id::game_icon:
|
||||
case rsx::overlays::image_resource_id::backbuffer:
|
||||
@ -548,27 +548,27 @@ namespace gl
|
||||
}
|
||||
case rsx::overlays::image_resource_id::raw_image:
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, find_temp_image((rsx::overlays::image_info*)cmd.first.external_data_ref, ui.uid)->id());
|
||||
glBindTexture(GL_TEXTURE_2D, find_temp_image((rsx::overlays::image_info*)cmd.config.external_data_ref, ui.uid)->id());
|
||||
break;
|
||||
}
|
||||
case rsx::overlays::image_resource_id::font_file:
|
||||
{
|
||||
is_font_draw = true;
|
||||
glBindTexture(GL_TEXTURE_2D, find_font(cmd.first.font_ref)->id());
|
||||
glBindTexture(GL_TEXTURE_2D, find_font(cmd.config.font_ref)->id());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, view_cache[cmd.first.texture_ref - 1]->id());
|
||||
glBindTexture(GL_TEXTURE_2D, view_cache[cmd.config.texture_ref - 1]->id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
program_handle.uniforms["color"] = cmd.first.color;
|
||||
program_handle.uniforms["color"] = cmd.config.color;
|
||||
program_handle.uniforms["read_texture"] = texture_exists;
|
||||
program_handle.uniforms["pulse_glow"] = (s32)cmd.first.pulse_glow;
|
||||
program_handle.uniforms["clip_region"] = (s32)cmd.first.clip_region;
|
||||
program_handle.uniforms["clip_bounds"] = cmd.first.clip_rect;
|
||||
program_handle.uniforms["pulse_glow"] = (s32)cmd.config.pulse_glow;
|
||||
program_handle.uniforms["clip_region"] = (s32)cmd.config.clip_region;
|
||||
program_handle.uniforms["clip_bounds"] = cmd.config.clip_rect;
|
||||
overlay_pass::run(w, h, target, false, true);
|
||||
}
|
||||
|
||||
|
@ -567,20 +567,26 @@ namespace rsx
|
||||
|
||||
command_config() {}
|
||||
|
||||
command_config(u8 ref)
|
||||
void set_image_resource(u8 ref)
|
||||
{
|
||||
texture_ref = ref;
|
||||
font_ref = nullptr;
|
||||
}
|
||||
|
||||
command_config(font *ref)
|
||||
void set_font(font *ref)
|
||||
{
|
||||
texture_ref = image_resource_id::font_file;
|
||||
font_ref = ref;
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<std::pair<command_config, std::vector<vertex>>> draw_commands;
|
||||
struct command
|
||||
{
|
||||
command_config config;
|
||||
std::vector<vertex> verts;
|
||||
};
|
||||
|
||||
std::vector<command> draw_commands;
|
||||
|
||||
void add(const compiled_resource& other)
|
||||
{
|
||||
@ -597,7 +603,7 @@ namespace rsx
|
||||
|
||||
for (size_t n = old_size; n < draw_commands.size(); ++n)
|
||||
{
|
||||
for (auto &v : draw_commands[n].second)
|
||||
for (auto &v : draw_commands[n].verts)
|
||||
{
|
||||
v += vertex(x_offset, y_offset, 0.f, 0.f);
|
||||
}
|
||||
@ -612,13 +618,13 @@ namespace rsx
|
||||
|
||||
for (size_t n = old_size; n < draw_commands.size(); ++n)
|
||||
{
|
||||
for (auto &v : draw_commands[n].second)
|
||||
for (auto &v : draw_commands[n].verts)
|
||||
{
|
||||
v += vertex(x_offset, y_offset, 0.f, 0.f);
|
||||
}
|
||||
|
||||
draw_commands[n].first.clip_rect = clip_rect;
|
||||
draw_commands[n].first.clip_region = true;
|
||||
draw_commands[n].config.clip_rect = clip_rect;
|
||||
draw_commands[n].config.clip_region = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -852,11 +858,11 @@ namespace rsx
|
||||
compiled_resources = {};
|
||||
compiled_resources.draw_commands.push_back({});
|
||||
|
||||
auto &config = compiled_resources.draw_commands.front().first;
|
||||
auto &config = compiled_resources.draw_commands.front().config;
|
||||
config.color = back_color;
|
||||
config.pulse_glow = pulse_effect_enabled;
|
||||
|
||||
auto& verts = compiled_resources.draw_commands.front().second;
|
||||
auto& verts = compiled_resources.draw_commands.front().verts;
|
||||
verts.resize(4);
|
||||
verts[0].vec4(x + padding_left - margin_left, y + padding_bottom - margin_bottom, 0.f, 0.f);
|
||||
verts[1].vec4(x + w - padding_right + margin_right, y + padding_bottom - margin_top, 1.f, 0.f);
|
||||
@ -866,11 +872,11 @@ namespace rsx
|
||||
if (!text.empty())
|
||||
{
|
||||
compiled_resources.draw_commands.push_back({});
|
||||
compiled_resources.draw_commands.back().first = font_ref? font_ref : fontmgr::get("Arial", 12);
|
||||
compiled_resources.draw_commands.back().first.color = fore_color;
|
||||
compiled_resources.draw_commands.back().second = render_text(text.c_str(), (f32)x, (f32)y);
|
||||
compiled_resources.draw_commands.back().config.set_font(font_ref ? font_ref : fontmgr::get("Arial", 12));
|
||||
compiled_resources.draw_commands.back().config.color = fore_color;
|
||||
compiled_resources.draw_commands.back().verts = render_text(text.c_str(), (f32)x, (f32)y);
|
||||
|
||||
if (compiled_resources.draw_commands.back().second.size() == 0)
|
||||
if (compiled_resources.draw_commands.back().verts.size() == 0)
|
||||
compiled_resources.draw_commands.pop_back();
|
||||
}
|
||||
|
||||
@ -1172,9 +1178,9 @@ namespace rsx
|
||||
if (!is_compiled)
|
||||
{
|
||||
auto &result = overlay_element::get_compiled();
|
||||
result.draw_commands.front().first = image_resource_ref;
|
||||
result.draw_commands.front().first.color = fore_color;
|
||||
result.draw_commands.front().first.external_data_ref = external_ref;
|
||||
result.draw_commands.front().config.set_image_resource(image_resource_ref);
|
||||
result.draw_commands.front().config.color = fore_color;
|
||||
result.draw_commands.front().config.external_data_ref = external_ref;
|
||||
}
|
||||
|
||||
return compiled_resources;
|
||||
@ -1223,13 +1229,13 @@ namespace rsx
|
||||
auto& compiled = image_view::get_compiled();
|
||||
for (auto &cmd : compiled.draw_commands)
|
||||
{
|
||||
if (cmd.first.texture_ref == image_resource_id::font_file)
|
||||
if (cmd.config.texture_ref == image_resource_id::font_file)
|
||||
{
|
||||
//Text, translate geometry to the right
|
||||
const f32 text_height = font_ref ? font_ref->size_px : 16.f;
|
||||
const f32 offset_y = (h > text_height) ? (f32)(h - text_height) : ((f32)h - text_height);
|
||||
|
||||
for (auto &v : cmd.second)
|
||||
for (auto &v : cmd.verts)
|
||||
{
|
||||
v.values[0] += text_offset + 15.f;
|
||||
v.values[1] += offset_y + 5.f;
|
||||
|
@ -694,19 +694,19 @@ namespace vk
|
||||
|
||||
for (auto &command : ui.get_compiled().draw_commands)
|
||||
{
|
||||
num_drawable_elements = (u32)command.second.size();
|
||||
num_drawable_elements = (u32)command.verts.size();
|
||||
const u32 value_count = num_drawable_elements * 4;
|
||||
|
||||
upload_vertex_data((f32*)command.second.data(), value_count);
|
||||
upload_vertex_data((f32*)command.verts.data(), value_count);
|
||||
|
||||
m_skip_texture_read = false;
|
||||
m_color = command.first.color;
|
||||
m_pulse_glow = command.first.pulse_glow;
|
||||
m_clip_enabled = command.first.clip_region;
|
||||
m_clip_region = command.first.clip_rect;
|
||||
m_color = command.config.color;
|
||||
m_pulse_glow = command.config.pulse_glow;
|
||||
m_clip_enabled = command.config.clip_region;
|
||||
m_clip_region = command.config.clip_rect;
|
||||
|
||||
auto src = vk::null_image_view(cmd);
|
||||
switch (command.first.texture_ref)
|
||||
switch (command.config.texture_ref)
|
||||
{
|
||||
case rsx::overlays::image_resource_id::game_icon:
|
||||
case rsx::overlays::image_resource_id::backbuffer:
|
||||
@ -715,13 +715,13 @@ namespace vk
|
||||
m_skip_texture_read = true;
|
||||
break;
|
||||
case rsx::overlays::image_resource_id::font_file:
|
||||
src = find_font(command.first.font_ref, cmd, upload_heap)->value;
|
||||
src = find_font(command.config.font_ref, cmd, upload_heap)->value;
|
||||
break;
|
||||
case rsx::overlays::image_resource_id::raw_image:
|
||||
src = find_temp_image((rsx::overlays::image_info*)command.first.external_data_ref, cmd, upload_heap, ui.uid)->value;
|
||||
src = find_temp_image((rsx::overlays::image_info*)command.config.external_data_ref, cmd, upload_heap, ui.uid)->value;
|
||||
break;
|
||||
default:
|
||||
src = view_cache[command.first.texture_ref]->value;
|
||||
src = view_cache[command.config.texture_ref]->value;
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user