Implement missing checks for bitmap type in generate functions of C-API

This commit is contained in:
KitsuneAlex 2024-05-02 05:22:22 +02:00
parent 130f6ffaaf
commit f041dd492c
No known key found for this signature in database
GPG Key ID: 6B0CE864BB69B7D0
1 changed files with 24 additions and 0 deletions

View File

@ -565,6 +565,9 @@ int msdf_generate_sdf(msdf_bitmap_t* output, msdf_shape_handle shape, const msdf
if(output == nullptr || shape == nullptr || transform == nullptr) {
return MSDF_ERR_INVALID_ARG;
}
if(output->type != MSDF_BITMAP_TYPE_SDF) {
return MSDF_ERR_INVALID_TYPE;
}
const msdfgen::Projection projection(*reinterpret_cast<const msdfgen::Vector2*>(&transform->scale),
*reinterpret_cast<const msdfgen::Vector2*>(&transform->translation));
const msdfgen::Range dist_mapping(transform->distance_mapping.lower, transform->distance_mapping.upper);
@ -577,6 +580,9 @@ int msdf_generate_psdf(msdf_bitmap_t* output, msdf_shape_handle shape, const msd
if(output == nullptr || shape == nullptr || transform == nullptr) {
return MSDF_ERR_INVALID_ARG;
}
if(output->type != MSDF_BITMAP_TYPE_PSDF) {
return MSDF_ERR_INVALID_TYPE;
}
const msdfgen::Projection projection(*reinterpret_cast<const msdfgen::Vector2*>(&transform->scale),
*reinterpret_cast<const msdfgen::Vector2*>(&transform->translation));
const msdfgen::Range dist_mapping(transform->distance_mapping.lower, transform->distance_mapping.upper);
@ -589,6 +595,9 @@ int msdf_generate_msdf(msdf_bitmap_t* output, msdf_shape_handle shape, const msd
if(output == nullptr || shape == nullptr || transform == nullptr) {
return MSDF_ERR_INVALID_ARG;
}
if(output->type != MSDF_BITMAP_TYPE_MSDF) {
return MSDF_ERR_INVALID_TYPE;
}
const msdfgen::Projection projection(*reinterpret_cast<const msdfgen::Vector2*>(&transform->scale),
*reinterpret_cast<const msdfgen::Vector2*>(&transform->translation));
const msdfgen::Range dist_mapping(transform->distance_mapping.lower, transform->distance_mapping.upper);
@ -601,6 +610,9 @@ int msdf_generate_mtsdf(msdf_bitmap_t* output, msdf_shape_handle shape, const ms
if(output == nullptr || shape == nullptr || transform == nullptr) {
return MSDF_ERR_INVALID_ARG;
}
if(output->type != MSDF_BITMAP_TYPE_MTSDF) {
return MSDF_ERR_INVALID_TYPE;
}
const msdfgen::Projection projection(*reinterpret_cast<const msdfgen::Vector2*>(&transform->scale),
*reinterpret_cast<const msdfgen::Vector2*>(&transform->translation));
const msdfgen::Range dist_mapping(transform->distance_mapping.lower, transform->distance_mapping.upper);
@ -616,6 +628,9 @@ int msdf_generate_sdf_with_config(msdf_bitmap_t* output,
if(output == nullptr || shape == nullptr || transform == nullptr || config == nullptr) {
return MSDF_ERR_INVALID_ARG;
}
if(output->type != MSDF_BITMAP_TYPE_SDF) {
return MSDF_ERR_INVALID_TYPE;
}
const msdfgen::Projection projection(*reinterpret_cast<const msdfgen::Vector2*>(&transform->scale),
*reinterpret_cast<const msdfgen::Vector2*>(&transform->translation));
const msdfgen::Range dist_mapping(transform->distance_mapping.lower, transform->distance_mapping.upper);
@ -633,6 +648,9 @@ int msdf_generate_psdf_with_config(msdf_bitmap_t* output,
if(output == nullptr || shape == nullptr || transform == nullptr || config == nullptr) {
return MSDF_ERR_INVALID_ARG;
}
if(output->type != MSDF_BITMAP_TYPE_PSDF) {
return MSDF_ERR_INVALID_TYPE;
}
const msdfgen::Projection projection(*reinterpret_cast<const msdfgen::Vector2*>(&transform->scale),
*reinterpret_cast<const msdfgen::Vector2*>(&transform->translation));
const msdfgen::Range dist_mapping(transform->distance_mapping.lower, transform->distance_mapping.upper);
@ -650,6 +668,9 @@ int msdf_generate_msdf_with_config(msdf_bitmap_t* output,
if(output == nullptr || shape == nullptr || transform == nullptr || config == nullptr) {
return MSDF_ERR_INVALID_ARG;
}
if(output->type != MSDF_BITMAP_TYPE_MSDF) {
return MSDF_ERR_INVALID_TYPE;
}
const msdfgen::Projection projection(*reinterpret_cast<const msdfgen::Vector2*>(&transform->scale),
*reinterpret_cast<const msdfgen::Vector2*>(&transform->translation));
const msdfgen::Range dist_mapping(transform->distance_mapping.lower, transform->distance_mapping.upper);
@ -671,6 +692,9 @@ int msdf_generate_mtsdf_with_config(msdf_bitmap_t* output,
if(output == nullptr || shape == nullptr || transform == nullptr || config == nullptr) {
return MSDF_ERR_INVALID_ARG;
}
if(output->type != MSDF_BITMAP_TYPE_MTSDF) {
return MSDF_ERR_INVALID_TYPE;
}
const msdfgen::Projection projection(*reinterpret_cast<const msdfgen::Vector2*>(&transform->scale),
*reinterpret_cast<const msdfgen::Vector2*>(&transform->translation));
const msdfgen::Range dist_mapping(transform->distance_mapping.lower, transform->distance_mapping.upper);