From d3d3691806aaa6aed93a88c845d472e727e7f850 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 3 Feb 2017 15:42:03 -0800 Subject: [PATCH] Add dirty-state tracking to hb_face_t --- src/hb-face-private.hh | 9 +++++++++ src/hb-face.cc | 19 ++++++++++++++++++- src/hb-font.cc | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/hb-face-private.hh b/src/hb-face-private.hh index 43e7b1cb3..eb0e850aa 100644 --- a/src/hb-face-private.hh +++ b/src/hb-face-private.hh @@ -54,6 +54,13 @@ struct hb_face_t { 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 @@ struct hb_face_t { 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 1ba970707..1800c995a 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -51,6 +51,8 @@ const hb_face_t _hb_face_nil = { 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 @@ hb_face_create (hb_blob_t *blob, 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 @@ hb_face_set_index (hb_face_t *face, if (face->immutable) return; + if (face->index == index) + return; + + face->dirty |= face->INDEX; + face->index = index; } @@ -400,6 +407,11 @@ hb_face_set_upem (hb_face_t *face, if (face->immutable) return; + if (face->upem == upem) + return; + + face->dirty |= face->UPEM; + face->upem = upem; } @@ -444,6 +456,11 @@ hb_face_set_glyph_count (hb_face_t *face, 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 cc0e6c348..a08766f5b 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -1196,7 +1196,7 @@ hb_font_get_empty (void) 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,