diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2009-08-01 22:19:06 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2009-08-01 22:21:47 -0400 |
commit | b522838694c10d2f4055ff0a22167c0ace546e04 (patch) | |
tree | 432344daf881e637d411c39f0ba31fad927d3121 /pango/opentype/hb-buffer.c | |
parent | b0285768b9ea64f0d523edf14232ab870deacb9c (diff) | |
download | pango-b522838694c10d2f4055ff0a22167c0ace546e04.tar.gz |
[HB] Port buffert to new object API
Diffstat (limited to 'pango/opentype/hb-buffer.c')
-rw-r--r-- | pango/opentype/hb-buffer.c | 65 |
1 files changed, 50 insertions, 15 deletions
diff --git a/pango/opentype/hb-buffer.c b/pango/opentype/hb-buffer.c index 89887fcb..a4b92d75 100644 --- a/pango/opentype/hb-buffer.c +++ b/pango/opentype/hb-buffer.c @@ -29,6 +29,10 @@ #include <string.h> +static hb_buffer_t _hb_buffer_nil = { + HB_REFERENCE_COUNT_INVALID /* ref_count */ +}; + /* Here is how the buffer works internally: * * There are two string pointers: in_string and out_string. They @@ -69,33 +73,40 @@ hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size) /* Public API */ hb_buffer_t * -hb_buffer_new (unsigned int allocation_size) +hb_buffer_create (unsigned int pre_alloc_size) { hb_buffer_t *buffer; - buffer = calloc (1, sizeof (hb_buffer_t)); - if (HB_UNLIKELY (!buffer)) - return NULL; + if (!HB_OBJECT_DO_CREATE (buffer)) + return &_hb_buffer_nil; - buffer->allocated = 0; - buffer->in_string = NULL; - buffer->alt_string = NULL; - buffer->positions = NULL; + if (pre_alloc_size) + hb_buffer_ensure(buffer, pre_alloc_size); - hb_buffer_clear (buffer); + return buffer; +} - if (allocation_size) - hb_buffer_ensure(buffer, allocation_size); +hb_buffer_t * +hb_buffer_reference (hb_buffer_t *buffer) +{ + HB_OBJECT_DO_REFERENCE (buffer); +} - return buffer; +unsigned int +hb_buffer_get_reference_count (hb_buffer_t *buffer) +{ + HB_OBJECT_DO_GET_REFERENCE_COUNT (buffer); } void -hb_buffer_free (hb_buffer_t *buffer) +hb_buffer_destroy (hb_buffer_t *buffer) { + HB_OBJECT_DO_DESTROY (buffer); + free (buffer->in_string); free (buffer->alt_string); free (buffer->positions); + free (buffer); } @@ -185,8 +196,8 @@ _hb_buffer_clear_output (hb_buffer_t *buffer) buffer->out_string = buffer->in_string; } -HB_INTERNAL void -_hb_buffer_clear_positions (hb_buffer_t *buffer) +void +hb_buffer_clear_positions (hb_buffer_t *buffer) { _hb_buffer_clear_output (buffer); @@ -340,3 +351,27 @@ _hb_buffer_allocate_lig_id (hb_buffer_t *buffer) { return ++buffer->max_lig_id; } + + +unsigned int +hb_buffer_get_len (hb_buffer_t *buffer) +{ + return buffer->in_length; +} + +/* Return value valid as long as buffer not modified */ +hb_glyph_info_t * +hb_buffer_get_glyph_infos (hb_buffer_t *buffer) +{ + return buffer->in_string; +} + +/* Return value valid as long as buffer not modified */ +hb_glyph_position_t * +hb_buffer_get_glyph_positions (hb_buffer_t *buffer) +{ + if (buffer->in_length && !buffer->positions) + hb_buffer_clear_positions (buffer); + + return buffer->positions; +} |