Index: third_party/harfbuzz-ng/src/hb-ot-map.cc |
=================================================================== |
--- third_party/harfbuzz-ng/src/hb-ot-map.cc (리비전 201894) |
+++ third_party/harfbuzz-ng/src/hb-ot-map.cc (작업 사본) |
@@ -1,6 +1,6 @@ |
/* |
* Copyright © 2009,2010 Red Hat, Inc. |
- * Copyright © 2010,2011 Google, Inc. |
+ * Copyright © 2010,2011,2013 Google, Inc. |
* |
* This is part of HarfBuzz, a text shaping library. |
* |
@@ -28,7 +28,9 @@ |
#include "hb-ot-map-private.hh" |
+#include "hb-ot-layout-private.hh" |
+ |
void |
hb_ot_map_t::add_lookups (hb_face_t *face, |
unsigned int table_index, |
@@ -100,55 +102,50 @@ |
info->stage[1] = current_stage[1]; |
} |
-/* Keep the next two functions in sync. */ |
- |
-void hb_ot_map_t::substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const |
+inline void hb_ot_map_t::apply (unsigned int table_index, |
+ const hb_ot_shape_plan_t *plan, |
+ hb_font_t *font, |
+ hb_buffer_t *buffer) const |
{ |
- const unsigned int table_index = 0; |
unsigned int i = 0; |
- for (unsigned int pause_index = 0; pause_index < pauses[table_index].len; pause_index++) { |
- const pause_map_t *pause = &pauses[table_index][pause_index]; |
- for (; i < pause->num_lookups; i++) |
- hb_ot_layout_substitute_lookup (font, buffer, |
- lookups[table_index][i].index, |
- lookups[table_index][i].mask, |
- lookups[table_index][i].auto_zwj); |
+ for (unsigned int stage_index = 0; stage_index < stages[table_index].len; stage_index++) { |
+ const stage_map_t *stage = &stages[table_index][stage_index]; |
+ for (; i < stage->last_lookup; i++) |
+ switch (table_index) |
+ { |
+ case 0: |
+ hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].index, |
+ lookups[table_index][i].mask, |
+ lookups[table_index][i].auto_zwj); |
+ break; |
- buffer->clear_output (); |
+ case 1: |
+ hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index, |
+ lookups[table_index][i].mask, |
+ lookups[table_index][i].auto_zwj); |
+ break; |
+ } |
- if (pause->callback) |
- pause->callback (plan, font, buffer); |
+ if (stage->pause_func) |
+ { |
+ buffer->clear_output (); |
+ stage->pause_func (plan, font, buffer); |
+ } |
} |
+} |
- for (; i < lookups[table_index].len; i++) |
- hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].index, |
- lookups[table_index][i].mask, |
- lookups[table_index][i].auto_zwj); |
+void hb_ot_map_t::substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const |
+{ |
+ apply (0, plan, font, buffer); |
} |
void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const |
{ |
- const unsigned int table_index = 1; |
- unsigned int i = 0; |
- |
- for (unsigned int pause_index = 0; pause_index < pauses[table_index].len; pause_index++) { |
- const pause_map_t *pause = &pauses[table_index][pause_index]; |
- for (; i < pause->num_lookups; i++) |
- hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index, |
- lookups[table_index][i].mask, |
- lookups[table_index][i].auto_zwj); |
- |
- if (pause->callback) |
- pause->callback (plan, font, buffer); |
- } |
- |
- for (; i < lookups[table_index].len; i++) |
- hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index, |
- lookups[table_index][i].mask, |
- lookups[table_index][i].auto_zwj); |
+ apply (1, plan, font, buffer); |
} |
+ |
void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_out) const |
{ |
for (unsigned int i = 0; i < lookups[table_index].len; i++) |
@@ -157,10 +154,10 @@ |
void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func) |
{ |
- pause_info_t *p = pauses[table_index].push (); |
- if (likely (p)) { |
- p->stage = current_stage[table_index]; |
- p->callback = pause_func; |
+ stage_info_t *s = stages[table_index].push (); |
+ if (likely (s)) { |
+ s->index = current_stage[table_index]; |
+ s->pause_func = pause_func; |
} |
current_stage[table_index]++; |
@@ -277,7 +274,7 @@ |
&required_feature_index)) |
m.add_lookups (face, table_index, required_feature_index, 1, true); |
- unsigned int pause_index = 0; |
+ unsigned int stage_index = 0; |
unsigned int last_num_lookups = 0; |
for (unsigned stage = 0; stage < current_stage[table_index]; stage++) |
{ |
@@ -307,14 +304,14 @@ |
last_num_lookups = m.lookups[table_index].len; |
- if (pause_index < pauses[table_index].len && pauses[table_index][pause_index].stage == stage) { |
- hb_ot_map_t::pause_map_t *pause_map = m.pauses[table_index].push (); |
- if (likely (pause_map)) { |
- pause_map->num_lookups = last_num_lookups; |
- pause_map->callback = pauses[table_index][pause_index].callback; |
+ if (stage_index < stages[table_index].len && stages[table_index][stage_index].index == stage) { |
+ hb_ot_map_t::stage_map_t *stage_map = m.stages[table_index].push (); |
+ if (likely (stage_map)) { |
+ stage_map->last_lookup = last_num_lookups; |
+ stage_map->pause_func = stages[table_index][stage_index].pause_func; |
} |
- pause_index++; |
+ stage_index++; |
} |
} |
} |