From 934d21ac305f57bc807c86351aa2ecf3368ffa40 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 9 Nov 2017 16:33:28 +0530 Subject: [PATCH] Wire up a few remaining pieces --- kitty/fonts.c | 1 + kitty/fonts.h | 3 +++ kitty/screen.c | 1 + kitty/shaders.c | 9 ++++++--- kitty/state.h | 1 - 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/kitty/fonts.c b/kitty/fonts.c index a312b456a..04a34595f 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -710,5 +710,6 @@ init_fonts(PyObject *module) { hb_buffer_set_cluster_level(harfbuzz_buffer, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS); if (PyModule_AddFunctions(module, module_methods) != 0) return false; current_send_sprite_to_gpu = send_sprite_to_gpu; + sprite_tracker_set_limits(2000, 2000); return true; } diff --git a/kitty/fonts.h b/kitty/fonts.h index 676000c22..90c9ef0f9 100644 --- a/kitty/fonts.h +++ b/kitty/fonts.h @@ -20,3 +20,6 @@ bool set_size_for_face(PyObject*, float, float, float); void cell_metrics(PyObject*, unsigned int*, unsigned int*, unsigned int*, unsigned int*, unsigned int*); void sprite_tracker_current_layout(unsigned int *x, unsigned int *y, unsigned int *z); bool render_glyphs_in_cells(PyObject *f, bool bold, bool italic, hb_glyph_info_t *info, hb_glyph_position_t *positions, unsigned int num_glyphs, uint8_t *canvas, unsigned int cell_width, unsigned int cell_height, unsigned int num_cells, unsigned int baseline); +void render_line(Line *line); +void sprite_tracker_set_limits(size_t max_texture_size, size_t max_array_len); +void sprite_tracker_set_layout(unsigned int cell_width, unsigned int cell_height); diff --git a/kitty/screen.c b/kitty/screen.c index 7316a6cc5..0adba516d 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -8,6 +8,7 @@ #define EXTRA_INIT PyModule_AddIntMacro(module, SCROLL_LINE); PyModule_AddIntMacro(module, SCROLL_PAGE); PyModule_AddIntMacro(module, SCROLL_FULL); #include "state.h" +#include "fonts.h" #include "lineops.h" #include "screen.h" #include diff --git a/kitty/shaders.c b/kitty/shaders.c index 974bf8f56..8267e20b0 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -100,18 +100,21 @@ send_sprite_to_gpu(unsigned int x, unsigned int y, unsigned int z, uint8_t *buf) Py_DECREF(buf); } +static bool limits_updated = false; + static void layout_sprite_map(unsigned int cell_width, unsigned int cell_height) { sprite_map.cell_width = MAX(1, cell_width); sprite_map.cell_height = MAX(1, cell_height); global_state.cell_width = sprite_map.cell_width; global_state.cell_height = sprite_map.cell_height; - if (sprite_map.max_texture_size == 0) { + if (!limits_updated) { glGetIntegerv(GL_MAX_TEXTURE_SIZE, &(sprite_map.max_texture_size)); glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &(sprite_map.max_array_texture_layers)); - /* sprite_map_set_limits(sprite_map.max_texture_size, sprite_map.max_array_texture_layers); */ + sprite_tracker_set_limits(sprite_map.max_texture_size, sprite_map.max_array_texture_layers); + limits_updated = true; } - /* sprite_map_set_layout(sprite_map.cell_width, sprite_map.cell_height); */ + sprite_tracker_set_layout(sprite_map.cell_width, sprite_map.cell_height); if (sprite_map.texture_id) { glDeleteTextures(1, &(sprite_map.texture_id)); sprite_map.texture_id = 0; } realloc_sprite_texture(); } diff --git a/kitty/state.h b/kitty/state.h index 6a9ea7b7c..bff465fe1 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -105,4 +105,3 @@ void update_viewport_size(int, int); void free_texture(uint32_t*); void send_image_to_gpu(uint32_t*, const void*, int32_t, int32_t, bool, bool); void send_sprite_to_gpu(unsigned int, unsigned int, unsigned int, uint8_t*); -void render_line(Line *line);