ngl: Reduce type checking overhead
authorMatthias Clasen <mclasen@redhat.com>
Sat, 24 Jul 2021 13:50:43 +0000 (09:50 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 24 Jul 2021 22:48:09 +0000 (18:48 -0400)
No need to be very careful here, these are entirely
internal types.

gsk/ngl/gsknglglyphlibrary.c
gsk/ngl/gskngliconlibrary.c
gsk/ngl/gsknglrenderjob.c

index 0339f4590f46af9b5a8ae0bd08d303dff7c3814b..627f35f59ec32b62125b6c345e53480df789eaba 100644 (file)
@@ -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,
index 4d84cb2354c5c5eda36c50b203c0f0ca8f275876..977c20105144d7169c9ee476b6e718ee90d27e0e 100644 (file)
@@ -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 ())
     {
index 49ad2774019e1c2848f32e2eddc931df34453c0f..40e730557fb2e9d20f4e7a5fd78e0809f73e97f1 100644 (file)
@@ -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))