Blender V5.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.hh"
12#include "BLI_math_color_c.hh"
13#include "BLI_math_vector_c.hh"
14#include "BLI_rect.hh"
15#include "BLI_utildefines.hh"
16
17#include "BKE_context.hh"
18#include "BKE_mask.hh"
19
20#include "DNA_mask_types.h"
21#include "DNA_object_types.h" /* SELECT */
22#include "DNA_screen_types.h"
23#include "DNA_space_types.h"
24
25#include "ED_clip.hh"
26#include "ED_mask.hh" /* own include */
27#include "ED_screen.hh"
28#include "ED_space_api.hh"
29
30#include "BIF_glutil.hh"
31
32#include "GPU_immediate.hh"
33#include "GPU_matrix.hh"
34#include "GPU_shader.hh"
35#include "GPU_state.hh"
36
37#include "UI_resources.hh"
38#include "UI_view2d.hh"
39
41
42namespace blender {
43
44static void mask_spline_color_get(MaskLayer *mask_layer,
45 MaskSpline *spline,
46 const bool is_sel,
47 uchar r_rgb[4])
48{
49 if (is_sel) {
50 if (mask_layer->act_spline == spline) {
51 r_rgb[0] = r_rgb[1] = r_rgb[2] = 255;
52 }
53 else {
54 r_rgb[0] = 255;
55 r_rgb[1] = r_rgb[2] = 0;
56 }
57 }
58 else {
59 r_rgb[0] = 128;
60 r_rgb[1] = r_rgb[2] = 0;
61 }
62
63 r_rgb[3] = 255;
64}
65
66static void mask_spline_feather_color_get(MaskLayer * /*mask_layer*/,
67 MaskSpline * /*spline*/,
68 const bool is_sel,
69 uchar r_rgb[4])
70{
71 if (is_sel) {
72 r_rgb[1] = 255;
73 r_rgb[0] = r_rgb[2] = 0;
74 }
75 else {
76 r_rgb[1] = 128;
77 r_rgb[0] = r_rgb[2] = 0;
78 }
79
80 r_rgb[3] = 255;
81}
82
83static void mask_point_undistort_pos(SpaceClip *sc, float r_co[2], const float co[2])
84{
85 BKE_mask_coord_to_movieclip(sc->clip, &sc->user, r_co, co);
86 ED_clip_point_undistorted_pos(sc, r_co, r_co);
87 BKE_mask_coord_from_movieclip(sc->clip, &sc->user, r_co, r_co);
88}
89
90static void draw_single_handle(const MaskLayer *mask_layer,
91 const MaskSplinePoint *point,
92 const eMaskWhichHandle which_handle,
93 const int draw_type,
94 const float handle_size,
95 const float point_pos[2],
96 const float handle_pos[2])
97{
98 const BezTriple *bezt = &point->bezt;
99 char handle_type;
100
102 handle_type = bezt->h1;
103 }
104 else {
105 handle_type = bezt->h2;
106 }
107
108 if (handle_type == HD_VECT) {
109 return;
110 }
111
112 GPUVertFormat *format = immVertexFormat();
113 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
114 const uchar rgb_gray[4] = {0x60, 0x60, 0x60, 0xff};
115
117 immUniformColor3ubv(rgb_gray);
118
119 /* this could be split into its own loop */
120 if (draw_type == MASK_DT_OUTLINE) {
121 GPU_line_width(3.0f);
123 immVertex2fv(pos, point_pos);
124 immVertex2fv(pos, handle_pos);
125 immEnd();
126 }
127
128 switch (handle_type) {
129 case HD_FREE:
131 break;
132 case HD_AUTO:
134 break;
135 case HD_ALIGN:
138 break;
139 }
140
141 GPU_line_width(1.0f);
143 immVertex2fv(pos, point_pos);
144 immVertex2fv(pos, handle_pos);
145 immEnd();
147
148 /* draw handle points */
150 immUniform1f("size", handle_size);
151 immUniform1f("outlineWidth", 1.5f);
152
153 float point_color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; /* active color by default */
154 if (BKE_mask_point_is_handle_selected(point, which_handle)) {
155 if (point != mask_layer->act_point) {
157 }
158 }
159 else {
161 }
162
163 immUniform4fv("outlineColor", point_color);
164 immUniformColor3fvAlpha(point_color, 0.25f);
165
167 immVertex2fv(pos, handle_pos);
168 immEnd();
169
171}
172
173/* return non-zero if spline is selected */
174static void draw_spline_points(const bContext *C,
175 MaskLayer *mask_layer,
176 MaskSpline *spline,
177 const MaskDrawType draw_type)
178{
179 const bool is_spline_sel = (spline->flag & SELECT) &&
180 (mask_layer->visibility_flag & MASK_HIDE_SELECT) == 0;
181
182 uchar rgb_spline[4];
183 MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
185 bool undistort = false;
186
187 int tot_feather_point;
188 float (*feather_points)[2], (*fp)[2];
189 float min[2], max[2];
190
191 if (!spline->tot_point) {
192 return;
193 }
194
195 if (sc) {
196 undistort = sc->clip && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT);
197 }
198
199 /* TODO: add this to sequence editor. */
200 float handle_size = 2.0f * ui::theme::get_value_f(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
201
202 mask_spline_color_get(mask_layer, spline, is_spline_sel, rgb_spline);
203
204 GPUVertFormat *format = immVertexFormat();
205 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
206
208 immUniform1f("size", 0.7f * handle_size);
209
210 /* feather points */
211 feather_points = fp = BKE_mask_spline_feather_points(spline, &tot_feather_point);
212 for (int i = 0; i < spline->tot_point; i++) {
213
214 /* watch it! this is intentionally not the deform array, only check for sel */
215 MaskSplinePoint *point = &spline->points[i];
216
217 for (int j = 0; j <= point->tot_uw; j++) {
218 float feather_point[2];
219 bool sel = false;
220
221 copy_v2_v2(feather_point, *fp);
222
223 if (undistort) {
224 mask_point_undistort_pos(sc, feather_point, feather_point);
225 }
226
227 if (j == 0) {
228 sel = BKE_mask_point_selected(point);
229 }
230 else {
231 sel = (point->uw[j - 1].flag & SELECT) != 0;
232 }
233
234 if (sel) {
235 if (point == mask_layer->act_point) {
236 immUniformColor3f(1.0f, 1.0f, 1.0f);
237 }
238 else {
240 }
241 }
242 else {
244 }
245
247 immVertex2fv(pos, feather_point);
248 immEnd();
249
250 fp++;
251 }
252 }
253 MEM_delete(feather_points);
254
256
257 GPU_line_smooth(true);
258
259 /* control points */
261 for (int i = 0; i < spline->tot_point; i++) {
262
263 /* watch it! this is intentionally not the deform array, only check for sel */
264 MaskSplinePoint *point = &spline->points[i];
265 MaskSplinePoint *point_deform = &points_array[i];
266 BezTriple *bezt = &point_deform->bezt;
267
268 float vert[2];
269
270 copy_v2_v2(vert, bezt->vec[1]);
271
272 if (undistort) {
273 mask_point_undistort_pos(sc, vert, vert);
274 }
275
276 /* draw handle segment */
278 float handle[2];
279 BKE_mask_point_handle(point_deform, MASK_WHICH_HANDLE_STICK, handle);
280 if (undistort) {
281 mask_point_undistort_pos(sc, handle, handle);
282 }
284 mask_layer, point, MASK_WHICH_HANDLE_STICK, draw_type, handle_size, vert, handle);
285 }
286 else {
287 float handle_left[2], handle_right[2];
288 BKE_mask_point_handle(point_deform, MASK_WHICH_HANDLE_LEFT, handle_left);
289 BKE_mask_point_handle(point_deform, MASK_WHICH_HANDLE_RIGHT, handle_right);
290 if (undistort) {
291 mask_point_undistort_pos(sc, handle_left, handle_left);
292 mask_point_undistort_pos(sc, handle_left, handle_left);
293 }
295 mask_layer, point, MASK_WHICH_HANDLE_LEFT, draw_type, handle_size, vert, handle_left);
297 mask_layer, point, MASK_WHICH_HANDLE_RIGHT, draw_type, handle_size, vert, handle_right);
298 }
299
300 /* bind program in loop so it does not interfere with draw_single_handle */
302
303 /* draw CV point */
304 if (BKE_mask_point_selected_knot(point)) {
305 if (point == mask_layer->act_point) {
306 immUniformColor3f(1.0f, 1.0f, 1.0f);
307 }
308 else {
310 }
311 }
312 else {
314 }
315
317 immVertex2fv(pos, vert);
318 immEnd();
319
321
322 minmax_v2v2_v2(min, max, vert);
323 }
324
325 GPU_line_smooth(false);
326
327 if (is_spline_sel) {
328 float x = (min[0] + max[0]) * 0.5f;
329 float y = (min[1] + max[1]) * 0.5f;
330
332 immUniform1f("outlineWidth", 1.5f);
333
334 if (mask_layer->act_spline == spline) {
335 immUniformColor3f(1.0f, 1.0f, 1.0f);
336 }
337 else {
338 immUniformColor3f(1.0f, 1.0f, 0.0f);
339 }
340
341 immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 1.0f);
342 immUniform1f("size", 12.0f);
343
345 immVertex2f(pos, x, y);
346 immEnd();
347
349 }
350}
351
352static void mask_color_active_tint(uchar r_rgb[4], const uchar rgb[4], const bool is_active)
353{
354 if (!is_active) {
355 r_rgb[0] = uchar((int(rgb[0]) + 128) / 2);
356 r_rgb[1] = uchar((int(rgb[1]) + 128) / 2);
357 r_rgb[2] = uchar((int(rgb[2]) + 128) / 2);
358 r_rgb[3] = rgb[3];
359 }
360 else {
361 *reinterpret_cast<uint *>(r_rgb) = *reinterpret_cast<const uint *>(rgb);
362 }
363}
364
365static void mask_draw_array(uint pos,
366 GPUPrimType prim_type,
367 const float (*points)[2],
368 uint vertex_len)
369{
370 immBegin(prim_type, vertex_len);
371 for (uint i = 0; i < vertex_len; i++) {
372 immVertex2fv(pos, points[i]);
373 }
374 immEnd();
375}
376
377static void mask_draw_curve_type(const bContext *C,
378 MaskSpline *spline,
379 float (*orig_points)[2],
380 int tot_point,
381 const bool is_feather,
382 const bool is_active,
383 const uchar rgb_spline[4],
384 const MaskDrawType draw_type)
385{
386 const GPUPrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GPU_PRIM_LINE_LOOP :
388 const uchar rgb_black[4] = {0x00, 0x00, 0x00, 0xff};
389 uchar rgb_tmp[4];
391 float (*points)[2] = orig_points;
392
393 if (sc) {
394 const bool undistort = sc->clip && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT);
395
396 if (undistort) {
397 points = MEM_new_array_zeroed<float[2]>(tot_point, "undistorthed mask curve");
398
399 for (int i = 0; i < tot_point; i++) {
400 mask_point_undistort_pos(sc, points[i], orig_points[i]);
401 }
402 }
403 }
404
405 GPUVertFormat *format = immVertexFormat();
406 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
407
408 switch (draw_type) {
409
410 case MASK_DT_OUTLINE:
411 /* TODO(merwin): use fancy line shader here
412 * probably better with geometry shader (after core profile switch)
413 */
415
416 GPU_line_width(3.0f);
417
418 mask_color_active_tint(rgb_tmp, rgb_black, is_active);
419 immUniformColor4ubv(rgb_tmp);
420 mask_draw_array(pos, draw_method, points, tot_point);
421
422 GPU_line_width(1.0f);
423
424 mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
425 immUniformColor4ubv(rgb_tmp);
426 mask_draw_array(pos, draw_method, points, tot_point);
427
429 break;
430
431 case MASK_DT_BLACK:
432 case MASK_DT_WHITE:
434 GPU_line_width(1.0f);
435
436 if (draw_type == MASK_DT_BLACK) {
437 rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 0;
438 }
439 else {
440 rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 255;
441 }
442 /* alpha values seem too low but gl draws many points that compensate for it */
443 if (is_feather) {
444 rgb_tmp[3] = 64;
445 }
446 else {
447 rgb_tmp[3] = 128;
448 }
449
450 if (is_feather) {
451 rgb_tmp[0] = uchar((short(rgb_tmp[0]) + short(rgb_spline[0])) / 2);
452 rgb_tmp[1] = uchar((short(rgb_tmp[1]) + short(rgb_spline[1])) / 2);
453 rgb_tmp[2] = uchar((short(rgb_tmp[2]) + short(rgb_spline[2])) / 2);
454 }
455
456 mask_color_active_tint(rgb_tmp, rgb_tmp, is_active);
457 immUniformColor4ubv(rgb_tmp);
458 mask_draw_array(pos, draw_method, points, tot_point);
459
461 break;
462
463 case MASK_DT_DASH: {
464 float colors[2][4];
465
466 mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
467 rgba_uchar_to_float(colors[0], rgb_tmp);
468 mask_color_active_tint(rgb_tmp, rgb_black, is_active);
469 rgba_uchar_to_float(colors[1], rgb_tmp);
470
472
473 float viewport_size[4];
474 GPU_viewport_size_get_f(viewport_size);
476 "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
477
478 immUniform1i("colors_len", 2); /* "advanced" mode */
479 immUniform4fv("color", colors[0]);
480 immUniform4fv("color2", colors[1]);
481 immUniform1f("dash_width", 4.0f);
482 immUniform1f("udash_factor", 0.5f);
483 GPU_line_width(1.0f);
484
485 mask_draw_array(pos, draw_method, points, tot_point);
486
488 break;
489 }
490
491 default:
492 BLI_assert(false);
493 }
494
495 if (points != orig_points) {
496 MEM_delete(points);
497 }
498}
499
500static void draw_spline_curve(const bContext *C,
501 MaskLayer *mask_layer,
502 MaskSpline *spline,
503 const MaskDrawType draw_type,
504 const bool is_active,
505 const int width,
506 const int height)
507{
508 const uint resol = max_ii(BKE_mask_spline_feather_resolution(spline, width, height),
509 BKE_mask_spline_resolution(spline, width, height));
510
511 uchar rgb_tmp[4];
512
513 const bool is_spline_sel = (spline->flag & SELECT) &&
514 (mask_layer->visibility_flag & MASK_HIDE_SELECT) == 0;
515 const bool is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0;
516
517 uint tot_diff_point;
518 float (*diff_points)[2];
519
520 uint tot_feather_point;
521 float (*feather_points)[2];
522
523 diff_points = BKE_mask_spline_differentiate_with_resolution(spline, resol, &tot_diff_point);
524
525 if (!diff_points) {
526 return;
527 }
528
529 GPU_line_smooth(true);
530
532 spline, resol, (is_fill != false), &tot_feather_point);
533
534 /* draw feather */
535 mask_spline_feather_color_get(mask_layer, spline, is_spline_sel, rgb_tmp);
537 C, spline, feather_points, tot_feather_point, true, is_active, rgb_tmp, draw_type);
538
539 if (!is_fill) {
540 const float *fp = &diff_points[0][0];
541 float *fp_feather = &feather_points[0][0];
542
543 BLI_assert(tot_diff_point == tot_feather_point);
544
545 for (int i = 0; i < tot_diff_point; i++, fp += 2, fp_feather += 2) {
546 float tvec[2];
547 sub_v2_v2v2(tvec, fp, fp_feather);
548 add_v2_v2v2(fp_feather, fp, tvec);
549 }
550
551 /* same as above */
553 C, spline, feather_points, tot_feather_point, true, is_active, rgb_tmp, draw_type);
554 }
555
556 MEM_delete(feather_points);
557
558 /* draw main curve */
559 mask_spline_color_get(mask_layer, spline, is_spline_sel, rgb_tmp);
561 C, spline, diff_points, tot_diff_point, false, is_active, rgb_tmp, draw_type);
562 MEM_delete(diff_points);
563
564 GPU_line_smooth(false);
565}
566
567static void draw_layer_splines(const bContext *C,
569 const MaskDrawType draw_type,
570 const int width,
571 const int height,
572 const bool is_active)
573{
574 for (MaskSpline &spline : layer->splines) {
575 /* draw curve itself first... */
576 draw_spline_curve(C, layer, &spline, draw_type, is_active, width, height);
577
578 if (!(layer->visibility_flag & MASK_HIDE_SELECT)) {
579 /* ...and then handles over the curve so they're nicely visible */
580 draw_spline_points(C, layer, &spline, draw_type);
581 }
582
583 /* show undeform for testing */
584 if (false) {
585 Array<MaskSplinePoint> deform = std::move(spline.runtime->points_deform);
586
587 draw_spline_curve(C, layer, &spline, draw_type, is_active, width, height);
588 draw_spline_points(C, layer, &spline, draw_type);
589 spline.runtime->points_deform = std::move(deform);
590 }
591 }
592}
593
595 const bContext *C, Mask *mask, const MaskDrawType draw_type, const int width, const int height)
596{
599
600 MaskLayer *active = nullptr;
601
602 for (const auto [i, mask_layer] : mask->masklayers.enumerate()) {
603 const bool is_active = (i == mask->masklay_act);
604
605 if (mask_layer.visibility_flag & MASK_HIDE_VIEW) {
606 continue;
607 }
608
609 if (is_active) {
610 active = &mask_layer;
611 continue;
612 }
613
614 draw_layer_splines(C, &mask_layer, draw_type, width, height, is_active);
615 }
616
617 if (active != nullptr) {
618 draw_layer_splines(C, active, draw_type, width, height, true);
619 }
620
623}
624
625static float *mask_rasterize(Mask *mask, const int width, const int height)
626{
627 MaskRasterHandle *handle;
628 float *buffer = MEM_new_array_zeroed<float>(height * width, "rasterized mask buffer");
629
630 /* Initialize rasterization handle. */
632 BKE_maskrasterize_handle_init(handle, mask, width, height, true, true, true);
633
634 BKE_maskrasterize_buffer(handle, width, height, buffer);
635
636 /* Free memory. */
638
639 return buffer;
640}
641
643 Depsgraph *depsgraph,
644 Mask *mask_,
645 ARegion *region,
646 const bool show_overlays,
647 const MaskDrawFlag draw_flag,
648 const MaskDrawType draw_type,
649 const MaskOverlayMode overlay_mode,
650 const float blend_factor,
651 /* convert directly into aspect corrected vars */
652 const int width_i,
653 const int height_i,
654 const float aspx,
655 const float aspy,
656 const bool do_scale_applied,
657 const bool do_draw_cb,
658 /* optional - only used by clip */
659 float stabmat[4][4],
660 /* optional - only used when do_post_draw is set or called from clip editor */
661 const bContext *C)
662{
663 View2D *v2d = &region->v2d;
664 Mask *mask_eval = DEG_get_evaluated(depsgraph, mask_);
665
666 /* aspect always scales vertically in movie and image spaces */
667 const float width = width_i, height = float(height_i) * (aspy / aspx);
668
669 int x, y;
670 // int w, h;
671 float zoomx, zoomy;
672
673 /* Frame image. */
674 float maxdim;
675 float xofs, yofs;
676
677 /* find window pixel coordinates of origin */
678 ui::view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
679
680 // w = BLI_rctf_size_x(&v2d->tot);
681 // h = BLI_rctf_size_y(&v2d->tot);
682
683 zoomx = float(BLI_rcti_size_x(&region->winrct) + 1) / BLI_rctf_size_x(&region->v2d.cur);
684 zoomy = float(BLI_rcti_size_y(&region->winrct) + 1) / BLI_rctf_size_y(&region->v2d.cur);
685
686 if (do_scale_applied) {
687 zoomx /= width;
688 zoomy /= height;
689 }
690
691 x += v2d->tot.xmin * zoomx;
692 y += v2d->tot.ymin * zoomy;
693
694 /* frame the image */
695 maxdim = max_ff(width, height);
696 if (width == height) {
697 xofs = yofs = 0;
698 }
699 else if (width < height) {
700 xofs = ((height - width) / -2.0f) * zoomx;
701 yofs = 0.0f;
702 }
703 else { /* (width > height) */
704 xofs = 0.0f;
705 yofs = ((width - height) / -2.0f) * zoomy;
706 }
707
708 if (show_overlays && draw_flag & MASK_DRAWFLAG_OVERLAY) {
709 float buf_col[4] = {1.0f, 0.0f, 0.0f, 0.0f};
710 const float *buffer = mask_rasterize(mask_eval, width, height);
711
712 if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
713 /* More blending types could be supported in the future. */
715 buf_col[0] = -1.0f;
716 buf_col[3] = 1.0f;
717 }
718
721 GPU_matrix_scale_2f(zoomx, zoomy);
722 if (stabmat) {
723 GPU_matrix_mul(stabmat);
724 }
727 GPU_shader_get_uniform(drawer.shader_get(), "shuffle"),
728 4,
729 1,
730 buf_col);
731
732 if (overlay_mode == MASK_OVERLAY_COMBINED) {
733 const float blend_col[4] = {0.0f, 0.0f, 0.0f, blend_factor};
734
735 drawer.draw(0.0f,
736 0.0f,
737 width,
738 height,
739 gpu::TextureFormat::SFLOAT_16,
740 false,
741 buffer,
742 1.0f,
743 1.0f,
744 blend_col);
745 }
746 else {
747 drawer.draw(0.0f,
748 0.0f,
749 width,
750 height,
751 gpu::TextureFormat::SFLOAT_16,
752 false,
753 buffer,
754 1.0f,
755 1.0f,
756 nullptr);
757 }
759
760 if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
762 }
763
764 MEM_delete(buffer);
765 }
766
767 /* apply transformation so mask editing tools will assume drawing from the
768 * origin in normalized space */
770 GPU_matrix_translate_2f(x + xofs, y + yofs);
771 GPU_matrix_scale_2f(zoomx, zoomy);
772 if (stabmat) {
773 GPU_matrix_mul(stabmat);
774 }
775 GPU_matrix_scale_2f(maxdim, maxdim);
776
777 if (do_draw_cb) {
779 }
780
781 /* draw! */
782 if (show_overlays && draw_flag & MASK_DRAWFLAG_SPLINE) {
783 draw_mask_layers(C, mask_eval, draw_type, width, height);
784 }
785
786 if (do_draw_cb) {
788 }
789
791}
792
794 Mask *mask, ARegion *region, const int cfra, const int sfra, const int efra)
795{
796 const float framelen = region->winx / float(efra - sfra + 1);
797
798 MaskLayer *mask_layer = BKE_mask_layer_active(mask);
799 if (mask_layer == nullptr) {
800 return;
801 }
802
803 uint num_lines = mask_layer->splines_shapes.count();
804 if (num_lines == 0) {
805 return;
806 }
807
808 /* Local coordinate visible rect inside region, to accommodate overlapping ui. */
809 const rcti *rect_visible = ED_region_visible_rect(region);
810 const int region_bottom = rect_visible->ymin;
811
812 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
813
815 immUniformColor4ub(255, 175, 0, 255);
816
817 immBegin(GPU_PRIM_LINES, 2 * num_lines);
818
819 for (MaskLayerShape &mask_layer_shape : mask_layer->splines_shapes) {
820 int frame = mask_layer_shape.frame;
821
822 // draw_keyframe(i, scene->r.cfra, sfra, framelen, 1);
823 int height = (frame == cfra) ? 22 : 10;
824 int x = (frame - sfra) * framelen;
825 immVertex2f(pos, x, region_bottom);
826 immVertex2f(pos, x, region_bottom + height * UI_SCALE_FAC);
827 }
828 immEnd();
830}
831
832} // namespace blender
#define SELECT
Definition BKE_mask.hh:19
Object is a sort of wrapper for general info.
#define UI_SCALE_FAC
#define REGION_DRAW_POST_VIEW
#define REGION_DRAW_PRE_VIEW
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define INIT_MINMAX2(min, max)
#define ELEM(...)
btScalar max
gpu::Shader * shader_get()
Definition BIF_glutil.hh:51
void draw(float x, float y, int img_w, int img_h, gpu::TextureFormat gpu_format, bool use_filter, const void *rect, float scale_x, float scale_y, const float color[4])
Definition glutil.cc:45
#define layer
void get_color_3fv(int colorid, float col[3])
float get_value_f(int colorid)
void view2d_view_to_region(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1705
BMesh Iterators.
UserDef U
Definition blender.cc:58
eMaskWhichHandle
Definition BKE_mask.hh:44
@ MASK_WHICH_HANDLE_LEFT
Definition BKE_mask.hh:47
@ MASK_WHICH_HANDLE_RIGHT
Definition BKE_mask.hh:48
@ MASK_WHICH_HANDLE_STICK
Definition BKE_mask.hh:46
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ MASK_OVERLAY_COMBINED
@ MASK_OVERLAY_ALPHACHANNEL
MINLINE void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
static void mask_color_active_tint(uchar r_rgb[4], const uchar rgb[4], const bool is_active)
Definition mask_draw.cc:352
void immEnd()
void immUniformColor3f(float r, float g, float b)
MaskRasterHandle * BKE_maskrasterize_handle_new()
unsigned int uint
Definition BKE_text.h:55
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
void BKE_mask_point_handle(const MaskSplinePoint *point, eMaskWhichHandle which_handle, float r_handle[2])
void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
static void draw_spline_points(const bContext *C, MaskLayer *mask_layer, MaskSpline *spline, const MaskDrawType draw_type)
Definition mask_draw.cc:174
void immUniform2f(const char *name, float x, float y)
MINLINE void copy_v2_v2(float r[2], const float a[2])
GPUVertFormat * immVertexFormat()
void ED_clip_point_undistorted_pos(const SpaceClip *sc, const float co[2], float r_co[2])
static void mask_point_undistort_pos(SpaceClip *sc, float r_co[2], const float co[2])
Definition mask_draw.cc:83
SpaceClip * CTX_wm_space_clip(const bContext *C)
void immBegin(GPUPrimType, uint vertex_len)
void GPU_line_smooth(bool enable)
Definition gpu_state.cc:80
@ GPU_PRIM_LINE_STRIP
@ GPU_PRIM_LINE_LOOP
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE int max_ii(int a, int b)
@ TH_HANDLE_VERTEX_SELECT
@ TH_HANDLE_VERTEX_SIZE
const rcti * ED_region_visible_rect(ARegion *region)
Definition area.cc:4791
@ MCLIP_PROXY_RENDER_UNDISTORT
void immUnbindProgram()
void immUniformColor3ubv(const unsigned char rgb[3])
void GPU_matrix_mul(const float m[4][4])
void GPU_line_width(float width)
Definition gpu_state.cc:151
static void mask_spline_color_get(MaskLayer *mask_layer, MaskSpline *spline, const bool is_sel, uchar r_rgb[4])
Definition mask_draw.cc:44
void GPU_matrix_scale_2f(float x, float y)
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void BKE_mask_coord_to_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
void immUniform1f(const char *name, float x)
void immVertex2f(uint attr_id, float x, float y)
unsigned char uchar
Definition BKE_text.h:58
bool BKE_mask_point_selected(const MaskSplinePoint *p)
Definition BKE_mask.hh:155
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
int BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:258
float(* BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, unsigned int resol, bool do_feather_isect, unsigned int *r_tot_feather_point))[2]
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
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:90
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
@ GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
void immUniform4fv(const char *name, const float data[4])
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.hh:215
void GPU_shader_uniform_float_ex(gpu::Shader *shader, int location, int length, int array_size, const float *value)
void immUniformThemeColor3(int color_id)
void BKE_mask_coord_from_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
float(* BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_point))[2]
void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, Mask *mask, int width, int height, bool do_aspect_correct, bool do_mask_aa, bool do_feather)
MaskLayer * BKE_mask_layer_active(Mask *mask)
static float * mask_rasterize(Mask *mask, const int width, const int height)
Definition mask_draw.cc:625
void BKE_maskrasterize_handle_free(MaskRasterHandle *mr_handle)
@ MASK_SPLINE_CYCLIC
@ MASK_SPLINE_NOFILL
static void mask_spline_feather_color_get(MaskLayer *, MaskSpline *, const bool is_sel, uchar r_rgb[4])
Definition mask_draw.cc:66
bool BKE_mask_point_is_handle_selected(const MaskSplinePoint *point, eMaskWhichHandle handle)
Definition BKE_mask.hh:165
bool BKE_mask_point_selected_knot(const MaskSplinePoint *p)
Definition BKE_mask.hh:160
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 MaskDrawType draw_type)
Definition mask_draw.cc:377
void GPU_program_point_size(bool enable)
Definition gpu_state.cc:165
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
@ MASK_DRAWFLAG_SPLINE
@ MASK_DRAWFLAG_OVERLAY
void GPU_matrix_translate_2f(float x, float y)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
static void draw_spline_curve(const bContext *C, MaskLayer *mask_layer, MaskSpline *spline, const MaskDrawType draw_type, const bool is_active, const int width, const int height)
Definition mask_draw.cc:500
int GPU_shader_get_uniform(gpu::Shader *shader, const char *name)
void immUniform4f(const char *name, float x, float y, float z, float w)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
void ED_mask_draw_frames(Mask *mask, ARegion *region, int cfra, int sfra, int efra)
Definition mask_draw.cc:793
unsigned int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int height)
MINLINE float max_ff(float a, float b)
static void draw_layer_splines(const bContext *C, MaskLayer *layer, const MaskDrawType draw_type, const int width, const int height, const bool is_active)
Definition mask_draw.cc:567
void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle, unsigned int width, unsigned int height, float *buffer)
Rasterize a buffer from a single mask (threaded execution).
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
void immUniform1i(const char *name, int x)
static void mask_draw_array(uint pos, GPUPrimType prim_type, const float(*points)[2], uint vertex_len)
Definition mask_draw.cc:365
void immUniformColor4ubv(const unsigned char rgba[4])
void immVertex2fv(uint attr_id, const float data[2])
void GPU_matrix_pop()
void immUniformColor3fvAlpha(const float rgb[3], float a)
MaskSplinePoint * BKE_mask_spline_point_array(MaskSpline *spline)
eMaskhandleMode BKE_mask_point_handles_mode_get(const MaskSplinePoint *point)
void ED_mask_draw_region(Depsgraph *depsgraph, Mask *mask, ARegion *region, bool show_overlays, MaskDrawFlag draw_flag, MaskDrawType draw_type, MaskOverlayMode overlay_mode, float blend_factor, int width_i, int height_i, float aspx, float aspy, bool do_scale_applied, bool do_draw_cb, float stabmat[4][4], const bContext *C)
Definition mask_draw.cc:642
static void draw_mask_layers(const bContext *C, Mask *mask, const MaskDrawType draw_type, const int width, const int height)
Definition mask_draw.cc:594
@ MASK_HANDLE_MODE_STICK
Definition BKE_mask.hh:53
void GPU_matrix_push()
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
float(* BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, unsigned int resol, unsigned int *r_tot_diff_point))[2]
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
eBezTriple_Handle h2
eBezTriple_Handle h1
struct MaskSplinePoint * act_point
struct MaskSpline * act_spline
ListBaseT< MaskLayerShape > splines_shapes
MaskLayerVisibility visibility_flag
MaskSplinePointUW * uw
MaskSplinePoint * points
MaskSplineRuntime * runtime
MaskSplineFlag flag
eMovieClipProxy_RenderFlag render_flag
struct MovieClip * clip
struct MovieClipUser user
Array< MaskSplinePoint > points_deform
Definition BKE_mask.hh:38