More scratch-buffer cleanup
This commit is contained in:
parent
8fcadb9cf9
commit
68c372ed2e
|
@ -186,7 +186,8 @@ struct hb_buffer_t {
|
|||
HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out);
|
||||
HB_INTERNAL bool shift_forward (unsigned int count);
|
||||
|
||||
HB_INTERNAL int *get_scratch_buffer (unsigned int *int_size);
|
||||
typedef int scratch_buffer_t;
|
||||
HB_INTERNAL scratch_buffer_t *get_scratch_buffer (unsigned int *size);
|
||||
|
||||
inline void clear_context (unsigned int side) { context_len[side] = 0; }
|
||||
};
|
||||
|
|
|
@ -152,8 +152,8 @@ hb_buffer_t::shift_forward (unsigned int count)
|
|||
return true;
|
||||
}
|
||||
|
||||
int *
|
||||
hb_buffer_t::get_scratch_buffer (unsigned int *int_size)
|
||||
hb_buffer_t::scratch_buffer_t *
|
||||
hb_buffer_t::get_scratch_buffer (unsigned int *size)
|
||||
{
|
||||
have_output = false;
|
||||
have_positions = false;
|
||||
|
@ -161,9 +161,9 @@ hb_buffer_t::get_scratch_buffer (unsigned int *int_size)
|
|||
out_len = 0;
|
||||
out_info = info;
|
||||
|
||||
ASSERT_STATIC (sizeof (pos[0]) % sizeof (int) == 0);
|
||||
*int_size = allocated * (sizeof (pos[0]) / sizeof (int));
|
||||
return (int *) pos;
|
||||
ASSERT_STATIC (sizeof (pos[0]) % sizeof (scratch_buffer_t) == 0);
|
||||
*size = allocated * sizeof (pos[0]) / sizeof (scratch_buffer_t);
|
||||
return (scratch_buffer_t *) pos;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -553,7 +553,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
|
|||
} HB_STMT_END;
|
||||
|
||||
unsigned int scratch_size;
|
||||
int *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||
hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||
|
||||
#define ALLOCATE_ARRAY(Type, name, len) \
|
||||
Type *name = (Type *) scratch; \
|
||||
|
@ -657,8 +657,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
|
|||
|
||||
buffer->ensure (buffer->len + num_glyphs);
|
||||
|
||||
unsigned int scratch_size;
|
||||
int *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||
scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||
|
||||
/* Testing indicates that CTRunGetGlyphsPtr, etc (almost?) always
|
||||
* succeed, and so copying data to our own buffer will be rare. */
|
||||
|
|
|
@ -243,7 +243,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan,
|
|||
float curradvx = 0., curradvy = 0.;
|
||||
|
||||
unsigned int scratch_size;
|
||||
int *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||
hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||
|
||||
uint32_t *chars = (uint32_t *) scratch;
|
||||
|
||||
|
|
|
@ -729,13 +729,21 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
|
|||
retry:
|
||||
|
||||
unsigned int scratch_size;
|
||||
int *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||
hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||
|
||||
/* Allocate char buffers; they all fit */
|
||||
#define ALLOCATE_ARRAY(Type, name, len) \
|
||||
Type *name = (Type *) scratch; \
|
||||
{ \
|
||||
unsigned int _consumed = DIV_CEIL ((len) * sizeof (Type), sizeof (*scratch)); \
|
||||
assert (_consumed <= scratch_size); \
|
||||
scratch += _consumed; \
|
||||
scratch_size -= _consumed; \
|
||||
}
|
||||
|
||||
#define utf16_index() var1.u32
|
||||
|
||||
WCHAR *pchars = (WCHAR *) scratch;
|
||||
ALLOCATE_ARRAY (WCHAR, pchars, buffer->len * 2);
|
||||
|
||||
unsigned int chars_len = 0;
|
||||
for (unsigned int i = 0; i < buffer->len; i++)
|
||||
{
|
||||
|
@ -751,16 +759,6 @@ retry:
|
|||
}
|
||||
}
|
||||
|
||||
#define ALLOCATE_ARRAY(Type, name, len) \
|
||||
Type *name = (Type *) scratch; \
|
||||
{ \
|
||||
unsigned int _consumed = DIV_CEIL ((len) * sizeof (Type), sizeof (*scratch)); \
|
||||
assert (_consumed <= scratch_size); \
|
||||
scratch += _consumed; \
|
||||
scratch_size -= _consumed; \
|
||||
}
|
||||
|
||||
ALLOCATE_ARRAY (WCHAR, wchars, chars_len);
|
||||
ALLOCATE_ARRAY (WORD, log_clusters, chars_len);
|
||||
ALLOCATE_ARRAY (SCRIPT_CHARPROP, char_props, chars_len);
|
||||
|
||||
|
@ -817,7 +815,7 @@ retry:
|
|||
bidi_state.uBidiLevel = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1;
|
||||
bidi_state.fOverrideDirection = 1;
|
||||
|
||||
hr = funcs->ScriptItemizeOpenType (wchars,
|
||||
hr = funcs->ScriptItemizeOpenType (pchars,
|
||||
chars_len,
|
||||
MAX_ITEMS,
|
||||
&bidi_control,
|
||||
|
@ -892,7 +890,7 @@ retry:
|
|||
range_char_counts.array,
|
||||
range_properties.array,
|
||||
range_properties.len,
|
||||
wchars + chars_offset,
|
||||
pchars + chars_offset,
|
||||
item_chars_len,
|
||||
glyphs_size - glyphs_offset,
|
||||
/* out */
|
||||
|
@ -934,7 +932,7 @@ retry:
|
|||
range_char_counts.array,
|
||||
range_properties.array,
|
||||
range_properties.len,
|
||||
wchars + chars_offset,
|
||||
pchars + chars_offset,
|
||||
log_clusters + chars_offset,
|
||||
char_props + chars_offset,
|
||||
item_chars_len,
|
||||
|
|
Loading…
Reference in New Issue