diff options
Diffstat (limited to 'source/blender/compositor/operations')
-rw-r--r-- | source/blender/compositor/operations/COM_PreviewOperation.cpp | 35 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_PreviewOperation.h | 5 |
2 files changed, 23 insertions, 17 deletions
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp index 6e58b277f66..ba158fb2509 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cpp +++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp @@ -36,42 +36,47 @@ extern "C" { #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_colormanagement.h" + #include "BKE_node.h" } PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings) : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); + this->m_preview = NULL; this->m_outputBuffer = NULL; this->m_input = NULL; this->m_divider = 1.0f; - this->m_node = NULL; this->m_viewSettings = viewSettings; this->m_displaySettings = displaySettings; } +void PreviewOperation::verifyPreview(bNodeInstanceHash *previews, bNodeInstanceKey key) +{ + /* Size (0, 0) ensures the preview rect is not allocated in advance, + * this is set later in initExecution once the resolution is determined. + */ + this->m_preview = BKE_node_preview_verify(previews, key, 0, 0, TRUE); +} + void PreviewOperation::initExecution() { this->m_input = getInputSocketReader(0); - if (!this->m_node->preview) { - this->m_node->preview = (bNodePreview *)MEM_callocN(sizeof(bNodePreview), "node preview"); - } - else { - if (this->getWidth() == (unsigned int)this->m_node->preview->xsize && - this->getHeight() == (unsigned int)this->m_node->preview->ysize) - { - this->m_outputBuffer = this->m_node->preview->rect; - } + + if (this->getWidth() == (unsigned int)this->m_preview->xsize && + this->getHeight() == (unsigned int)this->m_preview->ysize) + { + this->m_outputBuffer = this->m_preview->rect; } if (this->m_outputBuffer == NULL) { this->m_outputBuffer = (unsigned char *)MEM_callocN(sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation"); - if (this->m_node->preview->rect) { - MEM_freeN(this->m_node->preview->rect); + if (this->m_preview->rect) { + MEM_freeN(this->m_preview->rect); } - this->m_node->preview->xsize = getWidth(); - this->m_node->preview->ysize = getHeight(); - this->m_node->preview->rect = this->m_outputBuffer; + this->m_preview->xsize = getWidth(); + this->m_preview->ysize = getHeight(); + this->m_preview->rect = this->m_outputBuffer; } } diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h index 0da6b8e4e56..bb60dfa0420 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.h +++ b/source/blender/compositor/operations/COM_PreviewOperation.h @@ -35,7 +35,7 @@ protected: /** * @brief holds reference to the SDNA bNode, where this nodes will render the preview image for */ - bNode *m_node; + bNodePreview *m_preview; SocketReader *m_input; float m_divider; @@ -43,6 +43,8 @@ protected: const ColorManagedDisplaySettings *m_displaySettings; public: PreviewOperation(const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings); + void verifyPreview(bNodeInstanceHash *previews, bNodeInstanceKey key); + bool isOutputOperation(bool rendering) const { return !G.background; } void initExecution(); void deinitExecution(); @@ -50,7 +52,6 @@ public: void executeRegion(rcti *rect, unsigned int tileNumber); void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); - void setbNode(bNode *node) { this->m_node = node; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); bool isPreviewOperation() { return true; } |