[gtk/glyphy2: 43/47] glyphy: Shrink GskGlGlyphyValue a bit




commit 24d1dd8f135c5774993a25b850994390253bb090
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Mar 19 14:04:41 2022 -0400

    glyphy: Shrink GskGlGlyphyValue a bit
    
    Store the extent as floats, and drop the unused is_empty
    and advance fields. With that, we fit into one cacheline.

 gsk/gl/gskglglyphylibrary.c        | 19 +++++++------------
 gsk/gl/gskglglyphylibraryprivate.h |  9 ++++++---
 2 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/gsk/gl/gskglglyphylibrary.c b/gsk/gl/gskglglyphylibrary.c
index c29408f639..9411081534 100644
--- a/gsk/gl/gskglglyphylibrary.c
+++ b/gsk/gl/gskglglyphylibrary.c
@@ -239,9 +239,7 @@ encode_glyph (GskGLGlyphyLibrary *self,
               guint              *output_len,
               guint              *nominal_width,
               guint              *nominal_height,
-              glyphy_extents_t   *extents,
-              double             *advance,
-              gboolean           *is_empty)
+              glyphy_extents_t   *extents)
 {
   hb_face_t *face = hb_font_get_face (font);
   guint upem = hb_face_get_upem (face);
@@ -283,9 +281,6 @@ encode_glyph (GskGLGlyphyLibrary *self,
 
   glyphy_extents_scale (extents, 1./upem, 1./upem);
 
-  *advance = hb_font_get_glyph_h_advance (font, glyph_index) / (double)upem;
-  *is_empty = glyphy_extents_is_empty (extents);
-
   return TRUE;
 }
 
@@ -299,8 +294,6 @@ gsk_gl_glyphy_library_add (GskGLGlyphyLibrary      *self,
   GskGLGlyphyValue *value;
   glyphy_extents_t extents;
   hb_font_t *font;
-  gboolean is_empty;
-  double advance;
   guint packed_x;
   guint packed_y;
   guint nominal_w, nominal_h;
@@ -318,7 +311,7 @@ gsk_gl_glyphy_library_add (GskGLGlyphyLibrary      *self,
   if (!encode_glyph (self, font, key->glyph, TOLERANCE,
                      buffer, sizeof buffer, &output_len,
                      &nominal_w, &nominal_h,
-                     &extents, &advance, &is_empty))
+                     &extents))
     return FALSE;
 
   /* Allocate space for list within atlas */
@@ -336,7 +329,7 @@ gsk_gl_glyphy_library_add (GskGLGlyphyLibrary      *self,
   if (texture_id == 0)
     return FALSE;
 
-  if (!is_empty)
+  if (!glyphy_extents_is_empty (&extents))
     {
       /* Connect the texture for data upload */
       glActiveTexture (GL_TEXTURE0);
@@ -370,8 +363,10 @@ gsk_gl_glyphy_library_add (GskGLGlyphyLibrary      *self,
         }
     }
 
-  value->advance = advance;
-  value->extents = extents;
+  value->extents.min_x = extents.min_x;
+  value->extents.min_y = extents.min_y;
+  value->extents.max_x = extents.max_x;
+  value->extents.max_y = extents.max_y;
   value->nominal_w = nominal_w;
   value->nominal_h = nominal_h;
   value->atlas_x = packed_x / self->item_w;
diff --git a/gsk/gl/gskglglyphylibraryprivate.h b/gsk/gl/gskglglyphylibraryprivate.h
index 3d2a817768..7bd83a5640 100644
--- a/gsk/gl/gskglglyphylibraryprivate.h
+++ b/gsk/gl/gskglglyphylibraryprivate.h
@@ -39,13 +39,16 @@ typedef struct _GskGLGlyphyKey
 typedef struct _GskGLGlyphyValue
 {
   GskGLTextureAtlasEntry entry;
-  glyphy_extents_t extents;
-  double advance;
+  struct {
+    float min_x;
+    float min_y;
+    float max_x;
+    float max_y;
+  } extents;
   guint nominal_w;
   guint nominal_h;
   guint atlas_x;
   guint atlas_y;
-  guint is_empty : 1;
 } GskGLGlyphyValue;
 
 G_DECLARE_FINAL_TYPE (GskGLGlyphyLibrary, gsk_gl_glyphy_library, GSK, GL_GLYPHY_LIBRARY, GskGLTextureLibrary)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]