Blender V5.0
vse_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_scene_types.h"
12#include "DNA_sequence_types.h"
13
14#include "IMB_imbuf.hh"
15
16#include "effects.hh"
17
18namespace blender::seq {
19
20static void init_solid_color(Strip *strip)
21{
22 if (strip->effectdata) {
23 MEM_freeN(strip->effectdata);
24 }
25
27 strip->effectdata = cv;
28
29 cv->col[0] = cv->col[1] = cv->col[2] = 0.5;
30}
31
32static int num_inputs_color()
33{
34 return 0;
35}
36
37static void free_solid_color(Strip *strip, const bool /*do_id_user*/)
38{
40}
41
42static void copy_solid_color(Strip *dst, const Strip *src, const int /*flag*/)
43{
45}
46
47static StripEarlyOut early_out_color(const Strip * /*strip*/, float /*fac*/)
48{
50}
51
52static ImBuf *do_solid_color(const RenderData *context,
53 SeqRenderState * /*state*/,
54 Strip *strip,
55 float /*timeline_frame*/,
56 float /*fac*/,
57 ImBuf *ibuf1,
58 ImBuf *ibuf2)
59{
60 using namespace blender;
61 ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2);
62
64
65 threading::parallel_for(IndexRange(out->y), 64, [&](const IndexRange y_range) {
66 if (out->byte_buffer.data) {
67 /* Byte image. */
68 uchar color[4];
69 rgb_float_to_uchar(color, cv->col);
70 color[3] = 255;
71
72 uchar *dst = out->byte_buffer.data + y_range.first() * out->x * 4;
73 uchar *dst_end = dst + y_range.size() * out->x * 4;
74 while (dst < dst_end) {
75 memcpy(dst, color, sizeof(color));
76 dst += 4;
77 }
78 }
79 else {
80 /* Float image. */
81 float color[4];
82 color[0] = cv->col[0];
83 color[1] = cv->col[1];
84 color[2] = cv->col[2];
85 color[3] = 1.0f;
86
87 float *dst = out->float_buffer.data + y_range.first() * out->x * 4;
88 float *dst_end = dst + y_range.size() * out->x * 4;
89 while (dst < dst_end) {
90 memcpy(dst, color, sizeof(color));
91 dst += 4;
92 }
93 }
94 });
95
96 out->planes = R_IMF_PLANES_RGB;
97
98 return out;
99}
100
110
111} // namespace blender::seq
@ R_IMF_PLANES_RGB
#define MEM_SAFE_FREE(v)
#define out
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void * MEM_dupallocN(const void *vmemh)
Definition mallocn.cc:143
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
static ImBuf * do_solid_color(const RenderData *context, SeqRenderState *, Strip *strip, float, float, ImBuf *ibuf1, ImBuf *ibuf2)
static void copy_solid_color(Strip *dst, const Strip *src, const int)
static int num_inputs_color()
void solid_color_effect_get_handle(EffectHandle &rval)
static StripEarlyOut early_out_color(const Strip *, float)
ImBuf * prepare_effect_imbufs(const RenderData *context, ImBuf *ibuf1, ImBuf *ibuf2, bool uninitialized_pixels)
Definition effects.cc:28
static void init_solid_color(Strip *strip)
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:93
void * effectdata
void(* copy)(Strip *dst, const Strip *src, int flag)
ImBuf *(* execute)(const RenderData *context, SeqRenderState *state, Strip *strip, float timeline_frame, float fac, ImBuf *ibuf1, ImBuf *ibuf2)
void(* free)(Strip *strip, bool do_id_user)
StripEarlyOut(* early_out)(const Strip *strip, float fac)
void(* init)(Strip *strip)