Towards separating bit allocation from shaping
[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
66 HB_INTERNAL void
67 _hb_buffer_swap (hb_buffer_t *buffer);
68
69 HB_INTERNAL void
70 _hb_buffer_clear_output (hb_buffer_t *buffer);
71
72 HB_INTERNAL void
73 _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
74                               unsigned int num_in,
75                               unsigned int num_out,
76                               const hb_codepoint_t *glyph_data,
77                               unsigned short component,
78                               unsigned short ligID);
79
80 HB_INTERNAL void
81 _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
82                                    unsigned int num_in,
83                                    unsigned int num_out,
84                                    const uint16_t *glyph_data_be,
85                                    unsigned short component,
86                                    unsigned short ligID);
87
88 HB_INTERNAL void
89 _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
90                              hb_codepoint_t glyph_index,
91                              unsigned short component,
92                              unsigned short ligID);
93
94 HB_INTERNAL void
95 _hb_buffer_next_glyph (hb_buffer_t *buffer);
96
97
98 HB_INTERNAL void
99 _hb_buffer_clear_masks (hb_buffer_t *buffer);
100
101 HB_INTERNAL void
102 _hb_buffer_set_masks (hb_buffer_t *buffer,
103                       hb_mask_t    value,
104                       hb_mask_t    mask,
105                       unsigned int cluster_start,
106                       unsigned int cluster_end);
107
108
109 struct _hb_buffer_t {
110   hb_reference_count_t ref_count;
111
112   /* Information about how the text in the buffer should be treated */
113   hb_unicode_funcs_t *unicode;
114
115   struct properties_t {
116     hb_direction_t      direction;
117     hb_script_t         script;
118     hb_language_t       language;
119   } props;
120
121   /* Buffer contents */
122
123   unsigned int allocated; /* Length of allocated arrays */
124
125   hb_bool_t have_output; /* Whether we have an output buffer going on */
126   hb_bool_t have_positions; /* Whether we have positions */
127   hb_bool_t in_error; /* Allocation failed */
128
129   unsigned int i; /* Cursor into ->info and ->pos arrays */
130   unsigned int len; /* Length of ->info and ->pos arrays */
131   unsigned int out_len; /* Length of ->out array */
132
133   hb_internal_glyph_info_t     *info;
134   hb_internal_glyph_info_t     *out_info;
135   hb_internal_glyph_position_t *pos;
136
137   /* Other stuff */
138
139   unsigned int max_lig_id;
140
141
142   /* Methods */
143   inline unsigned int allocate_lig_id (void) { return max_lig_id++; }
144   inline void swap (void) { _hb_buffer_swap (this); }
145   inline void clear_output (void) { _hb_buffer_clear_output (this); }
146   inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
147   inline void add_output_glyphs (unsigned int num_in,
148                                  unsigned int num_out,
149                                  const hb_codepoint_t *glyph_data,
150                                  unsigned short component,
151                                  unsigned short ligID)
152   { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data, component, ligID); }
153   inline void add_output_glyphs_be16 (unsigned int num_in,
154                                       unsigned int num_out,
155                                       const uint16_t *glyph_data_be,
156                                       unsigned short component,
157                                       unsigned short ligID)
158   { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be, component, ligID); }
159   inline void add_output_glyph (hb_codepoint_t glyph_index,
160                                 unsigned short component = 0xFFFF,
161                                 unsigned short ligID = 0xFFFF)
162   { _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); }
163   inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); }
164
165   inline void clear_masks (void) { _hb_buffer_clear_masks (this); }
166   inline void set_masks (hb_mask_t    value,
167                          hb_mask_t mask,
168                          unsigned int cluster_start,
169                          unsigned int cluster_end)
170   { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); }
171
172 };
173
174
175 HB_END_DECLS
176
177 #endif /* HB_BUFFER_PRIVATE_HH */