Minor renaming
[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 #define component() var1.u16[0]
40 #define lig_id() var1.u16[1]
41 #define gproperty() var2.u32
42 #define back() var.u16[0] /* number of glyphs to go back for drawing current glyph */
43 #define cursive_chain() var.i16[1] /* character to which this connects, may be positive or negative */
44
45 ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20);
46 ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
47
48 typedef struct _hb_segment_properties_t {
49     hb_direction_t      direction;
50     hb_script_t         script;
51     hb_language_t       language;
52 } hb_segment_properties_t;
53
54
55 HB_INTERNAL void
56 _hb_buffer_swap (hb_buffer_t *buffer);
57
58 HB_INTERNAL void
59 _hb_buffer_clear_output (hb_buffer_t *buffer);
60
61 HB_INTERNAL void
62 _hb_buffer_replace_glyphs (hb_buffer_t *buffer,
63                            unsigned int num_in,
64                            unsigned int num_out,
65                            const hb_codepoint_t *glyph_data);
66
67 HB_INTERNAL void
68 _hb_buffer_replace_glyphs_be16 (hb_buffer_t *buffer,
69                                 unsigned int num_in,
70                                 unsigned int num_out,
71                                 const uint16_t *glyph_data_be);
72
73 HB_INTERNAL void
74 _hb_buffer_replace_glyph (hb_buffer_t *buffer,
75                           hb_codepoint_t glyph_index);
76
77 HB_INTERNAL void
78 _hb_buffer_next_glyph (hb_buffer_t *buffer);
79
80
81 HB_INTERNAL void
82 _hb_buffer_reset_masks (hb_buffer_t *buffer,
83                         hb_mask_t    mask);
84
85 HB_INTERNAL void
86 _hb_buffer_add_masks (hb_buffer_t *buffer,
87                       hb_mask_t    mask);
88
89 HB_INTERNAL void
90 _hb_buffer_set_masks (hb_buffer_t *buffer,
91                       hb_mask_t    value,
92                       hb_mask_t    mask,
93                       unsigned int cluster_start,
94                       unsigned int cluster_end);
95
96
97 struct _hb_buffer_t {
98   hb_reference_count_t ref_count;
99
100   /* Information about how the text in the buffer should be treated */
101
102   hb_unicode_funcs_t *unicode; /* Unicode functions */
103   hb_segment_properties_t props; /* Script, language, direction */
104
105   /* Buffer contents */
106
107   unsigned int allocated; /* Length of allocated arrays */
108
109   hb_bool_t have_output; /* Whether we have an output buffer going on */
110   hb_bool_t have_positions; /* Whether we have positions */
111   hb_bool_t in_error; /* Allocation failed */
112
113   unsigned int i; /* Cursor into ->info and ->pos arrays */
114   unsigned int len; /* Length of ->info and ->pos arrays */
115   unsigned int out_len; /* Length of ->out array */
116
117   hb_glyph_info_t     *info;
118   hb_glyph_info_t     *out_info;
119   hb_glyph_position_t *pos;
120
121   /* Other stuff */
122
123   unsigned int max_lig_id;
124
125
126   /* Methods */
127   inline unsigned int allocate_lig_id (void) { return max_lig_id++; }
128   inline void swap (void) { _hb_buffer_swap (this); }
129   inline void clear_output (void) { _hb_buffer_clear_output (this); }
130   inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
131   inline void replace_glyphs (unsigned int num_in,
132                               unsigned int num_out,
133                               const hb_codepoint_t *glyph_data)
134   { _hb_buffer_replace_glyphs (this, num_in, num_out, glyph_data); }
135   inline void replace_glyphs_be16 (unsigned int num_in,
136                                    unsigned int num_out,
137                                    const uint16_t *glyph_data_be)
138   { _hb_buffer_replace_glyphs_be16 (this, num_in, num_out, glyph_data_be); }
139   inline void replace_glyph (hb_codepoint_t glyph_index)
140   { _hb_buffer_replace_glyph (this, glyph_index); }
141
142   inline void reset_masks (hb_mask_t mask)
143   {
144     for (unsigned int i = 0; i < len; i++)
145       info[i].mask = mask;
146   }
147   inline void add_masks (hb_mask_t mask)
148   {
149     for (unsigned int i = 0; i < len; i++)
150       info[i].mask |= mask;
151   }
152   inline void set_masks (hb_mask_t value,
153                          hb_mask_t mask,
154                          unsigned int cluster_start,
155                          unsigned int cluster_end)
156   { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); }
157
158 };
159
160
161 HB_END_DECLS
162
163 #endif /* HB_BUFFER_PRIVATE_HH */