Split up creation of font group and sending of sprites to GPU

This commit is contained in:
Kovid Goyal 2018-05-26 12:07:40 +05:30
parent da166aef99
commit e056460f0b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 15 additions and 3 deletions

View File

@ -1118,9 +1118,17 @@ initialize_font_group(FontGroup *fg) {
}
#undef I
calc_cell_metrics(fg);
fg->sprite_map = alloc_sprite_map(fg->cell_width, fg->cell_height);
if (!fg->sprite_map) fatal("Out of memory allocating a sprite map");
send_prerendered_sprites(fg);
}
void
send_prerendered_sprites_for_window(OSWindow *w) {
FontGroup *fg = (FontGroup*)w->fonts_data;
if (!fg->sprite_map) {
fg->sprite_map = alloc_sprite_map(fg->cell_width, fg->cell_height);
if (!fg->sprite_map) fatal("Out of memory allocating a sprite map");
send_prerendered_sprites(fg);
}
}
FONTS_DATA_HANDLE
@ -1269,6 +1277,7 @@ create_test_font_group(PyObject *self UNUSED, PyObject *args) {
double sz, dpix, dpiy;
if (!PyArg_ParseTuple(args, "ddd", &sz, &dpix, &dpiy)) return NULL;
FontGroup *fg = font_group_for(sz, dpix, dpiy);
if (!fg->sprite_map) send_prerendered_sprites(fg);
return Py_BuildValue("II", fg->cell_width, fg->cell_height);
}

View File

@ -431,6 +431,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
}
w->logical_dpi_x = dpi_x; w->logical_dpi_y = dpi_y;
w->fonts_data = fonts_data;
send_prerendered_sprites_for_window(w);
if (logo.pixels && logo.width && logo.height) glfwSetWindowIcon(glfw_window, 1, &logo);
glfwSetCursor(glfw_window, standard_cursor);
update_os_window_viewport(w, false);

View File

@ -628,6 +628,7 @@ PYWRAP1(os_window_font_size) {
os_window->font_sz_in_pts = new_sz;
os_window->fonts_data = NULL;
os_window->fonts_data = load_fonts_data(os_window->font_sz_in_pts, os_window->logical_dpi_x, os_window->logical_dpi_y);
send_prerendered_sprites_for_window(os_window);
resize_screen(os_window, os_window->tab_bar_render_data.screen, false);
for (size_t ti = 0; ti < os_window->num_tabs; ti++) {
Tab *tab = os_window->tabs + ti;

View File

@ -187,3 +187,4 @@ void send_image_to_gpu(uint32_t*, const void*, int32_t, int32_t, bool, bool);
void send_sprite_to_gpu(FONTS_DATA_HANDLE fg, unsigned int, unsigned int, unsigned int, pixel*);
void set_titlebar_color(OSWindow *w, color_type color);
FONTS_DATA_HANDLE load_fonts_data(double, double, double);
void send_prerendered_sprites_for_window(OSWindow *w);