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

Side by Side Diff: third_party/harfbuzz-ng/src/hb-ot-map-private.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, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009,2010 Red Hat, Inc. 2 * Copyright © 2009,2010 Red Hat, Inc.
3 * Copyright (C) 2010 Google, Inc. 3 * Copyright © 2010,2011 Google, Inc.
4 * 4 *
5 * This is part of HarfBuzz, a text shaping library. 5 * This is part of HarfBuzz, a text shaping library.
6 * 6 *
7 * Permission is hereby granted, without written agreement and without 7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this 8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the 9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in 10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software. 11 * all copies of this software.
12 * 12 *
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
(...skipping 12 matching lines...) Expand all
26 * Google Author(s): Behdad Esfahbod 26 * Google Author(s): Behdad Esfahbod
27 */ 27 */
28 28
29 #ifndef HB_OT_MAP_PRIVATE_HH 29 #ifndef HB_OT_MAP_PRIVATE_HH
30 #define HB_OT_MAP_PRIVATE_HH 30 #define HB_OT_MAP_PRIVATE_HH
31 31
32 #include "hb-buffer-private.hh" 32 #include "hb-buffer-private.hh"
33 33
34 #include "hb-ot-layout.h" 34 #include "hb-ot-layout.h"
35 35
36 HB_BEGIN_DECLS
37 36
38 37
39 #define MAX_FEATURES 100 /* FIXME */
40 #define MAX_LOOKUPS 1000 /* FIXME */
41
42 static const hb_tag_t table_tags[2] = {HB_OT_TAG_GSUB, HB_OT_TAG_GPOS}; 38 static const hb_tag_t table_tags[2] = {HB_OT_TAG_GSUB, HB_OT_TAG_GPOS};
43 39
44 struct hb_ot_map_t { 40 struct hb_ot_map_t
41 {
42 friend struct hb_ot_map_builder_t;
43
44 public:
45
46 hb_ot_map_t (void) { memset (this, 0, sizeof (*this)); }
47
48 typedef void (*gsub_pause_func_t) (const hb_ot_map_t *map, hb_face_t *face, hb _buffer_t *buffer, void *user_data);
49 typedef void (*gpos_pause_func_t) (const hb_ot_map_t *map, hb_font_t *font, hb _buffer_t *buffer, void *user_data);
50
51 inline hb_mask_t get_global_mask (void) const { return global_mask; }
52
53 inline hb_mask_t get_mask (hb_tag_t tag, unsigned int *shift = NULL) const {
54 const feature_map_t *map = features.bsearch (&tag);
55 if (shift) *shift = map ? map->shift : 0;
56 return map ? map->mask : 0;
57 }
58
59 inline hb_mask_t get_1_mask (hb_tag_t tag) const {
60 const feature_map_t *map = features.bsearch (&tag);
61 return map ? map->_1_mask : 0;
62 }
63
64 inline hb_tag_t get_chosen_script (unsigned int table_index) const
65 { return chosen_script[table_index]; }
66
67 inline void substitute (hb_face_t *face, hb_buffer_t *buffer) const
68 { apply (0, (hb_ot_map_t::apply_lookup_func_t) hb_ot_layout_substitute_lookup, face, buffer); }
69 inline void position (hb_font_t *font, hb_buffer_t *buffer) const
70 { apply (1, (hb_ot_map_t::apply_lookup_func_t) hb_ot_layout_position_lookup, f ont, buffer); }
71
72 inline void finish (void) {
73 features.finish ();
74 lookups[0].finish ();
75 lookups[1].finish ();
76 pauses[0].finish ();
77 pauses[1].finish ();
78 }
45 79
46 private: 80 private:
47 81
48 struct feature_info_t {
49 hb_tag_t tag;
50 unsigned int seq; /* sequence#, used for stable sorting only */
51 unsigned int max_value;
52 bool global; /* whether the feature applies value to every glyph in the buff er */
53 unsigned int default_value; /* for non-global features, what should the unse t glyphs take */
54
55 static int cmp (const feature_info_t *a, const feature_info_t *b)
56 { return (a->tag != b->tag) ? (a->tag < b->tag ? -1 : 1) : (a->seq < b->seq ? -1 : 1); }
57 };
58
59 struct feature_map_t { 82 struct feature_map_t {
60 hb_tag_t tag; /* should be first for our bsearch to work */ 83 hb_tag_t tag; /* should be first for our bsearch to work */
61 unsigned int index[2]; /* GSUB, GPOS */ 84 unsigned int index[2]; /* GSUB/GPOS */
85 unsigned int stage[2]; /* GSUB/GPOS */
62 unsigned int shift; 86 unsigned int shift;
63 hb_mask_t mask; 87 hb_mask_t mask;
64 hb_mask_t _1_mask; /* mask for value=1, for quick access */ 88 hb_mask_t _1_mask; /* mask for value=1, for quick access */
65 89
66 static int cmp (const feature_map_t *a, const feature_map_t *b) 90 static int cmp (const feature_map_t *a, const feature_map_t *b)
67 { return a->tag < b->tag ? -1 : a->tag > b->tag ? 1 : 0; } 91 { return a->tag < b->tag ? -1 : a->tag > b->tag ? 1 : 0; }
68 }; 92 };
69 93
70 struct lookup_map_t { 94 struct lookup_map_t {
71 unsigned int index; 95 unsigned int index;
72 hb_mask_t mask; 96 hb_mask_t mask;
73 97
74 static int cmp (const lookup_map_t *a, const lookup_map_t *b) 98 static int cmp (const lookup_map_t *a, const lookup_map_t *b)
75 { return a->index < b->index ? -1 : a->index > b->index ? 1 : 0; } 99 { return a->index < b->index ? -1 : a->index > b->index ? 1 : 0; }
76 }; 100 };
77 101
102 typedef void (*pause_func_t) (const hb_ot_map_t *map, void *face_or_font, hb_b uffer_t *buffer, void *user_data);
103 typedef struct {
104 pause_func_t func;
105 void *user_data;
106 } pause_callback_t;
107
108 struct pause_map_t {
109 unsigned int num_lookups; /* Cumulative */
110 pause_callback_t callback;
111 };
112
113 typedef hb_bool_t (*apply_lookup_func_t) (void *face_or_font,
114 hb_buffer_t *buffer,
115 unsigned int lookup_index,
116 hb_mask_t mask);
117
78 HB_INTERNAL void add_lookups (hb_face_t *face, 118 HB_INTERNAL void add_lookups (hb_face_t *face,
79 unsigned int table_index, 119 unsigned int table_index,
80 unsigned int feature_index, 120 unsigned int feature_index,
81 hb_mask_t mask); 121 hb_mask_t mask);
82 122
123 HB_INTERNAL void apply (unsigned int table_index,
124 hb_ot_map_t::apply_lookup_func_t apply_lookup_func,
125 void *face_or_font,
126 hb_buffer_t *buffer) const;
83 127
128 hb_mask_t global_mask;
129
130 hb_tag_t chosen_script[2];
131 hb_prealloced_array_t<feature_map_t, 8> features;
132 hb_prealloced_array_t<lookup_map_t, 32> lookups[2]; /* GSUB/GPOS */
133 hb_prealloced_array_t<pause_map_t, 1> pauses[2]; /* GSUB/GPOS */
134 };
135
136
137 struct hb_ot_map_builder_t
138 {
84 public: 139 public:
85 140
86 hb_ot_map_t (void) : feature_count (0) {} 141 hb_ot_map_builder_t (void) { memset (this, 0, sizeof (*this)); }
87 142
88 void add_feature (hb_tag_t tag, unsigned int value, bool global) 143 HB_INTERNAL void add_feature (hb_tag_t tag, unsigned int value, bool global);
89 {
90 feature_info_t *info = &feature_infos[feature_count++];
91 info->tag = tag;
92 info->seq = feature_count;
93 info->max_value = value;
94 info->global = global;
95 info->default_value = global ? value : 0;
96 }
97 144
98 inline void add_bool_feature (hb_tag_t tag, bool global = true) 145 inline void add_bool_feature (hb_tag_t tag, bool global = true)
99 { add_feature (tag, 1, global); } 146 { add_feature (tag, 1, global); }
100 147
148 inline void add_gsub_pause (hb_ot_map_t::gsub_pause_func_t pause_func, void *u ser_data)
149 { add_pause (0, (hb_ot_map_t::pause_func_t) pause_func, user_data); }
150 inline void add_gpos_pause (hb_ot_map_t::gpos_pause_func_t pause_func, void *u ser_data)
151 { add_pause (1, (hb_ot_map_t::pause_func_t) pause_func, user_data); }
152
101 HB_INTERNAL void compile (hb_face_t *face, 153 HB_INTERNAL void compile (hb_face_t *face,
102 » » » const hb_segment_properties_t *props); 154 » » » const hb_segment_properties_t *props,
155 » » » struct hb_ot_map_t &m);
103 156
104 inline hb_mask_t get_global_mask (void) const { return global_mask; } 157 inline void finish (void) {
105 158 feature_infos.finish ();
106 inline hb_mask_t get_mask (hb_tag_t tag, unsigned int *shift = NULL) const { 159 pauses[0].finish ();
107 const feature_map_t *map = (const feature_map_t *) bsearch (&tag, feature_ma ps, feature_count, sizeof (feature_maps[0]), (hb_compare_func_t) feature_map_t:: cmp); 160 pauses[1].finish ();
108 if (shift) *shift = map ? map->shift : 0;
109 return map ? map->mask : 0;
110 }
111
112 inline hb_mask_t get_1_mask (hb_tag_t tag) const {
113 const feature_map_t *map = (const feature_map_t *) bsearch (&tag, feature_ma ps, feature_count, sizeof (feature_maps[0]), (hb_compare_func_t) feature_map_t:: cmp);
114 return map ? map->_1_mask : 0;
115 }
116
117 inline void substitute (hb_face_t *face, hb_buffer_t *buffer) const {
118 for (unsigned int i = 0; i < lookup_count[0]; i++)
119 hb_ot_layout_substitute_lookup (face, buffer, lookup_maps[0][i].index, loo kup_maps[0][i].mask);
120 }
121
122 inline void position (hb_font_t *font, hb_face_t *face, hb_buffer_t *buffer) c onst {
123 for (unsigned int i = 0; i < lookup_count[1]; i++)
124 hb_ot_layout_position_lookup (font, face, buffer, lookup_maps[1][i].index, lookup_maps[1][i].mask);
125 } 161 }
126 162
127 private: 163 private:
128 164
129 hb_mask_t global_mask; 165 struct feature_info_t {
166 hb_tag_t tag;
167 unsigned int seq; /* sequence#, used for stable sorting only */
168 unsigned int max_value;
169 bool global; /* whether the feature applies value to every glyph in the buff er */
170 unsigned int default_value; /* for non-global features, what should the unse t glyphs take */
171 unsigned int stage[2]; /* GSUB/GPOS */
130 172
131 unsigned int feature_count; 173 static int cmp (const feature_info_t *a, const feature_info_t *b)
132 feature_info_t feature_infos[MAX_FEATURES]; /* used before compile() only */ 174 { return (a->tag != b->tag) ? (a->tag < b->tag ? -1 : 1) : (a->seq < b->seq ? -1 : 1); }
133 feature_map_t feature_maps[MAX_FEATURES]; 175 };
134 176
135 lookup_map_t lookup_maps[2][MAX_LOOKUPS]; /* GSUB/GPOS */ 177 struct pause_info_t {
136 unsigned int lookup_count[2]; 178 unsigned int stage;
179 hb_ot_map_t::pause_callback_t callback;
180 };
181
182 HB_INTERNAL void add_pause (unsigned int table_index, hb_ot_map_t::pause_func_ t pause_func, void *user_data);
183
184 unsigned int current_stage[2]; /* GSUB/GPOS */
185 hb_prealloced_array_t<feature_info_t,16> feature_infos;
186 hb_prealloced_array_t<pause_info_t, 1> pauses[2]; /* GSUB/GPOS */
137 }; 187 };
138 188
139 189
140 190
141 HB_END_DECLS
142
143 #endif /* HB_OT_MAP_PRIVATE_HH */ 191 #endif /* HB_OT_MAP_PRIVATE_HH */
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ot-map.cc ('k') | third_party/harfbuzz-ng/src/hb-ot-maxp-table.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698