Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Castilla <manzanillawork@gmail.com>2021-09-28 20:32:49 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-09-28 23:00:16 +0300
commit76377f0176b9561a7fc8f46b4ed704c631ddd90d (patch)
tree96775442f403dfdb0dc4d91f835495c72c1ca9c1
parent2ecd963d87e4f5215d1d86e7f1c22ab7833697f3 (diff)
Compositor: Replace resolution concept by canvas
This is a code refactor in preparation of supporting canvas compositing. See {D12466}. No functional changes, all canvases are at (0,0) position matching tiled implementation. Differential Revision: https://developer.blender.org/D12465
-rw-r--r--source/blender/compositor/COM_defines.h3
-rw-r--r--source/blender/compositor/intern/COM_BufferOperation.cc7
-rw-r--r--source/blender/compositor/intern/COM_Converter.cc22
-rw-r--r--source/blender/compositor/intern/COM_Converter.h6
-rw-r--r--source/blender/compositor/intern/COM_Debug.cc4
-rw-r--r--source/blender/compositor/intern/COM_FullFrameExecutionModel.cc10
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cc85
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h92
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.cc25
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.h4
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.cc6
-rw-r--r--source/blender/compositor/nodes/COM_CombineColorNode.cc8
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.cc2
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cc2
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.cc2
-rw-r--r--source/blender/compositor/nodes/COM_MapUVNode.cc2
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.cc2
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.cc4
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cc23
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.cc30
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.cc10
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.cc6
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.cc4
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cc13
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_ConstantOperation.cc4
-rw-r--r--source/blender/compositor/operations/COM_ConstantOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.cc9
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_DenoiseOperation.cc5
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.cc5
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.cc5
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.cc5
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc5
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc10
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.cc11
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cc11
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.cc5
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.cc12
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.cc19
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.cc17
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cc17
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.cc22
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.cc10
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.cc12
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.cc16
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.cc6
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_PixelateOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc14
-rw-r--r--source/blender/compositor/operations/COM_PlaneCornerPinOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc5
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackOperation.cc12
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackOperation.h23
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cc15
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.cc9
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.cc9
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.h3
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.cc5
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cc19
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc7
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.cc6
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.cc6
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.cc6
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_SplitOperation.cc12
-rw-r--r--source/blender/compositor/operations/COM_SplitOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_SunBeamsOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cc28
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.cc6
-rw-r--r--source/blender/compositor/operations/COM_TrackPositionOperation.cc6
-rw-r--r--source/blender/compositor/operations/COM_TrackPositionOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_TransformOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc19
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cc5
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cc10
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_WrapOperation.cc4
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.cc15
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.h3
109 files changed, 390 insertions, 543 deletions
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
index 73c4343a230..e0f23fbede3 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -121,7 +121,8 @@ constexpr float COM_PREVIEW_SIZE = 140.f;
constexpr float COM_RULE_OF_THIRDS_DIVIDER = 100.0f;
constexpr float COM_BLUR_BOKEH_PIXELS = 512;
-constexpr rcti COM_SINGLE_ELEM_AREA = {0, 1, 0, 1};
+constexpr rcti COM_AREA_NONE = {0, 0, 0, 0};
+constexpr rcti COM_CONSTANT_INPUT_AREA_OF_INTEREST = COM_AREA_NONE;
constexpr IndexRange XRange(const rcti &area)
{
diff --git a/source/blender/compositor/intern/COM_BufferOperation.cc b/source/blender/compositor/intern/COM_BufferOperation.cc
index cafdff89c8e..c6530cf6bd1 100644
--- a/source/blender/compositor/intern/COM_BufferOperation.cc
+++ b/source/blender/compositor/intern/COM_BufferOperation.cc
@@ -24,12 +24,7 @@ BufferOperation::BufferOperation(MemoryBuffer *buffer, DataType data_type)
{
buffer_ = buffer;
inflated_buffer_ = nullptr;
- /* TODO: Implement a MemoryBuffer get_size() method returning a Size2d type. Shorten following
- * code to: set_resolution(buffer.get_size()) */
- unsigned int resolution[2];
- resolution[0] = buffer->getWidth();
- resolution[1] = buffer->getHeight();
- setResolution(resolution);
+ set_canvas(buffer->get_rect());
addOutputSocket(data_type);
flags.is_constant_operation = buffer_->is_a_single_elem();
flags.is_fullframe_operation = false;
diff --git a/source/blender/compositor/intern/COM_Converter.cc b/source/blender/compositor/intern/COM_Converter.cc
index 4b103c21c75..bd05a8e4ef0 100644
--- a/source/blender/compositor/intern/COM_Converter.cc
+++ b/source/blender/compositor/intern/COM_Converter.cc
@@ -460,9 +460,9 @@ NodeOperation *COM_convert_data_type(const NodeOperationOutput &from, const Node
return nullptr;
}
-void COM_convert_resolution(NodeOperationBuilder &builder,
- NodeOperationOutput *fromSocket,
- NodeOperationInput *toSocket)
+void COM_convert_canvas(NodeOperationBuilder &builder,
+ NodeOperationOutput *fromSocket,
+ NodeOperationInput *toSocket)
{
/* Data type conversions are executed before resolutions to ensure convert operations have
* resolution. This method have to ensure same datatypes are linked for new operations. */
@@ -535,10 +535,10 @@ void COM_convert_resolution(NodeOperationBuilder &builder,
builder.addOperation(sxop);
builder.addOperation(syop);
- unsigned int resolution[2] = {fromOperation->getWidth(), fromOperation->getHeight()};
- scaleOperation->setResolution(resolution);
- sxop->setResolution(resolution);
- syop->setResolution(resolution);
+ const rcti &scale_canvas = fromOperation->get_canvas();
+ scaleOperation->set_canvas(scale_canvas);
+ sxop->set_canvas(scale_canvas);
+ syop->set_canvas(scale_canvas);
builder.addOperation(scaleOperation);
}
@@ -557,10 +557,10 @@ void COM_convert_resolution(NodeOperationBuilder &builder,
builder.addOperation(xop);
builder.addOperation(yop);
- unsigned int resolution[2] = {toOperation->getWidth(), toOperation->getHeight()};
- translateOperation->setResolution(resolution);
- xop->setResolution(resolution);
- yop->setResolution(resolution);
+ const rcti &translate_canvas = toOperation->get_canvas();
+ translateOperation->set_canvas(translate_canvas);
+ xop->set_canvas(translate_canvas);
+ yop->set_canvas(translate_canvas);
builder.addOperation(translateOperation);
if (doScale) {
diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h
index 28136437103..7f0402d4e70 100644
--- a/source/blender/compositor/intern/COM_Converter.h
+++ b/source/blender/compositor/intern/COM_Converter.h
@@ -65,8 +65,8 @@ NodeOperation *COM_convert_data_type(const NodeOperationOutput &from,
* \note Conversion logic is implemented in this function.
* \see InputSocketResizeMode for the possible conversions.
*/
-void COM_convert_resolution(NodeOperationBuilder &builder,
- NodeOperationOutput *fromSocket,
- NodeOperationInput *toSocket);
+void COM_convert_canvas(NodeOperationBuilder &builder,
+ NodeOperationOutput *fromSocket,
+ NodeOperationInput *toSocket);
} // namespace blender::compositor
diff --git a/source/blender/compositor/intern/COM_Debug.cc b/source/blender/compositor/intern/COM_Debug.cc
index f2dcba65b7c..9e47aa9fcb5 100644
--- a/source/blender/compositor/intern/COM_Debug.cc
+++ b/source/blender/compositor/intern/COM_Debug.cc
@@ -162,8 +162,10 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system,
len += snprintf(str + len,
maxlen > len ? maxlen - len : 0,
- "#%d (%u,%u)",
+ "#%d (%i,%i) (%u,%u)",
operation->get_id(),
+ operation->get_canvas().xmin,
+ operation->get_canvas().ymin,
operation->getWidth(),
operation->getHeight());
diff --git a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc
index bd3a481d691..957bbe24e5f 100644
--- a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc
+++ b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc
@@ -87,12 +87,9 @@ Vector<MemoryBuffer *> FullFrameExecutionModel::get_input_buffers(NodeOperation
MemoryBuffer *FullFrameExecutionModel::create_operation_buffer(NodeOperation *op)
{
- rcti op_rect;
- BLI_rcti_init(&op_rect, 0, op->getWidth(), 0, op->getHeight());
-
const DataType data_type = op->getOutputSocket(0)->getDataType();
const bool is_a_single_elem = op->get_flags().is_constant_operation;
- return new MemoryBuffer(data_type, op_rect, is_a_single_elem);
+ return new MemoryBuffer(data_type, op->get_canvas(), is_a_single_elem);
}
void FullFrameExecutionModel::render_operation(NodeOperation *op)
@@ -199,12 +196,11 @@ void FullFrameExecutionModel::determine_areas_to_render(NodeOperation *output_op
const int num_inputs = operation->getNumberOfInputSockets();
for (int i = 0; i < num_inputs; i++) {
NodeOperation *input_op = operation->get_input_operation(i);
- rcti input_op_rect, input_area;
- BLI_rcti_init(&input_op_rect, 0, input_op->getWidth(), 0, input_op->getHeight());
+ rcti input_area;
operation->get_area_of_interest(input_op, render_area, input_area);
/* Ensure area of interest is within operation bounds, cropping areas outside. */
- BLI_rcti_isect(&input_area, &input_op_rect, &input_area);
+ BLI_rcti_isect(&input_area, &input_op->get_canvas(), &input_area);
stack.append({input_op, input_area});
}
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cc b/source/blender/compositor/intern/COM_NodeOperation.cc
index 3bbd1b22d60..ff232efdb08 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cc
+++ b/source/blender/compositor/intern/COM_NodeOperation.cc
@@ -35,9 +35,8 @@ namespace blender::compositor {
NodeOperation::NodeOperation()
{
- this->m_resolutionInputSocketIndex = 0;
- this->m_width = 0;
- this->m_height = 0;
+ canvas_input_index_ = 0;
+ canvas_ = COM_AREA_NONE;
this->m_btree = nullptr;
}
@@ -48,7 +47,7 @@ NodeOperation::NodeOperation()
*/
std::optional<NodeOperationHash> NodeOperation::generate_hash()
{
- params_hash_ = get_default_hash_2(m_width, m_height);
+ params_hash_ = get_default_hash_2(canvas_.xmin, canvas_.xmax);
/* Hash subclasses params. */
is_hash_output_params_implemented_ = true;
@@ -57,7 +56,11 @@ std::optional<NodeOperationHash> NodeOperation::generate_hash()
return std::nullopt;
}
- hash_param(getOutputSocket()->getDataType());
+ hash_params(canvas_.ymin, canvas_.ymax);
+ if (m_outputs.size() > 0) {
+ BLI_assert(m_outputs.size() == 1);
+ hash_param(this->getOutputSocket()->getDataType());
+ }
NodeOperationHash hash;
hash.params_hash_ = params_hash_;
@@ -108,48 +111,46 @@ void NodeOperation::addOutputSocket(DataType datatype)
m_outputs.append(NodeOperationOutput(this, datatype));
}
-void NodeOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- unsigned int used_resolution_index = 0;
- if (m_resolutionInputSocketIndex == RESOLUTION_INPUT_ANY) {
+ unsigned int used_canvas_index = 0;
+ if (canvas_input_index_ == RESOLUTION_INPUT_ANY) {
for (NodeOperationInput &input : m_inputs) {
- unsigned int any_resolution[2] = {0, 0};
- input.determineResolution(any_resolution, preferredResolution);
- if (any_resolution[0] * any_resolution[1] > 0) {
- resolution[0] = any_resolution[0];
- resolution[1] = any_resolution[1];
+ rcti any_area = COM_AREA_NONE;
+ const bool determined = input.determine_canvas(preferred_area, any_area);
+ if (determined) {
+ r_area = any_area;
break;
}
- used_resolution_index += 1;
+ used_canvas_index += 1;
}
}
- else if (m_resolutionInputSocketIndex < m_inputs.size()) {
- NodeOperationInput &input = m_inputs[m_resolutionInputSocketIndex];
- input.determineResolution(resolution, preferredResolution);
- used_resolution_index = m_resolutionInputSocketIndex;
+ else if (canvas_input_index_ < m_inputs.size()) {
+ NodeOperationInput &input = m_inputs[canvas_input_index_];
+ input.determine_canvas(preferred_area, r_area);
+ used_canvas_index = canvas_input_index_;
}
- if (modify_determined_resolution_fn_) {
- modify_determined_resolution_fn_(resolution);
+ if (modify_determined_canvas_fn_) {
+ modify_determined_canvas_fn_(r_area);
}
- unsigned int temp2[2] = {resolution[0], resolution[1]};
- unsigned int temp[2];
+ rcti unused_area;
+ const rcti &local_preferred_area = r_area;
for (unsigned int index = 0; index < m_inputs.size(); index++) {
- if (index == used_resolution_index) {
+ if (index == used_canvas_index) {
continue;
}
NodeOperationInput &input = m_inputs[index];
if (input.isConnected()) {
- input.determineResolution(temp, temp2);
+ input.determine_canvas(local_preferred_area, unused_area);
}
}
}
-void NodeOperation::setResolutionInputSocketIndex(unsigned int index)
+void NodeOperation::set_canvas_input_index(unsigned int index)
{
- this->m_resolutionInputSocketIndex = index;
+ this->canvas_input_index_ = index;
}
void NodeOperation::init_data()
@@ -260,7 +261,7 @@ void NodeOperation::get_area_of_interest(const int input_idx,
/* Non full-frame operations never implement this method. To ensure correctness assume
* whole area is used. */
NodeOperation *input_op = getInputOperation(input_idx);
- BLI_rcti_init(&r_input_area, 0, input_op->getWidth(), 0, input_op->getHeight());
+ r_input_area = input_op->get_canvas();
}
}
@@ -420,12 +421,16 @@ SocketReader *NodeOperationInput::getReader()
return nullptr;
}
-void NodeOperationInput::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+/**
+ * \return Whether canvas area could be determined.
+ */
+bool NodeOperationInput::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
if (m_link) {
- m_link->determineResolution(resolution, preferredResolution);
+ m_link->determine_canvas(preferred_area, r_area);
+ return !BLI_rcti_is_empty(&r_area);
}
+ return false;
}
/******************
@@ -437,18 +442,16 @@ NodeOperationOutput::NodeOperationOutput(NodeOperation *op, DataType datatype)
{
}
-void NodeOperationOutput::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void NodeOperationOutput::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
NodeOperation &operation = getOperation();
- if (operation.get_flags().is_resolution_set) {
- resolution[0] = operation.getWidth();
- resolution[1] = operation.getHeight();
+ if (operation.get_flags().is_canvas_set) {
+ r_area = operation.get_canvas();
}
else {
- operation.determineResolution(resolution, preferredResolution);
- if (resolution[0] > 0 && resolution[1] > 0) {
- operation.setResolution(resolution);
+ operation.determine_canvas(preferred_area, r_area);
+ if (!BLI_rcti_is_empty(&r_area)) {
+ operation.set_canvas(r_area);
}
}
}
@@ -470,8 +473,8 @@ std::ostream &operator<<(std::ostream &os, const NodeOperationFlags &node_operat
if (node_operation_flags.use_viewer_border) {
os << "view_border,";
}
- if (node_operation_flags.is_resolution_set) {
- os << "resolution_set,";
+ if (node_operation_flags.is_canvas_set) {
+ os << "canvas_set,";
}
if (node_operation_flags.is_set_operation) {
os << "set_operation,";
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index ef7cf319222..9f113b60345 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -130,7 +130,7 @@ class NodeOperationInput {
SocketReader *getReader();
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ bool determine_canvas(const rcti &preferred_area, rcti &r_area);
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
@@ -158,12 +158,7 @@ class NodeOperationOutput {
return m_datatype;
}
- /**
- * \brief determine the resolution of this data going through this socket
- * \param resolution: the result of this operation
- * \param preferredResolution: the preferable resolution as no resolution could be determined
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ void determine_canvas(const rcti &preferred_area, rcti &r_area);
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
@@ -211,9 +206,9 @@ struct NodeOperationFlags {
bool use_viewer_border : 1;
/**
- * Is the resolution of the operation set.
+ * Is the canvas of the operation set.
*/
- bool is_resolution_set : 1;
+ bool is_canvas_set : 1;
/**
* Is this a set operation (value, color, vector).
@@ -257,7 +252,7 @@ struct NodeOperationFlags {
open_cl = false;
use_render_border = false;
use_viewer_border = false;
- is_resolution_set = false;
+ is_canvas_set = false;
is_set_operation = false;
is_read_buffer_operation = false;
is_write_buffer_operation = false;
@@ -324,11 +319,11 @@ class NodeOperation {
bool is_hash_output_params_implemented_;
/**
- * \brief the index of the input socket that will be used to determine the resolution
+ * \brief the index of the input socket that will be used to determine the canvas
*/
- unsigned int m_resolutionInputSocketIndex;
+ unsigned int canvas_input_index_;
- std::function<void(unsigned int resolution[2])> modify_determined_resolution_fn_;
+ std::function<void(rcti &canvas)> modify_determined_canvas_fn_;
/**
* \brief mutex reference for very special node initializations
@@ -352,15 +347,7 @@ class NodeOperation {
*/
eExecutionModel execution_model_;
- /**
- * Width of the output of this operation.
- */
- unsigned int m_width;
-
- /**
- * Height of the output of this operation.
- */
- unsigned int m_height;
+ rcti canvas_;
/**
* Flags how to evaluate this operation.
@@ -374,11 +361,6 @@ class NodeOperation {
{
}
- void set_execution_model(const eExecutionModel model)
- {
- execution_model_ = model;
- }
-
void set_name(const std::string name)
{
m_name = name;
@@ -424,14 +406,7 @@ class NodeOperation {
return getInputOperation(index);
}
- /**
- * \brief determine the resolution of this node
- * \note this method will not set the resolution, this is the responsibility of the caller
- * \param resolution: the result of this operation
- * \param preferredResolution: the preferable resolution as no resolution could be determined
- */
- virtual void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]);
+ virtual void determine_canvas(const rcti &preferred_area, rcti &r_area);
/**
* \brief isOutputOperation determines whether this operation is an output of the
@@ -453,6 +428,11 @@ class NodeOperation {
return false;
}
+ void set_execution_model(const eExecutionModel model)
+ {
+ execution_model_ = model;
+ }
+
void setbNodeTree(const bNodeTree *tree)
{
this->m_btree = tree;
@@ -527,19 +507,19 @@ class NodeOperation {
}
virtual void deinitExecution();
- /**
- * \brief set the resolution
- * \param resolution: the resolution to set
- */
- void setResolution(unsigned int resolution[2])
+ void set_canvas(const rcti &canvas_area)
{
- if (!this->flags.is_resolution_set) {
- this->m_width = resolution[0];
- this->m_height = resolution[1];
- this->flags.is_resolution_set = true;
+ if (!this->flags.is_canvas_set) {
+ canvas_ = canvas_area;
+ flags.is_canvas_set = true;
}
}
+ const rcti &get_canvas() const
+ {
+ return canvas_;
+ }
+
/**
* \brief is this operation the active viewer output
* user can select an ViewerNode to be active
@@ -557,18 +537,18 @@ class NodeOperation {
rcti *output);
/**
- * \brief set the index of the input socket that will determine the resolution of this
+ * \brief set the index of the input socket that will determine the canvas of this
* operation \param index: the index to set
*/
- void setResolutionInputSocketIndex(unsigned int index);
+ void set_canvas_input_index(unsigned int index);
/**
- * Set a custom function to modify determined resolution from main input just before setting it
- * as preferred resolution for the other inputs.
+ * Set a custom function to modify determined canvas from main input just before setting it
+ * as preferred for the other inputs.
*/
- void set_determined_resolution_modifier(std::function<void(unsigned int resolution[2])> fn)
+ void set_determined_canvas_modifier(std::function<void(rcti &canvas)> fn)
{
- modify_determined_resolution_fn_ = fn;
+ modify_determined_canvas_fn_ = fn;
}
/**
@@ -595,12 +575,12 @@ class NodeOperation {
unsigned int getWidth() const
{
- return m_width;
+ return BLI_rcti_size_x(&canvas_);
}
unsigned int getHeight() const
{
- return m_height;
+ return BLI_rcti_size_y(&canvas_);
}
inline void readSampled(float result[4], float x, float y, PixelSampler sampler)
@@ -699,13 +679,13 @@ class NodeOperation {
void setWidth(unsigned int width)
{
- this->m_width = width;
- this->flags.is_resolution_set = true;
+ canvas_.xmax = canvas_.xmin + width;
+ this->flags.is_canvas_set = true;
}
void setHeight(unsigned int height)
{
- this->m_height = height;
- this->flags.is_resolution_set = true;
+ canvas_.ymax = canvas_.ymin + height;
+ this->flags.is_canvas_set = true;
}
SocketReader *getInputSocketReader(unsigned int inputSocketindex);
NodeOperation *getInputOperation(unsigned int inputSocketindex);
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
index b2cd76be2c3..3791d05602d 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
@@ -106,7 +106,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
folder.fold_operations();
}
- determineResolutions();
+ determine_canvases();
save_graphviz("compositor_prior_merging");
merge_equal_operations();
@@ -423,28 +423,27 @@ void NodeOperationBuilder::resolve_proxies()
}
}
-void NodeOperationBuilder::determineResolutions()
+void NodeOperationBuilder::determine_canvases()
{
- /* determine all resolutions of the operations (Width/Height) */
+ /* Determine all canvas areas of the operations. */
+ const rcti &preferred_area = COM_AREA_NONE;
for (NodeOperation *op : m_operations) {
if (op->isOutputOperation(m_context->isRendering()) && !op->get_flags().is_preview_operation) {
- unsigned int resolution[2] = {0, 0};
- unsigned int preferredResolution[2] = {0, 0};
- op->determineResolution(resolution, preferredResolution);
- op->setResolution(resolution);
+ rcti canvas = COM_AREA_NONE;
+ op->determine_canvas(preferred_area, canvas);
+ op->set_canvas(canvas);
}
}
for (NodeOperation *op : m_operations) {
if (op->isOutputOperation(m_context->isRendering()) && op->get_flags().is_preview_operation) {
- unsigned int resolution[2] = {0, 0};
- unsigned int preferredResolution[2] = {0, 0};
- op->determineResolution(resolution, preferredResolution);
- op->setResolution(resolution);
+ rcti canvas = COM_AREA_NONE;
+ op->determine_canvas(preferred_area, canvas);
+ op->set_canvas(canvas);
}
}
- /* add convert resolution operations when needed */
+ /* Convert operation canvases when needed. */
{
Vector<Link> convert_links;
for (const Link &link : m_links) {
@@ -457,7 +456,7 @@ void NodeOperationBuilder::determineResolutions()
}
}
for (const Link &link : convert_links) {
- COM_convert_resolution(*this, link.from(), link.to());
+ COM_convert_canvas(*this, link.from(), link.to());
}
}
}
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.h b/source/blender/compositor/intern/COM_NodeOperationBuilder.h
index aca4d043d41..1f9c86b51cd 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.h
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.h
@@ -145,8 +145,8 @@ class NodeOperationBuilder {
/** Replace proxy operations with direct links */
void resolve_proxies();
- /** Calculate resolution for each operation */
- void determineResolutions();
+ /** Calculate canvas area for each operation. */
+ void determine_canvases();
/** Helper function to store connected inputs for replacement */
Vector<NodeOperationInput *> cache_output_links(NodeOperationOutput *output) const;
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.cc b/source/blender/compositor/nodes/COM_AlphaOverNode.cc
index 5e09902aee2..c9038886b0d 100644
--- a/source/blender/compositor/nodes/COM_AlphaOverNode.cc
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.cc
@@ -51,13 +51,13 @@ void AlphaOverNode::convertToOperations(NodeConverter &converter,
convertProg->setUseValueAlphaMultiply(false);
if (color1Socket->isLinked()) {
- convertProg->setResolutionInputSocketIndex(1);
+ convertProg->set_canvas_input_index(1);
}
else if (color2Socket->isLinked()) {
- convertProg->setResolutionInputSocketIndex(2);
+ convertProg->set_canvas_input_index(2);
}
else {
- convertProg->setResolutionInputSocketIndex(0);
+ convertProg->set_canvas_input_index(0);
}
converter.addOperation(convertProg);
diff --git a/source/blender/compositor/nodes/COM_CombineColorNode.cc b/source/blender/compositor/nodes/COM_CombineColorNode.cc
index 8a2bbba1c1e..dd68780dc19 100644
--- a/source/blender/compositor/nodes/COM_CombineColorNode.cc
+++ b/source/blender/compositor/nodes/COM_CombineColorNode.cc
@@ -37,16 +37,16 @@ void CombineColorNode::convertToOperations(NodeConverter &converter,
CombineChannelsOperation *operation = new CombineChannelsOperation();
if (inputRSocket->isLinked()) {
- operation->setResolutionInputSocketIndex(0);
+ operation->set_canvas_input_index(0);
}
else if (inputGSocket->isLinked()) {
- operation->setResolutionInputSocketIndex(1);
+ operation->set_canvas_input_index(1);
}
else if (inputBSocket->isLinked()) {
- operation->setResolutionInputSocketIndex(2);
+ operation->set_canvas_input_index(2);
}
else {
- operation->setResolutionInputSocketIndex(3);
+ operation->set_canvas_input_index(3);
}
converter.addOperation(operation);
diff --git a/source/blender/compositor/nodes/COM_GlareNode.cc b/source/blender/compositor/nodes/COM_GlareNode.cc
index cd0b5306be1..9c26d7c86a9 100644
--- a/source/blender/compositor/nodes/COM_GlareNode.cc
+++ b/source/blender/compositor/nodes/COM_GlareNode.cc
@@ -66,7 +66,7 @@ void GlareNode::convertToOperations(NodeConverter &converter,
mixvalueoperation->setValue(glare->mix);
MixGlareOperation *mixoperation = new MixGlareOperation();
- mixoperation->setResolutionInputSocketIndex(1);
+ mixoperation->set_canvas_input_index(1);
mixoperation->getInputSocket(2)->setResizeMode(ResizeMode::FitAny);
converter.addOperation(glareoperation);
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cc b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cc
index 5042d217f9a..e7b1664c354 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cc
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cc
@@ -53,7 +53,7 @@ void HueSaturationValueCorrectNode::convertToOperations(
converter.addOperation(changeHSV);
MixBlendOperation *blend = new MixBlendOperation();
- blend->setResolutionInputSocketIndex(1);
+ blend->set_canvas_input_index(1);
converter.addOperation(blend);
converter.mapInputSocket(colorSocket, rgbToHSV->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cc b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cc
index 54d2caa75af..29e5f39a144 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cc
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cc
@@ -56,7 +56,7 @@ void HueSaturationValueNode::convertToOperations(NodeConverter &converter,
converter.addOperation(changeHSV);
MixBlendOperation *blend = new MixBlendOperation();
- blend->setResolutionInputSocketIndex(1);
+ blend->set_canvas_input_index(1);
converter.addOperation(blend);
converter.mapInputSocket(colorSocket, rgbToHSV->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_MapUVNode.cc b/source/blender/compositor/nodes/COM_MapUVNode.cc
index 4b7a9e8af0f..bbf9e8f3aeb 100644
--- a/source/blender/compositor/nodes/COM_MapUVNode.cc
+++ b/source/blender/compositor/nodes/COM_MapUVNode.cc
@@ -34,7 +34,7 @@ void MapUVNode::convertToOperations(NodeConverter &converter,
MapUVOperation *operation = new MapUVOperation();
operation->setAlpha((float)node->custom1);
- operation->setResolutionInputSocketIndex(1);
+ operation->set_canvas_input_index(1);
converter.addOperation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.cc b/source/blender/compositor/nodes/COM_SetAlphaNode.cc
index dc41c126ba8..c7365b09f71 100644
--- a/source/blender/compositor/nodes/COM_SetAlphaNode.cc
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.cc
@@ -39,7 +39,7 @@ void SetAlphaNode::convertToOperations(NodeConverter &converter,
}
if (!this->getInputSocket(0)->isLinked() && this->getInputSocket(1)->isLinked()) {
- operation->setResolutionInputSocketIndex(1);
+ operation->set_canvas_input_index(1);
}
converter.addOperation(operation);
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cc b/source/blender/compositor/nodes/COM_ViewerNode.cc
index 3833a8d7ca8..4dbcdbe9e40 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.cc
+++ b/source/blender/compositor/nodes/COM_ViewerNode.cc
@@ -60,10 +60,10 @@ void ViewerNode::convertToOperations(NodeConverter &converter,
viewerOperation->setViewSettings(context.getViewSettings());
viewerOperation->setDisplaySettings(context.getDisplaySettings());
- viewerOperation->setResolutionInputSocketIndex(0);
+ viewerOperation->set_canvas_input_index(0);
if (!imageSocket->isLinked()) {
if (alphaSocket->isLinked()) {
- viewerOperation->setResolutionInputSocketIndex(1);
+ viewerOperation->set_canvas_input_index(1);
}
}
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cc b/source/blender/compositor/operations/COM_BlurBaseOperation.cc
index 058b422c4a5..2c162425f13 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cc
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cc
@@ -212,31 +212,30 @@ void BlurBaseOperation::updateSize()
this->m_sizeavailable = true;
}
-void BlurBaseOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void BlurBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
if (!m_extend_bounds) {
- NodeOperation::determineResolution(resolution, preferredResolution);
+ NodeOperation::determine_canvas(preferred_area, r_area);
return;
}
switch (execution_model_) {
case eExecutionModel::Tiled: {
- NodeOperation::determineResolution(resolution, preferredResolution);
- resolution[0] += 2 * m_size * m_data.sizex;
- resolution[1] += 2 * m_size * m_data.sizey;
+ NodeOperation::determine_canvas(preferred_area, r_area);
+ r_area.xmax += 2 * m_size * m_data.sizex;
+ r_area.ymax += 2 * m_size * m_data.sizey;
break;
}
case eExecutionModel::FullFrame: {
/* Setting a modifier ensures all non main inputs have extended bounds as preferred
- * resolution, avoiding unnecessary resolution conversions that would hide constant
+ * canvas, avoiding unnecessary canvas convertions that would hide constant
* operations. */
- set_determined_resolution_modifier([=](unsigned int res[2]) {
+ set_determined_canvas_modifier([=](rcti &canvas) {
/* Rounding to even prevents jiggling in backdrop while switching size values. */
- res[0] += round_to_even(2 * m_size * m_data.sizex);
- res[1] += round_to_even(2 * m_size * m_data.sizey);
+ canvas.xmax += round_to_even(2 * m_size * m_data.sizex);
+ canvas.ymax += round_to_even(2 * m_size * m_data.sizey);
});
- NodeOperation::determineResolution(resolution, preferredResolution);
+ NodeOperation::determine_canvas(preferred_area, r_area);
break;
}
}
@@ -251,7 +250,7 @@ void BlurBaseOperation::get_area_of_interest(const int input_idx,
r_input_area = output_area;
break;
case 1:
- r_input_area = use_variable_size_ ? output_area : COM_SINGLE_ELEM_AREA;
+ r_input_area = use_variable_size_ ? output_area : COM_CONSTANT_INPUT_AREA_OF_INTEREST;
break;
}
}
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h
index 78b1e919aa6..9ab9bf5a173 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.h
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h
@@ -85,8 +85,7 @@ class BlurBaseOperation : public MultiThreadedOperation, public QualityStepHelpe
int get_blur_size(eDimension dim) const;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
virtual void get_area_of_interest(int input_idx,
const rcti &output_area,
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cc b/source/blender/compositor/operations/COM_BokehBlurOperation.cc
index f2a43b7dbca..3f61a300849 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.cc
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cc
@@ -266,31 +266,30 @@ void BokehBlurOperation::updateSize()
this->m_sizeavailable = true;
}
-void BokehBlurOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void BokehBlurOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
if (!m_extend_bounds) {
- NodeOperation::determineResolution(resolution, preferredResolution);
+ NodeOperation::determine_canvas(preferred_area, r_area);
return;
}
switch (execution_model_) {
case eExecutionModel::Tiled: {
- NodeOperation::determineResolution(resolution, preferredResolution);
- const float max_dim = MAX2(resolution[0], resolution[1]);
- resolution[0] += 2 * this->m_size * max_dim / 100.0f;
- resolution[1] += 2 * this->m_size * max_dim / 100.0f;
+ NodeOperation::determine_canvas(preferred_area, r_area);
+ const float max_dim = MAX2(BLI_rcti_size_x(&r_area), BLI_rcti_size_y(&r_area));
+ r_area.xmax += 2 * this->m_size * max_dim / 100.0f;
+ r_area.ymax += 2 * this->m_size * max_dim / 100.0f;
break;
}
case eExecutionModel::FullFrame: {
- set_determined_resolution_modifier([=](unsigned int res[2]) {
- const float max_dim = MAX2(res[0], res[1]);
+ set_determined_canvas_modifier([=](rcti &canvas) {
+ const float max_dim = MAX2(BLI_rcti_size_x(&canvas), BLI_rcti_size_y(&canvas));
/* Rounding to even prevents image jiggling in backdrop while switching size values. */
float add_size = round_to_even(2 * this->m_size * max_dim / 100.0f);
- res[0] += add_size;
- res[1] += add_size;
+ canvas.xmax += add_size;
+ canvas.ymax += add_size;
});
- NodeOperation::determineResolution(resolution, preferredResolution);
+ NodeOperation::determine_canvas(preferred_area, r_area);
break;
}
}
@@ -312,17 +311,14 @@ void BokehBlurOperation::get_area_of_interest(const int input_idx,
}
case BOKEH_INPUT_INDEX: {
NodeOperation *bokeh_input = getInputOperation(BOKEH_INPUT_INDEX);
- r_input_area.xmin = 0;
- r_input_area.xmax = bokeh_input->getWidth();
- r_input_area.ymin = 0;
- r_input_area.ymax = bokeh_input->getHeight();
+ r_input_area = bokeh_input->get_canvas();
break;
}
case BOUNDING_BOX_INPUT_INDEX:
r_input_area = output_area;
break;
case SIZE_INPUT_INDEX: {
- r_input_area = COM_SINGLE_ELEM_AREA;
+ r_input_area = COM_CONSTANT_INPUT_AREA_OF_INTEREST;
break;
}
}
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h
index 59c14305393..84f5a8293ba 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h
@@ -80,8 +80,7 @@ class BokehBlurOperation : public MultiThreadedOperation, public QualityStepHelp
this->m_extend_bounds = extend_bounds;
}
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
void update_memory_buffer_partial(MemoryBuffer *output,
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cc b/source/blender/compositor/operations/COM_BokehImageOperation.cc
index bd5b25b5af8..5c9c8b36ee0 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.cc
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.cc
@@ -145,11 +145,13 @@ void BokehImageOperation::deinitExecution()
}
}
-void BokehImageOperation::determineResolution(unsigned int resolution[2],
- unsigned int /*preferredResolution*/[2])
+void BokehImageOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- resolution[0] = COM_BLUR_BOKEH_PIXELS;
- resolution[1] = COM_BLUR_BOKEH_PIXELS;
+ BLI_rcti_init(&r_area,
+ preferred_area.xmin,
+ preferred_area.xmin + COM_BLUR_BOKEH_PIXELS,
+ preferred_area.ymin,
+ preferred_area.ymin + COM_BLUR_BOKEH_PIXELS);
}
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h
index 2527233fabd..f7fec5d71a5 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.h
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.h
@@ -128,8 +128,7 @@ class BokehImageOperation : public MultiThreadedOperation {
* \brief determine the resolution of this operation. currently fixed at [COM_BLUR_BOKEH_PIXELS,
* COM_BLUR_BOKEH_PIXELS] \param resolution: \param preferredResolution:
*/
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
/**
* \brief set the node data
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cc b/source/blender/compositor/operations/COM_CalculateMeanOperation.cc
index 7457ac9e227..5fff4da62ae 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cc
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cc
@@ -165,11 +165,7 @@ void CalculateMeanOperation::get_area_of_interest(int input_idx,
rcti &r_input_area)
{
BLI_assert(input_idx == 0);
- NodeOperation *operation = getInputOperation(input_idx);
- r_input_area.xmin = 0;
- r_input_area.ymin = 0;
- r_input_area.xmax = operation->getWidth();
- r_input_area.ymax = operation->getHeight();
+ r_input_area = get_input_operation(input_idx)->get_canvas();
}
void CalculateMeanOperation::update_memory_buffer_started(MemoryBuffer *UNUSED(output),
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc
index aee8c0d52e8..0b6590ae4c7 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc
@@ -40,7 +40,7 @@ ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation()
this->addOutputSocket(DataType::Color);
this->m_inputValueOperation = nullptr;
this->m_inputColorOperation = nullptr;
- this->setResolutionInputSocketIndex(1);
+ this->set_canvas_input_index(1);
flags.can_be_constant = true;
}
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc
index 674cb79a238..c658ecd6394 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc
@@ -45,7 +45,7 @@ ColorBalanceLGGOperation::ColorBalanceLGGOperation()
this->addOutputSocket(DataType::Color);
this->m_inputValueOperation = nullptr;
this->m_inputColorOperation = nullptr;
- this->setResolutionInputSocketIndex(1);
+ this->set_canvas_input_index(1);
flags.can_be_constant = true;
}
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cc b/source/blender/compositor/operations/COM_ColorCurveOperation.cc
index 646238460ba..364b310945e 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.cc
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cc
@@ -37,7 +37,7 @@ ColorCurveOperation::ColorCurveOperation()
this->m_inputBlackProgram = nullptr;
this->m_inputWhiteProgram = nullptr;
- this->setResolutionInputSocketIndex(1);
+ this->set_canvas_input_index(1);
}
void ColorCurveOperation::initExecution()
{
@@ -139,7 +139,7 @@ ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation()
this->m_inputFacProgram = nullptr;
this->m_inputImageProgram = nullptr;
- this->setResolutionInputSocketIndex(1);
+ this->set_canvas_input_index(1);
}
void ConstantLevelColorCurveOperation::initExecution()
{
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cc b/source/blender/compositor/operations/COM_CompositorOperation.cc
index fb9e2e43c60..52bc9ed6c2f 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cc
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cc
@@ -236,8 +236,7 @@ void CompositorOperation::update_memory_buffer_partial(MemoryBuffer *UNUSED(outp
depth_buf.copy_from(inputs[2], area);
}
-void CompositorOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void CompositorOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti &r_area)
{
int width = this->m_rd->xsch * this->m_rd->size / 100;
int height = this->m_rd->ysch * this->m_rd->size / 100;
@@ -254,13 +253,11 @@ void CompositorOperation::determineResolution(unsigned int resolution[2],
RE_ReleaseResult(re);
}
- preferredResolution[0] = width;
- preferredResolution[1] = height;
+ rcti local_preferred;
+ BLI_rcti_init(&local_preferred, 0, width, 0, height);
- NodeOperation::determineResolution(resolution, preferredResolution);
-
- resolution[0] = width;
- resolution[1] = height;
+ NodeOperation::determine_canvas(local_preferred, r_area);
+ r_area = local_preferred;
}
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h
index 66367ec8bae..6eb96e01b47 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.h
+++ b/source/blender/compositor/operations/COM_CompositorOperation.h
@@ -115,8 +115,7 @@ class CompositorOperation : public MultiThreadedOperation {
{
return eCompositorPriority::Medium;
}
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void setUseAlphaInput(bool value)
{
this->m_useAlphaInput = value;
diff --git a/source/blender/compositor/operations/COM_ConstantOperation.cc b/source/blender/compositor/operations/COM_ConstantOperation.cc
index 33d51cca432..c127860a89c 100644
--- a/source/blender/compositor/operations/COM_ConstantOperation.cc
+++ b/source/blender/compositor/operations/COM_ConstantOperation.cc
@@ -22,14 +22,14 @@ namespace blender::compositor {
ConstantOperation::ConstantOperation()
{
- needs_resolution_to_get_constant_ = false;
+ needs_canvas_to_get_constant_ = false;
flags.is_constant_operation = true;
flags.is_fullframe_operation = true;
}
bool ConstantOperation::can_get_constant_elem() const
{
- return !needs_resolution_to_get_constant_ || this->flags.is_resolution_set;
+ return !needs_canvas_to_get_constant_ || this->flags.is_canvas_set;
}
void ConstantOperation::update_memory_buffer(MemoryBuffer *output,
diff --git a/source/blender/compositor/operations/COM_ConstantOperation.h b/source/blender/compositor/operations/COM_ConstantOperation.h
index 31b8d30254b..d44d1939424 100644
--- a/source/blender/compositor/operations/COM_ConstantOperation.h
+++ b/source/blender/compositor/operations/COM_ConstantOperation.h
@@ -31,7 +31,7 @@ namespace blender::compositor {
*/
class ConstantOperation : public NodeOperation {
protected:
- bool needs_resolution_to_get_constant_;
+ bool needs_canvas_to_get_constant_;
public:
ConstantOperation();
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.cc b/source/blender/compositor/operations/COM_ConvertOperation.cc
index 9a3733dda5b..7b2721ebbb2 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.cc
+++ b/source/blender/compositor/operations/COM_ConvertOperation.cc
@@ -587,7 +587,7 @@ CombineChannelsOperation::CombineChannelsOperation()
this->addInputSocket(DataType::Value);
this->addInputSocket(DataType::Value);
this->addOutputSocket(DataType::Color);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->m_inputChannel1Operation = nullptr;
this->m_inputChannel2Operation = nullptr;
this->m_inputChannel3Operation = nullptr;
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cc b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cc
index 11a077229fd..807223fd45f 100644
--- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cc
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cc
@@ -29,7 +29,7 @@ ConvolutionFilterOperation::ConvolutionFilterOperation()
this->addInputSocket(DataType::Color);
this->addInputSocket(DataType::Value);
this->addOutputSocket(DataType::Color);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->m_inputOperation = nullptr;
this->flags.complex = true;
}
diff --git a/source/blender/compositor/operations/COM_CropOperation.cc b/source/blender/compositor/operations/COM_CropOperation.cc
index 12833660fcb..73805b76864 100644
--- a/source/blender/compositor/operations/COM_CropOperation.cc
+++ b/source/blender/compositor/operations/COM_CropOperation.cc
@@ -142,13 +142,12 @@ void CropImageOperation::get_area_of_interest(const int input_idx,
r_input_area.ymin = output_area.ymin + this->m_ymin;
}
-void CropImageOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void CropImageOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- NodeOperation::determineResolution(resolution, preferredResolution);
+ NodeOperation::determine_canvas(preferred_area, r_area);
updateArea();
- resolution[0] = this->m_xmax - this->m_xmin;
- resolution[1] = this->m_ymax - this->m_ymin;
+ r_area.xmax = r_area.xmin + (m_xmax - m_xmin);
+ r_area.ymax = r_area.ymin + (m_ymax - m_ymin);
}
void CropImageOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h
index 57caa4e5834..a156727402b 100644
--- a/source/blender/compositor/operations/COM_CropOperation.h
+++ b/source/blender/compositor/operations/COM_CropOperation.h
@@ -66,8 +66,7 @@ class CropImageOperation : public CropBaseOperation {
bool determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation,
rcti *output) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
diff --git a/source/blender/compositor/operations/COM_DenoiseOperation.cc b/source/blender/compositor/operations/COM_DenoiseOperation.cc
index 0c660e0b723..f8a575acc3a 100644
--- a/source/blender/compositor/operations/COM_DenoiseOperation.cc
+++ b/source/blender/compositor/operations/COM_DenoiseOperation.cc
@@ -153,10 +153,7 @@ void DenoiseBaseOperation::get_area_of_interest(const int UNUSED(input_idx),
const rcti &UNUSED(output_area),
rcti &r_input_area)
{
- r_input_area.xmin = 0;
- r_input_area.xmax = this->getWidth();
- r_input_area.ymin = 0;
- r_input_area.ymax = this->getHeight();
+ r_input_area = this->get_canvas();
}
DenoiseOperation::DenoiseOperation()
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cc b/source/blender/compositor/operations/COM_DespeckleOperation.cc
index 19bd7b2af6f..df637ee6709 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.cc
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.cc
@@ -29,7 +29,7 @@ DespeckleOperation::DespeckleOperation()
this->addInputSocket(DataType::Color);
this->addInputSocket(DataType::Value);
this->addOutputSocket(DataType::Color);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->m_inputOperation = nullptr;
this->flags.complex = true;
}
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc
index 102025ed915..e69124205d0 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc
@@ -152,10 +152,7 @@ void DirectionalBlurOperation::get_area_of_interest(const int input_idx,
{
BLI_assert(input_idx == 0);
UNUSED_VARS_NDEBUG(input_idx);
- r_input_area.xmin = 0;
- r_input_area.xmax = this->getWidth();
- r_input_area.ymin = 0;
- r_input_area.ymax = this->getHeight();
+ r_input_area = this->get_canvas();
}
void DirectionalBlurOperation::update_memory_buffer_partial(MemoryBuffer *output,
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cc b/source/blender/compositor/operations/COM_DisplaceOperation.cc
index a4c01fda7ca..d08ff60d5d0 100644
--- a/source/blender/compositor/operations/COM_DisplaceOperation.cc
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.cc
@@ -211,10 +211,7 @@ void DisplaceOperation::get_area_of_interest(const int input_idx,
{
switch (input_idx) {
case 0: {
- r_input_area.xmin = 0;
- r_input_area.ymin = 0;
- r_input_area.xmax = getInputOperation(input_idx)->getWidth();
- r_input_area.ymax = getInputOperation(input_idx)->getHeight();
+ r_input_area = getInputOperation(input_idx)->get_canvas();
break;
}
case 1: {
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cc b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cc
index e1c531bd49e..712b61be805 100644
--- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cc
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cc
@@ -138,10 +138,7 @@ void DisplaceSimpleOperation::get_area_of_interest(const int input_idx,
{
switch (input_idx) {
case 0: {
- r_input_area.xmin = 0;
- r_input_area.ymin = 0;
- r_input_area.xmax = getInputOperation(input_idx)->getWidth();
- r_input_area.ymax = getInputOperation(input_idx)->getHeight();
+ r_input_area = get_input_operation(input_idx)->get_canvas();
break;
}
default: {
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.cc b/source/blender/compositor/operations/COM_DotproductOperation.cc
index 875b161e208..aa18ff1e827 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.cc
+++ b/source/blender/compositor/operations/COM_DotproductOperation.cc
@@ -25,7 +25,7 @@ DotproductOperation::DotproductOperation()
this->addInputSocket(DataType::Vector);
this->addInputSocket(DataType::Vector);
this->addOutputSocket(DataType::Value);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->m_input1Operation = nullptr;
this->m_input2Operation = nullptr;
flags.can_be_constant = true;
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc
index 55ae19ad194..d112334b749 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc
@@ -1399,10 +1399,7 @@ void DoubleEdgeMaskOperation::get_area_of_interest(int UNUSED(input_idx),
const rcti &UNUSED(output_area),
rcti &r_input_area)
{
- r_input_area.xmax = this->getWidth();
- r_input_area.xmin = 0;
- r_input_area.ymax = this->getHeight();
- r_input_area.ymin = 0;
+ r_input_area = this->get_canvas();
}
void DoubleEdgeMaskOperation::update_memory_buffer(MemoryBuffer *output,
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc
index e0fc45811cb..f45b77c6ebc 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc
@@ -271,10 +271,7 @@ void FastGaussianBlurOperation::get_area_of_interest(const int input_idx,
{
switch (input_idx) {
case IMAGE_INPUT_INDEX:
- r_input_area.xmin = 0;
- r_input_area.xmax = getWidth();
- r_input_area.ymin = 0;
- r_input_area.ymax = getHeight();
+ r_input_area = this->get_canvas();
break;
default:
BlurBaseOperation::get_area_of_interest(input_idx, output_area, r_input_area);
@@ -411,10 +408,7 @@ void FastGaussianBlurValueOperation::get_area_of_interest(const int UNUSED(input
const rcti &UNUSED(output_area),
rcti &r_input_area)
{
- r_input_area.xmin = 0;
- r_input_area.xmax = getWidth();
- r_input_area.ymin = 0;
- r_input_area.ymax = getHeight();
+ r_input_area = this->get_canvas();
}
void FastGaussianBlurValueOperation::update_memory_buffer_started(MemoryBuffer *UNUSED(output),
diff --git a/source/blender/compositor/operations/COM_FlipOperation.cc b/source/blender/compositor/operations/COM_FlipOperation.cc
index d0dc6c0b570..c88fcaa7da2 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.cc
+++ b/source/blender/compositor/operations/COM_FlipOperation.cc
@@ -24,7 +24,7 @@ FlipOperation::FlipOperation()
{
this->addInputSocket(DataType::Color);
this->addOutputSocket(DataType::Color);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->m_inputOperation = nullptr;
this->m_flipX = true;
this->m_flipY = false;
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cc b/source/blender/compositor/operations/COM_GlareThresholdOperation.cc
index 1d3402f5b7b..f8da0b9a102 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cc
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cc
@@ -30,12 +30,13 @@ GlareThresholdOperation::GlareThresholdOperation()
this->m_inputProgram = nullptr;
}
-void GlareThresholdOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void GlareThresholdOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- NodeOperation::determineResolution(resolution, preferredResolution);
- resolution[0] = resolution[0] / (1 << this->m_settings->quality);
- resolution[1] = resolution[1] / (1 << this->m_settings->quality);
+ NodeOperation::determine_canvas(preferred_area, r_area);
+ const int width = BLI_rcti_size_x(&r_area) / (1 << this->m_settings->quality);
+ const int height = BLI_rcti_size_y(&r_area) / (1 << this->m_settings->quality);
+ r_area.xmax = r_area.xmin + width;
+ r_area.ymax = r_area.ymin + height;
}
void GlareThresholdOperation::initExecution()
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
index a6e971dada7..1f247f58324 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.h
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
@@ -58,8 +58,7 @@ class GlareThresholdOperation : public NodeOperation {
this->m_settings = settings;
}
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
};
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cc b/source/blender/compositor/operations/COM_ImageOperation.cc
index e78d389410f..ff389093f5a 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cc
+++ b/source/blender/compositor/operations/COM_ImageOperation.cc
@@ -112,17 +112,14 @@ void BaseImageOperation::deinitExecution()
}
}
-void BaseImageOperation::determineResolution(unsigned int resolution[2],
- unsigned int /*preferredResolution*/[2])
+void BaseImageOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti &r_area)
{
ImBuf *stackbuf = getImBuf();
- resolution[0] = 0;
- resolution[1] = 0;
+ r_area = COM_AREA_NONE;
if (stackbuf) {
- resolution[0] = stackbuf->x;
- resolution[1] = stackbuf->y;
+ BLI_rcti_init(&r_area, 0, stackbuf->x, 0, stackbuf->y);
}
BKE_image_release_ibuf(this->m_image, stackbuf, nullptr);
@@ -222,7 +219,7 @@ void ImageDepthOperation::executePixelSampled(float output[4],
output[0] = 0.0f;
}
else {
- int offset = y * this->m_width + x;
+ int offset = y * getWidth() + x;
output[0] = this->m_depthBuffer[offset];
}
}
diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h
index f8b4239c9f8..e2fdfbf6f81 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.h
+++ b/source/blender/compositor/operations/COM_ImageOperation.h
@@ -54,8 +54,7 @@ class BaseImageOperation : public MultiThreadedOperation {
/**
* Determine the output resolution. The resolution is retrieved from the Renderer
*/
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
virtual ImBuf *getImBuf();
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cc b/source/blender/compositor/operations/COM_InpaintOperation.cc
index 5e76c41752c..5d440dd7d76 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.cc
+++ b/source/blender/compositor/operations/COM_InpaintOperation.cc
@@ -293,10 +293,7 @@ void InpaintSimpleOperation::get_area_of_interest(const int input_idx,
{
BLI_assert(input_idx == 0);
UNUSED_VARS_NDEBUG(input_idx);
- r_input_area.xmin = 0;
- r_input_area.xmax = this->getWidth();
- r_input_area.ymin = 0;
- r_input_area.ymax = this->getHeight();
+ r_input_area = this->get_canvas();
}
void InpaintSimpleOperation::update_memory_buffer(MemoryBuffer *output,
diff --git a/source/blender/compositor/operations/COM_InvertOperation.cc b/source/blender/compositor/operations/COM_InvertOperation.cc
index 4f71a1d0d1d..d406b809c7a 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.cc
+++ b/source/blender/compositor/operations/COM_InvertOperation.cc
@@ -29,7 +29,7 @@ InvertOperation::InvertOperation()
this->m_inputColorProgram = nullptr;
this->m_color = true;
this->m_alpha = false;
- setResolutionInputSocketIndex(1);
+ set_canvas_input_index(1);
this->flags.can_be_constant = true;
}
void InvertOperation::initExecution()
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cc b/source/blender/compositor/operations/COM_KeyingScreenOperation.cc
index c00aafc19a2..b4840926d55 100644
--- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cc
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cc
@@ -303,11 +303,9 @@ void KeyingScreenOperation::deinitializeTileData(rcti * /*rect*/, void *data)
MEM_freeN(tile_data);
}
-void KeyingScreenOperation::determineResolution(unsigned int resolution[2],
- unsigned int /*preferredResolution*/[2])
+void KeyingScreenOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- resolution[0] = 0;
- resolution[1] = 0;
+ r_area = COM_AREA_NONE;
if (this->m_movieClip) {
MovieClipUser user = {0};
@@ -317,9 +315,9 @@ void KeyingScreenOperation::determineResolution(unsigned int resolution[2],
BKE_movieclip_user_set_frame(&user, clip_frame);
BKE_movieclip_get_size(this->m_movieClip, &user, &width, &height);
-
- resolution[0] = width;
- resolution[1] = height;
+ r_area = preferred_area;
+ r_area.xmax = r_area.xmin + width;
+ r_area.ymax = r_area.ymin + height;
}
}
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.h b/source/blender/compositor/operations/COM_KeyingScreenOperation.h
index 0bc47dbea30..7a7dda27710 100644
--- a/source/blender/compositor/operations/COM_KeyingScreenOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.h
@@ -57,8 +57,7 @@ class KeyingScreenOperation : public MultiThreadedOperation {
/**
* Determine the output resolution. The resolution is retrieved from the Renderer
*/
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
TriangulationData *buildVoronoiTriangulation();
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cc b/source/blender/compositor/operations/COM_MapUVOperation.cc
index ad047c619f8..5062b0c42cb 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.cc
+++ b/source/blender/compositor/operations/COM_MapUVOperation.cc
@@ -28,7 +28,7 @@ MapUVOperation::MapUVOperation()
this->addOutputSocket(DataType::Color);
this->m_alpha = 0.0f;
this->flags.complex = true;
- setResolutionInputSocketIndex(1);
+ set_canvas_input_index(UV_INPUT_INDEX);
this->m_inputUVProgram = nullptr;
this->m_inputColorProgram = nullptr;
@@ -36,11 +36,11 @@ MapUVOperation::MapUVOperation()
void MapUVOperation::init_data()
{
- NodeOperation *image_input = get_input_operation(0);
+ NodeOperation *image_input = get_input_operation(IMAGE_INPUT_INDEX);
image_width_ = image_input->getWidth();
image_height_ = image_input->getHeight();
- NodeOperation *uv_input = get_input_operation(1);
+ NodeOperation *uv_input = get_input_operation(UV_INPUT_INDEX);
uv_width_ = uv_input->getWidth();
uv_height_ = uv_input->getHeight();
}
@@ -205,14 +205,11 @@ void MapUVOperation::get_area_of_interest(const int input_idx,
rcti &r_input_area)
{
switch (input_idx) {
- case 0: {
- r_input_area.xmin = 0;
- r_input_area.xmax = image_width_;
- r_input_area.ymin = 0;
- r_input_area.ymax = image_height_;
+ case IMAGE_INPUT_INDEX: {
+ r_input_area = get_input_operation(IMAGE_INPUT_INDEX)->get_canvas();
break;
}
- case 1: {
+ case UV_INPUT_INDEX: {
r_input_area = output_area;
expand_area_for_sampler(r_input_area, PixelSampler::Bilinear);
break;
@@ -224,7 +221,7 @@ void MapUVOperation::update_memory_buffer_started(MemoryBuffer *UNUSED(output),
const rcti &UNUSED(area),
Span<MemoryBuffer *> inputs)
{
- const MemoryBuffer *uv_input = inputs[1];
+ const MemoryBuffer *uv_input = inputs[UV_INPUT_INDEX];
uv_input_read_fn_ = [=](float x, float y, float *out) {
uv_input->read_elem_bilinear(x, y, out);
};
@@ -234,7 +231,7 @@ void MapUVOperation::update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs)
{
- const MemoryBuffer *input_image = inputs[0];
+ const MemoryBuffer *input_image = inputs[IMAGE_INPUT_INDEX];
for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
float xy[2] = {(float)it.x, (float)it.y};
float uv[2];
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.h b/source/blender/compositor/operations/COM_MapUVOperation.h
index 65fbcb461c9..49c6689f700 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.h
+++ b/source/blender/compositor/operations/COM_MapUVOperation.h
@@ -24,6 +24,8 @@ namespace blender::compositor {
class MapUVOperation : public MultiThreadedOperation {
private:
+ static constexpr int IMAGE_INPUT_INDEX = 0;
+ static constexpr int UV_INPUT_INDEX = 1;
/**
* Cached reference to the inputProgram
*/
diff --git a/source/blender/compositor/operations/COM_MaskOperation.cc b/source/blender/compositor/operations/COM_MaskOperation.cc
index 84992f23924..65b89a8c79a 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.cc
+++ b/source/blender/compositor/operations/COM_MaskOperation.cc
@@ -109,22 +109,15 @@ void MaskOperation::deinitExecution()
}
}
-void MaskOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void MaskOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
if (this->m_maskWidth == 0 || this->m_maskHeight == 0) {
- NodeOperation::determineResolution(resolution, preferredResolution);
+ r_area = COM_AREA_NONE;
}
else {
- unsigned int nr[2];
-
- nr[0] = this->m_maskWidth;
- nr[1] = this->m_maskHeight;
-
- NodeOperation::determineResolution(resolution, nr);
-
- resolution[0] = this->m_maskWidth;
- resolution[1] = this->m_maskHeight;
+ r_area = preferred_area;
+ r_area.xmax = r_area.xmin + m_maskWidth;
+ r_area.ymax = r_area.ymin + m_maskHeight;
}
}
diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h
index 81e344c0451..cc7eb0c022c 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.h
+++ b/source/blender/compositor/operations/COM_MaskOperation.h
@@ -54,8 +54,7 @@ class MaskOperation : public MultiThreadedOperation {
/**
* Determine the output resolution. The resolution is retrieved from the Renderer
*/
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
public:
MaskOperation();
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cc b/source/blender/compositor/operations/COM_MathBaseOperation.cc
index 2256dce011b..d3fb83caf7c 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cc
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cc
@@ -51,22 +51,19 @@ void MathBaseOperation::deinitExecution()
this->m_inputValue3Operation = nullptr;
}
-void MathBaseOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void MathBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
NodeOperationInput *socket;
- unsigned int tempPreferredResolution[2] = {0, 0};
- unsigned int tempResolution[2];
-
+ rcti temp_area;
socket = this->getInputSocket(0);
- socket->determineResolution(tempResolution, tempPreferredResolution);
- if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) {
- this->setResolutionInputSocketIndex(0);
+ const bool determined = socket->determine_canvas(COM_AREA_NONE, temp_area);
+ if (determined) {
+ this->set_canvas_input_index(0);
}
else {
- this->setResolutionInputSocketIndex(1);
+ this->set_canvas_input_index(1);
}
- NodeOperation::determineResolution(resolution, preferredResolution);
+ NodeOperation::determine_canvas(preferred_area, r_area);
}
void MathBaseOperation::clampIfNeeded(float *color)
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h
index d2da05db68e..0188eb50fa8 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.h
@@ -75,8 +75,7 @@ class MathBaseOperation : public MultiThreadedOperation {
/**
* Determine resolution
*/
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void setUseClamp(bool value)
{
diff --git a/source/blender/compositor/operations/COM_MixOperation.cc b/source/blender/compositor/operations/COM_MixOperation.cc
index 77ecbf60356..4b9f4786e79 100644
--- a/source/blender/compositor/operations/COM_MixOperation.cc
+++ b/source/blender/compositor/operations/COM_MixOperation.cc
@@ -66,29 +66,27 @@ void MixBaseOperation::executePixelSampled(float output[4], float x, float y, Pi
output[3] = inputColor1[3];
}
-void MixBaseOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void MixBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
NodeOperationInput *socket;
- unsigned int tempPreferredResolution[2] = {0, 0};
- unsigned int tempResolution[2];
+ rcti temp_area;
socket = this->getInputSocket(1);
- socket->determineResolution(tempResolution, tempPreferredResolution);
- if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) {
- this->setResolutionInputSocketIndex(1);
+ bool determined = socket->determine_canvas(COM_AREA_NONE, temp_area);
+ if (determined) {
+ this->set_canvas_input_index(1);
}
else {
socket = this->getInputSocket(2);
- socket->determineResolution(tempResolution, tempPreferredResolution);
- if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) {
- this->setResolutionInputSocketIndex(2);
+ determined = socket->determine_canvas(COM_AREA_NONE, temp_area);
+ if (determined) {
+ this->set_canvas_input_index(2);
}
else {
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
}
}
- NodeOperation::determineResolution(resolution, preferredResolution);
+ NodeOperation::determine_canvas(preferred_area, r_area);
}
void MixBaseOperation::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_MixOperation.h b/source/blender/compositor/operations/COM_MixOperation.h
index 7ef9d78d58f..fabbea422eb 100644
--- a/source/blender/compositor/operations/COM_MixOperation.h
+++ b/source/blender/compositor/operations/COM_MixOperation.h
@@ -87,8 +87,7 @@ class MixBaseOperation : public MultiThreadedOperation {
*/
void deinitExecution() override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void setUseValueAlphaMultiply(const bool value)
{
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cc b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cc
index e36e93984fb..5654ea0425d 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cc
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cc
@@ -29,7 +29,7 @@ MovieClipAttributeOperation::MovieClipAttributeOperation()
this->m_framenumber = 0;
this->m_attribute = MCA_X;
this->m_invert = false;
- needs_resolution_to_get_constant_ = true;
+ needs_canvas_to_get_constant_ = true;
is_value_calculated_ = false;
}
@@ -42,7 +42,7 @@ void MovieClipAttributeOperation::initExecution()
void MovieClipAttributeOperation::calc_value()
{
- BLI_assert(this->get_flags().is_resolution_set);
+ BLI_assert(this->get_flags().is_canvas_set);
is_value_calculated_ = true;
if (this->m_clip == nullptr) {
return;
@@ -87,11 +87,9 @@ void MovieClipAttributeOperation::executePixelSampled(float output[4],
output[0] = this->m_value;
}
-void MovieClipAttributeOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void MovieClipAttributeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ r_area = preferred_area;
}
const float *MovieClipAttributeOperation::get_constant_elem()
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
index 28c39d4dad3..e42605e5026 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
@@ -55,8 +55,7 @@ class MovieClipAttributeOperation : public ConstantOperation {
* The inner loop of this operation.
*/
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
const float *get_constant_elem() override;
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cc b/source/blender/compositor/operations/COM_MovieClipOperation.cc
index e520b928edf..1ca33b12432 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.cc
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.cc
@@ -71,19 +71,13 @@ void MovieClipBaseOperation::deinitExecution()
}
}
-void MovieClipBaseOperation::determineResolution(unsigned int resolution[2],
- unsigned int /*preferredResolution*/[2])
+void MovieClipBaseOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti &r_area)
{
- resolution[0] = 0;
- resolution[1] = 0;
-
+ r_area = COM_AREA_NONE;
if (this->m_movieClip) {
int width, height;
-
BKE_movieclip_get_size(this->m_movieClip, this->m_movieClipUser, &width, &height);
-
- resolution[0] = width;
- resolution[1] = height;
+ BLI_rcti_init(&r_area, 0, width, 0, height);
}
}
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.h b/source/blender/compositor/operations/COM_MovieClipOperation.h
index 0a0c4c00f81..465ccd4fc00 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.h
@@ -41,8 +41,7 @@ class MovieClipBaseOperation : public MultiThreadedOperation {
/**
* Determine the output resolution. The resolution is retrieved from the Renderer
*/
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
public:
MovieClipBaseOperation();
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cc b/source/blender/compositor/operations/COM_MovieDistortionOperation.cc
index d3424959061..72162ffb110 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cc
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cc
@@ -29,7 +29,7 @@ MovieDistortionOperation::MovieDistortionOperation(bool distortion)
{
this->addInputSocket(DataType::Color);
this->addOutputSocket(DataType::Color);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->m_inputOperation = nullptr;
this->m_movieClip = nullptr;
this->m_apply = distortion;
@@ -49,10 +49,10 @@ void MovieDistortionOperation::initExecution()
float delta[2];
rcti full_frame;
full_frame.xmin = full_frame.ymin = 0;
- full_frame.xmax = this->m_width;
- full_frame.ymax = this->m_height;
+ full_frame.xmax = this->getWidth();
+ full_frame.ymax = this->getHeight();
BKE_tracking_max_distortion_delta_across_bound(
- tracking, this->m_width, this->m_height, &full_frame, !this->m_apply, delta);
+ tracking, this->getWidth(), this->getHeight(), &full_frame, !this->m_apply, delta);
/* 5 is just in case we didn't hit real max of distortion in
* BKE_tracking_max_undistortion_delta_across_bound
@@ -89,8 +89,8 @@ void MovieDistortionOperation::executePixelSampled(float output[4],
if (this->m_distortion != nullptr) {
/* float overscan = 0.0f; */
const float pixel_aspect = this->m_pixel_aspect;
- const float w = (float)this->m_width /* / (1 + overscan) */;
- const float h = (float)this->m_height /* / (1 + overscan) */;
+ const float w = (float)this->getWidth() /* / (1 + overscan) */;
+ const float h = (float)this->getHeight() /* / (1 + overscan) */;
const float aspx = w / (float)this->m_calibration_width;
const float aspy = h / (float)this->m_calibration_height;
float in[2];
@@ -152,8 +152,8 @@ void MovieDistortionOperation::update_memory_buffer_partial(MemoryBuffer *output
/* `float overscan = 0.0f;` */
const float pixel_aspect = this->m_pixel_aspect;
- const float w = (float)this->m_width /* `/ (1 + overscan)` */;
- const float h = (float)this->m_height /* `/ (1 + overscan)` */;
+ const float w = (float)this->getWidth() /* `/ (1 + overscan)` */;
+ const float h = (float)this->getHeight() /* `/ (1 + overscan)` */;
const float aspx = w / (float)this->m_calibration_width;
const float aspy = h / (float)this->m_calibration_height;
float xy[2];
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.cc b/source/blender/compositor/operations/COM_NormalizeOperation.cc
index c3e72d2575f..7d79b375b45 100644
--- a/source/blender/compositor/operations/COM_NormalizeOperation.cc
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.cc
@@ -133,11 +133,7 @@ void NormalizeOperation::get_area_of_interest(const int UNUSED(input_idx),
const rcti &UNUSED(output_area),
rcti &r_input_area)
{
- NodeOperation *input = get_input_operation(0);
- r_input_area.xmin = 0;
- r_input_area.xmax = input->getWidth();
- r_input_area.ymin = 0;
- r_input_area.ymax = input->getHeight();
+ r_input_area = get_input_operation(0)->get_canvas();
}
void NormalizeOperation::update_memory_buffer_started(MemoryBuffer *UNUSED(output),
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cc b/source/blender/compositor/operations/COM_OutputFileOperation.cc
index 402d29893a4..79be95bb686 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cc
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cc
@@ -339,7 +339,7 @@ OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(const Scene *
this->m_exr_codec = exr_codec;
this->m_exr_half_float = exr_half_float;
this->m_viewName = viewName;
- this->setResolutionInputSocketIndex(RESOLUTION_INPUT_ANY);
+ this->set_canvas_input_index(RESOLUTION_INPUT_ANY);
}
void OutputOpenExrMultiLayerOperation::add_layer(const char *name,
diff --git a/source/blender/compositor/operations/COM_PixelateOperation.cc b/source/blender/compositor/operations/COM_PixelateOperation.cc
index 94827cd1b02..4fc238bc094 100644
--- a/source/blender/compositor/operations/COM_PixelateOperation.cc
+++ b/source/blender/compositor/operations/COM_PixelateOperation.cc
@@ -24,7 +24,7 @@ PixelateOperation::PixelateOperation(DataType datatype)
{
this->addInputSocket(datatype);
this->addOutputSocket(datatype);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->m_inputOperation = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc
index d2a06ddd7c4..65cd08456ef 100644
--- a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc
+++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc
@@ -209,15 +209,13 @@ void *PlaneCornerPinMaskOperation::initializeTileData(rcti *rect)
return data;
}
-void PlaneCornerPinMaskOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void PlaneCornerPinMaskOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
if (execution_model_ == eExecutionModel::FullFrame) {
- /* Determine inputs resolution. */
- PlaneDistortMaskOperation::determineResolution(resolution, preferredResolution);
+ /* Determine input canvases. */
+ PlaneDistortMaskOperation::determine_canvas(preferred_area, r_area);
}
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ r_area = preferred_area;
}
void PlaneCornerPinMaskOperation::get_area_of_interest(const int UNUSED(input_idx),
@@ -225,7 +223,7 @@ void PlaneCornerPinMaskOperation::get_area_of_interest(const int UNUSED(input_id
rcti &r_input_area)
{
/* All corner inputs are used as constants. */
- r_input_area = COM_SINGLE_ELEM_AREA;
+ r_input_area = COM_CONSTANT_INPUT_AREA_OF_INTEREST;
}
/* ******** PlaneCornerPinWarpImageOperation ******** */
@@ -322,7 +320,7 @@ void PlaneCornerPinWarpImageOperation::get_area_of_interest(const int input_idx,
}
else {
/* Corner inputs are used as constants. */
- r_input_area = COM_SINGLE_ELEM_AREA;
+ r_input_area = COM_CONSTANT_INPUT_AREA_OF_INTEREST;
}
}
diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h
index 2831e937147..7b3917923d2 100644
--- a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h
@@ -43,8 +43,7 @@ class PlaneCornerPinMaskOperation : public PlaneDistortMaskOperation {
void *initializeTileData(rcti *rect) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
};
diff --git a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc
index ccabb3cf11c..ab45899b7f5 100644
--- a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc
+++ b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc
@@ -196,10 +196,7 @@ void PlaneDistortWarpImageOperation::get_area_of_interest(const int input_idx,
}
/* TODO: figure out the area needed for warping and EWA filtering. */
- r_input_area.xmin = 0;
- r_input_area.ymin = 0;
- r_input_area.xmax = get_input_operation(0)->getWidth();
- r_input_area.ymax = get_input_operation(0)->getHeight();
+ r_input_area = get_input_operation(0)->get_canvas();
/* Old implementation but resulting coordinates are way out of input operation bounds and in some
* cases the area result may incorrectly cause cropping. */
diff --git a/source/blender/compositor/operations/COM_PlaneTrackOperation.cc b/source/blender/compositor/operations/COM_PlaneTrackOperation.cc
index bf24f843ca2..7226a133a52 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackOperation.cc
+++ b/source/blender/compositor/operations/COM_PlaneTrackOperation.cc
@@ -83,19 +83,17 @@ void PlaneTrackCommon::readCornersFromTrack(float corners[4][2], float frame)
}
}
-void PlaneTrackCommon::determineResolution(unsigned int resolution[2],
- unsigned int /*preferredResolution*/[2])
+void PlaneTrackCommon::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- resolution[0] = 0;
- resolution[1] = 0;
-
+ r_area = COM_AREA_NONE;
if (this->m_movieClip) {
int width, height;
MovieClipUser user = {0};
BKE_movieclip_user_set_frame(&user, this->m_framenumber);
BKE_movieclip_get_size(this->m_movieClip, &user, &width, &height);
- resolution[0] = width;
- resolution[1] = height;
+ r_area = preferred_area;
+ r_area.xmax = r_area.xmin + width;
+ r_area.ymax = r_area.ymin + height;
}
}
diff --git a/source/blender/compositor/operations/COM_PlaneTrackOperation.h b/source/blender/compositor/operations/COM_PlaneTrackOperation.h
index d2027755162..60845aac514 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneTrackOperation.h
@@ -41,7 +41,7 @@ class PlaneTrackCommon {
* implementation classes must make wrappers to use these methods, see below.
*/
void read_and_calculate_corners(PlaneDistortBaseOperation *distort_op);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ void determine_canvas(const rcti &preferred_area, rcti &r_area);
public:
PlaneTrackCommon();
@@ -77,13 +77,13 @@ class PlaneTrackMaskOperation : public PlaneDistortMaskOperation, public PlaneTr
void initExecution() override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override
{
- PlaneTrackCommon::determineResolution(resolution, preferredResolution);
+ PlaneTrackCommon::determine_canvas(preferred_area, r_area);
- unsigned int temp[2];
- NodeOperation::determineResolution(temp, resolution);
+ rcti unused;
+ rcti &preferred = r_area;
+ NodeOperation::determine_canvas(preferred, unused);
}
};
@@ -98,12 +98,13 @@ class PlaneTrackWarpImageOperation : public PlaneDistortWarpImageOperation,
void initExecution() override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override
{
- PlaneTrackCommon::determineResolution(resolution, preferredResolution);
- unsigned int temp[2];
- NodeOperation::determineResolution(temp, resolution);
+ PlaneTrackCommon::determine_canvas(preferred_area, r_area);
+
+ rcti unused;
+ rcti &preferred = r_area;
+ NodeOperation::determine_canvas(preferred, unused);
}
};
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cc b/source/blender/compositor/operations/COM_PreviewOperation.cc
index fa8b5ffcabf..7b1dd89bd75 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cc
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cc
@@ -130,14 +130,14 @@ bool PreviewOperation::determineDependingAreaOfInterest(rcti *input,
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
-void PreviewOperation::determineResolution(unsigned int resolution[2],
- unsigned int /*preferredResolution*/[2])
+void PreviewOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti &r_area)
{
/* Use default preview resolution as preferred ensuring it has size so that
* generated inputs (which don't have resolution on their own) are displayed */
BLI_assert(this->m_defaultWidth > 0 && this->m_defaultHeight > 0);
- unsigned int previewPreferredRes[2] = {this->m_defaultWidth, this->m_defaultHeight};
- NodeOperation::determineResolution(resolution, previewPreferredRes);
+ rcti local_preferred;
+ BLI_rcti_init(&local_preferred, 0, m_defaultWidth, 0, m_defaultHeight);
+ NodeOperation::determine_canvas(local_preferred, r_area);
/* If resolution is 0 there are two possible scenarios:
* - Either node is not connected at all
@@ -148,8 +148,8 @@ void PreviewOperation::determineResolution(unsigned int resolution[2],
* The latter case would only happen if an input doesn't set any resolution ignoring output
* preferred resolution. In such case preview size will be 0 too.
*/
- int width = resolution[0];
- int height = resolution[1];
+ int width = BLI_rcti_size_x(&r_area);
+ int height = BLI_rcti_size_y(&r_area);
this->m_divider = 0.0f;
if (width > 0 && height > 0) {
if (width > height) {
@@ -162,8 +162,7 @@ void PreviewOperation::determineResolution(unsigned int resolution[2],
width = width * this->m_divider;
height = height * this->m_divider;
- resolution[0] = width;
- resolution[1] = height;
+ BLI_rcti_init(&r_area, 0, width, 0, height);
}
eCompositorPriority PreviewOperation::getRenderPriority() const
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h
index 05dae9c4dd8..4bd0f07d882 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.h
+++ b/source/blender/compositor/operations/COM_PreviewOperation.h
@@ -58,8 +58,7 @@ class PreviewOperation : public MultiThreadedOperation {
eCompositorPriority getRenderPriority() const override;
void executeRegion(rcti *rect, unsigned int tileNumber) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
bool determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation,
rcti *output) override;
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cc b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cc
index fcab5dd5751..faebaf657cc 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cc
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cc
@@ -137,7 +137,7 @@ void ProjectorLensDistortionOperation::get_area_of_interest(const int input_idx,
{
if (input_idx == 1) {
/* Dispersion input is used as constant only. */
- r_input_area = COM_SINGLE_ELEM_AREA;
+ r_input_area = COM_CONSTANT_INPUT_AREA_OF_INTEREST;
return;
}
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cc b/source/blender/compositor/operations/COM_ReadBufferOperation.cc
index d35d2516f16..599370751bb 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.cc
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cc
@@ -36,16 +36,17 @@ void *ReadBufferOperation::initializeTileData(rcti * /*rect*/)
return m_buffer;
}
-void ReadBufferOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void ReadBufferOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
if (this->m_memoryProxy != nullptr) {
WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation();
- operation->determineResolution(resolution, preferredResolution);
- operation->setResolution(resolution);
+ operation->determine_canvas(preferred_area, r_area);
+ operation->set_canvas(r_area);
/** \todo may not occur! But does with blur node. */
if (this->m_memoryProxy->getExecutor()) {
+ uint resolution[2] = {static_cast<uint>(BLI_rcti_size_x(&r_area)),
+ static_cast<uint>(BLI_rcti_size_y(&r_area))};
this->m_memoryProxy->getExecutor()->setResolution(resolution);
}
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h
index 8b96b961a43..02f6eccd246 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.h
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h
@@ -43,8 +43,7 @@ class ReadBufferOperation : public NodeOperation {
return this->m_memoryProxy;
}
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void *initializeTileData(rcti *rect) override;
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cc b/source/blender/compositor/operations/COM_RenderLayersProg.cc
index 72e2c92c9cf..2ac551ffe6f 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cc
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cc
@@ -196,15 +196,13 @@ void RenderLayersProg::deinitExecution()
}
}
-void RenderLayersProg::determineResolution(unsigned int resolution[2],
- unsigned int /*preferredResolution*/[2])
+void RenderLayersProg::determine_canvas(const rcti &UNUSED(preferred_area), rcti &r_area)
{
Scene *sce = this->getScene();
Render *re = (sce) ? RE_GetSceneRender(sce) : nullptr;
RenderResult *rr = nullptr;
- resolution[0] = 0;
- resolution[1] = 0;
+ r_area = COM_AREA_NONE;
if (re) {
rr = RE_AcquireResultRead(re);
@@ -215,8 +213,7 @@ void RenderLayersProg::determineResolution(unsigned int resolution[2],
if (view_layer) {
RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
if (rl) {
- resolution[0] = rl->rectx;
- resolution[1] = rl->recty;
+ BLI_rcti_init(&r_area, 0, rl->rectx, 0, rl->recty);
}
}
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.h b/source/blender/compositor/operations/COM_RenderLayersProg.h
index dd76a56d645..b499afd45df 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.h
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.h
@@ -73,8 +73,7 @@ class RenderLayersProg : public MultiThreadedOperation {
/**
* Determine the output resolution. The resolution is retrieved from the Renderer
*/
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
/**
* retrieve the reference to the float buffer of the renderer.
diff --git a/source/blender/compositor/operations/COM_RotateOperation.cc b/source/blender/compositor/operations/COM_RotateOperation.cc
index e3c482c15cb..8578e5c3269 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.cc
+++ b/source/blender/compositor/operations/COM_RotateOperation.cc
@@ -28,7 +28,7 @@ RotateOperation::RotateOperation()
this->addInputSocket(DataType::Color);
this->addInputSocket(DataType::Value);
this->addOutputSocket(DataType::Color);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->m_imageSocket = nullptr;
this->m_degreeSocket = nullptr;
this->m_doDegree2RadConversion = false;
@@ -164,8 +164,7 @@ void RotateOperation::get_area_of_interest(const int input_idx,
rcti &r_input_area)
{
if (input_idx == DEGREE_INPUT_INDEX) {
- /* Degrees input is always used as constant. */
- r_input_area = COM_SINGLE_ELEM_AREA;
+ r_input_area = COM_CONSTANT_INPUT_AREA_OF_INTEREST;
return;
}
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cc b/source/blender/compositor/operations/COM_ScaleOperation.cc
index 0161b837915..f5a423ea8e3 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.cc
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cc
@@ -48,7 +48,7 @@ ScaleOperation::ScaleOperation(DataType data_type) : BaseScaleOperation()
this->addInputSocket(DataType::Value);
this->addInputSocket(DataType::Value);
this->addOutputSocket(data_type);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->m_inputOperation = nullptr;
this->m_inputXOperation = nullptr;
this->m_inputYOperation = nullptr;
@@ -267,7 +267,7 @@ ScaleFixedSizeOperation::ScaleFixedSizeOperation() : BaseScaleOperation()
{
this->addInputSocket(DataType::Color, ResizeMode::None);
this->addOutputSocket(DataType::Color);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->m_inputOperation = nullptr;
this->m_is_offset = false;
}
@@ -366,15 +366,14 @@ bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input,
return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
-void ScaleFixedSizeOperation::determineResolution(unsigned int resolution[2],
- unsigned int /*preferredResolution*/[2])
+void ScaleFixedSizeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- unsigned int nr[2];
- nr[0] = this->m_newWidth;
- nr[1] = this->m_newHeight;
- BaseScaleOperation::determineResolution(resolution, nr);
- resolution[0] = this->m_newWidth;
- resolution[1] = this->m_newHeight;
+ rcti local_preferred = preferred_area;
+ local_preferred.xmax = local_preferred.xmin + m_newWidth;
+ local_preferred.ymax = local_preferred.ymin + m_newHeight;
+ BaseScaleOperation::determine_canvas(local_preferred, r_area);
+ r_area.xmax = r_area.xmin + m_newWidth;
+ r_area.ymax = r_area.ymin + m_newHeight;
}
void ScaleFixedSizeOperation::get_area_of_interest(const int input_idx,
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h
index 65762d1ce62..04fa4fe62d1 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.h
+++ b/source/blender/compositor/operations/COM_ScaleOperation.h
@@ -141,8 +141,7 @@ class ScaleFixedSizeOperation : public BaseScaleOperation {
bool determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation,
rcti *output) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
void init_data() override;
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc
index 628da686a42..87949a1b24f 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc
@@ -388,7 +388,7 @@ void ScreenLensDistortionOperation::get_area_of_interest(const int input_idx,
{
if (input_idx != 0) {
/* Dispersion and distortion inputs are used as constants only. */
- r_input_area = COM_SINGLE_ELEM_AREA;
+ r_input_area = COM_CONSTANT_INPUT_AREA_OF_INTEREST;
}
/* XXX the original method of estimating the area-of-interest does not work
@@ -398,10 +398,7 @@ void ScreenLensDistortionOperation::get_area_of_interest(const int input_idx,
*/
#if 1
NodeOperation *image = getInputOperation(0);
- r_input_area.xmax = image->getWidth();
- r_input_area.xmin = 0;
- r_input_area.ymax = image->getHeight();
- r_input_area.ymin = 0;
+ r_input_area = image->get_canvas();
#else /* Original method in tiled implementation. */
rcti newInput;
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.cc b/source/blender/compositor/operations/COM_SetColorOperation.cc
index dbe45fa60db..1e7a950e727 100644
--- a/source/blender/compositor/operations/COM_SetColorOperation.cc
+++ b/source/blender/compositor/operations/COM_SetColorOperation.cc
@@ -34,11 +34,9 @@ void SetColorOperation::executePixelSampled(float output[4],
copy_v4_v4(output, this->m_color);
}
-void SetColorOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void SetColorOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ r_area = preferred_area;
}
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h
index f546d5e7668..34ea35bdcbc 100644
--- a/source/blender/compositor/operations/COM_SetColorOperation.h
+++ b/source/blender/compositor/operations/COM_SetColorOperation.h
@@ -83,8 +83,7 @@ class SetColorOperation : public ConstantOperation {
*/
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
};
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.cc b/source/blender/compositor/operations/COM_SetValueOperation.cc
index ef43cf64653..b7c50f94887 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.cc
+++ b/source/blender/compositor/operations/COM_SetValueOperation.cc
@@ -34,11 +34,9 @@ void SetValueOperation::executePixelSampled(float output[4],
output[0] = this->m_value;
}
-void SetValueOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void SetValueOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ r_area = preferred_area;
}
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h
index 726624c1c6a..e72652450a9 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.h
+++ b/source/blender/compositor/operations/COM_SetValueOperation.h
@@ -54,8 +54,8 @@ class SetValueOperation : public ConstantOperation {
* The inner loop of this operation.
*/
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
};
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cc b/source/blender/compositor/operations/COM_SetVectorOperation.cc
index 7b8cf44048c..3e8514f1f59 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.cc
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.cc
@@ -37,11 +37,9 @@ void SetVectorOperation::executePixelSampled(float output[4],
output[2] = vector_.z;
}
-void SetVectorOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void SetVectorOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ r_area = preferred_area;
}
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h
index 41fd06659d6..920ea8051e4 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.h
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.h
@@ -84,8 +84,7 @@ class SetVectorOperation : public ConstantOperation {
*/
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void setVector(const float vector[3])
{
diff --git a/source/blender/compositor/operations/COM_SplitOperation.cc b/source/blender/compositor/operations/COM_SplitOperation.cc
index b2a50e2c740..47b2bbb7e94 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.cc
+++ b/source/blender/compositor/operations/COM_SplitOperation.cc
@@ -67,16 +67,14 @@ void SplitOperation::executePixelSampled(float output[4],
}
}
-void SplitOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void SplitOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- unsigned int tempPreferredResolution[2] = {0, 0};
- unsigned int tempResolution[2];
+ rcti unused_area;
- this->getInputSocket(0)->determineResolution(tempResolution, tempPreferredResolution);
- this->setResolutionInputSocketIndex((tempResolution[0] && tempResolution[1]) ? 0 : 1);
+ const bool determined = this->getInputSocket(0)->determine_canvas(COM_AREA_NONE, unused_area);
+ this->set_canvas_input_index(determined ? 0 : 1);
- NodeOperation::determineResolution(resolution, preferredResolution);
+ NodeOperation::determine_canvas(preferred_area, r_area);
}
void SplitOperation::update_memory_buffer_partial(MemoryBuffer *output,
diff --git a/source/blender/compositor/operations/COM_SplitOperation.h b/source/blender/compositor/operations/COM_SplitOperation.h
index 2d09d2a07dc..f923c9f8b7a 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.h
+++ b/source/blender/compositor/operations/COM_SplitOperation.h
@@ -35,8 +35,7 @@ class SplitOperation : public MultiThreadedOperation {
void initExecution() override;
void deinitExecution() override;
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void setSplitPercentage(float splitPercentage)
{
this->m_splitPercentage = splitPercentage;
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cc b/source/blender/compositor/operations/COM_SunBeamsOperation.cc
index ad96e3a02ba..494506389c5 100644
--- a/source/blender/compositor/operations/COM_SunBeamsOperation.cc
+++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cc
@@ -25,7 +25,7 @@ SunBeamsOperation::SunBeamsOperation()
{
this->addInputSocket(DataType::Color);
this->addOutputSocket(DataType::Color);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->flags.complex = true;
}
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cc b/source/blender/compositor/operations/COM_TextureOperation.cc
index c8e0844d35f..94977ed5adf 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cc
+++ b/source/blender/compositor/operations/COM_TextureOperation.cc
@@ -72,32 +72,26 @@ void TextureBaseOperation::deinitExecution()
NodeOperation::deinitExecution();
}
-void TextureBaseOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void TextureBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
switch (execution_model_) {
case eExecutionModel::Tiled: {
- if (preferredResolution[0] == 0 || preferredResolution[1] == 0) {
+ r_area = preferred_area;
+ if (BLI_rcti_is_empty(&preferred_area)) {
int width = this->m_rd->xsch * this->m_rd->size / 100;
int height = this->m_rd->ysch * this->m_rd->size / 100;
- resolution[0] = width;
- resolution[1] = height;
- }
- else {
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ r_area.xmax = preferred_area.xmin + width;
+ r_area.ymax = preferred_area.ymin + height;
}
break;
}
case eExecutionModel::FullFrame: {
- /* Determine inputs resolutions. */
- unsigned int temp[2];
- NodeOperation::determineResolution(temp, preferredResolution);
-
- /* We don't use inputs resolutions because they are only used as parameters, not image data.
- */
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ /* Determine inputs. */
+ rcti temp;
+ NodeOperation::determine_canvas(preferred_area, temp);
+
+ /* Don't use input areas, they are only used as parameters. */
+ r_area = preferred_area;
break;
}
}
diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h
index 1e95cb270d0..5bc21da1f96 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.h
+++ b/source/blender/compositor/operations/COM_TextureOperation.h
@@ -46,8 +46,7 @@ class TextureBaseOperation : public MultiThreadedOperation {
/**
* Determine the output resolution.
*/
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
/**
* Constructor
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cc b/source/blender/compositor/operations/COM_TonemapOperation.cc
index 20da468eeb1..67eb26993d0 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.cc
+++ b/source/blender/compositor/operations/COM_TonemapOperation.cc
@@ -160,11 +160,7 @@ void TonemapOperation::get_area_of_interest(const int input_idx,
rcti &r_input_area)
{
BLI_assert(input_idx == 0);
- NodeOperation *operation = getInputOperation(input_idx);
- r_input_area.xmin = 0;
- r_input_area.ymin = 0;
- r_input_area.xmax = operation->getWidth();
- r_input_area.ymax = operation->getHeight();
+ r_input_area = get_input_operation(input_idx)->get_canvas();
}
struct Luminance {
diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.cc b/source/blender/compositor/operations/COM_TrackPositionOperation.cc
index 0f4be16a620..1929c578177 100644
--- a/source/blender/compositor/operations/COM_TrackPositionOperation.cc
+++ b/source/blender/compositor/operations/COM_TrackPositionOperation.cc
@@ -157,11 +157,9 @@ const float *TrackPositionOperation::get_constant_elem()
return &track_position_;
}
-void TrackPositionOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void TrackPositionOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ r_area = preferred_area;
}
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.h b/source/blender/compositor/operations/COM_TrackPositionOperation.h
index f716bd97737..a47d3e03ed4 100644
--- a/source/blender/compositor/operations/COM_TrackPositionOperation.h
+++ b/source/blender/compositor/operations/COM_TrackPositionOperation.h
@@ -53,8 +53,7 @@ class TrackPositionOperation : public ConstantOperation {
/**
* Determine the output resolution. The resolution is retrieved from the Renderer
*/
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
public:
TrackPositionOperation();
diff --git a/source/blender/compositor/operations/COM_TransformOperation.cc b/source/blender/compositor/operations/COM_TransformOperation.cc
index 2feaa0ae16d..f73c9e9d956 100644
--- a/source/blender/compositor/operations/COM_TransformOperation.cc
+++ b/source/blender/compositor/operations/COM_TransformOperation.cc
@@ -99,7 +99,7 @@ void TransformOperation::get_area_of_interest(const int input_idx,
case X_INPUT_INDEX:
case Y_INPUT_INDEX:
case DEGREE_INPUT_INDEX: {
- r_input_area = COM_SINGLE_ELEM_AREA;
+ r_input_area = COM_CONSTANT_INPUT_AREA_OF_INTEREST;
break;
}
case SCALE_INPUT_INDEX: {
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cc b/source/blender/compositor/operations/COM_TranslateOperation.cc
index a3db086e974..266e960037c 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.cc
+++ b/source/blender/compositor/operations/COM_TranslateOperation.cc
@@ -29,7 +29,7 @@ TranslateOperation::TranslateOperation(DataType data_type)
this->addInputSocket(DataType::Value);
this->addInputSocket(DataType::Value);
this->addOutputSocket(data_type);
- this->setResolutionInputSocketIndex(0);
+ this->set_canvas_input_index(0);
this->m_inputOperation = nullptr;
this->m_inputXOperation = nullptr;
this->m_inputYOperation = nullptr;
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc
index b8274576cb5..0fe44e3a61f 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc
@@ -77,7 +77,7 @@ void *VariableSizeBokehBlurOperation::initializeTileData(rcti *rect)
this->determineDependingAreaOfInterest(
rect, (ReadBufferOperation *)this->m_inputSizeProgram, &rect2);
- const float max_dim = MAX2(m_width, m_height);
+ const float max_dim = MAX2(this->getWidth(), this->getHeight());
const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
data->maxBlurScalar = (int)(data->size->get_max_value(rect2) * scalar);
@@ -105,7 +105,7 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
float multiplier_accum[4];
float color_accum[4];
- const float max_dim = MAX2(m_width, m_height);
+ const float max_dim = MAX2(getWidth(), getHeight());
const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
int maxBlurScalar = tileData->maxBlurScalar;
@@ -125,8 +125,8 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
#else
int minx = MAX2(x - maxBlurScalar, 0);
int miny = MAX2(y - maxBlurScalar, 0);
- int maxx = MIN2(x + maxBlurScalar, (int)m_width);
- int maxy = MIN2(y + maxBlurScalar, (int)m_height);
+ int maxx = MIN2(x + maxBlurScalar, (int)getWidth());
+ int maxy = MIN2(y + maxBlurScalar, (int)getHeight());
#endif
{
inputSizeBuffer->readNoCheck(tempSize, x, y);
@@ -200,7 +200,7 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice *device,
MemoryBuffer *sizeMemoryBuffer = this->m_inputSizeProgram->getInputMemoryBuffer(
inputMemoryBuffers);
- const float max_dim = MAX2(m_width, m_height);
+ const float max_dim = MAX2(getWidth(), getHeight());
cl_float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
maxBlur = (cl_int)min_ff(sizeMemoryBuffer->get_max_value() * scalar, (float)this->m_maxBlur);
@@ -238,7 +238,7 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(
rcti newInput;
rcti bokehInput;
- const float max_dim = MAX2(m_width, m_height);
+ const float max_dim = MAX2(getWidth(), getHeight());
const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
int maxBlurScalar = this->m_maxBlur * scalar;
@@ -294,10 +294,9 @@ void VariableSizeBokehBlurOperation::get_area_of_interest(const int input_idx,
break;
}
case BOKEH_INPUT_INDEX: {
- r_input_area.xmax = COM_BLUR_BOKEH_PIXELS;
- r_input_area.xmin = 0;
- r_input_area.ymax = COM_BLUR_BOKEH_PIXELS;
- r_input_area.ymin = 0;
+ r_input_area = output_area;
+ r_input_area.xmax = r_input_area.xmin + COM_BLUR_BOKEH_PIXELS;
+ r_input_area.ymax = r_input_area.ymin + COM_BLUR_BOKEH_PIXELS;
break;
}
#ifdef COM_DEFOCUS_SEARCH
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
index 56b4677087b..3634bc2f1d7 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
@@ -130,8 +130,7 @@ class InverseSearchRadiusOperation : public NodeOperation {
bool determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation,
rcti *output) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void setMaxBlur(int maxRadius)
{
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cc b/source/blender/compositor/operations/COM_VectorBlurOperation.cc
index 5405e6d424a..63956410b60 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cc
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cc
@@ -126,10 +126,7 @@ void VectorBlurOperation::get_area_of_interest(const int UNUSED(input_idx),
const rcti &UNUSED(output_area),
rcti &r_input_area)
{
- r_input_area.xmin = 0;
- r_input_area.xmax = this->getWidth();
- r_input_area.ymin = 0;
- r_input_area.ymax = this->getHeight();
+ r_input_area = this->get_canvas();
}
void VectorBlurOperation::update_memory_buffer(MemoryBuffer *output,
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cc b/source/blender/compositor/operations/COM_ViewerOperation.cc
index a038e8994d8..1cb98ac8474 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cc
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cc
@@ -122,15 +122,15 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
updateImage(rect);
}
-void ViewerOperation::determineResolution(unsigned int resolution[2],
- unsigned int /*preferredResolution*/[2])
+void ViewerOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
const int sceneRenderWidth = this->m_rd->xsch * this->m_rd->size / 100;
const int sceneRenderHeight = this->m_rd->ysch * this->m_rd->size / 100;
- unsigned int localPrefRes[2] = {static_cast<unsigned int>(sceneRenderWidth),
- static_cast<unsigned int>(sceneRenderHeight)};
- NodeOperation::determineResolution(resolution, localPrefRes);
+ rcti local_preferred = preferred_area;
+ local_preferred.xmax = local_preferred.xmin + sceneRenderWidth;
+ local_preferred.ymax = local_preferred.ymin + sceneRenderHeight;
+ NodeOperation::determine_canvas(local_preferred, r_area);
}
void ViewerOperation::initImage()
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h
index 06ac501a535..e759bcf9898 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerOperation.h
@@ -55,8 +55,7 @@ class ViewerOperation : public MultiThreadedOperation {
void initExecution() override;
void deinitExecution() override;
void executeRegion(rcti *rect, unsigned int tileNumber) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
bool isOutputOperation(bool /*rendering*/) const override
{
if (G.background) {
diff --git a/source/blender/compositor/operations/COM_WrapOperation.cc b/source/blender/compositor/operations/COM_WrapOperation.cc
index 888602114cc..393128ded41 100644
--- a/source/blender/compositor/operations/COM_WrapOperation.cc
+++ b/source/blender/compositor/operations/COM_WrapOperation.cc
@@ -33,7 +33,7 @@ inline float WrapOperation::getWrappedOriginalXPos(float x)
return 0;
}
while (x < 0) {
- x += this->m_width;
+ x += this->getWidth();
}
return fmodf(x, this->getWidth());
}
@@ -44,7 +44,7 @@ inline float WrapOperation::getWrappedOriginalYPos(float y)
return 0;
}
while (y < 0) {
- y += this->m_height;
+ y += this->getHeight();
}
return fmodf(y, this->getHeight());
}
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cc b/source/blender/compositor/operations/COM_WriteBufferOperation.cc
index 6380f6bf3df..a1c1e514eb7 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.cc
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cc
@@ -50,7 +50,7 @@ void WriteBufferOperation::executePixelSampled(float output[4],
void WriteBufferOperation::initExecution()
{
this->m_input = this->getInputOperation(0);
- this->m_memoryProxy->allocate(this->m_width, this->m_height);
+ this->m_memoryProxy->allocate(this->getWidth(), this->getHeight());
}
void WriteBufferOperation::deinitExecution()
@@ -206,18 +206,17 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice *device,
delete clKernelsToCleanUp;
}
-void WriteBufferOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void WriteBufferOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- NodeOperation::determineResolution(resolution, preferredResolution);
+ NodeOperation::determine_canvas(preferred_area, r_area);
/* make sure there is at least one pixel stored in case the input is a single value */
m_single_value = false;
- if (resolution[0] == 0) {
- resolution[0] = 1;
+ if (BLI_rcti_size_x(&r_area) == 0) {
+ r_area.xmax += 1;
m_single_value = true;
}
- if (resolution[1] == 0) {
- resolution[1] = 1;
+ if (BLI_rcti_size_y(&r_area) == 0) {
+ r_area.ymax += 1;
m_single_value = true;
}
}
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h
index 2817fbe24b9..b7dededc69f 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.h
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h
@@ -56,8 +56,7 @@ class WriteBufferOperation : public NodeOperation {
unsigned int chunkNumber,
MemoryBuffer **memoryBuffers,
MemoryBuffer *outputBuffer) override;
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]) override;
+ void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
void readResolutionFromInputSocket();
inline NodeOperation *getInput()
{