[embolden] Renames
This commit is contained in:
parent
c06f95ebe1
commit
7774bccb48
|
@ -30,7 +30,7 @@
|
|||
#include "hb-draw.hh"
|
||||
|
||||
|
||||
struct hb_contour_point_t
|
||||
struct hb_outline_point_t
|
||||
{
|
||||
enum class type_t
|
||||
{
|
||||
|
@ -40,16 +40,14 @@ struct hb_contour_point_t
|
|||
CUBIC_TO,
|
||||
};
|
||||
|
||||
hb_contour_point_t (float x, float y, type_t type) :
|
||||
hb_outline_point_t (float x, float y, type_t type) :
|
||||
x (x), y (y), type (type) {}
|
||||
|
||||
float x, y;
|
||||
type_t type;
|
||||
};
|
||||
|
||||
using hb_contour_t = hb_vector_t<hb_contour_point_t>;
|
||||
|
||||
struct hb_recording_pen_t
|
||||
struct hb_outline_t
|
||||
{
|
||||
void replay (hb_draw_funcs_t *pen, void *pen_data) const
|
||||
{
|
||||
|
@ -61,33 +59,33 @@ struct hb_recording_pen_t
|
|||
auto it = points.as_array ().sub_array (first, contour - first);
|
||||
while (it)
|
||||
{
|
||||
hb_contour_point_t p1 = *it++;
|
||||
hb_outline_point_t p1 = *it++;
|
||||
switch (p1.type)
|
||||
{
|
||||
case hb_contour_point_t::type_t::MOVE_TO:
|
||||
case hb_outline_point_t::type_t::MOVE_TO:
|
||||
{
|
||||
pen->move_to (pen_data, st,
|
||||
p1.x, p1.y);
|
||||
}
|
||||
break;
|
||||
case hb_contour_point_t::type_t::LINE_TO:
|
||||
case hb_outline_point_t::type_t::LINE_TO:
|
||||
{
|
||||
pen->line_to (pen_data, st,
|
||||
p1.x, p1.y);
|
||||
}
|
||||
break;
|
||||
case hb_contour_point_t::type_t::QUADRATIC_TO:
|
||||
case hb_outline_point_t::type_t::QUADRATIC_TO:
|
||||
{
|
||||
hb_contour_point_t p2 = *it++;
|
||||
hb_outline_point_t p2 = *it++;
|
||||
pen->quadratic_to (pen_data, st,
|
||||
p1.x, p1.y,
|
||||
p2.x, p2.y);
|
||||
}
|
||||
break;
|
||||
case hb_contour_point_t::type_t::CUBIC_TO:
|
||||
case hb_outline_point_t::type_t::CUBIC_TO:
|
||||
{
|
||||
hb_contour_point_t p2 = *it++;
|
||||
hb_contour_point_t p3 = *it++;
|
||||
hb_outline_point_t p2 = *it++;
|
||||
hb_outline_point_t p3 = *it++;
|
||||
pen->cubic_to (pen_data, st,
|
||||
p1.x, p1.y,
|
||||
p2.x, p2.y,
|
||||
|
@ -121,50 +119,50 @@ struct hb_recording_pen_t
|
|||
return a * .5f;
|
||||
}
|
||||
|
||||
hb_vector_t<hb_contour_point_t> points;
|
||||
hb_vector_t<hb_outline_point_t> points;
|
||||
hb_vector_t<unsigned> contours;
|
||||
};
|
||||
|
||||
static void
|
||||
hb_recording_pen_move_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||
hb_outline_recording_pen_move_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||
void *data,
|
||||
hb_draw_state_t *st,
|
||||
float to_x, float to_y,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
hb_recording_pen_t *c = (hb_recording_pen_t *) data;
|
||||
hb_outline_t *c = (hb_outline_t *) data;
|
||||
|
||||
c->points.push (hb_contour_point_t {to_x, to_y, hb_contour_point_t::type_t::MOVE_TO});
|
||||
c->points.push (hb_outline_point_t {to_x, to_y, hb_outline_point_t::type_t::MOVE_TO});
|
||||
}
|
||||
|
||||
static void
|
||||
hb_recording_pen_line_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||
hb_outline_recording_pen_line_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||
void *data,
|
||||
hb_draw_state_t *st,
|
||||
float to_x, float to_y,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
hb_recording_pen_t *c = (hb_recording_pen_t *) data;
|
||||
hb_outline_t *c = (hb_outline_t *) data;
|
||||
|
||||
c->points.push (hb_contour_point_t {to_x, to_y, hb_contour_point_t::type_t::LINE_TO});
|
||||
c->points.push (hb_outline_point_t {to_x, to_y, hb_outline_point_t::type_t::LINE_TO});
|
||||
}
|
||||
|
||||
static void
|
||||
hb_recording_pen_quadratic_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||
hb_outline_recording_pen_quadratic_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||
void *data,
|
||||
hb_draw_state_t *st,
|
||||
float control_x, float control_y,
|
||||
float to_x, float to_y,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
hb_recording_pen_t *c = (hb_recording_pen_t *) data;
|
||||
hb_outline_t *c = (hb_outline_t *) data;
|
||||
|
||||
c->points.push (hb_contour_point_t {control_x, control_y, hb_contour_point_t::type_t::QUADRATIC_TO});
|
||||
c->points.push (hb_contour_point_t {to_x, to_y, hb_contour_point_t::type_t::QUADRATIC_TO});
|
||||
c->points.push (hb_outline_point_t {control_x, control_y, hb_outline_point_t::type_t::QUADRATIC_TO});
|
||||
c->points.push (hb_outline_point_t {to_x, to_y, hb_outline_point_t::type_t::QUADRATIC_TO});
|
||||
}
|
||||
|
||||
static void
|
||||
hb_recording_pen_cubic_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||
hb_outline_recording_pen_cubic_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||
void *data,
|
||||
hb_draw_state_t *st,
|
||||
float control1_x, float control1_y,
|
||||
|
@ -172,60 +170,60 @@ hb_recording_pen_cubic_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
|||
float to_x, float to_y,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
hb_recording_pen_t *c = (hb_recording_pen_t *) data;
|
||||
hb_outline_t *c = (hb_outline_t *) data;
|
||||
|
||||
c->points.push (hb_contour_point_t {control1_x, control1_y, hb_contour_point_t::type_t::CUBIC_TO});
|
||||
c->points.push (hb_contour_point_t {control2_x, control2_y, hb_contour_point_t::type_t::CUBIC_TO});
|
||||
c->points.push (hb_contour_point_t {to_x, to_y, hb_contour_point_t::type_t::CUBIC_TO});
|
||||
c->points.push (hb_outline_point_t {control1_x, control1_y, hb_outline_point_t::type_t::CUBIC_TO});
|
||||
c->points.push (hb_outline_point_t {control2_x, control2_y, hb_outline_point_t::type_t::CUBIC_TO});
|
||||
c->points.push (hb_outline_point_t {to_x, to_y, hb_outline_point_t::type_t::CUBIC_TO});
|
||||
}
|
||||
|
||||
static void
|
||||
hb_recording_pen_close_path (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||
hb_outline_recording_pen_close_path (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||
void *data,
|
||||
hb_draw_state_t *st,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
hb_recording_pen_t *c = (hb_recording_pen_t *) data;
|
||||
hb_outline_t *c = (hb_outline_t *) data;
|
||||
|
||||
c->contours.push (c->points.length);
|
||||
}
|
||||
|
||||
static inline void free_static_recording_pen_funcs ();
|
||||
static inline void free_static_outline_recording_pen_funcs ();
|
||||
|
||||
static struct hb_recording_pen_funcs_lazy_loader_t : hb_draw_funcs_lazy_loader_t<hb_recording_pen_funcs_lazy_loader_t>
|
||||
static struct hb_outline_recording_pen_funcs_lazy_loader_t : hb_draw_funcs_lazy_loader_t<hb_outline_recording_pen_funcs_lazy_loader_t>
|
||||
{
|
||||
static hb_draw_funcs_t *create ()
|
||||
{
|
||||
hb_draw_funcs_t *funcs = hb_draw_funcs_create ();
|
||||
|
||||
hb_draw_funcs_set_move_to_func (funcs, hb_recording_pen_move_to, nullptr, nullptr);
|
||||
hb_draw_funcs_set_line_to_func (funcs, hb_recording_pen_line_to, nullptr, nullptr);
|
||||
hb_draw_funcs_set_quadratic_to_func (funcs, hb_recording_pen_quadratic_to, nullptr, nullptr);
|
||||
hb_draw_funcs_set_cubic_to_func (funcs, hb_recording_pen_cubic_to, nullptr, nullptr);
|
||||
hb_draw_funcs_set_close_path_func (funcs, hb_recording_pen_close_path, nullptr, nullptr);
|
||||
hb_draw_funcs_set_move_to_func (funcs, hb_outline_recording_pen_move_to, nullptr, nullptr);
|
||||
hb_draw_funcs_set_line_to_func (funcs, hb_outline_recording_pen_line_to, nullptr, nullptr);
|
||||
hb_draw_funcs_set_quadratic_to_func (funcs, hb_outline_recording_pen_quadratic_to, nullptr, nullptr);
|
||||
hb_draw_funcs_set_cubic_to_func (funcs, hb_outline_recording_pen_cubic_to, nullptr, nullptr);
|
||||
hb_draw_funcs_set_close_path_func (funcs, hb_outline_recording_pen_close_path, nullptr, nullptr);
|
||||
|
||||
hb_draw_funcs_make_immutable (funcs);
|
||||
|
||||
hb_atexit (free_static_recording_pen_funcs);
|
||||
hb_atexit (free_static_outline_recording_pen_funcs);
|
||||
|
||||
return funcs;
|
||||
}
|
||||
} static_recording_pen_funcs;
|
||||
} static_outline_recording_pen_funcs;
|
||||
|
||||
static inline
|
||||
void free_static_recording_pen_funcs ()
|
||||
void free_static_outline_recording_pen_funcs ()
|
||||
{
|
||||
static_recording_pen_funcs.free_instance ();
|
||||
static_outline_recording_pen_funcs.free_instance ();
|
||||
}
|
||||
|
||||
static hb_draw_funcs_t *
|
||||
hb_recording_pen_get_funcs ()
|
||||
hb_outline_recording_pen_get_funcs ()
|
||||
{
|
||||
return static_recording_pen_funcs.get_unconst ();
|
||||
return static_outline_recording_pen_funcs.get_unconst ();
|
||||
}
|
||||
|
||||
|
||||
struct hb_draw_embolden_context_t : hb_recording_pen_t
|
||||
struct hb_draw_embolden_context_t : hb_outline_t
|
||||
{
|
||||
void operator () (float x_strength, float y_strength)
|
||||
{
|
||||
|
@ -356,7 +354,7 @@ struct hb_draw_embolden_context_t : hb_recording_pen_t
|
|||
static hb_draw_funcs_t *
|
||||
hb_draw_embolden_get_funcs ()
|
||||
{
|
||||
return hb_recording_pen_get_funcs ();
|
||||
return hb_outline_recording_pen_get_funcs ();
|
||||
}
|
||||
|
||||
#endif /* HB_DRAW_EMBOLDEN_HH */
|
||||
|
|
Loading…
Reference in New Issue