[HarfBuzz] harfbuzz-ng: Branch 'master' - 2 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon May 10 21:44:36 PDT 2010
src/hb-ot-layout-gpos-private.hh | 101 ++++++++++++++++++++-------------------
src/hb-private.h | 2
2 files changed, 55 insertions(+), 48 deletions(-)
New commits:
commit 70c9bfd5646a4a55a7f43c0cf0b5ac5993615d5b
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue May 11 00:23:50 2010 -0400
Simplify PairSet
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 04b156f..5e17d6a 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -546,6 +546,7 @@ struct SinglePos
struct PairValueRecord
{
friend struct PairPosFormat1;
+ friend struct PairSet;
private:
GlyphID secondGlyph; /* GlyphID of second glyph in the
@@ -561,12 +562,50 @@ struct PairSet
{
friend struct PairPosFormat1;
- /* Note: Doesn't sanitize the Device entries in the ValueRecord */
- inline bool sanitize (hb_sanitize_context_t *context, unsigned int format_len) {
+ inline bool apply (hb_apply_context_t *context,
+ const ValueFormat *valueFormats,
+ unsigned int pos) const
+ {
+ TRACE_APPLY ();
+ unsigned int len1 = valueFormats[0].get_len ();
+ unsigned int len2 = valueFormats[1].get_len ();
+ unsigned int record_size = USHORT::static_size * (1 + len1 + len2);
+
+ unsigned int count = len;
+ const PairValueRecord *record = CastP<PairValueRecord> (array);
+ for (unsigned int i = 0; i < count; i++)
+ {
+ if (IN_GLYPH (pos) == record->secondGlyph)
+ {
+ valueFormats[0].apply_value (context->layout, this, &record->values[0], CURPOSITION ());
+ valueFormats[1].apply_value (context->layout, this, &record->values[len1], POSITION (pos));
+ if (len2)
+ pos++;
+ context->buffer->in_pos = pos;
+ return true;
+ }
+ record = &StructAtOffset<PairValueRecord> (record, record_size);
+ }
+
+ return false;
+ }
+
+ struct sanitize_closure_t {
+ void *base;
+ ValueFormat *valueFormats;
+ unsigned int len1; /* valueFormats[0].get_len() */
+ unsigned int stride; /* 1 + len1 + len2 */
+ };
+
+ inline bool sanitize (hb_sanitize_context_t *context, const sanitize_closure_t *closure) {
TRACE_SANITIZE ();
- if (!context->check_struct (this)) return false;
- unsigned int count = (1 + format_len) * len;
- return context->check_array (array, USHORT::static_size, count);
+ if (!(context->check_struct (this)
+ && context->check_array (array, USHORT::static_size * closure->stride, len))) return false;
+
+ unsigned int count = len;
+ PairValueRecord *record = CastP<PairValueRecord> (array);
+ return closure->valueFormats[0].sanitize_values_stride_unsafe (context, closure->base, &record->values[0], count, closure->stride)
+ && closure->valueFormats[1].sanitize_values_stride_unsafe (context, closure->base, &record->values[closure->len1], count, closure->stride);
}
private:
@@ -601,28 +640,7 @@ struct PairPosFormat1
j++;
}
- unsigned int len1 = valueFormat1.get_len ();
- unsigned int len2 = valueFormat2.get_len ();
- unsigned int record_size = USHORT::static_size * (1 + len1 + len2);
-
- const PairSet &pair_set = this+pairSet[index];
- unsigned int count = pair_set.len;
- const PairValueRecord *record = CastP<PairValueRecord> (pair_set.array);
- for (unsigned int i = 0; i < count; i++)
- {
- if (IN_GLYPH (j) == record->secondGlyph)
- {
- valueFormat1.apply_value (context->layout, this, &record->values[0], CURPOSITION ());
- valueFormat2.apply_value (context->layout, this, &record->values[len1], POSITION (j));
- if (len2)
- j++;
- context->buffer->in_pos = j;
- return true;
- }
- record = &StructAtOffset<PairValueRecord> (record, record_size);
- }
-
- return false;
+ return (this+pairSet[index]).apply (context, &valueFormat1, j);
}
inline bool sanitize (hb_sanitize_context_t *context) {
@@ -630,27 +648,16 @@ struct PairPosFormat1
unsigned int len1 = valueFormat1.get_len ();
unsigned int len2 = valueFormat2.get_len ();
+ PairSet::sanitize_closure_t closure = {
+ this,
+ &valueFormat1,
+ len1,
+ 1 + len1 + len2
+ };
- if (!(context->check_struct (this)
- && coverage.sanitize (context, this)
- && pairSet.sanitize (context, this, len1 + len2))) return false;
-
- if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
-
- unsigned int stride = 1 + len1 + len2;
- unsigned int count1 = pairSet.len;
- for (unsigned int i = 0; i < count1; i++)
- {
- PairSet &pair_set = const_cast<PairSet &> (this+pairSet[i]); /* XXX clean this up */
-
- unsigned int count2 = pair_set.len;
- PairValueRecord *record = CastP<PairValueRecord> (pair_set.array);
- if (!(valueFormat1.sanitize_values_stride_unsafe (context, this, &record->values[0], count2, stride) &&
- valueFormat2.sanitize_values_stride_unsafe (context, this, &record->values[len1], count2, stride)))
- return false;
- }
-
- return true;
+ return context->check_struct (this)
+ && coverage.sanitize (context, this)
+ && pairSet.sanitize (context, this, &closure);
}
private:
commit 97e7f8f305c47caf2968a9da3b8407825547286d
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue May 11 00:11:36 2010 -0400
Add CONST_FUNC annotation
diff --git a/src/hb-private.h b/src/hb-private.h
index 866ee59..7e292dc 100644
--- a/src/hb-private.h
+++ b/src/hb-private.h
@@ -143,7 +143,7 @@
* in libgcc in case a target does not have one, which should be just as
* good as the open-coded solution below, (which is "HACKMEM 169").
*/
-static inline unsigned int
+static inline HB_CONST_FUNC unsigned int
_hb_popcount32 (uint32_t mask)
{
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
More information about the HarfBuzz
mailing list