Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Unified Diff: third_party/harfbuzz-ng/src/hb-ot-layout-gsub-table.hh

Issue 9223010: Update harfbuzz-ng to 1a5a91dc0d8bf4b72a2f22dc6300b06ad7000b79. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't use -M option for 'git diff' to patch correctly Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/harfbuzz-ng/src/hb-ot-layout-gsub-table.hh
diff --git a/third_party/harfbuzz-ng/src/hb-ot-layout-gsub-private.hh b/third_party/harfbuzz-ng/src/hb-ot-layout-gsub-table.hh
similarity index 86%
rename from third_party/harfbuzz-ng/src/hb-ot-layout-gsub-private.hh
rename to third_party/harfbuzz-ng/src/hb-ot-layout-gsub-table.hh
index ae1c5f3c5fdbdd12f61d779bda0f0a800ab0a4e6..f7ec3cc0f1a92b776a128ca5d6d23bacfbbe72fd 100644
--- a/third_party/harfbuzz-ng/src/hb-ot-layout-gsub-private.hh
+++ b/third_party/harfbuzz-ng/src/hb-ot-layout-gsub-table.hh
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2007,2008,2009,2010 Red Hat, Inc.
- * Copyright (C) 2010 Google, Inc.
+ * Copyright © 2007,2008,2009,2010 Red Hat, Inc.
+ * Copyright © 2010 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@@ -26,12 +26,11 @@
* Google Author(s): Behdad Esfahbod
*/
-#ifndef HB_OT_LAYOUT_GSUB_PRIVATE_HH
-#define HB_OT_LAYOUT_GSUB_PRIVATE_HH
+#ifndef HB_OT_LAYOUT_GSUB_TABLE_HH
+#define HB_OT_LAYOUT_GSUB_TABLE_HH
#include "hb-ot-layout-gsubgpos-private.hh"
-HB_BEGIN_DECLS
struct SingleSubstFormat1
@@ -43,12 +42,14 @@ struct SingleSubstFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- hb_codepoint_t glyph_id = c->buffer->info[c->buffer->i].codepoint;
+ hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED))
return false;
- glyph_id += deltaGlyphID;
+ /* According to the Adobe Annotated OpenType Suite, result is always
+ * limited to 16bit. */
+ glyph_id = (glyph_id + deltaGlyphID) & 0xFFFF;
c->replace_glyph (glyph_id);
return true;
@@ -80,7 +81,7 @@ struct SingleSubstFormat2
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- hb_codepoint_t glyph_id = c->buffer->info[c->buffer->i].codepoint;
+ hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED))
return false;
@@ -188,7 +189,7 @@ struct MultipleSubstFormat1
{
TRACE_APPLY ();
- unsigned int index = (this+coverage) (c->buffer->info[c->buffer->i].codepoint);
+ unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
if (likely (index == NOT_COVERED))
return false;
@@ -257,8 +258,8 @@ struct AlternateSubstFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- hb_codepoint_t glyph_id = c->buffer->info[c->buffer->i].codepoint;
- hb_mask_t glyph_mask = c->buffer->info[c->buffer->i].mask;
+ hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
+ hb_mask_t glyph_mask = c->buffer->info[c->buffer->idx].mask;
hb_mask_t lookup_mask = c->lookup_mask;
unsigned int index = (this+coverage) (glyph_id);
@@ -342,28 +343,27 @@ struct Ligature
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- unsigned int i, j;
unsigned int count = component.len;
- unsigned int end = MIN (c->buffer->len, c->buffer->i + c->context_length);
- if (unlikely (count < 2 || c->buffer->i + count > end))
+ if (unlikely (count < 2))
+ return false;
+
+ hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, count - 1);
+ if (skippy_iter.has_no_chance ())
return false;
bool first_was_mark = (c->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
bool found_non_mark = false;
- for (i = 1, j = c->buffer->i + 1; i < count; i++, j++)
+ for (unsigned int i = 1; i < count; i++)
{
unsigned int property;
- while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[j], c->lookup_props, &property))
- {
- if (unlikely (j + count - i == end))
- return false;
- j++;
- }
+
+ if (!skippy_iter.next (&property))
+ return false;
found_non_mark |= !(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
- if (likely (c->buffer->info[j].codepoint != component[i]))
+ if (likely (c->buffer->info[skippy_iter.idx].codepoint != component[i]))
return false;
}
@@ -372,12 +372,12 @@ struct Ligature
/* Allocate new ligature id */
unsigned int lig_id = allocate_lig_id (c->buffer);
- c->buffer->info[c->buffer->i].lig_comp() = 0;
- c->buffer->info[c->buffer->i].lig_id() = lig_id;
+ c->buffer->info[c->buffer->idx].lig_comp() = 0;
+ c->buffer->info[c->buffer->idx].lig_id() = lig_id;
- if (j == c->buffer->i + i) /* No input glyphs skipped */
+ if (skippy_iter.idx < c->buffer->idx + count) /* No input glyphs skipped */
{
- c->replace_glyphs_be16 (i, 1, (const uint16_t *) &ligGlyph);
+ c->replace_glyphs_be16 (count, 1, (const uint16_t *) &ligGlyph);
}
else
{
@@ -390,29 +390,23 @@ struct Ligature
value it is later possible to check whether a specific
component value really belongs to a given ligature. */
- for (i = 1; i < count; i++)
+ for (unsigned int i = 1; i < count; i++)
{
- while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_props, NULL))
+ while (c->should_mark_skip_current_glyph ())
{
- c->buffer->info[c->buffer->i].lig_comp() = i;
- c->buffer->info[c->buffer->i].lig_id() = lig_id;
- c->replace_glyph (c->buffer->info[c->buffer->i].codepoint);
+ c->buffer->info[c->buffer->idx].lig_comp() = i;
+ c->buffer->info[c->buffer->idx].lig_id() = lig_id;
+ c->replace_glyph (c->buffer->info[c->buffer->idx].codepoint);
}
/* Skip the base glyph */
- c->buffer->i++;
+ c->buffer->idx++;
}
}
return true;
}
- inline uint16_t allocate_lig_id (hb_buffer_t *buffer) const {
- uint16_t lig_id = buffer->next_serial ();
- if (unlikely (!lig_id)) lig_id = buffer->next_serial (); /* in case of overflows */
- return lig_id;
- }
-
public:
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
@@ -471,7 +465,7 @@ struct LigatureSubstFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- hb_codepoint_t glyph_id = c->buffer->info[c->buffer->i].codepoint;
+ hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED))
@@ -530,9 +524,7 @@ struct LigatureSubst
};
-HB_BEGIN_DECLS
static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index);
-HB_END_DECLS
struct ContextSubst : Context
{
@@ -591,7 +583,7 @@ struct ReverseChainSingleSubstFormat1
if (unlikely (c->context_length != NO_CONTEXT))
return false; /* No chaining to this type */
- unsigned int index = (this+coverage) (c->buffer->info[c->buffer->i].codepoint);
+ unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
if (likely (index == NOT_COVERED))
return false;
@@ -606,8 +598,8 @@ struct ReverseChainSingleSubstFormat1
match_coverage, this,
1))
{
- c->buffer->info[c->buffer->i].codepoint = substitute[index];
- c->buffer->i--; /* Reverse! */
+ c->buffer->info[c->buffer->idx].codepoint = substitute[index];
+ c->buffer->idx--; /* Reverse! */
return true;
}
@@ -762,7 +754,7 @@ struct SubstLookup : Lookup
}
- inline bool apply_once (hb_ot_layout_context_t *layout,
+ inline bool apply_once (hb_face_t *face,
hb_buffer_t *buffer,
hb_mask_t lookup_mask,
unsigned int context_length,
@@ -771,14 +763,15 @@ struct SubstLookup : Lookup
unsigned int lookup_type = get_type ();
hb_apply_context_t c[1] = {{0}};
- c->layout = layout;
+ c->face = face;
c->buffer = buffer;
+ c->direction = buffer->props.direction;
c->lookup_mask = lookup_mask;
c->context_length = context_length;
c->nesting_level_left = nesting_level_left;
c->lookup_props = get_props ();
- if (!_hb_ot_layout_check_glyph_property (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_props, &c->property))
+ if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->info[c->buffer->idx], c->lookup_props, &c->property))
return false;
if (unlikely (lookup_type == SubstLookupSubTable::Extension))
@@ -803,7 +796,7 @@ struct SubstLookup : Lookup
return false;
}
- inline bool apply_string (hb_ot_layout_context_t *layout,
+ inline bool apply_string (hb_face_t *face,
hb_buffer_t *buffer,
hb_mask_t mask) const
{
@@ -816,33 +809,33 @@ struct SubstLookup : Lookup
{
/* in/out forward substitution */
buffer->clear_output ();
- buffer->i = 0;
- while (buffer->i < buffer->len)
+ buffer->idx = 0;
+ while (buffer->idx < buffer->len)
{
- if ((buffer->info[buffer->i].mask & mask) &&
- apply_once (layout, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL))
+ if ((buffer->info[buffer->idx].mask & mask) &&
+ apply_once (face, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL))
ret = true;
else
buffer->next_glyph ();
}
if (ret)
- buffer->swap ();
+ buffer->swap_buffers ();
}
else
{
/* in-place backward substitution */
- buffer->i = buffer->len - 1;
+ buffer->idx = buffer->len - 1;
do
{
- if ((buffer->info[buffer->i].mask & mask) &&
- apply_once (layout, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL))
+ if ((buffer->info[buffer->idx].mask & mask) &&
+ apply_once (face, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL))
ret = true;
else
- buffer->i--;
+ buffer->idx--;
}
- while ((int) buffer->i >= 0);
+ while ((int) buffer->idx >= 0);
}
return ret;
@@ -859,7 +852,7 @@ struct SubstLookup : Lookup
typedef OffsetListOf<SubstLookup> SubstLookupList;
/*
- * GSUB
+ * GSUB -- The Glyph Substitution Table
*/
struct GSUB : GSUBGPOS
@@ -869,11 +862,14 @@ struct GSUB : GSUBGPOS
inline const SubstLookup& get_lookup (unsigned int i) const
{ return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }
- inline bool substitute_lookup (hb_ot_layout_context_t *layout,
+ inline bool substitute_lookup (hb_face_t *face,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_mask_t mask) const
- { return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
+ { return get_lookup (lookup_index).apply_string (face, buffer, mask); }
+
+ static inline void substitute_start (hb_buffer_t *buffer);
+ static inline void substitute_finish (hb_buffer_t *buffer);
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
@@ -886,6 +882,24 @@ struct GSUB : GSUBGPOS
};
+void
+GSUB::substitute_start (hb_buffer_t *buffer)
+{
+ HB_BUFFER_ALLOCATE_VAR (buffer, props_cache);
+ HB_BUFFER_ALLOCATE_VAR (buffer, lig_id);
+ HB_BUFFER_ALLOCATE_VAR (buffer, lig_comp);
+
+ unsigned int count = buffer->len;
+ for (unsigned int i = 0; i < count; i++)
+ buffer->info[i].props_cache() = buffer->info[i].lig_id() = buffer->info[i].lig_comp() = 0;
+}
+
+void
+GSUB::substitute_finish (hb_buffer_t *buffer)
+{
+}
+
+
/* Out-of-class implementation for methods recursing */
inline bool ExtensionSubst::apply (hb_apply_context_t *c) const
@@ -913,7 +927,7 @@ inline bool ExtensionSubst::is_reverse (void) const
static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index)
{
- const GSUB &gsub = *(c->layout->face->ot_layout->gsub);
+ const GSUB &gsub = *(c->face->ot_layout->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
if (unlikely (c->nesting_level_left == 0))
@@ -922,10 +936,9 @@ static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup
if (unlikely (c->context_length < 1))
return false;
- return l.apply_once (c->layout, c->buffer, c->lookup_mask, c->context_length, c->nesting_level_left - 1);
+ return l.apply_once (c->face, c->buffer, c->lookup_mask, c->context_length, c->nesting_level_left - 1);
}
-HB_END_DECLS
-#endif /* HB_OT_LAYOUT_GSUB_PRIVATE_HH */
+#endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ot-layout-gsub-private.hh ('k') | third_party/harfbuzz-ng/src/hb-ot-layout-gsubgpos-private.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698