[draw] Add get_empty / [sg]et_user_data

This commit is contained in:
Behdad Esfahbod 2022-12-18 13:47:22 -07:00
parent 9a7422c5fb
commit 21a9db875e
4 changed files with 78 additions and 0 deletions

View File

@ -191,8 +191,11 @@ HB_DEPRECATED_FOR
<SECTION>
<FILE>hb-draw</FILE>
hb_draw_funcs_create
hb_draw_funcs_get_empty
hb_draw_funcs_reference
hb_draw_funcs_destroy
hb_draw_funcs_set_user_data
hb_draw_funcs_get_user_data
hb_draw_funcs_make_immutable
hb_draw_funcs_is_immutable
hb_draw_move_to_func_t

View File

@ -160,6 +160,8 @@ HB_DEFINE_VTABLE (map);
HB_DEFINE_VTABLE (set);
HB_DEFINE_VTABLE (shape_plan);
HB_DEFINE_VTABLE (unicode_funcs);
HB_DEFINE_VTABLE (draw_funcs);
//HB_DEFINE_VTABLE (paint_funcs);
#undef HB_DEFINE_VTABLE

View File

@ -198,6 +198,21 @@ DEFINE_NULL_INSTANCE (hb_draw_funcs_t) =
}
};
/**
* hb_draw_funcs_get_empty:
*
* Fetches the singleton empty draw-functions structure.
*
* Return value: (transfer full): The empty draw-functions structure
*
* Since: REPLACEME
**/
hb_draw_funcs_t *
hb_draw_funcs_get_empty ()
{
return const_cast<hb_draw_funcs_t *> (&Null (hb_draw_funcs_t));
}
/**
* hb_draw_funcs_reference: (skip)
@ -248,6 +263,49 @@ hb_draw_funcs_destroy (hb_draw_funcs_t *dfuncs)
hb_free (dfuncs);
}
/**
* hb_draw_funcs_set_user_data: (skip)
* @dfuncs: The draw-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 draw-functions structure.
*
* Return value: `true` if success, `false` otherwise
*
* Since: REPLACEME
**/
hb_bool_t
hb_draw_funcs_set_user_data (hb_draw_funcs_t *dfuncs,
hb_user_data_key_t *key,
void * data,
hb_destroy_func_t destroy,
hb_bool_t replace)
{
return hb_object_set_user_data (dfuncs, key, data, destroy, replace);
}
/**
* hb_draw_funcs_get_user_data: (skip)
* @dfuncs: The draw-functions structure
* @key: The user-data key to query
*
* Fetches the user-data associated with the specified key,
* attached to the specified draw-functions structure.
*
* Return value: (transfer none): A pointer to the user data
*
* Since: REPLACEME
**/
void *
hb_draw_funcs_get_user_data (const hb_draw_funcs_t *dfuncs,
hb_user_data_key_t *key)
{
return hb_object_get_user_data (dfuncs, key);
}
/**
* hb_draw_funcs_make_immutable:
* @dfuncs: draw functions

View File

@ -279,12 +279,27 @@ hb_draw_funcs_set_close_path_func (hb_draw_funcs_t *dfuncs,
HB_EXTERN hb_draw_funcs_t *
hb_draw_funcs_create (void);
HB_EXTERN hb_draw_funcs_t *
hb_draw_funcs_get_empty (void);
HB_EXTERN hb_draw_funcs_t *
hb_draw_funcs_reference (hb_draw_funcs_t *dfuncs);
HB_EXTERN void
hb_draw_funcs_destroy (hb_draw_funcs_t *dfuncs);
HB_EXTERN hb_bool_t
hb_draw_funcs_set_user_data (hb_draw_funcs_t *dfuncs,
hb_user_data_key_t *key,
void * data,
hb_destroy_func_t destroy,
hb_bool_t replace);
HB_EXTERN void *
hb_draw_funcs_get_user_data (const hb_draw_funcs_t *dfuncs,
hb_user_data_key_t *key);
HB_EXTERN void
hb_draw_funcs_make_immutable (hb_draw_funcs_t *dfuncs);