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-08-13 01:12:34 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-08-13 03:14:25 +0300
commiteb05b26a69c44887b4e6b43a3c55998fbce31708 (patch)
treef272ec0664790c27a553562cd6ba85e4937d69ec /source/blender
parent561ed5a61f0063a4e27be6c17b5203acd690f468 (diff)
Compositor: Full frame Inpaint node
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h6
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.cc44
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.h7
3 files changed, 57 insertions, 0 deletions
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index de00ba4737b..61c6d55afc1 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -373,6 +373,12 @@ class MemoryBuffer {
return this->m_buffer;
}
+ float *release_buffer()
+ {
+ owns_data_ = false;
+ return this->m_buffer;
+ }
+
MemoryBuffer *inflate() const;
inline void wrap_pixel(int &x, int &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cc b/source/blender/compositor/operations/COM_InpaintOperation.cc
index 413ed2694a9..a86c9888457 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.cc
+++ b/source/blender/compositor/operations/COM_InpaintOperation.cc
@@ -39,6 +39,7 @@ InpaintSimpleOperation::InpaintSimpleOperation()
this->m_manhattan_distance = nullptr;
this->m_cached_buffer = nullptr;
this->m_cached_buffer_ready = false;
+ flags.is_fullframe_operation = true;
}
void InpaintSimpleOperation::initExecution()
{
@@ -286,4 +287,47 @@ bool InpaintSimpleOperation::determineDependingAreaOfInterest(rcti * /*input*/,
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
+void InpaintSimpleOperation::get_area_of_interest(const int input_idx,
+ const rcti &UNUSED(output_area),
+ rcti &r_input_area)
+{
+ 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();
+}
+
+void InpaintSimpleOperation::update_memory_buffer(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs)
+{
+ /* TODO(manzanilla): once tiled implementation is removed, run multi-threaded where possible. */
+ MemoryBuffer *input = inputs[0];
+ if (!m_cached_buffer_ready) {
+ if (input->is_a_single_elem()) {
+ MemoryBuffer *tmp = input->inflate();
+ m_cached_buffer = tmp->release_buffer();
+ delete tmp;
+ }
+ else {
+ m_cached_buffer = (float *)MEM_dupallocN(input->getBuffer());
+ }
+
+ this->calc_manhattan_distance();
+
+ int curr = 0;
+ int x, y;
+ while (this->next_pixel(x, y, curr, this->m_iterations)) {
+ this->pix_step(x, y);
+ }
+ m_cached_buffer_ready = true;
+ }
+
+ const int num_channels = COM_data_type_num_channels(getOutputSocket()->getDataType());
+ MemoryBuffer buf(m_cached_buffer, num_channels, input->getWidth(), input->getHeight());
+ output->copy_from(&buf, area);
+}
+
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.h b/source/blender/compositor/operations/COM_InpaintOperation.h
index e3d27bf7704..e11610bd263 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.h
+++ b/source/blender/compositor/operations/COM_InpaintOperation.h
@@ -66,6 +66,13 @@ class InpaintSimpleOperation : public NodeOperation {
ReadBufferOperation *readOperation,
rcti *output) override;
+ void get_area_of_interest(const int input_idx,
+ const rcti &output_area,
+ rcti &r_input_area) override;
+ void update_memory_buffer(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs) override;
+
private:
void calc_manhattan_distance();
void clamp_xy(int &x, int &y);