diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-01-08 14:24:36 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-01-08 14:26:21 +0300 |
commit | 707500b5c49b4fb31c002b94d9cc6a6d5e9797bb (patch) | |
tree | 59c85b2871ba8abf0c7b29472937c947ffd6aa71 | |
parent | 875be10903465978562d6865ce06f6ff5bae20b4 (diff) |
Tracking: Use BLI mask rasterization for track masks
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 4235d96c3c1..4409833fcdd 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -64,8 +64,6 @@ #include "RNA_access.h" -#include "raskter.h" - #include "libmv-capi.h" #include "tracking_private.h" @@ -810,31 +808,51 @@ static bGPDlayer *track_mask_gpencil_layer_get(MovieTrackingTrack *track) return NULL; } +typedef struct TrackMaskSetPixelData { + float *mask; + int mask_width; + int mask_height; +} TrackMaskSetPixelData; + +static void track_mask_set_pixel_cb(int x, int y, void *user_data) +{ + TrackMaskSetPixelData *data = (TrackMaskSetPixelData *)user_data; + size_t index = (size_t)y * data->mask_width + x; + data->mask[index] = 1.0f; +} + static void track_mask_gpencil_layer_rasterize(int frame_width, int frame_height, MovieTrackingMarker *marker, bGPDlayer *layer, float *mask, int mask_width, int mask_height) { bGPDframe *frame = layer->frames.first; + TrackMaskSetPixelData data; + + data.mask = mask; + data.mask_width = mask_width; + data.mask_height = mask_height; while (frame) { bGPDstroke *stroke = frame->strokes.first; while (stroke) { bGPDspoint *stroke_points = stroke->points; - float *mask_points, *fp; + int *mask_points, *point; int i; if (stroke->flag & GP_STROKE_2DSPACE) { - fp = mask_points = MEM_callocN(2 * stroke->totpoints * sizeof(float), + point = mask_points = MEM_callocN(2 * stroke->totpoints * sizeof(int), "track mask rasterization points"); - for (i = 0; i < stroke->totpoints; i++, fp += 2) { - fp[0] = (stroke_points[i].x - marker->search_min[0]) * frame_width / mask_width; - fp[1] = (stroke_points[i].y - marker->search_min[1]) * frame_height / mask_height; + for (i = 0; i < stroke->totpoints; i++, point += 2) { + point[0] = (stroke_points[i].x - marker->search_min[0]) * frame_width; + point[1] = (stroke_points[i].y - marker->search_min[1]) * frame_height; } /* TODO: add an option to control whether AA is enabled or not */ - PLX_raskterize((float (*)[2])mask_points, stroke->totpoints, mask, mask_width, mask_height); + fill_poly_v2i_n(0, 0, mask_width, mask_height, + (const int (*)[2])mask_points, stroke->totpoints, + track_mask_set_pixel_cb, &data); MEM_freeN(mask_points); } |