Add dirty-state tracking to hb_face_t
diff --git a/src/hb-face-private.hh b/src/hb-face-private.hh
index 43e7b1c..eb0e850 100644
--- a/src/hb-face-private.hh
+++ b/src/hb-face-private.hh
@@ -54,6 +54,13 @@
mutable unsigned int upem; /* Units-per-EM. */
mutable unsigned int num_glyphs; /* Number of glyphs. */
+ enum dirty_t {
+ NOTHING = 0x0000,
+ INDEX = 0x0001,
+ UPEM = 0x0002,
+ NUM_GLYPHS = 0x0004,
+ } dirty;
+
struct hb_shaper_data_t shaper_data; /* Various shaper data. */
/* Various non-shaping data. */
@@ -99,6 +106,8 @@
HB_INTERNAL void load_num_glyphs (void) const;
};
+HB_MARK_AS_FLAG_T (hb_face_t::dirty_t);
+
extern HB_INTERNAL const hb_face_t _hb_face_nil;
#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
diff --git a/src/hb-face.cc b/src/hb-face.cc
index 1ba9707..1800c99 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -51,6 +51,8 @@
1000, /* upem */
0, /* num_glyphs */
+ hb_face_t::NOTHING, /* dirty */
+
{
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
#include "hb-shaper-list.hh"
@@ -171,7 +173,7 @@
closure,
(hb_destroy_func_t) _hb_face_for_data_closure_destroy);
- hb_face_set_index (face, index);
+ face->index = index;
return face;
}
@@ -365,6 +367,11 @@
if (face->immutable)
return;
+ if (face->index == index)
+ return;
+
+ face->dirty |= face->INDEX;
+
face->index = index;
}
@@ -400,6 +407,11 @@
if (face->immutable)
return;
+ if (face->upem == upem)
+ return;
+
+ face->dirty |= face->UPEM;
+
face->upem = upem;
}
@@ -444,6 +456,11 @@
if (face->immutable)
return;
+ if (face->num_glyphs == glyph_count)
+ return;
+
+ face->dirty |= face->NUM_GLYPHS;
+
face->num_glyphs = glyph_count;
}
diff --git a/src/hb-font.cc b/src/hb-font.cc
index cc0e6c3..a08766f 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1196,7 +1196,7 @@
NULL, /* user_data */
NULL, /* destroy */
- hb_font_t::NOTHING, /* dirty_bits */
+ hb_font_t::NOTHING, /* dirty */
{
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,