Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/sequencer_draw.c
| Show All 18 Lines | |||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_mask_types.h" | #include "DNA_mask_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_sound_types.h" | #include "DNA_sound_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_userdef_types.h" | #include "DNA_userdef_types.h" | ||||
| #include "DNA_video_edit_types.h" | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_sound.h" | #include "BKE_sound.h" | ||||
| #include "IMB_colormanagement.h" | #include "IMB_colormanagement.h" | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| #define SEQ_LEFTHANDLE 1 | #define SEQ_LEFTHANDLE 1 | ||||
| #define SEQ_RIGHTHANDLE 2 | #define SEQ_RIGHTHANDLE 2 | ||||
| #define SEQ_HANDLE_SIZE 8.0f | #define SEQ_HANDLE_SIZE 8.0f | ||||
| #define SEQ_SCROLLER_TEXT_OFFSET 8 | #define SEQ_SCROLLER_TEXT_OFFSET 8 | ||||
| #define MUTE_ALPHA 120 | #define MUTE_ALPHA 120 | ||||
| static Sequence *special_seq_update = NULL; | static Sequence *special_seq_update = NULL; | ||||
| void color3ubv_from_seq(const Scene *curscene, | void color3ubv_from_seq(const VideoEdit *video_edit, | ||||
| const Sequence *seq, | const Sequence *seq, | ||||
| const bool show_strip_color_tag, | const bool show_strip_color_tag, | ||||
| uchar r_col[3]) | uchar r_col[3]) | ||||
| { | { | ||||
| Editing *ed = SEQ_editing_get(curscene); | ListBase *channels = SEQ_channels_displayed_get(video_edit); | ||||
| ListBase *channels = SEQ_channels_displayed_get(ed); | |||||
| if (show_strip_color_tag && (uint)seq->color_tag < SEQUENCE_COLOR_TOT && | if (show_strip_color_tag && (uint)seq->color_tag < SEQUENCE_COLOR_TOT && | ||||
| seq->color_tag != SEQUENCE_COLOR_NONE) { | seq->color_tag != SEQUENCE_COLOR_NONE) { | ||||
| bTheme *btheme = UI_GetTheme(); | bTheme *btheme = UI_GetTheme(); | ||||
| const ThemeStripColor *strip_color = &btheme->strip_color[seq->color_tag]; | const ThemeStripColor *strip_color = &btheme->strip_color[seq->color_tag]; | ||||
| copy_v3_v3_uchar(r_col, strip_color->color); | copy_v3_v3_uchar(r_col, strip_color->color); | ||||
| return; | return; | ||||
| } | } | ||||
| Show All 25 Lines | switch (seq->type) { | ||||
| case SEQ_TYPE_MASK: | case SEQ_TYPE_MASK: | ||||
| UI_GetThemeColor3ubv(TH_SEQ_MASK, r_col); | UI_GetThemeColor3ubv(TH_SEQ_MASK, r_col); | ||||
| break; | break; | ||||
| case SEQ_TYPE_SCENE: | case SEQ_TYPE_SCENE: | ||||
| UI_GetThemeColor3ubv(TH_SEQ_SCENE, r_col); | UI_GetThemeColor3ubv(TH_SEQ_SCENE, r_col); | ||||
| #if 0 | |||||
| if (seq->scene == curscene) { | if (seq->scene == curscene) { | ||||
| UI_GetColorPtrShade3ubv(r_col, r_col, 20); | UI_GetColorPtrShade3ubv(r_col, r_col, 20); | ||||
| } | } | ||||
| #endif | |||||
| break; | break; | ||||
| /* Transitions use input colors, fallback for when the input is a transition itself. */ | /* Transitions use input colors, fallback for when the input is a transition itself. */ | ||||
| case SEQ_TYPE_CROSS: | case SEQ_TYPE_CROSS: | ||||
| case SEQ_TYPE_GAMCROSS: | case SEQ_TYPE_GAMCROSS: | ||||
| case SEQ_TYPE_WIPE: | case SEQ_TYPE_WIPE: | ||||
| r_col[0] = 130; | r_col[0] = 130; | ||||
| r_col[1] = 130; | r_col[1] = 130; | ||||
| ▲ Show 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * \param x1, x2, y1, y2: The starting and end X value to draw the wave, same for y1 and y2. | * \param x1, x2, y1, y2: The starting and end X value to draw the wave, same for y1 and y2. | ||||
| * \param frames_per_pixel: The amount of pixels a whole frame takes up (x-axis direction). | * \param frames_per_pixel: The amount of pixels a whole frame takes up (x-axis direction). | ||||
| */ | */ | ||||
| static void draw_seq_waveform_overlay( | static void draw_seq_waveform_overlay( | ||||
| const bContext *C, ARegion *region, Sequence *seq, float x1, float y1, float x2, float y2) | const bContext *C, ARegion *region, Sequence *seq, float x1, float y1, float x2, float y2) | ||||
| { | { | ||||
| const View2D *v2d = ®ion->v2d; | const View2D *v2d = ®ion->v2d; | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| const float frames_per_pixel = BLI_rctf_size_x(®ion->v2d.cur) / region->winx; | const float frames_per_pixel = BLI_rctf_size_x(®ion->v2d.cur) / region->winx; | ||||
| const float samples_per_frame = SOUND_WAVE_SAMPLES_PER_SECOND / FPS; | float fps = (((double)video_edit->r.frs_sec) / (double)video_edit->r.frs_sec_base); | ||||
| const float samples_per_frame = SOUND_WAVE_SAMPLES_PER_SECOND / fps; | |||||
| float samples_per_pixel = samples_per_frame * frames_per_pixel; | float samples_per_pixel = samples_per_frame * frames_per_pixel; | ||||
| /* Align strip start with nearest pixel to prevent waveform flickering. */ | /* Align strip start with nearest pixel to prevent waveform flickering. */ | ||||
| const float x1_aligned = align_frame_with_pixel(x1, frames_per_pixel); | const float x1_aligned = align_frame_with_pixel(x1, frames_per_pixel); | ||||
| /* Offset x1 and x2 values, to match view min/max, if strip is out of bounds. */ | /* Offset x1 and x2 values, to match view min/max, if strip is out of bounds. */ | ||||
| const float frame_start = max_ff(v2d->cur.xmin, x1_aligned); | const float frame_start = max_ff(v2d->cur.xmin, x1_aligned); | ||||
| const float frame_end = min_ff(v2d->cur.xmax, x2); | const float frame_end = min_ff(v2d->cur.xmax, x2); | ||||
| const int pixels_to_draw = round_fl_to_int((frame_end - frame_start) / frames_per_pixel); | const int pixels_to_draw = round_fl_to_int((frame_end - frame_start) / frames_per_pixel); | ||||
| if (pixels_to_draw < 2) { | if (pixels_to_draw < 2) { | ||||
| return; /* Not much to draw, exit before running job. */ | return; /* Not much to draw, exit before running job. */ | ||||
| } | } | ||||
| waveform_job_start_if_needed(C, seq); | waveform_job_start_if_needed(C, seq); | ||||
| SoundWaveform *waveform = seq->sound->waveform; | SoundWaveform *waveform = seq->sound->waveform; | ||||
| if (waveform == NULL || waveform->length == 0) { | if (waveform == NULL || waveform->length == 0) { | ||||
| return; /* Waveform was not built. */ | return; /* Waveform was not built. */ | ||||
| } | } | ||||
| /* F-Curve lookup is quite expensive, so do this after precondition. */ | /* F-Curve lookup is quite expensive, so do this after precondition. */ | ||||
| FCurve *fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, NULL); | FCurve *fcu = id_data_find_fcurve(&video_edit->id, seq, &RNA_Sequence, "volume", 0, NULL); | ||||
| WaveVizData *waveform_data = MEM_callocN(sizeof(WaveVizData) * pixels_to_draw * 3, __func__); | WaveVizData *waveform_data = MEM_callocN(sizeof(WaveVizData) * pixels_to_draw * 3, __func__); | ||||
| size_t wave_data_len = 0; | size_t wave_data_len = 0; | ||||
| /* Offset must be also aligned, otherwise waveform flickers when moving left handle. */ | /* Offset must be also aligned, otherwise waveform flickers when moving left handle. */ | ||||
| const float strip_offset = align_frame_with_pixel(seq->startofs + seq->anim_startofs, | const float strip_offset = align_frame_with_pixel(seq->startofs + seq->anim_startofs, | ||||
| frames_per_pixel); | frames_per_pixel); | ||||
| float start_sample = strip_offset * samples_per_frame; | float start_sample = strip_offset * samples_per_frame; | ||||
| start_sample += seq->sound->offset_time * SOUND_WAVE_SAMPLES_PER_SECOND; | start_sample += seq->sound->offset_time * SOUND_WAVE_SAMPLES_PER_SECOND; | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | static void draw_seq_waveform_overlay( | ||||
| } | } | ||||
| /* Terminate array, so `get_segment_length()` can know when to stop. */ | /* Terminate array, so `get_segment_length()` can know when to stop. */ | ||||
| waveform_data[wave_data_len].final_sample = true; | waveform_data[wave_data_len].final_sample = true; | ||||
| draw_waveform(waveform_data, wave_data_len); | draw_waveform(waveform_data, wave_data_len); | ||||
| MEM_freeN(waveform_data); | MEM_freeN(waveform_data); | ||||
| } | } | ||||
| static void drawmeta_contents(Scene *scene, | static void drawmeta_contents(VideoEdit *video_edit, | ||||
| Sequence *seqm, | Sequence *seqm, | ||||
| float x1, | float x1, | ||||
| float y1, | float y1, | ||||
| float x2, | float x2, | ||||
| float y2, | float y2, | ||||
| const bool show_strip_color_tag) | const bool show_strip_color_tag) | ||||
| { | { | ||||
| Sequence *seq; | Sequence *seq; | ||||
| uchar col[4]; | uchar col[4]; | ||||
| int chan_min = MAXSEQ; | int chan_min = MAXSEQ; | ||||
| int chan_max = 0; | int chan_max = 0; | ||||
| int chan_range = 0; | int chan_range = 0; | ||||
| float draw_range = y2 - y1; | float draw_range = y2 - y1; | ||||
| float draw_height; | float draw_height; | ||||
| Editing *ed = SEQ_editing_get(scene); | ListBase *channels = SEQ_channels_displayed_get(video_edit); | ||||
| ListBase *channels = SEQ_channels_displayed_get(ed); | |||||
| ListBase *meta_seqbase; | ListBase *meta_seqbase; | ||||
| ListBase *meta_channels; | ListBase *meta_channels; | ||||
| int offset; | int offset; | ||||
| meta_seqbase = SEQ_get_seqbase_from_sequence(seqm, &meta_channels, &offset); | meta_seqbase = SEQ_get_seqbase_from_sequence(seqm, &meta_channels, &offset); | ||||
| if (!meta_seqbase || BLI_listbase_is_empty(meta_seqbase)) { | if (!meta_seqbase || BLI_listbase_is_empty(meta_seqbase)) { | ||||
| return; | return; | ||||
| Show All 18 Lines | static void drawmeta_contents(VideoEdit *video_edit, | ||||
| col[3] = 196; /* Alpha, used for all meta children. */ | col[3] = 196; /* Alpha, used for all meta children. */ | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| /* Draw only immediate children (1 level depth). */ | /* Draw only immediate children (1 level depth). */ | ||||
| for (seq = meta_seqbase->first; seq; seq = seq->next) { | for (seq = meta_seqbase->first; seq; seq = seq->next) { | ||||
| const int startdisp = SEQ_time_left_handle_frame_get(scene, seq) + offset; | const int startdisp = SEQ_time_left_handle_frame_get(video_edit, seq) + offset; | ||||
| const int enddisp = SEQ_time_right_handle_frame_get(scene, seq) + offset; | const int enddisp = SEQ_time_right_handle_frame_get(video_edit, seq) + offset; | ||||
| if ((startdisp > x2 || enddisp < x1) == 0) { | if ((startdisp > x2 || enddisp < x1) == 0) { | ||||
| float y_chan = (seq->machine - chan_min) / (float)(chan_range)*draw_range; | float y_chan = (seq->machine - chan_min) / (float)(chan_range)*draw_range; | ||||
| float x1_chan = startdisp; | float x1_chan = startdisp; | ||||
| float x2_chan = enddisp; | float x2_chan = enddisp; | ||||
| float y1_chan, y2_chan; | float y1_chan, y2_chan; | ||||
| if (seq->type == SEQ_TYPE_COLOR) { | if (seq->type == SEQ_TYPE_COLOR) { | ||||
| SolidColorVars *colvars = (SolidColorVars *)seq->effectdata; | SolidColorVars *colvars = (SolidColorVars *)seq->effectdata; | ||||
| rgb_float_to_uchar(col, colvars->col); | rgb_float_to_uchar(col, colvars->col); | ||||
| } | } | ||||
| else { | else { | ||||
| color3ubv_from_seq(scene, seq, show_strip_color_tag, col); | color3ubv_from_seq(video_edit, seq, show_strip_color_tag, col); | ||||
| } | } | ||||
| if (SEQ_render_is_muted(channels, seqm) || SEQ_render_is_muted(meta_channels, seq)) { | if (SEQ_render_is_muted(channels, seqm) || SEQ_render_is_muted(meta_channels, seq)) { | ||||
| col[3] = 64; | col[3] = 64; | ||||
| } | } | ||||
| else { | else { | ||||
| col[3] = 196; | col[3] = 196; | ||||
| } | } | ||||
| Show All 15 Lines | for (seq = meta_seqbase->first; seq; seq = seq->next) { | ||||
| } | } | ||||
| } | } | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| float sequence_handle_size_get_clamped(const Scene *scene, Sequence *seq, const float pixelx) | float sequence_handle_size_get_clamped(const VideoEdit *video_edit, | ||||
| Sequence *seq, | |||||
| const float pixelx) | |||||
| { | { | ||||
| const float maxhandle = (pixelx * SEQ_HANDLE_SIZE) * U.pixelsize; | const float maxhandle = (pixelx * SEQ_HANDLE_SIZE) * U.pixelsize; | ||||
| /* Ensure that handle is not wider, than quarter of strip. */ | /* Ensure that handle is not wider, than quarter of strip. */ | ||||
| return min_ff(maxhandle, | return min_ff(maxhandle, | ||||
| ((float)(SEQ_time_right_handle_frame_get(scene, seq) - | ((float)(SEQ_time_right_handle_frame_get(video_edit, seq) - | ||||
| SEQ_time_left_handle_frame_get(scene, seq)) / | SEQ_time_left_handle_frame_get(video_edit, seq)) / | ||||
| 4.0f)); | 4.0f)); | ||||
| } | } | ||||
| /* Draw a handle, on left or right side of strip. */ | /* Draw a handle, on left or right side of strip. */ | ||||
| static void draw_seq_handle(const Scene *scene, | static void draw_seq_handle(const VideoEdit *video_edit, | ||||
| View2D *v2d, | View2D *v2d, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| const float handsize_clamped, | const float handsize_clamped, | ||||
| const short direction, | const short direction, | ||||
| uint pos, | uint pos, | ||||
| bool seq_active, | bool seq_active, | ||||
| float pixelx, | float pixelx, | ||||
| bool y_threshold) | bool y_threshold) | ||||
| { | { | ||||
| float rx1 = 0, rx2 = 0; | float rx1 = 0, rx2 = 0; | ||||
| float x1, x2, y1, y2; | float x1, x2, y1, y2; | ||||
| uint whichsel = 0; | uint whichsel = 0; | ||||
| uchar col[4]; | uchar col[4]; | ||||
| x1 = SEQ_time_left_handle_frame_get(scene, seq); | x1 = SEQ_time_left_handle_frame_get(video_edit, seq); | ||||
| x2 = SEQ_time_right_handle_frame_get(scene, seq); | x2 = SEQ_time_right_handle_frame_get(video_edit, seq); | ||||
| y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; | y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; | ||||
| y2 = seq->machine + SEQ_STRIP_OFSTOP; | y2 = seq->machine + SEQ_STRIP_OFSTOP; | ||||
| /* Set up co-ordinates and dimensions for either left or right handle. */ | /* Set up co-ordinates and dimensions for either left or right handle. */ | ||||
| if (direction == SEQ_LEFTHANDLE) { | if (direction == SEQ_LEFTHANDLE) { | ||||
| rx1 = x1; | rx1 = x1; | ||||
| rx2 = x1 + handsize_clamped; | rx2 = x1 + handsize_clamped; | ||||
| Show All 38 Lines | if (y_threshold && | ||||
| size_t numstr_len; | size_t numstr_len; | ||||
| const int fontid = BLF_default(); | const int fontid = BLF_default(); | ||||
| BLF_set_default(); | BLF_set_default(); | ||||
| /* Calculate if strip is wide enough for showing the labels. */ | /* Calculate if strip is wide enough for showing the labels. */ | ||||
| numstr_len = BLI_snprintf_rlen(numstr, | numstr_len = BLI_snprintf_rlen(numstr, | ||||
| sizeof(numstr), | sizeof(numstr), | ||||
| "%d%d", | "%d%d", | ||||
| SEQ_time_left_handle_frame_get(scene, seq), | SEQ_time_left_handle_frame_get(video_edit, seq), | ||||
| SEQ_time_right_handle_frame_get(scene, seq)); | SEQ_time_right_handle_frame_get(video_edit, seq)); | ||||
| float tot_width = BLF_width(fontid, numstr, numstr_len); | float tot_width = BLF_width(fontid, numstr, numstr_len); | ||||
| if ((x2 - x1) / pixelx > 20 + tot_width) { | if ((x2 - x1) / pixelx > 20 + tot_width) { | ||||
| col[0] = col[1] = col[2] = col[3] = 255; | col[0] = col[1] = col[2] = col[3] = 255; | ||||
| float text_margin = 1.2f * handsize_clamped; | float text_margin = 1.2f * handsize_clamped; | ||||
| if (direction == SEQ_LEFTHANDLE) { | if (direction == SEQ_LEFTHANDLE) { | ||||
| numstr_len = BLI_snprintf_rlen( | numstr_len = BLI_snprintf_rlen( | ||||
| numstr, sizeof(numstr), "%d", SEQ_time_left_handle_frame_get(scene, seq)); | numstr, sizeof(numstr), "%d", SEQ_time_left_handle_frame_get(video_edit, seq)); | ||||
| x1 += text_margin; | x1 += text_margin; | ||||
| y1 += 0.09f; | y1 += 0.09f; | ||||
| } | } | ||||
| else { | else { | ||||
| numstr_len = BLI_snprintf_rlen( | numstr_len = BLI_snprintf_rlen( | ||||
| numstr, sizeof(numstr), "%d", SEQ_time_right_handle_frame_get(scene, seq) - 1); | numstr, sizeof(numstr), "%d", SEQ_time_right_handle_frame_get(video_edit, seq) - 1); | ||||
| x1 = x2 - (text_margin + pixelx * BLF_width(fontid, numstr, numstr_len)); | x1 = x2 - (text_margin + pixelx * BLF_width(fontid, numstr, numstr_len)); | ||||
| y1 += 0.09f; | y1 += 0.09f; | ||||
| } | } | ||||
| UI_view2d_text_cache_add(v2d, x1, y1, numstr, numstr_len, col); | UI_view2d_text_cache_add(v2d, x1, y1, numstr, numstr_len, col); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void draw_seq_outline(Scene *scene, | static void draw_seq_outline(VideoEdit *video_edit, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| uint pos, | uint pos, | ||||
| float x1, | float x1, | ||||
| float x2, | float x2, | ||||
| float y1, | float y1, | ||||
| float y2, | float y2, | ||||
| float pixelx, | float pixelx, | ||||
| float pixely, | float pixely, | ||||
| Show All 12 Lines | else { | ||||
| /* Color for unselected strips is a bit darker than the background. */ | /* Color for unselected strips is a bit darker than the background. */ | ||||
| UI_GetThemeColorShade3ubv(TH_BACK, -40, col); | UI_GetThemeColorShade3ubv(TH_BACK, -40, col); | ||||
| } | } | ||||
| /* Outline while translating strips: | /* Outline while translating strips: | ||||
| * - Slightly lighter. | * - Slightly lighter. | ||||
| * - Red when overlapping with other strips. | * - Red when overlapping with other strips. | ||||
| */ | */ | ||||
| const eSeqOverlapMode overlap_mode = SEQ_tool_settings_overlap_mode_get(scene); | const eSeqOverlapMode overlap_mode = SEQ_tool_settings_overlap_mode_get(video_edit); | ||||
| if ((G.moving & G_TRANSFORM_SEQ) && (seq->flag & SELECT) && | if ((G.moving & G_TRANSFORM_SEQ) && (seq->flag & SELECT) && | ||||
| overlap_mode != SEQ_OVERLAP_OVERWRITE) { | overlap_mode != SEQ_OVERLAP_OVERWRITE) { | ||||
| if (seq->flag & SEQ_OVERLAP) { | if (seq->flag & SEQ_OVERLAP) { | ||||
| col[0] = 255; | col[0] = 255; | ||||
| col[1] = col[2] = 33; | col[1] = col[2] = 33; | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetColorPtrShade3ubv(col, col, 70); | UI_GetColorPtrShade3ubv(col, col, 70); | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | case SEQ_TYPE_MASK: { | ||||
| if (seq->mask != NULL) { | if (seq->mask != NULL) { | ||||
| BLI_strncpy(r_source, seq->mask->id.name + 2, source_len); | BLI_strncpy(r_source, seq->mask->id.name + 2, source_len); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static size_t draw_seq_text_get_overlay_string(const Scene *scene, | static size_t draw_seq_text_get_overlay_string(const VideoEdit *video_edit, | ||||
| SpaceSeq *sseq, | SpaceSeq *sseq, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| char *r_overlay_string, | char *r_overlay_string, | ||||
| size_t overlay_string_len) | size_t overlay_string_len) | ||||
| { | { | ||||
| const char *text_sep = " | "; | const char *text_sep = " | "; | ||||
| const char *text_array[5]; | const char *text_array[5]; | ||||
| int i = 0; | int i = 0; | ||||
| Show All 10 Lines | if (source[0] != '\0') { | ||||
| text_array[i++] = text_sep; | text_array[i++] = text_sep; | ||||
| } | } | ||||
| text_array[i++] = source; | text_array[i++] = source; | ||||
| } | } | ||||
| } | } | ||||
| char strip_duration_text[16]; | char strip_duration_text[16]; | ||||
| if (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_DURATION) { | if (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_DURATION) { | ||||
| const int strip_duration = SEQ_time_right_handle_frame_get(scene, seq) - | const int strip_duration = SEQ_time_right_handle_frame_get(video_edit, seq) - | ||||
| SEQ_time_left_handle_frame_get(scene, seq); | SEQ_time_left_handle_frame_get(video_edit, seq); | ||||
| SNPRINTF(strip_duration_text, "%d", strip_duration); | SNPRINTF(strip_duration_text, "%d", strip_duration); | ||||
| if (i != 0) { | if (i != 0) { | ||||
| text_array[i++] = text_sep; | text_array[i++] = text_sep; | ||||
| } | } | ||||
| text_array[i++] = strip_duration_text; | text_array[i++] = strip_duration_text; | ||||
| } | } | ||||
| BLI_assert(i <= ARRAY_SIZE(text_array)); | BLI_assert(i <= ARRAY_SIZE(text_array)); | ||||
| return BLI_string_join_array(r_overlay_string, overlay_string_len, text_array, i) - | return BLI_string_join_array(r_overlay_string, overlay_string_len, text_array, i) - | ||||
| r_overlay_string; | r_overlay_string; | ||||
| } | } | ||||
| /* Draw info text on a sequence strip. */ | /* Draw info text on a sequence strip. */ | ||||
| static void draw_seq_text_overlay(Scene *scene, | static void draw_seq_text_overlay(VideoEdit *video_edit, | ||||
| View2D *v2d, | View2D *v2d, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| SpaceSeq *sseq, | SpaceSeq *sseq, | ||||
| float x1, | float x1, | ||||
| float x2, | float x2, | ||||
| float y1, | float y1, | ||||
| float y2, | float y2, | ||||
| bool seq_active) | bool seq_active) | ||||
| { | { | ||||
| Editing *ed = SEQ_editing_get(scene); | ListBase *channels = SEQ_channels_displayed_get(video_edit); | ||||
| ListBase *channels = SEQ_channels_displayed_get(ed); | |||||
| char overlay_string[FILE_MAX]; | char overlay_string[FILE_MAX]; | ||||
| size_t overlay_string_len = draw_seq_text_get_overlay_string( | size_t overlay_string_len = draw_seq_text_get_overlay_string( | ||||
| scene, sseq, seq, overlay_string, sizeof(overlay_string)); | video_edit, sseq, seq, overlay_string, sizeof(overlay_string)); | ||||
| if (overlay_string_len == 0) { | if (overlay_string_len == 0) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* White text for the active strip. */ | /* White text for the active strip. */ | ||||
| uchar col[4]; | uchar col[4]; | ||||
| col[0] = col[1] = col[2] = seq_active ? 255 : 10; | col[0] = col[1] = col[2] = seq_active ? 255 : 10; | ||||
| Show All 14 Lines | static void draw_seq_text_overlay(VideoEdit *video_edit, | ||||
| rect.ymin = y1; | rect.ymin = y1; | ||||
| rect.xmax = x2; | rect.xmax = x2; | ||||
| rect.ymax = y2; | rect.ymax = y2; | ||||
| UI_view2d_text_cache_add_rectf(v2d, &rect, overlay_string, overlay_string_len, col); | UI_view2d_text_cache_add_rectf(v2d, &rect, overlay_string, overlay_string_len, col); | ||||
| } | } | ||||
| static void draw_sequence_extensions_overlay( | static void draw_sequence_extensions_overlay( | ||||
| Scene *scene, Sequence *seq, uint pos, float pixely, const bool show_strip_color_tag) | VideoEdit *video_edit, Sequence *seq, uint pos, float pixely, const bool show_strip_color_tag) | ||||
| { | { | ||||
| Editing *ed = SEQ_editing_get(scene); | ListBase *channels = SEQ_channels_displayed_get(video_edit); | ||||
| ListBase *channels = SEQ_channels_displayed_get(ed); | |||||
| float x1, x2, y1, y2; | float x1, x2, y1, y2; | ||||
| uchar col[4], blend_col[3]; | uchar col[4], blend_col[3]; | ||||
| x1 = SEQ_time_left_handle_frame_get(scene, seq); | x1 = SEQ_time_left_handle_frame_get(video_edit, seq); | ||||
| x2 = SEQ_time_right_handle_frame_get(scene, seq); | x2 = SEQ_time_right_handle_frame_get(video_edit, seq); | ||||
| y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; | y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; | ||||
| y2 = seq->machine + SEQ_STRIP_OFSTOP; | y2 = seq->machine + SEQ_STRIP_OFSTOP; | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| color3ubv_from_seq(scene, seq, show_strip_color_tag, col); | color3ubv_from_seq(video_edit, seq, show_strip_color_tag, col); | ||||
| if (seq->flag & SELECT) { | if (seq->flag & SELECT) { | ||||
| UI_GetColorPtrShade3ubv(col, col, 50); | UI_GetColorPtrShade3ubv(col, col, 50); | ||||
| } | } | ||||
| col[3] = SEQ_render_is_muted(channels, seq) ? MUTE_ALPHA : 200; | col[3] = SEQ_render_is_muted(channels, seq) ? MUTE_ALPHA : 200; | ||||
| UI_GetColorPtrShade3ubv(col, blend_col, 10); | UI_GetColorPtrShade3ubv(col, blend_col, 10); | ||||
| const float strip_content_start = SEQ_time_start_frame_get(seq); | const float strip_content_start = SEQ_time_start_frame_get(seq); | ||||
| const float strip_content_end = SEQ_time_content_end_frame_get(scene, seq); | const float strip_content_end = SEQ_time_content_end_frame_get(video_edit, seq); | ||||
| float right_handle_frame = SEQ_time_right_handle_frame_get(scene, seq); | float right_handle_frame = SEQ_time_right_handle_frame_get(video_edit, seq); | ||||
| float left_handle_frame = SEQ_time_left_handle_frame_get(scene, seq); | float left_handle_frame = SEQ_time_left_handle_frame_get(video_edit, seq); | ||||
| if (left_handle_frame > strip_content_start) { | if (left_handle_frame > strip_content_start) { | ||||
| immUniformColor4ubv(col); | immUniformColor4ubv(col); | ||||
| immRectf(pos, strip_content_start, y1 - pixely, x1, y1 - SEQ_STRIP_OFSBOTTOM); | immRectf(pos, strip_content_start, y1 - pixely, x1, y1 - SEQ_STRIP_OFSBOTTOM); | ||||
| /* Outline. */ | /* Outline. */ | ||||
| immUniformColor3ubv(blend_col); | immUniformColor3ubv(blend_col); | ||||
| imm_draw_box_wire_2d(pos, x1, y1 - pixely, strip_content_start, y1 - SEQ_STRIP_OFSBOTTOM); | imm_draw_box_wire_2d(pos, x1, y1 - pixely, strip_content_start, y1 - SEQ_STRIP_OFSBOTTOM); | ||||
| } | } | ||||
| if (right_handle_frame < strip_content_end) { | if (right_handle_frame < strip_content_end) { | ||||
| immUniformColor4ubv(col); | immUniformColor4ubv(col); | ||||
| immRectf(pos, x2, y2 + pixely, strip_content_end, y2 + SEQ_STRIP_OFSBOTTOM); | immRectf(pos, x2, y2 + pixely, strip_content_end, y2 + SEQ_STRIP_OFSBOTTOM); | ||||
| /* Outline. */ immUniformColor3ubv(blend_col); | /* Outline. */ immUniformColor3ubv(blend_col); | ||||
| imm_draw_box_wire_2d(pos, x2, y2 + pixely, strip_content_end, y2 + SEQ_STRIP_OFSBOTTOM); | imm_draw_box_wire_2d(pos, x2, y2 + pixely, strip_content_end, y2 + SEQ_STRIP_OFSBOTTOM); | ||||
| } | } | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| static void draw_color_strip_band( | static void draw_color_strip_band(const VideoEdit *video_edit, | ||||
| const Scene *scene, ListBase *channels, Sequence *seq, uint pos, float text_margin_y, float y1) | ListBase *channels, | ||||
| Sequence *seq, | |||||
| uint pos, | |||||
| float text_margin_y, | |||||
| float y1) | |||||
| { | { | ||||
| uchar col[4]; | uchar col[4]; | ||||
| SolidColorVars *colvars = (SolidColorVars *)seq->effectdata; | SolidColorVars *colvars = (SolidColorVars *)seq->effectdata; | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| rgb_float_to_uchar(col, colvars->col); | rgb_float_to_uchar(col, colvars->col); | ||||
| /* Draw muted strips semi-transparent. */ | /* Draw muted strips semi-transparent. */ | ||||
| if (SEQ_render_is_muted(channels, seq)) { | if (SEQ_render_is_muted(channels, seq)) { | ||||
| col[3] = MUTE_ALPHA; | col[3] = MUTE_ALPHA; | ||||
| } | } | ||||
| /* Draw background semi-transparent when overlapping strips. */ | /* Draw background semi-transparent when overlapping strips. */ | ||||
| else if (seq->flag & SEQ_OVERLAP) { | else if (seq->flag & SEQ_OVERLAP) { | ||||
| col[3] = OVERLAP_ALPHA; | col[3] = OVERLAP_ALPHA; | ||||
| } | } | ||||
| else { | else { | ||||
| col[3] = 255; | col[3] = 255; | ||||
| } | } | ||||
| immUniformColor4ubv(col); | immUniformColor4ubv(col); | ||||
| immRectf(pos, | immRectf(pos, | ||||
| SEQ_time_left_handle_frame_get(scene, seq), | SEQ_time_left_handle_frame_get(video_edit, seq), | ||||
| y1, | y1, | ||||
| SEQ_time_right_handle_frame_get(scene, seq), | SEQ_time_right_handle_frame_get(video_edit, seq), | ||||
| text_margin_y); | text_margin_y); | ||||
| /* 1px line to better separate the color band. */ | /* 1px line to better separate the color band. */ | ||||
| UI_GetColorPtrShade3ubv(col, col, -20); | UI_GetColorPtrShade3ubv(col, col, -20); | ||||
| immUniformColor4ubv(col); | immUniformColor4ubv(col); | ||||
| immBegin(GPU_PRIM_LINES, 2); | immBegin(GPU_PRIM_LINES, 2); | ||||
| immVertex2f(pos, SEQ_time_left_handle_frame_get(scene, seq), text_margin_y); | immVertex2f(pos, SEQ_time_left_handle_frame_get(video_edit, seq), text_margin_y); | ||||
| immVertex2f(pos, SEQ_time_right_handle_frame_get(scene, seq), text_margin_y); | immVertex2f(pos, SEQ_time_right_handle_frame_get(video_edit, seq), text_margin_y); | ||||
| immEnd(); | immEnd(); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| static void draw_seq_background(Scene *scene, | static void draw_seq_background(VideoEdit *video_edit, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| uint pos, | uint pos, | ||||
| float x1, | float x1, | ||||
| float x2, | float x2, | ||||
| float y1, | float y1, | ||||
| float y2, | float y2, | ||||
| bool is_single_image, | bool is_single_image, | ||||
| bool show_strip_color_tag) | bool show_strip_color_tag) | ||||
| { | { | ||||
| Editing *ed = SEQ_editing_get(scene); | ListBase *channels = SEQ_channels_displayed_get(video_edit); | ||||
| ListBase *channels = SEQ_channels_displayed_get(ed); | |||||
| uchar col[4]; | uchar col[4]; | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| /* Get the correct color per strip type, transitions use their inputs ones. */ | /* Get the correct color per strip type, transitions use their inputs ones. */ | ||||
| if (ELEM(seq->type, SEQ_TYPE_CROSS, SEQ_TYPE_GAMCROSS, SEQ_TYPE_WIPE)) { | if (ELEM(seq->type, SEQ_TYPE_CROSS, SEQ_TYPE_GAMCROSS, SEQ_TYPE_WIPE)) { | ||||
| Sequence *seq1 = seq->seq1; | Sequence *seq1 = seq->seq1; | ||||
| if (seq1->type == SEQ_TYPE_COLOR) { | if (seq1->type == SEQ_TYPE_COLOR) { | ||||
| SolidColorVars *colvars = (SolidColorVars *)seq1->effectdata; | SolidColorVars *colvars = (SolidColorVars *)seq1->effectdata; | ||||
| rgb_float_to_uchar(col, colvars->col); | rgb_float_to_uchar(col, colvars->col); | ||||
| } | } | ||||
| else { | else { | ||||
| color3ubv_from_seq(scene, seq1, show_strip_color_tag, col); | color3ubv_from_seq(video_edit, seq1, show_strip_color_tag, col); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| color3ubv_from_seq(scene, seq, show_strip_color_tag, col); | color3ubv_from_seq(video_edit, seq, show_strip_color_tag, col); | ||||
| } | } | ||||
| /* Draw muted strips semi-transparent. */ | /* Draw muted strips semi-transparent. */ | ||||
| if (SEQ_render_is_muted(channels, seq)) { | if (SEQ_render_is_muted(channels, seq)) { | ||||
| col[3] = MUTE_ALPHA; | col[3] = MUTE_ALPHA; | ||||
| } | } | ||||
| /* Draw background semi-transparent when overlapping strips. */ | /* Draw background semi-transparent when overlapping strips. */ | ||||
| else if (seq->flag & SEQ_OVERLAP) { | else if (seq->flag & SEQ_OVERLAP) { | ||||
| col[3] = OVERLAP_ALPHA; | col[3] = OVERLAP_ALPHA; | ||||
| } | } | ||||
| else { | else { | ||||
| col[3] = 255; | col[3] = 255; | ||||
| } | } | ||||
| immUniformColor4ubv(col); | immUniformColor4ubv(col); | ||||
| /* Draw the main strip body. */ | /* Draw the main strip body. */ | ||||
| if (is_single_image) { | if (is_single_image) { | ||||
| immRectf(pos, | immRectf(pos, | ||||
| SEQ_time_left_handle_frame_get(scene, seq), | SEQ_time_left_handle_frame_get(video_edit, seq), | ||||
| y1, | y1, | ||||
| SEQ_time_right_handle_frame_get(scene, seq), | SEQ_time_right_handle_frame_get(video_edit, seq), | ||||
| y2); | y2); | ||||
| } | } | ||||
| else { | else { | ||||
| immRectf(pos, x1, y1, x2, y2); | immRectf(pos, x1, y1, x2, y2); | ||||
| } | } | ||||
| /* Draw background for hold still regions. */ | /* Draw background for hold still regions. */ | ||||
| if (!is_single_image) { | if (!is_single_image) { | ||||
| UI_GetColorPtrShade3ubv(col, col, -35); | UI_GetColorPtrShade3ubv(col, col, -35); | ||||
| immUniformColor4ubv(col); | immUniformColor4ubv(col); | ||||
| if (SEQ_time_has_left_still_frames(scene, seq)) { | if (SEQ_time_has_left_still_frames(video_edit, seq)) { | ||||
| float left_handle_frame = SEQ_time_left_handle_frame_get(scene, seq); | float left_handle_frame = SEQ_time_left_handle_frame_get(video_edit, seq); | ||||
| const float content_start = SEQ_time_start_frame_get(seq); | const float content_start = SEQ_time_start_frame_get(seq); | ||||
| immRectf(pos, left_handle_frame, y1, content_start, y2); | immRectf(pos, left_handle_frame, y1, content_start, y2); | ||||
| } | } | ||||
| if (SEQ_time_has_right_still_frames(scene, seq)) { | if (SEQ_time_has_right_still_frames(video_edit, seq)) { | ||||
| float right_handle_frame = SEQ_time_right_handle_frame_get(scene, seq); | float right_handle_frame = SEQ_time_right_handle_frame_get(video_edit, seq); | ||||
| const float content_end = SEQ_time_content_end_frame_get(scene, seq); | const float content_end = SEQ_time_content_end_frame_get(video_edit, seq); | ||||
| immRectf(pos, content_end, y1, right_handle_frame, y2); | immRectf(pos, content_end, y1, right_handle_frame, y2); | ||||
| } | } | ||||
| } | } | ||||
| /* Draw right half of transition strips. */ | /* Draw right half of transition strips. */ | ||||
| if (ELEM(seq->type, SEQ_TYPE_CROSS, SEQ_TYPE_GAMCROSS, SEQ_TYPE_WIPE)) { | if (ELEM(seq->type, SEQ_TYPE_CROSS, SEQ_TYPE_GAMCROSS, SEQ_TYPE_WIPE)) { | ||||
| float vert_pos[3][2]; | float vert_pos[3][2]; | ||||
| Sequence *seq1 = seq->seq1; | Sequence *seq1 = seq->seq1; | ||||
| Sequence *seq2 = seq->seq2; | Sequence *seq2 = seq->seq2; | ||||
| if (seq2->type == SEQ_TYPE_COLOR) { | if (seq2->type == SEQ_TYPE_COLOR) { | ||||
| SolidColorVars *colvars = (SolidColorVars *)seq2->effectdata; | SolidColorVars *colvars = (SolidColorVars *)seq2->effectdata; | ||||
| rgb_float_to_uchar(col, colvars->col); | rgb_float_to_uchar(col, colvars->col); | ||||
| } | } | ||||
| else { | else { | ||||
| color3ubv_from_seq(scene, seq2, show_strip_color_tag, col); | color3ubv_from_seq(video_edit, seq2, show_strip_color_tag, col); | ||||
| /* If the transition inputs are of the same type, draw the right side slightly darker. */ | /* If the transition inputs are of the same type, draw the right side slightly darker. */ | ||||
| if (seq1->type == seq2->type) { | if (seq1->type == seq2->type) { | ||||
| UI_GetColorPtrShade3ubv(col, col, -15); | UI_GetColorPtrShade3ubv(col, col, -15); | ||||
| } | } | ||||
| } | } | ||||
| immUniformColor4ubv(col); | immUniformColor4ubv(col); | ||||
| copy_v2_fl2(vert_pos[0], x1, y2); | copy_v2_fl2(vert_pos[0], x1, y2); | ||||
| Show All 38 Lines | static void draw_seq_invalid(float x1, float x2, float y2, float text_margin_y) | ||||
| immUniformColor4f(1.0f, 0.0f, 0.0f, 0.9f); | immUniformColor4f(1.0f, 0.0f, 0.0f, 0.9f); | ||||
| immRectf(pos, x1, y2, x2, text_margin_y); | immRectf(pos, x1, y2, x2, text_margin_y); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| static void calculate_seq_text_offsets( | static void calculate_seq_text_offsets( | ||||
| const Scene *scene, View2D *v2d, Sequence *seq, float *x1, float *x2, float pixelx) | const VideoEdit *video_edit, View2D *v2d, Sequence *seq, float *x1, float *x2, float pixelx) | ||||
| { | { | ||||
| const float handsize_clamped = sequence_handle_size_get_clamped(scene, seq, pixelx); | const float handsize_clamped = sequence_handle_size_get_clamped(video_edit, seq, pixelx); | ||||
| float text_margin = 2.0f * handsize_clamped; | float text_margin = 2.0f * handsize_clamped; | ||||
| *x1 += text_margin; | *x1 += text_margin; | ||||
| *x2 -= text_margin; | *x2 -= text_margin; | ||||
| float scroller_vert_xoffs = (V2D_SCROLL_HANDLE_WIDTH + SEQ_SCROLLER_TEXT_OFFSET) * pixelx; | float scroller_vert_xoffs = (V2D_SCROLL_HANDLE_WIDTH + SEQ_SCROLLER_TEXT_OFFSET) * pixelx; | ||||
| /* Info text on the strip. */ | /* Info text on the strip. */ | ||||
| Show All 29 Lines | static void fcurve_batch_add_verts(GPUVertBuf *vbo, | ||||
| *vert_count += 2; | *vert_count += 2; | ||||
| } | } | ||||
| /** | /** | ||||
| * Draw f-curves as darkened regions of the strip: | * Draw f-curves as darkened regions of the strip: | ||||
| * - Volume for sound strips. | * - Volume for sound strips. | ||||
| * - Opacity for the other types. | * - Opacity for the other types. | ||||
| */ | */ | ||||
| static void draw_seq_fcurve_overlay( | static void draw_seq_fcurve_overlay(VideoEdit *video_edit, | ||||
| Scene *scene, View2D *v2d, Sequence *seq, float x1, float y1, float x2, float y2, float pixelx) | View2D *v2d, | ||||
| Sequence *seq, | |||||
| float x1, | |||||
| float y1, | |||||
| float x2, | |||||
| float y2, | |||||
| float pixelx) | |||||
| { | { | ||||
| FCurve *fcu; | FCurve *fcu; | ||||
| if (seq->type == SEQ_TYPE_SOUND_RAM) { | if (seq->type == SEQ_TYPE_SOUND_RAM) { | ||||
| fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, NULL); | fcu = id_data_find_fcurve(&video_edit->id, seq, &RNA_Sequence, "volume", 0, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "blend_alpha", 0, NULL); | fcu = id_data_find_fcurve(&video_edit->id, seq, &RNA_Sequence, "blend_alpha", 0, NULL); | ||||
| } | } | ||||
| if (fcu && !BKE_fcurve_is_empty(fcu)) { | if (fcu && !BKE_fcurve_is_empty(fcu)) { | ||||
| /* Clamp curve evaluation to the editor's borders. */ | /* Clamp curve evaluation to the editor's borders. */ | ||||
| int eval_start = max_ff(x1, v2d->cur.xmin); | int eval_start = max_ff(x1, v2d->cur.xmin); | ||||
| int eval_end = min_ff(x2, v2d->cur.xmax + 1); | int eval_end = min_ff(x2, v2d->cur.xmax + 1); | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | if (fcu && !BKE_fcurve_is_empty(fcu)) { | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| GPU_batch_discard(batch); | GPU_batch_discard(batch); | ||||
| } | } | ||||
| } | } | ||||
| /* Draw visible strips. Bounds check are already made. */ | /* Draw visible strips. Bounds check are already made. */ | ||||
| static void draw_seq_strip(const bContext *C, | static void draw_seq_strip(const bContext *C, | ||||
| SpaceSeq *sseq, | SpaceSeq *sseq, | ||||
| Scene *scene, | VideoEdit *video_edit, | ||||
| ARegion *region, | ARegion *region, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| float pixelx, | float pixelx, | ||||
| bool seq_active) | bool seq_active) | ||||
| { | { | ||||
| Editing *ed = SEQ_editing_get(CTX_data_scene(C)); | ListBase *channels = SEQ_channels_displayed_get(video_edit); | ||||
| ListBase *channels = SEQ_channels_displayed_get(ed); | |||||
| View2D *v2d = ®ion->v2d; | View2D *v2d = ®ion->v2d; | ||||
| float x1, x2, y1, y2; | float x1, x2, y1, y2; | ||||
| const float handsize_clamped = sequence_handle_size_get_clamped(scene, seq, pixelx); | const float handsize_clamped = sequence_handle_size_get_clamped(video_edit, seq, pixelx); | ||||
| float pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); | float pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); | ||||
| /* Check if we are doing "solo preview". */ | /* Check if we are doing "solo preview". */ | ||||
| bool is_single_image = (char)SEQ_transform_single_image_check(seq); | bool is_single_image = (char)SEQ_transform_single_image_check(seq); | ||||
| /* Use the seq->color_tag to display the tag color. */ | /* Use the seq->color_tag to display the tag color. */ | ||||
| const bool show_strip_color_tag = (sseq->timeline_overlay.flag & | const bool show_strip_color_tag = (sseq->timeline_overlay.flag & | ||||
| SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG); | SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG); | ||||
| /* Draw strip body. */ | /* Draw strip body. */ | ||||
| x1 = SEQ_time_has_left_still_frames(scene, seq) ? SEQ_time_start_frame_get(seq) : | x1 = SEQ_time_has_left_still_frames(video_edit, seq) ? | ||||
| SEQ_time_left_handle_frame_get(scene, seq); | SEQ_time_start_frame_get(seq) : | ||||
| SEQ_time_left_handle_frame_get(video_edit, seq); | |||||
| y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; | y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; | ||||
| x2 = SEQ_time_has_right_still_frames(scene, seq) ? SEQ_time_content_end_frame_get(scene, seq) : | x2 = SEQ_time_has_right_still_frames(video_edit, seq) ? | ||||
| SEQ_time_right_handle_frame_get(scene, seq); | SEQ_time_content_end_frame_get(video_edit, seq) : | ||||
| SEQ_time_right_handle_frame_get(video_edit, seq); | |||||
| y2 = seq->machine + SEQ_STRIP_OFSTOP; | y2 = seq->machine + SEQ_STRIP_OFSTOP; | ||||
| /* Limit body to strip bounds. Meta strip can end up with content outside of strip range. */ | /* Limit body to strip bounds. Meta strip can end up with content outside of strip range. */ | ||||
| x1 = min_ff(x1, SEQ_time_right_handle_frame_get(scene, seq)); | x1 = min_ff(x1, SEQ_time_right_handle_frame_get(video_edit, seq)); | ||||
| x2 = max_ff(x2, SEQ_time_left_handle_frame_get(scene, seq)); | x2 = max_ff(x2, SEQ_time_left_handle_frame_get(video_edit, seq)); | ||||
| float text_margin_y; | float text_margin_y; | ||||
| bool y_threshold; | bool y_threshold; | ||||
| if ((sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_NAME) || | if ((sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_NAME) || | ||||
| (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_SOURCE) || | (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_SOURCE) || | ||||
| (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_DURATION)) { | (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_DURATION)) { | ||||
| /* Calculate height needed for drawing text on strip. */ | /* Calculate height needed for drawing text on strip. */ | ||||
| text_margin_y = y2 - min_ff(0.40f, 20 * U.dpi_fac * pixely); | text_margin_y = y2 - min_ff(0.40f, 20 * U.dpi_fac * pixely); | ||||
| /* Is there enough space for drawing something else than text? */ | /* Is there enough space for drawing something else than text? */ | ||||
| y_threshold = ((y2 - y1) / pixely) > 20 * U.dpi_fac; | y_threshold = ((y2 - y1) / pixely) > 20 * U.dpi_fac; | ||||
| } | } | ||||
| else { | else { | ||||
| text_margin_y = y2; | text_margin_y = y2; | ||||
| y_threshold = false; | y_threshold = false; | ||||
| } | } | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| draw_seq_background(scene, seq, pos, x1, x2, y1, y2, is_single_image, show_strip_color_tag); | draw_seq_background(video_edit, seq, pos, x1, x2, y1, y2, is_single_image, show_strip_color_tag); | ||||
| /* Draw a color band inside color strip. */ | /* Draw a color band inside color strip. */ | ||||
| if (seq->type == SEQ_TYPE_COLOR && y_threshold) { | if (seq->type == SEQ_TYPE_COLOR && y_threshold) { | ||||
| draw_color_strip_band(scene, channels, seq, pos, text_margin_y, y1); | draw_color_strip_band(video_edit, channels, seq, pos, text_margin_y, y1); | ||||
| } | } | ||||
| /* Draw strip offsets when flag is enabled or during "solo preview". */ | /* Draw strip offsets when flag is enabled or during "solo preview". */ | ||||
| if (sseq->flag & SEQ_SHOW_OVERLAY) { | if (sseq->flag & SEQ_SHOW_OVERLAY) { | ||||
| if (!is_single_image && pixely > 0) { | if (!is_single_image && pixely > 0) { | ||||
| if ((sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_OFFSETS) || | if ((sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_OFFSETS) || | ||||
| (seq == special_seq_update)) { | (seq == special_seq_update)) { | ||||
| draw_sequence_extensions_overlay(scene, seq, pos, pixely, show_strip_color_tag); | draw_sequence_extensions_overlay(video_edit, seq, pos, pixely, show_strip_color_tag); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| x1 = SEQ_time_left_handle_frame_get(scene, seq); | x1 = SEQ_time_left_handle_frame_get(video_edit, seq); | ||||
| x2 = SEQ_time_right_handle_frame_get(scene, seq); | x2 = SEQ_time_right_handle_frame_get(video_edit, seq); | ||||
| if ((seq->type == SEQ_TYPE_META) || | if ((seq->type == SEQ_TYPE_META) || | ||||
| ((seq->type == SEQ_TYPE_SCENE) && (seq->flag & SEQ_SCENE_STRIPS))) { | ((seq->type == SEQ_TYPE_SCENE) && (seq->flag & SEQ_SCENE_STRIPS))) { | ||||
| drawmeta_contents(scene, seq, x1, y1, x2, y2, show_strip_color_tag); | drawmeta_contents(video_edit, seq, x1, y1, x2, y2, show_strip_color_tag); | ||||
| } | } | ||||
| if ((sseq->flag & SEQ_SHOW_OVERLAY) && | if ((sseq->flag & SEQ_SHOW_OVERLAY) && | ||||
| (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_THUMBNAILS) && | (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_THUMBNAILS) && | ||||
| ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) { | ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) { | ||||
| draw_seq_strip_thumbnail( | draw_seq_strip_thumbnail( | ||||
| v2d, C, scene, seq, y1, y_threshold ? text_margin_y : y2, pixelx, pixely); | v2d, C, video_edit, seq, y1, y_threshold ? text_margin_y : y2, pixelx, pixely); | ||||
| } | } | ||||
| if ((sseq->flag & SEQ_SHOW_OVERLAY) && | if ((sseq->flag & SEQ_SHOW_OVERLAY) && | ||||
| (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_FCURVES)) { | (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_FCURVES)) { | ||||
| draw_seq_fcurve_overlay(scene, v2d, seq, x1, y1, x2, y2, pixelx); | draw_seq_fcurve_overlay(video_edit, v2d, seq, x1, y1, x2, y2, pixelx); | ||||
| } | } | ||||
| /* Draw sound strip waveform. */ | /* Draw sound strip waveform. */ | ||||
| if (seq_draw_waveforms_poll(C, sseq, seq)) { | if (seq_draw_waveforms_poll(C, sseq, seq)) { | ||||
| draw_seq_waveform_overlay( | draw_seq_waveform_overlay( | ||||
| C, region, seq, x1, y_threshold ? y1 + 0.05f : y1, x2, y_threshold ? text_margin_y : y2); | C, region, seq, x1, y_threshold ? y1 + 0.05f : y1, x2, y_threshold ? text_margin_y : y2); | ||||
| } | } | ||||
| /* Draw locked state. */ | /* Draw locked state. */ | ||||
| if (SEQ_transform_is_locked(channels, seq)) { | if (SEQ_transform_is_locked(channels, seq)) { | ||||
| draw_seq_locked(x1, y1, x2, y2); | draw_seq_locked(x1, y1, x2, y2); | ||||
| } | } | ||||
| /* Draw Red line on the top of invalid strip (Missing media). */ | /* Draw Red line on the top of invalid strip (Missing media). */ | ||||
| if (!SEQ_sequence_has_source(seq)) { | if (!SEQ_sequence_has_source(seq)) { | ||||
| draw_seq_invalid(x1, x2, y2, text_margin_y); | draw_seq_invalid(x1, x2, y2, text_margin_y); | ||||
| } | } | ||||
| pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| if (!SEQ_transform_is_locked(channels, seq)) { | if (!SEQ_transform_is_locked(channels, seq)) { | ||||
| draw_seq_handle( | draw_seq_handle(video_edit, | ||||
| scene, v2d, seq, handsize_clamped, SEQ_LEFTHANDLE, pos, seq_active, pixelx, y_threshold); | v2d, | ||||
| draw_seq_handle( | seq, | ||||
| scene, v2d, seq, handsize_clamped, SEQ_RIGHTHANDLE, pos, seq_active, pixelx, y_threshold); | handsize_clamped, | ||||
| SEQ_LEFTHANDLE, | |||||
| pos, | |||||
| seq_active, | |||||
| pixelx, | |||||
| y_threshold); | |||||
| draw_seq_handle(video_edit, | |||||
| v2d, | |||||
| seq, | |||||
| handsize_clamped, | |||||
| SEQ_RIGHTHANDLE, | |||||
| pos, | |||||
| seq_active, | |||||
| pixelx, | |||||
| y_threshold); | |||||
| } | } | ||||
| draw_seq_outline(scene, seq, pos, x1, x2, y1, y2, pixelx, pixely, seq_active); | draw_seq_outline(video_edit, seq, pos, x1, x2, y1, y2, pixelx, pixely, seq_active); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| calculate_seq_text_offsets(scene, v2d, seq, &x1, &x2, pixelx); | calculate_seq_text_offsets(video_edit, v2d, seq, &x1, &x2, pixelx); | ||||
| /* If a waveform is drawn, avoid drawing text when there is not enough vertical space. */ | /* If a waveform is drawn, avoid drawing text when there is not enough vertical space. */ | ||||
| if (seq->type == SEQ_TYPE_SOUND_RAM) { | if (seq->type == SEQ_TYPE_SOUND_RAM) { | ||||
| if (!y_threshold && (sseq->timeline_overlay.flag & SEQ_TIMELINE_NO_WAVEFORMS) == 0 && | if (!y_threshold && (sseq->timeline_overlay.flag & SEQ_TIMELINE_NO_WAVEFORMS) == 0 && | ||||
| ((sseq->timeline_overlay.flag & SEQ_TIMELINE_ALL_WAVEFORMS) || | ((sseq->timeline_overlay.flag & SEQ_TIMELINE_ALL_WAVEFORMS) || | ||||
| (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM))) { | (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM))) { | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| if (sseq->flag & SEQ_SHOW_OVERLAY) { | if (sseq->flag & SEQ_SHOW_OVERLAY) { | ||||
| /* Don't draw strip if there is not enough vertical or horizontal space. */ | /* Don't draw strip if there is not enough vertical or horizontal space. */ | ||||
| if (((x2 - x1) > 32 * pixelx * U.dpi_fac) && ((y2 - y1) > 8 * pixely * U.dpi_fac)) { | if (((x2 - x1) > 32 * pixelx * U.dpi_fac) && ((y2 - y1) > 8 * pixely * U.dpi_fac)) { | ||||
| /* Depending on the vertical space, draw text on top or in the center of strip. */ | /* Depending on the vertical space, draw text on top or in the center of strip. */ | ||||
| draw_seq_text_overlay( | draw_seq_text_overlay( | ||||
| scene, v2d, seq, sseq, x1, x2, y_threshold ? text_margin_y : y1, y2, seq_active); | video_edit, v2d, seq, sseq, x1, x2, y_threshold ? text_margin_y : y1, y2, seq_active); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void draw_effect_inputs_highlight(const Scene *scene, Sequence *seq) | static void draw_effect_inputs_highlight(const VideoEdit *video_edit, Sequence *seq) | ||||
| { | { | ||||
| Sequence *seq1 = seq->seq1; | Sequence *seq1 = seq->seq1; | ||||
| Sequence *seq2 = seq->seq2; | Sequence *seq2 = seq->seq2; | ||||
| Sequence *seq3 = seq->seq3; | Sequence *seq3 = seq->seq3; | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4ub(255, 255, 255, 48); | immUniformColor4ub(255, 255, 255, 48); | ||||
| immRectf(pos, | immRectf(pos, | ||||
| SEQ_time_left_handle_frame_get(scene, seq1), | SEQ_time_left_handle_frame_get(video_edit, seq1), | ||||
| seq1->machine + SEQ_STRIP_OFSBOTTOM, | seq1->machine + SEQ_STRIP_OFSBOTTOM, | ||||
| SEQ_time_right_handle_frame_get(scene, seq1), | SEQ_time_right_handle_frame_get(video_edit, seq1), | ||||
| seq1->machine + SEQ_STRIP_OFSTOP); | seq1->machine + SEQ_STRIP_OFSTOP); | ||||
| if (seq2 && seq2 != seq1) { | if (seq2 && seq2 != seq1) { | ||||
| immRectf(pos, | immRectf(pos, | ||||
| SEQ_time_left_handle_frame_get(scene, seq2), | SEQ_time_left_handle_frame_get(video_edit, seq2), | ||||
| seq2->machine + SEQ_STRIP_OFSBOTTOM, | seq2->machine + SEQ_STRIP_OFSBOTTOM, | ||||
| SEQ_time_right_handle_frame_get(scene, seq2), | SEQ_time_right_handle_frame_get(video_edit, seq2), | ||||
| seq2->machine + SEQ_STRIP_OFSTOP); | seq2->machine + SEQ_STRIP_OFSTOP); | ||||
| } | } | ||||
| if (seq3 && !ELEM(seq3, seq1, seq2)) { | if (seq3 && !ELEM(seq3, seq1, seq2)) { | ||||
| immRectf(pos, | immRectf(pos, | ||||
| SEQ_time_left_handle_frame_get(scene, seq3), | SEQ_time_left_handle_frame_get(video_edit, seq3), | ||||
| seq3->machine + SEQ_STRIP_OFSBOTTOM, | seq3->machine + SEQ_STRIP_OFSBOTTOM, | ||||
| SEQ_time_right_handle_frame_get(scene, seq3), | SEQ_time_right_handle_frame_get(video_edit, seq3), | ||||
| seq3->machine + SEQ_STRIP_OFSTOP); | seq3->machine + SEQ_STRIP_OFSTOP); | ||||
| } | } | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| void sequencer_special_update_set(Sequence *seq) | void sequencer_special_update_set(Sequence *seq) | ||||
| { | { | ||||
| special_seq_update = seq; | special_seq_update = seq; | ||||
| } | } | ||||
| Sequence *ED_sequencer_special_preview_get(void) | Sequence *ED_sequencer_special_preview_get(void) | ||||
| { | { | ||||
| return special_seq_update; | return special_seq_update; | ||||
| } | } | ||||
| void ED_sequencer_special_preview_set(bContext *C, const int mval[2]) | void ED_sequencer_special_preview_set(bContext *C, const int mval[2]) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| int hand; | int hand; | ||||
| Sequence *seq; | Sequence *seq; | ||||
| seq = find_nearest_seq(scene, ®ion->v2d, &hand, mval); | seq = find_nearest_seq(video_edit, ®ion->v2d, &hand, mval); | ||||
| sequencer_special_update_set(seq); | sequencer_special_update_set(seq); | ||||
| } | } | ||||
| void ED_sequencer_special_preview_clear(void) | void ED_sequencer_special_preview_clear(void) | ||||
| { | { | ||||
| sequencer_special_update_set(NULL); | sequencer_special_update_set(NULL); | ||||
| } | } | ||||
| ImBuf *sequencer_ibuf_get(struct Main *bmain, | ImBuf *sequencer_ibuf_get(struct Main *bmain, | ||||
| ARegion *region, | ARegion *region, | ||||
| struct Depsgraph *depsgraph, | struct Depsgraph *depsgraph, | ||||
| Scene *scene, | VideoEdit *video_edit, | ||||
| SpaceSeq *sseq, | SpaceSeq *sseq, | ||||
| int timeline_frame, | int timeline_frame, | ||||
| int frame_ofs, | int frame_ofs, | ||||
| const char *viewname) | const char *viewname) | ||||
| { | { | ||||
| SeqRenderData context = {0}; | SeqRenderData context = {0}; | ||||
| ImBuf *ibuf; | ImBuf *ibuf; | ||||
| int rectx, recty; | int rectx, recty; | ||||
| double render_size; | double render_size; | ||||
| short is_break = G.is_break; | short is_break = G.is_break; | ||||
| if (sseq->render_size == SEQ_RENDER_SIZE_NONE) { | if (sseq->render_size == SEQ_RENDER_SIZE_NONE) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (sseq->render_size == SEQ_RENDER_SIZE_SCENE) { | if (sseq->render_size == SEQ_RENDER_SIZE_VIDEO_EDIT) { | ||||
| render_size = scene->r.size / 100.0; | render_size = video_edit->r.size / 100.0; | ||||
| } | } | ||||
| else { | else { | ||||
| render_size = SEQ_rendersize_to_scale_factor(sseq->render_size); | render_size = SEQ_rendersize_to_scale_factor(sseq->render_size); | ||||
| } | } | ||||
| rectx = roundf(render_size * scene->r.xsch); | rectx = roundf(render_size * video_edit->r.xsch); | ||||
| recty = roundf(render_size * scene->r.ysch); | recty = roundf(render_size * video_edit->r.ysch); | ||||
| SEQ_render_new_render_data( | SEQ_render_new_render_data( | ||||
| bmain, depsgraph, scene, rectx, recty, sseq->render_size, false, &context); | bmain, depsgraph, video_edit, rectx, recty, sseq->render_size, false, &context); | ||||
| context.view_id = BKE_scene_multiview_view_id_get(&scene->r, viewname); | context.view_id = BKE_scene_multiview_view_id_get(&video_edit->r, viewname); | ||||
| context.use_proxies = (sseq->flag & SEQ_USE_PROXIES) != 0; | context.use_proxies = (sseq->flag & SEQ_USE_PROXIES) != 0; | ||||
| /* Sequencer could start rendering, in this case we need to be sure it wouldn't be canceled | /* Sequencer could start rendering, in this case we need to be sure it wouldn't be canceled | ||||
| * by Escape pressed somewhere in the past. */ | * by Escape pressed somewhere in the past. */ | ||||
| G.is_break = false; | G.is_break = false; | ||||
| GPUViewport *viewport = WM_draw_region_get_bound_viewport(region); | GPUViewport *viewport = WM_draw_region_get_bound_viewport(region); | ||||
| GPUFrameBuffer *fb = GPU_framebuffer_active_get(); | GPUFrameBuffer *fb = GPU_framebuffer_active_get(); | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | if (scopes->reference_ibuf != ibuf) { | ||||
| if (scopes->histogram_ibuf) { | if (scopes->histogram_ibuf) { | ||||
| IMB_freeImBuf(scopes->histogram_ibuf); | IMB_freeImBuf(scopes->histogram_ibuf); | ||||
| scopes->histogram_ibuf = NULL; | scopes->histogram_ibuf = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_fn)(ImBuf *ibuf)) | static ImBuf *sequencer_make_scope(VideoEdit *video_edit, | ||||
| ImBuf *ibuf, | |||||
| ImBuf *(*make_scope_fn)(ImBuf *ibuf)) | |||||
| { | { | ||||
| ImBuf *display_ibuf = IMB_dupImBuf(ibuf); | ImBuf *display_ibuf = IMB_dupImBuf(ibuf); | ||||
| ImBuf *scope; | ImBuf *scope; | ||||
| IMB_colormanagement_imbuf_make_display_space( | IMB_colormanagement_imbuf_make_display_space( | ||||
| display_ibuf, &scene->view_settings, &scene->display_settings); | display_ibuf, &video_edit->view_settings, &video_edit->display_settings); | ||||
| scope = make_scope_fn(display_ibuf); | scope = make_scope_fn(display_ibuf); | ||||
| IMB_freeImBuf(display_ibuf); | IMB_freeImBuf(display_ibuf); | ||||
| return scope; | return scope; | ||||
| } | } | ||||
| static void sequencer_display_size(Scene *scene, float r_viewrect[2]) | static void sequencer_display_size(VideoEdit *video_edit, float r_viewrect[2]) | ||||
| { | { | ||||
| r_viewrect[0] = (float)scene->r.xsch; | r_viewrect[0] = (float)video_edit->r.xsch; | ||||
| r_viewrect[1] = (float)scene->r.ysch; | r_viewrect[1] = (float)video_edit->r.ysch; | ||||
| r_viewrect[0] *= scene->r.xasp / scene->r.yasp; | r_viewrect[0] *= video_edit->r.xasp / video_edit->r.yasp; | ||||
| } | } | ||||
| static void sequencer_draw_gpencil_overlay(const bContext *C) | static void sequencer_draw_gpencil_overlay(const bContext *C) | ||||
| { | { | ||||
| /* Draw grease-pencil (image aligned). */ | /* Draw grease-pencil (image aligned). */ | ||||
| ED_annotation_draw_2dimage(C); | ED_annotation_draw_2dimage(C); | ||||
| /* Orthographic at pixel level. */ | /* Orthographic at pixel level. */ | ||||
| UI_view2d_view_restore(C); | UI_view2d_view_restore(C); | ||||
| /* Draw grease-pencil (screen aligned). */ | /* Draw grease-pencil (screen aligned). */ | ||||
| ED_annotation_draw_view2d(C, 0); | ED_annotation_draw_view2d(C, 0); | ||||
| } | } | ||||
| /** | /** | ||||
| * Draw content and safety borders. | * Draw content and safety borders. | ||||
| */ | */ | ||||
| static void sequencer_draw_borders_overlay(const SpaceSeq *sseq, | static void sequencer_draw_borders_overlay(const SpaceSeq *sseq, | ||||
| const View2D *v2d, | const View2D *v2d, | ||||
| const Scene *scene) | const VideoEdit *video_edit) | ||||
| { | { | ||||
| float x1 = v2d->tot.xmin; | float x1 = v2d->tot.xmin; | ||||
| float y1 = v2d->tot.ymin; | float y1 = v2d->tot.ymin; | ||||
| float x2 = v2d->tot.xmax; | float x2 = v2d->tot.xmax; | ||||
| float y2 = v2d->tot.ymax; | float y2 = v2d->tot.ymax; | ||||
| GPU_line_width(1.0f); | GPU_line_width(1.0f); | ||||
| Show All 20 Lines | if (sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_SAFE_MARGINS) { | ||||
| UI_draw_safe_areas(shdr_pos, | UI_draw_safe_areas(shdr_pos, | ||||
| &(const rctf){ | &(const rctf){ | ||||
| .xmin = x1, | .xmin = x1, | ||||
| .xmax = x2, | .xmax = x2, | ||||
| .ymin = y1, | .ymin = y1, | ||||
| .ymax = y2, | .ymax = y2, | ||||
| }, | }, | ||||
| scene->safe_areas.title, | video_edit->safe_areas.title, | ||||
| scene->safe_areas.action); | video_edit->safe_areas.action); | ||||
| if (sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_SAFE_CENTER) { | if (sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_SAFE_CENTER) { | ||||
| UI_draw_safe_areas(shdr_pos, | UI_draw_safe_areas(shdr_pos, | ||||
| &(const rctf){ | &(const rctf){ | ||||
| .xmin = x1, | .xmin = x1, | ||||
| .xmax = x2, | .xmax = x2, | ||||
| .ymin = y1, | .ymin = y1, | ||||
| .ymax = y2, | .ymax = y2, | ||||
| }, | }, | ||||
| scene->safe_areas.title_center, | video_edit->safe_areas.title_center, | ||||
| scene->safe_areas.action_center); | video_edit->safe_areas.action_center); | ||||
| } | } | ||||
| } | } | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| #if 0 | #if 0 | ||||
| void sequencer_draw_maskedit(const bContext *C, Scene *scene, ARegion *region, SpaceSeq *sseq) | void sequencer_draw_maskedit(const bContext *C, Scene *scene, ARegion *region, SpaceSeq *sseq) | ||||
| Show All 27 Lines | if (mask) { | ||||
| NULL, | NULL, | ||||
| C); | C); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| /* Force redraw, when prefetching and using cache view. */ | /* Force redraw, when prefetching and using cache view. */ | ||||
| static void seq_prefetch_wm_notify(const bContext *C, Scene *scene) | static void seq_prefetch_wm_notify(const bContext *C, VideoEdit *video_edit) | ||||
| { | { | ||||
| if (SEQ_prefetch_need_redraw(CTX_data_main(C), scene)) { | if (SEQ_prefetch_need_redraw(CTX_data_main(C), video_edit)) { | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, NULL); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, NULL); | ||||
| } | } | ||||
| } | } | ||||
| static void *sequencer_OCIO_transform_ibuf(const bContext *C, | static void *sequencer_OCIO_transform_ibuf(const bContext *C, | ||||
| ImBuf *ibuf, | ImBuf *ibuf, | ||||
| bool *r_glsl_used, | bool *r_glsl_used, | ||||
| eGPUTextureFormat *r_format, | eGPUTextureFormat *r_format, | ||||
| eGPUDataFormat *r_data, | eGPUDataFormat *r_data, | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | if ((ibuf->rect || ibuf->rect_float) && !*r_glsl_used) { | ||||
| display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, r_buffer_cache_handle); | display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, r_buffer_cache_handle); | ||||
| *r_format = GPU_RGBA8; | *r_format = GPU_RGBA8; | ||||
| *r_data = GPU_DATA_UBYTE; | *r_data = GPU_DATA_UBYTE; | ||||
| } | } | ||||
| return display_buffer; | return display_buffer; | ||||
| } | } | ||||
| static void sequencer_stop_running_jobs(const bContext *C, Scene *scene) | static void sequencer_stop_running_jobs(const bContext *C, VideoEdit *video_edit) | ||||
| { | { | ||||
| if (G.is_rendering == false && (scene->r.seq_prev_type) == OB_RENDER) { | if (G.is_rendering == false && (video_edit->r.seq_prev_type) == OB_RENDER) { | ||||
| /* Stop all running jobs, except screen one. Currently previews frustrate Render. | /* Stop all running jobs, except screen one. Currently previews frustrate Render. | ||||
| * Need to make so sequencers rendering doesn't conflict with compositor. */ | * Need to make so sequencers rendering doesn't conflict with compositor. */ | ||||
| WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_COMPOSITE); | WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_COMPOSITE); | ||||
| /* In case of final rendering used for preview, kill all previews, | /* In case of final rendering used for preview, kill all previews, | ||||
| * otherwise threading conflict will happen in rendering module. */ | * otherwise threading conflict will happen in rendering module. */ | ||||
| WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_RENDER_PREVIEW); | WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_RENDER_PREVIEW); | ||||
| } | } | ||||
| } | } | ||||
| static void sequencer_preview_clear(void) | static void sequencer_preview_clear(void) | ||||
| { | { | ||||
| UI_ThemeClearColor(TH_SEQ_PREVIEW); | UI_ThemeClearColor(TH_SEQ_PREVIEW); | ||||
| } | } | ||||
| static void sequencer_preview_get_rect(rctf *preview, | static void sequencer_preview_get_rect(rctf *preview, | ||||
| Scene *scene, | VideoEdit *video_edit, | ||||
| ARegion *region, | ARegion *region, | ||||
| SpaceSeq *sseq, | SpaceSeq *sseq, | ||||
| bool draw_overlay, | bool draw_overlay, | ||||
| bool draw_backdrop) | bool draw_backdrop) | ||||
| { | { | ||||
| struct View2D *v2d = ®ion->v2d; | struct View2D *v2d = ®ion->v2d; | ||||
| float viewrect[2]; | float viewrect[2]; | ||||
| sequencer_display_size(scene, viewrect); | sequencer_display_size(video_edit, viewrect); | ||||
| BLI_rctf_init(preview, -1.0f, 1.0f, -1.0f, 1.0f); | BLI_rctf_init(preview, -1.0f, 1.0f, -1.0f, 1.0f); | ||||
| if (draw_overlay && (sseq->overlay_frame_type == SEQ_OVERLAY_FRAME_TYPE_RECT)) { | if (draw_overlay && (sseq->overlay_frame_type == SEQ_OVERLAY_FRAME_TYPE_RECT)) { | ||||
| preview->xmax = v2d->tot.xmin + | preview->xmax = v2d->tot.xmin + | ||||
| (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->overlay_frame_rect.xmax); | (fabsf(BLI_rctf_size_x(&v2d->tot)) * video_edit->overlay_frame_rect.xmax); | ||||
| preview->xmin = v2d->tot.xmin + | preview->xmin = v2d->tot.xmin + | ||||
| (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->overlay_frame_rect.xmin); | (fabsf(BLI_rctf_size_x(&v2d->tot)) * video_edit->overlay_frame_rect.xmin); | ||||
| preview->ymax = v2d->tot.ymin + | preview->ymax = v2d->tot.ymin + | ||||
| (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->overlay_frame_rect.ymax); | (fabsf(BLI_rctf_size_y(&v2d->tot)) * video_edit->overlay_frame_rect.ymax); | ||||
| preview->ymin = v2d->tot.ymin + | preview->ymin = v2d->tot.ymin + | ||||
| (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->overlay_frame_rect.ymin); | (fabsf(BLI_rctf_size_y(&v2d->tot)) * video_edit->overlay_frame_rect.ymin); | ||||
| } | } | ||||
| else if (draw_backdrop) { | else if (draw_backdrop) { | ||||
| float aspect = BLI_rcti_size_x(®ion->winrct) / (float)BLI_rcti_size_y(®ion->winrct); | float aspect = BLI_rcti_size_x(®ion->winrct) / (float)BLI_rcti_size_y(®ion->winrct); | ||||
| float image_aspect = viewrect[0] / viewrect[1]; | float image_aspect = viewrect[0] / viewrect[1]; | ||||
| if (aspect >= image_aspect) { | if (aspect >= image_aspect) { | ||||
| preview->xmax = image_aspect / aspect; | preview->xmax = image_aspect / aspect; | ||||
| preview->xmin = -preview->xmax; | preview->xmin = -preview->xmax; | ||||
| } | } | ||||
| else { | else { | ||||
| preview->ymax = aspect / image_aspect; | preview->ymax = aspect / image_aspect; | ||||
| preview->ymin = -preview->ymax; | preview->ymin = -preview->ymax; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| *preview = v2d->tot; | *preview = v2d->tot; | ||||
| } | } | ||||
| } | } | ||||
| static void sequencer_draw_display_buffer(const bContext *C, | static void sequencer_draw_display_buffer(const bContext *C, | ||||
| Scene *scene, | VideoEdit *video_edit, | ||||
| ARegion *region, | ARegion *region, | ||||
| SpaceSeq *sseq, | SpaceSeq *sseq, | ||||
| ImBuf *ibuf, | ImBuf *ibuf, | ||||
| ImBuf *scope, | ImBuf *scope, | ||||
| bool draw_overlay, | bool draw_overlay, | ||||
| bool draw_backdrop) | bool draw_backdrop) | ||||
| { | { | ||||
| void *display_buffer; | void *display_buffer; | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if (!glsl_used) { | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_IMAGE_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_IMAGE_COLOR); | ||||
| immUniformColor3f(1.0f, 1.0f, 1.0f); | immUniformColor3f(1.0f, 1.0f, 1.0f); | ||||
| } | } | ||||
| immBegin(GPU_PRIM_TRI_FAN, 4); | immBegin(GPU_PRIM_TRI_FAN, 4); | ||||
| rctf preview; | rctf preview; | ||||
| rctf canvas; | rctf canvas; | ||||
| sequencer_preview_get_rect(&preview, scene, region, sseq, draw_overlay, draw_backdrop); | sequencer_preview_get_rect(&preview, video_edit, region, sseq, draw_overlay, draw_backdrop); | ||||
| if (draw_overlay && (sseq->overlay_frame_type == SEQ_OVERLAY_FRAME_TYPE_RECT)) { | if (draw_overlay && (sseq->overlay_frame_type == SEQ_OVERLAY_FRAME_TYPE_RECT)) { | ||||
| canvas = scene->ed->overlay_frame_rect; | canvas = video_edit->overlay_frame_rect; | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_rctf_init(&canvas, 0.0f, 1.0f, 0.0f, 1.0f); | BLI_rctf_init(&canvas, 0.0f, 1.0f, 0.0f, 1.0f); | ||||
| } | } | ||||
| immAttr2f(texCoord, canvas.xmin, canvas.ymin); | immAttr2f(texCoord, canvas.xmin, canvas.ymin); | ||||
| immVertex2f(pos, preview.xmin, preview.ymin); | immVertex2f(pos, preview.xmin, preview.ymin); | ||||
| Show All 27 Lines | static void sequencer_draw_display_buffer(const bContext *C, | ||||
| } | } | ||||
| if (draw_backdrop) { | if (draw_backdrop) { | ||||
| GPU_matrix_pop(); | GPU_matrix_pop(); | ||||
| GPU_matrix_pop_projection(); | GPU_matrix_pop_projection(); | ||||
| } | } | ||||
| } | } | ||||
| static ImBuf *sequencer_get_scope(Scene *scene, SpaceSeq *sseq, ImBuf *ibuf, bool draw_backdrop) | static ImBuf *sequencer_get_scope(VideoEdit *video_edit, | ||||
| SpaceSeq *sseq, | |||||
| ImBuf *ibuf, | |||||
| bool draw_backdrop) | |||||
| { | { | ||||
| struct ImBuf *scope = NULL; | struct ImBuf *scope = NULL; | ||||
| SequencerScopes *scopes = &sseq->scopes; | SequencerScopes *scopes = &sseq->scopes; | ||||
| if (!draw_backdrop && (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0)) { | if (!draw_backdrop && (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0)) { | ||||
| sequencer_check_scopes(scopes, ibuf); | sequencer_check_scopes(scopes, ibuf); | ||||
| switch (sseq->mainb) { | switch (sseq->mainb) { | ||||
| case SEQ_DRAW_IMG_IMBUF: | case SEQ_DRAW_IMG_IMBUF: | ||||
| if (!scopes->zebra_ibuf) { | if (!scopes->zebra_ibuf) { | ||||
| ImBuf *display_ibuf = IMB_dupImBuf(ibuf); | ImBuf *display_ibuf = IMB_dupImBuf(ibuf); | ||||
| if (display_ibuf->rect_float) { | if (display_ibuf->rect_float) { | ||||
| IMB_colormanagement_imbuf_make_display_space( | IMB_colormanagement_imbuf_make_display_space( | ||||
| display_ibuf, &scene->view_settings, &scene->display_settings); | display_ibuf, &video_edit->view_settings, &video_edit->display_settings); | ||||
| } | } | ||||
| scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra); | scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra); | ||||
| IMB_freeImBuf(display_ibuf); | IMB_freeImBuf(display_ibuf); | ||||
| } | } | ||||
| scope = scopes->zebra_ibuf; | scope = scopes->zebra_ibuf; | ||||
| break; | break; | ||||
| case SEQ_DRAW_IMG_WAVEFORM: | case SEQ_DRAW_IMG_WAVEFORM: | ||||
| if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) { | if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) { | ||||
| if (!scopes->sep_waveform_ibuf) { | if (!scopes->sep_waveform_ibuf) { | ||||
| scopes->sep_waveform_ibuf = sequencer_make_scope( | scopes->sep_waveform_ibuf = sequencer_make_scope( | ||||
| scene, ibuf, make_sep_waveform_view_from_ibuf); | video_edit, ibuf, make_sep_waveform_view_from_ibuf); | ||||
| } | } | ||||
| scope = scopes->sep_waveform_ibuf; | scope = scopes->sep_waveform_ibuf; | ||||
| } | } | ||||
| else { | else { | ||||
| if (!scopes->waveform_ibuf) { | if (!scopes->waveform_ibuf) { | ||||
| scopes->waveform_ibuf = sequencer_make_scope( | scopes->waveform_ibuf = sequencer_make_scope( | ||||
| scene, ibuf, make_waveform_view_from_ibuf); | video_edit, ibuf, make_waveform_view_from_ibuf); | ||||
| } | } | ||||
| scope = scopes->waveform_ibuf; | scope = scopes->waveform_ibuf; | ||||
| } | } | ||||
| break; | break; | ||||
| case SEQ_DRAW_IMG_VECTORSCOPE: | case SEQ_DRAW_IMG_VECTORSCOPE: | ||||
| if (!scopes->vector_ibuf) { | if (!scopes->vector_ibuf) { | ||||
| scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf); | scopes->vector_ibuf = sequencer_make_scope( | ||||
| video_edit, ibuf, make_vectorscope_view_from_ibuf); | |||||
| } | } | ||||
| scope = scopes->vector_ibuf; | scope = scopes->vector_ibuf; | ||||
| break; | break; | ||||
| case SEQ_DRAW_IMG_HISTOGRAM: | case SEQ_DRAW_IMG_HISTOGRAM: | ||||
| if (!scopes->histogram_ibuf) { | if (!scopes->histogram_ibuf) { | ||||
| scopes->histogram_ibuf = sequencer_make_scope( | scopes->histogram_ibuf = sequencer_make_scope( | ||||
| scene, ibuf, make_histogram_view_from_ibuf); | video_edit, ibuf, make_histogram_view_from_ibuf); | ||||
| } | } | ||||
| scope = scopes->histogram_ibuf; | scope = scopes->histogram_ibuf; | ||||
| break; | break; | ||||
| } | } | ||||
| /* Future files may have new scopes we don't catch above. */ | /* Future files may have new scopes we don't catch above. */ | ||||
| if (scope) { | if (scope) { | ||||
| scopes->reference_ibuf = ibuf; | scopes->reference_ibuf = ibuf; | ||||
| } | } | ||||
| } | } | ||||
| return scope; | return scope; | ||||
| } | } | ||||
| static bool sequencer_draw_get_transform_preview(SpaceSeq *sseq, Scene *scene) | static bool sequencer_draw_get_transform_preview(SpaceSeq *sseq, VideoEdit *video_edit) | ||||
| { | { | ||||
| Sequence *last_seq = SEQ_select_active_get(scene); | Sequence *last_seq = SEQ_select_active_get(video_edit); | ||||
| if (last_seq == NULL) { | if (last_seq == NULL) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return (G.moving & G_TRANSFORM_SEQ) && (last_seq->flag & SELECT) && | return (G.moving & G_TRANSFORM_SEQ) && (last_seq->flag & SELECT) && | ||||
| ((last_seq->flag & SEQ_LEFTSEL) || (last_seq->flag & SEQ_RIGHTSEL)) && | ((last_seq->flag & SEQ_LEFTSEL) || (last_seq->flag & SEQ_RIGHTSEL)) && | ||||
| (sseq->draw_flag & SEQ_DRAW_TRANSFORM_PREVIEW); | (sseq->draw_flag & SEQ_DRAW_TRANSFORM_PREVIEW); | ||||
| } | } | ||||
| static int sequencer_draw_get_transform_preview_frame(Scene *scene) | static int sequencer_draw_get_transform_preview_frame(VideoEdit *video_edit) | ||||
| { | { | ||||
| Sequence *last_seq = SEQ_select_active_get(scene); | Sequence *last_seq = SEQ_select_active_get(video_edit); | ||||
| /* #sequencer_draw_get_transform_preview must already have been called. */ | /* #sequencer_draw_get_transform_preview must already have been called. */ | ||||
| BLI_assert(last_seq != NULL); | BLI_assert(last_seq != NULL); | ||||
| int preview_frame; | int preview_frame; | ||||
| if (last_seq->flag & SEQ_RIGHTSEL) { | if (last_seq->flag & SEQ_RIGHTSEL) { | ||||
| preview_frame = SEQ_time_right_handle_frame_get(scene, last_seq) - 1; | preview_frame = SEQ_time_right_handle_frame_get(video_edit, last_seq) - 1; | ||||
| } | } | ||||
| else { | else { | ||||
| preview_frame = SEQ_time_left_handle_frame_get(scene, last_seq); | preview_frame = SEQ_time_left_handle_frame_get(video_edit, last_seq); | ||||
| } | } | ||||
| return preview_frame; | return preview_frame; | ||||
| } | } | ||||
| static void seq_draw_image_origin_and_outline(const bContext *C, Sequence *seq, bool is_active_seq) | static void seq_draw_image_origin_and_outline(const bContext *C, Sequence *seq, bool is_active_seq) | ||||
| { | { | ||||
| SpaceSeq *sseq = CTX_wm_space_seq(C); | SpaceSeq *sseq = CTX_wm_space_seq(C); | ||||
| Show All 11 Lines | if ((sseq->flag & SEQ_SHOW_OVERLAY) == 0 || | ||||
| (sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_OUTLINE_SELECTED) == 0) { | (sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_OUTLINE_SELECTED) == 0) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (ELEM(sseq->mainb, SEQ_DRAW_IMG_WAVEFORM, SEQ_DRAW_IMG_VECTORSCOPE, SEQ_DRAW_IMG_HISTOGRAM)) { | if (ELEM(sseq->mainb, SEQ_DRAW_IMG_WAVEFORM, SEQ_DRAW_IMG_VECTORSCOPE, SEQ_DRAW_IMG_HISTOGRAM)) { | ||||
| return; | return; | ||||
| } | } | ||||
| float origin[2]; | float origin[2]; | ||||
| SEQ_image_transform_origin_offset_pixelspace_get(CTX_data_scene(C), seq, origin); | SEQ_image_transform_origin_offset_pixelspace_get(CTX_data_video_edit(C), seq, origin); | ||||
| /* Origin. */ | /* Origin. */ | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA); | immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA); | ||||
| immUniform1f("outlineWidth", 1.5f); | immUniform1f("outlineWidth", 1.5f); | ||||
| immUniformColor3f(1.0f, 1.0f, 1.0f); | immUniformColor3f(1.0f, 1.0f, 1.0f); | ||||
| immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 1.0f); | immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 1.0f); | ||||
| immUniform1f("size", 15.0f * U.pixelsize); | immUniform1f("size", 15.0f * U.pixelsize); | ||||
| immBegin(GPU_PRIM_POINTS, 1); | immBegin(GPU_PRIM_POINTS, 1); | ||||
| immVertex2f(pos, origin[0], origin[1]); | immVertex2f(pos, origin[0], origin[1]); | ||||
| immEnd(); | immEnd(); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| /* Outline. */ | /* Outline. */ | ||||
| float seq_image_quad[4][2]; | float seq_image_quad[4][2]; | ||||
| SEQ_image_transform_final_quad_get(CTX_data_scene(C), seq, seq_image_quad); | SEQ_image_transform_final_quad_get(CTX_data_video_edit(C), seq, seq_image_quad); | ||||
| GPU_line_smooth(true); | GPU_line_smooth(true); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| GPU_line_width(2); | GPU_line_width(2); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| float col[3]; | float col[3]; | ||||
| if (is_active_seq) { | if (is_active_seq) { | ||||
| Show All 12 Lines | static void seq_draw_image_origin_and_outline(const bContext *C, Sequence *seq, bool is_active_seq) | ||||
| immEnd(); | immEnd(); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| GPU_line_width(1); | GPU_line_width(1); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| GPU_line_smooth(false); | GPU_line_smooth(false); | ||||
| } | } | ||||
| void sequencer_draw_preview(const bContext *C, | void sequencer_draw_preview(const bContext *C, | ||||
| Scene *scene, | VideoEdit *video_edit, | ||||
| ARegion *region, | ARegion *region, | ||||
| SpaceSeq *sseq, | SpaceSeq *sseq, | ||||
| int timeline_frame, | int timeline_frame, | ||||
| int offset, | int offset, | ||||
| bool draw_overlay, | bool draw_overlay, | ||||
| bool draw_backdrop) | bool draw_backdrop) | ||||
| { | { | ||||
| struct Main *bmain = CTX_data_main(C); | struct Main *bmain = CTX_data_main(C); | ||||
| struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); | struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); | ||||
| struct View2D *v2d = ®ion->v2d; | struct View2D *v2d = ®ion->v2d; | ||||
| struct ImBuf *ibuf = NULL; | struct ImBuf *ibuf = NULL; | ||||
| struct ImBuf *scope = NULL; | struct ImBuf *scope = NULL; | ||||
| float viewrect[2]; | float viewrect[2]; | ||||
| const bool show_imbuf = ED_space_sequencer_check_show_imbuf(sseq); | const bool show_imbuf = ED_space_sequencer_check_show_imbuf(sseq); | ||||
| const bool draw_gpencil = ((sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_GPENCIL) && sseq->gpd); | const bool draw_gpencil = ((sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_GPENCIL) && sseq->gpd); | ||||
| const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; | const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; | ||||
| sequencer_stop_running_jobs(C, scene); | sequencer_stop_running_jobs(C, video_edit); | ||||
| if (G.is_rendering) { | if (G.is_rendering) { | ||||
| return; | return; | ||||
| } | } | ||||
| int preview_frame = timeline_frame; | int preview_frame = timeline_frame; | ||||
| if (sequencer_draw_get_transform_preview(sseq, scene)) { | if (sequencer_draw_get_transform_preview(sseq, video_edit)) { | ||||
| preview_frame = sequencer_draw_get_transform_preview_frame(scene); | preview_frame = sequencer_draw_get_transform_preview_frame(video_edit); | ||||
| } | } | ||||
| /* Get image. */ | /* Get image. */ | ||||
| ibuf = sequencer_ibuf_get( | ibuf = sequencer_ibuf_get(bmain, | ||||
| bmain, region, depsgraph, scene, sseq, preview_frame, offset, names[sseq->multiview_eye]); | region, | ||||
| depsgraph, | |||||
| video_edit, | |||||
| sseq, | |||||
| preview_frame, | |||||
| offset, | |||||
| names[sseq->multiview_eye]); | |||||
| /* Setup off-screen buffers. */ | /* Setup off-screen buffers. */ | ||||
| GPUViewport *viewport = WM_draw_region_get_viewport(region); | GPUViewport *viewport = WM_draw_region_get_viewport(region); | ||||
| GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport); | GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport); | ||||
| GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | ||||
| GPU_depth_test(GPU_DEPTH_NONE); | GPU_depth_test(GPU_DEPTH_NONE); | ||||
| if (sseq->render_size == SEQ_RENDER_SIZE_NONE) { | if (sseq->render_size == SEQ_RENDER_SIZE_NONE) { | ||||
| sequencer_preview_clear(); | sequencer_preview_clear(); | ||||
| return; | return; | ||||
| } | } | ||||
| /* Setup view. */ | /* Setup view. */ | ||||
| sequencer_display_size(scene, viewrect); | sequencer_display_size(video_edit, viewrect); | ||||
| UI_view2d_totRect_set(v2d, roundf(viewrect[0] + 0.5f), roundf(viewrect[1] + 0.5f)); | UI_view2d_totRect_set(v2d, roundf(viewrect[0] + 0.5f), roundf(viewrect[1] + 0.5f)); | ||||
| UI_view2d_curRect_validate(v2d); | UI_view2d_curRect_validate(v2d); | ||||
| UI_view2d_view_ortho(v2d); | UI_view2d_view_ortho(v2d); | ||||
| /* Draw background. */ | /* Draw background. */ | ||||
| if (!draw_backdrop && | if (!draw_backdrop && | ||||
| (!draw_overlay || (sseq->overlay_frame_type == SEQ_OVERLAY_FRAME_TYPE_REFERENCE))) { | (!draw_overlay || (sseq->overlay_frame_type == SEQ_OVERLAY_FRAME_TYPE_REFERENCE))) { | ||||
| sequencer_preview_clear(); | sequencer_preview_clear(); | ||||
| if (sseq->flag & SEQ_USE_ALPHA) { | if (sseq->flag & SEQ_USE_ALPHA) { | ||||
| imm_draw_box_checker_2d(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax); | imm_draw_box_checker_2d(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax); | ||||
| } | } | ||||
| } | } | ||||
| if (ibuf) { | if (ibuf) { | ||||
| scope = sequencer_get_scope(scene, sseq, ibuf, draw_backdrop); | scope = sequencer_get_scope(video_edit, sseq, ibuf, draw_backdrop); | ||||
| /* Draw image. */ | /* Draw image. */ | ||||
| sequencer_draw_display_buffer( | sequencer_draw_display_buffer( | ||||
| C, scene, region, sseq, ibuf, scope, draw_overlay, draw_backdrop); | C, video_edit, region, sseq, ibuf, scope, draw_overlay, draw_backdrop); | ||||
| /* Draw over image. */ | /* Draw over image. */ | ||||
| if (sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_METADATA && sseq->flag & SEQ_SHOW_OVERLAY) { | if (sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_METADATA && sseq->flag & SEQ_SHOW_OVERLAY) { | ||||
| ED_region_image_metadata_draw(0.0, 0.0, ibuf, &v2d->tot, 1.0, 1.0); | ED_region_image_metadata_draw(0.0, 0.0, ibuf, &v2d->tot, 1.0, 1.0); | ||||
| } | } | ||||
| } | } | ||||
| if (show_imbuf && (sseq->flag & SEQ_SHOW_OVERLAY)) { | if (show_imbuf && (sseq->flag & SEQ_SHOW_OVERLAY)) { | ||||
| sequencer_draw_borders_overlay(sseq, v2d, scene); | sequencer_draw_borders_overlay(sseq, v2d, video_edit); | ||||
| } | } | ||||
| if (!draw_backdrop && scene->ed != NULL) { | if (!draw_backdrop) { | ||||
| Editing *ed = SEQ_editing_get(scene); | ListBase *channels = SEQ_channels_displayed_get(video_edit); | ||||
| ListBase *channels = SEQ_channels_displayed_get(ed); | |||||
| SeqCollection *collection = SEQ_query_rendered_strips( | SeqCollection *collection = SEQ_query_rendered_strips( | ||||
| scene, channels, ed->seqbasep, timeline_frame, 0); | video_edit, channels, video_edit->seqbasep, timeline_frame, 0); | ||||
| Sequence *seq; | Sequence *seq; | ||||
| Sequence *active_seq = SEQ_select_active_get(scene); | Sequence *active_seq = SEQ_select_active_get(video_edit); | ||||
| SEQ_ITERATOR_FOREACH (seq, collection) { | SEQ_ITERATOR_FOREACH (seq, collection) { | ||||
| seq_draw_image_origin_and_outline(C, seq, seq == active_seq); | seq_draw_image_origin_and_outline(C, seq, seq == active_seq); | ||||
| } | } | ||||
| SEQ_collection_free(collection); | SEQ_collection_free(collection); | ||||
| } | } | ||||
| if (draw_gpencil && show_imbuf && (sseq->flag & SEQ_SHOW_OVERLAY)) { | if (draw_gpencil && show_imbuf && (sseq->flag & SEQ_SHOW_OVERLAY)) { | ||||
| sequencer_draw_gpencil_overlay(C); | sequencer_draw_gpencil_overlay(C); | ||||
| Show All 9 Lines | #endif | ||||
| GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | ||||
| /* Scope is freed in sequencer_check_scopes when `ibuf` changes and redraw is needed. */ | /* Scope is freed in sequencer_check_scopes when `ibuf` changes and redraw is needed. */ | ||||
| if (ibuf) { | if (ibuf) { | ||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| } | } | ||||
| UI_view2d_view_restore(C); | UI_view2d_view_restore(C); | ||||
| seq_prefetch_wm_notify(C, scene); | seq_prefetch_wm_notify(C, video_edit); | ||||
| } | } | ||||
| static void draw_seq_timeline_channels(View2D *v2d) | static void draw_seq_timeline_channels(View2D *v2d) | ||||
| { | { | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| immUniformThemeColor(TH_ROW_ALTERNATE); | immUniformThemeColor(TH_ROW_ALTERNATE); | ||||
| /* Alternating horizontal stripes. */ | /* Alternating horizontal stripes. */ | ||||
| int i = max_ii(1, ((int)v2d->cur.ymin) - 1); | int i = max_ii(1, ((int)v2d->cur.ymin) - 1); | ||||
| while (i < v2d->cur.ymax) { | while (i < v2d->cur.ymax) { | ||||
| if (i & 1) { | if (i & 1) { | ||||
| immRectf(pos, v2d->cur.xmin, i, v2d->cur.xmax, i + 1); | immRectf(pos, v2d->cur.xmin, i, v2d->cur.xmax, i + 1); | ||||
| } | } | ||||
| i++; | i++; | ||||
| } | } | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region) | static void draw_seq_strips(const bContext *C, VideoEdit *video_edit, ARegion *region) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | |||||
| View2D *v2d = ®ion->v2d; | View2D *v2d = ®ion->v2d; | ||||
| SpaceSeq *sseq = CTX_wm_space_seq(C); | SpaceSeq *sseq = CTX_wm_space_seq(C); | ||||
| Sequence *last_seq = SEQ_select_active_get(scene); | Sequence *last_seq = SEQ_select_active_get(video_edit); | ||||
| int sel = 0, j; | int sel = 0, j; | ||||
| float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); | float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); | ||||
| /* Loop through twice, first unselected, then selected. */ | /* Loop through twice, first unselected, then selected. */ | ||||
| for (j = 0; j < 2; j++) { | for (j = 0; j < 2; j++) { | ||||
| Sequence *seq; | Sequence *seq; | ||||
| /* Loop through strips, checking for those that are visible. */ | /* Loop through strips, checking for those that are visible. */ | ||||
| for (seq = ed->seqbasep->first; seq; seq = seq->next) { | for (seq = video_edit->seqbasep->first; seq; seq = seq->next) { | ||||
| /* Bound-box and selection tests for NOT drawing the strip. */ | /* Bound-box and selection tests for NOT drawing the strip. */ | ||||
| if ((seq->flag & SELECT) != sel) { | if ((seq->flag & SELECT) != sel) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (seq == last_seq && (last_seq->flag & SELECT)) { | if (seq == last_seq && (last_seq->flag & SELECT)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (min_ii(SEQ_time_left_handle_frame_get(scene, seq), SEQ_time_start_frame_get(seq)) > | if (min_ii(SEQ_time_left_handle_frame_get(video_edit, seq), SEQ_time_start_frame_get(seq)) > | ||||
| v2d->cur.xmax) { | v2d->cur.xmax) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (max_ii(SEQ_time_right_handle_frame_get(scene, seq), | if (max_ii(SEQ_time_right_handle_frame_get(video_edit, seq), | ||||
| SEQ_time_content_end_frame_get(scene, seq)) < v2d->cur.xmin) { | SEQ_time_content_end_frame_get(video_edit, seq)) < v2d->cur.xmin) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (seq->machine + 1.0f < v2d->cur.ymin) { | if (seq->machine + 1.0f < v2d->cur.ymin) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (seq->machine > v2d->cur.ymax) { | if (seq->machine > v2d->cur.ymax) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Strip passed all tests, draw it now. */ | /* Strip passed all tests, draw it now. */ | ||||
| draw_seq_strip(C, sseq, scene, region, seq, pixelx, seq == last_seq ? true : false); | draw_seq_strip(C, sseq, video_edit, region, seq, pixelx, seq == last_seq ? true : false); | ||||
| } | } | ||||
| /* Draw selected next time round. */ | /* Draw selected next time round. */ | ||||
| sel = SELECT; | sel = SELECT; | ||||
| } | } | ||||
| /* When selected draw the last selected (active) strip last, | /* When selected draw the last selected (active) strip last, | ||||
| * removes some overlapping error. */ | * removes some overlapping error. */ | ||||
| if (last_seq && (last_seq->flag & SELECT)) { | if (last_seq && (last_seq->flag & SELECT)) { | ||||
| draw_seq_strip(C, sseq, scene, region, last_seq, pixelx, true); | draw_seq_strip(C, sseq, video_edit, region, last_seq, pixelx, true); | ||||
| /* When active strip is an effect, highlight its inputs. */ | /* When active strip is an effect, highlight its inputs. */ | ||||
| if (SEQ_effect_get_num_inputs(last_seq->type) > 0) { | if (SEQ_effect_get_num_inputs(last_seq->type) > 0) { | ||||
| draw_effect_inputs_highlight(scene, last_seq); | draw_effect_inputs_highlight(video_edit, last_seq); | ||||
| } | } | ||||
| /* When active is a Multi-cam strip, highlight its source channel. */ | /* When active is a Multi-cam strip, highlight its source channel. */ | ||||
| else if (last_seq->type == SEQ_TYPE_MULTICAM) { | else if (last_seq->type == SEQ_TYPE_MULTICAM) { | ||||
| int channel = last_seq->multicam_source; | int channel = last_seq->multicam_source; | ||||
| if (channel != 0) { | if (channel != 0) { | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| uint pos = GPU_vertformat_attr_add( | uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| Show All 13 Lines | if (special_seq_update) { | ||||
| const Sequence *seq = special_seq_update; | const Sequence *seq = special_seq_update; | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4ub(255, 255, 255, 48); | immUniformColor4ub(255, 255, 255, 48); | ||||
| immRectf(pos, | immRectf(pos, | ||||
| SEQ_time_left_handle_frame_get(scene, seq), | SEQ_time_left_handle_frame_get(video_edit, seq), | ||||
| seq->machine + SEQ_STRIP_OFSBOTTOM, | seq->machine + SEQ_STRIP_OFSBOTTOM, | ||||
| SEQ_time_right_handle_frame_get(scene, seq), | SEQ_time_right_handle_frame_get(video_edit, seq), | ||||
| seq->machine + SEQ_STRIP_OFSTOP); | seq->machine + SEQ_STRIP_OFSTOP); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| } | } | ||||
| static void seq_draw_sfra_efra(const Scene *scene, View2D *v2d) | static void seq_draw_sfra_efra(const VideoEdit *video_edit, View2D *v2d) | ||||
| { | { | ||||
| const Editing *ed = SEQ_editing_get(scene); | const int frame_sta = video_edit->r.sfra; | ||||
| const int frame_sta = scene->r.sfra; | const int frame_end = video_edit->r.efra + 1; | ||||
| const int frame_end = scene->r.efra + 1; | |||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| /* Draw overlay outside of frame range. */ | /* Draw overlay outside of frame range. */ | ||||
| immUniformThemeColorShadeAlpha(TH_BACK, -10, -100); | immUniformThemeColorShadeAlpha(TH_BACK, -10, -100); | ||||
| Show All 15 Lines | static void seq_draw_sfra_efra(const VideoEdit *video_edit, View2D *v2d) | ||||
| immVertex2f(pos, frame_sta, v2d->cur.ymax); | immVertex2f(pos, frame_sta, v2d->cur.ymax); | ||||
| immVertex2f(pos, frame_end, v2d->cur.ymin); | immVertex2f(pos, frame_end, v2d->cur.ymin); | ||||
| immVertex2f(pos, frame_end, v2d->cur.ymax); | immVertex2f(pos, frame_end, v2d->cur.ymax); | ||||
| immEnd(); | immEnd(); | ||||
| /* While in meta strip, draw a checkerboard overlay outside of frame range. */ | /* While in meta strip, draw a checkerboard overlay outside of frame range. */ | ||||
| if (ed && !BLI_listbase_is_empty(&ed->metastack)) { | if (!BLI_listbase_is_empty(&video_edit->metastack)) { | ||||
| const MetaStack *ms = ed->metastack.last; | const MetaStack *ms = video_edit->metastack.last; | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_CHECKER); | immBindBuiltinProgram(GPU_SHADER_2D_CHECKER); | ||||
| immUniform4f("color1", 0.0f, 0.0f, 0.0f, 0.22f); | immUniform4f("color1", 0.0f, 0.0f, 0.0f, 0.22f); | ||||
| immUniform4f("color2", 1.0f, 1.0f, 1.0f, 0.0f); | immUniform4f("color2", 1.0f, 1.0f, 1.0f, 0.0f); | ||||
| immUniform1i("size", 8); | immUniform1i("size", 8); | ||||
| ▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | if (vert_count > 0) { | ||||
| GPU_batch_uniform_4f(batch, "color", col_r, col_g, col_b, col_a); | GPU_batch_uniform_4f(batch, "color", col_r, col_g, col_b, col_a); | ||||
| GPU_batch_draw(batch); | GPU_batch_draw(batch); | ||||
| } | } | ||||
| GPU_batch_discard(batch); | GPU_batch_discard(batch); | ||||
| } | } | ||||
| static void draw_cache_view(const bContext *C) | static void draw_cache_view(const bContext *C) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| struct View2D *v2d = ®ion->v2d; | struct View2D *v2d = ®ion->v2d; | ||||
| if ((scene->ed->cache_flag & SEQ_CACHE_VIEW_ENABLE) == 0) { | if ((video_edit->cache_flag & SEQ_CACHE_VIEW_ENABLE) == 0) { | ||||
| return; | return; | ||||
| } | } | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| float stripe_bot, stripe_top; | float stripe_bot, stripe_top; | ||||
| float stripe_ofs_y = UI_view2d_region_to_view_y(v2d, 1.0f) - v2d->cur.ymin; | float stripe_ofs_y = UI_view2d_region_to_view_y(v2d, 1.0f) - v2d->cur.ymin; | ||||
| float stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_DPI_FAC * U.pixelsize) - | float stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_DPI_FAC * U.pixelsize) - | ||||
| v2d->cur.ymin; | v2d->cur.ymin; | ||||
| CLAMP_MAX(stripe_ht, 0.2f); | CLAMP_MAX(stripe_ht, 0.2f); | ||||
| CLAMP_MIN(stripe_ofs_y, stripe_ht / 2); | CLAMP_MIN(stripe_ofs_y, stripe_ht / 2); | ||||
| if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) { | if (video_edit->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) { | ||||
| stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HANDLE_HEIGHT); | stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HANDLE_HEIGHT); | ||||
| stripe_top = stripe_bot + stripe_ht; | stripe_top = stripe_bot + stripe_ht; | ||||
| const float bg_color[4] = {1.0f, 0.4f, 0.2f, 0.1f}; | const float bg_color[4] = {1.0f, 0.4f, 0.2f, 0.1f}; | ||||
| immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); | immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); | ||||
| immRectf(pos, scene->r.sfra, stripe_bot, scene->r.efra, stripe_top); | immRectf(pos, video_edit->r.sfra, stripe_bot, video_edit->r.efra, stripe_top); | ||||
| } | } | ||||
| for (Sequence *seq = scene->ed->seqbasep->first; seq != NULL; seq = seq->next) { | for (Sequence *seq = video_edit->seqbasep->first; seq != NULL; seq = seq->next) { | ||||
| if (seq->type == SEQ_TYPE_SOUND_RAM) { | if (seq->type == SEQ_TYPE_SOUND_RAM) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (SEQ_time_left_handle_frame_get(scene, seq) > v2d->cur.xmax || | if (SEQ_time_left_handle_frame_get(video_edit, seq) > v2d->cur.xmax || | ||||
| SEQ_time_right_handle_frame_get(scene, seq) < v2d->cur.xmin) { | SEQ_time_right_handle_frame_get(video_edit, seq) < v2d->cur.xmin) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + stripe_ofs_y; | stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + stripe_ofs_y; | ||||
| stripe_top = stripe_bot + stripe_ht; | stripe_top = stripe_bot + stripe_ht; | ||||
| if (scene->ed->cache_flag & SEQ_CACHE_VIEW_RAW) { | if (video_edit->cache_flag & SEQ_CACHE_VIEW_RAW) { | ||||
| const float bg_color[4] = {1.0f, 0.1f, 0.02f, 0.1f}; | const float bg_color[4] = {1.0f, 0.1f, 0.02f, 0.1f}; | ||||
| immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); | immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); | ||||
| immRectf(pos, | immRectf(pos, | ||||
| SEQ_time_left_handle_frame_get(scene, seq), | SEQ_time_left_handle_frame_get(video_edit, seq), | ||||
| stripe_bot, | stripe_bot, | ||||
| SEQ_time_right_handle_frame_get(scene, seq), | SEQ_time_right_handle_frame_get(video_edit, seq), | ||||
| stripe_top); | stripe_top); | ||||
| } | } | ||||
| stripe_bot += stripe_ht + stripe_ofs_y; | stripe_bot += stripe_ht + stripe_ofs_y; | ||||
| stripe_top = stripe_bot + stripe_ht; | stripe_top = stripe_bot + stripe_ht; | ||||
| if (scene->ed->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) { | if (video_edit->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) { | ||||
| const float bg_color[4] = {0.1f, 0.1f, 0.75f, 0.1f}; | const float bg_color[4] = {0.1f, 0.1f, 0.75f, 0.1f}; | ||||
| immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); | immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); | ||||
| immRectf(pos, | immRectf(pos, | ||||
| SEQ_time_left_handle_frame_get(scene, seq), | SEQ_time_left_handle_frame_get(video_edit, seq), | ||||
| stripe_bot, | stripe_bot, | ||||
| SEQ_time_right_handle_frame_get(scene, seq), | SEQ_time_right_handle_frame_get(video_edit, seq), | ||||
| stripe_top); | stripe_top); | ||||
| } | } | ||||
| stripe_top = seq->machine + SEQ_STRIP_OFSTOP - stripe_ofs_y; | stripe_top = seq->machine + SEQ_STRIP_OFSTOP - stripe_ofs_y; | ||||
| stripe_bot = stripe_top - stripe_ht; | stripe_bot = stripe_top - stripe_ht; | ||||
| if (scene->ed->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) { | if (video_edit->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) { | ||||
| const float bg_color[4] = {1.0f, 0.6f, 0.0f, 0.1f}; | const float bg_color[4] = {1.0f, 0.6f, 0.0f, 0.1f}; | ||||
| immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); | immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); | ||||
| immRectf(pos, | immRectf(pos, | ||||
| SEQ_time_left_handle_frame_get(scene, seq), | SEQ_time_left_handle_frame_get(video_edit, seq), | ||||
| stripe_bot, | stripe_bot, | ||||
| SEQ_time_right_handle_frame_get(scene, seq), | SEQ_time_right_handle_frame_get(video_edit, seq), | ||||
| stripe_top); | stripe_top); | ||||
| } | } | ||||
| } | } | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| GPUVertFormat format = {0}; | GPUVertFormat format = {0}; | ||||
| GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| CacheDrawData userdata; | CacheDrawData userdata; | ||||
| userdata.v2d = v2d; | userdata.v2d = v2d; | ||||
| userdata.stripe_ofs_y = stripe_ofs_y; | userdata.stripe_ofs_y = stripe_ofs_y; | ||||
| userdata.stripe_ht = stripe_ht; | userdata.stripe_ht = stripe_ht; | ||||
| userdata.cache_flag = scene->ed->cache_flag; | userdata.cache_flag = video_edit->cache_flag; | ||||
| userdata.raw_vert_count = 0; | userdata.raw_vert_count = 0; | ||||
| userdata.preprocessed_vert_count = 0; | userdata.preprocessed_vert_count = 0; | ||||
| userdata.composite_vert_count = 0; | userdata.composite_vert_count = 0; | ||||
| userdata.final_out_vert_count = 0; | userdata.final_out_vert_count = 0; | ||||
| userdata.raw_vbo = GPU_vertbuf_create_with_format(&format); | userdata.raw_vbo = GPU_vertbuf_create_with_format(&format); | ||||
| userdata.preprocessed_vbo = GPU_vertbuf_create_with_format(&format); | userdata.preprocessed_vbo = GPU_vertbuf_create_with_format(&format); | ||||
| userdata.composite_vbo = GPU_vertbuf_create_with_format(&format); | userdata.composite_vbo = GPU_vertbuf_create_with_format(&format); | ||||
| userdata.final_out_vbo = GPU_vertbuf_create_with_format(&format); | userdata.final_out_vbo = GPU_vertbuf_create_with_format(&format); | ||||
| SEQ_cache_iterate(scene, &userdata, draw_cache_view_init_fn, draw_cache_view_iter_fn); | SEQ_cache_iterate(video_edit, &userdata, draw_cache_view_init_fn, draw_cache_view_iter_fn); | ||||
| draw_cache_view_batch(userdata.raw_vbo, userdata.raw_vert_count, 1.0f, 0.1f, 0.02f, 0.4f); | draw_cache_view_batch(userdata.raw_vbo, userdata.raw_vert_count, 1.0f, 0.1f, 0.02f, 0.4f); | ||||
| draw_cache_view_batch( | draw_cache_view_batch( | ||||
| userdata.preprocessed_vbo, userdata.preprocessed_vert_count, 0.1f, 0.1f, 0.75f, 0.4f); | userdata.preprocessed_vbo, userdata.preprocessed_vert_count, 0.1f, 0.1f, 0.75f, 0.4f); | ||||
| draw_cache_view_batch( | draw_cache_view_batch( | ||||
| userdata.composite_vbo, userdata.composite_vert_count, 1.0f, 0.6f, 0.0f, 0.4f); | userdata.composite_vbo, userdata.composite_vert_count, 1.0f, 0.6f, 0.0f, 0.4f); | ||||
| draw_cache_view_batch( | draw_cache_view_batch( | ||||
| userdata.final_out_vbo, userdata.final_out_vert_count, 1.0f, 0.4f, 0.2f, 0.4f); | userdata.final_out_vbo, userdata.final_out_vert_count, 1.0f, 0.4f, 0.2f, 0.4f); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| /* Draw sequencer timeline. */ | /* Draw sequencer timeline. */ | ||||
| static void draw_overlap_frame_indicator(const struct Scene *scene, const View2D *v2d) | static void draw_overlap_frame_indicator(const VideoEdit *video_edit, const View2D *v2d) | ||||
| { | { | ||||
| int overlap_frame = (scene->ed->overlay_frame_flag & SEQ_EDIT_OVERLAY_FRAME_ABS) ? | int overlap_frame = (video_edit->overlay_frame_flag & SEQ_EDIT_OVERLAY_FRAME_ABS) ? | ||||
| scene->ed->overlay_frame_abs : | video_edit->overlay_frame_abs : | ||||
| scene->r.cfra + scene->ed->overlay_frame_ofs; | video_edit->r.cfra + video_edit->overlay_frame_ofs; | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); | ||||
| float viewport_size[4]; | float viewport_size[4]; | ||||
| GPU_viewport_size_get_f(viewport_size); | GPU_viewport_size_get_f(viewport_size); | ||||
| immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); | immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); | ||||
| /* Shader may have color set from past usage - reset it. */ | /* Shader may have color set from past usage - reset it. */ | ||||
| immUniform1i("colors_len", 0); | immUniform1i("colors_len", 0); | ||||
| immUniform1f("dash_width", 20.0f * U.pixelsize); | immUniform1f("dash_width", 20.0f * U.pixelsize); | ||||
| immUniform1f("dash_factor", 0.5f); | immUniform1f("dash_factor", 0.5f); | ||||
| immUniformThemeColor(TH_CFRAME); | immUniformThemeColor(TH_CFRAME); | ||||
| immBegin(GPU_PRIM_LINES, 2); | immBegin(GPU_PRIM_LINES, 2); | ||||
| immVertex2f(pos, overlap_frame, v2d->cur.ymin); | immVertex2f(pos, overlap_frame, v2d->cur.ymin); | ||||
| immVertex2f(pos, overlap_frame, v2d->cur.ymax); | immVertex2f(pos, overlap_frame, v2d->cur.ymax); | ||||
| immEnd(); | immEnd(); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| void draw_timeline_seq(const bContext *C, ARegion *region) | void draw_timeline_seq(const bContext *C, ARegion *region) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_get(scene); | |||||
| SpaceSeq *sseq = CTX_wm_space_seq(C); | SpaceSeq *sseq = CTX_wm_space_seq(C); | ||||
| View2D *v2d = ®ion->v2d; | View2D *v2d = ®ion->v2d; | ||||
| float col[3]; | float col[3]; | ||||
| seq_prefetch_wm_notify(C, scene); | seq_prefetch_wm_notify(C, video_edit); | ||||
| GPUViewport *viewport = WM_draw_region_get_viewport(region); | GPUViewport *viewport = WM_draw_region_get_viewport(region); | ||||
| GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport); | GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport); | ||||
| GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | ||||
| GPU_depth_test(GPU_DEPTH_NONE); | GPU_depth_test(GPU_DEPTH_NONE); | ||||
| UI_GetThemeColor3fv(TH_BACK, col); | UI_GetThemeColor3fv(TH_BACK, col); | ||||
| GPU_clear_color(col[0], col[1], col[2], 0.0f); | GPU_clear_color(col[0], col[1], col[2], 0.0f); | ||||
| UI_view2d_view_ortho(v2d); | UI_view2d_view_ortho(v2d); | ||||
| draw_seq_timeline_channels(v2d); | draw_seq_timeline_channels(v2d); | ||||
| if ((sseq->flag & SEQ_SHOW_OVERLAY) && (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_GRID)) { | if ((sseq->flag & SEQ_SHOW_OVERLAY) && (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_GRID)) { | ||||
| double fps = (((double)video_edit->r.frs_sec) / (double)video_edit->r.frs_sec_base); | |||||
| U.v2d_min_gridsize *= 3; | U.v2d_min_gridsize *= 3; | ||||
| UI_view2d_draw_lines_x__discrete_frames_or_seconds( | UI_view2d_draw_lines_x__discrete_frames_or_seconds( | ||||
| v2d, scene, (sseq->flag & SEQ_DRAWFRAMES) == 0, false); | v2d, fps, (sseq->flag & SEQ_DRAWFRAMES) == 0, false); | ||||
| U.v2d_min_gridsize /= 3; | U.v2d_min_gridsize /= 3; | ||||
| } | } | ||||
| /* Only draw backdrop in timeline view. */ | /* Only draw backdrop in timeline view. */ | ||||
| if (sseq->view == SEQ_VIEW_SEQUENCE && sseq->draw_flag & SEQ_DRAW_BACKDROP) { | if (sseq->view == SEQ_VIEW_SEQUENCE && sseq->draw_flag & SEQ_DRAW_BACKDROP) { | ||||
| int preview_frame = scene->r.cfra; | int preview_frame = video_edit->r.cfra; | ||||
| if (sequencer_draw_get_transform_preview(sseq, scene)) { | if (sequencer_draw_get_transform_preview(sseq, video_edit)) { | ||||
| preview_frame = sequencer_draw_get_transform_preview_frame(scene); | preview_frame = sequencer_draw_get_transform_preview_frame(video_edit); | ||||
| } | } | ||||
| sequencer_draw_preview(C, scene, region, sseq, preview_frame, 0, false, true); | sequencer_draw_preview(C, video_edit, region, sseq, preview_frame, 0, false, true); | ||||
| UI_view2d_view_ortho(v2d); | UI_view2d_view_ortho(v2d); | ||||
| } | } | ||||
| /* Draw attached callbacks. */ | /* Draw attached callbacks. */ | ||||
| GPU_framebuffer_bind(framebuffer_overlay); | GPU_framebuffer_bind(framebuffer_overlay); | ||||
| ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW); | ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW); | ||||
| GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | ||||
| seq_draw_sfra_efra(scene, v2d); | seq_draw_sfra_efra(video_edit, v2d); | ||||
| if (ed) { | draw_seq_strips(C, video_edit, region); | ||||
| draw_seq_strips(C, ed, region); | |||||
| /* Draw text added in previous function. */ | /* Draw text added in previous function. */ | ||||
| UI_view2d_text_cache_draw(region); | UI_view2d_text_cache_draw(region); | ||||
| } | |||||
| UI_view2d_view_ortho(v2d); | UI_view2d_view_ortho(v2d); | ||||
| UI_view2d_view_orthoSpecial(region, v2d, 1); | UI_view2d_view_orthoSpecial(region, v2d, 1); | ||||
| int marker_draw_flag = DRAW_MARKERS_MARGIN; | int marker_draw_flag = DRAW_MARKERS_MARGIN; | ||||
| if (sseq->flag & SEQ_SHOW_MARKERS) { | if (sseq->flag & SEQ_SHOW_MARKERS) { | ||||
| ED_markers_draw(C, marker_draw_flag); | ED_markers_draw(C, marker_draw_flag); | ||||
| } | } | ||||
| UI_view2d_view_ortho(v2d); | UI_view2d_view_ortho(v2d); | ||||
| ANIM_draw_previewrange(C, v2d, 1); | ANIM_draw_previewrange(C, v2d, 1); | ||||
| if ((sseq->gizmo_flag & SEQ_GIZMO_HIDE) == 0) { | if ((sseq->gizmo_flag & SEQ_GIZMO_HIDE) == 0) { | ||||
| WM_gizmomap_draw(region->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); | WM_gizmomap_draw(region->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); | ||||
| } | } | ||||
| /* Draw registered callbacks. */ | /* Draw registered callbacks. */ | ||||
| GPU_framebuffer_bind(framebuffer_overlay); | GPU_framebuffer_bind(framebuffer_overlay); | ||||
| ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW); | ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW); | ||||
| GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | GPU_framebuffer_bind_no_srgb(framebuffer_overlay); | ||||
| UI_view2d_view_restore(C); | UI_view2d_view_restore(C); | ||||
| ED_time_scrub_draw(region, scene, !(sseq->flag & SEQ_DRAWFRAMES), true); | const double fps = (((double)video_edit->r.frs_sec) / (double)video_edit->r.frs_sec_base); | ||||
| ED_time_scrub_draw(region, fps, !(sseq->flag & SEQ_DRAWFRAMES), true); | |||||
| } | } | ||||
| void draw_timeline_seq_display(const bContext *C, ARegion *region) | void draw_timeline_seq_display(const bContext *C, ARegion *region) | ||||
| { | { | ||||
| const Scene *scene = CTX_data_scene(C); | const VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| const SpaceSeq *sseq = CTX_wm_space_seq(C); | const SpaceSeq *sseq = CTX_wm_space_seq(C); | ||||
| View2D *v2d = ®ion->v2d; | View2D *v2d = ®ion->v2d; | ||||
| if (scene->ed != NULL) { | |||||
| UI_view2d_view_ortho(v2d); | UI_view2d_view_ortho(v2d); | ||||
| draw_cache_view(C); | draw_cache_view(C); | ||||
| if (scene->ed->overlay_frame_flag & SEQ_EDIT_OVERLAY_FRAME_SHOW) { | if (video_edit->overlay_frame_flag & SEQ_EDIT_OVERLAY_FRAME_SHOW) { | ||||
| draw_overlap_frame_indicator(scene, v2d); | draw_overlap_frame_indicator(video_edit, v2d); | ||||
| } | } | ||||
| UI_view2d_view_restore(C); | UI_view2d_view_restore(C); | ||||
| } | |||||
| ED_time_scrub_draw_current_frame(region, scene, !(sseq->flag & SEQ_DRAWFRAMES)); | ED_time_scrub_draw_current_frame(region, &video_edit->r, !(sseq->flag & SEQ_DRAWFRAMES)); | ||||
| const ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene)); | const ListBase *seqbase = SEQ_active_seqbase_get(video_edit); | ||||
| SEQ_timeline_boundbox(scene, seqbase, &v2d->tot); | SEQ_timeline_boundbox(video_edit, seqbase, &v2d->tot); | ||||
| UI_view2d_scrollers_draw(v2d, NULL); | UI_view2d_scrollers_draw(v2d, NULL); | ||||
| } | } | ||||