Massage mask setting a bit more
[profile/ivi/org.tizen.video-player.git] / src / hb-buffer-private.hh
1 /*
2  * Copyright (C) 1998-2004  David Turner and Werner Lemberg
3  * Copyright (C) 2004,2007,2009,2010  Red Hat, Inc.
4  *
5  * This is part of HarfBuzz, a text shaping library.
6  *
7  * Permission is hereby granted, without written agreement and without
8  * license or royalty fees, to use, copy, modify, and distribute this
9  * software and its documentation for any purpose, provided that the
10  * above copyright notice and the following two paragraphs appear in
11  * all copies of this software.
12  *
13  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17  * DAMAGE.
18  *
19  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24  *
25  * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
26  */
27
28 #ifndef HB_BUFFER_PRIVATE_HH
29 #define HB_BUFFER_PRIVATE_HH
30
31 #include "hb-private.h"
32 #include "hb-buffer.h"
33 #include "hb-unicode-private.h"
34
35 HB_BEGIN_DECLS
36
37
38 #define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
39
40
41 typedef struct _hb_internal_glyph_info_t {
42   hb_codepoint_t codepoint;
43   hb_mask_t      mask;
44   uint32_t       cluster;
45   uint16_t       component;
46   uint16_t       lig_id;
47   uint32_t       gproperty;
48 } hb_internal_glyph_info_t;
49
50 typedef struct _hb_internal_glyph_position_t {
51   hb_position_t  x_advance;
52   hb_position_t  y_advance;
53   hb_position_t  x_offset;
54   hb_position_t  y_offset;
55   uint32_t       back : 16;             /* number of glyphs to go back
56                                            for drawing current glyph */
57   int32_t        cursive_chain : 16;    /* character to which this connects,
58                                            may be positive or negative */
59 } hb_internal_glyph_position_t;
60
61 ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t));
62 ASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t));
63 ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
64
65 typedef struct _hb_segment_properties_t {
66     hb_direction_t      direction;
67     hb_script_t         script;
68     hb_language_t       language;
69 } hb_segment_properties_t;
70
71
72 HB_INTERNAL void
73 _hb_buffer_swap (hb_buffer_t *buffer);
74
75 HB_INTERNAL void
76 _hb_buffer_clear_output (hb_buffer_t *buffer);
77
78 HB_INTERNAL void
79 _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
80                               unsigned int num_in,
81                               unsigned int num_out,
82                               const hb_codepoint_t *glyph_data,
83                               unsigned short component,
84                               unsigned short ligID);
85
86 HB_INTERNAL void
87 _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
88                                    unsigned int num_in,
89                                    unsigned int num_out,
90                                    const uint16_t *glyph_data_be,
91                                    unsigned short component,
92                                    unsigned short ligID);
93
94 HB_INTERNAL void
95 _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
96                              hb_codepoint_t glyph_index,
97                              unsigned short component,
98                              unsigned short ligID);
99
100 HB_INTERNAL void
101 _hb_buffer_next_glyph (hb_buffer_t *buffer);
102
103
104 HB_INTERNAL void
105 _hb_buffer_reset_masks (hb_buffer_t *buffer,
106                         hb_mask_t    mask);
107
108 HB_INTERNAL void
109 _hb_buffer_add_masks (hb_buffer_t *buffer,
110                       hb_mask_t    mask);
111
112 HB_INTERNAL void
113 _hb_buffer_set_masks (hb_buffer_t *buffer,
114                       hb_mask_t    value,
115                       hb_mask_t    mask,
116                       unsigned int cluster_start,
117                       unsigned int cluster_end);
118
119
120 struct _hb_buffer_t {
121   hb_reference_count_t ref_count;
122
123   /* Information about how the text in the buffer should be treated */
124
125   hb_unicode_funcs_t *unicode; /* Unicode functions */
126   hb_segment_properties_t props; /* Script, language, direction */
127
128   /* Buffer contents */
129
130   unsigned int allocated; /* Length of allocated arrays */
131
132   hb_bool_t have_output; /* Whether we have an output buffer going on */
133   hb_bool_t have_positions; /* Whether we have positions */
134   hb_bool_t in_error; /* Allocation failed */
135
136   unsigned int i; /* Cursor into ->info and ->pos arrays */
137   unsigned int len; /* Length of ->info and ->pos arrays */
138   unsigned int out_len; /* Length of ->out array */
139
140   hb_internal_glyph_info_t     *info;
141   hb_internal_glyph_info_t     *out_info;
142   hb_internal_glyph_position_t *pos;
143
144   /* Other stuff */
145
146   unsigned int max_lig_id;
147
148
149   /* Methods */
150   inline unsigned int allocate_lig_id (void) { return max_lig_id++; }
151   inline void swap (void) { _hb_buffer_swap (this); }
152   inline void clear_output (void) { _hb_buffer_clear_output (this); }
153   inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
154   inline void add_output_glyphs (unsigned int num_in,
155                                  unsigned int num_out,
156                                  const hb_codepoint_t *glyph_data,
157                                  unsigned short component,
158                                  unsigned short ligID)
159   { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data, component, ligID); }
160   inline void add_output_glyphs_be16 (unsigned int num_in,
161                                       unsigned int num_out,
162                                       const uint16_t *glyph_data_be,
163                                       unsigned short component,
164                                       unsigned short ligID)
165   { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be, component, ligID); }
166   inline void add_output_glyph (hb_codepoint_t glyph_index,
167                                 unsigned short component = 0xFFFF,
168                                 unsigned short ligID = 0xFFFF)
169   { _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); }
170   inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); }
171
172   inline void reset_masks (hb_mask_t mask)
173   {
174     for (unsigned int i = 0; i < len; i++)
175       info[i].mask = mask;
176   }
177   inline void add_masks (hb_mask_t mask)
178   {
179     for (unsigned int i = 0; i < len; i++)
180       info[i].mask |= mask;
181   }
182   inline void set_masks (hb_mask_t value,
183                          hb_mask_t mask,
184                          unsigned int cluster_start,
185                          unsigned int cluster_end)
186   { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); }
187
188 };
189
190
191 HB_END_DECLS
192
193 #endif /* HB_BUFFER_PRIVATE_HH */