2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2012 Blender Foundation.
19 * All rights reserved.
21 * Contributor(s): Blender Foundation,
24 * ***** END GPL LICENSE BLOCK *****
27 #ifndef __BKE_MASK_H__
28 #define __BKE_MASK_H__
35 struct MaskLayerShape;
37 struct MaskSplinePoint;
38 struct MaskSplinePointUW;
43 struct MaskSplinePoint *BKE_mask_spline_point_array(struct MaskSpline *spline);
44 struct MaskSplinePoint *BKE_mask_spline_point_array_from_point(struct MaskSpline *spline, struct MaskSplinePoint *point_ref);
47 struct MaskLayer *BKE_mask_layer_new(struct Mask *mask, const char *name);
48 struct MaskLayer *BKE_mask_layer_active(struct Mask *mask);
49 void BKE_mask_layer_active_set(struct Mask *mask, struct MaskLayer *masklay);
50 void BKE_mask_layer_remove(struct Mask *mask, struct MaskLayer *masklay);
52 void BKE_mask_layer_free_shapes(struct MaskLayer *masklay);
53 void BKE_mask_layer_free(struct MaskLayer *masklay);
54 void BKE_mask_layer_free_list(struct ListBase *masklayers);
55 void BKE_mask_spline_free(struct MaskSpline *spline);
56 struct MaskSpline *BKE_mask_spline_copy(struct MaskSpline *spline);
57 void BKE_mask_point_free(struct MaskSplinePoint *point);
59 void BKE_mask_layer_unique_name(struct Mask *mask, struct MaskLayer *masklay);
61 struct MaskLayer *BKE_mask_layer_copy(struct MaskLayer *layer);
62 void BKE_mask_layer_copy_list(struct ListBase *masklayers_new, struct ListBase *masklayers);
65 struct MaskSpline *BKE_mask_spline_add(struct MaskLayer *masklay);
67 float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point))[2];
68 float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point))[2];
70 float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2];
71 float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline,
72 int width, int height, int *tot_feather_point))[2];
74 float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2];
76 void BKE_mask_point_direction_switch(struct MaskSplinePoint *point);
77 void BKE_mask_spline_direction_switch(struct MaskLayer *masklay, struct MaskSpline *spline);
84 float BKE_mask_spline_project_co(struct MaskSpline *spline, struct MaskSplinePoint *point,
85 float start_u, const float co[2], const eMaskSign sign);
88 int BKE_mask_point_has_handle(struct MaskSplinePoint *point);
89 void BKE_mask_point_handle(struct MaskSplinePoint *point, float handle[2]);
90 void BKE_mask_point_set_handle(struct MaskSplinePoint *point, float loc[2], int keep_direction,
91 float orig_handle[2], float orig_vec[3][3]);
93 float *BKE_mask_point_segment_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, int *tot_diff_point);
94 float *BKE_mask_point_segment_feather_diff(struct MaskSpline *spline, struct MaskSplinePoint *point,
95 int *tot_feather_point);
97 float *BKE_mask_point_segment_diff_with_resolution(struct MaskSpline *spline, struct MaskSplinePoint *point,
98 int width, int height, int *tot_diff_point);
100 float *BKE_mask_point_segment_feather_diff_with_resolution(struct MaskSpline *spline, struct MaskSplinePoint *point,
101 int width, int height,
102 int *tot_feather_point);
104 void BKE_mask_point_segment_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float co[2]);
105 void BKE_mask_point_normal(struct MaskSpline *spline, struct MaskSplinePoint *point,
106 float u, float n[2]);
107 float BKE_mask_point_weight_scalar(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u);
108 float BKE_mask_point_weight(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u);
109 struct MaskSplinePointUW *BKE_mask_point_sort_uw(struct MaskSplinePoint *point, struct MaskSplinePointUW *uw);
110 void BKE_mask_point_add_uw(struct MaskSplinePoint *point, float u, float w);
112 void BKE_mask_point_select_set(struct MaskSplinePoint *point, const short do_select);
113 void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point, const short do_select);
116 struct Mask *BKE_mask_new(const char *name);
118 void BKE_mask_free(struct Mask *mask);
119 void BKE_mask_unlink(struct Main *bmain, struct Mask *mask);
121 void BKE_mask_coord_from_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2]);
122 void BKE_mask_coord_to_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2]);
126 void BKE_mask_update_display(struct Mask *mask, float ctime);
128 void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const int do_newframe);
129 void BKE_mask_evaluate(struct Mask *mask, const float ctime, const int do_newframe);
130 void BKE_mask_layer_evaluate(struct MaskLayer *masklay, const float ctime, const int do_newframe);
131 void BKE_mask_update_scene(struct Main *bmain, struct Scene *scene, const int do_newframe);
132 void BKE_mask_parent_init(struct MaskParent *parent);
133 void BKE_mask_calc_handle_adjacent_interp(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u);
134 void BKE_mask_calc_tangent_polyline(struct MaskSpline *spline, struct MaskSplinePoint *point, float t[2]);
135 void BKE_mask_calc_handle_point(struct MaskSpline *spline, struct MaskSplinePoint *point);
136 void BKE_mask_calc_handle_point_auto(struct MaskSpline *spline, struct MaskSplinePoint *point,
137 const short do_recalc_length);
138 void BKE_mask_get_handle_point_adjacent(struct MaskSpline *spline, struct MaskSplinePoint *point,
139 struct MaskSplinePoint **r_point_prev, struct MaskSplinePoint **r_point_next);
140 void BKE_mask_layer_calc_handles(struct MaskLayer *masklay);
141 void BKE_mask_layer_calc_handles_deform(struct MaskLayer *masklay);
142 void BKE_mask_calc_handles(struct Mask *mask);
143 void BKE_mask_calc_handles_deform(struct Mask *mask);
144 void BKE_mask_spline_ensure_deform(struct MaskSpline *spline);
147 int BKE_mask_layer_shape_totvert(struct MaskLayer *masklay);
148 void BKE_mask_layer_shape_from_mask(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape);
149 void BKE_mask_layer_shape_to_mask(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape);
150 void BKE_mask_layer_shape_to_mask_interp(struct MaskLayer *masklay,
151 struct MaskLayerShape *masklay_shape_a,
152 struct MaskLayerShape *masklay_shape_b,
154 struct MaskLayerShape *BKE_mask_layer_shape_find_frame(struct MaskLayer *masklay, const int frame);
155 int BKE_mask_layer_shape_find_frame_range(struct MaskLayer *masklay, const float frame,
156 struct MaskLayerShape **r_masklay_shape_a,
157 struct MaskLayerShape **r_masklay_shape_b);
158 struct MaskLayerShape *BKE_mask_layer_shape_alloc(struct MaskLayer *masklay, const int frame);
159 void BKE_mask_layer_shape_free(struct MaskLayerShape *masklay_shape);
160 struct MaskLayerShape *BKE_mask_layer_shape_varify_frame(struct MaskLayer *masklay, const int frame);
161 struct MaskLayerShape *BKE_mask_layer_shape_duplicate(struct MaskLayerShape *masklay_shape);
162 void BKE_mask_layer_shape_unlink(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape);
163 void BKE_mask_layer_shape_sort(struct MaskLayer *masklay);
165 int BKE_mask_layer_shape_spline_from_index(struct MaskLayer *masklay, int index,
166 struct MaskSpline **r_masklay_shape, int *r_index);
167 int BKE_mask_layer_shape_spline_to_index(struct MaskLayer *masklay, struct MaskSpline *spline);
169 int BKE_mask_layer_shape_spline_index(struct MaskLayer *masklay, int index,
170 struct MaskSpline **r_masklay_shape, int *r_index);
171 void BKE_mask_layer_shape_changed_add(struct MaskLayer *masklay, int index,
172 int do_init, int do_init_interpolate);
174 void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, int count);
177 int BKE_mask_get_duration(struct Mask *mask);
179 void BKE_mask_rasterize_layers(struct ListBase *masklayers, int width, int height, float *buffer,
180 const short do_aspect_correct, const short do_mask_aa,
181 const short do_feather);
183 void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer,
184 const short do_aspect_correct, const short do_mask_aa,
185 const short do_feather);
187 #define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f2) & SELECT)
188 #define MASKPOINT_ISSEL_KNOT(p) ( (p)->bezt.f2 & SELECT)
189 #define MASKPOINT_ISSEL_HANDLE_ONLY(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) && (((p)->bezt.f2 & SELECT) == 0) )
190 #define MASKPOINT_ISSEL_HANDLE(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) )
192 #define MASKPOINT_SEL_ALL(p) { (p)->bezt.f1 |= SELECT; (p)->bezt.f2 |= SELECT; (p)->bezt.f3 |= SELECT; } (void)0
193 #define MASKPOINT_DESEL_ALL(p) { (p)->bezt.f1 &= ~SELECT; (p)->bezt.f2 &= ~SELECT; (p)->bezt.f3 &= ~SELECT; } (void)0
194 #define MASKPOINT_INVSEL_ALL(p) { (p)->bezt.f1 ^= SELECT; (p)->bezt.f2 ^= SELECT; (p)->bezt.f3 ^= SELECT; } (void)0
196 #define MASKPOINT_SEL_HANDLE(p) { (p)->bezt.f1 |= SELECT; (p)->bezt.f3 |= SELECT; } (void)0
197 #define MASKPOINT_DESEL_HANDLE(p) { (p)->bezt.f1 &= ~SELECT; (p)->bezt.f3 &= ~SELECT; } (void)0