Blender V5.3
effect_solid_color.cc
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#include "BLI_task.hh"
10
11#include "DNA_sequence_types.h"
12
13#include "IMB_imbuf.hh"
14
15#include "PRF_profile.hh"
16
17#include "effects.hh"
18
19namespace blender::seq {
20
21static void init_solid_color(Strip *strip)
22{
23 SolidColorVars *data = MEM_new<SolidColorVars>("solidcolor");
24 strip->effectdata = data;
25 data->col[0] = data->col[1] = data->col[2] = 0.5;
26 data->width = data->height = 1;
27}
28
29static void free_solid_color(Strip *strip, const bool /*do_id_user*/)
30{
31 if (strip->effectdata) {
32 SolidColorVars *data = static_cast<SolidColorVars *>(strip->effectdata);
33 MEM_delete(data);
34 strip->effectdata = nullptr;
35 }
36}
37
38static StripEarlyOut early_out_color(const Strip * /*strip*/, float /*fac*/)
39{
41}
42
43static SeqResult do_solid_color(const RenderData * /*context*/,
44 SeqRenderState * /*state*/,
45 Strip *strip,
46 float /*timeline_frame*/,
47 float /*fac*/,
48 const SeqResult & /*ibuf1*/,
49 const SeqResult & /*ibuf2*/)
50{
53
54 const SolidColorVars *cv = static_cast<const SolidColorVars *>(strip->effectdata);
56
57 uchar color[4];
59 color[3] = 255;
60
61 uchar *byte_data = out.image->byte_data_for_write();
62 threading::parallel_for(IndexRange(out.image->y), 64, [&](const IndexRange y_range) {
63 uchar *dst = byte_data + y_range.first() * out.image->x * 4;
64 uchar *dst_end = dst + y_range.size() * out.image->x * 4;
65 while (dst < dst_end) {
66 memcpy(dst, color, sizeof(color));
67 dst += 4;
68 }
69 });
70
71 out.image->color_mode = ImColorMode::RGB;
72 out.is_opaque_before_transform = true;
73
74 return out;
75}
76
84
85} // namespace blender::seq
#define PRF_scope_with_name(ui_name, category)
constexpr IndexRange()=default
void solid_color_effect_get_handle(EffectHandle &rval)
static StripEarlyOut early_out_color(const Strip *, float)
static void init_solid_color(Strip *strip)
static SeqResult do_solid_color(const RenderData *, SeqRenderState *, Strip *strip, float, float, const SeqResult &, const SeqResult &)
static void free_solid_color(Strip *strip, const bool)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
MINLINE void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
unsigned char uchar
Definition BKE_text.h:58
BMesh const char void * data
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, ImBufFlags flags)
void(*) free(Strip *strip, bool do_id_user)
Definition effects.hh:47
void(*) init(Strip *strip)
Definition effects.hh:41
StripEarlyOut(*) early_out(const Strip *strip, float fac)
Definition effects.hh:49
SeqResult(*) execute(const RenderData *context, SeqRenderState *state, Strip *strip, float timeline_frame, float fac, const SeqResult &input1, const SeqResult &input2)
Definition effects.hh:52