Blender V5.3
clip_draw.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10#include "DNA_movieclip_types.h"
11#include "DNA_scene_types.h"
12
13#include "MEM_guardedalloc.h"
14
16#include "IMB_imbuf.hh"
17#include "IMB_imbuf_types.hh"
18
19#include "BLI_listbase.hh"
20#include "BLI_math_base_c.hh"
21#include "BLI_math_geom_c.hh"
22#include "BLI_rect.hh"
23#include "BLI_string_utf8.hh"
24#include "BLI_utildefines.hh"
25
26#include "BKE_context.hh"
27#include "BKE_image.hh"
28#include "BKE_movieclip.hh"
29#include "BKE_tracking.hh"
30
31#include "ED_clip.hh"
32#include "ED_gpencil_legacy.hh"
33#include "ED_mask.hh"
34#include "ED_screen.hh"
35#include "ED_util.hh"
36
37#include "BIF_glutil.hh"
38
39#include "GPU_immediate.hh"
40#include "GPU_immediate_util.hh"
41#include "GPU_matrix.hh"
42#include "GPU_state.hh"
43
44#include "WM_types.hh"
45
46#include "UI_resources.hh"
47#include "UI_view2d.hh"
48
49#include "BLF_api.hh"
50
51#include "clip_intern.hh" /* own include */
52
53namespace blender {
54
55/*********************** main area drawing *************************/
56
57static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int width, uint pos)
58{
59 int height = (frame == cfra) ? 22 : 10;
60 int x = (frame - sfra) * framelen;
61
62 if (width == 1) {
64 immVertex2f(pos, x, 0);
65 immVertex2f(pos, x, height * UI_SCALE_FAC);
66 immEnd();
67 }
68 else {
69 immRectf(pos, x, 0, x + width, height * UI_SCALE_FAC);
70 }
71}
72
74 const MovieTrackingPlaneTrack *plane_track)
75{
76 if (track) {
77 return track->markersnr;
78 }
79 if (plane_track) {
80 return plane_track->markersnr;
81 }
82
83 return 0;
84}
85
87 const MovieTrackingPlaneTrack *plane_track,
88 const int marker_index)
89{
90 if (track) {
91 BLI_assert(marker_index < track->markersnr);
92 return track->markers[marker_index].framenr;
93 }
94 if (plane_track) {
95 BLI_assert(marker_index < plane_track->markersnr);
96 return plane_track->markers[marker_index].framenr;
97 }
98
99 return 0;
100}
101
103 const MovieTrackingPlaneTrack *plane_track,
104 const int marker_index)
105{
106 if (track) {
107 BLI_assert(marker_index < track->markersnr);
108 return (track->markers[marker_index].flag & MARKER_DISABLED) == 0;
109 }
110 if (plane_track) {
111 return true;
112 }
113
114 return false;
115}
116
118 const MovieTrackingPlaneTrack *plane_track,
119 const int marker_index)
120{
121 if (track) {
122 BLI_assert(marker_index < track->markersnr);
123 return (track->markers[marker_index].flag & MARKER_TRACKED) == 0;
124 }
125 if (plane_track) {
126 BLI_assert(marker_index < plane_track->markersnr);
127 return (plane_track->markers[marker_index].flag & PLANE_MARKER_TRACKED) == 0;
128 }
129
130 return false;
131}
132
133static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip, Scene *scene)
134{
135 float x;
136 int *points, totseg, i, a;
137 float sfra = scene->r.sfra, efra = scene->r.efra, framelen = region->winx / (efra - sfra + 1);
138 const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
139 const MovieTrackingReconstruction *reconstruction = &tracking_object->reconstruction;
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
150 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
152
153 /* track */
154 if (tracking_object->active_track || tracking_object->active_plane_track) {
155 const MovieTrackingTrack *active_track = tracking_object->active_track;
156 const MovieTrackingPlaneTrack *active_plane_track = tracking_object->active_plane_track;
157
158 for (i = sfra - clip->start_frame + 1, a = 0; i <= efra - clip->start_frame + 1; i++) {
159 int framenr;
160 const int markersnr = generic_track_get_markersnr(active_track, active_plane_track);
161
162 while (a < markersnr) {
163 int marker_framenr = generic_track_get_marker_framenr(active_track, active_plane_track, a);
164
165 if (marker_framenr >= i) {
166 break;
167 }
168
169 if (a < markersnr - 1 &&
170 generic_track_get_marker_framenr(active_track, active_plane_track, a + 1) > i)
171 {
172 break;
173 }
174
175 a++;
176 }
177
178 a = min_ii(a, markersnr - 1);
179
180 if (generic_track_is_marker_enabled(active_track, active_plane_track, a)) {
181 framenr = generic_track_get_marker_framenr(active_track, active_plane_track, a);
182
183 if (framenr != i) {
184 immUniformColor4ub(128, 128, 0, 96);
185 }
186 else if (generic_track_is_marker_keyframed(active_track, active_plane_track, a)) {
187 immUniformColor4ub(255, 255, 0, 196);
188 }
189 else {
190 immUniformColor4ub(255, 255, 0, 96);
191 }
192
193 immRectf(pos,
194 (i - sfra + clip->start_frame - 1) * framelen,
195 0,
196 (i - sfra + clip->start_frame) * framelen,
197 4 * UI_SCALE_FAC);
198 }
199 }
200 }
201
202 /* failed frames */
203 if (reconstruction->flag & TRACKING_RECONSTRUCTED) {
204 int n = reconstruction->camnr;
205 MovieReconstructedCamera *cameras = reconstruction->cameras;
206
207 immUniformColor4ub(255, 0, 0, 96);
208
209 for (i = sfra, a = 0; i <= efra; i++) {
210 bool ok = false;
211
212 while (a < n) {
213 if (cameras[a].framenr == i) {
214 ok = true;
215 break;
216 }
217 if (cameras[a].framenr > i) {
218 break;
219 }
220
221 a++;
222 }
223
224 if (!ok) {
225 immRectf(pos,
226 (i - sfra + clip->start_frame - 1) * framelen,
227 0,
228 (i - sfra + clip->start_frame) * framelen,
229 8 * UI_SCALE_FAC);
230 }
231 }
232 }
233
235
236 /* current frame */
237 x = (sc->user.framenr - sfra) / (efra - sfra + 1) * region->winx;
238
240 immRectf(pos, x, 0, x + ceilf(framelen), 8 * UI_SCALE_FAC);
241
243
245 sc->user.framenr, x + roundf(framelen / 2), 8.0f * UI_SCALE_FAC);
246
247 pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
249
250 /* solver keyframes */
251 immUniformColor4ub(175, 255, 0, 255);
253 tracking_object->keyframe1 + clip->start_frame - 1, scene->r.cfra, sfra, framelen, 2, pos);
255 tracking_object->keyframe2 + clip->start_frame - 1, scene->r.cfra, sfra, framelen, 2, pos);
256
258
259 /* movie clip animation */
260 if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) {
261 ED_mask_draw_frames(sc->mask_info.mask, region, scene->r.cfra, sfra, efra);
262 }
263}
264
265static void draw_movieclip_notes(SpaceClip *sc, ARegion *region)
266{
268 MovieTracking *tracking = &clip->tracking;
269 char str[256] = {0};
270 bool full_redraw = false;
271
272 if (tracking->stats) {
273 STRNCPY_UTF8(str, tracking->stats->message);
274 full_redraw = true;
275 }
276 else {
277 if (sc->flag & SC_LOCK_SELECTION) {
278 STRNCPY_UTF8(str, "Locked");
279 }
280 }
281
282 if (str[0]) {
283 float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.6f};
284 ED_region_info_draw(region, str, fill_color, full_redraw);
285 }
286}
287
288static void draw_movieclip_muted(ARegion *region, int width, int height, float zoomx, float zoomy)
289{
290 int x, y;
291
292 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
294
295 /* find window pixel coordinates of origin */
296 ui::view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
297
298 immUniformColor3f(0.0f, 0.0f, 0.0f);
299 immRectf(pos, x, y, x + zoomx * width, y + zoomy * height);
300
302}
303
305 SpaceClip *sc,
306 ARegion *region,
307 const ImBuf *ibuf,
308 int width,
309 int height,
310 float zoomx,
311 float zoomy)
312{
314 bool use_filter = true;
315 int x, y;
316
317 /* find window pixel coordinates of origin */
318 ui::view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
319
320 /* checkerboard for case alpha */
321 if (ibuf->can_contain_alpha()) {
323
324 imm_draw_box_checker_2d(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y);
325 }
326
327 /* non-scaled proxy shouldn't use filtering */
328 if ((clip->flag & MCLIP_USE_PROXY) == 0 ||
330 {
331 use_filter = false;
332 }
333
334 ED_draw_imbuf_ctx(C, ibuf, x, y, use_filter, zoomx * width / ibuf->x, zoomy * height / ibuf->y);
335
336 if (ibuf->can_contain_alpha()) {
338 }
339
340 if (sc->flag & SC_SHOW_METADATA) {
341 rctf frame;
342 BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y);
344 x, y, ibuf, &frame, zoomx * width / ibuf->x, zoomy * height / ibuf->y);
345 }
346}
347
349 SpaceClip *sc, ARegion *region, int width, int height, float zoomx, float zoomy)
350{
351 int x, y;
353
354 /* find window pixel coordinates of origin */
355 ui::view2d_view_to_region(&region->v2d, 0.0f, 0.0f, &x, &y);
356
357 /* draw boundary border for frame if stabilization is enabled */
359 const uint shdr_pos = GPU_vertformat_attr_add(
360 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
361
362 /* Use invert blend mode for highly visible border */
364
367
368 GPU_matrix_scale_2f(zoomx, zoomy);
370
372
373 float viewport_size[4];
374 GPU_viewport_size_get_f(viewport_size);
376 "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
377
378 immUniform1i("colors_len", 0); /* "simple" mode */
379 immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f);
380 immUniform1f("dash_width", 6.0f);
381 immUniform1f("udash_factor", 0.5f);
382
383 imm_draw_box_wire_2d(shdr_pos, 0.0f, 0.0f, width, height);
384
386
388
390 }
391}
392
393enum {
395};
396
398 float co[2];
400};
401
403 const MovieTrackingTrack *track,
404 const MovieTrackingMarker *marker,
405 TrackPathPoint *point)
406{
407 add_v2_v2v2(point->co, marker->pos, track->offset);
408 ED_clip_point_undistorted_pos(sc, point->co, point->co);
409 point->flag = 0;
410 if ((marker->flag & MARKER_TRACKED) == 0) {
412 }
413}
414
416 MovieTrackingTrack *track,
417 int direction,
418 TrackPathPoint *path)
419{
420 const int count = sc->path_length;
421 int current_frame = ED_space_clip_get_clip_frame_number(sc);
422 const MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, current_frame);
423 /* Check whether there is marker at exact current frame.
424 * If not, we don't have anything to be put to path. */
425 if (marker == nullptr || (marker->flag & MARKER_DISABLED)) {
426 return 0;
427 }
428 /* Index inside of path array where we write data to. */
429 int point_index = count;
430 int path_length = 0;
431 for (int i = 0; i < count; ++i) {
432 marker_to_path_point(sc, track, marker, &path[point_index]);
433 /* Move to the next marker along the path segment. */
434 path_length++;
435 point_index += direction;
436 current_frame += direction;
437 marker = BKE_tracking_marker_get_exact(track, current_frame);
438 if (marker == nullptr || (marker->flag & MARKER_DISABLED)) {
439 /* Reached end of tracked segment. */
440 break;
441 }
442 }
443 return path_length;
444}
445
447 uint position_attribute,
448 const int start_point,
449 const int num_points)
450{
451 if (num_points == 0) {
452 return;
453 }
454 immBegin(GPU_PRIM_POINTS, num_points);
455 for (int i = 0; i < num_points; i++) {
456 const TrackPathPoint *point = &path[i + start_point];
457 immVertex2fv(position_attribute, point->co);
458 }
459 immEnd();
460}
461
463 uint position_attribute,
464 const int start_point,
465 const int num_points)
466{
467 immBeginAtMost(GPU_PRIM_POINTS, num_points);
468 for (int i = 0; i < num_points; i++) {
469 const TrackPathPoint *point = &path[i + start_point];
470 if (point->flag & PATH_POINT_FLAG_KEYFRAME) {
471 immVertex2fv(position_attribute, point->co);
472 }
473 }
474 immEnd();
475}
476
477static void draw_track_path_lines(const TrackPathPoint *path,
478 uint position_attribute,
479 const int start_point,
480 const int num_points)
481{
482 if (num_points < 2) {
483 return;
484 }
485 immBegin(GPU_PRIM_LINE_STRIP, num_points);
486 for (int i = 0; i < num_points; i++) {
487 const TrackPathPoint *point = &path[i + start_point];
488 immVertex2fv(position_attribute, point->co);
489 }
490 immEnd();
491}
492
493static void draw_track_path(SpaceClip *sc, MovieClip * /*clip*/, MovieTrackingTrack *track)
494{
495#define MAX_STATIC_PATH 64
496
497 const int count = sc->path_length;
498 TrackPathPoint path_static[(MAX_STATIC_PATH + 1) * 2];
499 TrackPathPoint *path;
500 const bool tiny = (sc->flag & SC_SHOW_TINY_MARKER) != 0;
501
502 if (count == 0) {
503 /* Early output, nothing to bother about here. */
504 return;
505 }
506
507 /* Try to use stack allocated memory when possibly, only use heap allocation
508 * for really long paths. */
509 path = (count < MAX_STATIC_PATH) ?
510 path_static :
511 MEM_new_array_zeroed<TrackPathPoint>(sizeof(*path) * (count + 1) * 2, "path");
512 /* Collect path information. */
513 const int num_points_before = track_to_path_segment(sc, track, -1, path);
514 const int num_points_after = track_to_path_segment(sc, track, 1, path);
515 if (num_points_before == 0 && num_points_after == 0) {
516 return;
517 }
518
519 int num_all_points = num_points_before + num_points_after;
520 /* If both leading and trailing parts of the path are there the center point is counted twice. */
521 if (num_points_before != 0 && num_points_after != 0) {
522 num_all_points -= 1;
523 }
524
525 const int path_start_index = count - num_points_before + 1;
526 const int path_center_index = count;
527
528 const uint position_attribute = GPU_vertformat_attr_add(
529 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
530
531 /* Draw path outline. */
532 if (!tiny) {
533 if (TRACK_VIEW_SELECTED(sc, track)) {
536 immUniform1f("size", 5.0f);
537 draw_track_path_points(path, position_attribute, path_start_index, num_all_points);
538 immUniform1f("size", 7.0f);
539 draw_track_path_keyframe_points(path, position_attribute, path_start_index, num_all_points);
541 }
542 /* Draw darker outline for actual path, all line segments at once. */
543 GPU_line_width(3.0f);
546 draw_track_path_lines(path, position_attribute, path_start_index, num_all_points);
548 }
549
550 /* Draw all points. */
553 immUniform1f("size", 3.0f);
554 draw_track_path_points(path, position_attribute, path_start_index, num_points_before);
556 draw_track_path_points(path, position_attribute, path_center_index, num_points_after);
558
559 /* Connect points with color coded segments. */
560 GPU_line_width(1.0f);
563 draw_track_path_lines(path, position_attribute, path_start_index, num_points_before);
565 draw_track_path_lines(path, position_attribute, path_center_index, num_points_after);
567
568 /* Draw all bigger points corresponding to keyframes. */
571 immUniform1f("size", 5.0f);
572 draw_track_path_keyframe_points(path, position_attribute, path_start_index, num_points_before);
574 draw_track_path_keyframe_points(path, position_attribute, path_center_index, num_points_after);
576
577 if (path != path_static) {
578 MEM_delete(path);
579 }
580
581#undef MAX_STATIC_PATH
582}
583
585 const MovieTrackingTrack *track,
586 const MovieTrackingMarker *marker,
587 const float marker_pos[2],
588 int width,
589 int height,
591{
592 int tiny = sc->flag & SC_SHOW_TINY_MARKER;
593 bool show_search = false;
594 float px[2];
595
596 px[0] = 1.0f / width / sc->zoom;
597 px[1] = 1.0f / height / sc->zoom;
598
599 if ((marker->flag & MARKER_DISABLED) == 0) {
600 float pos[2];
601 float p[2];
602
603 add_v2_v2v2(pos, marker->pos, track->offset);
604
605 ED_clip_point_undistorted_pos(sc, pos, pos);
606
607 sub_v2_v2v2(p, pos, marker_pos);
608
610 marker->pattern_corners[0],
611 marker->pattern_corners[1],
612 marker->pattern_corners[2],
613 marker->pattern_corners[3]))
614 {
616 immUniform1f("size", tiny ? 3.0f : 4.0f);
619 immVertex2f(position, pos[0], pos[1]);
620 immEnd();
622 }
623 else {
624 GPU_line_width(tiny ? 1.0f : 3.0f);
628
629 immVertex2f(position, pos[0] + px[0] * 2, pos[1]);
630 immVertex2f(position, pos[0] + px[0] * 8, pos[1]);
631
632 immVertex2f(position, pos[0] - px[0] * 2, pos[1]);
633 immVertex2f(position, pos[0] - px[0] * 8, pos[1]);
634
635 immVertex2f(position, pos[0], pos[1] - px[1] * 2);
636 immVertex2f(position, pos[0], pos[1] - px[1] * 8);
637
638 immVertex2f(position, pos[0], pos[1] + px[1] * 2);
639 immVertex2f(position, pos[0], pos[1] + px[1] * 8);
640
641 immEnd();
643 }
644 }
645
646 /* pattern and search outline */
647 GPU_line_width(tiny ? 1.0f : 3.0f);
650
652 GPU_matrix_translate_2fv(marker_pos);
653
654 if (sc->flag & SC_SHOW_MARKER_PATTERN) {
660 immEnd();
661 }
662
663 show_search = (TRACK_VIEW_SELECTED(sc, track) && ((marker->flag & MARKER_DISABLED) == 0 ||
664 (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) !=
665 0;
666
667 if (sc->flag & SC_SHOW_MARKER_SEARCH && show_search) {
669 marker->search_min[0],
670 marker->search_min[1],
671 marker->search_max[0],
672 marker->search_max[1]);
673 }
674
677}
678
679static void track_colors(const MovieTrackingTrack *track, int act, float r_col[3], float r_scol[3])
680{
681 if (track->flag & TRACK_CUSTOMCOLOR) {
682 if (act) {
684 }
685 else {
686 copy_v3_v3(r_scol, track->color);
687 }
688
689 mul_v3_v3fl(r_col, track->color, 0.5f);
690 }
691 else {
693
694 if (act) {
696 }
697 else {
699 }
700 }
701}
702
704 const MovieTrackingMarker *marker,
705 const bool is_track_active,
706 const bool is_area_selected,
707 const float color[3],
708 const float selected_color[3])
709{
710 if (track->flag & TRACK_LOCKED) {
711 if (is_track_active) {
713 }
714 else if (is_area_selected) {
716 }
717 else {
719 }
720 }
721 else if (marker->flag & MARKER_DISABLED) {
722 if (is_track_active) {
724 }
725 else if (is_area_selected) {
727 }
728 else {
730 }
731 }
732 else {
733 immUniformColor3fv(is_area_selected ? selected_color : color);
734 }
735}
736
738 const MovieTrackingTrack *track,
739 const MovieTrackingMarker *marker,
740 const float marker_pos[2],
741 int width,
742 int height,
743 int act,
744 int sel,
745 const uint shdr_pos)
746{
747 int tiny = sc->flag & SC_SHOW_TINY_MARKER;
748 bool show_search = false;
749 float col[3], scol[3];
751 float px[2];
752
753 track_colors(track, act, col, scol);
754
755 px[0] = 1.0f / width / sc->zoom;
756 px[1] = 1.0f / height / sc->zoom;
757
758 float viewport[4];
759 GPU_viewport_size_get_f(viewport);
760
761 /* marker position and offset position */
762 if ((track->flag & SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) {
763 float pos[2], p[2];
764
765 if (track->flag & TRACK_LOCKED) {
766 if (act) {
768 }
769 else if (track->flag & SELECT) {
771 }
772 else {
774 }
775 }
776 else {
777 if (bool(track->flag & SELECT)) {
778 color = float4(float3(scol), 1.0);
779 }
780 else {
781 color = float4(float3(col), 1.0);
782 }
783 }
784
785 add_v2_v2v2(pos, marker->pos, track->offset);
786 ED_clip_point_undistorted_pos(sc, pos, pos);
787
788 sub_v2_v2v2(p, pos, marker_pos);
789
791 marker->pattern_corners[0],
792 marker->pattern_corners[1],
793 marker->pattern_corners[2],
794 marker->pattern_corners[3]))
795 {
798 immUniform1f("size", tiny ? 1.0f : 2.0f);
800 immVertex2f(shdr_pos, pos[0], pos[1]);
801 immEnd();
803 }
804 else {
806 immUniform2f("viewport_size", viewport[2] / UI_SCALE_FAC, viewport[3] / UI_SCALE_FAC);
807 immUniform1i("colors_len", 0);
809 immUniform1f("udash_factor", 2.0f); /* Solid line */
810
812
813 immVertex2f(shdr_pos, pos[0] + px[0] * 3, pos[1]);
814 immVertex2f(shdr_pos, pos[0] + px[0] * 7, pos[1]);
815
816 immVertex2f(shdr_pos, pos[0] - px[0] * 3, pos[1]);
817 immVertex2f(shdr_pos, pos[0] - px[0] * 7, pos[1]);
818
819 immVertex2f(shdr_pos, pos[0], pos[1] - px[1] * 3);
820 immVertex2f(shdr_pos, pos[0], pos[1] - px[1] * 7);
821
822 immVertex2f(shdr_pos, pos[0], pos[1] + px[1] * 3);
823 immVertex2f(shdr_pos, pos[0], pos[1] + px[1] * 7);
824
825 immEnd();
826
827 immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f);
828 immUniform1f("dash_width", 6.0f);
829 immUniform1f("udash_factor", 0.5f);
830
831 /* Use invert blend mode for highly visible border */
833
835 immVertex2fv(shdr_pos, pos);
836 immVertex2fv(shdr_pos, marker_pos);
837 immEnd();
838
841 }
842 }
843
844 /* pattern */
846 GPU_matrix_translate_2fv(marker_pos);
847
849 immUniform2f("viewport_size", viewport[2] / UI_SCALE_FAC, viewport[3] / UI_SCALE_FAC);
850 immUniform1i("colors_len", 0);
851 set_draw_marker_area_color(track, marker, act, track->pat_flag & SELECT, col, scol);
852 if (tiny) {
853 immUniform1f("dash_width", 6.0f);
854 immUniform1f("udash_factor", 0.5f);
855 }
856 else {
857 immUniform1f("udash_factor", 2.0f); /* Solid line */
858 }
859
860 if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
862 immVertex2fv(shdr_pos, marker->pattern_corners[0]);
863 immVertex2fv(shdr_pos, marker->pattern_corners[1]);
864 immVertex2fv(shdr_pos, marker->pattern_corners[2]);
865 immVertex2fv(shdr_pos, marker->pattern_corners[3]);
866 immEnd();
867 }
868
869 /* search */
870 show_search = (TRACK_VIEW_SELECTED(sc, track) && ((marker->flag & MARKER_DISABLED) == 0 ||
871 (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) !=
872 0;
873
874 if ((track->search_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_SEARCH) && show_search) {
875 set_draw_marker_area_color(track, marker, act, track->search_flag & SELECT, col, scol);
876
877 imm_draw_box_wire_2d(shdr_pos,
878 marker->search_min[0],
879 marker->search_min[1],
880 marker->search_max[0],
881 marker->search_max[1]);
882 }
883
885
887 const uint pos = GPU_vertformat_attr_add(
888 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
889 BLI_assert(pos == shdr_pos);
891}
892
894{
895 float len_sq = FLT_MAX;
896
897 for (int i = 0; i < 4; i++) {
898 int next = (i + 1) % 4;
899 float cur_len = len_squared_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]);
900 len_sq = min_ff(cur_len, len_sq);
901 }
902
903 return sqrtf(len_sq);
904}
905
907 float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
908{
909 float tdx, tdy;
910
911 tdx = dx;
912 tdy = dy;
913
914 if (outline) {
915 tdx += px[0];
916 tdy += px[1];
917 }
918
919 immRectf(pos, x - tdx, y - tdy, x + tdx, y + tdy);
920}
921
923 float x, float y, float dx, float dy, int outline, const float px[2], uint pos)
924{
925 float tdx, tdy;
926
927 tdx = dx * 2.0f;
928 tdy = dy * 2.0f;
929
930 if (outline) {
931 tdx += px[0];
932 tdy += px[1];
933 }
934
936 immVertex2f(pos, x, y);
937 immVertex2f(pos, x - tdx, y);
938 immVertex2f(pos, x, y + tdy);
939 immEnd();
940}
941
943 const MovieTrackingTrack *track,
944 const MovieTrackingMarker *marker,
945 const float marker_pos[2],
946 int outline,
947 int sel,
948 int act,
949 int width,
950 int height,
951 uint pos)
952{
953 float dx, dy, patdx, patdy, searchdx, searchdy;
954 int tiny = sc->flag & SC_SHOW_TINY_MARKER;
955 float col[3], scol[3], px[2], side;
956
957 if ((tiny && outline) || (marker->flag & MARKER_DISABLED)) {
958 return;
959 }
960
961 if (!TRACK_VIEW_SELECTED(sc, track) || track->flag & TRACK_LOCKED) {
962 return;
963 }
964
966
967 track_colors(track, act, col, scol);
968
969 if (outline) {
971 }
972
974 GPU_matrix_translate_2fv(marker_pos);
975
976 dx = 6.0f / width / sc->zoom;
977 dy = 6.0f / height / sc->zoom;
978
979 side = get_shortest_pattern_side(marker);
980 patdx = min_ff(dx * 2.0f / 3.0f, side / 6.0f) * UI_SCALE_FAC;
981 patdy = min_ff(dy * 2.0f / 3.0f, side * width / height / 6.0f) * UI_SCALE_FAC;
982
983 searchdx = min_ff(dx, (marker->search_max[0] - marker->search_min[0]) / 6.0f) * UI_SCALE_FAC;
984 searchdy = min_ff(dy, (marker->search_max[1] - marker->search_min[1]) / 6.0f) * UI_SCALE_FAC;
985
986 px[0] = 1.0f / sc->zoom / width / sc->scale;
987 px[1] = 1.0f / sc->zoom / height / sc->scale;
988
989 if ((sc->flag & SC_SHOW_MARKER_SEARCH) && ((track->search_flag & SELECT) == sel || outline)) {
990 if (!outline) {
991 immUniformColor3fv((track->search_flag & SELECT) ? scol : col);
992 }
993
994 /* search offset square */
996 marker->search_min[0], marker->search_max[1], searchdx, searchdy, outline, px, pos);
997
998 /* search re-sizing triangle */
1000 marker->search_max[0], marker->search_min[1], searchdx, searchdy, outline, px, pos);
1001 }
1002
1003 if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) {
1004 float pat_min[2], pat_max[2];
1005 // float dx = 12.0f / width, dy = 12.0f / height; /*UNUSED*/
1006 float tilt_ctrl[2];
1007
1008 if (!outline) {
1009 immUniformColor3fv((track->pat_flag & SELECT) ? scol : col);
1010 }
1011
1012 /* pattern's corners sliding squares */
1013 for (int i = 0; i < 4; i++) {
1015 marker->pattern_corners[i][1],
1016 patdx / 1.5f,
1017 patdy / 1.5f,
1018 outline,
1019 px,
1020 pos);
1021 }
1022
1023 /* ** sliders to control overall pattern ** */
1024 add_v2_v2v2(tilt_ctrl, marker->pattern_corners[1], marker->pattern_corners[2]);
1025
1026 BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1027
1028 GPU_line_width(outline ? 3.0f : 1.0f);
1029
1031 immVertex2f(pos, 0.0f, 0.0f);
1032 immVertex2fv(pos, tilt_ctrl);
1033 immEnd();
1034
1035 /* slider to control pattern tilt */
1036 draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px, pos);
1037 }
1038
1041}
1042
1044 const MovieTrackingTrack *track,
1045 const MovieTrackingMarker *marker,
1046 const float marker_pos[2],
1047 int act,
1048 int width,
1049 int height,
1050 float zoomx,
1051 float zoomy)
1052{
1053 char str[128] = {0}, state[64] = {0};
1054 float dx = 0.0f, dy = 0.0f, fontsize, pos[3];
1055 uiStyle *style = U.uistyles.first();
1056 int fontid = style->widget.uifont_id;
1057
1058 if (!TRACK_VIEW_SELECTED(sc, track)) {
1059 return;
1060 }
1061
1062 BLF_size(fontid, 11.0f * UI_SCALE_FAC);
1063 fontsize = BLF_height_max(fontid);
1064
1065 if (marker->flag & MARKER_DISABLED) {
1066 if (act) {
1068 }
1069 else {
1070 uchar color[4];
1072 BLF_color4ubv(fontid, color);
1073 }
1074 }
1075 else {
1077 }
1078
1079 if ((sc->flag & SC_SHOW_MARKER_SEARCH) &&
1080 ((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0))
1081 {
1082 dx = marker->search_min[0];
1083 dy = marker->search_min[1];
1084 }
1085 else if (sc->flag & SC_SHOW_MARKER_PATTERN) {
1086 float pat_min[2], pat_max[2];
1087
1088 BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1089 dx = pat_min[0];
1090 dy = pat_min[1];
1091 }
1092
1093 pos[0] = (marker_pos[0] + dx) * width;
1094 pos[1] = (marker_pos[1] + dy) * height;
1095 pos[2] = 0.0f;
1096
1097 mul_m4_v3(sc->stabmat, pos);
1098
1099 pos[0] = pos[0] * zoomx;
1100 pos[1] = pos[1] * zoomy - fontsize;
1101
1102 if (marker->flag & MARKER_DISABLED) {
1103 STRNCPY_UTF8(state, "disabled");
1104 }
1105 else if (marker->framenr != ED_space_clip_get_clip_frame_number(sc)) {
1106 STRNCPY_UTF8(state, "estimated");
1107 }
1108 else if (marker->flag & MARKER_TRACKED) {
1109 STRNCPY_UTF8(state, "tracked");
1110 }
1111 else {
1112 STRNCPY_UTF8(state, "keyframed");
1113 }
1114
1115 if (state[0]) {
1116 SNPRINTF_UTF8(str, "%s: %s", track->name, state);
1117 }
1118 else {
1119 STRNCPY_UTF8(str, track->name);
1120 }
1121
1122 BLF_position(fontid, pos[0], pos[1], 0.0f);
1123 BLF_draw(fontid, str, sizeof(str));
1124 pos[1] -= fontsize;
1125
1126 if (track->flag & TRACK_HAS_BUNDLE) {
1127 SNPRINTF_UTF8(str, "Average error: %.2f px", track->error);
1128 BLF_position(fontid, pos[0], pos[1], 0.0f);
1129 BLF_draw(fontid, str, sizeof(str));
1130 pos[1] -= fontsize;
1131 }
1132
1133 if (track->flag & TRACK_LOCKED) {
1134 BLF_position(fontid, pos[0], pos[1], 0.0f);
1135 BLF_draw(fontid, "locked", 6);
1136 }
1137}
1138
1139static void plane_track_colors(bool is_active, float r_color[3], float r_selected_color[3])
1140{
1142
1143 ui::theme::get_color_3fv(is_active ? TH_ACT_MARKER : TH_SEL_MARKER, r_selected_color);
1144}
1145
1146static void getArrowEndPoint(const int width,
1147 const int height,
1148 const float zoom,
1149 const float start_corner[2],
1150 const float end_corner[2],
1151 float end_point[2])
1152{
1153 float direction[2];
1154 float max_length;
1155
1156 sub_v2_v2v2(direction, end_corner, start_corner);
1157
1158 direction[0] *= width;
1159 direction[1] *= height;
1160 max_length = normalize_v2(direction);
1161 mul_v2_fl(direction, min_ff(32.0f / zoom, max_length));
1162 direction[0] /= width;
1163 direction[1] /= height;
1164
1165 add_v2_v2v2(end_point, start_corner, direction);
1166}
1167
1168static void homogeneous_2d_to_gl_matrix(/*const*/ float matrix[3][3], float gl_matrix[4][4])
1169{
1170 gl_matrix[0][0] = matrix[0][0];
1171 gl_matrix[0][1] = matrix[0][1];
1172 gl_matrix[0][2] = 0.0f;
1173 gl_matrix[0][3] = matrix[0][2];
1174
1175 gl_matrix[1][0] = matrix[1][0];
1176 gl_matrix[1][1] = matrix[1][1];
1177 gl_matrix[1][2] = 0.0f;
1178 gl_matrix[1][3] = matrix[1][2];
1179
1180 gl_matrix[2][0] = 0.0f;
1181 gl_matrix[2][1] = 0.0f;
1182 gl_matrix[2][2] = 1.0f;
1183 gl_matrix[2][3] = 0.0f;
1184
1185 gl_matrix[3][0] = matrix[2][0];
1186 gl_matrix[3][1] = matrix[2][1];
1187 gl_matrix[3][2] = 0.0f;
1188 gl_matrix[3][3] = matrix[2][2];
1189}
1190
1192 MovieTrackingPlaneTrack *plane_track,
1193 MovieTrackingPlaneMarker *plane_marker)
1194{
1195 Image *image = plane_track->image;
1196 if (image == nullptr) {
1197 return;
1198 }
1199
1200 void *lock;
1201 ImBuf *ibuf = BKE_image_acquire_ibuf(image, nullptr, &lock);
1202
1203 if (ibuf) {
1204 GPUVertFormat *imm_format = immVertexFormat();
1205 uint pos = GPU_vertformat_attr_add(imm_format, "pos", gpu::VertAttrType::SFLOAT_32_32_32);
1206 uint texCoord = GPU_vertformat_attr_add(
1207 imm_format, "texCoord", gpu::VertAttrType::SFLOAT_32_32);
1208
1209 const ColorSpace *colorspace = ibuf->float_data() ? ibuf->float_buffer.colorspace :
1210 ibuf->byte_buffer.colorspace;
1211 const bool predivide = IMB_alpha_affects_rgb(ibuf);
1213 &scene->display_settings,
1214 colorspace,
1215 ibuf->dither,
1216 predivide,
1217 false,
1219 plane_track->image_opacity))
1220 {
1221 const void *texture_data = nullptr;
1223 eGPUDataFormat data_format = GPU_DATA_FLOAT;
1224 if (ibuf->float_data()) {
1225 data_format = GPU_DATA_FLOAT;
1226 if (ibuf->channels == 4) {
1227 texture_format = gpu::TextureFormat::SFLOAT_16_16_16_16;
1228 }
1229 else if (ibuf->channels == 3) {
1230 texture_format = gpu::TextureFormat::SFLOAT_16_16_16;
1231 }
1232 else if (ibuf->channels == 1) {
1233 texture_format = gpu::TextureFormat::SFLOAT_16;
1234 }
1235 texture_data = ibuf->float_data();
1236 }
1237 else {
1238 data_format = GPU_DATA_UBYTE;
1239 texture_format = gpu::TextureFormat::UNORM_8_8_8_8;
1240 texture_data = ibuf->byte_data();
1241 }
1242
1243 float frame_corners[4][2] = {{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}};
1244 float perspective_matrix[3][3];
1245 float gl_matrix[4][4];
1246 bool transparent = false;
1248 frame_corners, plane_marker->corners, perspective_matrix);
1249
1250 homogeneous_2d_to_gl_matrix(perspective_matrix, gl_matrix);
1251
1252 if (plane_track->image_opacity != 1.0f || ibuf->can_contain_alpha()) {
1253 transparent = true;
1255 }
1256
1257 gpu::Texture *texture = GPU_texture_create_2d("plane_marker_image",
1258 ibuf->x,
1259 ibuf->y,
1260 1,
1261 texture_format,
1263 nullptr);
1264 GPU_texture_update(texture, data_format, texture_data);
1267
1269 GPU_matrix_mul(gl_matrix);
1270
1272
1273 immAttr2f(texCoord, 0.0f, 0.0f);
1274 immVertex3f(pos, 0.0f, 0.0f, 0.0f);
1275
1276 immAttr2f(texCoord, 1.0f, 0.0f);
1277 immVertex3f(pos, 1.0f, 0.0f, 0.0f);
1278
1279 immAttr2f(texCoord, 1.0f, 1.0f);
1280 immVertex3f(pos, 1.0f, 1.0f, 0.0f);
1281
1282 immAttr2f(texCoord, 0.0f, 1.0f);
1283 immVertex3f(pos, 0.0f, 1.0f, 0.0f);
1284
1285 immEnd();
1286
1288
1291
1292 if (transparent) {
1294 }
1295 }
1296
1298 }
1299
1301}
1302
1304 Scene *scene,
1305 MovieTrackingPlaneTrack *plane_track,
1306 MovieTrackingPlaneMarker *plane_marker,
1307 bool is_active_track,
1308 bool draw_outline,
1309 int width,
1310 int height)
1311{
1312 bool tiny = (sc->flag & SC_SHOW_TINY_MARKER) != 0;
1313 bool is_selected_track = (plane_track->flag & SELECT) != 0;
1314 const bool has_image = plane_track->image != nullptr &&
1315 BKE_image_has_ibuf(plane_track->image, nullptr);
1316 const bool draw_plane_quad = !has_image || plane_track->image_opacity == 0.0f;
1317 float px[2];
1318 float color[3], selected_color[3];
1319
1320 px[0] = 1.0f / width / sc->zoom;
1321 px[1] = 1.0f / height / sc->zoom;
1322
1323 /* Draw image */
1324 if (draw_outline == false) {
1325 draw_plane_marker_image(scene, plane_track, plane_marker);
1326 }
1327
1328 if (draw_plane_quad || is_selected_track) {
1329 const uint shdr_pos = GPU_vertformat_attr_add(
1330 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
1331
1333
1334 float viewport_size[4];
1335 GPU_viewport_size_get_f(viewport_size);
1337 "viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
1338
1339 immUniform1i("colors_len", 0); /* "simple" mode */
1340
1341 if (is_selected_track) {
1342 plane_track_colors(is_active_track, color, selected_color);
1343 }
1344
1345 if (draw_plane_quad) {
1346 const bool stipple = !draw_outline && tiny;
1347 const bool thick = draw_outline && !tiny;
1348
1349 GPU_line_width(thick ? 3.0f : 1.0f);
1350
1351 if (stipple) {
1352 immUniform1f("dash_width", 6.0f);
1353 immUniform1f("udash_factor", 0.5f);
1354 }
1355 else {
1356 immUniform1f("udash_factor", 2.0f); /* Solid line */
1357 }
1358
1359 if (draw_outline) {
1361 }
1362 else {
1363 immUniformColor3fv(is_selected_track ? selected_color : color);
1364 }
1365
1366 /* Draw rectangle itself. */
1368 immVertex2fv(shdr_pos, plane_marker->corners[0]);
1369 immVertex2fv(shdr_pos, plane_marker->corners[1]);
1370 immVertex2fv(shdr_pos, plane_marker->corners[2]);
1371 immVertex2fv(shdr_pos, plane_marker->corners[3]);
1372 immEnd();
1373
1374 /* Draw axis. */
1375 if (!draw_outline) {
1376 float end_point[2];
1377
1378 immUniformColor3f(1.0f, 0.0f, 0.0f);
1379
1381
1382 getArrowEndPoint(width,
1383 height,
1384 sc->zoom,
1385 plane_marker->corners[0],
1386 plane_marker->corners[1],
1387 end_point);
1388 immVertex2fv(shdr_pos, plane_marker->corners[0]);
1389 immVertex2fv(shdr_pos, end_point);
1390
1391 immEnd();
1392
1393 immUniformColor3f(0.0f, 1.0f, 0.0f);
1394
1396
1397 getArrowEndPoint(width,
1398 height,
1399 sc->zoom,
1400 plane_marker->corners[0],
1401 plane_marker->corners[3],
1402 end_point);
1403 immVertex2fv(shdr_pos, plane_marker->corners[0]);
1404 immVertex2fv(shdr_pos, end_point);
1405
1406 immEnd();
1407 }
1408 }
1410
1411 /* Draw sliders. */
1412 if (is_selected_track) {
1414
1415 if (draw_outline) {
1417 }
1418 else {
1419 immUniformColor3fv(selected_color);
1420 }
1421
1422 for (int i = 0; i < 4; i++) {
1423 draw_marker_slide_square(plane_marker->corners[i][0],
1424 plane_marker->corners[i][1],
1425 3.0f * px[0],
1426 3.0f * px[1],
1427 draw_outline,
1428 px,
1429 shdr_pos);
1430 }
1432 }
1433 }
1434}
1435
1437 Scene *scene,
1438 MovieTrackingPlaneTrack *plane_track,
1439 MovieTrackingPlaneMarker *plane_marker,
1440 int width,
1441 int height)
1442{
1443 draw_plane_marker_ex(sc, scene, plane_track, plane_marker, false, true, width, height);
1444}
1445
1447 Scene *scene,
1448 MovieTrackingPlaneTrack *plane_track,
1449 MovieTrackingPlaneMarker *plane_marker,
1450 bool is_active_track,
1451 int width,
1452 int height)
1453{
1455 sc, scene, plane_track, plane_marker, is_active_track, false, width, height);
1456}
1457
1459 Scene *scene,
1460 MovieTrackingPlaneTrack *plane_track,
1461 int framenr,
1462 bool is_active_track,
1463 int width,
1464 int height)
1465{
1466 MovieTrackingPlaneMarker *plane_marker;
1467
1468 plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr);
1469
1470 draw_plane_marker_outline(sc, scene, plane_track, plane_marker, width, height);
1471 draw_plane_marker(sc, scene, plane_track, plane_marker, is_active_track, width, height);
1472}
1473
1474/* Draw all kind of tracks. */
1476 Scene *scene,
1477 ARegion *region,
1478 MovieClip *clip,
1479 int width,
1480 int height,
1481 float zoomx,
1482 float zoomy)
1483{
1484 float x, y;
1485 /*const*/ MovieTracking *tracking = &clip->tracking;
1486 /*const*/ MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
1487 /*const*/ MovieTrackingTrack *active_track = tracking_object->active_track;
1488 /*const*/ MovieTrackingPlaneTrack *active_plane_track = tracking_object->active_plane_track;
1489 const int framenr = ED_space_clip_get_clip_frame_number(sc);
1490 const int undistort = sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
1491 float *marker_pos = nullptr, *fp, *active_pos = nullptr, cur_pos[2];
1492
1493 /* ** find window pixel coordinates of origin ** */
1494
1495 /* #ui::view2d_view_to_region_no_clip return integer values, this could
1496 * lead to 1px flickering when view is locked to selection during playback.
1497 * to avoid this flickering, calculate base point in the same way as it happens
1498 * in #ui::view2d_view_to_region_no_clip, but do it in floats here. */
1499
1500 ui::view2d_view_to_region_fl(&region->v2d, 0.0f, 0.0f, &x, &y);
1501
1504
1506 GPU_matrix_scale_2f(zoomx, zoomy);
1508 GPU_matrix_scale_2f(width, height);
1509
1510 /* Draw plane tracks */
1511 for (MovieTrackingPlaneTrack &plane_track : tracking_object->plane_tracks) {
1512 if ((plane_track.flag & PLANE_TRACK_HIDDEN) == 0) {
1514 sc, scene, &plane_track, framenr, &plane_track == active_plane_track, width, height);
1515 }
1516 }
1517
1519 int count = 0;
1520
1521 /* count */
1522 for (MovieTrackingTrack &track : tracking_object->tracks) {
1523 if (track.flag & TRACK_HIDDEN) {
1524 continue;
1525 }
1526
1527 const MovieTrackingMarker *marker = BKE_tracking_marker_get(&track, framenr);
1528
1529 if (ED_space_clip_marker_is_visible(sc, tracking_object, &track, marker)) {
1530 count++;
1531 }
1532 }
1533
1534 /* undistort */
1535 if (count) {
1536 marker_pos = MEM_new_array_zeroed<float>(2 * count, "draw_tracking_tracks marker_pos");
1537
1538 fp = marker_pos;
1539 for (MovieTrackingTrack &track : tracking_object->tracks) {
1540 if (track.flag & TRACK_HIDDEN) {
1541 continue;
1542 }
1543
1544 const MovieTrackingMarker *marker = BKE_tracking_marker_get(&track, framenr);
1545
1546 if (ED_space_clip_marker_is_visible(sc, tracking_object, &track, marker)) {
1547 ED_clip_point_undistorted_pos(sc, marker->pos, fp);
1548
1549 if (&track == active_track) {
1550 active_pos = fp;
1551 }
1552
1553 fp += 2;
1554 }
1555 }
1556 }
1557 }
1558
1559 if (sc->flag & SC_SHOW_TRACK_PATH) {
1560 for (MovieTrackingTrack &track : tracking_object->tracks) {
1561 if ((track.flag & TRACK_HIDDEN) == 0) {
1562 draw_track_path(sc, clip, &track);
1563 }
1564 }
1565 }
1566
1568 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
1569
1570 /* markers outline and non-selected areas */
1571 fp = marker_pos;
1572 for (MovieTrackingTrack &track : tracking_object->tracks) {
1573 if (track.flag & TRACK_HIDDEN) {
1574 continue;
1575 }
1576
1577 const MovieTrackingMarker *marker = BKE_tracking_marker_get(&track, framenr);
1578
1579 if (ED_space_clip_marker_is_visible(sc, tracking_object, &track, marker)) {
1580 copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1581
1582 draw_marker_outline(sc, &track, marker, cur_pos, width, height, position);
1583 draw_marker_areas(sc, &track, marker, cur_pos, width, height, 0, 0, position);
1584 draw_marker_slide_zones(sc, &track, marker, cur_pos, 1, 0, 0, width, height, position);
1585 draw_marker_slide_zones(sc, &track, marker, cur_pos, 0, 0, 0, width, height, position);
1586
1587 if (fp) {
1588 fp += 2;
1589 }
1590 }
1591 }
1592
1593 /* selected areas only, so selection wouldn't be overlapped by non-selected areas */
1594 fp = marker_pos;
1595 for (MovieTrackingTrack &track : tracking_object->tracks) {
1596 if (track.flag & TRACK_HIDDEN) {
1597 continue;
1598 }
1599 const int act = &track == active_track;
1600 const MovieTrackingMarker *marker = BKE_tracking_marker_get(&track, framenr);
1601
1602 if (ED_space_clip_marker_is_visible(sc, tracking_object, &track, marker)) {
1603 if (!act) {
1604 copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1605
1606 draw_marker_areas(sc, &track, marker, cur_pos, width, height, 0, 1, position);
1607 draw_marker_slide_zones(sc, &track, marker, cur_pos, 0, 1, 0, width, height, position);
1608 }
1609
1610 if (fp) {
1611 fp += 2;
1612 }
1613 }
1614 }
1615
1616 /* active marker would be displayed on top of everything else */
1617 if (active_track && (active_track->flag & TRACK_HIDDEN) == 0) {
1618 const MovieTrackingMarker *marker = BKE_tracking_marker_get(active_track, framenr);
1619
1620 if (ED_space_clip_marker_is_visible(sc, tracking_object, active_track, marker)) {
1621 copy_v2_v2(cur_pos, active_pos ? active_pos : marker->pos);
1622
1623 draw_marker_areas(sc, active_track, marker, cur_pos, width, height, 1, 1, position);
1624 draw_marker_slide_zones(sc, active_track, marker, cur_pos, 0, 1, 1, width, height, position);
1625 }
1626 }
1627
1628 if (sc->flag & SC_SHOW_BUNDLES) {
1629 float pos[4], vec[4], mat[4][4], aspy;
1630
1631 aspy = 1.0f / clip->tracking.camera.pixel_aspect;
1632 BKE_tracking_get_projection_matrix(tracking, tracking_object, framenr, width, height, mat);
1633
1635 immUniform1f("size", 3.0f);
1636 for (MovieTrackingTrack &track : tracking_object->tracks) {
1637 if (track.flag & TRACK_HIDDEN || (track.flag & TRACK_HAS_BUNDLE) == 0) {
1638 continue;
1639 }
1640
1641 const MovieTrackingMarker *marker = BKE_tracking_marker_get(&track, framenr);
1642
1643 if (ED_space_clip_marker_is_visible(sc, tracking_object, &track, marker)) {
1644 float npos[2];
1645 copy_v3_v3(vec, track.bundle_pos);
1646 vec[3] = 1;
1647
1648 mul_v4_m4v4(pos, mat, vec);
1649
1650 pos[0] = (pos[0] / (pos[3] * 2.0f) + 0.5f) * width;
1651 pos[1] = (pos[1] / (pos[3] * 2.0f) + 0.5f) * height * aspy;
1652
1653 BKE_tracking_distort_v2(tracking, width, height, pos, npos);
1654
1655 if (npos[0] >= 0.0f && npos[1] >= 0.0f && npos[0] <= width && npos[1] <= height * aspy) {
1656 vec[0] = (marker->pos[0] + track.offset[0]) * width;
1657 vec[1] = (marker->pos[1] + track.offset[1]) * height * aspy;
1658
1659 sub_v2_v2(vec, npos);
1660
1661 immUniformColor4fv((len_squared_v2(vec) < (3.0f * 3.0f)) ?
1662 float4(0.0f, 1.0f, 0.0f, 1.0f) :
1663 float4(1.0f, 0.0f, 0.0f, 1.0f));
1664
1666
1667 if (undistort) {
1668 immVertex2f(position, pos[0] / width, pos[1] / (height * aspy));
1669 }
1670 else {
1671 immVertex2f(position, npos[0] / width, npos[1] / (height * aspy));
1672 }
1673
1674 immEnd();
1675 }
1676 }
1677 }
1679 }
1680
1682
1683 if (sc->flag & SC_SHOW_NAMES) {
1684 /* scaling should be cleared before drawing texts, otherwise font would also be scaled */
1685 fp = marker_pos;
1686 for (MovieTrackingTrack &track : tracking_object->tracks) {
1687 if (track.flag & TRACK_HIDDEN) {
1688 continue;
1689 }
1690
1691 const MovieTrackingMarker *marker = BKE_tracking_marker_get(&track, framenr);
1692
1693 if (ED_space_clip_marker_is_visible(sc, tracking_object, &track, marker)) {
1694 const int act = &track == active_track;
1695
1696 copy_v2_v2(cur_pos, fp ? fp : marker->pos);
1697
1698 draw_marker_texts(sc, &track, marker, cur_pos, act, width, height, zoomx, zoomy);
1699
1700 if (fp) {
1701 fp += 2;
1702 }
1703 }
1704 }
1705 }
1706
1708
1709 if (marker_pos) {
1710 MEM_delete(marker_pos);
1711 }
1712}
1713
1715 ARegion *region,
1716 MovieClip *clip,
1717 int width,
1718 int height,
1719 float zoomx,
1720 float zoomy)
1721{
1722 float x, y;
1723 const int n = 10;
1724 float tpos[2], grid[11][11][2];
1725 MovieTracking *tracking = &clip->tracking;
1726 bGPdata *gpd = nullptr;
1727 float aspy = 1.0f / tracking->camera.pixel_aspect;
1728 float dx = float(width) / n, dy = float(height) / n * aspy;
1729 float offsx = 0.0f, offsy = 0.0f;
1730
1731 if (!tracking->camera.focal) {
1732 return;
1733 }
1734
1735 if ((sc->flag & SC_SHOW_GRID) == 0 && (sc->flag & SC_MANUAL_CALIBRATION) == 0) {
1736 return;
1737 }
1738
1739 ui::view2d_view_to_region_fl(&region->v2d, 0.0f, 0.0f, &x, &y);
1740
1743 GPU_matrix_scale_2f(zoomx, zoomy);
1745 GPU_matrix_scale_2f(width, height);
1746
1748 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
1749
1751
1752 /* grid */
1753 if (sc->overlay.flag & SC_SHOW_OVERLAYS && sc->flag & SC_SHOW_GRID) {
1754 float val[4][2], idx[4][2];
1755 float min[2], max[2];
1756
1757 for (int a = 0; a < 4; a++) {
1758 if (a < 2) {
1759 val[a][a % 2] = FLT_MAX;
1760 }
1761 else {
1762 val[a][a % 2] = -FLT_MAX;
1763 }
1764 }
1765
1766 for (int i = 0; i <= n; i++) {
1767 for (int j = 0; j <= n; j++) {
1768 if (i == 0 || j == 0 || i == n || j == n) {
1769 const float pos[2] = {dx * j, dy * i};
1770 BKE_tracking_distort_v2(tracking, width, height, pos, tpos);
1771
1772 for (int a = 0; a < 4; a++) {
1773 int ok;
1774
1775 if (a < 2) {
1776 ok = tpos[a % 2] < val[a][a % 2];
1777 }
1778 else {
1779 ok = tpos[a % 2] > val[a][a % 2];
1780 }
1781
1782 if (ok) {
1783 copy_v2_v2(val[a], tpos);
1784 idx[a][0] = j;
1785 idx[a][1] = i;
1786 }
1787 }
1788 }
1789 }
1790 }
1791
1793
1794 for (int a = 0; a < 4; a++) {
1795 const float pos[2] = {idx[a][0] * dx, idx[a][1] * dy};
1796
1797 BKE_tracking_undistort_v2(tracking, width, height, pos, tpos);
1798
1799 minmax_v2v2_v2(min, max, tpos);
1800 }
1801
1802 dx = (max[0] - min[0]) / n;
1803 dy = (max[1] - min[1]) / n;
1804
1805 for (int i = 0; i <= n; i++) {
1806 for (int j = 0; j <= n; j++) {
1807 const float pos[2] = {min[0] + dx * j, min[1] + dy * i};
1808
1809 BKE_tracking_distort_v2(tracking, width, height, pos, grid[i][j]);
1810
1811 grid[i][j][0] /= width;
1812 grid[i][j][1] /= height * aspy;
1813 }
1814 }
1815
1816 immUniformColor3f(1.0f, 0.0f, 0.0f);
1817
1818 for (int i = 0; i <= n; i++) {
1820
1821 for (int j = 0; j <= n; j++) {
1822 immVertex2fv(position, grid[i][j]);
1823 }
1824
1825 immEnd();
1826 }
1827
1828 for (int j = 0; j <= n; j++) {
1830
1831 for (int i = 0; i <= n; i++) {
1832 immVertex2fv(position, grid[i][j]);
1833 }
1834
1835 immEnd();
1836 }
1837 }
1838
1839 if (sc->gpencil_src != SC_GPENCIL_SRC_TRACK) {
1840 gpd = clip->gpd;
1841 }
1842
1843 if (sc->flag & SC_MANUAL_CALIBRATION && gpd) {
1844 bGPDlayer *layer = gpd->layers.first();
1845
1846 while (layer) {
1847 bGPDframe *frame = layer->frames.first();
1848
1849 if (layer->flag & GP_LAYER_HIDE) {
1850 layer = layer->next;
1851 continue;
1852 }
1853
1854 immUniformColor4fv(layer->color);
1855
1856 GPU_line_width(layer->thickness);
1857 GPU_point_size(float(layer->thickness + 2));
1858
1859 while (frame) {
1860 bGPDstroke *stroke = frame->strokes.first();
1861
1862 while (stroke) {
1863 if (stroke->flag & GP_STROKE_2DSPACE) {
1864 if (stroke->totpoints > 1) {
1865 for (int i = 0; i < stroke->totpoints - 1; i++) {
1866 float pos[2], npos[2], dpos[2], len;
1867 int steps;
1868
1869 pos[0] = (stroke->points[i].x + offsx) * width;
1870 pos[1] = (stroke->points[i].y + offsy) * height * aspy;
1871
1872 npos[0] = (stroke->points[i + 1].x + offsx) * width;
1873 npos[1] = (stroke->points[i + 1].y + offsy) * height * aspy;
1874
1875 len = len_v2v2(pos, npos);
1876 steps = ceil(len / 5.0f);
1877
1878 /* we want to distort only long straight lines */
1879 if (stroke->totpoints == 2) {
1880 BKE_tracking_undistort_v2(tracking, width, height, pos, pos);
1881 BKE_tracking_undistort_v2(tracking, width, height, npos, npos);
1882 }
1883
1884 sub_v2_v2v2(dpos, npos, pos);
1885 mul_v2_fl(dpos, 1.0f / steps);
1886
1887 immBegin(GPU_PRIM_LINE_STRIP, steps + 1);
1888
1889 for (int j = 0; j <= steps; j++) {
1890 BKE_tracking_distort_v2(tracking, width, height, pos, tpos);
1891 immVertex2f(position, tpos[0] / width, tpos[1] / (height * aspy));
1892
1893 add_v2_v2(pos, dpos);
1894 }
1895
1896 immEnd();
1897 }
1898 }
1899 else if (stroke->totpoints == 1) {
1901 immVertex2f(position, stroke->points[0].x + offsx, stroke->points[0].y + offsy);
1902 immEnd();
1903 }
1904 }
1905
1906 stroke = stroke->next;
1907 }
1908
1909 frame = frame->next;
1910 }
1911
1912 layer = layer->next;
1913 }
1914 }
1915
1917
1919}
1920
1921void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *region)
1922{
1924 Scene *scene = CTX_data_scene(C);
1925 ImBuf *ibuf = nullptr;
1926 int width, height;
1927 float zoomx, zoomy;
1928
1929 ED_space_clip_get_size(sc, &width, &height);
1930 ED_space_clip_get_zoom(sc, region, &zoomx, &zoomy);
1931
1932 /* if no clip, nothing to do */
1933 if (!clip) {
1934 ED_region_grid_draw(region, zoomx, zoomy, 0.0f, 0.0f);
1935 return;
1936 }
1937
1938 if (sc->flag & SC_SHOW_STABLE) {
1939 float translation[2];
1940 float aspect = clip->tracking.camera.pixel_aspect;
1941 float smat[4][4], ismat[4][4];
1942
1943 if ((sc->flag & SC_MUTE_FOOTAGE) == 0) {
1944 ibuf = ED_space_clip_get_stable_buffer(sc, sc->loc, &sc->scale, &sc->angle);
1945 }
1946
1947 if (ibuf != nullptr && width != ibuf->x) {
1948 mul_v2_v2fl(translation, sc->loc, float(width) / ibuf->x);
1949 }
1950 else {
1951 copy_v2_v2(translation, sc->loc);
1952 }
1953
1955 width, height, aspect, translation, sc->scale, sc->angle, sc->stabmat);
1956
1957 unit_m4(smat);
1958 smat[0][0] = 1.0f / width;
1959 smat[1][1] = 1.0f / height;
1960 invert_m4_m4(ismat, smat);
1961
1962 mul_m4_series(sc->unistabmat, smat, sc->stabmat, ismat);
1963 }
1964 else if ((sc->flag & SC_MUTE_FOOTAGE) == 0) {
1965 ibuf = ED_space_clip_get_buffer(sc);
1966
1967 zero_v2(sc->loc);
1968 sc->scale = 1.0f;
1969 unit_m4(sc->stabmat);
1970 unit_m4(sc->unistabmat);
1971 }
1972
1973 if (ibuf) {
1974 draw_movieclip_buffer(C, sc, region, ibuf, width, height, zoomx, zoomy);
1975 IMB_freeImBuf(ibuf);
1976 }
1977 else if (sc->flag & SC_MUTE_FOOTAGE) {
1978 draw_movieclip_muted(region, width, height, zoomx, zoomy);
1979 }
1980 else {
1981 ED_region_grid_draw(region, zoomx, zoomy, 0.0f, 0.0f);
1982 }
1983
1984 if (width && height) {
1985 draw_stabilization_border(sc, region, width, height, zoomx, zoomy);
1986 if (sc->overlay.flag & SC_SHOW_OVERLAYS) {
1987 draw_tracking_tracks(sc, scene, region, clip, width, height, zoomx, zoomy);
1988 }
1989 draw_distortion(sc, region, clip, width, height, zoomx, zoomy);
1990 }
1991}
1992
1994{
1995 Scene *scene = CTX_data_scene(C);
1997 if (clip) {
1998 draw_movieclip_cache(sc, region, clip, scene);
1999 draw_movieclip_notes(sc, region);
2000 }
2001}
2002
2004{
2007
2008 if (!clip) {
2009 return;
2010 }
2011
2012 if (onlyv2d) {
2013 bool is_track_source = sc->gpencil_src == SC_GPENCIL_SRC_TRACK;
2014 /* if manual calibration is used then grease pencil data
2015 * associated with the clip is already drawn in draw_distortion
2016 */
2017 if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || is_track_source) {
2020
2021 if (is_track_source) {
2022 const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(
2023 &clip->tracking);
2024 MovieTrackingTrack *active_track = tracking_object->active_track;
2025
2026 if (active_track) {
2027 const int framenr = ED_space_clip_get_clip_frame_number(sc);
2028 MovieTrackingMarker *marker = BKE_tracking_marker_get(active_track, framenr);
2029
2031 }
2032 }
2033
2035
2037 }
2038 }
2039 else {
2041 }
2042}
2043
2044} // namespace blender
#define SELECT
Definition BKE_mask.hh:19
#define TRACK_VIEW_SELECTED(sc, track)
#define mul_m4_series(...)
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define UI_SCALE_FAC
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
volatile int lock
#define INIT_MINMAX2(min, max)
#define UNUSED_VARS_NDEBUG(...)
#define ELEM(...)
btScalar max
#define MAX_STATIC_PATH
#define roundf(x)
#define str(s)
#define FLT_MAX
#define position
#define layer
#define ceil
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
const int state
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
void font_theme_color_set(int fontid, int colorid)
void get_color_3fv(int colorid, float col[3])
void get_color_4fv(int colorid, float col[4])
void get_color_shade_4fv(int colorid, int offset, float col[4])
void get_color_shade_4ubv(int colorid, int offset, unsigned char col[4])
void view2d_view_to_region_fl(const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1720
void view2d_view_to_region(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1705
BMesh Iterators.
MINLINE float min_ff(float a, float b)
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.cc:922
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void ED_space_clip_get_size(const SpaceClip *sc, int *r_width, int *r_height)
MovieTrackingMarker * BKE_tracking_marker_get_exact(MovieTrackingTrack *track, int framenr)
Definition tracking.cc:1396
static void draw_track_path(SpaceClip *sc, MovieClip *, MovieTrackingTrack *track)
Definition clip_draw.cc:493
static void homogeneous_2d_to_gl_matrix(float matrix[3][3], float gl_matrix[4][4])
static void draw_stabilization_border(SpaceClip *sc, ARegion *region, int width, int height, float zoomx, float zoomy)
Definition clip_draw.cc:348
void BKE_tracking_get_projection_matrix(MovieTracking *tracking, MovieTrackingObject *tracking_object, int framenr, int winx, int winy, float mat[4][4])
Definition tracking.cc:388
void GPU_texture_update(gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
ImBuf * ED_space_clip_get_buffer(const SpaceClip *sc)
static void draw_movieclip_muted(ARegion *region, int width, int height, float zoomx, float zoomy)
Definition clip_draw.cc:288
void BLF_position(int fontid, float x, float y, float z)
Definition blf.cc:390
void immEnd()
static void draw_marker_texts(SpaceClip *sc, const MovieTrackingTrack *track, const MovieTrackingMarker *marker, const float marker_pos[2], int act, int width, int height, float zoomx, float zoomy)
void immUniformColor3f(float r, float g, float b)
void ED_annotation_draw_2dimage(const bContext *C)
static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *region, MovieClip *clip, int width, int height, float zoomx, float zoomy)
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
void IMB_colormanagement_finish_glsl_draw()
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
static void draw_plane_marker(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker, bool is_active_track, int width, int height)
static int track_to_path_segment(SpaceClip *sc, MovieTrackingTrack *track, int direction, TrackPathPoint *path)
Definition clip_draw.cc:415
void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
MINLINE void mul_v2_fl(float r[2], float f)
void immUniform2f(const char *name, float x, float y)
void immBeginAtMost(GPUPrimType, uint max_vertex_len)
static void draw_plane_marker_image(Scene *scene, MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker)
MINLINE void copy_v2_v2(float r[2], const float a[2])
void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2, bool clear_alpha=false)
MovieTrackingObject * BKE_tracking_object_get_active(const MovieTracking *tracking)
Definition tracking.cc:1982
GPUVertFormat * immVertexFormat()
void ED_clip_point_undistorted_pos(const SpaceClip *sc, const float co[2], float r_co[2])
void GPU_point_size(float size)
Definition gpu_state.cc:157
void ED_region_cache_draw_background(ARegion *region)
Definition area.cc:4806
SpaceClip * CTX_wm_space_clip(const bContext *C)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void immBegin(GPUPrimType, uint vertex_len)
bool IMB_colormanagement_setup_glsl_draw_from_space(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, const ColorSpace *from_colorspace, float dither, bool predivide, bool do_overlay_merge, ColorManagedDisplaySpace display_space=DISPLAY_SPACE_DRAW, float opacity=1.0f)
@ GPU_PRIM_LINE_STRIP
@ GPU_PRIM_LINE_LOOP
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float normalize_v2(float n[2])
@ TH_PATH_KEYFRAME_BEFORE
@ TH_PATH_KEYFRAME_AFTER
@ TH_MARKER_OUTLINE
void immUniformColor4fv(const float rgba[4])
static void draw_plane_track(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track, int framenr, bool is_active_track, int width, int height)
static bool generic_track_is_marker_keyframed(const MovieTrackingTrack *track, const MovieTrackingPlaneTrack *plane_track, const int marker_index)
Definition clip_draw.cc:117
void BKE_tracking_stabilization_data_to_mat4(int width, int height, float aspect, float translation[2], float scale, float angle, float mat[4][4])
@ MCLIP_PROXY_RENDER_UNDISTORT
static void draw_track_path_keyframe_points(const TrackPathPoint *path, uint position_attribute, const int start_point, const int num_points)
Definition clip_draw.cc:462
void immAttr2f(uint attr_id, float x, float y)
@ MCLIP_PROXY_RENDER_SIZE_FULL
@ MCLIP_PROXY_RENDER_SIZE_100
void ED_region_cache_draw_cached_segments(ARegion *region, int num_segments, const int *points, int sfra, int efra)
Definition area.cc:4854
static void draw_plane_marker_outline(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker, int width, int height)
void immUnbindProgram()
static void track_colors(const MovieTrackingTrack *track, int act, float r_col[3], float r_scol[3])
Definition clip_draw.cc:679
static float get_shortest_pattern_side(const MovieTrackingMarker *marker)
Definition clip_draw.cc:893
void GPU_matrix_mul(const float m[4][4])
void GPU_line_width(float width)
Definition gpu_state.cc:151
void GPU_matrix_scale_2f(float x, float y)
BLI_INLINE bool ED_space_clip_marker_is_visible(const SpaceClip *space_clip, const MovieTrackingObject *tracking_object, const MovieTrackingTrack *track, const MovieTrackingMarker *marker)
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
@ GPU_BLEND_INVERT
Definition GPU_state.hh:100
static bool generic_track_is_marker_enabled(const MovieTrackingTrack *track, const MovieTrackingPlaneTrack *plane_track, const int marker_index)
Definition clip_draw.cc:102
VecBase< float, 4 > float4
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
static void draw_track_path_points(const TrackPathPoint *path, uint position_attribute, const int start_point, const int num_points)
Definition clip_draw.cc:446
void BKE_movieclip_get_cache_segments(MovieClip *clip, const MovieClipUser *user, int *r_totseg, int **r_points)
void mul_m4_v3(const float M[4][4], float r[3])
void BKE_tracking_marker_pattern_minmax(const MovieTrackingMarker *marker, float min[2], float max[2])
Definition tracking.cc:1500
static int generic_track_get_marker_framenr(const MovieTrackingTrack *track, const MovieTrackingPlaneTrack *plane_track, const int marker_index)
Definition clip_draw.cc:86
void immUniformThemeColor(int color_id)
void BLF_size(int fontid, float size)
Definition blf.cc:445
void IMB_freeImBuf(ImBuf *ibuf)
void immUniform1f(const char *name, float x)
void immVertex2f(uint attr_id, float x, float y)
MINLINE void add_v2_v2(float r[2], const float a[2])
unsigned char uchar
Definition BKE_text.h:58
@ GPU_TEXTURE_USAGE_SHADER_READ
void BKE_tracking_undistort_v2(MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
Definition tracking.cc:2448
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *region)
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:258
@ GPU_SHADER_3D_POINT_UNIFORM_COLOR
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
int ED_space_clip_get_clip_frame_number(const SpaceClip *sc)
void immUniformThemeColorShade(int color_id, int offset)
void clip_draw_grease_pencil(bContext *C, int onlyv2d)
void GPU_texture_filter_mode(gpu::Texture *texture, bool use_filter)
void clip_draw_cache_and_notes(const bContext *C, SpaceClip *sc, ARegion *region)
ImBuf * ED_space_clip_get_stable_buffer(const SpaceClip *sc, float loc[2], float *scale, float *angle)
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)
static void marker_to_path_point(SpaceClip *sc, const MovieTrackingTrack *track, const MovieTrackingMarker *marker, TrackPathPoint *point)
Definition clip_draw.cc:402
void immUniformColor4f(float r, float g, float b, float a)
static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int width, uint pos)
Definition clip_draw.cc:57
void unit_m4(float m[4][4])
void ED_region_image_metadata_draw(int x, int y, const ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)
Definition ed_draw.cc:1039
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])
void BKE_tracking_homography_between_two_quads(float reference_corners[4][2], float corners[4][2], float H[3][3])
@ PATH_POINT_FLAG_KEYFRAME
Definition clip_draw.cc:394
static void draw_movieclip_notes(SpaceClip *sc, ARegion *region)
Definition clip_draw.cc:265
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
void GPU_matrix_translate_2f(float x, float y)
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
Definition blf.cc:587
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
Definition blf.cc:454
static void draw_marker_slide_zones(SpaceClip *sc, const MovieTrackingTrack *track, const MovieTrackingMarker *marker, const float marker_pos[2], int outline, int sel, int act, int width, int height, uint pos)
Definition clip_draw.cc:942
void ED_draw_imbuf_ctx(const bContext *C, const ImBuf *ibuf, float x, float y, bool use_filter, float zoom_x, float zoom_y)
Definition glutil.cc:177
bool IMB_alpha_affects_rgb(const ImBuf *ibuf)
Definition conversion.cc:45
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *region, const ImBuf *ibuf, int width, int height, float zoomx, float zoomy)
Definition clip_draw.cc:304
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:883
static void draw_distortion(SpaceClip *sc, ARegion *region, MovieClip *clip, int width, int height, float zoomx, float zoomy)
void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, float y0)
Definition area.cc:4636
MovieClip * ED_space_clip_get_clip(const SpaceClip *sc)
void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2)
void ED_mask_draw_frames(Mask *mask, ARegion *region, int cfra, int sfra, int efra)
Definition mask_draw.cc:793
void GPU_texture_bind(gpu::Texture *texture, int unit)
void GPU_texture_free(gpu::Texture *texture)
MINLINE float len_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
static void plane_track_colors(bool is_active, float r_color[3], float r_selected_color[3])
MovieTrackingPlaneMarker * BKE_tracking_plane_marker_get(MovieTrackingPlaneTrack *plane_track, int framenr)
Definition tracking.cc:1796
bool BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip, Scene *scene)
Definition clip_draw.cc:133
static void draw_marker_outline(SpaceClip *sc, const MovieTrackingTrack *track, const MovieTrackingMarker *marker, const float marker_pos[2], int width, int height, uint position)
Definition clip_draw.cc:584
void GPU_texture_unbind(gpu::Texture *texture)
void GPU_matrix_translate_2fv(const float vec[2])
Scene * CTX_data_scene(const bContext *C)
void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
MINLINE void sub_v2_v2(float r[2], const float a[2])
void immUniformColor3fv(const float rgb[3])
void immVertex3f(uint attr_id, float x, float y, float z)
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
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])
void immUniform1i(const char *name, int x)
VecBase< float, 3 > float3
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void immVertex2fv(uint attr_id, const float data[2])
void GPU_matrix_pop()
MINLINE int min_ii(int a, int b)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
MINLINE void zero_v2(float r[2])
void ED_space_clip_get_zoom(const SpaceClip *sc, const ARegion *region, float *r_zoomx, float *r_zoomy)
static int generic_track_get_markersnr(const MovieTrackingTrack *track, const MovieTrackingPlaneTrack *plane_track)
Definition clip_draw.cc:73
void ED_region_cache_draw_curfra_label(int framenr, float x, float y)
Definition area.cc:4819
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.cc:703
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.cc:906
void ED_region_info_draw(ARegion *region, const char *text, const float fill_color[4], bool full_redraw)
Definition area.cc:4602
void BKE_tracking_distort_v2(MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
Definition tracking.cc:2421
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_matrix_push()
ocio::ColorSpace ColorSpace
Definition BLF_api.hh:42
void mul_v4_m4v4(float r[4], const float mat[4][4], const float v[4])
static void draw_track_path_lines(const TrackPathPoint *path, uint position_attribute, const int start_point, const int num_points)
Definition clip_draw.cc:477
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition rct.cc:418
static void draw_marker_areas(SpaceClip *sc, const MovieTrackingTrack *track, const MovieTrackingMarker *marker, const float marker_pos[2], int width, int height, int act, int sel, const uint shdr_pos)
Definition clip_draw.cc:737
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
MovieTrackingMarker * BKE_tracking_marker_get(MovieTrackingTrack *track, int framenr)
Definition tracking.cc:1363
#define sqrtf
#define ceilf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
const ColorSpace * colorspace
const ColorSpace * colorspace
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
const uint8_t * byte_data() const
const float * float_data() const
bool can_contain_alpha() const
eMovieClipProxy_RenderFlag render_flag
eMovieClipProxy_RenderSize render_size
struct MovieTracking tracking
MovieTrackingPlaneTrack * active_plane_track
MovieTrackingReconstruction reconstruction
ListBaseT< MovieTrackingTrack > tracks
ListBaseT< MovieTrackingPlaneTrack > plane_tracks
MovieTrackingTrack * active_track
MovieTrackingPlaneMarker * markers
struct MovieReconstructedCamera * cameras
MovieTrackingMarker * markers
MovieTrackingStats * stats
MovieTrackingCamera camera
MovieTrackingStabilization stabilization
ColorManagedViewSettings view_settings
ColorManagedDisplaySettings display_settings
struct RenderData r
eSpaceClip_Flag flag
MaskSpaceInfo mask_info
eSpaceClip_GPencil_Source gpencil_src
eSpaceClip_Mode mode
struct MovieClipUser user
struct SpaceClipOverlay overlay
ListBaseT< bGPDstroke > strokes
ListBaseT< bGPDlayer > layers
uiFontStyle widget