diff options
author | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-04 14:32:07 +0300 |
---|---|---|
committer | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-04 14:32:07 +0300 |
commit | e94326b67b392aa4a42c972cdbee76121a9b8841 (patch) | |
tree | 623e53c2f1616003e5fb0eece617042dbca2585c | |
parent | c84a294c66179ba412040d194e04dbc3d7525b64 (diff) |
Compositor: Use a single elem as area of interest where possible
5 files changed, 56 insertions, 20 deletions
diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc index fcbf42c8713..92b273327be 100644 --- a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc +++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc @@ -220,6 +220,14 @@ void PlaneCornerPinMaskOperation::determineResolution(unsigned int resolution[2] resolution[1] = preferredResolution[1]; } +void PlaneCornerPinMaskOperation::get_area_of_interest(const int input_idx, + const rcti &output_area, + rcti &r_input_area) +{ + /* All corner inputs are used as constants. */ + r_input_area = COM_SINGLE_ELEM_AREA; +} + /* ******** PlaneCornerPinWarpImageOperation ******** */ PlaneCornerPinWarpImageOperation::PlaneCornerPinWarpImageOperation() : m_corners_ready(false) @@ -305,4 +313,17 @@ bool PlaneCornerPinWarpImageOperation::determineDependingAreaOfInterest( #endif } +void PlaneCornerPinWarpImageOperation::get_area_of_interest(const int input_idx, + const rcti &output_area, + rcti &r_input_area) +{ + if (input_idx == 0) { + PlaneDistortWarpImageOperation::get_area_of_interest(input_idx, output_area, r_input_area); + } + else { + /* Corner inputs are used as constants. */ + r_input_area = COM_SINGLE_ELEM_AREA; + } +} + } // namespace blender::compositor diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h index 7d857d270a0..2831e937147 100644 --- a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h +++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h @@ -45,6 +45,8 @@ class PlaneCornerPinMaskOperation : public PlaneDistortMaskOperation { void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) override; + + void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override; }; class PlaneCornerPinWarpImageOperation : public PlaneDistortWarpImageOperation { @@ -63,6 +65,8 @@ class PlaneCornerPinWarpImageOperation : public PlaneDistortWarpImageOperation { bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) override; + + void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override; }; } // namespace blender::compositor diff --git a/source/blender/compositor/operations/COM_RotateOperation.cc b/source/blender/compositor/operations/COM_RotateOperation.cc index dbfa88ec193..842bfcfdbfd 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.cc +++ b/source/blender/compositor/operations/COM_RotateOperation.cc @@ -163,8 +163,9 @@ void RotateOperation::get_area_of_interest(const int input_idx, const rcti &output_area, rcti &r_input_area) { - if (input_idx != 0) { - r_input_area = output_area; + if (input_idx == 1) { + /* Degrees input is always used as constant. */ + r_input_area = COM_SINGLE_ELEM_AREA; return; } diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc index 4741104b8f0..610c32f0ece 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc @@ -388,10 +388,7 @@ void ScreenLensDistortionOperation::get_area_of_interest(const int input_idx, { if (input_idx != 0) { /* Dispersion and distorsion inputs are used as constants only. */ - r_input_area.xmin = output_area.xmin; - r_input_area.ymin = output_area.ymin; - r_input_area.xmax = output_area.xmin + 1; - r_input_area.ymax = output_area.ymin + 1; + r_input_area = COM_SINGLE_ELEM_AREA; } /* XXX the original method of estimating the area-of-interest does not work diff --git a/source/blender/compositor/operations/COM_TransformOperation.cc b/source/blender/compositor/operations/COM_TransformOperation.cc index 255b97e0c73..7310dfd69ea 100644 --- a/source/blender/compositor/operations/COM_TransformOperation.cc +++ b/source/blender/compositor/operations/COM_TransformOperation.cc @@ -81,21 +81,34 @@ void TransformOperation::get_area_of_interest(const int input_idx, const rcti &output_area, rcti &r_input_area) { - r_input_area = output_area; - if (input_idx != 0) { - return; + switch (input_idx) { + case 0: { + r_input_area = output_area; + BLI_rcti_translate(&r_input_area, translate_x_, translate_y_); + ScaleOperation::scale_area( + r_input_area, scale_center_x_, scale_center_y_, constant_scale_, constant_scale_); + RotateOperation::get_area_rotation_bounds(r_input_area, + rotate_center_x_, + rotate_center_y_, + rotate_sine_, + rotate_cosine_, + r_input_area); + expand_area_for_sampler(r_input_area, sampler_); + return; + } + case 1: + case 2: + case 3: { + /* Translation x/y and rotation degrees are always constant. */ + r_input_area = COM_SINGLE_ELEM_AREA; + return; + } + case 4: { + /* Scaling can be variable. */ + r_input_area = output_area; + return; + } } - - BLI_rcti_translate(&r_input_area, translate_x_, translate_y_); - ScaleOperation::scale_area( - r_input_area, scale_center_x_, scale_center_y_, constant_scale_, constant_scale_); - RotateOperation::get_area_rotation_bounds(r_input_area, - rotate_center_x_, - rotate_center_y_, - rotate_sine_, - rotate_cosine_, - r_input_area); - expand_area_for_sampler(r_input_area, sampler_); } void TransformOperation::update_memory_buffer_partial(MemoryBuffer *output, |