Blender V4.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
9#pragma once
10
11#include "BLI_array.hh"
13#include "GPU_shader_shared.hh"
14
15struct GPUShader;
16struct GPUUniformBuf;
17struct View2D;
18
19namespace blender::gpu {
20class Batch;
21}
22
23namespace blender::ed::seq {
24
25/* Utility to draw VSE timeline strip widgets in batches, with a dedicated
26 * shader. Internally, strip data for drawing is encoded into a uniform
27 * buffer. Strip coordinates are converted into pixel space, to avoid
28 * precision issues at large frames. Drawing assumes that a pixel space
29 * projection matrix is set. */
31 SeqContextDrawData context_;
33 GPUUniformBuf *ubo_context_ = nullptr;
34 GPUUniformBuf *ubo_strips_ = nullptr;
35 GPUShader *shader_ = nullptr;
36 gpu::Batch *batch_ = nullptr;
37 int binding_context_ = 0;
38 int binding_strips_ = 0;
39 int strips_count_ = 0;
40
41 float2 view_mask_min_;
42 float2 view_mask_size_;
43 float2 view_cur_min_;
44 float2 view_cur_inv_size_;
45
46 public:
47 StripsDrawBatch(const View2D *v2d);
49
50 SeqStripDrawData &add_strip(float content_start,
51 float content_end,
52 float top,
53 float bottom,
54 float content_top,
55 float left_handle,
56 float right_handle,
57 float handle_width,
58 bool single_image);
59
60 void flush_batch();
61
62 /* Same math as `UI_view2d_view_to_region_*` but avoiding divisions,
63 * and without relying on View2D data type. */
64 inline float pos_to_pixel_space_x(float x) const
65 {
66 return (view_mask_min_.x + (x - view_cur_min_.x) * view_cur_inv_size_.x) * view_mask_size_.x;
67 }
68 inline float pos_to_pixel_space_y(float y) const
69 {
70 return (view_mask_min_.y + (y - view_cur_min_.y) * view_cur_inv_size_.y) * view_mask_size_.y;
71 }
72 inline float size_to_pixel_space_x(float x) const
73 {
74 return x * view_cur_inv_size_.x * view_mask_size_.x;
75 }
76
77 GPUUniformBuf *get_ubo_context() const
78 {
79 return ubo_context_;
80 }
81};
82
83uint color_pack(const uchar rgba[4]);
84float calc_strip_round_radius(float pixely);
85
86} // namespace blender::ed::seq
unsigned char uchar
unsigned int uint
struct GPUShader GPUShader
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)
uint color_pack(const uchar rgba[4])
float calc_strip_round_radius(float pixely)