diff options
author | Sv. Lockal <lockalsash@gmail.com> | 2013-08-05 23:16:52 +0400 |
---|---|---|
committer | Sv. Lockal <lockalsash@gmail.com> | 2013-08-05 23:16:52 +0400 |
commit | b438c2840cbf533830ecb29b1ef65325d3f77f73 (patch) | |
tree | 619cf52e827b0b2db0b8c5db605eaa96d0574e71 /source/blender/compositor/operations/COM_ViewerOperation.cpp | |
parent | f4e4e2594ce945b8ff900d4713cf7adcfa2d41d2 (diff) |
SplitViewer node:
- fix thumbnail preview (previously it showed only one input)
- make SplitViewer node update even if the second input is not connected
- now it works when the first socket is connected to a zero-sized node tree (e. g. Color Input node)
- SplitViewer node is now based on 2 operations: SplitOperation and ViewerOperation.
- ViewerBaseOperation was removed as a redundant one. Any future viewer style node can use the same principle and prepare the output before passing to an actual ViewerOperation.
Thanks Lukas Toenne for reviewing this patch and giving me get few pieces of advice.
Diffstat (limited to 'source/blender/compositor/operations/COM_ViewerOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_ViewerOperation.cpp | 80 |
1 files changed, 76 insertions, 4 deletions
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index 4d10e49aeeb..fbf73c27e09 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -35,11 +35,22 @@ extern "C" { #include "MEM_guardedalloc.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" + #include "IMB_colormanagement.h" } -ViewerOperation::ViewerOperation() : ViewerBaseOperation() +ViewerOperation::ViewerOperation() : NodeOperation() { + this->setImage(NULL); + this->setImageUser(NULL); + this->m_outputBuffer = NULL; + this->m_depthBuffer = NULL; + this->m_active = false; + this->m_doDepthBuffer = false; + this->m_viewSettings = NULL; + this->m_displaySettings = NULL; + this->m_ignoreAlpha = false; + this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_VALUE); @@ -56,7 +67,10 @@ void ViewerOperation::initExecution() this->m_alphaInput = getInputSocketReader(1); this->m_depthInput = getInputSocketReader(2); this->m_doDepthBuffer = (this->m_depthInput != NULL); - ViewerBaseOperation::initExecution(); + + if (isActiveViewerOutput()) { + initImage(); + } } void ViewerOperation::deinitExecution() @@ -64,10 +78,9 @@ void ViewerOperation::deinitExecution() this->m_imageInput = NULL; this->m_alphaInput = NULL; this->m_depthInput = NULL; - ViewerBaseOperation::deinitExecution(); + this->m_outputBuffer = NULL; } - void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) { float *buffer = this->m_outputBuffer; @@ -114,3 +127,62 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) } updateImage(rect); } + +void ViewerOperation::initImage() +{ + Image *anImage = this->m_image; + ImBuf *ibuf = BKE_image_acquire_ibuf(anImage, this->m_imageUser, &this->m_lock); + + if (!ibuf) return; + BLI_lock_thread(LOCK_DRAW_IMAGE); + if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) { + + imb_freerectImBuf(ibuf); + imb_freerectfloatImBuf(ibuf); + IMB_freezbuffloatImBuf(ibuf); + ibuf->x = getWidth(); + ibuf->y = getHeight(); + imb_addrectfloatImBuf(ibuf); + anImage->ok = IMA_OK_LOADED; + + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; + + BLI_unlock_thread(LOCK_DRAW_IMAGE); + } + + if (m_doDepthBuffer) { + addzbuffloatImBuf(ibuf); + } + BLI_unlock_thread(LOCK_DRAW_IMAGE); + + /* now we combine the input with ibuf */ + this->m_outputBuffer = ibuf->rect_float; + + /* needed for display buffer update */ + this->m_ibuf = ibuf; + + if (m_doDepthBuffer) { + this->m_depthBuffer = ibuf->zbuf_float; + } + + BKE_image_release_ibuf(this->m_image, this->m_ibuf, this->m_lock); +} + +void ViewerOperation::updateImage(rcti *rect) +{ + IMB_partial_display_buffer_update(this->m_ibuf, this->m_outputBuffer, NULL, getWidth(), 0, 0, + this->m_viewSettings, this->m_displaySettings, + rect->xmin, rect->ymin, rect->xmax, rect->ymax, FALSE); + + this->updateDraw(); +} + +const CompositorPriority ViewerOperation::getRenderPriority() const +{ + if (this->isActiveViewerOutput()) { + return COM_PRIORITY_HIGH; + } + else { + return COM_PRIORITY_LOW; + } +} |