diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-31 20:04:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-31 20:04:47 +0400 |
commit | 4c02549d5d90c698946c6beb9df344c05e453158 (patch) | |
tree | 12ad718582db598b16261832e38ff28c875aca0e /source/blender/blenkernel/intern/mask.c | |
parent | 2e5181195057b8e8525f2f91c107d6d67e2bdf3a (diff) |
remove references to raskter from compositor and BKE mask.
Diffstat (limited to 'source/blender/blenkernel/intern/mask.c')
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 253 |
1 files changed, 1 insertions, 252 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index a088a91000c..bb6e4d82bd2 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -56,8 +56,6 @@ #include "BKE_movieclip.h" #include "BKE_utildefines.h" -#include "raskter.h" - static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point) { if (point == &points_array[spline->tot_point - 1]) { @@ -2535,256 +2533,7 @@ void BKE_mask_layer_shape_changed_remove(MaskLayer *masklay, int index, int coun } } -/* local functions */ -static void invert_vn_vn(float *array, const int size) -{ - float *arr = array + (size - 1); - int i = size; - while (i--) { - *(arr) = 1.0f - *(arr); - arr--; - } -} - -static void m_invert_vn_vn(float *array, const float f, const int size) -{ - float *arr = array + (size - 1); - int i = size; - while (i--) { - *(arr) = 1.0f - (*(arr) * f); - arr--; - } -} - -static void clamp_vn_vn(float *array, const int size) -{ - float *arr = array + (size - 1); - - int i = size; - while (i--) { - if (*arr < 0.0f) *arr = 0.0f; - else if (*arr > 1.0f) *arr = 1.0f; - arr--; - } -} - int BKE_mask_get_duration(Mask *mask) { - return MAX2(1, mask->efra - mask->sfra); -} - -/* rasterization */ -void BKE_mask_rasterize_layers(ListBase *masklayers, int width, int height, float *buffer, - const short do_aspect_correct, const short do_mask_aa, - const short do_feather) -{ - MaskLayer *masklay; - - /* temp blending buffer */ - const int buffer_size = width * height; - float *buffer_tmp = MEM_mallocN(sizeof(float) * buffer_size, __func__); - - for (masklay = masklayers->first; masklay; masklay = masklay->next) { - MaskSpline *spline; - float alpha; - - if (masklay->restrictflag & MASK_RESTRICT_RENDER) { - continue; - } - - memset(buffer_tmp, 0, sizeof(float) * buffer_size); - - for (spline = masklay->splines.first; spline; spline = spline->next) { - float (*diff_points)[2]; - int tot_diff_point; - - float (*diff_feather_points)[2]; - int tot_diff_feather_points; - - diff_points = BKE_mask_spline_differentiate_with_resolution(spline, width, height, - &tot_diff_point); - - if (tot_diff_point) { - if (do_feather) { - diff_feather_points = - BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, - &tot_diff_feather_points); - } - else { - tot_diff_feather_points = 0; - diff_feather_points = NULL; - } - - if (do_aspect_correct) { - if (width != height) { - float *fp; - float *ffp; - int i; - float asp; - - if (width < height) { - fp = &diff_points[0][0]; - ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL; - asp = (float)width / (float)height; - } - else { - fp = &diff_points[0][1]; - ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL; - asp = (float)height / (float)width; - } - - for (i = 0; i < tot_diff_point; i++, fp += 2) { - (*fp) = (((*fp) - 0.5f) / asp) + 0.5f; - } - - if (tot_diff_feather_points) { - for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) { - (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f; - } - } - } - } - - if (tot_diff_point) { - PLX_raskterize(diff_points, tot_diff_point, - buffer_tmp, width, height,do_mask_aa); - - if (tot_diff_feather_points) { - PLX_raskterize_feather(diff_points, tot_diff_point, - diff_feather_points, tot_diff_feather_points, - buffer_tmp, width, height); - MEM_freeN(diff_feather_points); - } - - MEM_freeN(diff_points); - } - } - } - - /* blend with original */ - if (masklay->blend_flag & MASK_BLENDFLAG_INVERT) { - /* apply alpha multiply before inverting */ - if (masklay->alpha != 1.0f) { - m_invert_vn_vn(buffer_tmp, masklay->alpha, buffer_size); - } - else { - invert_vn_vn(buffer_tmp, buffer_size); - } - - alpha = 1.0f; - } - else { - alpha = masklay->alpha; - } - - switch (masklay->blend) { - case MASK_BLEND_SUBTRACT: - { - if (alpha == 1.0f) { - sub_vn_vn(buffer, buffer_tmp, buffer_size); - } - else { - msub_vn_vn(buffer, buffer_tmp, alpha, buffer_size); - } - break; - } - case MASK_BLEND_ADD: - default: - { - if (alpha == 1.0f) { - add_vn_vn(buffer, buffer_tmp, buffer_size); - } - else { - madd_vn_vn(buffer, buffer_tmp, alpha, buffer_size); - } - break; - } - } - - if (do_mask_aa) { - //PLX_antialias_buffer(buffer,width,height); - } - /* clamp at the end */ - clamp_vn_vn(buffer, buffer_size); - } - MEM_freeN(buffer_tmp); -} - -#ifdef __PLX_RASKTER_MT__ -void BKE_mask_init_layers(Mask *mask, struct layer_init_data *mlayer_data, int width, int height, const short do_aspect_correct) -{ - MaskLayer *masklay; - int numLayers=0; - int currLayer=0; - for (masklay = mask->masklayers->first; masklay; masklay = masklay->next) { - numLayers++; - } - mlayer_data = MEM_mallocN(sizeof(struct layer_init_data) * numLayers, __func__); //size correct? - - - for (masklay = mask->masklayers->first; masklay; masklay = masklay->next) { - MaskSpline *spline; - for (spline = masklay->splines.first; spline; spline = spline->next) { - float (*diff_points)[2]; - int tot_diff_point; - - float (*diff_feather_points)[2]; - int tot_diff_feather_points; - - diff_points = BKE_mask_spline_differentiate_with_resolution(spline, width, height, - &tot_diff_point); - - if (tot_diff_point) { - if (do_feather) { - diff_feather_points = - BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, - &tot_diff_feather_points); - } - else { - tot_diff_feather_points = 0; - diff_feather_points = NULL; - } - - if (do_aspect_correct) { - if (width != height) { - float *fp; - float *ffp; - int i; - float asp; - - if (width < height) { - fp = &diff_points[0][0]; - ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL; - asp = (float)width / (float)height; - } - else { - fp = &diff_points[0][1]; - ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL; - asp = (float)height / (float)width; - } - - for (i = 0; i < tot_diff_point; i++, fp += 2) { - (*fp) = (((*fp) - 0.5f) / asp) + 0.5f; - } - - if (tot_diff_feather_points) { - for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) { - (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f; - } - } - } - } - PLX_init_base_data(mlayer_data[currLayer], diff_points, tot_diff_points, width, height); - currLayer++; - } - } - } -} -#endif - -void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, - const short do_aspect_correct, const short do_mask_aa, - const short do_feather) -{ - BKE_mask_rasterize_layers(&mask->masklayers, width, height, buffer, do_aspect_correct, do_mask_aa, do_feather); + return maxi(1, mask->efra - mask->sfra); } |