Blender V4.5
compositor/intern/context.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BLI_math_vector.hh"
6#include "BLI_rect.h"
7
8#include "DNA_node_types.h"
9#include "DNA_vec_types.h"
10
11#include "GPU_shader.hh"
12#include "GPU_texture_pool.hh"
13
14#include "BKE_node_runtime.hh"
15
16#include "COM_context.hh"
17#include "COM_profiler.hh"
18#include "COM_render_context.hh"
20
21namespace blender::compositor {
22
24{
25 return false;
26}
27
29 int /*view_layer_id*/,
30 const char * /*pass_name*/,
31 MetaData & /*meta_data*/) const
32{
33}
34
36{
37 return nullptr;
38}
39
41{
42 return nullptr;
43}
44
46
48{
49 if (!this->get_node_tree().runtime->test_break) {
50 return false;
51 }
52 return this->get_node_tree().runtime->test_break(get_node_tree().runtime->tbh);
53}
54
56{
57 cache_manager_.reset();
58}
59
61{
62 const rcti compositing_region = get_compositing_region();
63 const int x = BLI_rcti_size_x(&compositing_region);
64 const int y = BLI_rcti_size_y(&compositing_region);
65 return math::max(int2(1), int2(x, y));
66}
67
69{
70 const rcti compositing_region = get_compositing_region();
71 const int x = BLI_rcti_size_x(&compositing_region);
72 const int y = BLI_rcti_size_y(&compositing_region);
73 return x != 0 && y != 0;
74}
75
77{
78 return get_render_data().size / 100.0f;
79}
80
82{
83 return get_render_data().cfra;
84}
85
86float Context::get_time() const
87{
88 const float frame_number = float(get_frame_number());
89 const float frame_rate = float(get_render_data().frs_sec) /
90 float(get_render_data().frs_sec_base);
91 return frame_number / frame_rate;
92}
93
94GPUShader *Context::get_shader(const char *info_name, ResultPrecision precision)
95{
96 return cache_manager().cached_shaders.get(info_name, precision);
97}
98
99GPUShader *Context::get_shader(const char *info_name)
100{
101 return get_shader(info_name, get_precision());
102}
103
105{
106 return Result(*this, type, precision);
107}
108
113
115{
116 return cache_manager_;
117}
118
119} // namespace blender::compositor
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.h:198
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.h:194
GPUShader * get(const char *info_name, ResultPrecision precision)
virtual Profiler * profiler() const
virtual const RenderData & get_render_data() const =0
Result create_result(ResultType type, ResultPrecision precision)
virtual ResultPrecision get_precision() const =0
virtual void populate_meta_data_for_pass(const Scene *scene, int view_layer_id, const char *pass_name, MetaData &meta_data) const
GPUShader * get_shader(const char *info_name, ResultPrecision precision)
virtual bool treat_viewer_as_composite_output() const
virtual RenderContext * render_context() const
virtual const bNodeTree & get_node_tree() const =0
virtual rcti get_compositing_region() const =0
T max(const T &a, const T &b)
VecBase< int32_t, 2 > int2
bNodeTreeRuntimeHandle * runtime