From ee2204469ebfe3a3e9c76e856a7e0c8aab1dd946 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 18 Dec 2022 13:50:34 -0700 Subject: [PATCH] [paint] Add get_empty / [sg]et_user_data --- src/hb-cplusplus.hh | 2 +- src/hb-draw.cc | 1 - src/hb-paint.cc | 58 +++++++++++++++++++++++++++++++++++++++++++++ src/hb-paint.h | 15 ++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) diff --git a/src/hb-cplusplus.hh b/src/hb-cplusplus.hh index f9e44aafd..531ef1b7c 100644 --- a/src/hb-cplusplus.hh +++ b/src/hb-cplusplus.hh @@ -161,7 +161,7 @@ HB_DEFINE_VTABLE (set); HB_DEFINE_VTABLE (shape_plan); HB_DEFINE_VTABLE (unicode_funcs); HB_DEFINE_VTABLE (draw_funcs); -//HB_DEFINE_VTABLE (paint_funcs); +HB_DEFINE_VTABLE (paint_funcs); #undef HB_DEFINE_VTABLE diff --git a/src/hb-draw.cc b/src/hb-draw.cc index dde7e39cc..c0d12992a 100644 --- a/src/hb-draw.cc +++ b/src/hb-draw.cc @@ -213,7 +213,6 @@ hb_draw_funcs_get_empty () return const_cast (&Null (hb_draw_funcs_t)); } - /** * hb_draw_funcs_reference: (skip) * @dfuncs: draw functions diff --git a/src/hb-paint.cc b/src/hb-paint.cc index 0872479f4..18f52f2bf 100644 --- a/src/hb-paint.cc +++ b/src/hb-paint.cc @@ -225,6 +225,21 @@ DEFINE_NULL_INSTANCE (hb_paint_funcs_t) = } }; +/** + * hb_paint_funcs_get_empty: + * + * Fetches the singleton empty paint-functions structure. + * + * Return value: (transfer full): The empty paint-functions structure + * + * Since: REPLACEME + **/ +hb_paint_funcs_t * +hb_paint_funcs_get_empty () +{ + return const_cast (&Null (hb_paint_funcs_t)); +} + /** * hb_paint_funcs_reference: (skip) * @funcs: The paint-functions structure @@ -270,6 +285,49 @@ hb_paint_funcs_destroy (hb_paint_funcs_t *funcs) hb_free (funcs); } +/** + * hb_paint_funcs_set_user_data: (skip) + * @pfuncs: The paint-functions structure + * @key: The user-data key + * @data: A pointer to the user data + * @destroy: (nullable): A callback to call when @data is not needed anymore + * @replace: Whether to replace an existing data with the same key + * + * Attaches a user-data key/data pair to the specified paint-functions structure. + * + * Return value: `true` if success, `false` otherwise + * + * Since: REPLACEME + **/ +hb_bool_t +hb_paint_funcs_set_user_data (hb_paint_funcs_t *pfuncs, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace) +{ + return hb_object_set_user_data (pfuncs, key, data, destroy, replace); +} + +/** + * hb_paint_funcs_get_user_data: (skip) + * @pfuncs: The paint-functions structure + * @key: The user-data key to query + * + * Fetches the user-data associated with the specified key, + * attached to the specified paint-functions structure. + * + * Return value: (transfer none): A pointer to the user data + * + * Since: REPLACEME + **/ +void * +hb_paint_funcs_get_user_data (const hb_paint_funcs_t *pfuncs, + hb_user_data_key_t *key) +{ + return hb_object_get_user_data (pfuncs, key); +} + /** * hb_paint_funcs_make_immutable: * @funcs: The paint-functions structure diff --git a/src/hb-paint.h b/src/hb-paint.h index 06e4095fc..6793a6349 100644 --- a/src/hb-paint.h +++ b/src/hb-paint.h @@ -65,12 +65,27 @@ typedef struct hb_paint_funcs_t hb_paint_funcs_t; HB_EXTERN hb_paint_funcs_t * hb_paint_funcs_create (void); +HB_EXTERN hb_paint_funcs_t * +hb_paint_funcs_get_empty (void); + HB_EXTERN hb_paint_funcs_t * hb_paint_funcs_reference (hb_paint_funcs_t *funcs); HB_EXTERN void hb_paint_funcs_destroy (hb_paint_funcs_t *funcs); +HB_EXTERN hb_bool_t +hb_paint_funcs_set_user_data (hb_paint_funcs_t *funcs, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace); + + +HB_EXTERN void * +hb_paint_funcs_get_user_data (const hb_paint_funcs_t *funcs, + hb_user_data_key_t *key); + HB_EXTERN void hb_paint_funcs_make_immutable (hb_paint_funcs_t *funcs);