Blender V4.5
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 Strip *strip,
54 float /*timeline_frame*/,
55 float /*fac*/,
56 ImBuf *ibuf1,
57 ImBuf *ibuf2)
58{
59 using namespace blender;
60 ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2);
61
63
64 threading::parallel_for(IndexRange(out->y), 64, [&](const IndexRange y_range) {
65 if (out->byte_buffer.data) {
66 /* Byte image. */
67 uchar color[4];
68 rgb_float_to_uchar(color, cv->col);
69 color[3] = 255;
70
71 uchar *dst = out->byte_buffer.data + y_range.first() * out->x * 4;
72 uchar *dst_end = dst + y_range.size() * out->x * 4;
73 while (dst < dst_end) {
74 memcpy(dst, color, sizeof(color));
75 dst += 4;
76 }
77 }
78 else {
79 /* Float image. */
80 float color[4];
81 color[0] = cv->col[0];
82 color[1] = cv->col[1];
83 color[2] = cv->col[2];
84 color[3] = 1.0f;
85
86 float *dst = out->float_buffer.data + y_range.first() * out->x * 4;
87 float *dst_end = dst + y_range.size() * out->x * 4;
88 while (dst < dst_end) {
89 memcpy(dst, color, sizeof(color));
90 dst += 4;
91 }
92 }
93 });
94
95 out->planes = R_IMF_PLANES_RGB;
96
97 return out;
98}
99
109
110} // namespace blender::seq
@ R_IMF_PLANES_RGB
#define out
#define MEM_SAFE_FREE(v)
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, 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, 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)