[Bf-blender-cvs] [76043bc3d62] master: Cleanup: VSE code readability

Richard Antalik noreply at git.blender.org
Tue Oct 4 21:24:25 CEST 2022


Commit: 76043bc3d62c5a23f182c2cf0521e787600bd0d7
Author: Richard Antalik
Date:   Tue Oct 4 19:50:13 2022 +0200
Branches: master
https://developer.blender.org/rB76043bc3d62c5a23f182c2cf0521e787600bd0d7

Cleanup: VSE code readability

Add function `SEQ_time_content_end_frame_get` to get content end frame.
New function is shorthand for
`SEQ_time_start_frame_get() + SEQ_time_strip_length_get()`.

===================================================================

M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_sequencer/sequencer_thumbnails.c
M	source/blender/editors/transform/transform_snap_sequencer.c
M	source/blender/sequencer/SEQ_time.h
M	source/blender/sequencer/intern/render.c
M	source/blender/sequencer/intern/strip_edit.c
M	source/blender/sequencer/intern/strip_time.c

===================================================================

diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index ce12629f9d6..6ebc3e95b70 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -963,8 +963,7 @@ static void draw_sequence_extensions_overlay(
   UI_GetColorPtrShade3ubv(col, blend_col, 10);
 
   const float strip_content_start = SEQ_time_start_frame_get(seq);
-  const float strip_content_end = SEQ_time_start_frame_get(seq) +
-                                  SEQ_time_strip_length_get(scene, seq);
+  const float strip_content_end = SEQ_time_content_end_frame_get(scene, seq);
   float right_handle_frame = SEQ_time_right_handle_frame_get(scene, seq);
   float left_handle_frame = SEQ_time_left_handle_frame_get(scene, seq);
 
@@ -1095,8 +1094,7 @@ static void draw_seq_background(Scene *scene,
     }
     if (SEQ_time_has_right_still_frames(scene, seq)) {
       float right_handle_frame = SEQ_time_right_handle_frame_get(scene, seq);
-      const float content_end = SEQ_time_start_frame_get(seq) +
-                                SEQ_time_strip_length_get(scene, seq);
+      const float content_end = SEQ_time_content_end_frame_get(scene, seq);
       immRectf(pos, content_end, y1, right_handle_frame, y2);
     }
   }
@@ -1317,8 +1315,7 @@ static void draw_seq_strip(const bContext *C,
   x1 = SEQ_time_has_left_still_frames(scene, seq) ? SEQ_time_start_frame_get(seq) :
                                                     SEQ_time_left_handle_frame_get(scene, seq);
   y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
-  x2 = SEQ_time_has_right_still_frames(scene, seq) ?
-           SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq) :
+  x2 = SEQ_time_has_right_still_frames(scene, seq) ? SEQ_time_content_end_frame_get(scene, seq) :
            SEQ_time_right_handle_frame_get(scene, seq);
   y2 = seq->machine + SEQ_STRIP_OFSTOP;
 
@@ -2290,7 +2287,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region)
         continue;
       }
       if (max_ii(SEQ_time_right_handle_frame_get(scene, seq),
-                 SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq)) <
+                 SEQ_time_content_end_frame_get(scene, seq)) <
           v2d->cur.xmin) {
         continue;
       }
diff --git a/source/blender/editors/space_sequencer/sequencer_thumbnails.c b/source/blender/editors/space_sequencer/sequencer_thumbnails.c
index 6f443d0353e..36f2aa87d9d 100644
--- a/source/blender/editors/space_sequencer/sequencer_thumbnails.c
+++ b/source/blender/editors/space_sequencer/sequencer_thumbnails.c
@@ -74,10 +74,11 @@ static bool check_seq_need_thumbnails(const Scene *scene, Sequence *seq, rctf *v
   if (!ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) {
     return false;
   }
-  if (min_ii(SEQ_time_left_handle_frame_get(scene, seq), seq->start) > view_area->xmax) {
+  if (min_ii(SEQ_time_left_handle_frame_get(scene, seq), SEQ_time_start_frame_get(seq)) >
+      view_area->xmax) {
     return false;
   }
-  if (max_ii(SEQ_time_right_handle_frame_get(scene, seq), seq->start + seq->len) <
+  if (max_ii(SEQ_time_right_handle_frame_get(scene, seq), SEQ_time_content_end_frame_get(scene, seq)) <
       view_area->xmin) {
     return false;
   }
diff --git a/source/blender/editors/transform/transform_snap_sequencer.c b/source/blender/editors/transform/transform_snap_sequencer.c
index 06d9bb05206..ed8b201240b 100644
--- a/source/blender/editors/transform/transform_snap_sequencer.c
+++ b/source/blender/editors/transform/transform_snap_sequencer.c
@@ -203,8 +203,10 @@ static void seq_snap_target_points_build(Scene *scene,
     i += 2;
 
     if (snap_mode & SEQ_SNAP_TO_STRIP_HOLD) {
-      int content_start = min_ii(SEQ_time_right_handle_frame_get(scene, seq), seq->start);
-      int content_end = max_ii(SEQ_time_left_handle_frame_get(scene, seq), seq->start + seq->len);
+      int content_start = min_ii(SEQ_time_left_handle_frame_get(scene, seq),
+                                       SEQ_time_start_frame_get(seq));
+      int content_end = max_ii(SEQ_time_right_handle_frame_get(scene, seq),
+                                     SEQ_time_content_end_frame_get(scene, seq));
       /* Effects and single image strips produce incorrect content length. Skip these strips. */
       if ((seq->type & SEQ_TYPE_EFFECT) != 0 || seq->len == 1) {
         content_start = SEQ_time_left_handle_frame_get(scene, seq);
diff --git a/source/blender/sequencer/SEQ_time.h b/source/blender/sequencer/SEQ_time.h
index 69dc20d39ca..e6e8d75807e 100644
--- a/source/blender/sequencer/SEQ_time.h
+++ b/source/blender/sequencer/SEQ_time.h
@@ -74,6 +74,7 @@ void SEQ_time_speed_factor_set(const struct Scene *scene,
                                struct Sequence *seq,
                                const float speed_factor);
 float SEQ_time_start_frame_get(const struct Sequence *seq);
+float SEQ_time_content_end_frame_get(const struct Scene *scene, const struct Sequence *seq);
 void SEQ_time_start_frame_set(const struct Scene *scene, struct Sequence *seq, int timeline_frame);
 void SEQ_time_update_meta_strip_range(const struct Scene *scene, struct Sequence *seq_meta);
 
diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c
index 1b6c4b42730..91ecccbe0f8 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -2103,7 +2103,7 @@ void SEQ_render_thumbnails(const SeqRenderData *context,
   /* Adding the hold offset value (seq->anim_startofs) to the start frame. Position of image not
    * affected, but frame loaded affected. */
   float upper_thumb_bound = SEQ_time_has_right_still_frames(scene, seq) ?
-                                (seq->start + seq->len) :
+                                SEQ_time_content_end_frame_get(scene, seq) :
                                 SEQ_time_right_handle_frame_get(scene, seq);
   upper_thumb_bound = (upper_thumb_bound > view_area->xmax) ? view_area->xmax + frame_step :
                                                               upper_thumb_bound;
@@ -2137,9 +2137,10 @@ void SEQ_render_thumbnails(const SeqRenderData *context,
 
 int SEQ_render_thumbnails_guaranteed_set_frame_step_get(const Scene *scene, const Sequence *seq)
 {
-  const int content_start = max_ii(SEQ_time_left_handle_frame_get(scene, seq), seq->start);
+  const int content_start = max_ii(SEQ_time_left_handle_frame_get(scene, seq),
+                                   SEQ_time_start_frame_get(seq));
   const int content_end = min_ii(SEQ_time_right_handle_frame_get(scene, seq),
-                                 seq->start + seq->len);
+                                 SEQ_time_content_end_frame_get(scene, seq));
   const int content_len = content_end - content_start;
 
   /* Arbitrary, but due to performance reasons should be as low as possible. */
diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c
index 9751ccf18a6..69e43f3679c 100644
--- a/source/blender/sequencer/intern/strip_edit.c
+++ b/source/blender/sequencer/intern/strip_edit.c
@@ -260,8 +260,8 @@ bool SEQ_edit_move_strip_to_meta(Scene *scene,
 
 static void seq_split_set_right_hold_offset(Scene *scene, Sequence *seq, int timeline_frame)
 {
-  const float content_start = seq->start;
-  const float content_end = seq->start + SEQ_time_strip_length_get(scene, seq);
+  const float content_start = SEQ_time_start_frame_get(seq);
+  const float content_end = SEQ_time_content_end_frame_get(scene, seq);
 
   /* Adjust within range of extended still-frames before strip. */
   if (timeline_frame < content_start) {
@@ -283,8 +283,8 @@ static void seq_split_set_right_hold_offset(Scene *scene, Sequence *seq, int tim
 
 static void seq_split_set_left_hold_offset(Scene *scene, Sequence *seq, int timeline_frame)
 {
-  const float content_start = seq->start;
-  const float content_end = seq->start + SEQ_time_strip_length_get(scene, seq);
+  const float content_start = SEQ_time_start_frame_get(seq);
+  const float content_end = SEQ_time_content_end_frame_get(scene, seq);
 
   /* Adjust within range of extended still-frames before strip. */
   if (timeline_frame < content_start) {
diff --git a/source/blender/sequencer/intern/strip_time.c b/source/blender/sequencer/intern/strip_time.c
index 6725e0a8394..5d953398732 100644
--- a/source/blender/sequencer/intern/strip_time.c
+++ b/source/blender/sequencer/intern/strip_time.c
@@ -53,7 +53,7 @@ float seq_give_frame_index(const Scene *scene, Sequence *seq, float timeline_fra
 {
   float frame_index;
   float sta = SEQ_time_start_frame_get(seq);
-  float end = SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq) - 1;
+  float end = SEQ_time_content_end_frame_get(scene, seq) - 1;
 
   if (seq->type & SEQ_TYPE_EFFECT) {
     end = SEQ_time_right_handle_frame_get(scene, seq);
@@ -470,8 +470,7 @@ bool SEQ_time_has_left_still_frames(const Scene *scene, const Sequence *seq)
 
 bool SEQ_time_has_right_still_frames(const Scene *scene, const Sequence *seq)
 {
-  return SEQ_time_right_handle_frame_get(scene, seq) >
-         SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq);
+  return SEQ_time_right_handle_frame_get(scene, seq) > SEQ_time_content_end_frame_get(scene, seq);
 }
 
 bool SEQ_time_has_still_frames(const Scene *scene, const Sequence *seq)
@@ -503,6 +502,11 @@ void SEQ_time_start_frame_set(const Scene *scene, Sequence *seq, int timeline_fr
   seq_time_update_effects_strip_range(scene, seq_sequence_lookup_effects_by_seq(scene, seq));
 }
 
+float SEQ_time_content_end_frame_get(const Scene *scene, const Sequence *seq)
+{
+  return SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq);
+}
+
 int SEQ_time_left_handle_frame_get(const Scene *UNUSED(scene), const Sequence *seq)
 {
   if (seq->seq1 || seq->seq2) {
@@ -518,7 +522,7 @@ int SEQ_time_right_handle_frame_get(const Scene *scene, const Sequence *seq)
     return seq->enddisp;
   }
 
-  return seq->start + SEQ_time_strip_length_get(scene, seq) - seq->endofs;
+  return SEQ_time_content_end_frame_get(scene, seq) - seq->endofs

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list