From 5deb3229a0757e2637163c60d7915888cc50c9d8 Mon Sep 17 00:00:00 2001 From: Manuel Castilla Date: Tue, 10 Aug 2021 15:24:17 +0200 Subject: Compositor: Full frame Mask node Adds full frame implementation to this node operations. No functional changes. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D11751 --- .../compositor/operations/COM_MaskOperation.cc | 37 ++++++++++++++++++++++ .../compositor/operations/COM_MaskOperation.h | 11 +++++-- 2 files changed, 46 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/compositor/operations/COM_MaskOperation.cc b/source/blender/compositor/operations/COM_MaskOperation.cc index c7763f08e71..84992f23924 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cc +++ b/source/blender/compositor/operations/COM_MaskOperation.cc @@ -161,4 +161,41 @@ void MaskOperation::executePixelSampled(float output[4], } } +void MaskOperation::update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span UNUSED(inputs)) +{ + Vector handles = get_non_null_handles(); + if (handles.size() == 0) { + output->fill(area, COM_VALUE_ZERO); + return; + } + + float xy[2]; + for (BuffersIterator it = output->iterate_with({}, area); !it.is_end(); ++it) { + xy[0] = it.x * m_maskWidthInv + m_mask_px_ofs[0]; + xy[1] = it.y * m_maskHeightInv + m_mask_px_ofs[1]; + *it.out = 0.0f; + for (MaskRasterHandle *handle : handles) { + *it.out += BKE_maskrasterize_handle_sample(handle, xy); + } + + /* Until we get better falloff. */ + *it.out /= m_rasterMaskHandleTot; + } +} + +Vector MaskOperation::get_non_null_handles() const +{ + Vector handles; + for (int i = 0; i < m_rasterMaskHandleTot; i++) { + MaskRasterHandle *handle = m_rasterMaskHandles[i]; + if (handle == nullptr) { + continue; + } + handles.append(handle); + } + return handles; +} + } // namespace blender::compositor diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index e8cd9c722df..81e344c0451 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -19,7 +19,7 @@ #pragma once #include "BLI_listbase.h" -#include "COM_NodeOperation.h" +#include "COM_MultiThreadedOperation.h" #include "DNA_mask_types.h" #include "IMB_imbuf_types.h" @@ -31,7 +31,7 @@ namespace blender::compositor { /** * Class with implementation of mask rasterization */ -class MaskOperation : public NodeOperation { +class MaskOperation : public MultiThreadedOperation { protected: Mask *m_mask; @@ -98,6 +98,13 @@ class MaskOperation : public NodeOperation { } void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override; + + void update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span inputs) override; + + private: + Vector get_non_null_handles() const; }; } // namespace blender::compositor -- cgit v1.2.3