Blender V5.0
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_math_vector.h"
14#include "BLI_rect.h"
15#include "BLI_utildefines.h"
16
17#include "BKE_context.hh"
18#include "BKE_mask.h"
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
42static void mask_spline_color_get(MaskLayer *mask_layer,
43 MaskSpline *spline,
44 const bool is_sel,
45 uchar r_rgb[4])
46{
47 if (is_sel) {
48 if (mask_layer->act_spline == spline) {
49 r_rgb[0] = r_rgb[1] = r_rgb[2] = 255;
50 }
51 else {
52 r_rgb[0] = 255;
53 r_rgb[1] = r_rgb[2] = 0;
54 }
55 }
56 else {
57 r_rgb[0] = 128;
58 r_rgb[1] = r_rgb[2] = 0;
59 }
60
61 r_rgb[3] = 255;
62}
63
64static void mask_spline_feather_color_get(MaskLayer * /*mask_layer*/,
65 MaskSpline * /*spline*/,
66 const bool is_sel,
67 uchar r_rgb[4])
68{
69 if (is_sel) {
70 r_rgb[1] = 255;
71 r_rgb[0] = r_rgb[2] = 0;
72 }
73 else {
74 r_rgb[1] = 128;
75 r_rgb[0] = r_rgb[2] = 0;
76 }
77
78 r_rgb[3] = 255;
79}
80
81static void mask_point_undistort_pos(SpaceClip *sc, float r_co[2], const float co[2])
82{
83 BKE_mask_coord_to_movieclip(sc->clip, &sc->user, r_co, co);
84 ED_clip_point_undistorted_pos(sc, r_co, r_co);
85 BKE_mask_coord_from_movieclip(sc->clip, &sc->user, r_co, r_co);
86}
87
88static void draw_single_handle(const MaskLayer *mask_layer,
89 const MaskSplinePoint *point,
90 const eMaskWhichHandle which_handle,
91 const int draw_type,
92 const float handle_size,
93 const float point_pos[2],
94 const float handle_pos[2])
95{
96 const BezTriple *bezt = &point->bezt;
97 char handle_type;
98
100 handle_type = bezt->h1;
101 }
102 else {
103 handle_type = bezt->h2;
104 }
105
106 if (handle_type == HD_VECT) {
107 return;
108 }
109
111 uint pos = GPU_vertformat_attr_add(format, "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
112 const uchar rgb_gray[4] = {0x60, 0x60, 0x60, 0xff};
113
115 immUniformColor3ubv(rgb_gray);
116
117 /* this could be split into its own loop */
118 if (draw_type == MASK_DT_OUTLINE) {
119 GPU_line_width(3.0f);
121 immVertex2fv(pos, point_pos);
122 immVertex2fv(pos, handle_pos);
123 immEnd();
124 }
125
126 switch (handle_type) {
127 case HD_FREE:
129 break;
130 case HD_AUTO:
132 break;
133 case HD_ALIGN:
136 break;
137 }
138
139 GPU_line_width(1.0f);
141 immVertex2fv(pos, point_pos);
142 immVertex2fv(pos, handle_pos);
143 immEnd();
145
146 /* draw handle points */
148 immUniform1f("size", handle_size);
149 immUniform1f("outlineWidth", 1.5f);
150
151 float point_color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; /* active color by default */
152 if (MASKPOINT_ISSEL_HANDLE(point, which_handle)) {
153 if (point != mask_layer->act_point) {
155 }
156 }
157 else {
159 }
160
161 immUniform4fv("outlineColor", point_color);
162 immUniformColor3fvAlpha(point_color, 0.25f);
163
165 immVertex2fv(pos, handle_pos);
166 immEnd();
167
169}
170
171/* return non-zero if spline is selected */
172static void draw_spline_points(const bContext *C,
173 MaskLayer *mask_layer,
174 MaskSpline *spline,
175 const char draw_type)
176{
177 const bool is_spline_sel = (spline->flag & SELECT) &&
178 (mask_layer->visibility_flag & MASK_HIDE_SELECT) == 0;
179
180 uchar rgb_spline[4];
181 MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
183 bool undistort = false;
184
185 int tot_feather_point;
186 float (*feather_points)[2], (*fp)[2];
187 float min[2], max[2];
188
189 if (!spline->tot_point) {
190 return;
191 }
192
193 if (sc) {
194 undistort = sc->clip && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT);
195 }
196
197 /* TODO: add this to sequence editor. */
198 float handle_size = 2.0f * UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
199
200 mask_spline_color_get(mask_layer, spline, is_spline_sel, rgb_spline);
201
203 uint pos = GPU_vertformat_attr_add(format, "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
204
206 immUniform1f("size", 0.7f * handle_size);
207
208 /* feather points */
209 feather_points = fp = BKE_mask_spline_feather_points(spline, &tot_feather_point);
210 for (int i = 0; i < spline->tot_point; i++) {
211
212 /* watch it! this is intentionally not the deform array, only check for sel */
213 MaskSplinePoint *point = &spline->points[i];
214
215 for (int j = 0; j <= point->tot_uw; j++) {
216 float feather_point[2];
217 bool sel = false;
218
219 copy_v2_v2(feather_point, *fp);
220
221 if (undistort) {
222 mask_point_undistort_pos(sc, feather_point, feather_point);
223 }
224
225 if (j == 0) {
226 sel = MASKPOINT_ISSEL_ANY(point);
227 }
228 else {
229 sel = (point->uw[j - 1].flag & SELECT) != 0;
230 }
231
232 if (sel) {
233 if (point == mask_layer->act_point) {
234 immUniformColor3f(1.0f, 1.0f, 1.0f);
235 }
236 else {
238 }
239 }
240 else {
242 }
243
245 immVertex2fv(pos, feather_point);
246 immEnd();
247
248 fp++;
249 }
250 }
251 MEM_freeN(feather_points);
252
254
255 GPU_line_smooth(true);
256
257 /* control points */
259 for (int i = 0; i < spline->tot_point; i++) {
260
261 /* watch it! this is intentionally not the deform array, only check for sel */
262 MaskSplinePoint *point = &spline->points[i];
263 MaskSplinePoint *point_deform = &points_array[i];
264 BezTriple *bezt = &point_deform->bezt;
265
266 float vert[2];
267
268 copy_v2_v2(vert, bezt->vec[1]);
269
270 if (undistort) {
271 mask_point_undistort_pos(sc, vert, vert);
272 }
273
274 /* draw handle segment */
276 float handle[2];
277 BKE_mask_point_handle(point_deform, MASK_WHICH_HANDLE_STICK, handle);
278 if (undistort) {
279 mask_point_undistort_pos(sc, handle, handle);
280 }
282 mask_layer, point, MASK_WHICH_HANDLE_STICK, draw_type, handle_size, vert, handle);
283 }
284 else {
285 float handle_left[2], handle_right[2];
286 BKE_mask_point_handle(point_deform, MASK_WHICH_HANDLE_LEFT, handle_left);
287 BKE_mask_point_handle(point_deform, MASK_WHICH_HANDLE_RIGHT, handle_right);
288 if (undistort) {
289 mask_point_undistort_pos(sc, handle_left, handle_left);
290 mask_point_undistort_pos(sc, handle_left, handle_left);
291 }
293 mask_layer, point, MASK_WHICH_HANDLE_LEFT, draw_type, handle_size, vert, handle_left);
295 mask_layer, point, MASK_WHICH_HANDLE_RIGHT, draw_type, handle_size, vert, handle_right);
296 }
297
298 /* bind program in loop so it does not interfere with draw_single_handle */
300
301 /* draw CV point */
302 if (MASKPOINT_ISSEL_KNOT(point)) {
303 if (point == mask_layer->act_point) {
304 immUniformColor3f(1.0f, 1.0f, 1.0f);
305 }
306 else {
308 }
309 }
310 else {
312 }
313
315 immVertex2fv(pos, vert);
316 immEnd();
317
319
320 minmax_v2v2_v2(min, max, vert);
321 }
322
323 GPU_line_smooth(false);
324
325 if (is_spline_sel) {
326 float x = (min[0] + max[0]) * 0.5f;
327 float y = (min[1] + max[1]) * 0.5f;
328
330 immUniform1f("outlineWidth", 1.5f);
331
332 if (mask_layer->act_spline == spline) {
333 immUniformColor3f(1.0f, 1.0f, 1.0f);
334 }
335 else {
336 immUniformColor3f(1.0f, 1.0f, 0.0f);
337 }
338
339 immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 1.0f);
340 immUniform1f("size", 12.0f);
341
343 immVertex2f(pos, x, y);
344 immEnd();
345
347 }
348}
349
350static void mask_color_active_tint(uchar r_rgb[4], const uchar rgb[4], const bool is_active)
351{
352 if (!is_active) {
353 r_rgb[0] = uchar((int(rgb[0]) + 128) / 2);
354 r_rgb[1] = uchar((int(rgb[1]) + 128) / 2);
355 r_rgb[2] = uchar((int(rgb[2]) + 128) / 2);
356 r_rgb[3] = rgb[3];
357 }
358 else {
359 *(uint *)r_rgb = *(const uint *)rgb;
360 }
361}
362
364 GPUPrimType prim_type,
365 const float (*points)[2],
366 uint vertex_len)
367{
368 immBegin(prim_type, vertex_len);
369 for (uint i = 0; i < vertex_len; i++) {
370 immVertex2fv(pos, points[i]);
371 }
372 immEnd();
373}
374
375static void mask_draw_curve_type(const bContext *C,
376 MaskSpline *spline,
377 float (*orig_points)[2],
378 int tot_point,
379 const bool is_feather,
380 const bool is_active,
381 const uchar rgb_spline[4],
382 const char draw_type)
383{
384 const GPUPrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GPU_PRIM_LINE_LOOP :
386 const uchar rgb_black[4] = {0x00, 0x00, 0x00, 0xff};
387 uchar rgb_tmp[4];
389 float (*points)[2] = orig_points;
390
391 if (sc) {
392 const bool undistort = sc->clip && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT);
393
394 if (undistort) {
395 points = MEM_calloc_arrayN<float[2]>(tot_point, "undistorthed mask curve");
396
397 for (int i = 0; i < tot_point; i++) {
398 mask_point_undistort_pos(sc, points[i], orig_points[i]);
399 }
400 }
401 }
402
404 uint pos = GPU_vertformat_attr_add(format, "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
405
406 switch (draw_type) {
407
408 case MASK_DT_OUTLINE:
409 /* TODO(merwin): use fancy line shader here
410 * probably better with geometry shader (after core profile switch)
411 */
413
414 GPU_line_width(3.0f);
415
416 mask_color_active_tint(rgb_tmp, rgb_black, is_active);
417 immUniformColor4ubv(rgb_tmp);
418 mask_draw_array(pos, draw_method, points, tot_point);
419
420 GPU_line_width(1.0f);
421
422 mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
423 immUniformColor4ubv(rgb_tmp);
424 mask_draw_array(pos, draw_method, points, tot_point);
425
427 break;
428
429 case MASK_DT_BLACK:
430 case MASK_DT_WHITE:
432 GPU_line_width(1.0f);
433
434 if (draw_type == MASK_DT_BLACK) {
435 rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 0;
436 }
437 else {
438 rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 255;
439 }
440 /* alpha values seem too low but gl draws many points that compensate for it */
441 if (is_feather) {
442 rgb_tmp[3] = 64;
443 }
444 else {
445 rgb_tmp[3] = 128;
446 }
447
448 if (is_feather) {
449 rgb_tmp[0] = uchar((short(rgb_tmp[0]) + short(rgb_spline[0])) / 2);
450 rgb_tmp[1] = uchar((short(rgb_tmp[1]) + short(rgb_spline[1])) / 2);
451 rgb_tmp[2] = uchar((short(rgb_tmp[2]) + short(rgb_spline[2])) / 2);
452 }
453
454 mask_color_active_tint(rgb_tmp, rgb_tmp, is_active);
455 immUniformColor4ubv(rgb_tmp);
456 mask_draw_array(pos, draw_method, points, tot_point);
457
459 break;
460
461 case MASK_DT_DASH: {
462 float colors[2][4];
463
464 mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
465 rgba_uchar_to_float(colors[0], rgb_tmp);
466 mask_color_active_tint(rgb_tmp, rgb_black, is_active);
467 rgba_uchar_to_float(colors[1], rgb_tmp);
468
470
471 float viewport_size[4];
472 GPU_viewport_size_get_f(viewport_size);
474 "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
475
476 immUniform1i("colors_len", 2); /* "advanced" mode */
477 immUniform4fv("color", colors[0]);
478 immUniform4fv("color2", colors[1]);
479 immUniform1f("dash_width", 4.0f);
480 immUniform1f("udash_factor", 0.5f);
481 GPU_line_width(1.0f);
482
483 mask_draw_array(pos, draw_method, points, tot_point);
484
486 break;
487 }
488
489 default:
490 BLI_assert(false);
491 }
492
493 if (points != orig_points) {
494 MEM_freeN(points);
495 }
496}
497
498static void draw_spline_curve(const bContext *C,
499 MaskLayer *mask_layer,
500 MaskSpline *spline,
501 const char draw_type,
502 const bool is_active,
503 const int width,
504 const int height)
505{
506 const uint resol = max_ii(BKE_mask_spline_feather_resolution(spline, width, height),
507 BKE_mask_spline_resolution(spline, width, height));
508
509 uchar rgb_tmp[4];
510
511 const bool is_spline_sel = (spline->flag & SELECT) &&
512 (mask_layer->visibility_flag & MASK_HIDE_SELECT) == 0;
513 const bool is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0;
514
515 uint tot_diff_point;
516 float (*diff_points)[2];
517
518 uint tot_feather_point;
519 float (*feather_points)[2];
520
521 diff_points = BKE_mask_spline_differentiate_with_resolution(spline, resol, &tot_diff_point);
522
523 if (!diff_points) {
524 return;
525 }
526
527 GPU_line_smooth(true);
528
530 spline, resol, (is_fill != false), &tot_feather_point);
531
532 /* draw feather */
533 mask_spline_feather_color_get(mask_layer, spline, is_spline_sel, rgb_tmp);
535 C, spline, feather_points, tot_feather_point, true, is_active, rgb_tmp, draw_type);
536
537 if (!is_fill) {
538 const float *fp = &diff_points[0][0];
539 float *fp_feather = &feather_points[0][0];
540
541 BLI_assert(tot_diff_point == tot_feather_point);
542
543 for (int i = 0; i < tot_diff_point; i++, fp += 2, fp_feather += 2) {
544 float tvec[2];
545 sub_v2_v2v2(tvec, fp, fp_feather);
546 add_v2_v2v2(fp_feather, fp, tvec);
547 }
548
549 /* same as above */
551 C, spline, feather_points, tot_feather_point, true, is_active, rgb_tmp, draw_type);
552 }
553
554 MEM_freeN(feather_points);
555
556 /* draw main curve */
557 mask_spline_color_get(mask_layer, spline, is_spline_sel, rgb_tmp);
559 C, spline, diff_points, tot_diff_point, false, is_active, rgb_tmp, draw_type);
560 MEM_freeN(diff_points);
561
562 GPU_line_smooth(false);
563}
564
565static void draw_layer_splines(const bContext *C,
566 MaskLayer *layer,
567 const char draw_type,
568 const int width,
569 const int height,
570 const bool is_active)
571{
572 LISTBASE_FOREACH (MaskSpline *, spline, &layer->splines) {
573 /* draw curve itself first... */
574 draw_spline_curve(C, layer, spline, draw_type, is_active, width, height);
575
576 if (!(layer->visibility_flag & MASK_HIDE_SELECT)) {
577 /* ...and then handles over the curve so they're nicely visible */
578 draw_spline_points(C, layer, spline, draw_type);
579 }
580
581 /* show undeform for testing */
582 if (false) {
583 MaskSplinePoint *back = spline->points_deform;
584
585 spline->points_deform = nullptr;
586 draw_spline_curve(C, layer, spline, draw_type, is_active, width, height);
587 draw_spline_points(C, layer, spline, draw_type);
588 spline->points_deform = back;
589 }
590 }
591}
592
594 const bContext *C, Mask *mask, const char draw_type, const int width, const int height)
595{
598
599 MaskLayer *active = nullptr;
600 int i;
601 LISTBASE_FOREACH_INDEX (MaskLayer *, mask_layer, &mask->masklayers, i) {
602 const bool is_active = (i == mask->masklay_act);
603
604 if (mask_layer->visibility_flag & MASK_HIDE_VIEW) {
605 continue;
606 }
607
608 if (is_active) {
609 active = mask_layer;
610 continue;
611 }
612
613 draw_layer_splines(C, mask_layer, draw_type, width, height, is_active);
614 }
615
616 if (active != nullptr) {
617 draw_layer_splines(C, active, draw_type, width, height, true);
618 }
619
622}
623
624static float *mask_rasterize(Mask *mask, const int width, const int height)
625{
626 MaskRasterHandle *handle;
627 float *buffer = MEM_calloc_arrayN<float>(height * width, "rasterized mask buffer");
628
629 /* Initialize rasterization handle. */
631 BKE_maskrasterize_handle_init(handle, mask, width, height, true, true, true);
632
633 BKE_maskrasterize_buffer(handle, width, height, buffer);
634
635 /* Free memory. */
637
638 return buffer;
639}
640
642 Depsgraph *depsgraph,
643 Mask *mask_,
644 ARegion *region,
645 const bool show_overlays,
646 const char draw_flag,
647 const char draw_type,
648 const eMaskOverlayMode overlay_mode,
649 const float blend_factor,
650 /* convert directly into aspect corrected vars */
651 const int width_i,
652 const int height_i,
653 const float aspx,
654 const float aspy,
655 const bool do_scale_applied,
656 const bool do_draw_cb,
657 /* optional - only used by clip */
658 float stabmat[4][4],
659 /* optional - only used when do_post_draw is set or called from clip editor */
660 const bContext *C)
661{
662 View2D *v2d = &region->v2d;
663 Mask *mask_eval = DEG_get_evaluated(depsgraph, mask_);
664
665 /* aspect always scales vertically in movie and image spaces */
666 const float width = width_i, height = float(height_i) * (aspy / aspx);
667
668 int x, y;
669 // int w, h;
670 float zoomx, zoomy;
671
672 /* Frame image. */
673 float maxdim;
674 float xofs, yofs;
675
676 /* find window pixel coordinates of origin */
677 UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
678
679 // w = BLI_rctf_size_x(&v2d->tot);
680 // h = BLI_rctf_size_y(&v2d->tot);
681
682 zoomx = float(BLI_rcti_size_x(&region->winrct) + 1) / BLI_rctf_size_x(&region->v2d.cur);
683 zoomy = float(BLI_rcti_size_y(&region->winrct) + 1) / BLI_rctf_size_y(&region->v2d.cur);
684
685 if (do_scale_applied) {
686 zoomx /= width;
687 zoomy /= height;
688 }
689
690 x += v2d->tot.xmin * zoomx;
691 y += v2d->tot.ymin * zoomy;
692
693 /* frame the image */
694 maxdim = max_ff(width, height);
695 if (width == height) {
696 xofs = yofs = 0;
697 }
698 else if (width < height) {
699 xofs = ((height - width) / -2.0f) * zoomx;
700 yofs = 0.0f;
701 }
702 else { /* (width > height) */
703 xofs = 0.0f;
704 yofs = ((width - height) / -2.0f) * zoomy;
705 }
706
707 if (show_overlays && draw_flag & MASK_DRAWFLAG_OVERLAY) {
708 float buf_col[4] = {1.0f, 0.0f, 0.0f, 0.0f};
709 const float *buffer = mask_rasterize(mask_eval, width, height);
710
711 if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
712 /* More blending types could be supported in the future. */
714 buf_col[0] = -1.0f;
715 buf_col[3] = 1.0f;
716 }
717
720 GPU_matrix_scale_2f(zoomx, zoomy);
721 if (stabmat) {
722 GPU_matrix_mul(stabmat);
723 }
726 state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, buf_col);
727
728 if (overlay_mode == MASK_OVERLAY_COMBINED) {
729 const float blend_col[4] = {0.0f, 0.0f, 0.0f, blend_factor};
730
732 0.0f,
733 0.0f,
734 width,
735 height,
736 blender::gpu::TextureFormat::SFLOAT_16,
737 false,
738 buffer,
739 1.0f,
740 1.0f,
741 blend_col);
742 }
743 else {
745 0.0f,
746 0.0f,
747 width,
748 height,
749 blender::gpu::TextureFormat::SFLOAT_16,
750 false,
751 buffer,
752 1.0f,
753 1.0f,
754 nullptr);
755 }
757
758 if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
760 }
761
762 MEM_freeN(buffer);
763 }
764
765 /* apply transformation so mask editing tools will assume drawing from the
766 * origin in normalized space */
768 GPU_matrix_translate_2f(x + xofs, y + yofs);
769 GPU_matrix_scale_2f(zoomx, zoomy);
770 if (stabmat) {
771 GPU_matrix_mul(stabmat);
772 }
773 GPU_matrix_scale_2f(maxdim, maxdim);
774
775 if (do_draw_cb) {
777 }
778
779 /* draw! */
780 if (show_overlays && draw_flag & MASK_DRAWFLAG_SPLINE) {
781 draw_mask_layers(C, mask_eval, draw_type, width, height);
782 }
783
784 if (do_draw_cb) {
786 }
787
789}
790
792 Mask *mask, ARegion *region, const int cfra, const int sfra, const int efra)
793{
794 const float framelen = region->winx / float(efra - sfra + 1);
795
796 MaskLayer *mask_layer = BKE_mask_layer_active(mask);
797 if (mask_layer == nullptr) {
798 return;
799 }
800
801 uint num_lines = BLI_listbase_count(&mask_layer->splines_shapes);
802 if (num_lines == 0) {
803 return;
804 }
805
806 /* Local coordinate visible rect inside region, to accommodate overlapping ui. */
807 const rcti *rect_visible = ED_region_visible_rect(region);
808 const int region_bottom = rect_visible->ymin;
809
811 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
812
814 immUniformColor4ub(255, 175, 0, 255);
815
816 immBegin(GPU_PRIM_LINES, 2 * num_lines);
817
818 LISTBASE_FOREACH (MaskLayerShape *, mask_layer_shape, &mask_layer->splines_shapes) {
819 int frame = mask_layer_shape->frame;
820
821 // draw_keyframe(i, scene->r.cfra, sfra, framelen, 1);
822 int height = (frame == cfra) ? 22 : 10;
823 int x = (frame - sfra) * framelen;
824 immVertex2f(pos, x, region_bottom);
825 immVertex2f(pos, x, region_bottom + height * UI_SCALE_FAC);
826 }
827 immEnd();
829}
void immDrawPixelsTexTiled(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, blender::gpu::TextureFormat gpu_format, bool use_filter, const void *rect, float xzoom, float yzoom, const float color[4])
Definition glutil.cc:342
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
Definition glutil.cc:37
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:37
#define MASKPOINT_ISSEL_ANY(p)
Definition BKE_mask.h:292
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:28
@ MASK_WHICH_HANDLE_RIGHT
Definition BKE_mask.h:32
@ MASK_WHICH_HANDLE_LEFT
Definition BKE_mask.h:31
@ MASK_WHICH_HANDLE_STICK
Definition BKE_mask.h:30
MaskRasterHandle * BKE_maskrasterize_handle_new(void)
#define MASKPOINT_ISSEL_KNOT(p)
Definition BKE_mask.h:293
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:295
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:46
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:524
MINLINE float max_ff(float a, float b)
MINLINE int max_ii(int a, int b)
MINLINE 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:198
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.h:194
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.h:202
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.h:206
unsigned char uchar
unsigned int uint
#define INIT_MINMAX2(min, max)
#define ELEM(...)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
@ HD_VECT
@ HD_FREE
@ HD_AUTO
@ HD_ALIGN_DOUBLESIDE
@ HD_ALIGN
@ MASK_HIDE_SELECT
@ MASK_HIDE_VIEW
eMaskOverlayMode
@ MASK_OVERLAY_COMBINED
@ MASK_OVERLAY_ALPHACHANNEL
@ MASK_DRAWFLAG_SPLINE
@ MASK_DRAWFLAG_OVERLAY
@ MASK_DT_BLACK
@ MASK_DT_WHITE
@ MASK_DT_DASH
@ MASK_DT_OUTLINE
@ MASK_SPLINE_CYCLIC
@ MASK_SPLINE_NOFILL
@ 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:4301
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 immBindBuiltinProgram(GPUBuiltinShader shader_id)
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 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 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(blender::gpu::Shader *shader, const char *name)
void GPU_shader_uniform_float_ex(blender::gpu::Shader *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:180
void GPU_line_width(float width)
Definition gpu_state.cc:166
void GPU_line_smooth(bool enable)
Definition gpu_state.cc:78
@ GPU_BLEND_NONE
Definition GPU_state.hh:85
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:87
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:42
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:273
uint GPU_vertformat_attr_add(GPUVertFormat *format, blender::StringRef name, blender::gpu::VertAttrType type)
Read Guarded memory(de)allocation.
#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:1723
#define U
BPy_StructRNA * depsgraph
nullptr float
#define SELECT
uint pos
#define active
format
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:123
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
void ED_mask_draw_frames(Mask *mask, ARegion *region, const int cfra, const int sfra, const int efra)
Definition mask_draw.cc:791
void ED_mask_draw_region(Depsgraph *depsgraph, Mask *mask_, ARegion *region, const bool show_overlays, 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:641
static void mask_color_active_tint(uchar r_rgb[4], const uchar rgb[4], const bool is_active)
Definition mask_draw.cc:350
static void draw_mask_layers(const bContext *C, Mask *mask, const char draw_type, const int width, const int height)
Definition mask_draw.cc:593
static void mask_draw_array(uint pos, GPUPrimType prim_type, const float(*points)[2], uint vertex_len)
Definition mask_draw.cc:363
static void mask_spline_feather_color_get(MaskLayer *, MaskSpline *, const bool is_sel, uchar r_rgb[4])
Definition mask_draw.cc:64
static void mask_point_undistort_pos(SpaceClip *sc, float r_co[2], const float co[2])
Definition mask_draw.cc:81
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:375
static void draw_spline_points(const bContext *C, MaskLayer *mask_layer, MaskSpline *spline, const char draw_type)
Definition mask_draw.cc:172
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:565
static float * mask_rasterize(Mask *mask, const int width, const int height)
Definition mask_draw.cc:624
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:498
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:88
static void mask_spline_color_get(MaskLayer *mask_layer, MaskSpline *spline, const bool is_sel, uchar r_rgb[4])
Definition mask_draw.cc:42
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
static ulong state[N]
#define min(a, b)
Definition sort.cc:36
float vec[3][3]
ListBase splines_shapes
char visibility_flag
ListBase splines
struct MaskSplinePoint * act_point
struct MaskSpline * act_spline
MaskSplinePointUW * uw
MaskSplinePoint * points_deform
MaskSplinePoint * points
struct MovieClipUser user
struct MovieClip * clip
float xmin
float ymin
int ymin
i
Definition text_draw.cc:230
max
Definition text_draw.cc:251