2022-12-14 03:14:25 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2022 Matthias Clasen
|
|
|
|
*
|
|
|
|
* This is part of HarfBuzz, a text shaping library.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, without written agreement and without
|
|
|
|
* license or royalty fees, to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose, provided that the
|
|
|
|
* above copyright notice and the following two paragraphs appear in
|
|
|
|
* all copies of this software.
|
|
|
|
*
|
|
|
|
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
|
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
|
|
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
* DAMAGE.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
|
|
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
|
|
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HB_PAINT_HH
|
|
|
|
#define HB_PAINT_HH
|
|
|
|
|
|
|
|
#include "hb.hh"
|
|
|
|
|
|
|
|
#define HB_PAINT_FUNCS_IMPLEMENT_CALLBACKS \
|
|
|
|
HB_PAINT_FUNC_IMPLEMENT (push_transform) \
|
|
|
|
HB_PAINT_FUNC_IMPLEMENT (pop_transform) \
|
2022-12-15 04:32:40 +01:00
|
|
|
HB_PAINT_FUNC_IMPLEMENT (push_clip_glyph) \
|
|
|
|
HB_PAINT_FUNC_IMPLEMENT (push_clip_rect) \
|
2022-12-14 03:14:25 +01:00
|
|
|
HB_PAINT_FUNC_IMPLEMENT (pop_clip) \
|
|
|
|
HB_PAINT_FUNC_IMPLEMENT (solid) \
|
|
|
|
HB_PAINT_FUNC_IMPLEMENT (linear_gradient) \
|
|
|
|
HB_PAINT_FUNC_IMPLEMENT (radial_gradient) \
|
|
|
|
HB_PAINT_FUNC_IMPLEMENT (sweep_gradient) \
|
|
|
|
HB_PAINT_FUNC_IMPLEMENT (push_group) \
|
2022-12-15 04:36:54 +01:00
|
|
|
HB_PAINT_FUNC_IMPLEMENT (pop_group) \
|
2022-12-14 03:14:25 +01:00
|
|
|
/* ^--- Add new callbacks here */
|
|
|
|
|
|
|
|
struct hb_paint_funcs_t
|
|
|
|
{
|
|
|
|
hb_object_header_t header;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
#define HB_PAINT_FUNC_IMPLEMENT(name) hb_paint_##name##_func_t name;
|
|
|
|
HB_PAINT_FUNCS_IMPLEMENT_CALLBACKS
|
|
|
|
#undef HB_PAINT_FUNC_IMPLEMENT
|
|
|
|
} func;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
#define HB_PAINT_FUNC_IMPLEMENT(name) void *name;
|
|
|
|
HB_PAINT_FUNCS_IMPLEMENT_CALLBACKS
|
|
|
|
#undef HB_PAINT_FUNC_IMPLEMENT
|
|
|
|
} *user_data;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
#define HB_PAINT_FUNC_IMPLEMENT(name) hb_destroy_func_t name;
|
|
|
|
HB_PAINT_FUNCS_IMPLEMENT_CALLBACKS
|
|
|
|
#undef HB_PAINT_FUNC_IMPLEMENT
|
|
|
|
} *destroy;
|
|
|
|
|
|
|
|
void push_transform (void *paint_data,
|
2022-12-15 05:58:25 +01:00
|
|
|
float xx, float yx,
|
|
|
|
float xy, float yy,
|
|
|
|
float dx, float dy)
|
2022-12-14 03:14:25 +01:00
|
|
|
{ func.push_transform (this, paint_data,
|
2022-12-15 05:58:25 +01:00
|
|
|
xx, yx, xy, yy, dx, dy,
|
2022-12-14 03:14:25 +01:00
|
|
|
!user_data ? nullptr : user_data->push_transform); }
|
|
|
|
void pop_transform (void *paint_data)
|
|
|
|
{ func.pop_transform (this, paint_data,
|
|
|
|
!user_data ? nullptr : user_data->pop_transform); }
|
2022-12-15 04:32:40 +01:00
|
|
|
void push_clip_glyph (void *paint_data,
|
|
|
|
hb_codepoint_t glyph)
|
|
|
|
{ func.push_clip_glyph (this, paint_data,
|
|
|
|
glyph,
|
|
|
|
!user_data ? nullptr : user_data->push_clip_glyph); }
|
|
|
|
void push_clip_rect (void *paint_data,
|
|
|
|
float xmin, float ymin, float xmax, float ymax)
|
|
|
|
{ func.push_clip_rect (this, paint_data,
|
|
|
|
xmin, ymin, xmax, ymax,
|
|
|
|
!user_data ? nullptr : user_data->push_clip_rect); }
|
2022-12-14 03:14:25 +01:00
|
|
|
void pop_clip (void *paint_data)
|
|
|
|
{ func.pop_clip (this, paint_data,
|
|
|
|
!user_data ? nullptr : user_data->pop_clip); }
|
|
|
|
void solid (void *paint_data,
|
2022-12-15 04:32:40 +01:00
|
|
|
unsigned int color_index,
|
|
|
|
float alpha)
|
2022-12-14 03:14:25 +01:00
|
|
|
{ func.solid (this, paint_data,
|
2022-12-15 04:32:40 +01:00
|
|
|
color_index, alpha,
|
2022-12-14 03:14:25 +01:00
|
|
|
!user_data ? nullptr : user_data->solid); }
|
|
|
|
void linear_gradient (void *paint_data,
|
|
|
|
hb_color_line_t *color_line,
|
2022-12-15 04:32:40 +01:00
|
|
|
float x0, float y0,
|
|
|
|
float x1, float y1,
|
|
|
|
float x2, float y2)
|
2022-12-14 03:14:25 +01:00
|
|
|
{ func.linear_gradient (this, paint_data,
|
|
|
|
color_line, x0, y0, x1, y1, x2, y2,
|
|
|
|
!user_data ? nullptr : user_data->linear_gradient); }
|
|
|
|
void radial_gradient (void *paint_data,
|
|
|
|
hb_color_line_t *color_line,
|
2022-12-15 04:32:40 +01:00
|
|
|
float x0, float y0, float r0,
|
|
|
|
float x1, float y1, float r1)
|
2022-12-14 03:14:25 +01:00
|
|
|
{ func.radial_gradient (this, paint_data,
|
|
|
|
color_line, x0, y0, r0, x1, y1, r1,
|
|
|
|
!user_data ? nullptr : user_data->radial_gradient); }
|
|
|
|
void sweep_gradient (void *paint_data,
|
|
|
|
hb_color_line_t *color_line,
|
2022-12-15 04:32:40 +01:00
|
|
|
float x0, float y0,
|
2022-12-14 03:14:25 +01:00
|
|
|
float start_angle,
|
|
|
|
float end_angle)
|
|
|
|
{ func.sweep_gradient (this, paint_data,
|
|
|
|
color_line, x0, y0, start_angle, end_angle,
|
|
|
|
!user_data ? nullptr : user_data->sweep_gradient); }
|
|
|
|
void push_group (void *paint_data)
|
|
|
|
{ func.push_group (this, paint_data,
|
|
|
|
!user_data ? nullptr : user_data->push_group); }
|
2022-12-15 04:36:54 +01:00
|
|
|
void pop_group (void *paint_data,
|
|
|
|
hb_paint_composite_mode_t mode)
|
|
|
|
{ func.pop_group (this, paint_data,
|
|
|
|
mode,
|
|
|
|
!user_data ? nullptr : user_data->pop_group); }
|
2022-12-14 03:14:25 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
DECLARE_NULL_INSTANCE (hb_paint_funcs_t);
|
|
|
|
|
|
|
|
#endif /* HB_PAINT_HH */
|