diff options
author | Manuel Castilla <manzanillawork@gmail.com> | 2021-06-23 18:21:17 +0300 |
---|---|---|
committer | Manuel Castilla <manzanillawork@gmail.com> | 2021-06-23 18:46:53 +0300 |
commit | 35db01325f41da34e5a71d2b28cc717cddbdb996 (patch) | |
tree | 923bfa9c71e1eda1f1fc25c01a7ebbd0382f0d49 /source/blender/compositor/operations/COM_ImageOperation.cc | |
parent | 8f4d99159404621a9063f4bd155a519baf51f313 (diff) |
Compositor: Full frame Image node
Adds full frame implementation to Image node operations.
Mostly refactored into buffer utility methods for reuse in other
operations.
No functional changes.
1.8x faster than tiled fallback.
Reviewed By: jbakker
Differential Revision: https://developer.blender.org/D11559
Diffstat (limited to 'source/blender/compositor/operations/COM_ImageOperation.cc')
-rw-r--r-- | source/blender/compositor/operations/COM_ImageOperation.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cc b/source/blender/compositor/operations/COM_ImageOperation.cc index a1d401d4499..e78d389410f 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.cc +++ b/source/blender/compositor/operations/COM_ImageOperation.cc @@ -44,6 +44,7 @@ BaseImageOperation::BaseImageOperation() this->m_imageheight = 0; this->m_framenumber = 0; this->m_depthBuffer = nullptr; + depth_buffer_ = nullptr; this->m_numberOfChannels = 0; this->m_rd = nullptr; this->m_viewName = nullptr; @@ -91,6 +92,9 @@ void BaseImageOperation::initExecution() this->m_imageFloatBuffer = stackbuf->rect_float; this->m_imageByteBuffer = stackbuf->rect; this->m_depthBuffer = stackbuf->zbuf_float; + if (stackbuf->zbuf_float) { + depth_buffer_ = new MemoryBuffer(stackbuf->zbuf_float, 1, stackbuf->x, stackbuf->y); + } this->m_imagewidth = stackbuf->x; this->m_imageheight = stackbuf->y; this->m_numberOfChannels = stackbuf->channels; @@ -102,6 +106,10 @@ void BaseImageOperation::deinitExecution() this->m_imageFloatBuffer = nullptr; this->m_imageByteBuffer = nullptr; BKE_image_release_ibuf(this->m_image, this->m_buffer, nullptr); + if (depth_buffer_) { + delete depth_buffer_; + depth_buffer_ = nullptr; + } } void BaseImageOperation::determineResolution(unsigned int resolution[2], @@ -170,6 +178,13 @@ void ImageOperation::executePixelSampled(float output[4], float x, float y, Pixe } } +void ImageOperation::update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span<MemoryBuffer *> UNUSED(inputs)) +{ + output->copy_from(m_buffer, area, true); +} + void ImageAlphaOperation::executePixelSampled(float output[4], float x, float y, @@ -187,6 +202,13 @@ void ImageAlphaOperation::executePixelSampled(float output[4], } } +void ImageAlphaOperation::update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span<MemoryBuffer *> UNUSED(inputs)) +{ + output->copy_from(m_buffer, area, 3, COM_DATA_TYPE_VALUE_CHANNELS, 0); +} + void ImageDepthOperation::executePixelSampled(float output[4], float x, float y, @@ -206,4 +228,16 @@ void ImageDepthOperation::executePixelSampled(float output[4], } } +void ImageDepthOperation::update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span<MemoryBuffer *> UNUSED(inputs)) +{ + if (depth_buffer_) { + output->copy_from(depth_buffer_, area); + } + else { + output->fill(area, COM_VALUE_ZERO); + } +} + } // namespace blender::compositor |