Blender  V3.3
clip_draw.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. All rights reserved. */
3 
8 #include "DNA_gpencil_types.h"
9 #include "DNA_movieclip_types.h"
10 #include "DNA_scene_types.h"
11 
12 #include "MEM_guardedalloc.h"
13 
14 #include "IMB_colormanagement.h"
15 #include "IMB_imbuf.h"
16 #include "IMB_imbuf_types.h"
17 
18 #include "BLI_math.h"
19 #include "BLI_math_base.h"
20 #include "BLI_rect.h"
21 #include "BLI_string.h"
22 #include "BLI_utildefines.h"
23 
24 #include "BKE_context.h"
25 #include "BKE_image.h"
26 #include "BKE_movieclip.h"
27 #include "BKE_tracking.h"
28 
29 #include "ED_clip.h"
30 #include "ED_gpencil.h"
31 #include "ED_mask.h"
32 #include "ED_screen.h"
33 #include "ED_util.h"
34 
35 #include "BIF_glutil.h"
36 
37 #include "GPU_immediate.h"
38 #include "GPU_immediate_util.h"
39 #include "GPU_matrix.h"
40 #include "GPU_state.h"
41 
42 #include "WM_types.h"
43 
44 #include "UI_interface.h"
45 #include "UI_resources.h"
46 #include "UI_view2d.h"
47 
48 #include "BLF_api.h"
49 
50 #include "clip_intern.h" /* own include */
51 
52 /*********************** main area drawing *************************/
53 
54 static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int width, uint pos)
55 {
56  int height = (frame == cfra) ? 22 : 10;
57  int x = (frame - sfra) * framelen;
58 
59  if (width == 1) {
61  immVertex2i(pos, x, 0);
63  immEnd();
64  }
65  else {
66  immRecti(pos, x, 0, x + width, height * UI_DPI_FAC);
67  }
68 }
69 
71  MovieTrackingPlaneTrack *plane_track)
72 {
73  if (track) {
74  return track->markersnr;
75  }
76  if (plane_track) {
77  return plane_track->markersnr;
78  }
79 
80  return 0;
81 }
82 
84  MovieTrackingPlaneTrack *plane_track,
85  int marker_index)
86 {
87  if (track) {
88  BLI_assert(marker_index < track->markersnr);
89  return track->markers[marker_index].framenr;
90  }
91  if (plane_track) {
92  BLI_assert(marker_index < plane_track->markersnr);
93  return plane_track->markers[marker_index].framenr;
94  }
95 
96  return 0;
97 }
98 
100  MovieTrackingPlaneTrack *plane_track,
101  int marker_index)
102 {
103  if (track) {
104  BLI_assert(marker_index < track->markersnr);
105  return (track->markers[marker_index].flag & MARKER_DISABLED) == 0;
106  }
107  if (plane_track) {
108  return true;
109  }
110 
111  return false;
112 }
113 
115  MovieTrackingPlaneTrack *plane_track,
116  int marker_index)
117 {
118  if (track) {
119  BLI_assert(marker_index < track->markersnr);
120  return (track->markers[marker_index].flag & MARKER_TRACKED) == 0;
121  }
122  if (plane_track) {
123  BLI_assert(marker_index < plane_track->markersnr);
124  return (plane_track->markers[marker_index].flag & PLANE_MARKER_TRACKED) == 0;
125  }
126 
127  return false;
128 }
129 
130 static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip, Scene *scene)
131 {
132  float x;
133  int *points, totseg, i, a;
134  float sfra = scene->r.sfra, efra = scene->r.efra, framelen = region->winx / (efra - sfra + 1);
135  MovieTracking *tracking = &clip->tracking;
136  MovieTrackingObject *act_object = BKE_tracking_object_get_active(tracking);
140 
142 
143  /* cache background */
145 
146  /* cached segments -- could be useful to debug caching strategies */
147  BKE_movieclip_get_cache_segments(clip, &sc->user, &totseg, &points);
148  ED_region_cache_draw_cached_segments(region, totseg, points, sfra, efra);
149 
153 
154  /* track */
155  if (act_track || act_plane_track) {
156  for (i = sfra - clip->start_frame + 1, a = 0; i <= efra - clip->start_frame + 1; i++) {
157  int framenr;
158  int markersnr = generic_track_get_markersnr(act_track, act_plane_track);
159 
160  while (a < markersnr) {
161  int marker_framenr = generic_track_get_marker_framenr(act_track, act_plane_track, a);
162 
163  if (marker_framenr >= i) {
164  break;
165  }
166 
167  if (a < markersnr - 1 &&
168  generic_track_get_marker_framenr(act_track, act_plane_track, a + 1) > i) {
169  break;
170  }
171 
172  a++;
173  }
174 
175  a = min_ii(a, markersnr - 1);
176 
177  if (generic_track_is_marker_enabled(act_track, act_plane_track, a)) {
178  framenr = generic_track_get_marker_framenr(act_track, act_plane_track, a);
179 
180  if (framenr != i) {
181  immUniformColor4ub(128, 128, 0, 96);
182  }
183  else if (generic_track_is_marker_keyframed(act_track, act_plane_track, a)) {
184  immUniformColor4ub(255, 255, 0, 196);
185  }
186  else {
187  immUniformColor4ub(255, 255, 0, 96);
188  }
189 
190  immRecti(pos,
191  (i - sfra + clip->start_frame - 1) * framelen,
192  0,
193  (i - sfra + clip->start_frame) * framelen,
194  4 * UI_DPI_FAC);
195  }
196  }
197  }
198 
199  /* failed frames */
201  int n = reconstruction->camnr;
202  MovieReconstructedCamera *cameras = reconstruction->cameras;
203 
204  immUniformColor4ub(255, 0, 0, 96);
205 
206  for (i = sfra, a = 0; i <= efra; i++) {
207  bool ok = false;
208 
209  while (a < n) {
210  if (cameras[a].framenr == i) {
211  ok = true;
212  break;
213  }
214  if (cameras[a].framenr > i) {
215  break;
216  }
217 
218  a++;
219  }
220 
221  if (!ok) {
222  immRecti(pos,
223  (i - sfra + clip->start_frame - 1) * framelen,
224  0,
225  (i - sfra + clip->start_frame) * framelen,
226  8 * UI_DPI_FAC);
227  }
228  }
229  }
230 
232 
233  /* current frame */
234  x = (sc->user.framenr - sfra) / (efra - sfra + 1) * region->winx;
235 
237  immRecti(pos, x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC);
238 
240 
242 
245 
246  /* solver keyframes */
247  immUniformColor4ub(175, 255, 0, 255);
249  act_object->keyframe1 + clip->start_frame - 1, scene->r.cfra, sfra, framelen, 2, pos);
251  act_object->keyframe2 + clip->start_frame - 1, scene->r.cfra, sfra, framelen, 2, pos);
252 
254 
255  /* movie clip animation */
256  if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) {
257  ED_mask_draw_frames(sc->mask_info.mask, region, scene->r.cfra, sfra, efra);
258  }
259 }
260 
261 static void draw_movieclip_notes(SpaceClip *sc, ARegion *region)
262 {
263  MovieClip *clip = ED_space_clip_get_clip(sc);
264  MovieTracking *tracking = &clip->tracking;
265  char str[256] = {0};
266  bool full_redraw = false;
267 
268  if (tracking->stats) {
269  BLI_strncpy(str, tracking->stats->message, sizeof(str));
270  full_redraw = true;
271  }
272  else {
273  if (sc->flag & SC_LOCK_SELECTION) {
274  strcpy(str, "Locked");
275  }
276  }
277 
278  if (str[0]) {
279  float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.6f};
280  ED_region_info_draw(region, str, fill_color, full_redraw);
281  }
282 }
283 
284 static void draw_movieclip_muted(ARegion *region, int width, int height, float zoomx, float zoomy)
285 {
286  int x, y;
287 
290 
291  /* find window pixel coordinates of origin */
292  UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
293 
294  immUniformColor3f(0.0f, 0.0f, 0.0f);
295  immRectf(pos, x, y, x + zoomx * width, y + zoomy * height);
296 
298 }
299 
300 static void draw_movieclip_buffer(const bContext *C,
301  SpaceClip *sc,
302  ARegion *region,
303  ImBuf *ibuf,
304  int width,
305  int height,
306  float zoomx,
307  float zoomy)
308 {
309  MovieClip *clip = ED_space_clip_get_clip(sc);
310  bool use_filter = true;
311  int x, y;
312 
313  /* find window pixel coordinates of origin */
314  UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
315 
316  /* checkerboard for case alpha */
317  if (ibuf->planes == 32) {
319 
320  imm_draw_box_checker_2d(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y);
321  }
322 
323  /* non-scaled proxy shouldn't use filtering */
324  if ((clip->flag & MCLIP_USE_PROXY) == 0 ||
326  use_filter = false;
327  }
328 
329  ED_draw_imbuf_ctx(C, ibuf, x, y, use_filter, zoomx * width / ibuf->x, zoomy * height / ibuf->y);
330 
331  if (ibuf->planes == 32) {
333  }
334 
335  if (sc->flag & SC_SHOW_METADATA) {
336  rctf frame;
337  BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y);
339  x, y, ibuf, &frame, zoomx * width / ibuf->x, zoomy * height / ibuf->y);
340  }
341 }
342 
344  SpaceClip *sc, ARegion *region, int width, int height, float zoomx, float zoomy)
345 {
346  int x, y;
347  MovieClip *clip = ED_space_clip_get_clip(sc);
348 
349  /* find window pixel coordinates of origin */
350  UI_view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
351 
352  /* draw boundary border for frame if stabilization is enabled */
354  const uint shdr_pos = GPU_vertformat_attr_add(
356 
357  /* Exclusive OR allows to get orig value when second operand is 0,
358  * and negative of orig value when second operand is 1. */
359  GPU_logic_op_xor_set(true);
360 
361  GPU_matrix_push();
363 
364  GPU_matrix_scale_2f(zoomx, zoomy);
365  GPU_matrix_mul(sc->stabmat);
366 
368 
369  float viewport_size[4];
370  GPU_viewport_size_get_f(viewport_size);
371  immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
372 
373  immUniform1i("colors_len", 0); /* "simple" mode */
374  immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f);
375  immUniform1f("dash_width", 6.0f);
376  immUniform1f("dash_factor", 0.5f);
377 
378  imm_draw_box_wire_2d(shdr_pos, 0.0f, 0.0f, width, height);
379 
381 
382  GPU_matrix_pop();
383 
384  GPU_logic_op_xor_set(false);
385  }
386 }
387 
388 enum {
390 };
391 
392 typedef struct TrachPathPoint {
393  float co[2];
396 
398  const MovieTrackingTrack *track,
399  const MovieTrackingMarker *marker,
401 {
402  add_v2_v2v2(point->co, marker->pos, track->offset);
404  point->flag = 0;
405  if ((marker->flag & MARKER_TRACKED) == 0) {
407  }
408 }
409 
411  MovieTrackingTrack *track,
412  int direction,
413  TrackPathPoint *path)
414 {
415  const int count = sc->path_length;
416  int current_frame = ED_space_clip_get_clip_frame_number(sc);
417  const MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, current_frame);
418  /* Check whether there is marker at exact current frame.
419  * If not, we don't have anything to be put to path. */
420  if (marker == NULL || (marker->flag & MARKER_DISABLED)) {
421  return 0;
422  }
423  /* Index inside of path array where we write data to. */
424  int point_index = count;
425  int path_length = 0;
426  for (int i = 0; i < count; ++i) {
427  marker_to_path_point(sc, track, marker, &path[point_index]);
428  /* Move to the next marker along the path segment. */
429  path_length++;
430  point_index += direction;
431  current_frame += direction;
432  marker = BKE_tracking_marker_get_exact(track, current_frame);
433  if (marker == NULL || (marker->flag & MARKER_DISABLED)) {
434  /* Reached end of tracked segment. */
435  break;
436  }
437  }
438  return path_length;
439 }
440 
441 static void draw_track_path_points(const TrackPathPoint *path,
442  uint position_attribute,
443  const int start_point,
444  const int num_points)
445 {
446  if (num_points == 0) {
447  return;
448  }
449  immBegin(GPU_PRIM_POINTS, num_points);
450  for (int i = 0; i < num_points; i++) {
451  const TrackPathPoint *point = &path[i + start_point];
452  immVertex2fv(position_attribute, point->co);
453  }
454  immEnd();
455 }
456 
458  uint position_attribute,
459  const int start_point,
460  const int num_points)
461 {
462  immBeginAtMost(GPU_PRIM_POINTS, num_points);
463  for (int i = 0; i < num_points; i++) {
464  const TrackPathPoint *point = &path[i + start_point];
465  if (point->flag & PATH_POINT_FLAG_KEYFRAME) {
466  immVertex2fv(position_attribute, point->co);
467  }
468  }
469  immEnd();
470 }
471 
472 static void draw_track_path_lines(const TrackPathPoint *path,
473  uint position_attribute,
474  const int start_point,
475  const int num_points)
476 {
477  if (num_points < 2) {
478  return;
479  }
480  immBegin(GPU_PRIM_LINE_STRIP, num_points);
481  for (int i = 0; i < num_points; i++) {
482  const TrackPathPoint *point = &path[i + start_point];
483  immVertex2fv(position_attribute, point->co);
484  }
485  immEnd();
486 }
487 
489 {
490 #define MAX_STATIC_PATH 64
491 
492  const int count = sc->path_length;
493  TrackPathPoint path_static[(MAX_STATIC_PATH + 1) * 2];
494  TrackPathPoint *path;
495  const bool tiny = (sc->flag & SC_SHOW_TINY_MARKER) != 0;
496 
497  if (count == 0) {
498  /* Early output, nothing to bother about here. */
499  return;
500  }
501 
502  /* Try to use stack allocated memory when possibly, only use heap allocation
503  * for really long paths. */
504  path = (count < MAX_STATIC_PATH) ? path_static :
505  MEM_mallocN(sizeof(*path) * (count + 1) * 2, "path");
506  /* Collect path information. */
507  const int num_points_before = track_to_path_segment(sc, track, -1, path);
508  const int num_points_after = track_to_path_segment(sc, track, 1, path);
509  if (num_points_before == 0 && num_points_after == 0) {
510  return;
511  }
512 
513  int num_all_points = num_points_before + num_points_after;
514  /* If both leading and trailing parts of the path are there the center point is counted twice. */
515  if (num_points_before != 0 && num_points_after != 0) {
516  num_all_points -= 1;
517  }
518 
519  const int path_start_index = count - num_points_before + 1;
520  const int path_center_index = count;
521 
522  const uint position_attribute = GPU_vertformat_attr_add(
525 
526  /* Draw path outline. */
527  if (!tiny) {
529  if (TRACK_VIEW_SELECTED(sc, track)) {
530  GPU_point_size(5.0f);
531  draw_track_path_points(path, position_attribute, path_start_index, num_all_points);
532  GPU_point_size(7.0f);
533  draw_track_path_keyframe_points(path, position_attribute, path_start_index, num_all_points);
534  }
535  /* Draw darker outline for actual path, all line segments at once. */
536  GPU_line_width(3.0f);
537  draw_track_path_lines(path, position_attribute, path_start_index, num_all_points);
538  }
539 
540  /* Draw all points. */
541  GPU_point_size(3.0f);
543  draw_track_path_points(path, position_attribute, path_start_index, num_points_before);
545  draw_track_path_points(path, position_attribute, path_center_index, num_points_after);
546 
547  /* Connect points with color coded segments. */
548  GPU_line_width(1);
550  draw_track_path_lines(path, position_attribute, path_start_index, num_points_before);
552  draw_track_path_lines(path, position_attribute, path_center_index, num_points_after);
553 
554  /* Draw all bigger points corresponding to keyframes. */
555  GPU_point_size(5.0f);
557  draw_track_path_keyframe_points(path, position_attribute, path_start_index, num_points_before);
559  draw_track_path_keyframe_points(path, position_attribute, path_center_index, num_points_after);
560 
561  if (path != path_static) {
562  MEM_freeN(path);
563  }
564 
566 
567 #undef MAX_STATIC_PATH
568 }
569 
571  MovieTrackingTrack *track,
572  MovieTrackingMarker *marker,
573  const float marker_pos[2],
574  int width,
575  int height,
576  uint position)
577 {
578  int tiny = sc->flag & SC_SHOW_TINY_MARKER;
579  bool show_search = false;
580  float px[2];
581 
582  px[0] = 1.0f / width / sc->zoom;
583  px[1] = 1.0f / height / sc->zoom;
584 
585  GPU_line_width(tiny ? 1.0f : 3.0f);
586 
588 
589  if ((marker->flag & MARKER_DISABLED) == 0) {
590  float pos[2];
591  float p[2];
592 
593  add_v2_v2v2(pos, marker->pos, track->offset);
594 
596 
597  sub_v2_v2v2(p, pos, marker_pos);
598 
599  if (isect_point_quad_v2(p,
600  marker->pattern_corners[0],
601  marker->pattern_corners[1],
602  marker->pattern_corners[2],
603  marker->pattern_corners[3])) {
604  GPU_point_size(tiny ? 3.0f : 4.0f);
605 
607  immVertex2f(position, pos[0], pos[1]);
608  immEnd();
609  }
610  else {
612 
613  immVertex2f(position, pos[0] + px[0] * 2, pos[1]);
614  immVertex2f(position, pos[0] + px[0] * 8, pos[1]);
615 
616  immVertex2f(position, pos[0] - px[0] * 2, pos[1]);
617  immVertex2f(position, pos[0] - px[0] * 8, pos[1]);
618 
619  immVertex2f(position, pos[0], pos[1] - px[1] * 2);
620  immVertex2f(position, pos[0], pos[1] - px[1] * 8);
621 
622  immVertex2f(position, pos[0], pos[1] + px[1] * 2);
623  immVertex2f(position, pos[0], pos[1] + px[1] * 8);
624 
625  immEnd();
626  }
627  }
628 
629  /* pattern and search outline */
630  GPU_matrix_push();
631  GPU_matrix_translate_2fv(marker_pos);
632 
633  if (sc->flag & SC_SHOW_MARKER_PATTERN) {
635  immVertex2fv(position, marker->pattern_corners[0]);
636  immVertex2fv(position, marker->pattern_corners[1]);
637  immVertex2fv(position, marker->pattern_corners[2]);
638  immVertex2fv(position, marker->pattern_corners[3]);
639  immEnd();
640  }
641 
642  show_search = (TRACK_VIEW_SELECTED(sc, track) && ((marker->flag & MARKER_DISABLED) == 0 ||
643  (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) !=
644  0;
645 
646  if (sc->flag & SC_SHOW_MARKER_SEARCH && show_search) {
647  imm_draw_box_wire_2d(position,
648  marker->search_min[0],
649  marker->search_min[1],
650  marker->search_max[0],
651  marker->search_max[1]);
652  }
653 
654  GPU_matrix_pop();
655 }
656 
657 static void track_colors(MovieTrackingTrack *track, int act, float col[3], float scol[3])
658 {
659  if (track->flag & TRACK_CUSTOMCOLOR) {
660  if (act) {
662  }
663  else {
664  copy_v3_v3(scol, track->color);
665  }
666 
667  mul_v3_v3fl(col, track->color, 0.5f);
668  }
669  else {
671 
672  if (act) {
674  }
675  else {
677  }
678  }
679 }
680 
682  const MovieTrackingMarker *marker,
683  const bool is_track_active,
684  const bool is_area_selected,
685  const float color[3],
686  const float selected_color[3])
687 {
688  if (track->flag & TRACK_LOCKED) {
689  if (is_track_active) {
691  }
692  else if (is_area_selected) {
694  }
695  else {
697  }
698  }
699  else if (marker->flag & MARKER_DISABLED) {
700  if (is_track_active) {
702  }
703  else if (is_area_selected) {
705  }
706  else {
708  }
709  }
710  else {
711  immUniformColor3fv(is_area_selected ? selected_color : color);
712  }
713 }
714 
715 static void draw_marker_areas(SpaceClip *sc,
716  MovieTrackingTrack *track,
717  MovieTrackingMarker *marker,
718  const float marker_pos[2],
719  int width,
720  int height,
721  int act,
722  int sel,
723  const uint shdr_pos)
724 {
725  int tiny = sc->flag & SC_SHOW_TINY_MARKER;
726  bool show_search = false;
727  float col[3], scol[3];
728  float px[2];
729 
730  track_colors(track, act, col, scol);
731 
732  px[0] = 1.0f / width / sc->zoom;
733  px[1] = 1.0f / height / sc->zoom;
734 
735  GPU_line_width(1.0f);
736 
737  /* Since we are switching solid and dashed lines in rather complex logic here,
738  * just always go with dashed shader. */
740 
742 
743  float viewport_size[4];
744  GPU_viewport_size_get_f(viewport_size);
745  immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
746 
747  immUniform1i("colors_len", 0); /* "simple" mode */
748 
749  /* marker position and offset position */
750  if ((track->flag & SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) {
751  float pos[2], p[2];
752 
753  if (track->flag & TRACK_LOCKED) {
754  if (act) {
756  }
757  else if (track->flag & SELECT) {
759  }
760  else {
762  }
763  }
764  else {
765  immUniformColor3fv((track->flag & SELECT) ? scol : col);
766  }
767 
768  add_v2_v2v2(pos, marker->pos, track->offset);
770 
771  sub_v2_v2v2(p, pos, marker_pos);
772 
773  if (isect_point_quad_v2(p,
774  marker->pattern_corners[0],
775  marker->pattern_corners[1],
776  marker->pattern_corners[2],
777  marker->pattern_corners[3])) {
778  GPU_point_size(tiny ? 1.0f : 2.0f);
779 
780  immUniform1f("dash_factor", 2.0f); /* Solid "line" */
781 
783  immVertex2f(shdr_pos, pos[0], pos[1]);
784  immEnd();
785  }
786  else {
787  immUniform1f("dash_factor", 2.0f); /* Solid line */
788 
790 
791  immVertex2f(shdr_pos, pos[0] + px[0] * 3, pos[1]);
792  immVertex2f(shdr_pos, pos[0] + px[0] * 7, pos[1]);
793 
794  immVertex2f(shdr_pos, pos[0] - px[0] * 3, pos[1]);
795  immVertex2f(shdr_pos, pos[0] - px[0] * 7, pos[1]);
796 
797  immVertex2f(shdr_pos, pos[0], pos[1] - px[1] * 3);
798  immVertex2f(shdr_pos, pos[0], pos[1] - px[1] * 7);
799 
800  immVertex2f(shdr_pos, pos[0], pos[1] + px[1] * 3);
801  immVertex2f(shdr_pos, pos[0], pos[1] + px[1] * 7);
802 
803  immEnd();
804 
805  immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f);
806  immUniform1f("dash_width", 6.0f);
807  immUniform1f("dash_factor", 0.5f);
808 
809  GPU_logic_op_xor_set(true);
810 
812  immVertex2fv(shdr_pos, pos);
813  immVertex2fv(shdr_pos, marker_pos);
814  immEnd();
815 
816  GPU_logic_op_xor_set(false);
817  }
818  }
819 
820  /* pattern */
821  GPU_matrix_push();
822  GPU_matrix_translate_2fv(marker_pos);
823 
824  set_draw_marker_area_color(track, marker, act, track->pat_flag & SELECT, col, scol);
825 
826  if (tiny) {
827  immUniform1f("dash_width", 6.0f);
828  immUniform1f("dash_factor", 0.5f);
829  }
830  else {
831  immUniform1f("dash_factor", 2.0f); /* Solid line */
832  }
833 
834  if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
836  immVertex2fv(shdr_pos, marker->pattern_corners[0]);
837  immVertex2fv(shdr_pos, marker->pattern_corners[1]);
838  immVertex2fv(shdr_pos, marker->pattern_corners[2]);
839  immVertex2fv(shdr_pos, marker->pattern_corners[3]);
840  immEnd();
841  }
842 
843  /* search */
844  show_search = (TRACK_VIEW_SELECTED(sc, track) && ((marker->flag & MARKER_DISABLED) == 0 ||
845  (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) !=
846  0;
847 
848  if ((track->search_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_SEARCH) && show_search) {
849  set_draw_marker_area_color(track, marker, act, track->search_flag & SELECT, col, scol);
850 
851  imm_draw_box_wire_2d(shdr_pos,
852  marker->search_min[0],
853  marker->search_min[1],
854  marker->search_max[0],
855  marker->search_max[1]);
856  }
857 
858  GPU_matrix_pop();
859 
860  /* Restore default shader */
862 
865  BLI_assert(pos == shdr_pos);
867 
869 }
870 
872 {
873  float len_sq = FLT_MAX;
874 
875  for (int i = 0; i < 4; i++) {
876  int next = (i + 1) % 4;
877  float cur_len = len_squared_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]);
878  len_sq = min_ff(cur_len, len_sq);
879  }
880 
881  return sqrtf(len_sq);
882 }
883 
885  float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
886 {
887  float tdx, tdy;
888 
889  tdx = dx;
890  tdy = dy;
891 
892  if (outline) {
893  tdx += px[0];
894  tdy += px[1];
895  }
896 
897  immRectf(pos, x - tdx, y - tdy, x + tdx, y + tdy);
898 }
899 
901  float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
902 {
903  float tdx, tdy;
904 
905  tdx = dx * 2.0f;
906  tdy = dy * 2.0f;
907 
908  if (outline) {
909  tdx += px[0];
910  tdy += px[1];
911  }
912 
914  immVertex2f(pos, x, y);
915  immVertex2f(pos, x - tdx, y);
916  immVertex2f(pos, x, y + tdy);
917  immEnd();
918 }
919 
921  MovieTrackingTrack *track,
922  MovieTrackingMarker *marker,
923  const float marker_pos[2],
924  int outline,
925  int sel,
926  int act,
927  int width,
928  int height,
929  uint pos)
930 {
931  float dx, dy, patdx, patdy, searchdx, searchdy;
932  int tiny = sc->flag & SC_SHOW_TINY_MARKER;
933  float col[3], scol[3], px[2], side;
934 
935  if ((tiny && outline) || (marker->flag & MARKER_DISABLED)) {
936  return;
937  }
938 
939  if (!TRACK_VIEW_SELECTED(sc, track) || track->flag & TRACK_LOCKED) {
940  return;
941  }
942 
943  track_colors(track, act, col, scol);
944 
945  if (outline) {
947  }
948 
949  GPU_matrix_push();
950  GPU_matrix_translate_2fv(marker_pos);
951 
952  dx = 6.0f / width / sc->zoom;
953  dy = 6.0f / height / sc->zoom;
954 
955  side = get_shortest_pattern_side(marker);
956  patdx = min_ff(dx * 2.0f / 3.0f, side / 6.0f) * UI_DPI_FAC;
957  patdy = min_ff(dy * 2.0f / 3.0f, side * width / height / 6.0f) * UI_DPI_FAC;
958 
959  searchdx = min_ff(dx, (marker->search_max[0] - marker->search_min[0]) / 6.0f) * UI_DPI_FAC;
960  searchdy = min_ff(dy, (marker->search_max[1] - marker->search_min[1]) / 6.0f) * UI_DPI_FAC;
961 
962  px[0] = 1.0f / sc->zoom / width / sc->scale;
963  px[1] = 1.0f / sc->zoom / height / sc->scale;
964 
965  if ((sc->flag & SC_SHOW_MARKER_SEARCH) && ((track->search_flag & SELECT) == sel || outline)) {
966  if (!outline) {
967  immUniformColor3fv((track->search_flag & SELECT) ? scol : col);
968  }
969 
970  /* search offset square */
972  marker->search_min[0], marker->search_max[1], searchdx, searchdy, outline, px, pos);
973 
974  /* search re-sizing triangle */
976  marker->search_max[0], marker->search_min[1], searchdx, searchdy, outline, px, pos);
977  }
978 
979  if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) {
980  float pat_min[2], pat_max[2];
981  /* float dx = 12.0f / width, dy = 12.0f / height;*/ /* XXX UNUSED */
982  float tilt_ctrl[2];
983 
984  if (!outline) {
985  immUniformColor3fv((track->pat_flag & SELECT) ? scol : col);
986  }
987 
988  /* pattern's corners sliding squares */
989  for (int i = 0; i < 4; i++) {
991  marker->pattern_corners[i][1],
992  patdx / 1.5f,
993  patdy / 1.5f,
994  outline,
995  px,
996  pos);
997  }
998 
999  /* ** sliders to control overall pattern ** */
1000  add_v2_v2v2(tilt_ctrl, marker->pattern_corners[1], marker->pattern_corners[2]);
1001 
1002  BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1003 
1004  GPU_line_width(outline ? 3.0f : 1.0f);
1005 
1007  immVertex2f(pos, 0.0f, 0.0f);
1008  immVertex2fv(pos, tilt_ctrl);
1009  immEnd();
1010 
1011  /* slider to control pattern tilt */
1012  draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px, pos);
1013  }
1014 
1015  GPU_matrix_pop();
1016 }
1017 
1019  MovieTrackingTrack *track,
1020  MovieTrackingMarker *marker,
1021  const float marker_pos[2],
1022  int act,
1023  int width,
1024  int height,
1025  float zoomx,
1026  float zoomy)
1027 {
1028  char str[128] = {0}, state[64] = {0};
1029  float dx = 0.0f, dy = 0.0f, fontsize, pos[3];
1030  uiStyle *style = U.uistyles.first;
1031  int fontid = style->widget.uifont_id;
1032 
1033  if (!TRACK_VIEW_SELECTED(sc, track)) {
1034  return;
1035  }
1036 
1037  BLF_size(fontid, 11.0f * U.pixelsize, U.dpi);
1038  fontsize = BLF_height_max(fontid);
1039 
1040  if (marker->flag & MARKER_DISABLED) {
1041  if (act) {
1043  }
1044  else {
1045  uchar color[4];
1047  BLF_color4ubv(fontid, color);
1048  }
1049  }
1050  else {
1052  }
1053 
1054  if ((sc->flag & SC_SHOW_MARKER_SEARCH) &&
1055  ((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) {
1056  dx = marker->search_min[0];
1057  dy = marker->search_min[1];
1058  }
1059  else if (sc->flag & SC_SHOW_MARKER_PATTERN) {
1060  float pat_min[2], pat_max[2];
1061 
1062  BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1063  dx = pat_min[0];
1064  dy = pat_min[1];
1065  }
1066 
1067  pos[0] = (marker_pos[0] + dx) * width;
1068  pos[1] = (marker_pos[1] + dy) * height;
1069  pos[2] = 0.0f;
1070 
1071  mul_m4_v3(sc->stabmat, pos);
1072 
1073  pos[0] = pos[0] * zoomx;
1074  pos[1] = pos[1] * zoomy - fontsize;
1075 
1076  if (marker->flag & MARKER_DISABLED) {
1077  strcpy(state, "disabled");
1078  }
1079  else if (marker->framenr != ED_space_clip_get_clip_frame_number(sc)) {
1080  strcpy(state, "estimated");
1081  }
1082  else if (marker->flag & MARKER_TRACKED) {
1083  strcpy(state, "tracked");
1084  }
1085  else {
1086  strcpy(state, "keyframed");
1087  }
1088 
1089  if (state[0]) {
1090  BLI_snprintf(str, sizeof(str), "%s: %s", track->name, state);
1091  }
1092  else {
1093  BLI_strncpy(str, track->name, sizeof(str));
1094  }
1095 
1096  BLF_position(fontid, pos[0], pos[1], 0.0f);
1097  BLF_draw(fontid, str, sizeof(str));
1098  pos[1] -= fontsize;
1099 
1100  if (track->flag & TRACK_HAS_BUNDLE) {
1101  BLI_snprintf(str, sizeof(str), "Average error: %.2f px", track->error);
1102  BLF_position(fontid, pos[0], pos[1], 0.0f);
1103  BLF_draw(fontid, str, sizeof(str));
1104  pos[1] -= fontsize;
1105  }
1106 
1107  if (track->flag & TRACK_LOCKED) {
1108  BLF_position(fontid, pos[0], pos[1], 0.0f);
1109  BLF_draw(fontid, "locked", 6);
1110  }
1111 }
1112 
1113 static void plane_track_colors(bool is_active, float color[3], float selected_color[3])
1114 {
1116 
1117  UI_GetThemeColor3fv(is_active ? TH_ACT_MARKER : TH_SEL_MARKER, selected_color);
1118 }
1119 
1120 static void getArrowEndPoint(const int width,
1121  const int height,
1122  const float zoom,
1123  const float start_corner[2],
1124  const float end_corner[2],
1125  float end_point[2])
1126 {
1127  float direction[2];
1128  float max_length;
1129 
1130  sub_v2_v2v2(direction, end_corner, start_corner);
1131 
1132  direction[0] *= width;
1133  direction[1] *= height;
1134  max_length = normalize_v2(direction);
1135  mul_v2_fl(direction, min_ff(32.0f / zoom, max_length));
1136  direction[0] /= width;
1137  direction[1] /= height;
1138 
1139  add_v2_v2v2(end_point, start_corner, direction);
1140 }
1141 
1142 static void homogeneous_2d_to_gl_matrix(/*const*/ float matrix[3][3], float gl_matrix[4][4])
1143 {
1144  gl_matrix[0][0] = matrix[0][0];
1145  gl_matrix[0][1] = matrix[0][1];
1146  gl_matrix[0][2] = 0.0f;
1147  gl_matrix[0][3] = matrix[0][2];
1148 
1149  gl_matrix[1][0] = matrix[1][0];
1150  gl_matrix[1][1] = matrix[1][1];
1151  gl_matrix[1][2] = 0.0f;
1152  gl_matrix[1][3] = matrix[1][2];
1153 
1154  gl_matrix[2][0] = 0.0f;
1155  gl_matrix[2][1] = 0.0f;
1156  gl_matrix[2][2] = 1.0f;
1157  gl_matrix[2][3] = 0.0f;
1158 
1159  gl_matrix[3][0] = matrix[2][0];
1160  gl_matrix[3][1] = matrix[2][1];
1161  gl_matrix[3][2] = 0.0f;
1162  gl_matrix[3][3] = matrix[2][2];
1163 }
1164 
1166  MovieTrackingPlaneTrack *plane_track,
1167  MovieTrackingPlaneMarker *plane_marker)
1168 {
1169  Image *image = plane_track->image;
1170  ImBuf *ibuf;
1171  void *lock;
1172 
1173  if (image == NULL) {
1174  return;
1175  }
1176 
1178 
1179  if (ibuf) {
1180  void *cache_handle;
1181  uchar *display_buffer = IMB_display_buffer_acquire(
1182  ibuf, &scene->view_settings, &scene->display_settings, &cache_handle);
1183 
1184  if (display_buffer) {
1185  float frame_corners[4][2] = {{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}};
1186  float perspective_matrix[3][3];
1187  float gl_matrix[4][4];
1188  bool transparent = false;
1190  frame_corners, plane_marker->corners, perspective_matrix);
1191 
1192  homogeneous_2d_to_gl_matrix(perspective_matrix, gl_matrix);
1193 
1194  if (plane_track->image_opacity != 1.0f || ibuf->planes == 32) {
1195  transparent = true;
1197  }
1198 
1199  GPUTexture *texture = GPU_texture_create_2d(
1200  "plane_marker_image", ibuf->x, ibuf->y, 1, GPU_RGBA8, NULL);
1201  GPU_texture_update(texture, GPU_DATA_UBYTE, display_buffer);
1202  GPU_texture_filter_mode(texture, false);
1203 
1204  GPU_matrix_push();
1205  GPU_matrix_mul(gl_matrix);
1206 
1207  GPUVertFormat *imm_format = immVertexFormat();
1208  uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
1209  uint texCoord = GPU_vertformat_attr_add(
1210  imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
1211 
1212  /* Use 3D image for correct display of planar tracked images. */
1214 
1215  immBindTexture("image", texture);
1216  immUniform1f("alpha", plane_track->image_opacity);
1217 
1219 
1220  immAttr2f(texCoord, 0.0f, 0.0f);
1221  immVertex3f(pos, 0.0f, 0.0f, 0.0f);
1222 
1223  immAttr2f(texCoord, 1.0f, 0.0f);
1224  immVertex3f(pos, 1.0f, 0.0f, 0.0f);
1225 
1226  immAttr2f(texCoord, 1.0f, 1.0f);
1227  immVertex3f(pos, 1.0f, 1.0f, 0.0f);
1228 
1229  immAttr2f(texCoord, 0.0f, 1.0f);
1230  immVertex3f(pos, 0.0f, 1.0f, 0.0f);
1231 
1232  immEnd();
1233 
1234  immUnbindProgram();
1235 
1236  GPU_matrix_pop();
1237 
1238  GPU_texture_unbind(texture);
1239  GPU_texture_free(texture);
1240 
1241  if (transparent) {
1243  }
1244  }
1245 
1246  IMB_display_buffer_release(cache_handle);
1247  }
1248 
1250 }
1251 
1253  Scene *scene,
1254  MovieTrackingPlaneTrack *plane_track,
1255  MovieTrackingPlaneMarker *plane_marker,
1256  bool is_active_track,
1257  bool draw_outline,
1258  int width,
1259  int height)
1260 {
1261  bool tiny = (sc->flag & SC_SHOW_TINY_MARKER) != 0;
1262  bool is_selected_track = (plane_track->flag & SELECT) != 0;
1263  const bool has_image = plane_track->image != NULL &&
1264  BKE_image_has_ibuf(plane_track->image, NULL);
1265  const bool draw_plane_quad = !has_image || plane_track->image_opacity == 0.0f;
1266  float px[2];
1267  float color[3], selected_color[3];
1268 
1269  px[0] = 1.0f / width / sc->zoom;
1270  px[1] = 1.0f / height / sc->zoom;
1271 
1272  /* Draw image */
1273  if (draw_outline == false) {
1274  draw_plane_marker_image(scene, plane_track, plane_marker);
1275  }
1276 
1277  if (draw_plane_quad || is_selected_track) {
1278  const uint shdr_pos = GPU_vertformat_attr_add(
1280 
1282 
1283  float viewport_size[4];
1284  GPU_viewport_size_get_f(viewport_size);
1285  immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
1286 
1287  immUniform1i("colors_len", 0); /* "simple" mode */
1288 
1289  if (is_selected_track) {
1290  plane_track_colors(is_active_track, color, selected_color);
1291  }
1292 
1293  if (draw_plane_quad) {
1294  const bool stipple = !draw_outline && tiny;
1295  const bool thick = draw_outline && !tiny;
1296 
1297  GPU_line_width(thick ? 3.0f : 1.0f);
1298 
1299  if (stipple) {
1300  immUniform1f("dash_width", 6.0f);
1301  immUniform1f("dash_factor", 0.5f);
1302  }
1303  else {
1304  immUniform1f("dash_factor", 2.0f); /* Solid line */
1305  }
1306 
1307  if (draw_outline) {
1309  }
1310  else {
1311  immUniformColor3fv(is_selected_track ? selected_color : color);
1312  }
1313 
1314  /* Draw rectangle itself. */
1316  immVertex2fv(shdr_pos, plane_marker->corners[0]);
1317  immVertex2fv(shdr_pos, plane_marker->corners[1]);
1318  immVertex2fv(shdr_pos, plane_marker->corners[2]);
1319  immVertex2fv(shdr_pos, plane_marker->corners[3]);
1320  immEnd();
1321 
1322  /* Draw axis. */
1323  if (!draw_outline) {
1324  float end_point[2];
1325 
1326  immUniformColor3f(1.0f, 0.0f, 0.0f);
1327 
1329 
1331  height,
1332  sc->zoom,
1333  plane_marker->corners[0],
1334  plane_marker->corners[1],
1335  end_point);
1336  immVertex2fv(shdr_pos, plane_marker->corners[0]);
1337  immVertex2fv(shdr_pos, end_point);
1338 
1339  immEnd();
1340 
1341  immUniformColor3f(0.0f, 1.0f, 0.0f);
1342 
1344 
1346  height,
1347  sc->zoom,
1348  plane_marker->corners[0],
1349  plane_marker->corners[3],
1350  end_point);
1351  immVertex2fv(shdr_pos, plane_marker->corners[0]);
1352  immVertex2fv(shdr_pos, end_point);
1353 
1354  immEnd();
1355  }
1356  }
1357  immUnbindProgram();
1358 
1359  /* Draw sliders. */
1360  if (is_selected_track) {
1362 
1363  if (draw_outline) {
1365  }
1366  else {
1367  immUniformColor3fv(selected_color);
1368  }
1369 
1370  for (int i = 0; i < 4; i++) {
1371  draw_marker_slide_square(plane_marker->corners[i][0],
1372  plane_marker->corners[i][1],
1373  3.0f * px[0],
1374  3.0f * px[1],
1375  draw_outline,
1376  px,
1377  shdr_pos);
1378  }
1379  immUnbindProgram();
1380  }
1381  }
1382 }
1383 
1385  Scene *scene,
1386  MovieTrackingPlaneTrack *plane_track,
1387  MovieTrackingPlaneMarker *plane_marker,
1388  int width,
1389  int height)
1390 {
1391  draw_plane_marker_ex(sc, scene, plane_track, plane_marker, false, true, width, height);
1392 }
1393 
1395  Scene *scene,
1396  MovieTrackingPlaneTrack *plane_track,
1397  MovieTrackingPlaneMarker *plane_marker,
1398  bool is_active_track,
1399  int width,
1400  int height)
1401 {
1403  sc, scene, plane_track, plane_marker, is_active_track, false, width, height);
1404 }
1405 
1406 static void draw_plane_track(SpaceClip *sc,
1407  Scene *scene,
1408  MovieTrackingPlaneTrack *plane_track,
1409  int framenr,
1410  bool is_active_track,
1411  int width,
1412  int height)
1413 {
1414  MovieTrackingPlaneMarker *plane_marker;
1415 
1416  plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr);
1417 
1418  draw_plane_marker_outline(sc, scene, plane_track, plane_marker, width, height);
1419  draw_plane_marker(sc, scene, plane_track, plane_marker, is_active_track, width, height);
1420 }
1421 
1422 /* Draw all kind of tracks. */
1424  Scene *scene,
1425  ARegion *region,
1426  MovieClip *clip,
1427  int width,
1428  int height,
1429  float zoomx,
1430  float zoomy)
1431 {
1432  float x, y;
1433  MovieTracking *tracking = &clip->tracking;
1434  ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
1435  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
1436  MovieTrackingTrack *track, *act_track;
1437  MovieTrackingPlaneTrack *plane_track, *active_plane_track;
1438  MovieTrackingMarker *marker;
1439  int framenr = ED_space_clip_get_clip_frame_number(sc);
1440  int undistort = sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
1441  float *marker_pos = NULL, *fp, *active_pos = NULL, cur_pos[2];
1442 
1443  /* ** find window pixel coordinates of origin ** */
1444 
1445  /* UI_view2d_view_to_region_no_clip return integer values, this could
1446  * lead to 1px flickering when view is locked to selection during playback.
1447  * to avoid this flickering, calculate base point in the same way as it happens
1448  * in UI_view2d_view_to_region_no_clip, but do it in floats here */
1449 
1450  UI_view2d_view_to_region_fl(&region->v2d, 0.0f, 0.0f, &x, &y);
1451 
1452  GPU_matrix_push();
1454 
1455  GPU_matrix_push();
1456  GPU_matrix_scale_2f(zoomx, zoomy);
1457  GPU_matrix_mul(sc->stabmat);
1459 
1460  act_track = BKE_tracking_track_get_active(tracking);
1461 
1462  /* Draw plane tracks */
1463  active_plane_track = BKE_tracking_plane_track_get_active(tracking);
1464  for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) {
1465  if ((plane_track->flag & PLANE_TRACK_HIDDEN) == 0) {
1467  sc, scene, plane_track, framenr, plane_track == active_plane_track, width, height);
1468  }
1469  }
1470 
1472  int count = 0;
1473 
1474  /* count */
1475  track = tracksbase->first;
1476  while (track) {
1477  if ((track->flag & TRACK_HIDDEN) == 0) {
1478  marker = BKE_tracking_marker_get(track, framenr);
1479 
1480  if (MARKER_VISIBLE(sc, track, marker)) {
1481  count++;
1482  }
1483  }
1484 
1485  track = track->next;
1486  }
1487 
1488  /* undistort */
1489  if (count) {
1490  marker_pos = MEM_callocN(sizeof(float[2]) * count, "draw_tracking_tracks marker_pos");
1491 
1492  track = tracksbase->first;
1493  fp = marker_pos;
1494  while (track) {
1495  if ((track->flag & TRACK_HIDDEN) == 0) {
1496  marker = BKE_tracking_marker_get(track, framenr);
1497 
1498  if (MARKER_VISIBLE(sc, track, marker)) {
1499  ED_clip_point_undistorted_pos(sc, marker->pos, fp);
1500 
1501  if (track == act_track) {
1502  active_pos = fp;
1503  }
1504 
1505  fp += 2;
1506  }
1507  }
1508 
1509  track = track->next;
1510  }
1511  }
1512  }
1513 
1514  if (sc->flag & SC_SHOW_TRACK_PATH) {
1515  track = tracksbase->first;
1516  while (track) {
1517  if ((track->flag & TRACK_HIDDEN) == 0) {
1518  draw_track_path(sc, clip, track);
1519  }
1520 
1521  track = track->next;
1522  }
1523  }
1524 
1525  uint position = GPU_vertformat_attr_add(
1527 
1529 
1530  /* markers outline and non-selected areas */
1531  track = tracksbase->first;
1532  fp = marker_pos;
1533  while (track) {
1534  if ((track->flag & TRACK_HIDDEN) == 0) {
1535  marker = BKE_tracking_marker_get(track, framenr);
1536 
1537  if (MARKER_VISIBLE(sc, track, marker)) {
1538  copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1539 
1540  draw_marker_outline(sc, track, marker, cur_pos, width, height, position);
1541  draw_marker_areas(sc, track, marker, cur_pos, width, height, 0, 0, position);
1542  draw_marker_slide_zones(sc, track, marker, cur_pos, 1, 0, 0, width, height, position);
1543  draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 0, 0, width, height, position);
1544 
1545  if (fp) {
1546  fp += 2;
1547  }
1548  }
1549  }
1550 
1551  track = track->next;
1552  }
1553 
1554  /* selected areas only, so selection wouldn't be overlapped by
1555  * non-selected areas */
1556  track = tracksbase->first;
1557  fp = marker_pos;
1558  while (track) {
1559  if ((track->flag & TRACK_HIDDEN) == 0) {
1560  int act = track == act_track;
1561  marker = BKE_tracking_marker_get(track, framenr);
1562 
1563  if (MARKER_VISIBLE(sc, track, marker)) {
1564  if (!act) {
1565  copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1566 
1567  draw_marker_areas(sc, track, marker, cur_pos, width, height, 0, 1, position);
1568  draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 1, 0, width, height, position);
1569  }
1570 
1571  if (fp) {
1572  fp += 2;
1573  }
1574  }
1575  }
1576 
1577  track = track->next;
1578  }
1579 
1580  /* active marker would be displayed on top of everything else */
1581  if (act_track) {
1582  if ((act_track->flag & TRACK_HIDDEN) == 0) {
1583  marker = BKE_tracking_marker_get(act_track, framenr);
1584 
1585  if (MARKER_VISIBLE(sc, act_track, marker)) {
1586  copy_v2_v2(cur_pos, active_pos ? active_pos : marker->pos);
1587 
1588  draw_marker_areas(sc, act_track, marker, cur_pos, width, height, 1, 1, position);
1589  draw_marker_slide_zones(sc, act_track, marker, cur_pos, 0, 1, 1, width, height, position);
1590  }
1591  }
1592  }
1593 
1594  if (sc->flag & SC_SHOW_BUNDLES) {
1596  float pos[4], vec[4], mat[4][4], aspy;
1597 
1598  GPU_point_size(3.0f);
1599 
1600  aspy = 1.0f / clip->tracking.camera.pixel_aspect;
1601  BKE_tracking_get_projection_matrix(tracking, object, framenr, width, height, mat);
1602 
1603  track = tracksbase->first;
1604  while (track) {
1605  if ((track->flag & TRACK_HIDDEN) == 0 && track->flag & TRACK_HAS_BUNDLE) {
1606  marker = BKE_tracking_marker_get(track, framenr);
1607 
1608  if (MARKER_VISIBLE(sc, track, marker)) {
1609  float npos[2];
1610  copy_v3_v3(vec, track->bundle_pos);
1611  vec[3] = 1;
1612 
1613  mul_v4_m4v4(pos, mat, vec);
1614 
1615  pos[0] = (pos[0] / (pos[3] * 2.0f) + 0.5f) * width;
1616  pos[1] = (pos[1] / (pos[3] * 2.0f) + 0.5f) * height * aspy;
1617 
1618  BKE_tracking_distort_v2(tracking, width, height, pos, npos);
1619 
1620  if (npos[0] >= 0.0f && npos[1] >= 0.0f && npos[0] <= width && npos[1] <= height * aspy) {
1621  vec[0] = (marker->pos[0] + track->offset[0]) * width;
1622  vec[1] = (marker->pos[1] + track->offset[1]) * height * aspy;
1623 
1624  sub_v2_v2(vec, npos);
1625 
1626  if (len_squared_v2(vec) < (3.0f * 3.0f)) {
1627  immUniformColor3f(0.0f, 1.0f, 0.0f);
1628  }
1629  else {
1630  immUniformColor3f(1.0f, 0.0f, 0.0f);
1631  }
1632 
1634 
1635  if (undistort) {
1636  immVertex2f(position, pos[0] / width, pos[1] / (height * aspy));
1637  }
1638  else {
1639  immVertex2f(position, npos[0] / width, npos[1] / (height * aspy));
1640  }
1641 
1642  immEnd();
1643  }
1644  }
1645  }
1646 
1647  track = track->next;
1648  }
1649  }
1650 
1651  immUnbindProgram();
1652 
1653  GPU_matrix_pop();
1654 
1655  if (sc->flag & SC_SHOW_NAMES) {
1656  /* scaling should be cleared before drawing texts, otherwise font would also be scaled */
1657  track = tracksbase->first;
1658  fp = marker_pos;
1659  while (track) {
1660  if ((track->flag & TRACK_HIDDEN) == 0) {
1661  marker = BKE_tracking_marker_get(track, framenr);
1662 
1663  if (MARKER_VISIBLE(sc, track, marker)) {
1664  int act = track == act_track;
1665 
1666  copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1667 
1668  draw_marker_texts(sc, track, marker, cur_pos, act, width, height, zoomx, zoomy);
1669 
1670  if (fp) {
1671  fp += 2;
1672  }
1673  }
1674  }
1675 
1676  track = track->next;
1677  }
1678  }
1679 
1680  GPU_matrix_pop();
1681 
1682  if (marker_pos) {
1683  MEM_freeN(marker_pos);
1684  }
1685 }
1686 
1687 static void draw_distortion(SpaceClip *sc,
1688  ARegion *region,
1689  MovieClip *clip,
1690  int width,
1691  int height,
1692  float zoomx,
1693  float zoomy)
1694 {
1695  float x, y;
1696  const int n = 10;
1697  float tpos[2], grid[11][11][2];
1698  MovieTracking *tracking = &clip->tracking;
1699  bGPdata *gpd = NULL;
1700  float aspy = 1.0f / tracking->camera.pixel_aspect;
1701  float dx = (float)width / n, dy = (float)height / n * aspy;
1702  float offsx = 0.0f, offsy = 0.0f;
1703 
1704  if (!tracking->camera.focal) {
1705  return;
1706  }
1707 
1708  if ((sc->flag & SC_SHOW_GRID) == 0 && (sc->flag & SC_MANUAL_CALIBRATION) == 0) {
1709  return;
1710  }
1711 
1712  UI_view2d_view_to_region_fl(&region->v2d, 0.0f, 0.0f, &x, &y);
1713 
1714  GPU_matrix_push();
1716  GPU_matrix_scale_2f(zoomx, zoomy);
1717  GPU_matrix_mul(sc->stabmat);
1719 
1720  uint position = GPU_vertformat_attr_add(
1722 
1724 
1725  /* grid */
1726  if (sc->flag & SC_SHOW_GRID) {
1727  float val[4][2], idx[4][2];
1728  float min[2], max[2];
1729 
1730  for (int a = 0; a < 4; a++) {
1731  if (a < 2) {
1732  val[a][a % 2] = FLT_MAX;
1733  }
1734  else {
1735  val[a][a % 2] = -FLT_MAX;
1736  }
1737  }
1738 
1739  for (int i = 0; i <= n; i++) {
1740  for (int j = 0; j <= n; j++) {
1741  if (i == 0 || j == 0 || i == n || j == n) {
1742  const float pos[2] = {dx * j, dy * i};
1743  BKE_tracking_distort_v2(tracking, width, height, pos, tpos);
1744 
1745  for (int a = 0; a < 4; a++) {
1746  int ok;
1747 
1748  if (a < 2) {
1749  ok = tpos[a % 2] < val[a][a % 2];
1750  }
1751  else {
1752  ok = tpos[a % 2] > val[a][a % 2];
1753  }
1754 
1755  if (ok) {
1756  copy_v2_v2(val[a], tpos);
1757  idx[a][0] = j;
1758  idx[a][1] = i;
1759  }
1760  }
1761  }
1762  }
1763  }
1764 
1765  INIT_MINMAX2(min, max);
1766 
1767  for (int a = 0; a < 4; a++) {
1768  const float pos[2] = {idx[a][0] * dx, idx[a][1] * dy};
1769 
1770  BKE_tracking_undistort_v2(tracking, width, height, pos, tpos);
1771 
1772  minmax_v2v2_v2(min, max, tpos);
1773  }
1774 
1775  dx = (max[0] - min[0]) / n;
1776  dy = (max[1] - min[1]) / n;
1777 
1778  for (int i = 0; i <= n; i++) {
1779  for (int j = 0; j <= n; j++) {
1780  const float pos[2] = {min[0] + dx * j, min[1] + dy * i};
1781 
1782  BKE_tracking_distort_v2(tracking, width, height, pos, grid[i][j]);
1783 
1784  grid[i][j][0] /= width;
1785  grid[i][j][1] /= height * aspy;
1786  }
1787  }
1788 
1789  immUniformColor3f(1.0f, 0.0f, 0.0f);
1790 
1791  for (int i = 0; i <= n; i++) {
1792  immBegin(GPU_PRIM_LINE_STRIP, n + 1);
1793 
1794  for (int j = 0; j <= n; j++) {
1795  immVertex2fv(position, grid[i][j]);
1796  }
1797 
1798  immEnd();
1799  }
1800 
1801  for (int j = 0; j <= n; j++) {
1802  immBegin(GPU_PRIM_LINE_STRIP, n + 1);
1803 
1804  for (int i = 0; i <= n; i++) {
1805  immVertex2fv(position, grid[i][j]);
1806  }
1807 
1808  immEnd();
1809  }
1810  }
1811 
1812  if (sc->gpencil_src != SC_GPENCIL_SRC_TRACK) {
1813  gpd = clip->gpd;
1814  }
1815 
1816  if (sc->flag & SC_MANUAL_CALIBRATION && gpd) {
1817  bGPDlayer *layer = gpd->layers.first;
1818 
1819  while (layer) {
1820  bGPDframe *frame = layer->frames.first;
1821 
1822  if (layer->flag & GP_LAYER_HIDE) {
1823  layer = layer->next;
1824  continue;
1825  }
1826 
1827  immUniformColor4fv(layer->color);
1828 
1829  GPU_line_width(layer->thickness);
1830  GPU_point_size((float)(layer->thickness + 2));
1831 
1832  while (frame) {
1833  bGPDstroke *stroke = frame->strokes.first;
1834 
1835  while (stroke) {
1836  if (stroke->flag & GP_STROKE_2DSPACE) {
1837  if (stroke->totpoints > 1) {
1838  for (int i = 0; i < stroke->totpoints - 1; i++) {
1839  float pos[2], npos[2], dpos[2], len;
1840  int steps;
1841 
1842  pos[0] = (stroke->points[i].x + offsx) * width;
1843  pos[1] = (stroke->points[i].y + offsy) * height * aspy;
1844 
1845  npos[0] = (stroke->points[i + 1].x + offsx) * width;
1846  npos[1] = (stroke->points[i + 1].y + offsy) * height * aspy;
1847 
1848  len = len_v2v2(pos, npos);
1849  steps = ceil(len / 5.0f);
1850 
1851  /* we want to distort only long straight lines */
1852  if (stroke->totpoints == 2) {
1854  BKE_tracking_undistort_v2(tracking, width, height, npos, npos);
1855  }
1856 
1857  sub_v2_v2v2(dpos, npos, pos);
1858  mul_v2_fl(dpos, 1.0f / steps);
1859 
1861 
1862  for (int j = 0; j <= steps; j++) {
1863  BKE_tracking_distort_v2(tracking, width, height, pos, tpos);
1864  immVertex2f(position, tpos[0] / width, tpos[1] / (height * aspy));
1865 
1866  add_v2_v2(pos, dpos);
1867  }
1868 
1869  immEnd();
1870  }
1871  }
1872  else if (stroke->totpoints == 1) {
1874  immVertex2f(position, stroke->points[0].x + offsx, stroke->points[0].y + offsy);
1875  immEnd();
1876  }
1877  }
1878 
1879  stroke = stroke->next;
1880  }
1881 
1882  frame = frame->next;
1883  }
1884 
1885  layer = layer->next;
1886  }
1887  }
1888 
1889  immUnbindProgram();
1890 
1891  GPU_matrix_pop();
1892 }
1893 
1894 void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *region)
1895 {
1896  MovieClip *clip = ED_space_clip_get_clip(sc);
1898  ImBuf *ibuf = NULL;
1899  int width, height;
1900  float zoomx, zoomy;
1901 
1903  ED_space_clip_get_zoom(sc, region, &zoomx, &zoomy);
1904 
1905  /* if no clip, nothing to do */
1906  if (!clip) {
1907  ED_region_grid_draw(region, zoomx, zoomy, 0.0f, 0.0f);
1908  return;
1909  }
1910 
1911  if (sc->flag & SC_SHOW_STABLE) {
1912  float translation[2];
1913  float aspect = clip->tracking.camera.pixel_aspect;
1914  float smat[4][4], ismat[4][4];
1915 
1916  if ((sc->flag & SC_MUTE_FOOTAGE) == 0) {
1917  ibuf = ED_space_clip_get_stable_buffer(sc, sc->loc, &sc->scale, &sc->angle);
1918  }
1919 
1920  if (ibuf != NULL && width != ibuf->x) {
1921  mul_v2_v2fl(translation, sc->loc, (float)width / ibuf->x);
1922  }
1923  else {
1924  copy_v2_v2(translation, sc->loc);
1925  }
1926 
1928  width, height, aspect, translation, sc->scale, sc->angle, sc->stabmat);
1929 
1930  unit_m4(smat);
1931  smat[0][0] = 1.0f / width;
1932  smat[1][1] = 1.0f / height;
1933  invert_m4_m4(ismat, smat);
1934 
1935  mul_m4_series(sc->unistabmat, smat, sc->stabmat, ismat);
1936  }
1937  else if ((sc->flag & SC_MUTE_FOOTAGE) == 0) {
1938  ibuf = ED_space_clip_get_buffer(sc);
1939 
1940  zero_v2(sc->loc);
1941  sc->scale = 1.0f;
1942  unit_m4(sc->stabmat);
1943  unit_m4(sc->unistabmat);
1944  }
1945 
1946  if (ibuf) {
1947  draw_movieclip_buffer(C, sc, region, ibuf, width, height, zoomx, zoomy);
1948  IMB_freeImBuf(ibuf);
1949  }
1950  else if (sc->flag & SC_MUTE_FOOTAGE) {
1951  draw_movieclip_muted(region, width, height, zoomx, zoomy);
1952  }
1953  else {
1954  ED_region_grid_draw(region, zoomx, zoomy, 0.0f, 0.0f);
1955  }
1956 
1957  if (width && height) {
1958  draw_stabilization_border(sc, region, width, height, zoomx, zoomy);
1959  draw_tracking_tracks(sc, scene, region, clip, width, height, zoomx, zoomy);
1960  draw_distortion(sc, region, clip, width, height, zoomx, zoomy);
1961  }
1962 }
1963 
1965 {
1967  MovieClip *clip = ED_space_clip_get_clip(sc);
1968  if (clip) {
1969  draw_movieclip_cache(sc, region, clip, scene);
1970  draw_movieclip_notes(sc, region);
1971  }
1972 }
1973 
1975 {
1976  SpaceClip *sc = CTX_wm_space_clip(C);
1977  MovieClip *clip = ED_space_clip_get_clip(sc);
1978 
1979  if (!clip) {
1980  return;
1981  }
1982 
1983  if (onlyv2d) {
1984  bool is_track_source = sc->gpencil_src == SC_GPENCIL_SRC_TRACK;
1985  /* if manual calibration is used then grease pencil data
1986  * associated with the clip is already drawn in draw_distortion
1987  */
1988  if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || is_track_source) {
1989  GPU_matrix_push();
1991 
1992  if (is_track_source) {
1994 
1995  if (track) {
1996  int framenr = ED_space_clip_get_clip_frame_number(sc);
1997  MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1998 
1999  GPU_matrix_translate_2fv(marker->pos);
2000  }
2001  }
2002 
2004 
2005  GPU_matrix_pop();
2006  }
2007  }
2008  else {
2010  }
2011 }
typedef float(TangentPoint)[2]
void ED_draw_imbuf_ctx(const struct bContext *C, struct ImBuf *ibuf, float x, float y, bool use_filter, float zoom_x, float zoom_y)
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct SpaceClip * CTX_wm_space_clip(const bContext *C)
Definition: context.c:923
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
bool BKE_image_has_ibuf(struct Image *ima, struct ImageUser *iuser)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
void BKE_movieclip_get_cache_segments(struct MovieClip *clip, struct MovieClipUser *user, int *r_totseg, int **r_points)
Definition: movieclip.c:1596
struct MovieTrackingPlaneTrack * BKE_tracking_plane_track_get_active(struct MovieTracking *tracking)
Definition: tracking.c:1718
void BKE_tracking_stabilization_data_to_mat4(int width, int height, float aspect, float translation[2], float scale, float angle, float mat[4][4])
struct ListBase * BKE_tracking_get_active_tracks(struct MovieTracking *tracking)
Definition: tracking.c:346
#define MARKER_VISIBLE(sc, track, marker)
Definition: BKE_tracking.h:840
struct MovieTrackingPlaneMarker * BKE_tracking_plane_marker_get(struct MovieTrackingPlaneTrack *plane_track, int framenr)
Definition: tracking.c:1890
struct MovieTrackingTrack * BKE_tracking_track_get_active(struct MovieTracking *tracking)
Definition: tracking.c:1089
struct MovieTrackingReconstruction * BKE_tracking_get_active_reconstruction(struct MovieTracking *tracking)
Definition: tracking.c:368
struct MovieTrackingMarker * BKE_tracking_marker_get_exact(struct MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1457
struct ListBase * BKE_tracking_get_active_plane_tracks(struct MovieTracking *tracking)
Definition: tracking.c:357
void BKE_tracking_distort_v2(struct MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
Definition: tracking.c:2457
#define TRACK_VIEW_SELECTED(sc, track)
Definition: BKE_tracking.h:831
void BKE_tracking_marker_pattern_minmax(const struct MovieTrackingMarker *marker, float min[2], float max[2])
void BKE_tracking_get_projection_matrix(struct MovieTracking *tracking, struct MovieTrackingObject *object, int framenr, int winx, int winy, float mat[4][4])
Definition: tracking.c:391
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1424
void BKE_tracking_undistort_v2(struct MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
Definition: tracking.c:2480
void BKE_tracking_homography_between_two_quads(float reference_corners[4][2], float corners[4][2], float H[3][3])
struct MovieTrackingObject * BKE_tracking_object_get_active(struct MovieTracking *tracking)
Definition: tracking.c:2092
void BLF_draw(int fontid, const char *str, size_t str_len) ATTR_NONNULL(2)
Definition: blf.c:538
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
Definition: blf.c:722
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
Definition: blf.c:383
void BLF_size(int fontid, float size, int dpi)
Definition: blf.c:363
void BLF_position(int fontid, float x, float y, float z)
Definition: blf.c:308
#define BLI_assert(a)
Definition: BLI_assert.h:46
MINLINE int min_ii(int a, int b)
MINLINE float min_ff(float a, float b)
int isect_point_quad_v2(const float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2])
Definition: math_geom.c:1536
void mul_v4_m4v4(float r[4], const float M[4][4], const float v[4])
Definition: math_matrix.c:850
void unit_m4(float m[4][4])
Definition: rct.c:1090
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1287
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:729
#define mul_m4_series(...)
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
Definition: math_vector.c:890
MINLINE void add_v2_v2(float r[2], const float a[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])
MINLINE void zero_v2(float r[2])
MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float normalize_v2(float r[2])
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition: rct.c:407
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
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_VARS_NDEBUG(...)
#define UNUSED(x)
#define ELEM(...)
@ GP_STROKE_2DSPACE
@ GP_LAYER_HIDE
@ MCLIP_PROXY_RENDER_UNDISTORT
@ MCLIP_PROXY_RENDER_SIZE_100
@ MCLIP_PROXY_RENDER_SIZE_FULL
@ MCLIP_USE_PROXY
@ SC_MODE_MASKEDIT
@ SC_SHOW_MARKER_SEARCH
@ SC_SHOW_NAMES
@ SC_SHOW_TINY_MARKER
@ SC_LOCK_SELECTION
@ SC_SHOW_METADATA
@ SC_SHOW_GRID
@ SC_SHOW_STABLE
@ SC_MUTE_FOOTAGE
@ SC_SHOW_BUNDLES
@ SC_SHOW_MARKER_PATTERN
@ SC_MANUAL_CALIBRATION
@ SC_SHOW_TRACK_PATH
@ SC_GPENCIL_SRC_TRACK
@ PLANE_MARKER_TRACKED
@ TRACKING_2D_STABILIZATION
@ TRACKING_RECONSTRUCTED
@ PLANE_TRACK_HIDDEN
@ MARKER_TRACKED
@ MARKER_DISABLED
@ TRACK_CUSTOMCOLOR
@ TRACK_HIDDEN
@ TRACK_LOCKED
@ TRACK_HAS_BUNDLE
int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc)
Definition: clip_editor.c:231
void ED_clip_point_undistorted_pos(struct SpaceClip *sc, const float co[2], float r_co[2])
Definition: clip_editor.c:462
struct ImBuf * ED_space_clip_get_buffer(struct SpaceClip *sc)
Definition: clip_editor.c:239
void ED_space_clip_get_zoom(struct SpaceClip *sc, struct ARegion *region, float *zoomx, float *zoomy)
Definition: clip_editor.c:164
void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height)
Definition: clip_editor.c:146
struct ImBuf * ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2], float *scale, float *angle)
Definition: clip_editor.c:258
struct MovieClip * ED_space_clip_get_clip(struct SpaceClip *sc)
Definition: clip_editor.c:570
void ED_mask_draw_frames(struct Mask *mask, struct ARegion *region, int cfra, int sfra, int efra)
Definition: mask_draw.c:773
void ED_region_info_draw(struct ARegion *region, const char *text, float fill_color[4], bool full_redraw)
Definition: area.c:3591
void ED_region_grid_draw(struct ARegion *region, float zoomx, float zoomy, float x0, float y0)
Definition: area.c:3619
void ED_region_cache_draw_curfra_label(int framenr, float x, float y)
Definition: area.c:3788
void ED_region_cache_draw_background(struct ARegion *region)
Definition: area.c:3774
void ED_region_cache_draw_cached_segments(struct ARegion *region, int num_segments, const int *points, int sfra, int efra)
Definition: area.c:3813
void ED_region_image_metadata_draw(int x, int y, struct ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)
Definition: ed_draw.c:755
void immUniform2f(const char *name, float x, float y)
void immUniformColor4f(float r, float g, float b, float a)
void immUnbindProgram(void)
void immVertex2f(uint attr_id, float x, float y)
void immUniformThemeColor(int color_id)
void immUniformThemeColorShade(int color_id, int offset)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immBindTexture(const char *name, GPUTexture *tex)
void immVertex3f(uint attr_id, float x, float y, float z)
void immVertex2fv(uint attr_id, const float data[2])
void immUniform1i(const char *name, int x)
void immBeginAtMost(GPUPrimType, uint max_vertex_len)
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)
void immUniformColor4fv(const float rgba[4])
GPUVertFormat * immVertexFormat(void)
void immUniformColor3f(float r, float g, float b)
void immAttr2f(uint attr_id, float x, float y)
void immBegin(GPUPrimType, uint vertex_len)
void immEnd(void)
void immUniformColor3fv(const float rgb[3])
void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2)
void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2)
void immRecti(uint pos, int x1, int y1, int x2, int y2)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
_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_translate_2fv(const float vec[2])
Definition: gpu_matrix.cc:183
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
@ GPU_PRIM_TRI_FAN
Definition: GPU_primitive.h:25
@ 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
@ GPU_PRIM_TRIS
Definition: GPU_primitive.h:21
@ GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR
Definition: GPU_shader.h:349
@ GPU_SHADER_3D_IMAGE_MODULATE_ALPHA
Definition: GPU_shader.h:300
@ GPU_SHADER_2D_UNIFORM_COLOR
Definition: GPU_shader.h:201
@ 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_logic_op_xor_set(bool enable)
Definition: gpu_state.cc:85
void GPU_point_size(float size)
Definition: gpu_state.cc:164
void GPU_viewport_size_get_f(float coords[4])
Definition: gpu_state.cc:259
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
@ GPU_DATA_UBYTE
Definition: GPU_texture.h:174
void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
Definition: gpu_texture.cc:444
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:564
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter)
Definition: gpu_texture.cc:518
void GPU_texture_unbind(GPUTexture *tex)
Definition: gpu_texture.cc:472
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:291
@ GPU_RGBA8
Definition: GPU_texture.h:87
@ 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
void IMB_display_buffer_release(void *cache_handle)
unsigned char * IMB_display_buffer_acquire(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings, void **cache_handle)
Contains defines and structs used throughout the imbuf module.
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
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
#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_PATH_BEFORE
Definition: UI_resources.h:234
@ TH_MARKER_OUTLINE
Definition: UI_resources.h:228
@ TH_LOCK_MARKER
Definition: UI_resources.h:239
@ TH_PATH_AFTER
Definition: UI_resources.h:235
@ TH_DIS_MARKER
Definition: UI_resources.h:233
@ TH_CFRAME
Definition: UI_resources.h:97
@ TH_MARKER
Definition: UI_resources.h:229
@ TH_ACT_MARKER
Definition: UI_resources.h:230
@ TH_PATH_KEYFRAME_AFTER
Definition: UI_resources.h:237
@ TH_SEL_MARKER
Definition: UI_resources.h:231
@ TH_PATH_KEYFRAME_BEFORE
Definition: UI_resources.h:236
void UI_GetThemeColorShade4ubv(int colorid, int offset, unsigned char col[4])
Definition: resources.c:1241
void UI_FontThemeColor(int fontid, int colorid)
Definition: resources.c:1134
void UI_view2d_view_to_region_fl(const struct View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL()
void UI_view2d_view_to_region(const struct View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
void ED_annotation_draw_2dimage(const bContext *C)
void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
volatile int lock
unsigned int U
Definition: btGjkEpa3.h:78
static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, const float marker_pos[2], int width, int height, int act, int sel, const uint shdr_pos)
Definition: clip_draw.c:715
void clip_draw_cache_and_notes(const bContext *C, SpaceClip *sc, ARegion *region)
Definition: clip_draw.c:1964
static void draw_movieclip_notes(SpaceClip *sc, ARegion *region)
Definition: clip_draw.c:261
static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip, Scene *scene)
Definition: clip_draw.c:130
static void track_colors(MovieTrackingTrack *track, int act, float col[3], float scol[3])
Definition: clip_draw.c:657
static void draw_movieclip_muted(ARegion *region, int width, int height, float zoomx, float zoomy)
Definition: clip_draw.c:284
static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, const float marker_pos[2], int width, int height, uint position)
Definition: clip_draw.c:570
static void draw_track_path_points(const TrackPathPoint *path, uint position_attribute, const int start_point, const int num_points)
Definition: clip_draw.c:441
static void draw_plane_marker(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker, bool is_active_track, int width, int height)
Definition: clip_draw.c:1394
static void getArrowEndPoint(const int width, const int height, const float zoom, const float start_corner[2], const float end_corner[2], float end_point[2])
Definition: clip_draw.c:1120
struct TrachPathPoint TrackPathPoint
static void draw_marker_slide_triangle(float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
Definition: clip_draw.c:900
static void draw_track_path_keyframe_points(const TrackPathPoint *path, uint position_attribute, const int start_point, const int num_points)
Definition: clip_draw.c:457
void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *region)
Definition: clip_draw.c:1894
static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, const float marker_pos[2], int act, int width, int height, float zoomx, float zoomy)
Definition: clip_draw.c:1018
static int track_to_path_segment(SpaceClip *sc, MovieTrackingTrack *track, int direction, TrackPathPoint *path)
Definition: clip_draw.c:410
#define MAX_STATIC_PATH
static void set_draw_marker_area_color(const MovieTrackingTrack *track, const MovieTrackingMarker *marker, const bool is_track_active, const bool is_area_selected, const float color[3], const float selected_color[3])
Definition: clip_draw.c:681
static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker, bool is_active_track, bool draw_outline, int width, int height)
Definition: clip_draw.c:1252
static void draw_plane_track(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track, int framenr, bool is_active_track, int width, int height)
Definition: clip_draw.c:1406
static void marker_to_path_point(SpaceClip *sc, const MovieTrackingTrack *track, const MovieTrackingMarker *marker, TrackPathPoint *point)
Definition: clip_draw.c:397
static void draw_distortion(SpaceClip *sc, ARegion *region, MovieClip *clip, int width, int height, float zoomx, float zoomy)
Definition: clip_draw.c:1687
static float get_shortest_pattern_side(MovieTrackingMarker *marker)
Definition: clip_draw.c:871
static void plane_track_colors(bool is_active, float color[3], float selected_color[3])
Definition: clip_draw.c:1113
@ PATH_POINT_FLAG_KEYFRAME
Definition: clip_draw.c:389
static bool generic_track_is_marker_enabled(MovieTrackingTrack *track, MovieTrackingPlaneTrack *plane_track, int marker_index)
Definition: clip_draw.c:99
static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *region, MovieClip *clip, int width, int height, float zoomx, float zoomy)
Definition: clip_draw.c:1423
static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackingTrack *track)
Definition: clip_draw.c:488
static int generic_track_get_marker_framenr(MovieTrackingTrack *track, MovieTrackingPlaneTrack *plane_track, int marker_index)
Definition: clip_draw.c:83
static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int width, uint pos)
Definition: clip_draw.c:54
static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *region, ImBuf *ibuf, int width, int height, float zoomx, float zoomy)
Definition: clip_draw.c:300
void clip_draw_grease_pencil(bContext *C, int onlyv2d)
Definition: clip_draw.c:1974
static void draw_stabilization_border(SpaceClip *sc, ARegion *region, int width, int height, float zoomx, float zoomy)
Definition: clip_draw.c:343
static void draw_marker_slide_square(float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
Definition: clip_draw.c:884
static void draw_track_path_lines(const TrackPathPoint *path, uint position_attribute, const int start_point, const int num_points)
Definition: clip_draw.c:472
static int generic_track_get_markersnr(MovieTrackingTrack *track, MovieTrackingPlaneTrack *plane_track)
Definition: clip_draw.c:70
static void homogeneous_2d_to_gl_matrix(float matrix[3][3], float gl_matrix[4][4])
Definition: clip_draw.c:1142
static void draw_plane_marker_image(Scene *scene, MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker)
Definition: clip_draw.c:1165
static bool generic_track_is_marker_keyframed(MovieTrackingTrack *track, MovieTrackingPlaneTrack *plane_track, int marker_index)
Definition: clip_draw.c:114
static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, const float marker_pos[2], int outline, int sel, int act, int width, int height, uint pos)
Definition: clip_draw.c:920
static void draw_plane_marker_outline(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker, int width, int height)
Definition: clip_draw.c:1384
#define SELECT
Scene scene
int len
Definition: draw_manager.c:108
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
#define str(s)
uint pos
uint col
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
int count
const ProjectiveReconstruction & reconstruction
Definition: intersect.cc:198
const int state
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
ccl_device_inline float3 ceil(const float3 &a)
Definition: math_float3.h:363
static ulong * next
#define ceilf(x)
Definition: metal/compat.h:225
#define sqrtf(x)
Definition: metal/compat.h:243
static unsigned a[3]
Definition: RandGen.cpp:78
static const int steps
Definition: sky_nishita.cpp:19
#define min(a, b)
Definition: sort.c:35
unsigned char planes
void * first
Definition: DNA_listBase.h:31
struct Mask * mask
struct MovieTracking tracking
struct bGPdata * gpd
struct MovieTrackingPlaneTrack * next
MovieTrackingPlaneMarker * markers
MovieTrackingMarker * markers
struct MovieTrackingTrack * next
MovieTrackingStats * stats
MovieTrackingStabilization stabilization
MovieTrackingCamera camera
float co[3]
ColorManagedViewSettings view_settings
struct RenderData r
ColorManagedDisplaySettings display_settings
struct MovieClipUser user
float stabmat[4][4]
float unistabmat[4][4]
float loc[2]
struct MovieClip * clip
MaskSpaceInfo mask_info
float co[2]
Definition: clip_draw.c:393
struct bGPDframe * next
ListBase strokes
float color[4]
struct bGPDlayer * next
ListBase frames
bGPDspoint * points
struct bGPDstroke * next
ListBase layers
uiFontStyle widget
float max