[HarfBuzz] harfbuzz: Branch 'master' - 3 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Apr 16 18:58:09 PDT 2013


 src/hb-ot-layout.cc                        |    6 ++++++
 src/hb-ot-shape-complex-arabic-fallback.hh |    4 +++-
 src/hb-set-private.hh                      |   19 ++++++++++++++++---
 src/hb-set.cc                              |   13 +++++++++++++
 4 files changed, 38 insertions(+), 4 deletions(-)

New commits:
commit 893991fc9d2d3a57c4c148f3a9c3b98263cf3aed
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Apr 16 21:50:33 2013 -0400

    Initialize set digests
    
    We were not initializing the digests properly and as a result they were
    being initialized to zero, making digest1 to never do any useful work.
    
    Speeds up Amiri shaping significantly.

diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 8161ce3..c80ca7d 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -70,9 +70,15 @@ _hb_ot_layout_create (hb_face_t *face)
   }
 
   for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
+  {
+    layout->gsub_digests[i].init ();
     layout->gsub->get_lookup (i).add_coverage (&layout->gsub_digests[i]);
+  }
   for (unsigned int i = 0; i < layout->gpos_lookup_count; i++)
+  {
+    layout->gpos_digests[i].init ();
     layout->gpos->get_lookup (i).add_coverage (&layout->gpos_digests[i]);
+  }
 
   return layout;
 }
diff --git a/src/hb-ot-shape-complex-arabic-fallback.hh b/src/hb-ot-shape-complex-arabic-fallback.hh
index 5e151f7..996e40e 100644
--- a/src/hb-ot-shape-complex-arabic-fallback.hh
+++ b/src/hb-ot-shape-complex-arabic-fallback.hh
@@ -212,7 +212,9 @@ arabic_fallback_plan_create (const hb_ot_shape_plan_t *plan,
   if (unlikely (!fallback_plan))
     return const_cast<arabic_fallback_plan_t *> (&arabic_fallback_plan_nil);
 
-  for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++) {
+  for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
+  {
+    fallback_plan->digest_array[i].init ();
     fallback_plan->mask_array[i] = plan->map.get_1_mask (arabic_fallback_features[i]);
     if (fallback_plan->mask_array[i]) {
       fallback_plan->lookup_array[i] = arabic_fallback_synthesize_lookup (plan, font, i);
commit 4d2813d3e980c8e6150caafa604a78cc44bf62a2
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Apr 16 21:57:21 2013 -0400

    Print set-digest hit ratio with HB_DEBUG_SET_DIGESTS

diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index 1241e05..d9e0d29 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -102,6 +102,10 @@ struct hb_set_digest_lowest_bits_t
   mask_t mask;
 };
 
+#ifdef HB_DEBUG_SET_DIGESTS
+extern unsigned long digest_total, digest_yes, digest_yes1, digest_yes2;
+#endif
+
 struct hb_set_digest_t
 {
   ASSERT_POD ();
@@ -122,6 +126,15 @@ struct hb_set_digest_t
   }
 
   inline bool may_have (hb_codepoint_t g) const {
+#ifdef HB_DEBUG_SET_DIGESTS
+    digest_total++;
+    if (digest1.may_have (g) && digest2.may_have (g))
+      digest_yes++;
+    if (digest1.may_have (g))
+      digest_yes1++;
+    if (digest2.may_have (g))
+      digest_yes2++;
+#endif
     return digest1.may_have (g) && digest2.may_have (g);
   }
 
diff --git a/src/hb-set.cc b/src/hb-set.cc
index 5f427a5..050cc24 100644
--- a/src/hb-set.cc
+++ b/src/hb-set.cc
@@ -27,6 +27,19 @@
 #include "hb-set-private.hh"
 
 
+#ifdef HB_DEBUG_SET_DIGESTS
+unsigned long digest_total, digest_yes, digest_yes1, digest_yes2;
+__attribute__((__destructor__))
+void digest_print (void)
+{
+  if (!digest_total)
+    return;
+  printf("Set digest summary: both %%%ld first %%%ld second %%%ld\n",
+	 100 * digest_yes / digest_total,
+	 100 * digest_yes1 / digest_total,
+	 100 * digest_yes2 / digest_total);
+}
+#endif
 
 /* Public API */
 
commit 1357c2dd120d005ceecfa83ed328d05dc634d7bc
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Apr 16 21:47:40 2013 -0400

    Revert "Speed up hb_set_digest_common_bits_t calcs"
    
    This reverts commit 3d1b66a35e1ab3be19335705f310b278d76d66d2.
    
    The calculations were buggy.  It's not worth optimizing right now.

diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index 5e30a7e..1241e05 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -54,9 +54,9 @@ struct hb_set_digest_common_bits_t
   }
 
   inline void add_range (hb_codepoint_t a, hb_codepoint_t b) {
-    /* The negation here stands for ~(x-1). */
-    mask &= -(1 << _hb_bit_storage (a ^ b));
-    value &= mask;
+    /* TODO Speedup. */
+    for (unsigned int i = a; i < b + 1; i++)
+      add (i);
   }
 
   inline bool may_have (hb_codepoint_t g) const {



More information about the HarfBuzz mailing list