diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-07 22:24:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-07 22:24:36 +0400 |
commit | bdf9e023466756b6a75722cfa05ce75150e5ad75 (patch) | |
tree | b40653194b5a1b9f2fa8e31720df4b15bd6dc0f6 /source/blender/blenkernel/intern/mask.c | |
parent | 32530c28274c9c0de0707b39a6be9e4bafe7b257 (diff) |
new sequence strip type for masks.
Diffstat (limited to 'source/blender/blenkernel/intern/mask.c')
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 80 |
1 files changed, 54 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index aaae58a6ab7..b942b633aef 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -951,6 +951,10 @@ Mask *BKE_mask_new(const char *name) mask = mask_alloc(mask_name); + /* arbitrary defaults */ + mask->sfra = 1; + mask->efra = 100; + return mask; } @@ -2040,7 +2044,7 @@ static void m_invert_vn_vn(float *array, const float f, const int size) } } -static void linear_clamp_vn_vn(float *array, const int size) +static void clamp_vn_vn_linear(float *array, const int size) { float *arr = array + (size - 1); @@ -2053,8 +2057,26 @@ static void linear_clamp_vn_vn(float *array, const int size) } } +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(Mask *mask, int width, int height, float *buffer) +void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, + const short do_aspect_correct, const short do_linear) { MaskLayer *masklay; @@ -2087,31 +2109,32 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer) BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, &tot_diff_feather_points); - /* TODO, make this optional! */ - 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; - } + 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; - } + 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_feather_points) { + for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) { + (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f; + } } } } @@ -2173,7 +2196,12 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer) } /* clamp at the end */ - linear_clamp_vn_vn(buffer, buffer_size); + if (do_linear) { + clamp_vn_vn_linear(buffer, buffer_size); + } + else { + clamp_vn_vn(buffer, buffer_size); + } } MEM_freeN(buffer_tmp); |