From 8f0d7e0c3fd4b05c43ac449be4f374dc2dc56127 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 15 Apr 2011 18:59:56 -0400 Subject: [PATCH] Remove hb_buffer_clear_positions(), add hb_ot_layout_position_start() --- src/hb-buffer-private.hh | 6 +++++- src/hb-buffer.cc | 24 ++++++++++++------------ src/hb-buffer.h | 5 +---- src/hb-ot-layout.cc | 6 ++++++ src/hb-ot-layout.h | 4 ++++ src/hb-ot-shape.cc | 2 +- 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh index d8834c550..4b1ff12e6 100644 --- a/src/hb-buffer-private.hh +++ b/src/hb-buffer-private.hh @@ -2,7 +2,7 @@ * Copyright (C) 1998-2004 David Turner and Werner Lemberg * Copyright (C) 2004,2007,2009,2010 Red Hat, Inc. * - * This is part of HarfBuzz, a text shaping library. + * This is part of HarfBuzz, a text shaping library. * * Permission is hereby granted, without written agreement and without * license or royalty fees, to use, copy, modify, and distribute this @@ -51,6 +51,9 @@ _hb_buffer_swap (hb_buffer_t *buffer); HB_INTERNAL void _hb_buffer_clear_output (hb_buffer_t *buffer); +HB_INTERNAL void +_hb_buffer_clear_positions (hb_buffer_t *buffer); + HB_INTERNAL void _hb_buffer_replace_glyphs_be16 (hb_buffer_t *buffer, unsigned int num_in, @@ -116,6 +119,7 @@ struct _hb_buffer_t { inline unsigned int next_serial (void) { return serial++; } inline void swap (void) { _hb_buffer_swap (this); } inline void clear_output (void) { _hb_buffer_clear_output (this); } + inline void clear_positions (void) { _hb_buffer_clear_positions (this); } inline void next_glyph (void) { _hb_buffer_next_glyph (this); } inline void replace_glyphs_be16 (unsigned int num_in, unsigned int num_out, diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index f5dc02f08..4020d2ce6 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -3,7 +3,7 @@ * Copyright (C) 2004,2007,2009,2010 Red Hat, Inc. * Copyright (C) 2011 Google, Inc. * - * This is part of HarfBuzz, a text shaping library. + * This is part of HarfBuzz, a text shaping library. * * Permission is hereby granted, without written agreement and without * license or royalty fees, to use, copy, modify, and distribute this @@ -272,16 +272,6 @@ hb_buffer_add_glyph (hb_buffer_t *buffer, buffer->len++; } -void -hb_buffer_clear_positions (hb_buffer_t *buffer) -{ - _hb_buffer_clear_output (buffer); - buffer->have_output = FALSE; - buffer->have_positions = TRUE; - - memset (buffer->pos, 0, sizeof (buffer->pos[0]) * buffer->len); -} - /* HarfBuzz-Internal API */ void @@ -289,10 +279,20 @@ _hb_buffer_clear_output (hb_buffer_t *buffer) { buffer->have_output = TRUE; buffer->have_positions = FALSE; + buffer->out_len = 0; buffer->out_info = buffer->info; } +void +_hb_buffer_clear_positions (hb_buffer_t *buffer) +{ + buffer->have_output = FALSE; + buffer->have_positions = TRUE; + + memset (buffer->pos, 0, sizeof (buffer->pos[0]) * buffer->len); +} + void _hb_buffer_swap (hb_buffer_t *buffer) { @@ -477,7 +477,7 @@ hb_glyph_position_t * hb_buffer_get_glyph_positions (hb_buffer_t *buffer) { if (!buffer->have_positions) - hb_buffer_clear_positions (buffer); + _hb_buffer_clear_positions (buffer); return (hb_glyph_position_t *) buffer->pos; } diff --git a/src/hb-buffer.h b/src/hb-buffer.h index 49f6a49cd..2151a4580 100644 --- a/src/hb-buffer.h +++ b/src/hb-buffer.h @@ -3,7 +3,7 @@ * Copyright (C) 2004,2007,2009 Red Hat, Inc. * Copyright (C) 2011 Google, Inc. * - * This is part of HarfBuzz, a text shaping library. + * This is part of HarfBuzz, a text shaping library. * * Permission is hereby granted, without written agreement and without * license or royalty fees, to use, copy, modify, and distribute this @@ -102,9 +102,6 @@ hb_buffer_get_language (hb_buffer_t *buffer); void hb_buffer_reset (hb_buffer_t *buffer); -void -hb_buffer_clear_positions (hb_buffer_t *buffer); - hb_bool_t hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size); diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index fc4b1d323..f1287c5c9 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -462,6 +462,12 @@ hb_ot_layout_has_positioning (hb_face_t *face) return &_get_gpos (face) != &Null(GPOS); } +void +hb_ot_layout_position_start (hb_buffer_t *buffer) +{ + buffer->clear_positions (); +} + hb_bool_t hb_ot_layout_position_lookup (hb_font_t *font, hb_face_t *face, diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h index 9619eb79f..0e0d77f0b 100644 --- a/src/hb-ot-layout.h +++ b/src/hb-ot-layout.h @@ -179,6 +179,10 @@ hb_ot_layout_substitute_lookup (hb_face_t *face, hb_bool_t hb_ot_layout_has_positioning (hb_face_t *face); +/* Should be called before all the position_lookup's are done. Resets positions to zero. */ +void +hb_ot_layout_position_start (hb_buffer_t *buffer); + hb_bool_t hb_ot_layout_position_lookup (hb_font_t *font, hb_face_t *face, diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 76d4a56e2..2364d3c63 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -249,7 +249,7 @@ hb_substitute_complex_fallback (hb_ot_shape_context_t *c HB_UNUSED) static void hb_position_default (hb_ot_shape_context_t *c) { - hb_buffer_clear_positions (c->buffer); + hb_ot_layout_position_start (c->buffer); unsigned int count = c->buffer->len; for (unsigned int i = 0; i < count; i++) {