From 7b0f9abc897f656addc55ad875bd4737cbb17128 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 27 Dec 2022 12:37:53 -0700 Subject: [PATCH] [paint] Add back "remote-control" API This reverts commit f146299a405b8338542a245b85e664de29f0c972. --- docs/harfbuzz-sections.txt | 13 ++ src/hb-paint.cc | 246 +++++++++++++++++++++++++++++++++++++ src/hb-paint.h | 67 ++++++++++ 3 files changed, 326 insertions(+) diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index df460bb6a..a9846f891 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -270,6 +270,19 @@ hb_paint_push_group_func_t hb_paint_funcs_set_push_group_func hb_paint_pop_group_func_t hb_paint_funcs_set_pop_group_func + +hb_paint_push_transform +hb_paint_pop_transform +hb_paint_push_clip_glyph +hb_paint_push_clip_rectangle +hb_paint_pop_clip +hb_paint_color +hb_paint_image +hb_paint_linear_gradient +hb_paint_radial_gradient +hb_paint_sweep_gradient +hb_paint_push_group +hb_paint_pop_group
diff --git a/src/hb-paint.cc b/src/hb-paint.cc index 24ac7131c..ec2bd0c04 100644 --- a/src/hb-paint.cc +++ b/src/hb-paint.cc @@ -428,4 +428,250 @@ hb_color_line_get_extend (hb_color_line_t *color_line) } +/** + * hb_paint_push_transform: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * @xx: xx component of the transform matrix + * @yx: yx component of the transform matrix + * @xy: xy component of the transform matrix + * @yy: yy component of the transform matrix + * @dx: dx component of the transform matrix + * @dy: dy component of the transform matrix + * + * Perform a "push-transform" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_push_transform (hb_paint_funcs_t *funcs, void *paint_data, + float xx, float yx, + float xy, float yy, + float dx, float dy) +{ + funcs->push_transform (paint_data, xx, yx, xy, yy, dx, dy); +} + +/** + * hb_paint_pop_transform: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * + * Perform a "pop-transform" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data) +{ + funcs->pop_transform (paint_data); +} + +/** + * hb_paint_push_clip_glyph: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * @glyph: the glyph ID + * @font: the font + * + * Perform a "push-clip-glyph" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data, + hb_codepoint_t glyph, + hb_font_t *font) +{ + funcs->push_clip_glyph (paint_data, glyph, font); +} + +/** + * hb_paint_push_clip_rectangle: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * @xmin: min X for the rectangle + * @ymin: min Y for the rectangle + * @xmax: max X for the rectangle + * @ymax: max Y for the rectangle + * + * Perform a "push-clip-rect" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_push_clip_rectangle (hb_paint_funcs_t *funcs, void *paint_data, + float xmin, float ymin, float xmax, float ymax) +{ + funcs->push_clip_rectangle (paint_data, xmin, ymin, xmax, ymax); +} + +/** + * hb_paint_pop_clip: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * + * Perform a "pop-clip" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_pop_clip (hb_paint_funcs_t *funcs, void *paint_data) +{ + funcs->pop_clip (paint_data); +} + +/** + * hb_paint_color: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * @is_foreground: whether the color is the foreground + * @color: The color to use + * + * Perform a "color" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data, + hb_bool_t is_foreground, + hb_color_t color) +{ + funcs->color (paint_data, is_foreground, color); +} + +/** + * hb_paint_image: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * @image: image data + * @width: width of the raster image in pixels, or 0 + * @height: height of the raster image in pixels, or 0 + * @format: the image format as a tag + * @slant: the synthetic slant ratio to be applied to the image during rendering + * @extents: (nullable): the extents of the glyph + * + * Perform a "image" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data, + hb_blob_t *image, + unsigned int width, + unsigned int height, + hb_tag_t format, + float slant, + hb_glyph_extents_t *extents) +{ + funcs->image (paint_data, image, width, height, format, slant, extents); +} + +/** + * hb_paint_linear_gradient: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * @color_line: Color information for the gradient + * @x0: X coordinate of the first point + * @y0: Y coordinate of the first point + * @x1: X coordinate of the second point + * @y1: Y coordinate of the second point + * @x2: X coordinate of the third point + * @y2: Y coordinate of the third point + * + * Perform a "linear-gradient" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data, + hb_color_line_t *color_line, + float x0, float y0, + float x1, float y1, + float x2, float y2) +{ + funcs->linear_gradient (paint_data, color_line, x0, y0, x1, y1, x2, y2); +} + +/** + * hb_paint_radial_gradient: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * @color_line: Color information for the gradient + * @x0: X coordinate of the first circle's center + * @y0: Y coordinate of the first circle's center + * @r0: radius of the first circle + * @x1: X coordinate of the second circle's center + * @y1: Y coordinate of the second circle's center + * @r1: radius of the second circle + * + * Perform a "radial-gradient" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data, + hb_color_line_t *color_line, + float x0, float y0, float r0, + float x1, float y1, float r1) +{ + funcs->radial_gradient (paint_data, color_line, x0, y0, r0, y1, x1, r1); +} + +/** + * hb_paint_sweep_gradient: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * @color_line: Color information for the gradient + * @x0: X coordinate of the circle's center + * @y0: Y coordinate of the circle's center + * @start_angle: the start angle + * @end_angle: the end angle + * + * Perform a "sweep-gradient" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_sweep_gradient (hb_paint_funcs_t *funcs, void *paint_data, + hb_color_line_t *color_line, + float x0, float y0, + float start_angle, float end_angle) +{ + funcs->sweep_gradient (paint_data, color_line, x0, y0, start_angle, end_angle); +} + +/** + * hb_paint_push_group: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * + * Perform a "push-group" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data) +{ + funcs->push_group (paint_data); +} + +/** + * hb_paint_pop_group: + * @funcs: paint functions + * @paint_data: associated data passed by the caller + * @mode: the compositing mode to use + * + * Perform a "pop-group" paint operation. + * + * Since: REPLACEME + */ +void +hb_paint_pop_group (hb_paint_funcs_t *funcs, void *paint_data, + hb_paint_composite_mode_t mode) +{ + funcs->pop_group (paint_data, mode); +} + + #endif diff --git a/src/hb-paint.h b/src/hb-paint.h index 56c9515dd..e95917ca5 100644 --- a/src/hb-paint.h +++ b/src/hb-paint.h @@ -859,6 +859,73 @@ hb_paint_funcs_set_pop_group_func (hb_paint_funcs_t *funcs, void *user_data, hb_destroy_func_t destroy); +/* + * Manual API + */ + +HB_EXTERN void +hb_paint_push_transform (hb_paint_funcs_t *funcs, void *paint_data, + float xx, float yx, + float xy, float yy, + float dx, float dy); + +HB_EXTERN void +hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data); + +HB_EXTERN void +hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data, + hb_codepoint_t glyph, + hb_font_t *font); + +HB_EXTERN void +hb_paint_push_clip_rectangle (hb_paint_funcs_t *funcs, void *paint_data, + float xmin, float ymin, + float xmax, float ymax); + +HB_EXTERN void +hb_paint_pop_clip (hb_paint_funcs_t *funcs, void *paint_data); + +HB_EXTERN void +hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data, + hb_bool_t is_foreground, + hb_color_t color); + +HB_EXTERN void +hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data, + hb_blob_t *image, + unsigned int width, + unsigned int height, + hb_tag_t format, + float slant, + hb_glyph_extents_t *extents); + +HB_EXTERN void +hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data, + hb_color_line_t *color_line, + float x0, float y0, + float x1, float y1, + float x2, float y2); + +HB_EXTERN void +hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data, + hb_color_line_t *color_line, + float x0, float y0, + float r0, + float x1, float y1, + float r1); + +HB_EXTERN void +hb_paint_sweep_gradient (hb_paint_funcs_t *funcs, void *paint_data, + hb_color_line_t *color_line, + float x0, float y0, + float start_angle, float end_angle); + +HB_EXTERN void +hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data); + +HB_EXTERN void +hb_paint_pop_group (hb_paint_funcs_t *funcs, void *paint_data, + hb_paint_composite_mode_t mode); HB_END_DECLS