41 : frame(frame), smoothness(smoothness)
52 return a.frame ==
b.frame && a.smoothness ==
b.smoothness;
88 image_buffer, track, marker,
true,
false);
89 if (!pattern_image_buffer) {
95 for (
int i = 0; i < pattern_image_buffer->
x * pattern_image_buffer->
y; i++) {
103 mean_color += linear_color;
106 mean_color /= pattern_image_buffer->
x * pattern_image_buffer->
y;
108 marker_colors.
append(mean_color);
109 marker_positions.
append(position);
121 const int scene_frame = context.get_frame_number();
124 return movie_clip_user;
139 movie_clip, movie_clip_user, movie_tracking_object, marker_positions, marker_colors);
141 GPUShader *shader = context.get_shader(
"compositor_keying_screen");
152 if (marker_positions.
size() % 2 == 1) {
158 marker_positions.
data(),
165 marker_colors.
data(),
221 for (
auto &cached_keying_screens_for_id : map_.values()) {
222 cached_keying_screens_for_id.remove_if([](
auto item) {
return !item.value->needed; });
224 map_.remove_if([](
auto item) {
return item.value.is_empty(); });
228 for (
auto &cached_keying_screens_for_id : map_.values()) {
229 for (
auto &value : cached_keying_screens_for_id.values()) {
230 value->needed =
false;
244 const std::string library_key = movie_clip->
id.
lib ? movie_clip->
id.
lib->
id.
name :
"";
245 const std::string id_key = std::string(movie_clip->
id.
name) + library_key;
246 const std::string object_key = id_key + movie_tracking_object->
name;
247 auto &cached_keying_screens_for_id = map_.lookup_or_add_default(object_key);
251 if (context.query_id_recalc_flag(
reinterpret_cast<ID *
>(movie_clip)) &
ID_RECALC_ALL) {
252 cached_keying_screens_for_id.clear();
255 auto &keying_screen = *cached_keying_screens_for_id.lookup_or_add_cb(key, [&]() {
256 return std::make_unique<KeyingScreen>(context, movie_clip, movie_tracking_object, smoothness);
259 keying_screen.needed =
true;
260 return keying_screen;
float BKE_movieclip_remap_scene_to_clip_frame(const struct MovieClip *clip, float framenr)
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr)
void BKE_movieclip_get_size(struct MovieClip *clip, const struct MovieClipUser *user, int *r_width, int *r_height)
struct ImBuf * BKE_movieclip_get_ibuf(struct MovieClip *clip, const struct MovieClipUser *user)
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
struct ImBuf * BKE_tracking_get_pattern_imbuf(const struct ImBuf *ibuf, const struct MovieTrackingTrack *track, const struct MovieTrackingMarker *marker, bool anchored, bool disable_channels)
#define LISTBASE_FOREACH(type, var, list)
MINLINE void srgb_to_linearrgb_uchar4(float linear[4], const unsigned char srgb[4])
#define DNA_struct_default_get(struct_name)
int GPU_shader_get_sampler_binding(GPUShader *shader, const char *name)
void GPU_shader_uniform_1i(GPUShader *sh, const char *name, int value)
void GPU_shader_uniform_1f(GPUShader *sh, const char *name, float value)
int GPU_shader_get_ssbo_binding(GPUShader *shader, const char *name)
void GPU_shader_bind(GPUShader *shader)
void GPU_storagebuf_bind(GPUStorageBuf *ssbo, int slot)
GPUStorageBuf * GPU_storagebuf_create_ex(size_t size, const void *data, GPUUsageType usage, const char *name)
void GPU_storagebuf_unbind(GPUStorageBuf *ssbo)
void GPU_storagebuf_free(GPUStorageBuf *ssbo)
void GPU_texture_bind(GPUTexture *texture, int unit)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_free(GPUTexture *texture)
void GPU_texture_unbind(GPUTexture *texture)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
void GPU_texture_image_unbind(GPUTexture *texture)
void GPU_texture_image_bind(GPUTexture *texture, int unit)
struct GPUShader GPUShader
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void append(const T &value)
KeyingScreen & get(Context &context, MovieClip *movie_clip, MovieTrackingObject *movie_tracking_object, float smoothness)
KeyingScreenKey(int frame, float smoothness)
void unbind_as_texture() const
GPUTexture * texture() const
KeyingScreen(Context &context, MovieClip *movie_clip, MovieTrackingObject *movie_tracking_object, float smoothness)
void bind_as_texture(GPUShader *shader, const char *texture_name) const
static eGPUTextureFormat gpu_texture_format(ResultType type, ResultPrecision precision)
local_group_size(16, 16) .push_constant(Type b
void IMB_freeImBuf(ImBuf *)
T clamp(const T &a, const T &min, const T &max)
static MovieClipUser get_movie_clip_user(Context &context, MovieClip *movie_clip)
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
static void compute_marker_points(MovieClip *movie_clip, MovieClipUser &movie_clip_user, MovieTrackingObject *movie_tracking_object, Vector< float2 > &marker_positions, Vector< float4 > &marker_colors)
void compute_dispatch_threads_at_least(GPUShader *shader, int2 threads_range, int2 local_size=int2(16))
blender::VecBase< uint8_t, 4 > uchar4
VecBase< float, 4 > float4
VecBase< float, 2 > float2
uint64_t get_default_hash(const T &v)
unsigned __int64 uint64_t
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer