Compositor: Allow delayed typing for results

This patch allows result to have their types set after construction but
before allocation.
This commit is contained in:
Omar Emara
2024-08-19 11:06:10 +03:00
parent 975dcea23f
commit ba61fc9326
2 changed files with 15 additions and 0 deletions

View File

@@ -160,6 +160,9 @@ class Result {
MetaData meta_data;
public:
/* Construct a result within the given context. */
Result(Context &context);
/* Construct a result of the given type and precision within the given context. */
Result(Context &context, ResultType type, ResultPrecision precision);
@@ -337,6 +340,9 @@ class Result {
/* Returns the precision of the result. */
ResultPrecision precision() const;
/* Sets the type of the result. */
void set_type(ResultType type);
/* Sets the precision of the result. */
void set_precision(ResultPrecision precision);

View File

@@ -19,6 +19,8 @@
namespace blender::realtime_compositor {
Result::Result(Context &context) : context_(&context) {}
Result::Result(Context &context, ResultType type, ResultPrecision precision)
: context_(&context), type_(type), precision_(precision)
{
@@ -646,6 +648,13 @@ ResultPrecision Result::precision() const
return precision_;
}
void Result::set_type(ResultType type)
{
/* Changing the type can only be done if it wasn't allocated yet. */
BLI_assert(!this->is_allocated());
type_ = type;
}
void Result::set_precision(ResultPrecision precision)
{
/* Changing the precision can only be done if it wasn't allocated yet. */