From dcb81a434db4b1c221a40c78fe7a6001199e9762 Mon Sep 17 00:00:00 2001 From: Habib Gahbiche Date: Thu, 4 Apr 2024 10:53:32 +0200 Subject: [PATCH] Fix #119973: Flip node produces artifacts The Flip node produces artifacts if not connected directly to an input. This due to a wrong calculation of depending area of interest, which is a regressed introduced in 70a8a9e. This is fixed by reverting the removal of the area of interest calculation method in the aforementioned commit. Pull Request: https://projects.blender.org/blender/blender/pulls/120149 --- .../operations/COM_FlipOperation.cc | 28 +++++++++++++++++++ .../compositor/operations/COM_FlipOperation.h | 3 ++ 2 files changed, 31 insertions(+) diff --git a/source/blender/compositor/operations/COM_FlipOperation.cc b/source/blender/compositor/operations/COM_FlipOperation.cc index fdd10a4f645..374eed3f96f 100644 --- a/source/blender/compositor/operations/COM_FlipOperation.cc +++ b/source/blender/compositor/operations/COM_FlipOperation.cc @@ -34,6 +34,34 @@ void FlipOperation::execute_pixel_sampled(float output[4], float x, float y, Pix input_operation_->read_sampled(output, nx, ny, sampler); } +bool FlipOperation::determine_depending_area_of_interest(rcti *input, + ReadBufferOperation *read_operation, + rcti *output) +{ + rcti new_input; + + if (flip_x_) { + const int w = int(this->get_width()) - 1; + new_input.xmax = (w - input->xmin) + 1; + new_input.xmin = (w - input->xmax) - 1; + } + else { + new_input.xmin = input->xmin; + new_input.xmax = input->xmax; + } + if (flip_y_) { + const int h = int(this->get_height()) - 1; + new_input.ymax = (h - input->ymin) + 1; + new_input.ymin = (h - input->ymax) - 1; + } + else { + new_input.ymin = input->ymin; + new_input.ymax = input->ymax; + } + + return NodeOperation::determine_depending_area_of_interest(&new_input, read_operation, output); +} + void FlipOperation::update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span inputs) diff --git a/source/blender/compositor/operations/COM_FlipOperation.h b/source/blender/compositor/operations/COM_FlipOperation.h index 98884887dbc..c6b760008e4 100644 --- a/source/blender/compositor/operations/COM_FlipOperation.h +++ b/source/blender/compositor/operations/COM_FlipOperation.h @@ -16,6 +16,9 @@ class FlipOperation : public MultiThreadedOperation { public: FlipOperation(); + bool determine_depending_area_of_interest(rcti *input, + ReadBufferOperation *read_operation, + rcti *output) override; void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override; void init_execution() override;