From: Behdad Esfahbod Date: Mon, 18 May 2009 06:47:57 +0000 (-0400) Subject: [HB] One more step to go, for fully working GSUB and ChainContext X-Git-Tag: submit/master/20120920.151126~7^2~1220 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02e1e5c63fa4f896053fa3c21e495239e1e9caa2;p=framework%2Fuifw%2Fharfbuzz.git [HB] One more step to go, for fully working GSUB and ChainContext --- diff --git a/src/hb-ot-layout-gsubgpos-private.h b/src/hb-ot-layout-gsubgpos-private.h index 6a35bc6..72df46c 100644 --- a/src/hb-ot-layout-gsubgpos-private.h +++ b/src/hb-ot-layout-gsubgpos-private.h @@ -168,12 +168,9 @@ static inline bool context_lookup (LOOKUP_ARGS_DEF, USHORT inputCount, /* Including the first glyph (not matched) */ const USHORT input[], /* Array of input values--start with second glyph */ USHORT lookupCount, - const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */ + const LookupRecord lookupRecord[], ContextLookupContext &context) { - unsigned int i, j; - unsigned int count = inputCount; - return match_input (LOOKUP_ARGS, inputCount, input, context.funcs.match, context.match_data, @@ -308,8 +305,12 @@ struct ContextFormat3 { friend struct Context; private: + inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const { + + unsigned int index = (this+coverage[0]) (IN_CURGLYPH ()); + if (G_LIKELY (index == NOT_COVERED)) + return false; - inline bool apply_coverage (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const { const LookupRecord *lookupRecord = (const LookupRecord *) ((const char *) coverage + sizeof (coverage[0]) * glyphCount); @@ -325,15 +326,6 @@ struct ContextFormat3 { context); } - inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const { - - unsigned int index = (this+coverage[0]) (IN_CURGLYPH ()); - if (G_LIKELY (index == NOT_COVERED)) - return false; - - return apply_coverage (LOOKUP_ARGS, apply_func); - } - private: USHORT format; /* Format identifier--format = 3 */ USHORT glyphCount; /* Number of glyphs in the input glyph @@ -377,6 +369,26 @@ struct ChainContextLookupContext { char *match_data[3]; }; +static inline bool chain_context_lookup (LOOKUP_ARGS_DEF, + USHORT backtrackCount, + const USHORT backtrack[], + USHORT inputCount, /* Including the first glyph (not matched) */ + const USHORT input[], /* Array of input values--start with second glyph */ + USHORT lookaheadCount, + const USHORT lookahead[], + USHORT lookupCount, + const LookupRecord lookupRecord[], + ChainContextLookupContext &context) +{ + return match_input (LOOKUP_ARGS, + inputCount, input, + context.funcs.match, context.match_data[1], + &context_length) && + apply_lookup (LOOKUP_ARGS, + inputCount, + lookupCount, lookupRecord, + context.funcs.apply); +} struct ChainRule { @@ -388,15 +400,18 @@ struct ChainRule { ((const char *) &backtrack + backtrack.get_size ()); const ArrayOf &lookahead = * (const ArrayOf *) ((const char *) &input + input.get_size ()); - const LookupRecord &lookupRecord = * (const LookupRecord *) - ((const char *) &lookahead + lookahead.get_size ()); -// XXXXXXXXXXXXXXXXXX -// return context_lookup (LOOKUP_ARGS, -// inputCount, -// input, -// lookupCount, -// record, -// context); + const ArrayOf &lookup = * (const ArrayOf *) + ((const char *) &lookahead + lookahead.get_size ()); + return chain_context_lookup (LOOKUP_ARGS, + backtrack.len, + backtrack.array, + input.len, + input.array + 1, + lookahead.len, + lookahead.array, + lookup.len, + lookup.array, + context); return false; } @@ -413,7 +428,7 @@ struct ChainRule { lookaheadX; /* Array of lookahead values's (to be * matched after the input sequence) */ ArrayOf - lookupRecordX; /* Array of LookupRecords--in + lookupX; /* Array of LookupRecords--in * design order) */ }; ASSERT_SIZE (ChainRule, 8); @@ -526,38 +541,38 @@ struct ChainContextFormat3 { private: inline bool apply_coverage (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const { + } + + inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const { + const OffsetArrayOf &input = * (const OffsetArrayOf *) ((const char *) &backtrack + backtrack.get_size ()); + + unsigned int index = (this+input[0]) (IN_CURGLYPH ()); + if (G_LIKELY (index == NOT_COVERED)) + return false; + const OffsetArrayOf &lookahead = * (const OffsetArrayOf *) ((const char *) &input + input.get_size ()); - const LookupRecord &lookupRecord = * (const LookupRecord *) - ((const char *) &lookahead + lookahead.get_size ()); + const ArrayOf &lookup = * (const ArrayOf *) + ((const char *) &lookahead + lookahead.get_size ()); struct ChainContextLookupContext context = { {match_coverage, apply_func}, {(char *) this, (char *) this, (char *) this} }; - /* - XXXXXXXXXXXXXXXXXXXXX - return context_lookup (LOOKUP_ARGS, - glyphCount, - (const USHORT *) (coverage + 1), - lookupCount, - record, - context); - */ + return chain_context_lookup (LOOKUP_ARGS, + backtrack.len, + (USHORT *) backtrack.array, + input.len, + (USHORT *) input.array, + lookahead.len, + (USHORT *) lookahead.array, + lookup.len, + lookup.array, + context); return false; } - inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const { - - /* XXX */ - unsigned int index = 0;//(this+coverage[0]) (IN_CURGLYPH ()); - if (G_LIKELY (index == NOT_COVERED)) - return false; - - return apply_coverage (LOOKUP_ARGS, apply_func); - } - private: USHORT format; /* Format identifier--format = 3 */ OffsetArrayOf @@ -573,7 +588,7 @@ struct ChainContextFormat3 { * in lookahead sequence, in glyph * sequence order */ ArrayOf - lookupRecordX; /* Array of LookupRecords--in + lookupX; /* Array of LookupRecords--in * design order) */ }; ASSERT_SIZE (ChainContextFormat3, 10);