Blender V5.3
sequencer_strips_batch.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_array.hh"
13#include "GPU_shader_shared.hh"
14
15namespace blender {
16
17namespace gpu {
18class Shader;
19class UniformBuf;
20} // namespace gpu
21struct View2D;
22
23namespace gpu {
24class Batch;
25}
26
27namespace ed::vse {
28
29/* Utility to draw VSE timeline strip widgets in batches, with a dedicated
30 * shader. Internally, strip data for drawing is encoded into a uniform
31 * buffer. Strip coordinates are converted into pixel space, to avoid
32 * precision issues at large frames. Drawing assumes that a pixel space
33 * projection matrix is set. */
35 SeqContextDrawData context_;
37 gpu::UniformBuf *ubo_context_ = nullptr;
38 gpu::UniformBuf *ubo_strips_ = nullptr;
39 gpu::Shader *shader_ = nullptr;
40 gpu::Batch *batch_ = nullptr;
41 int binding_context_ = 0;
42 int binding_strips_ = 0;
43 int strips_count_ = 0;
44
45 float2 view_mask_min_;
46 float2 view_mask_size_;
47 float2 view_cur_min_;
48 float2 view_cur_inv_size_;
49
50 public:
51 StripsDrawBatch(const View2D *v2d);
53
54 SeqStripDrawData &add_strip(float content_start,
55 float content_end,
56 float top,
57 float bottom,
58 float content_top,
59 float left_handle,
60 float right_handle,
61 float handle_width,
62 bool single_image);
63
64 void flush_batch();
65
66 /* Same math as `view2d_view_to_region_*` but avoiding divisions,
67 * and without relying on View2D data type. */
68 float pos_to_pixel_space_x(float x) const
69 {
70 return (view_mask_min_.x + (x - view_cur_min_.x) * view_cur_inv_size_.x) * view_mask_size_.x;
71 }
72 float pos_to_pixel_space_y(float y) const
73 {
74 return (view_mask_min_.y + (y - view_cur_min_.y) * view_cur_inv_size_.y) * view_mask_size_.y;
75 }
76 float size_to_pixel_space_x(float x) const
77 {
78 return x * view_cur_inv_size_.x * view_mask_size_.x;
79 }
80
82 {
83 return ubo_context_;
84 }
85};
86
87uint color_pack(const uchar rgba[4]);
88float calc_strip_round_radius(float pixely);
89
90} // namespace ed::vse
91} // namespace blender
SeqStripDrawData & add_strip(float content_start, float content_end, float top, float bottom, float content_top, float left_handle, float right_handle, float handle_width, bool single_image)
gpu::UniformBuf * get_ubo_context() const
float calc_strip_round_radius(float pixely)
uint color_pack(const uchar rgba[4])
BMesh Iterators.
unsigned int uint
Definition BKE_text.h:55
VecBase< float, 2 > float2
unsigned char uchar
Definition BKE_text.h:58