use unsigned int, for mask rasterizer.

This commit is contained in:
Campbell Barton
2013-05-08 12:54:47 +00:00
parent 5c4f96af2c
commit 8238cd6992
4 changed files with 34 additions and 29 deletions

View File

@@ -184,17 +184,17 @@ unsigned int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, in
unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int width, int height);
int BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline, const unsigned int resol);
float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point))[2];
float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point))[2];
float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, unsigned int *tot_diff_point))[2];
float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, unsigned int *tot_feather_point))[2];
float (*BKE_mask_spline_differentiate_with_resolution_ex(struct MaskSpline *spline, int *tot_diff_point,
float (*BKE_mask_spline_differentiate_with_resolution_ex(struct MaskSpline *spline, unsigned int *tot_diff_point,
const unsigned int resol))[2];
void BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point);
float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2];
float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, int *tot_feather_point,
void BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline *spline, float (*feather_points)[2], const unsigned int tot_feather_point);
float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, unsigned int *tot_diff_point))[2];
float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, unsigned int *tot_feather_point,
const unsigned int resol, const int do_feather_isect))[2];
float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height,
int *tot_feather_point, const int do_feather_isect))[2];
unsigned int *tot_feather_point, const int do_feather_isect))[2];
/* *** mask point functions which involve evaluation *** */
float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2];

View File

@@ -155,7 +155,7 @@ int BKE_mask_spline_differentiate_calc_total(const MaskSpline *spline, const uns
}
float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline,
int *tot_diff_point,
unsigned int *tot_diff_point,
const unsigned int resol
))[2]
{
@@ -214,7 +214,7 @@ float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline,
}
float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int width, int height,
int *tot_diff_point
unsigned int *tot_diff_point
))[2]
{
int unsigned resol = BKE_mask_spline_resolution(spline, width, height);
@@ -222,7 +222,7 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int wi
return BKE_mask_spline_differentiate_with_resolution_ex(spline, tot_diff_point, resol);
}
float (*BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point))[2]
float (*BKE_mask_spline_differentiate(MaskSpline *spline, unsigned int *tot_diff_point))[2]
{
return BKE_mask_spline_differentiate_with_resolution(spline, 0, 0, tot_diff_point);
}
@@ -350,7 +350,7 @@ static void feather_bucket_get_diagonal(FeatherEdgesBucket *buckets, int start_b
*diagonal_bucket_b_r = &buckets[diagonal_bucket_b_index];
}
void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point)
void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feather_points)[2], const unsigned int tot_feather_point)
{
#define BUCKET_INDEX(co) \
feather_bucket_index_from_coord(co, min, bucket_scale, buckets_per_side)
@@ -360,7 +360,7 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*fe
FeatherEdgesBucket *buckets;
int i;
unsigned int i;
float min[2], max[2];
float max_delta_x = -1.0f, max_delta_y = -1.0f, max_delta;
@@ -376,7 +376,7 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*fe
INIT_MINMAX2(min, max);
for (i = 0; i < tot_feather_point; i++) {
int next = i + 1;
unsigned int next = i + 1;
float delta;
minmax_v2v2_v2(min, max, feather_points[i]);
@@ -508,7 +508,7 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*fe
/** only called from #BKE_mask_spline_feather_differentiated_points_with_resolution_ex() ! */
static float (*mask_spline_feather_differentiated_points_with_resolution_ex__even(MaskSpline *spline,
int *tot_feather_point,
unsigned int *tot_feather_point,
const unsigned int resol,
const int do_feather_isect
))[2]
@@ -581,7 +581,7 @@ static float (*mask_spline_feather_differentiated_points_with_resolution_ex__eve
/** only called from #BKE_mask_spline_feather_differentiated_points_with_resolution_ex() ! */
static float (*mask_spline_feather_differentiated_points_with_resolution_ex__double(MaskSpline *spline,
int *tot_feather_point,
unsigned int *tot_feather_point,
const unsigned int resol,
const int do_feather_isect
))[2]
@@ -718,7 +718,7 @@ static float (*mask_spline_feather_differentiated_points_with_resolution_ex__dou
* when \a resol arguments match.
*/
float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline,
int *tot_feather_point,
unsigned int *tot_feather_point,
const unsigned int resol,
const int do_feather_isect
))[2]
@@ -735,14 +735,14 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpl
}
float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height,
int *tot_feather_point, const int do_feather_isect))[2]
unsigned int *tot_feather_point, const int do_feather_isect))[2]
{
unsigned int resol = BKE_mask_spline_feather_resolution(spline, width, height);
return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, tot_feather_point, resol, do_feather_isect);
}
float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2]
float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, unsigned int *tot_feather_point))[2]
{
return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point, TRUE);
}

View File

@@ -85,6 +85,10 @@
#include "BKE_mask.h"
#ifdef __GNUC__
# pragma GCC diagnostic error "-Wsign-conversion"
#endif
/* this is rather and annoying hack, use define to isolate it.
* problem is caused by scanfill removing edges on us. */
#define USE_SCANFILL_EDGE_WORKAROUND
@@ -568,7 +572,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
MaskLayer *masklay;
unsigned int masklay_index;
mr_handle->layers_tot = BLI_countlist(&mask->masklayers);
mr_handle->layers_tot = (unsigned int)BLI_countlist(&mask->masklayers);
mr_handle->layers = MEM_mallocN(sizeof(MaskRasterLayer) * mr_handle->layers_tot, "MaskRasterLayer");
BLI_rctf_init_minmax(&mr_handle->bounds);
@@ -602,7 +606,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
continue;
}
tot_splines = BLI_countlist(&masklay->splines);
tot_splines = (unsigned int)BLI_countlist(&masklay->splines);
open_spline_ranges = MEM_callocN(sizeof(*open_spline_ranges) * tot_splines, __func__);
BLI_scanfill_begin(&sf_ctx);
@@ -612,11 +616,11 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
const unsigned int is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0;
float (*diff_points)[2];
int tot_diff_point;
unsigned int tot_diff_point;
float (*diff_feather_points)[2];
float (*diff_feather_points_flip)[2];
int tot_diff_feather_points;
unsigned int tot_diff_feather_points;
const unsigned int resol_a = BKE_mask_spline_resolution(spline, width, height) / 4;
const unsigned int resol_b = BKE_mask_spline_feather_resolution(spline, width, height) / 4;
@@ -676,7 +680,8 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
if (do_mask_aa == TRUE) {
if (do_feather == FALSE) {
tot_diff_feather_points = tot_diff_point;
diff_feather_points = MEM_mallocN(sizeof(*diff_feather_points) * tot_diff_feather_points,
diff_feather_points = MEM_mallocN(sizeof(*diff_feather_points) *
(size_t)tot_diff_feather_points,
__func__);
/* add single pixel feather */
maskrasterize_spline_differentiate_point_outset(diff_feather_points, diff_points,
@@ -905,9 +910,9 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
{
unsigned int (*face_array)[4], *face; /* access coords */
float (*face_coords)[3], *cos; /* xy, z 0-1 (1.0 == filled) */
int sf_tri_tot;
unsigned int sf_tri_tot;
rctf bounds;
int face_index;
unsigned int face_index;
/* now we have all the splines */
face_coords = MEM_mallocN((sizeof(float) * 3) * sf_vert_tot, "maskrast_face_coords");
@@ -933,9 +938,9 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
}
/* main scan-fill */
sf_tri_tot = BLI_scanfill_calc_ex(&sf_ctx, BLI_SCANFILL_CALC_HOLES, zvec);
sf_tri_tot = (unsigned int)BLI_scanfill_calc_ex(&sf_ctx, BLI_SCANFILL_CALC_HOLES, zvec);
face_array = MEM_mallocN(sizeof(*face_array) * (sf_tri_tot + tot_feather_quads), "maskrast_face_index");
face_array = MEM_mallocN(sizeof(*face_array) * ((size_t)sf_tri_tot + (size_t)tot_feather_quads), "maskrast_face_index");
face_index = 0;
/* faces */

View File

@@ -417,10 +417,10 @@ static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline
const short is_smooth = (draw_flag & MASK_DRAWFLAG_SMOOTH);
const short is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0;
int tot_diff_point;
unsigned int tot_diff_point;
float (*diff_points)[2];
int tot_feather_point;
unsigned int tot_feather_point;
float (*feather_points)[2];
diff_points = BKE_mask_spline_differentiate_with_resolution_ex(spline, &tot_diff_point, resol);