Blender  V3.3
mask_draw.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2012 Blender Foundation. All rights reserved. */
3 
8 #include "MEM_guardedalloc.h"
9 
10 #include "BLI_listbase.h"
11 #include "BLI_math.h"
12 #include "BLI_rect.h"
13 #include "BLI_utildefines.h"
14 
15 #include "BKE_context.h"
16 #include "BKE_mask.h"
17 
18 #include "DNA_mask_types.h"
19 #include "DNA_object_types.h" /* SELECT */
20 #include "DNA_screen_types.h"
21 #include "DNA_space_types.h"
22 
23 #include "ED_clip.h"
24 #include "ED_mask.h" /* own include */
25 #include "ED_screen.h"
26 #include "ED_space_api.h"
27 
28 #include "BIF_glutil.h"
29 
30 #include "GPU_immediate.h"
31 #include "GPU_matrix.h"
32 #include "GPU_shader.h"
33 #include "GPU_state.h"
34 
35 #include "UI_interface.h"
36 #include "UI_resources.h"
37 #include "UI_view2d.h"
38 
39 #include "DEG_depsgraph_query.h"
40 
41 static 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 
64  MaskSpline *UNUSED(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 
80 static 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 
87 static void draw_single_handle(const MaskLayer *mask_layer,
88  const MaskSplinePoint *point,
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:
133  case HD_ALIGN_DOUBLESIDE:
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 */
171 static 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) {
225  sel = MASKPOINT_ISSEL_ANY(point);
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 */
257  INIT_MINMAX2(min, max);
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 
349 static 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 
374 static 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_callocN(2 * tot_point * sizeof(float), "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);
472  immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
473 
474  immUniform1i("colors_len", 2); /* "advanced" mode */
475  immUniform4fv("color", colors[0]);
476  immUniform4fv("color2", colors[1]);
477  immUniform1f("dash_width", 4.0f);
478  immUniform1f("dash_factor", 0.5f);
479  GPU_line_width(1.0f);
480 
481  mask_draw_array(pos, draw_method, points, tot_point);
482 
484  break;
485  }
486 
487  default:
488  BLI_assert(false);
489  }
490 
491  if (points != orig_points) {
492  MEM_freeN(points);
493  }
494 }
495 
496 static void draw_spline_curve(const bContext *C,
497  MaskLayer *mask_layer,
498  MaskSpline *spline,
499  const char draw_type,
500  const bool is_active,
501  const int width,
502  const int height)
503 {
506 
507  uchar rgb_tmp[4];
508 
509  const bool is_spline_sel = (spline->flag & SELECT) &&
510  (mask_layer->visibility_flag & MASK_HIDE_SELECT) == 0;
511  const bool is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0;
512 
513  uint tot_diff_point;
514  float(*diff_points)[2];
515 
516  uint tot_feather_point;
517  float(*feather_points)[2];
518 
519  diff_points = BKE_mask_spline_differentiate_with_resolution(spline, resol, &tot_diff_point);
520 
521  if (!diff_points) {
522  return;
523  }
524 
525  GPU_line_smooth(true);
526 
528  spline, resol, (is_fill != false), &tot_feather_point);
529 
530  /* draw feather */
531  mask_spline_feather_color_get(mask_layer, spline, is_spline_sel, rgb_tmp);
533  C, spline, feather_points, tot_feather_point, true, is_active, rgb_tmp, draw_type);
534 
535  if (!is_fill) {
536  const float *fp = &diff_points[0][0];
537  float *fp_feather = &feather_points[0][0];
538 
539  BLI_assert(tot_diff_point == tot_feather_point);
540 
541  for (int i = 0; i < tot_diff_point; i++, fp += 2, fp_feather += 2) {
542  float tvec[2];
543  sub_v2_v2v2(tvec, fp, fp_feather);
544  add_v2_v2v2(fp_feather, fp, tvec);
545  }
546 
547  /* same as above */
549  C, spline, feather_points, tot_feather_point, true, is_active, rgb_tmp, draw_type);
550  }
551 
552  MEM_freeN(feather_points);
553 
554  /* draw main curve */
555  mask_spline_color_get(mask_layer, spline, is_spline_sel, rgb_tmp);
557  C, spline, diff_points, tot_diff_point, false, is_active, rgb_tmp, draw_type);
558  MEM_freeN(diff_points);
559 
560  GPU_line_smooth(false);
561 }
562 
563 static void draw_layer_splines(const bContext *C,
564  MaskLayer *layer,
565  const char draw_type,
566  const int width,
567  const int height,
568  const bool is_active)
569 {
570  LISTBASE_FOREACH (MaskSpline *, spline, &layer->splines) {
571  /* draw curve itself first... */
572  draw_spline_curve(C, layer, spline, draw_type, is_active, width, height);
573 
574  if (!(layer->visibility_flag & MASK_HIDE_SELECT)) {
575  /* ...and then handles over the curve so they're nicely visible */
576  draw_spline_points(C, layer, spline, draw_type);
577  }
578 
579  /* show undeform for testing */
580  if (0) {
581  void *back = spline->points_deform;
582 
583  spline->points_deform = NULL;
584  draw_spline_curve(C, layer, spline, draw_type, is_active, width, height);
585  draw_spline_points(C, layer, spline, draw_type);
586  spline->points_deform = back;
587  }
588  }
589 }
590 
591 static void draw_mask_layers(
592  const bContext *C, Mask *mask, const char draw_type, const int width, const int height)
593 {
596 
597  MaskLayer *mask_layer;
598  int i;
599 
600  MaskLayer *active = NULL;
601  for (mask_layer = mask->masklayers.first, i = 0; mask_layer != NULL;
602  mask_layer = mask_layer->next, i++) {
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 != NULL) {
618  draw_layer_splines(C, active, draw_type, width, height, true);
619  }
620 
621  GPU_program_point_size(false);
623 }
624 
625 static float *mask_rasterize(Mask *mask, const int width, const int height)
626 {
627  MaskRasterHandle *handle;
628  float *buffer = MEM_mallocN(sizeof(float) * height * width, "rasterized mask buffer");
629 
630  /* Initialize rasterization handle. */
631  handle = BKE_maskrasterize_handle_new();
632  BKE_maskrasterize_handle_init(handle, mask, width, height, true, true, true);
633 
635 
636  /* Free memory. */
638 
639  return buffer;
640 }
641 
644  Mask *mask_,
645  ARegion *region,
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  struct View2D *v2d = &region->v2d;
663  Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_->id);
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 (draw_flag & MASK_DRAWFLAG_OVERLAY) {
708  float buf_col[4] = {1.0f, 0.0f, 0.0f, 0.0f};
709  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 
718  GPU_matrix_push();
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  &state, 0.0f, 0.0f, width, height, GPU_R16F, false, buffer, 1.0f, 1.0f, blend_col);
733  }
734  else {
736  &state, 0.0f, 0.0f, width, height, GPU_R16F, false, buffer, 1.0f, 1.0f, NULL);
737  }
738  GPU_matrix_pop();
739 
740  if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
742  }
743 
744  MEM_freeN(buffer);
745  }
746 
747  /* apply transformation so mask editing tools will assume drawing from the
748  * origin in normalized space */
749  GPU_matrix_push();
750  GPU_matrix_translate_2f(x + xofs, y + yofs);
751  GPU_matrix_scale_2f(zoomx, zoomy);
752  if (stabmat) {
753  GPU_matrix_mul(stabmat);
754  }
755  GPU_matrix_scale_2f(maxdim, maxdim);
756 
757  if (do_draw_cb) {
759  }
760 
761  /* draw! */
762  if (draw_flag & MASK_DRAWFLAG_SPLINE) {
763  draw_mask_layers(C, mask_eval, draw_type, width, height);
764  }
765 
766  if (do_draw_cb) {
768  }
769 
770  GPU_matrix_pop();
771 }
772 
774  Mask *mask, ARegion *region, const int cfra, const int sfra, const int efra)
775 {
776  const float framelen = region->winx / (float)(efra - sfra + 1);
777 
778  MaskLayer *mask_layer = BKE_mask_layer_active(mask);
779  if (mask_layer == NULL) {
780  return;
781  }
782 
783  uint num_lines = BLI_listbase_count(&mask_layer->splines_shapes);
784  if (num_lines == 0) {
785  return;
786  }
787 
788  /* Local coordinate visible rect inside region, to accommodate overlapping ui. */
789  const rcti *rect_visible = ED_region_visible_rect(region);
790  const int region_bottom = rect_visible->ymin;
791 
794 
796  immUniformColor4ub(255, 175, 0, 255);
797 
798  immBegin(GPU_PRIM_LINES, 2 * num_lines);
799 
800  for (MaskLayerShape *mask_layer_shape = mask_layer->splines_shapes.first;
801  mask_layer_shape != NULL;
802  mask_layer_shape = mask_layer_shape->next) {
803  int frame = mask_layer_shape->frame;
804 
805  // draw_keyframe(i, scene->r.cfra, sfra, framelen, 1);
806  int height = (frame == cfra) ? 22 : 10;
807  int x = (frame - sfra) * framelen;
808  immVertex2i(pos, x, region_bottom);
809  immVertex2i(pos, x, region_bottom + height * UI_DPI_FAC);
810  }
811  immEnd();
813 }
typedef float(TangentPoint)[2]
void immDrawPixelsTexTiled(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, void *rect, float xzoom, float yzoom, const float color[4])
Definition: glutil.c:333
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
Definition: glutil.c:44
struct SpaceClip * CTX_wm_space_clip(const bContext *C)
Definition: context.c:923
@ MASK_HANDLE_MODE_STICK
Definition: BKE_mask.h:40
#define MASKPOINT_ISSEL_ANY(p)
Definition: BKE_mask.h:296
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)
Definition: mask_evaluate.c:66
eMaskWhichHandle
Definition: BKE_mask.h:31
@ MASK_WHICH_HANDLE_RIGHT
Definition: BKE_mask.h:35
@ MASK_WHICH_HANDLE_LEFT
Definition: BKE_mask.h:34
@ MASK_WHICH_HANDLE_STICK
Definition: BKE_mask.h:33
struct MaskLayer * BKE_mask_layer_active(struct Mask *mask)
Definition: mask.c:361
#define MASKPOINT_ISSEL_KNOT(p)
Definition: BKE_mask.h:297
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])
Definition: mask.c:1246
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:299
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)
struct MaskSplinePoint * BKE_mask_spline_point_array(struct MaskSpline *spline)
Definition: mask.c:314
void BKE_mask_coord_from_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
Definition: mask.c:1200
MaskRasterHandle * BKE_maskrasterize_handle_new(void)
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]
void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle, unsigned int width, unsigned int height, float *buffer)
Rasterize a buffer from a single mask (threaded execution).
unsigned int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height)
Definition: mask_evaluate.c:27
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
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])
Definition: math_color.c:383
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])
Definition: math_vector.c:890
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:190
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:186
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition: BLI_rect.h:194
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition: BLI_rect.h:198
unsigned char uchar
Definition: BLI_sys_types.h:70
unsigned int uint
Definition: BLI_sys_types.h:67
#define INIT_MINMAX2(min, max)
#define UNUSED(x)
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
struct ID * DEG_get_evaluated_id(const struct Depsgraph *depsgraph, struct ID *id)
@ HD_VECT
@ HD_FREE
@ HD_AUTO
@ HD_ALIGN_DOUBLESIDE
@ HD_ALIGN
#define MASK_HIDE_SELECT
@ MASK_DT_BLACK
@ MASK_DT_WHITE
@ MASK_DT_DASH
@ MASK_DT_OUTLINE
#define MASK_HIDE_VIEW
eMaskOverlayMode
@ MASK_OVERLAY_COMBINED
@ MASK_OVERLAY_ALPHACHANNEL
#define MASK_DRAWFLAG_SPLINE
@ MASK_SPLINE_CYCLIC
@ MASK_SPLINE_NOFILL
#define MASK_DRAWFLAG_OVERLAY
@ MCLIP_PROXY_RENDER_UNDISTORT
Object is a sort of wrapper for general info.
void ED_clip_point_undistorted_pos(struct SpaceClip *sc, const float co[2], float r_co[2])
Definition: clip_editor.c:462
const rcti * ED_region_visible_rect(ARegion *region)
Definition: area.c:3763
#define REGION_DRAW_POST_VIEW
Definition: ED_space_api.h:62
void ED_region_draw_cb_draw(const struct bContext *C, struct ARegion *region, int type)
#define REGION_DRAW_PRE_VIEW
Definition: ED_space_api.h:64
void immUniformColor4ubv(const unsigned char rgba[4])
void immUniform4f(const char *name, float x, float y, float z, float w)
void immUniform2f(const char *name, float x, float y)
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
void immUnbindProgram(void)
void immVertex2f(uint attr_id, float x, float y)
void immUniformThemeColor(int color_id)
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 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)
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 immEnd(void)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void GPU_matrix_pop(void)
Definition: gpu_matrix.cc:126
void GPU_matrix_scale_2f(float x, float y)
Definition: gpu_matrix.cc:216
#define GPU_matrix_mul(x)
Definition: GPU_matrix.h:224
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:119
void GPU_matrix_translate_2f(float x, float y)
Definition: gpu_matrix.cc:174
GPUPrimType
Definition: GPU_primitive.h:18
@ GPU_PRIM_LINE_LOOP
Definition: GPU_primitive.h:23
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:20
@ GPU_PRIM_POINTS
Definition: GPU_primitive.h:19
@ GPU_PRIM_LINE_STRIP
Definition: GPU_primitive.h:22
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
Definition: gpu_shader.cc:559
void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, int arraysize, const float *value)
Definition: gpu_shader.cc:630
@ GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR
Definition: GPU_shader.h:349
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
Definition: GPU_shader.h:310
@ GPU_SHADER_2D_UNIFORM_COLOR
Definition: GPU_shader.h:201
@ GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR
Definition: GPU_shader.h:281
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA
Definition: GPU_shader.h:321
void GPU_program_point_size(bool enable)
Definition: gpu_state.cc:172
@ GPU_BLEND_NONE
Definition: GPU_state.h:60
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:62
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:39
void GPU_line_width(float width)
Definition: gpu_state.cc:158
void GPU_line_smooth(bool enable)
Definition: gpu_state.cc:75
void GPU_viewport_size_get_f(float coords[4])
Definition: gpu_state.cc:259
@ GPU_R16F
Definition: GPU_texture.h:113
@ 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 Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise 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:25
#define UI_DPI_FAC
Definition: UI_interface.h:305
void UI_GetThemeColor3fv(int colorid, float col[3])
Definition: resources.c:1165
@ TH_HANDLE_ALIGN
Definition: UI_resources.h:112
@ TH_HANDLE_VERTEX_SIZE
Definition: UI_resources.h:206
@ TH_HANDLE_AUTO
Definition: UI_resources.h:110
@ TH_HANDLE_VERTEX_SELECT
Definition: UI_resources.h:205
@ TH_HANDLE_VERTEX
Definition: UI_resources.h:204
@ TH_HANDLE_FREE
Definition: UI_resources.h:109
float UI_GetThemeValuef(int colorid)
Definition: resources.c:1141
void UI_view2d_view_to_region(const struct View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
unsigned int U
Definition: btGjkEpa3.h:78
#define SELECT
const Depsgraph * depsgraph
uint pos
ccl_global float * buffer
const int state
format
Definition: logImageCore.h:38
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
void ED_mask_draw_frames(Mask *mask, ARegion *region, const int cfra, const int sfra, const int efra)
Definition: mask_draw.c:773
static void mask_spline_feather_color_get(MaskLayer *UNUSED(mask_layer), MaskSpline *UNUSED(spline), const bool is_sel, uchar r_rgb[4])
Definition: mask_draw.c:63
static void mask_color_active_tint(uchar r_rgb[4], const uchar rgb[4], const bool is_active)
Definition: mask_draw.c:349
static void draw_mask_layers(const bContext *C, Mask *mask, const char draw_type, const int width, const int height)
Definition: mask_draw.c:591
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.c:642
static void mask_draw_array(uint pos, GPUPrimType prim_type, const float(*points)[2], uint vertex_len)
Definition: mask_draw.c:362
static void mask_point_undistort_pos(SpaceClip *sc, float r_co[2], const float co[2])
Definition: mask_draw.c:80
static float * mask_rasterize(Mask *mask, const int width, const int height)
Definition: mask_draw.c:625
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.c:374
static void draw_spline_points(const bContext *C, MaskLayer *mask_layer, MaskSpline *spline, const char draw_type)
Definition: mask_draw.c: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.c:563
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.c:496
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.c:87
static void mask_spline_color_get(MaskLayer *mask_layer, MaskSpline *spline, const bool is_sel, uchar r_rgb[4])
Definition: mask_draw.c:41
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
bool active
all scheduled work for the GPU.
static const pxr::TfToken rgb("rgb", pxr::TfToken::Immortal)
#define min(a, b)
Definition: sort.c:35
uint8_t h1
float vec[3][3]
uint8_t h2
void * first
Definition: DNA_listBase.h:31
struct MaskLayer * next
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
Definition: DNA_vec_types.h:69
float ymin
Definition: DNA_vec_types.h:70
int ymin
Definition: DNA_vec_types.h:64
float max