~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to source/blender/blenkernel/intern/mask_rasterize.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
 
86
86
#include "BKE_mask.h"
87
87
 
 
88
#ifdef __GNUC__
 
89
#  pragma GCC diagnostic error "-Wsign-conversion"
 
90
#  if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406  /* gcc4.6+ only */
 
91
#    pragma GCC diagnostic error "-Wsign-compare"
 
92
#    pragma GCC diagnostic error "-Wconversion"
 
93
#  endif
 
94
#endif
 
95
 
88
96
/* this is rather and annoying hack, use define to isolate it.
89
97
 * problem is caused by scanfill removing edges on us. */
90
98
#define USE_SCANFILL_EDGE_WORKAROUND
331
339
        unsigned int *face = layer->face_array[face_index];
332
340
        float (*cos)[3] = layer->face_coords;
333
341
 
334
 
        const float xmin = layer->bounds.xmin + (bucket_size_x * bucket_x);
335
 
        const float ymin = layer->bounds.ymin + (bucket_size_y * bucket_y);
 
342
        const float xmin = layer->bounds.xmin + (bucket_size_x * (float)bucket_x);
 
343
        const float ymin = layer->bounds.ymin + (bucket_size_y * (float)bucket_y);
336
344
        const float xmax = xmin + bucket_size_x;
337
345
        const float ymax = ymin + bucket_size_y;
338
346
 
413
421
        const float bucket_dim_x = BLI_rctf_size_x(&layer->bounds);
414
422
        const float bucket_dim_y = BLI_rctf_size_y(&layer->bounds);
415
423
 
416
 
        layer->buckets_x = (bucket_dim_x / pixel_size) / (float)BUCKET_PIXELS_PER_CELL;
417
 
        layer->buckets_y = (bucket_dim_y / pixel_size) / (float)BUCKET_PIXELS_PER_CELL;
 
424
        layer->buckets_x = (unsigned int)((bucket_dim_x / pixel_size) / (float)BUCKET_PIXELS_PER_CELL);
 
425
        layer->buckets_y = (unsigned int)((bucket_dim_y / pixel_size) / (float)BUCKET_PIXELS_PER_CELL);
418
426
 
419
427
//              printf("bucket size %ux%u\n", layer->buckets_x, layer->buckets_y);
420
428
 
421
429
        CLAMP(layer->buckets_x, 8, 512);
422
430
        CLAMP(layer->buckets_y, 8, 512);
423
431
 
424
 
        layer->buckets_xy_scalar[0] = (1.0f / (bucket_dim_x + FLT_EPSILON)) * layer->buckets_x;
425
 
        layer->buckets_xy_scalar[1] = (1.0f / (bucket_dim_y + FLT_EPSILON)) * layer->buckets_y;
 
432
        layer->buckets_xy_scalar[0] = (1.0f / (bucket_dim_x + FLT_EPSILON)) * (float)layer->buckets_x;
 
433
        layer->buckets_xy_scalar[1] = (1.0f / (bucket_dim_y + FLT_EPSILON)) * (float)layer->buckets_y;
426
434
 
427
435
        {
428
436
                /* width and height of each bucket */
429
 
                const float bucket_size_x = (bucket_dim_x + FLT_EPSILON) / layer->buckets_x;
430
 
                const float bucket_size_y = (bucket_dim_y + FLT_EPSILON) / layer->buckets_y;
 
437
                const float bucket_size_x = (bucket_dim_x + FLT_EPSILON) / (float)layer->buckets_x;
 
438
                const float bucket_size_y = (bucket_dim_y + FLT_EPSILON) / (float)layer->buckets_y;
431
439
                const float bucket_max_rad = (max_ff(bucket_size_x, bucket_size_y) * (float)M_SQRT2) + FLT_EPSILON;
432
440
                const float bucket_max_rad_squared = bucket_max_rad * bucket_max_rad;
433
441
 
522
530
 
523
531
                if (1) {
524
532
                        /* now convert linknodes into arrays for faster per pixel access */
525
 
                        unsigned int  **buckets_face = MEM_mallocN(bucket_tot * sizeof(unsigned int **), __func__);
 
533
                        unsigned int  **buckets_face = MEM_mallocN(bucket_tot * sizeof(*buckets_face), __func__);
526
534
                        unsigned int bucket_index;
527
535
 
528
536
                        for (bucket_index = 0; bucket_index < bucket_tot; bucket_index++) {
568
576
        MaskLayer *masklay;
569
577
        unsigned int masklay_index;
570
578
 
571
 
        mr_handle->layers_tot = BLI_countlist(&mask->masklayers);
 
579
        mr_handle->layers_tot = (unsigned int)BLI_countlist(&mask->masklayers);
572
580
        mr_handle->layers = MEM_mallocN(sizeof(MaskRasterLayer) * mr_handle->layers_tot, "MaskRasterLayer");
573
581
        BLI_rctf_init_minmax(&mr_handle->bounds);
574
582
 
602
610
                        continue;
603
611
                }
604
612
 
605
 
                tot_splines = BLI_countlist(&masklay->splines);
 
613
                tot_splines = (unsigned int)BLI_countlist(&masklay->splines);
606
614
                open_spline_ranges = MEM_callocN(sizeof(*open_spline_ranges) * tot_splines, __func__);
607
615
 
608
616
                BLI_scanfill_begin(&sf_ctx);
612
620
                        const unsigned int is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0;
613
621
 
614
622
                        float (*diff_points)[2];
615
 
                        int tot_diff_point;
 
623
                        unsigned int tot_diff_point;
616
624
 
617
625
                        float (*diff_feather_points)[2];
618
626
                        float (*diff_feather_points_flip)[2];
619
 
                        int tot_diff_feather_points;
 
627
                        unsigned int tot_diff_feather_points;
620
628
 
621
629
                        const unsigned int resol_a = BKE_mask_spline_resolution(spline, width, height) / 4;
622
630
                        const unsigned int resol_b = BKE_mask_spline_feather_resolution(spline, width, height) / 4;
637
645
 
638
646
                        if (tot_diff_point > 3) {
639
647
                                ScanFillVert *sf_vert_prev;
640
 
                                int j;
 
648
                                unsigned int j;
641
649
 
642
650
                                float co[3];
643
651
                                co[2] = 0.0f;
646
654
                                        if (width != height) {
647
655
                                                float *fp;
648
656
                                                float *ffp;
649
 
                                                int i;
 
657
                                                unsigned int i;
650
658
                                                float asp;
651
659
 
652
660
                                                if (width < height) {
676
684
                                if (do_mask_aa == TRUE) {
677
685
                                        if (do_feather == FALSE) {
678
686
                                                tot_diff_feather_points = tot_diff_point;
679
 
                                                diff_feather_points = MEM_mallocN(sizeof(*diff_feather_points) * tot_diff_feather_points,
 
687
                                                diff_feather_points = MEM_mallocN(sizeof(*diff_feather_points) *
 
688
                                                                                  (size_t)tot_diff_feather_points,
680
689
                                                                                  __func__);
681
690
                                                /* add single pixel feather */
682
691
                                                maskrasterize_spline_differentiate_point_outset(diff_feather_points, diff_points,
841
850
                                                        fp_turn = diff_feather_points[0];
842
851
 
843
852
#define CALC_CAP_RESOL                                                                      \
844
 
        clampis_uint((len_v2v2(fp_cent, fp_turn) / (pixel_size * SPLINE_RESOL_CAP_PER_PIXEL)),  \
845
 
                     SPLINE_RESOL_CAP_MIN,                                                      \
846
 
                     SPLINE_RESOL_CAP_MAX)
 
853
        clampis_uint((unsigned int )(len_v2v2(fp_cent, fp_turn) /                               \
 
854
                                     (pixel_size * SPLINE_RESOL_CAP_PER_PIXEL)),                \
 
855
                     SPLINE_RESOL_CAP_MIN, SPLINE_RESOL_CAP_MAX)
847
856
 
848
857
                                                        {
849
858
                                                                const unsigned int vertex_total_cap = CALC_CAP_RESOL;
850
859
 
851
860
                                                                for (k = 1; k < vertex_total_cap; k++) {
852
 
                                                                        const float angle = (float)k * (1.0f / vertex_total_cap) * (float)M_PI;
 
861
                                                                        const float angle = (float)k * (1.0f / (float)vertex_total_cap) * (float)M_PI;
853
862
                                                                        rotate_point_v2(co_feather, fp_turn, fp_cent, angle, asp_xy);
854
863
 
855
864
                                                                        sf_vert = BLI_scanfill_vert_add(&sf_ctx, co_feather);
869
878
                                                                const unsigned int vertex_total_cap = CALC_CAP_RESOL;
870
879
 
871
880
                                                                for (k = 1; k < vertex_total_cap; k++) {
872
 
                                                                        const float angle = (float)k * (1.0f / vertex_total_cap) * (float)M_PI;
 
881
                                                                        const float angle = (float)k * (1.0f / (float)vertex_total_cap) * (float)M_PI;
873
882
                                                                        rotate_point_v2(co_feather, fp_turn, fp_cent, -angle, asp_xy);
874
883
 
875
884
                                                                        sf_vert = BLI_scanfill_vert_add(&sf_ctx, co_feather);
905
914
                {
906
915
                        unsigned int (*face_array)[4], *face;  /* access coords */
907
916
                        float        (*face_coords)[3], *cos; /* xy, z 0-1 (1.0 == filled) */
908
 
                        int sf_tri_tot;
 
917
                        unsigned int sf_tri_tot;
909
918
                        rctf bounds;
910
 
                        int face_index;
 
919
                        unsigned int face_index;
911
920
 
912
921
                        /* now we have all the splines */
913
922
                        face_coords = MEM_mallocN((sizeof(float) * 3) * sf_vert_tot, "maskrast_face_coords");
933
942
                        }
934
943
 
935
944
                        /* main scan-fill */
936
 
                        sf_tri_tot = BLI_scanfill_calc_ex(&sf_ctx, BLI_SCANFILL_CALC_HOLES, zvec);
 
945
                        sf_tri_tot = (unsigned int)BLI_scanfill_calc_ex(&sf_ctx, BLI_SCANFILL_CALC_HOLES, zvec);
937
946
 
938
 
                        face_array = MEM_mallocN(sizeof(*face_array) * (sf_tri_tot + tot_feather_quads), "maskrast_face_index");
 
947
                        face_array = MEM_mallocN(sizeof(*face_array) * ((size_t)sf_tri_tot + (size_t)tot_feather_quads), "maskrast_face_index");
939
948
                        face_index = 0;
940
949
 
941
950
                        /* faces */