Blender V4.3
mask_draw.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "MEM_guardedalloc.h"
10
11#include "BLI_listbase.h"
12#include "BLI_math_color.h"
13#include "BLI_rect.h"
14#include "BLI_utildefines.h"
15
16#include "BKE_context.hh"
17#include "BKE_mask.h"
18
19#include "DNA_mask_types.h"
20#include "DNA_object_types.h" /* SELECT */
21#include "DNA_screen_types.h"
22#include "DNA_space_types.h"
23
24#include "ED_clip.hh"
25#include "ED_mask.hh" /* own include */
26#include "ED_screen.hh"
27#include "ED_space_api.hh"
28
29#include "BIF_glutil.hh"
30
31#include "GPU_immediate.hh"
32#include "GPU_matrix.hh"
33#include "GPU_shader.hh"
34#include "GPU_state.hh"
35
36#include "UI_resources.hh"
37#include "UI_view2d.hh"
38
40
41static void mask_spline_color_get(MaskLayer *mask_layer,
42 MaskSpline *spline,
43 const bool is_sel,
44 uchar r_rgb[4])
45{
46 if (is_sel) {
47 if (mask_layer->act_spline == spline) {
48 r_rgb[0] = r_rgb[1] = r_rgb[2] = 255;
49 }
50 else {
51 r_rgb[0] = 255;
52 r_rgb[1] = r_rgb[2] = 0;
53 }
54 }
55 else {
56 r_rgb[0] = 128;
57 r_rgb[1] = r_rgb[2] = 0;
58 }
59
60 r_rgb[3] = 255;
61}
62
63static void mask_spline_feather_color_get(MaskLayer * /*mask_layer*/,
64 MaskSpline * /*spline*/,
65 const bool is_sel,
66 uchar r_rgb[4])
67{
68 if (is_sel) {
69 r_rgb[1] = 255;
70 r_rgb[0] = r_rgb[2] = 0;
71 }
72 else {
73 r_rgb[1] = 128;
74 r_rgb[0] = r_rgb[2] = 0;
75 }
76
77 r_rgb[3] = 255;
78}
79
80static void mask_point_undistort_pos(SpaceClip *sc, float r_co[2], const float co[2])
81{
82 BKE_mask_coord_to_movieclip(sc->clip, &sc->user, r_co, co);
83 ED_clip_point_undistorted_pos(sc, r_co, r_co);
84 BKE_mask_coord_from_movieclip(sc->clip, &sc->user, r_co, r_co);
85}
86
87static void draw_single_handle(const MaskLayer *mask_layer,
89 const eMaskWhichHandle which_handle,
90 const int draw_type,
91 const float handle_size,
92 const float point_pos[2],
93 const float handle_pos[2])
94{
95 const BezTriple *bezt = &point->bezt;
96 char handle_type;
97
99 handle_type = bezt->h1;
100 }
101 else {
102 handle_type = bezt->h2;
103 }
104
105 if (handle_type == HD_VECT) {
106 return;
107 }
108
111 const uchar rgb_gray[4] = {0x60, 0x60, 0x60, 0xff};
112
114 immUniformColor3ubv(rgb_gray);
115
116 /* this could be split into its own loop */
117 if (draw_type == MASK_DT_OUTLINE) {
118 GPU_line_width(3.0f);
120 immVertex2fv(pos, point_pos);
121 immVertex2fv(pos, handle_pos);
122 immEnd();
123 }
124
125 switch (handle_type) {
126 case HD_FREE:
128 break;
129 case HD_AUTO:
131 break;
132 case HD_ALIGN:
135 break;
136 }
137
138 GPU_line_width(1.0f);
140 immVertex2fv(pos, point_pos);
141 immVertex2fv(pos, handle_pos);
142 immEnd();
144
145 /* draw handle points */
147 immUniform1f("size", handle_size);
148 immUniform1f("outlineWidth", 1.5f);
149
150 float point_color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; /* active color by default */
151 if (MASKPOINT_ISSEL_HANDLE(point, which_handle)) {
152 if (point != mask_layer->act_point) {
154 }
155 }
156 else {
158 }
159
160 immUniform4fv("outlineColor", point_color);
161 immUniformColor3fvAlpha(point_color, 0.25f);
162
164 immVertex2fv(pos, handle_pos);
165 immEnd();
166
168}
169
170/* return non-zero if spline is selected */
171static void draw_spline_points(const bContext *C,
172 MaskLayer *mask_layer,
173 MaskSpline *spline,
174 const char draw_type)
175{
176 const bool is_spline_sel = (spline->flag & SELECT) &&
177 (mask_layer->visibility_flag & MASK_HIDE_SELECT) == 0;
178
179 uchar rgb_spline[4];
180 MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
182 bool undistort = false;
183
184 int tot_feather_point;
185 float(*feather_points)[2], (*fp)[2];
186 float min[2], max[2];
187
188 if (!spline->tot_point) {
189 return;
190 }
191
192 if (sc) {
193 undistort = sc->clip && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT);
194 }
195
196 /* TODO: add this to sequence editor. */
197 float handle_size = 2.0f * UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
198
199 mask_spline_color_get(mask_layer, spline, is_spline_sel, rgb_spline);
200
203
205 immUniform1f("size", 0.7f * handle_size);
206
207 /* feather points */
208 feather_points = fp = BKE_mask_spline_feather_points(spline, &tot_feather_point);
209 for (int i = 0; i < spline->tot_point; i++) {
210
211 /* watch it! this is intentionally not the deform array, only check for sel */
212 MaskSplinePoint *point = &spline->points[i];
213
214 for (int j = 0; j <= point->tot_uw; j++) {
215 float feather_point[2];
216 bool sel = false;
217
218 copy_v2_v2(feather_point, *fp);
219
220 if (undistort) {
221 mask_point_undistort_pos(sc, feather_point, feather_point);
222 }
223
224 if (j == 0) {
226 }
227 else {
228 sel = (point->uw[j - 1].flag & SELECT) != 0;
229 }
230
231 if (sel) {
232 if (point == mask_layer->act_point) {
233 immUniformColor3f(1.0f, 1.0f, 1.0f);
234 }
235 else {
237 }
238 }
239 else {
241 }
242
244 immVertex2fv(pos, feather_point);
245 immEnd();
246
247 fp++;
248 }
249 }
250 MEM_freeN(feather_points);
251
253
254 GPU_line_smooth(true);
255
256 /* control points */
258 for (int i = 0; i < spline->tot_point; i++) {
259
260 /* watch it! this is intentionally not the deform array, only check for sel */
261 MaskSplinePoint *point = &spline->points[i];
262 MaskSplinePoint *point_deform = &points_array[i];
263 BezTriple *bezt = &point_deform->bezt;
264
265 float vert[2];
266
267 copy_v2_v2(vert, bezt->vec[1]);
268
269 if (undistort) {
270 mask_point_undistort_pos(sc, vert, vert);
271 }
272
273 /* draw handle segment */
275 float handle[2];
276 BKE_mask_point_handle(point_deform, MASK_WHICH_HANDLE_STICK, handle);
277 if (undistort) {
278 mask_point_undistort_pos(sc, handle, handle);
279 }
281 mask_layer, point, MASK_WHICH_HANDLE_STICK, draw_type, handle_size, vert, handle);
282 }
283 else {
284 float handle_left[2], handle_right[2];
285 BKE_mask_point_handle(point_deform, MASK_WHICH_HANDLE_LEFT, handle_left);
286 BKE_mask_point_handle(point_deform, MASK_WHICH_HANDLE_RIGHT, handle_right);
287 if (undistort) {
288 mask_point_undistort_pos(sc, handle_left, handle_left);
289 mask_point_undistort_pos(sc, handle_left, handle_left);
290 }
292 mask_layer, point, MASK_WHICH_HANDLE_LEFT, draw_type, handle_size, vert, handle_left);
294 mask_layer, point, MASK_WHICH_HANDLE_RIGHT, draw_type, handle_size, vert, handle_right);
295 }
296
297 /* bind program in loop so it does not interfere with draw_single_handle */
299
300 /* draw CV point */
302 if (point == mask_layer->act_point) {
303 immUniformColor3f(1.0f, 1.0f, 1.0f);
304 }
305 else {
307 }
308 }
309 else {
311 }
312
314 immVertex2fv(pos, vert);
315 immEnd();
316
318
319 minmax_v2v2_v2(min, max, vert);
320 }
321
322 GPU_line_smooth(false);
323
324 if (is_spline_sel) {
325 float x = (min[0] + max[0]) * 0.5f;
326 float y = (min[1] + max[1]) * 0.5f;
327
329 immUniform1f("outlineWidth", 1.5f);
330
331 if (mask_layer->act_spline == spline) {
332 immUniformColor3f(1.0f, 1.0f, 1.0f);
333 }
334 else {
335 immUniformColor3f(1.0f, 1.0f, 0.0f);
336 }
337
338 immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 1.0f);
339 immUniform1f("size", 12.0f);
340
342 immVertex2f(pos, x, y);
343 immEnd();
344
346 }
347}
348
349static void mask_color_active_tint(uchar r_rgb[4], const uchar rgb[4], const bool is_active)
350{
351 if (!is_active) {
352 r_rgb[0] = uchar((int(rgb[0]) + 128) / 2);
353 r_rgb[1] = uchar((int(rgb[1]) + 128) / 2);
354 r_rgb[2] = uchar((int(rgb[2]) + 128) / 2);
355 r_rgb[3] = rgb[3];
356 }
357 else {
358 *(uint *)r_rgb = *(const uint *)rgb;
359 }
360}
361
363 GPUPrimType prim_type,
364 const float (*points)[2],
365 uint vertex_len)
366{
367 immBegin(prim_type, vertex_len);
368 for (uint i = 0; i < vertex_len; i++) {
369 immVertex2fv(pos, points[i]);
370 }
371 immEnd();
372}
373
374static void mask_draw_curve_type(const bContext *C,
375 MaskSpline *spline,
376 float (*orig_points)[2],
377 int tot_point,
378 const bool is_feather,
379 const bool is_active,
380 const uchar rgb_spline[4],
381 const char draw_type)
382{
383 const GPUPrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GPU_PRIM_LINE_LOOP :
385 const uchar rgb_black[4] = {0x00, 0x00, 0x00, 0xff};
386 uchar rgb_tmp[4];
388 float(*points)[2] = orig_points;
389
390 if (sc) {
391 const bool undistort = sc->clip && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT);
392
393 if (undistort) {
394 points = MEM_cnew_array<float[2]>(tot_point, "undistorthed mask curve");
395
396 for (int i = 0; i < tot_point; i++) {
397 mask_point_undistort_pos(sc, points[i], orig_points[i]);
398 }
399 }
400 }
401
404
405 switch (draw_type) {
406
407 case MASK_DT_OUTLINE:
408 /* TODO(merwin): use fancy line shader here
409 * probably better with geometry shader (after core profile switch)
410 */
412
413 GPU_line_width(3.0f);
414
415 mask_color_active_tint(rgb_tmp, rgb_black, is_active);
416 immUniformColor4ubv(rgb_tmp);
417 mask_draw_array(pos, draw_method, points, tot_point);
418
419 GPU_line_width(1.0f);
420
421 mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
422 immUniformColor4ubv(rgb_tmp);
423 mask_draw_array(pos, draw_method, points, tot_point);
424
426 break;
427
428 case MASK_DT_BLACK:
429 case MASK_DT_WHITE:
431 GPU_line_width(1.0f);
432
433 if (draw_type == MASK_DT_BLACK) {
434 rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 0;
435 }
436 else {
437 rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 255;
438 }
439 /* alpha values seem too low but gl draws many points that compensate for it */
440 if (is_feather) {
441 rgb_tmp[3] = 64;
442 }
443 else {
444 rgb_tmp[3] = 128;
445 }
446
447 if (is_feather) {
448 rgb_tmp[0] = uchar((short(rgb_tmp[0]) + short(rgb_spline[0])) / 2);
449 rgb_tmp[1] = uchar((short(rgb_tmp[1]) + short(rgb_spline[1])) / 2);
450 rgb_tmp[2] = uchar((short(rgb_tmp[2]) + short(rgb_spline[2])) / 2);
451 }
452
453 mask_color_active_tint(rgb_tmp, rgb_tmp, is_active);
454 immUniformColor4ubv(rgb_tmp);
455 mask_draw_array(pos, draw_method, points, tot_point);
456
458 break;
459
460 case MASK_DT_DASH: {
461 float colors[2][4];
462
463 mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
464 rgba_uchar_to_float(colors[0], rgb_tmp);
465 mask_color_active_tint(rgb_tmp, rgb_black, is_active);
466 rgba_uchar_to_float(colors[1], rgb_tmp);
467
469
470 float viewport_size[4];
471 GPU_viewport_size_get_f(viewport_size);
473 "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
474
475 immUniform1i("colors_len", 2); /* "advanced" mode */
476 immUniform4fv("color", colors[0]);
477 immUniform4fv("color2", colors[1]);
478 immUniform1f("dash_width", 4.0f);
479 immUniform1f("udash_factor", 0.5f);
480 GPU_line_width(1.0f);
481
482 mask_draw_array(pos, draw_method, points, tot_point);
483
485 break;
486 }
487
488 default:
489 BLI_assert(false);
490 }
491
492 if (points != orig_points) {
493 MEM_freeN(points);
494 }
495}
496
497static void draw_spline_curve(const bContext *C,
498 MaskLayer *mask_layer,
499 MaskSpline *spline,
500 const char draw_type,
501 const bool is_active,
502 const int width,
503 const int height)
504{
505 const uint resol = max_ii(BKE_mask_spline_feather_resolution(spline, width, height),
506 BKE_mask_spline_resolution(spline, width, height));
507
508 uchar rgb_tmp[4];
509
510 const bool is_spline_sel = (spline->flag & SELECT) &&
511 (mask_layer->visibility_flag & MASK_HIDE_SELECT) == 0;
512 const bool is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0;
513
514 uint tot_diff_point;
515 float(*diff_points)[2];
516
517 uint tot_feather_point;
518 float(*feather_points)[2];
519
520 diff_points = BKE_mask_spline_differentiate_with_resolution(spline, resol, &tot_diff_point);
521
522 if (!diff_points) {
523 return;
524 }
525
526 GPU_line_smooth(true);
527
529 spline, resol, (is_fill != false), &tot_feather_point);
530
531 /* draw feather */
532 mask_spline_feather_color_get(mask_layer, spline, is_spline_sel, rgb_tmp);
534 C, spline, feather_points, tot_feather_point, true, is_active, rgb_tmp, draw_type);
535
536 if (!is_fill) {
537 const float *fp = &diff_points[0][0];
538 float *fp_feather = &feather_points[0][0];
539
540 BLI_assert(tot_diff_point == tot_feather_point);
541
542 for (int i = 0; i < tot_diff_point; i++, fp += 2, fp_feather += 2) {
543 float tvec[2];
544 sub_v2_v2v2(tvec, fp, fp_feather);
545 add_v2_v2v2(fp_feather, fp, tvec);
546 }
547
548 /* same as above */
550 C, spline, feather_points, tot_feather_point, true, is_active, rgb_tmp, draw_type);
551 }
552
553 MEM_freeN(feather_points);
554
555 /* draw main curve */
556 mask_spline_color_get(mask_layer, spline, is_spline_sel, rgb_tmp);
558 C, spline, diff_points, tot_diff_point, false, is_active, rgb_tmp, draw_type);
559 MEM_freeN(diff_points);
560
561 GPU_line_smooth(false);
562}
563
564static void draw_layer_splines(const bContext *C,
565 MaskLayer *layer,
566 const char draw_type,
567 const int width,
568 const int height,
569 const bool is_active)
570{
571 LISTBASE_FOREACH (MaskSpline *, spline, &layer->splines) {
572 /* draw curve itself first... */
573 draw_spline_curve(C, layer, spline, draw_type, is_active, width, height);
574
575 if (!(layer->visibility_flag & MASK_HIDE_SELECT)) {
576 /* ...and then handles over the curve so they're nicely visible */
577 draw_spline_points(C, layer, spline, draw_type);
578 }
579
580 /* show undeform for testing */
581 if (false) {
582 MaskSplinePoint *back = spline->points_deform;
583
584 spline->points_deform = nullptr;
585 draw_spline_curve(C, layer, spline, draw_type, is_active, width, height);
586 draw_spline_points(C, layer, spline, draw_type);
587 spline->points_deform = back;
588 }
589 }
590}
591
593 const bContext *C, Mask *mask, const char draw_type, const int width, const int height)
594{
597
598 MaskLayer *active = nullptr;
599 int i;
600 LISTBASE_FOREACH_INDEX (MaskLayer *, mask_layer, &mask->masklayers, i) {
601 const bool is_active = (i == mask->masklay_act);
602
603 if (mask_layer->visibility_flag & MASK_HIDE_VIEW) {
604 continue;
605 }
606
607 if (is_active) {
608 active = mask_layer;
609 continue;
610 }
611
612 draw_layer_splines(C, mask_layer, draw_type, width, height, is_active);
613 }
614
615 if (active != nullptr) {
616 draw_layer_splines(C, active, draw_type, width, height, true);
617 }
618
621}
622
623static float *mask_rasterize(Mask *mask, const int width, const int height)
624{
625 MaskRasterHandle *handle;
626 float *buffer = MEM_cnew_array<float>(height * width, "rasterized mask buffer");
627
628 /* Initialize rasterization handle. */
630 BKE_maskrasterize_handle_init(handle, mask, width, height, true, true, true);
631
632 BKE_maskrasterize_buffer(handle, width, height, buffer);
633
634 /* Free memory. */
636
637 return buffer;
638}
639
641 Depsgraph *depsgraph,
642 Mask *mask_,
643 ARegion *region,
644 const char draw_flag,
645 const char draw_type,
646 const eMaskOverlayMode overlay_mode,
647 const float blend_factor,
648 /* convert directly into aspect corrected vars */
649 const int width_i,
650 const int height_i,
651 const float aspx,
652 const float aspy,
653 const bool do_scale_applied,
654 const bool do_draw_cb,
655 /* optional - only used by clip */
656 float stabmat[4][4],
657 /* optional - only used when do_post_draw is set or called from clip editor */
658 const bContext *C)
659{
660 View2D *v2d = &region->v2d;
661 Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_->id);
662
663 /* aspect always scales vertically in movie and image spaces */
664 const float width = width_i, height = float(height_i) * (aspy / aspx);
665
666 int x, y;
667 // int w, h;
668 float zoomx, zoomy;
669
670 /* Frame image. */
671 float maxdim;
672 float xofs, yofs;
673
674 /* find window pixel coordinates of origin */
675 UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
676
677 // w = BLI_rctf_size_x(&v2d->tot);
678 // h = BLI_rctf_size_y(&v2d->tot);
679
680 zoomx = float(BLI_rcti_size_x(&region->winrct) + 1) / BLI_rctf_size_x(&region->v2d.cur);
681 zoomy = float(BLI_rcti_size_y(&region->winrct) + 1) / BLI_rctf_size_y(&region->v2d.cur);
682
683 if (do_scale_applied) {
684 zoomx /= width;
685 zoomy /= height;
686 }
687
688 x += v2d->tot.xmin * zoomx;
689 y += v2d->tot.ymin * zoomy;
690
691 /* frame the image */
692 maxdim = max_ff(width, height);
693 if (width == height) {
694 xofs = yofs = 0;
695 }
696 else if (width < height) {
697 xofs = ((height - width) / -2.0f) * zoomx;
698 yofs = 0.0f;
699 }
700 else { /* (width > height) */
701 xofs = 0.0f;
702 yofs = ((width - height) / -2.0f) * zoomy;
703 }
704
705 if (draw_flag & MASK_DRAWFLAG_OVERLAY) {
706 float buf_col[4] = {1.0f, 0.0f, 0.0f, 0.0f};
707 const float *buffer = mask_rasterize(mask_eval, width, height);
708
709 if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
710 /* More blending types could be supported in the future. */
712 buf_col[0] = -1.0f;
713 buf_col[3] = 1.0f;
714 }
715
718 GPU_matrix_scale_2f(zoomx, zoomy);
719 if (stabmat) {
720 GPU_matrix_mul(stabmat);
721 }
724 state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, buf_col);
725
726 if (overlay_mode == MASK_OVERLAY_COMBINED) {
727 const float blend_col[4] = {0.0f, 0.0f, 0.0f, blend_factor};
728
730 &state, 0.0f, 0.0f, width, height, GPU_R16F, false, buffer, 1.0f, 1.0f, blend_col);
731 }
732 else {
734 &state, 0.0f, 0.0f, width, height, GPU_R16F, false, buffer, 1.0f, 1.0f, nullptr);
735 }
737
738 if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
740 }
741
742 MEM_freeN((void *)buffer);
743 }
744
745 /* apply transformation so mask editing tools will assume drawing from the
746 * origin in normalized space */
748 GPU_matrix_translate_2f(x + xofs, y + yofs);
749 GPU_matrix_scale_2f(zoomx, zoomy);
750 if (stabmat) {
751 GPU_matrix_mul(stabmat);
752 }
753 GPU_matrix_scale_2f(maxdim, maxdim);
754
755 if (do_draw_cb) {
757 }
758
759 /* draw! */
760 if (draw_flag & MASK_DRAWFLAG_SPLINE) {
761 draw_mask_layers(C, mask_eval, draw_type, width, height);
762 }
763
764 if (do_draw_cb) {
766 }
767
769}
770
772 Mask *mask, ARegion *region, const int cfra, const int sfra, const int efra)
773{
774 const float framelen = region->winx / float(efra - sfra + 1);
775
776 MaskLayer *mask_layer = BKE_mask_layer_active(mask);
777 if (mask_layer == nullptr) {
778 return;
779 }
780
781 uint num_lines = BLI_listbase_count(&mask_layer->splines_shapes);
782 if (num_lines == 0) {
783 return;
784 }
785
786 /* Local coordinate visible rect inside region, to accommodate overlapping ui. */
787 const rcti *rect_visible = ED_region_visible_rect(region);
788 const int region_bottom = rect_visible->ymin;
789
792
794 immUniformColor4ub(255, 175, 0, 255);
795
796 immBegin(GPU_PRIM_LINES, 2 * num_lines);
797
798 LISTBASE_FOREACH (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
799 int frame = mask_layer_shape->frame;
800
801 // draw_keyframe(i, scene->r.cfra, sfra, framelen, 1);
802 int height = (frame == cfra) ? 22 : 10;
803 int x = (frame - sfra) * framelen;
804 immVertex2i(pos, x, region_bottom);
805 immVertex2i(pos, x, region_bottom + height * UI_SCALE_FAC);
806 }
807 immEnd();
809}
void immDrawPixelsTexTiled(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, const void *rect, float xzoom, float yzoom, const float color[4])
Definition glutil.cc:334
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
Definition glutil.cc:40
SpaceClip * CTX_wm_space_clip(const bContext *C)
int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height)
@ MASK_HANDLE_MODE_STICK
Definition BKE_mask.h:41
#define MASKPOINT_ISSEL_ANY(p)
Definition BKE_mask.h:297
float(* BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, unsigned int resol, unsigned int *r_tot_diff_point))[2]
void BKE_maskrasterize_handle_free(MaskRasterHandle *mr_handle)
unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int width, int height)
eMaskWhichHandle
Definition BKE_mask.h:32
@ MASK_WHICH_HANDLE_RIGHT
Definition BKE_mask.h:36
@ MASK_WHICH_HANDLE_LEFT
Definition BKE_mask.h:35
@ MASK_WHICH_HANDLE_STICK
Definition BKE_mask.h:34
MaskRasterHandle * BKE_maskrasterize_handle_new(void)
#define MASKPOINT_ISSEL_KNOT(p)
Definition BKE_mask.h:298
void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mask, int width, int height, bool do_aspect_correct, bool do_mask_aa, bool do_feather)
void BKE_mask_coord_to_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
void BKE_mask_point_handle(const struct MaskSplinePoint *point, eMaskWhichHandle which_handle, float r_handle[2])
#define MASKPOINT_ISSEL_HANDLE(point, which_handle)
Definition BKE_mask.h:300
float(* BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]
eMaskhandleMode BKE_mask_point_handles_mode_get(const struct MaskSplinePoint *point)
void BKE_mask_coord_from_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
float(* BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, unsigned int resol, bool do_feather_isect, unsigned int *r_tot_feather_point))[2]
struct MaskLayer * BKE_mask_layer_active(struct Mask *mask)
void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle, unsigned int width, unsigned int height, float *buffer)
Rasterize a buffer from a single mask (threaded execution).
struct MaskSplinePoint * BKE_mask_spline_point_array(struct MaskSpline *spline)
#define BLI_assert(a)
Definition BLI_assert.h:50
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
MINLINE int max_ii(int a, int b)
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
MINLINE void copy_v2_v2(float r[2], const float a[2])
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.h:193
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.h:189
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.h:197
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.h:201
unsigned char uchar
unsigned int uint
#define INIT_MINMAX2(min, max)
#define ELEM(...)
ID * DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
@ HD_VECT
@ HD_FREE
@ HD_AUTO
@ HD_ALIGN_DOUBLESIDE
@ HD_ALIGN
@ MASK_DRAWFLAG_SPLINE
@ MASK_DRAWFLAG_OVERLAY
eMaskOverlayMode
@ MASK_OVERLAY_COMBINED
@ MASK_OVERLAY_ALPHACHANNEL
@ MASK_SPLINE_CYCLIC
@ MASK_SPLINE_NOFILL
@ MASK_DT_BLACK
@ MASK_DT_WHITE
@ MASK_DT_DASH
@ MASK_DT_OUTLINE
@ MASK_HIDE_SELECT
@ MASK_HIDE_VIEW
@ MCLIP_PROXY_RENDER_UNDISTORT
Object is a sort of wrapper for general info.
#define UI_SCALE_FAC
void ED_clip_point_undistorted_pos(const SpaceClip *sc, const float co[2], float r_co[2])
const rcti * ED_region_visible_rect(ARegion *region)
Definition area.cc:4014
void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
#define REGION_DRAW_POST_VIEW
#define REGION_DRAW_PRE_VIEW
void immUniformColor4ubv(const unsigned char rgba[4])
void immUniform4f(const char *name, float x, float y, float z, float w)
void immEnd()
void immUnbindProgram()
void immUniform2f(const char *name, float x, float y)
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
void immVertex2f(uint attr_id, float x, float y)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immVertex2fv(uint attr_id, const float data[2])
void immUniformColor3ubv(const unsigned char rgb[3])
void immUniform1i(const char *name, int x)
void immUniformThemeColor3(int color_id)
void immVertex2i(uint attr_id, int x, int y)
void immUniform1f(const char *name, float x)
void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
GPUVertFormat * immVertexFormat()
void immUniformColor3f(float r, float g, float b)
void immUniform4fv(const char *name, const float data[4])
void immBegin(GPUPrimType, uint vertex_len)
void immUniformColor3fvAlpha(const float rgb[3], float a)
void GPU_matrix_scale_2f(float x, float y)
void GPU_matrix_push()
#define GPU_matrix_mul(x)
void GPU_matrix_pop()
void GPU_matrix_translate_2f(float x, float y)
GPUPrimType
@ GPU_PRIM_LINE_LOOP
@ GPU_PRIM_LINES
@ GPU_PRIM_POINTS
@ GPU_PRIM_LINE_STRIP
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
void GPU_shader_uniform_float_ex(GPUShader *shader, int location, int length, int array_size, const float *value)
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA
void GPU_program_point_size(bool enable)
Definition gpu_state.cc:175
@ GPU_BLEND_NONE
Definition GPU_state.hh:85
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:87
void GPU_blend(eGPUBlend blend)
Definition gpu_state.cc:42
void GPU_line_width(float width)
Definition gpu_state.cc:161
void GPU_line_smooth(bool enable)
Definition gpu_state.cc:78
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:262
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT_TO_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
@ GPU_COMP_I32
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
#define C
Definition RandGen.cpp:29
void UI_GetThemeColor3fv(int colorid, float col[3])
@ TH_HANDLE_ALIGN
@ TH_HANDLE_VERTEX_SIZE
@ TH_HANDLE_AUTO
@ TH_HANDLE_VERTEX_SELECT
@ TH_HANDLE_VERTEX
@ TH_HANDLE_FREE
float UI_GetThemeValuef(int colorid)
void UI_view2d_view_to_region(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1718
#define U
BPy_StructRNA * depsgraph
#define SELECT
draw_view in_light_buf[] float
format
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void ED_mask_draw_frames(Mask *mask, ARegion *region, const int cfra, const int sfra, const int efra)
Definition mask_draw.cc:771
static void mask_color_active_tint(uchar r_rgb[4], const uchar rgb[4], const bool is_active)
Definition mask_draw.cc:349
static void draw_mask_layers(const bContext *C, Mask *mask, const char draw_type, const int width, const int height)
Definition mask_draw.cc:592
void ED_mask_draw_region(Depsgraph *depsgraph, Mask *mask_, ARegion *region, const char draw_flag, const char draw_type, const eMaskOverlayMode overlay_mode, const float blend_factor, const int width_i, const int height_i, const float aspx, const float aspy, const bool do_scale_applied, const bool do_draw_cb, float stabmat[4][4], const bContext *C)
Definition mask_draw.cc:640
static void mask_draw_array(uint pos, GPUPrimType prim_type, const float(*points)[2], uint vertex_len)
Definition mask_draw.cc:362
static void mask_spline_feather_color_get(MaskLayer *, MaskSpline *, const bool is_sel, uchar r_rgb[4])
Definition mask_draw.cc:63
static void mask_point_undistort_pos(SpaceClip *sc, float r_co[2], const float co[2])
Definition mask_draw.cc:80
static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float(*orig_points)[2], int tot_point, const bool is_feather, const bool is_active, const uchar rgb_spline[4], const char draw_type)
Definition mask_draw.cc:374
static void draw_spline_points(const bContext *C, MaskLayer *mask_layer, MaskSpline *spline, const char draw_type)
Definition mask_draw.cc:171
static void draw_layer_splines(const bContext *C, MaskLayer *layer, const char draw_type, const int width, const int height, const bool is_active)
Definition mask_draw.cc:564
static float * mask_rasterize(Mask *mask, const int width, const int height)
Definition mask_draw.cc:623
static void draw_spline_curve(const bContext *C, MaskLayer *mask_layer, MaskSpline *spline, const char draw_type, const bool is_active, const int width, const int height)
Definition mask_draw.cc:497
static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoint *point, const eMaskWhichHandle which_handle, const int draw_type, const float handle_size, const float point_pos[2], const float handle_pos[2])
Definition mask_draw.cc:87
static void mask_spline_color_get(MaskLayer *mask_layer, MaskSpline *spline, const bool is_sel, uchar r_rgb[4])
Definition mask_draw.cc:41
ccl_device_inline float4 mask(const int4 mask, const float4 a)
static ulong state[N]
#define min(a, b)
Definition sort.c:32
float vec[3][3]
ListBase splines_shapes
char visibility_flag
ListBase splines
struct MaskSplinePoint * act_point
struct MaskSpline * act_spline
MaskSplinePoint * points_deform
MaskSplinePoint * points
struct MovieClipUser user
struct MovieClip * clip
float xmin
float ymin
int ymin
float max