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