From f88efb811bad5a20f755c8da80e7378d2c16a4be Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 24 Jul 2021 09:50:43 -0400 Subject: [PATCH] ngl: Reduce type checking overhead No need to be very careful here, these are entirely internal types. --- gsk/ngl/gsknglglyphlibrary.c | 14 +++++++++----- gsk/ngl/gskngliconlibrary.c | 11 +++++++---- gsk/ngl/gsknglrenderjob.c | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/gsk/ngl/gsknglglyphlibrary.c b/gsk/ngl/gsknglglyphlibrary.c index 0339f4590f..627f35f59e 100644 --- a/gsk/ngl/gsknglglyphlibrary.c +++ b/gsk/ngl/gsknglglyphlibrary.c @@ -88,7 +88,7 @@ gsk_ngl_glyph_library_begin_frame (GskNglTextureLibrary *library, gint64 frame_id, GPtrArray *removed_atlases) { - GskNglGlyphLibrary *self = GSK_NGL_GLYPH_LIBRARY (library); + GskNglGlyphLibrary *self = (GskNglGlyphLibrary *)library; memset (self->front, 0, sizeof self->front); } @@ -117,8 +117,10 @@ gsk_ngl_glyph_library_class_init (GskNglGlyphLibraryClass *klass) static void gsk_ngl_glyph_library_init (GskNglGlyphLibrary *self) { - GSK_NGL_TEXTURE_LIBRARY (self)->max_entry_size = MAX_GLYPH_SIZE; - gsk_ngl_texture_library_set_funcs (GSK_NGL_TEXTURE_LIBRARY (self), + GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self; + + tl->max_entry_size = MAX_GLYPH_SIZE; + gsk_ngl_texture_library_set_funcs (tl, gsk_ngl_glyph_key_hash, gsk_ngl_glyph_key_equal, gsk_ngl_glyph_key_free, @@ -200,6 +202,7 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self, int height, double device_scale) { + GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self; G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME; cairo_scaled_font_t *scaled_font; cairo_surface_t *surface; @@ -264,7 +267,7 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self, gdk_gl_context_pop_debug_group (gdk_gl_context_get_current ()); - GSK_NGL_TEXTURE_LIBRARY (self)->driver->command_queue->n_uploads++; + tl->driver->command_queue->n_uploads++; if (gdk_profiler_is_running ()) { @@ -279,6 +282,7 @@ gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self, GskNglGlyphKey *key, const GskNglGlyphValue **out_value) { + GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self; PangoRectangle ink_rect; GskNglGlyphValue *value; int width; @@ -301,7 +305,7 @@ gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self, width = (int) ceil (ink_rect.width * key->scale / 1024.0); height = (int) ceil (ink_rect.height * key->scale / 1024.0); - value = gsk_ngl_texture_library_pack (GSK_NGL_TEXTURE_LIBRARY (self), + value = gsk_ngl_texture_library_pack (tl, key, sizeof *value, width, diff --git a/gsk/ngl/gskngliconlibrary.c b/gsk/ngl/gskngliconlibrary.c index 4d84cb2354..977c201051 100644 --- a/gsk/ngl/gskngliconlibrary.c +++ b/gsk/ngl/gskngliconlibrary.c @@ -63,8 +63,10 @@ gsk_ngl_icon_library_class_init (GskNglIconLibraryClass *klass) static void gsk_ngl_icon_library_init (GskNglIconLibrary *self) { - GSK_NGL_TEXTURE_LIBRARY (self)->max_entry_size = 128; - gsk_ngl_texture_library_set_funcs (GSK_NGL_TEXTURE_LIBRARY (self), + GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self; + + tl->max_entry_size = 128; + gsk_ngl_texture_library_set_funcs (tl, NULL, NULL, NULL, gsk_ngl_icon_data_free); } @@ -74,6 +76,7 @@ gsk_ngl_icon_library_add (GskNglIconLibrary *self, GdkTexture *key, const GskNglIconData **out_value) { + GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self; G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME; cairo_surface_t *surface; GskNglIconData *icon_data; @@ -95,7 +98,7 @@ gsk_ngl_icon_library_add (GskNglIconLibrary *self, width = key->width; height = key->height; - icon_data = gsk_ngl_texture_library_pack (GSK_NGL_TEXTURE_LIBRARY (self), + icon_data = gsk_ngl_texture_library_pack (tl, key, sizeof (GskNglIconData), width, height, 1, @@ -202,7 +205,7 @@ gsk_ngl_icon_library_add (GskNglIconLibrary *self, cairo_surface_destroy (surface); g_free (free_data); - GSK_NGL_TEXTURE_LIBRARY (self)->driver->command_queue->n_uploads++; + tl->driver->command_queue->n_uploads++; if (gdk_profiler_is_running ()) { diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c index 49ad277401..40e730557f 100644 --- a/gsk/ngl/gsknglrenderjob.c +++ b/gsk/ngl/gsknglrenderjob.c @@ -3332,7 +3332,7 @@ gsk_ngl_render_job_upload_texture (GskNglRenderJob *job, GdkTexture *texture, GskNglRenderOffscreen *offscreen) { - if (gsk_ngl_texture_library_can_cache (GSK_NGL_TEXTURE_LIBRARY (job->driver->icons), + if (gsk_ngl_texture_library_can_cache ((GskNglTextureLibrary *)job->driver->icons, texture->width, texture->height) && !GDK_IS_GL_TEXTURE (texture))