[paint-extents] Move code around
This commit is contained in:
parent
d9a9bd8fa8
commit
c86d1892ad
|
@ -60,24 +60,6 @@ hb_paint_extents_pop_transform (hb_paint_funcs_t *funcs HB_UNUSED,
|
|||
c->pop_transform ();
|
||||
}
|
||||
|
||||
static void
|
||||
add_point (hb_extents_t *extents,
|
||||
float x, float y)
|
||||
{
|
||||
if (unlikely (extents->xmax < extents->xmin))
|
||||
{
|
||||
extents->xmin = extents->xmax = x;
|
||||
extents->ymin = extents->ymax = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
extents->xmin = hb_min (extents->xmin, x);
|
||||
extents->ymin = hb_min (extents->ymin, y);
|
||||
extents->xmax = hb_max (extents->xmax, x);
|
||||
extents->ymax = hb_max (extents->ymax, y);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
hb_draw_extents_move_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||
void *data,
|
||||
|
@ -87,7 +69,7 @@ hb_draw_extents_move_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
|||
{
|
||||
hb_extents_t *extents = (hb_extents_t *) data;
|
||||
|
||||
add_point (extents, to_x, to_y);
|
||||
extents->add_point (to_x, to_y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -99,7 +81,7 @@ hb_draw_extents_line_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
|||
{
|
||||
hb_extents_t *extents = (hb_extents_t *) data;
|
||||
|
||||
add_point (extents, to_x, to_y);
|
||||
extents->add_point (to_x, to_y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -112,8 +94,8 @@ hb_draw_extents_quadratic_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
|||
{
|
||||
hb_extents_t *extents = (hb_extents_t *) data;
|
||||
|
||||
add_point (extents, control_x, control_y);
|
||||
add_point (extents, to_x, to_y);
|
||||
extents->add_point (control_x, control_y);
|
||||
extents->add_point (to_x, to_y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -127,9 +109,9 @@ hb_draw_extents_cubic_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
|||
{
|
||||
hb_extents_t *extents = (hb_extents_t *) data;
|
||||
|
||||
add_point (extents, control1_x, control1_y);
|
||||
add_point (extents, control2_x, control2_y);
|
||||
add_point (extents, to_x, to_y);
|
||||
extents->add_point (control1_x, control1_y);
|
||||
extents->add_point (control2_x, control2_y);
|
||||
extents->add_point (to_x, to_y);
|
||||
}
|
||||
|
||||
static inline void free_static_draw_extents_funcs ();
|
||||
|
|
|
@ -36,6 +36,7 @@ typedef struct hb_extents_t
|
|||
xmin (xmin), ymin (ymin), xmax (xmax), ymax (ymax) {}
|
||||
|
||||
bool is_empty () const { return xmin >= xmax || ymin >= ymax; }
|
||||
bool is_void () const { return xmin > xmax; }
|
||||
|
||||
void union_ (const hb_extents_t &o)
|
||||
{
|
||||
|
@ -53,6 +54,23 @@ typedef struct hb_extents_t
|
|||
ymax = hb_min (ymax, o.ymax);
|
||||
}
|
||||
|
||||
void
|
||||
add_point (float x, float y)
|
||||
{
|
||||
if (unlikely (is_void ()))
|
||||
{
|
||||
xmin = xmax = x;
|
||||
ymin = ymax = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
xmin = hb_min (xmin, x);
|
||||
ymin = hb_min (ymin, y);
|
||||
xmax = hb_max (xmax, x);
|
||||
ymax = hb_max (ymax, y);
|
||||
}
|
||||
}
|
||||
|
||||
float xmin = 0.f;
|
||||
float ymin = 0.f;
|
||||
float xmax = -1.f;
|
||||
|
|
Loading…
Reference in New Issue