61 float *r_image_height)
63 int image_width = seq::THUMB_SIZE, image_height = seq::THUMB_SIZE;
65 image_width = strip->
data->stripdata->orig_width;
66 image_height = strip->
data->stripdata->orig_height;
69 image_width = strip->clip->lastsize[0];
70 image_height = strip->clip->lastsize[1];
73 image_width = strip->scene->r.xsch;
74 image_height = strip->scene->r.ysch;
80 const float aspect_ratio =
float(image_width) /
float(image_height);
81 float thumb_h_px = thumb_height / pixely;
82 float thumb_width = aspect_ratio * thumb_h_px * pixelx;
84 *r_thumb_width = thumb_width;
85 *r_image_width = image_width;
86 *r_image_height = image_height;
97 float crop_x_multiplier,
98 float upper_thumb_bound,
104 const float display_frame = timeline_frame + display_offset;
106 float thumb_x_end = display_frame + thumb_width;
107 bool clipped =
false;
110 if (display_frame > v2d->
cur.
xmax) {
115 if (thumb_x_end > upper_thumb_bound) {
116 thumb_x_end = upper_thumb_bound;
120 crop_left =
max_ff(crop_left, 0.0f);
121 crop_right =
max_ff(crop_right, 0.0f);
123 if (crop_left > 0.0f || crop_right > 0.0f) {
127 float cropx_min = crop_left * crop_x_multiplier;
128 float cropx_max =
min_ff(thumb_width - crop_right, (thumb_x_end - display_frame)) *
130 if (cropx_max - cropx_min < 1.0f) {
136 if (ibuf ==
nullptr) {
154 thumb.
x1 = display_frame + crop_left;
155 thumb.
x2 =
min_ff(thumb_x_end, display_frame + thumb_width - crop_right);
164 const float thumb_width,
167 if (timeline_frame < v2d->cur.xmax && timeline_frame + thumb_width > v2d->
cur.
xmin) {
177 const float thumb_width,
178 const float crop_x_multiplier,
179 const float upper_thumb_bound,
187 (right_frame - left_frame);
188 const float middle_frame =
roundf((left_frame + right_frame) / 2.0f);
191 const float display_offset = (strip.
is_single_image ? strip_width / 2.0f : 0.0f) -
192 (thumb_width / 2.0f);
195 const float crop =
max_ff(0.0f, thumb_width - strip_width) / 2.0f;
218 const float thumb_width,
219 const float crop_x_multiplier,
220 const float upper_thumb_bound,
228 (right_frame - left_frame);
229 const float overlap =
max_ff(0.0f, 2.0f * thumb_width - strip_width);
233 const float display_offset = (strip.
is_single_image ? strip_width : 0.0f) - thumb_width;
236 float crop_left = 0.0;
237 float crop_right = 0.0;
239 if (overlap > 0.0f && only_right_handle_selected) {
241 crop_right = overlap + gap;
243 else if (overlap > 0.0f) {
245 crop_left = overlap + gap;
288 bool show_only_middle,
289 bool show_only_at_strip_ends,
305 float thumb_width, image_width, image_height;
307 strip.
strip, pixelx, pixely, &thumb_width, thumb_height, &image_width, &image_height);
309 const float crop_x_multiplier = 1.0f / pixelx / (thumb_height / image_height / pixely);
316 if (show_only_middle) {
329 if (show_only_at_strip_ends) {
344 float aligned_frame_offset = int((first_drawable_frame - strip.
strip->start) / thumb_width) *
352 bool draw_next_frame_ontop = first_drawable_frame == strip.
left_handle;
353 float timeline_frame;
354 if (draw_next_frame_ontop) {
355 timeline_frame = first_drawable_frame;
358 timeline_frame = strip.
strip->start + aligned_frame_offset;
362 while (timeline_frame < upper_thumb_bound) {
378 if (!should_add_next_thumbnail) {
382 if (draw_next_frame_ontop) {
383 timeline_frame = strip.
strip->start + aligned_frame_offset + thumb_width;
384 draw_next_frame_ontop =
false;
387 timeline_frame += thumb_width;
425 const SeqThumbInfo &info,
float width,
const rcti &rect,
int tex_width,
int tex_height)
438 res.tint_color =
float4(1.0f, 1.0f, 1.0f, info.
is_muted ? 0.47f : 1.0f);
494 show_only_at_strip_ends,
505 constexpr int ATLAS_WIDTH = 4096;
506 constexpr int ATLAS_MAX_HEIGHT = 4096;
509 int cur_row_height = 0;
513 int cropx_min = int(info.cropx_min);
514 int cropx_max = int(
math::ceil(info.cropx_max));
515 int width = cropx_max - cropx_min + 1;
516 int height = info.ibuf->y;
517 cur_row_height =
math::max(cur_row_height, height);
520 if (cur_row_x + width > ATLAS_WIDTH) {
521 cur_row_y += cur_row_height + 1;
522 cur_row_height = height;
524 if (cur_row_y > ATLAS_MAX_HEIGHT) {
530 rcti rect{cur_row_x, cur_row_x + width, cur_row_y, cur_row_y + height};
534 cur_row_x += width + 1;
538 const int tex_width = ATLAS_WIDTH;
539 const int tex_height = cur_row_y + cur_row_height;
543 const rcti &rect = rects[i];
547 BLI_assert_msg(thumb_image !=
nullptr,
"Sequencer thumbnails are expected to be byte images");
550 int width = cropx_max - cropx_min + 1;
551 int height = info.
ibuf->
y;
552 const uchar *src = thumb_image + cropx_min * 4;
553 uchar *dst = &tex_data[(rect.
ymin * ATLAS_WIDTH + rect.
xmin) * 4];
554 for (
int y = 0;
y < height;
y++) {
555 memcpy(dst, src, width * 4);
556 src += info.
ibuf->
x * 4;
557 dst += ATLAS_WIDTH * 4;
568 gpu::TextureFormat::UNORM_8_8_8_8,
581 const rcti &rect = rects[i];
#define PRF_scope_with_name(ui_name, category)
#define BLI_assert_msg(a, msg)
void append(const T &value)
void reserve(const int64_t min_capacity)
const T & data(const Action &owning_action) const
float pos_to_pixel_space_x(float x) const
gpu::UniformBuf * get_ubo_context() const
float pos_to_pixel_space_y(float y) const
static void get_seq_strip_middle_thumbnail(const View2D *v2d, const bContext *C, const StripDrawContext &strip, Scene *scene, const float thumb_width, const float crop_x_multiplier, const float upper_thumb_bound, bool is_muted, Vector< SeqThumbInfo > &r_thumbs)
void draw_strip_thumbnails(const TimelineDrawContext &ctx, StripsDrawBatch &strips_batch, const Vector< StripDrawContext > &strips)
static bool is_thumbnail_in_view(const float timeline_frame, const float thumb_width, const View2D *v2d)
static void strip_get_thumb_image_dimensions(const Strip *strip, float pixelx, float pixely, float *r_thumb_width, float thumb_height, float *r_image_width, float *r_image_height)
static bool add_thumbnail_at_frame(float timeline_frame, const bContext *C, const View2D *v2d, const StripDrawContext &strip, Scene *scene, float thumb_width, float crop_left, float crop_right, float crop_x_multiplier, float upper_thumb_bound, float display_offset, bool is_muted, Vector< SeqThumbInfo > &r_thumbs)
static void get_seq_strip_ends_thumbnails(const View2D *v2d, const bContext *C, const StripDrawContext &strip, Scene *scene, const float thumb_width, const float crop_x_multiplier, const float upper_thumb_bound, bool is_muted, Vector< SeqThumbInfo > &r_thumbs)
static void get_seq_strip_thumbnails(const View2D *v2d, const bContext *C, Scene *scene, const StripDrawContext &strip, bool is_muted, bool show_only_middle, bool show_only_at_strip_ends, Vector< SeqThumbInfo > &r_thumbs)
T max(const T &a, const T &b)
bool strip_can_have_thumbnail(const Scene *scene, const Strip *strip)
ImBuf * thumbnail_cache_get(const bContext *C, Scene *scene, const Strip *strip, float timeline_frame)
void image_size_to_thumb_size(int &r_width, int &r_height, int size)
float view2d_pixel_size_get_y(const View2D *v2d)
float view2d_pixel_size_get_x(const View2D *v2d)
MINLINE float min_ff(float a, float b)
int GPU_shader_get_sampler_binding(gpu::Shader *shader, const char *name)
void wmOrtho2_region_pixelspace(const ARegion *region)
@ SEQ_TIMELINE_MIDDLE_THUMBNAILS
@ SEQ_TIMELINE_STRIP_END_THUMBNAILS
@ SEQ_TIMELINE_SHOW_THUMBNAILS
void GPU_texture_update(gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
void GPU_uniformbuf_free(gpu::UniformBuf *ubo)
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
void GPU_batch_set_shader(gpu::Batch *batch, gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
VecBase< float, 4 > float4
void IMB_freeImBuf(ImBuf *ibuf)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_SHADER_SEQUENCER_THUMBS
void GPU_texture_filter_mode(gpu::Texture *texture, bool use_filter)
void GPU_batch_draw_instance_range(gpu::Batch *batch, int instance_first, int instance_count)
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_uniformbuf_bind(gpu::UniformBuf *ubo, int slot)
void GPU_uniformbuf_update(gpu::UniformBuf *ubo, const void *data)
void GPU_texture_extend_mode(gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
gpu::Shader * GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
gpu::Batch * GPU_batch_preset_quad()
void GPU_matrix_pop_projection()
void GPU_texture_bind(gpu::Texture *texture, int unit)
MINLINE float max_ff(float a, float b)
void GPU_texture_free(gpu::Texture *texture)
int GPU_shader_get_ubo_binding(gpu::Shader *shader, const char *name)
void GPU_texture_unbind(gpu::Texture *texture)
void GPU_uniformbuf_unbind(gpu::UniformBuf *ubo)
void GPU_matrix_push_projection()
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
MINLINE float clamp_f(float value, float min, float max)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const uint8_t * byte_data() const
eSpaceSeq_SequencerTimelineOverlay_Flag flag
struct SequencerTimelineOverlay timeline_overlay
Array< SeqStripThumbData > thumbs_
StripsDrawBatch & strips_batch_
gpu::UniformBuf * ubo_thumbs_
ThumbsDrawBatch(StripsDrawBatch &strips_batch, gpu::Texture *atlas)
void add_thumb(const SeqThumbInfo &info, float width, const rcti &rect, int tex_width, int tex_height)