mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 06:51:26 +12:00
overlays: use thread local static vector in get_glyph_data
This commit is contained in:
parent
7fd1f5b5d3
commit
4aa25285a3
4 changed files with 13 additions and 14 deletions
|
@ -303,7 +303,7 @@ namespace gl
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create font file
|
// Create font file
|
||||||
const std::vector<u8> glyph_data = font->get_glyph_data();
|
const std::vector<u8>& glyph_data = font->get_glyph_data();
|
||||||
|
|
||||||
auto tex = std::make_unique<gl::texture>(GL_TEXTURE_2D_ARRAY, font_size.width, font_size.height, font_size.depth, 1, 1, GL_R8, RSX_FORMAT_CLASS_COLOR);
|
auto tex = std::make_unique<gl::texture>(GL_TEXTURE_2D_ARRAY, font_size.width, font_size.height, font_size.depth, 1, 1, GL_R8, RSX_FORMAT_CLASS_COLOR);
|
||||||
tex->copy_from(glyph_data.data(), gl::texture::format::r, gl::texture::type::ubyte, {});
|
tex->copy_from(glyph_data.data(), gl::texture::format::r, gl::texture::type::ubyte, {});
|
||||||
|
|
|
@ -417,13 +417,14 @@ namespace rsx
|
||||||
return {loc_x, loc_y};
|
return {loc_x, loc_y};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<u8> font::get_glyph_data() const
|
const std::vector<u8>& font::get_glyph_data() const
|
||||||
{
|
{
|
||||||
std::vector<u8> bytes;
|
constexpr u32 page_size = codepage::bitmap_width * codepage::bitmap_height;
|
||||||
const u32 page_size = codepage::bitmap_width * codepage::bitmap_height;
|
|
||||||
const auto size = page_size * m_glyph_map.size();
|
const auto size = page_size * m_glyph_map.size();
|
||||||
|
|
||||||
|
static thread_local std::vector<u8> bytes;
|
||||||
bytes.resize(size);
|
bytes.resize(size);
|
||||||
|
|
||||||
u8* data = bytes.data();
|
u8* data = bytes.data();
|
||||||
|
|
||||||
for (const auto& e : m_glyph_map)
|
for (const auto& e : m_glyph_map)
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace rsx
|
||||||
|
|
||||||
std::pair<f32, f32> get_char_offset(const char32_t* text, usz max_length, u16 max_width = -1, bool wrap = false);
|
std::pair<f32, f32> get_char_offset(const char32_t* text, usz max_length, u16 max_width = -1, bool wrap = false);
|
||||||
|
|
||||||
bool matches(const char* name, int size) const { return font_name == name && static_cast<int>(size_pt) == size; }
|
bool matches(const char* name, int size) const { return static_cast<int>(size_pt) == size && font_name == name; }
|
||||||
std::string_view get_name() const { return font_name; }
|
std::string_view get_name() const { return font_name; }
|
||||||
f32 get_size_pt() const { return size_pt; }
|
f32 get_size_pt() const { return size_pt; }
|
||||||
f32 get_size_px() const { return size_px; }
|
f32 get_size_px() const { return size_px; }
|
||||||
|
@ -87,7 +87,7 @@ namespace rsx
|
||||||
|
|
||||||
// Renderer info
|
// Renderer info
|
||||||
size3u get_glyph_data_dimensions() const { return { codepage::bitmap_width, codepage::bitmap_height, ::size32(m_glyph_map) }; }
|
size3u get_glyph_data_dimensions() const { return { codepage::bitmap_width, codepage::bitmap_height, ::size32(m_glyph_map) }; }
|
||||||
std::vector<u8> get_glyph_data() const;
|
const std::vector<u8>& get_glyph_data() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Singletons are cancer
|
// TODO: Singletons are cancer
|
||||||
|
@ -99,7 +99,7 @@ namespace rsx
|
||||||
|
|
||||||
font* find(const char* name, int size)
|
font* find(const char* name, int size)
|
||||||
{
|
{
|
||||||
for (auto& f : fonts)
|
for (const auto& f : fonts)
|
||||||
{
|
{
|
||||||
if (f->matches(name, size))
|
if (f->matches(name, size))
|
||||||
return f.get();
|
return f.get();
|
||||||
|
|
|
@ -508,16 +508,14 @@ namespace vk
|
||||||
{
|
{
|
||||||
return found->second.get();
|
return found->second.get();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
auto gc = vk::get_resource_manager();
|
auto gc = vk::get_resource_manager();
|
||||||
gc->dispose(font_cache[key]);
|
gc->dispose(font_cache[key]);
|
||||||
gc->dispose(view_cache[key]);
|
gc->dispose(view_cache[key]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Create font resource
|
// Create font resource
|
||||||
const std::vector<u8> bytes = font->get_glyph_data();
|
const std::vector<u8>& bytes = font->get_glyph_data();
|
||||||
|
|
||||||
return upload_simple_texture(cmd.get_command_pool().get_owner(), cmd, upload_heap, key, image_size.width, image_size.height, image_size.depth,
|
return upload_simple_texture(cmd.get_command_pool().get_owner(), cmd, upload_heap, key, image_size.width, image_size.height, image_size.depth,
|
||||||
true, false, bytes.data(), -1);
|
true, false, bytes.data(), -1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue