Change add_contour function to populate a handle with already owned memory instead of copying

This commit is contained in:
KitsuneAlex 2024-05-14 03:03:16 +02:00
parent 68dc012b32
commit 3d15f9309d
No known key found for this signature in database
GPG Key ID: 6B0CE864BB69B7D0
2 changed files with 4 additions and 4 deletions

View File

@ -168,11 +168,11 @@ MSDF_API int msdf_shape_get_bounds(msdf_shape_const_handle shape, msdf_bounds_t*
return MSDF_SUCCESS;
}
MSDF_API int msdf_shape_add_contour(msdf_shape_handle shape, msdf_contour_const_handle contour) {
MSDF_API int msdf_shape_add_contour(msdf_shape_handle shape, msdf_contour_const_handle* contour) {
if(shape == nullptr || contour == nullptr) {
return MSDF_ERR_INVALID_ARG;
}
reinterpret_cast<msdfgen::Shape*>(shape)->addContour(*reinterpret_cast<const msdfgen::Contour*>(contour));
*contour = reinterpret_cast<msdf_contour_const_handle>(&reinterpret_cast<msdfgen::Shape*>(shape)->addContour());
return MSDF_SUCCESS;
}

View File

@ -192,10 +192,10 @@ MSDF_API int msdf_shape_get_bounds(msdf_shape_const_handle shape, msdf_bounds_t*
/**
* Adds a new contour to the given shape.
* @param shape A pointer to a shape object to add a new contour to.
* @param contour A pointer to the contour to add to the shape.
* @param contour A pointer to a contour handle to be populated with a new contour that was added to the shape.
* @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/
MSDF_API int msdf_shape_add_contour(msdf_shape_handle shape, msdf_contour_const_handle contour);
MSDF_API int msdf_shape_add_contour(msdf_shape_handle shape, msdf_contour_const_handle* contour);
/**
* Removes the given contour from the given shape if present.