[buffer] Add sync_so_far()

This removes separate out-buffer, at the cost of possibly changing
idx.
This commit is contained in:
Behdad Esfahbod 2022-03-21 18:51:01 -06:00
parent cbccadba8d
commit da9edce84c
2 changed files with 29 additions and 2 deletions

View File

@ -387,9 +387,11 @@ hb_buffer_t::clear_positions ()
hb_memset (pos, 0, sizeof (pos[0]) * len);
}
void
bool
hb_buffer_t::sync ()
{
bool ret = false;
assert (have_output);
assert (idx <= len);
@ -403,12 +405,36 @@ hb_buffer_t::sync ()
info = out_info;
}
len = out_len;
ret = true;
reset:
have_output = false;
out_len = 0;
out_info = info;
idx = 0;
return ret;
}
void
hb_buffer_t::sync_so_far ()
{
bool had_output = have_output;
unsigned out_i = out_len;
unsigned i = idx;
if (sync ())
idx = out_i;
else
idx = i;
if (had_output)
{
have_output = true;
out_len = idx;
}
assert (idx <= len);
}
bool

View File

@ -288,7 +288,8 @@ struct hb_buffer_t
HB_INTERNAL void guess_segment_properties ();
HB_INTERNAL void sync ();
HB_INTERNAL bool sync ();
HB_INTERNAL void sync_so_far ();
HB_INTERNAL void clear_output ();
HB_INTERNAL void clear_positions ();