[HB] Port buffert to new object API
This commit is contained in:
parent
0cc7bc59ea
commit
11fbb5487d
|
@ -35,15 +35,33 @@ HB_BEGIN_DECLS
|
||||||
|
|
||||||
#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
|
#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
|
||||||
|
|
||||||
|
|
||||||
|
struct _hb_buffer_t {
|
||||||
|
hb_reference_count_t ref_count;
|
||||||
|
|
||||||
|
unsigned int allocated;
|
||||||
|
|
||||||
|
unsigned int in_length;
|
||||||
|
unsigned int out_length;
|
||||||
|
unsigned int in_pos;
|
||||||
|
unsigned int out_pos;
|
||||||
|
|
||||||
|
hb_glyph_info_t *in_string;
|
||||||
|
hb_glyph_info_t *out_string;
|
||||||
|
hb_glyph_info_t *alt_string;
|
||||||
|
hb_glyph_position_t *positions;
|
||||||
|
|
||||||
|
hb_direction_t direction;
|
||||||
|
unsigned int max_lig_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_hb_buffer_swap (hb_buffer_t *buffer);
|
_hb_buffer_swap (hb_buffer_t *buffer);
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_hb_buffer_clear_output (hb_buffer_t *buffer);
|
_hb_buffer_clear_output (hb_buffer_t *buffer);
|
||||||
|
|
||||||
HB_INTERNAL void
|
|
||||||
_hb_buffer_clear_positions (hb_buffer_t *buffer);
|
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
||||||
unsigned int num_in,
|
unsigned int num_in,
|
||||||
|
|
|
@ -29,6 +29,10 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
static hb_buffer_t _hb_buffer_nil = {
|
||||||
|
HB_REFERENCE_COUNT_INVALID /* ref_count */
|
||||||
|
};
|
||||||
|
|
||||||
/* Here is how the buffer works internally:
|
/* Here is how the buffer works internally:
|
||||||
*
|
*
|
||||||
* There are two string pointers: in_string and out_string. They
|
* 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 */
|
/* Public API */
|
||||||
|
|
||||||
hb_buffer_t *
|
hb_buffer_t *
|
||||||
hb_buffer_new (unsigned int allocation_size)
|
hb_buffer_create (unsigned int pre_alloc_size)
|
||||||
{
|
{
|
||||||
hb_buffer_t *buffer;
|
hb_buffer_t *buffer;
|
||||||
|
|
||||||
buffer = calloc (1, sizeof (hb_buffer_t));
|
if (!HB_OBJECT_DO_CREATE (buffer))
|
||||||
if (HB_UNLIKELY (!buffer))
|
return &_hb_buffer_nil;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
buffer->allocated = 0;
|
if (pre_alloc_size)
|
||||||
buffer->in_string = NULL;
|
hb_buffer_ensure(buffer, pre_alloc_size);
|
||||||
buffer->alt_string = NULL;
|
|
||||||
buffer->positions = NULL;
|
|
||||||
|
|
||||||
hb_buffer_clear (buffer);
|
|
||||||
|
|
||||||
if (allocation_size)
|
|
||||||
hb_buffer_ensure(buffer, allocation_size);
|
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
hb_buffer_t *
|
||||||
hb_buffer_free (hb_buffer_t *buffer)
|
hb_buffer_reference (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
|
HB_OBJECT_DO_REFERENCE (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
hb_buffer_get_reference_count (hb_buffer_t *buffer)
|
||||||
|
{
|
||||||
|
HB_OBJECT_DO_GET_REFERENCE_COUNT (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
hb_buffer_destroy (hb_buffer_t *buffer)
|
||||||
|
{
|
||||||
|
HB_OBJECT_DO_DESTROY (buffer);
|
||||||
|
|
||||||
free (buffer->in_string);
|
free (buffer->in_string);
|
||||||
free (buffer->alt_string);
|
free (buffer->alt_string);
|
||||||
free (buffer->positions);
|
free (buffer->positions);
|
||||||
|
|
||||||
free (buffer);
|
free (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +196,8 @@ _hb_buffer_clear_output (hb_buffer_t *buffer)
|
||||||
buffer->out_string = buffer->in_string;
|
buffer->out_string = buffer->in_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
HB_INTERNAL void
|
void
|
||||||
_hb_buffer_clear_positions (hb_buffer_t *buffer)
|
hb_buffer_clear_positions (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
_hb_buffer_clear_output (buffer);
|
_hb_buffer_clear_output (buffer);
|
||||||
|
|
||||||
|
@ -340,3 +351,27 @@ _hb_buffer_allocate_lig_id (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
return ++buffer->max_lig_id;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
HB_BEGIN_DECLS
|
HB_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct _hb_buffer_t hb_buffer_t;
|
||||||
|
|
||||||
typedef enum _hb_direction_t {
|
typedef enum _hb_direction_t {
|
||||||
HB_DIRECTION_LTR,
|
HB_DIRECTION_LTR,
|
||||||
HB_DIRECTION_RTL,
|
HB_DIRECTION_RTL,
|
||||||
|
@ -39,7 +41,7 @@ typedef enum _hb_direction_t {
|
||||||
HB_DIRECTION_BTT
|
HB_DIRECTION_BTT
|
||||||
} hb_direction_t;
|
} hb_direction_t;
|
||||||
|
|
||||||
/* XXX Hide structs? */
|
/* XXX these structs need review before we can commit to them */
|
||||||
|
|
||||||
typedef struct _hb_glyph_info_t {
|
typedef struct _hb_glyph_info_t {
|
||||||
hb_codepoint_t gindex;
|
hb_codepoint_t gindex;
|
||||||
|
@ -67,45 +69,56 @@ typedef struct _hb_glyph_position_t {
|
||||||
} hb_glyph_position_t;
|
} hb_glyph_position_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _hb_buffer_t {
|
hb_buffer_t *
|
||||||
unsigned int allocated;
|
hb_buffer_create (unsigned int pre_alloc_size);
|
||||||
|
|
||||||
unsigned int in_length;
|
|
||||||
unsigned int out_length;
|
|
||||||
unsigned int in_pos;
|
|
||||||
unsigned int out_pos;
|
|
||||||
|
|
||||||
hb_glyph_info_t *in_string;
|
|
||||||
hb_glyph_info_t *out_string;
|
|
||||||
hb_glyph_info_t *alt_string;
|
|
||||||
hb_glyph_position_t *positions;
|
|
||||||
|
|
||||||
hb_direction_t direction;
|
|
||||||
unsigned int max_lig_id;
|
|
||||||
} hb_buffer_t;
|
|
||||||
|
|
||||||
hb_buffer_t *
|
hb_buffer_t *
|
||||||
hb_buffer_new (unsigned int allocation_size);
|
hb_buffer_reference (hb_buffer_t *buffer);
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
hb_buffer_get_reference_count (hb_buffer_t *buffer);
|
||||||
|
|
||||||
void
|
void
|
||||||
hb_buffer_free (hb_buffer_t *buffer);
|
hb_buffer_destroy (hb_buffer_t *buffer);
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
hb_buffer_set_direction (hb_buffer_t *buffer,
|
||||||
|
hb_direction_t direction);
|
||||||
|
|
||||||
|
hb_direction_t
|
||||||
|
hb_buffer_get_direction (hb_buffer_t *buffer);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
hb_buffer_clear (hb_buffer_t *buffer);
|
hb_buffer_clear (hb_buffer_t *buffer);
|
||||||
|
|
||||||
|
void
|
||||||
|
hb_buffer_clear_positions (hb_buffer_t *buffer);
|
||||||
|
|
||||||
void
|
void
|
||||||
hb_buffer_ensure (hb_buffer_t *buffer,
|
hb_buffer_ensure (hb_buffer_t *buffer,
|
||||||
unsigned int size);
|
unsigned int size);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
hb_buffer_add_glyph (hb_buffer_t *buffer,
|
hb_buffer_add_glyph (hb_buffer_t *buffer,
|
||||||
hb_codepoint_t glyph_index,
|
hb_codepoint_t glyph_index,
|
||||||
unsigned int properties,
|
unsigned int properties,
|
||||||
unsigned int cluster);
|
unsigned int cluster);
|
||||||
|
|
||||||
void
|
|
||||||
hb_buffer_set_direction (hb_buffer_t *buffer,
|
/* Return value valid as long as buffer not modified */
|
||||||
hb_direction_t direction);
|
unsigned int
|
||||||
|
hb_buffer_get_len (hb_buffer_t *buffer);
|
||||||
|
|
||||||
|
/* Return value valid as long as buffer not modified */
|
||||||
|
hb_glyph_info_t *
|
||||||
|
hb_buffer_get_glyph_infos (hb_buffer_t *buffer);
|
||||||
|
|
||||||
|
/* Return value valid as long as buffer not modified */
|
||||||
|
hb_glyph_position_t *
|
||||||
|
hb_buffer_get_glyph_positions (hb_buffer_t *buffer);
|
||||||
|
|
||||||
|
|
||||||
HB_END_DECLS
|
HB_END_DECLS
|
||||||
|
|
Loading…
Reference in New Issue