From: Jean-Philippe Bruyère Date: Wed, 22 Jun 2022 04:00:45 +0000 (+0200) Subject: get_matrix with const pointer X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=fae189723237dd5fa3b87bbe421f63a8e7f66ca7;p=jp%2Fvkvg.git get_matrix with const pointer --- diff --git a/include/vkvg.h b/include/vkvg.h index a30d73b..3483a1e 100644 --- a/include/vkvg.h +++ b/include/vkvg.h @@ -752,7 +752,16 @@ VkvgSurface vkvg_surface_create_from_image (VkvgDevice dev, const char* filePath */ vkvg_public VkvgSurface vkvg_surface_create_for_VkhImage (VkvgDevice dev, void* vkhImg); -// VkvgSurface vkvg_surface_create_from_bitmap (VkvgDevice dev, unsigned char* img, uint32_t width, uint32_t height); +/** + * @brief Create a new vkvg surface from an in memory rgba bitmap + * @param dev The vkvg device used for creating the surface. + * @param img a pointer to a rgba encoded bimap + * @param width the width of the provided bitmap. + * @param height the height of the provided bitmap. + * @return + */ +vkvg_public +VkvgSurface vkvg_surface_create_from_bitmap (VkvgDevice dev, unsigned char* img, uint32_t width, uint32_t height); /** * @brief Increment reference count on the surface by one. * @param The vkvg surface to increment the reference count for. @@ -1684,7 +1693,7 @@ void vkvg_set_matrix (VkvgContext ctx, const vkvg_matrix_t* matrix); * @param matrix a valid #vkvg_matrix_t pointer to receive the current context's transform. */ vkvg_public -void vkvg_get_matrix (VkvgContext ctx, const vkvg_matrix_t* matrix); +void vkvg_get_matrix (VkvgContext ctx, vkvg_matrix_t * const matrix); /** * @brief Set the current matrix to identity. * diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 895c546..ea5b1f5 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -1594,8 +1594,8 @@ void vkvg_set_matrix (VkvgContext ctx, const vkvg_matrix_t* matrix){ ctx->pushConsts.mat = (*matrix); _set_mat_inv_and_vkCmdPush (ctx); } -void vkvg_get_matrix (VkvgContext ctx, const vkvg_matrix_t* matrix){ - memcpy ((void*)matrix, &ctx->pushConsts.mat, sizeof(vkvg_matrix_t)); +void vkvg_get_matrix (VkvgContext ctx, vkvg_matrix_t* const matrix){ + *matrix = ctx->pushConsts.mat; } void vkvg_elliptic_arc_to (VkvgContext ctx, float x2, float y2, bool largeArc, bool sweepFlag, float rx, float ry, float phi) {