* modified vieweroperation to not calculate based on the DO_NODE_OUTPUT
authorJeroen Bakker <j.bakker@atmind.nl>
Mon, 4 Jun 2012 18:07:29 +0000 (18:07 +0000)
committerJeroen Bakker <j.bakker@atmind.nl>
Mon, 4 Jun 2012 18:07:29 +0000 (18:07 +0000)
flag of the editorbNode.

source/blender/compositor/nodes/COM_ViewerNode.cpp
source/blender/compositor/operations/COM_BlurBaseOperation.cpp
source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
source/blender/compositor/operations/COM_ViewerBaseOperation.h

index db4fd115d734072b615bada2cbc6523eace7c070..679589a7ce12c86150e85fec2f8464cd0e798c66 100644 (file)
@@ -37,7 +37,7 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
        Image *image = (Image*)this->getbNode()->id;
        ImageUser * imageUser = (ImageUser*) this->getbNode()->storage;
        bNode *editorNode = this->getbNode();
-       if (imageSocket->isConnected() && (editorNode->flag & NODE_DO_OUTPUT)) {
+       if (imageSocket->isConnected()) {
                ViewerOperation *viewerOperation = new ViewerOperation();
                viewerOperation->setColorManagement(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT);
                viewerOperation->setColorPredivide(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
index babea459d6a81ab82547cc7fe5a92054c8d7a57e..2280ee3a435995585cb6257f6e3c3f902fafb450 100644 (file)
@@ -101,7 +101,10 @@ void BlurBaseOperation::deinitExecution()
 
 void BlurBaseOperation::updateSize(MemoryBuffer **memoryBuffers)
 {
-       float result[4];
-       this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, memoryBuffers);
-       this->size = result[0];
+       if (!this->sizeavailable) {
+               float result[4];
+               this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, memoryBuffers);
+               this->size = result[0];
+               this->sizeavailable = true;
+       }
 }
index ad8f3b12387bd782d416f8e0910eb5bd6b1a2dd0..ad58631f2c1b0d37aecab018bca9e0b43204839e 100644 (file)
 
 FastGaussianBlurOperation::FastGaussianBlurOperation(): BlurBaseOperation()
 {
-       this->iirgaus = false;
+       this->iirgaus = NULL;
 }
 
 void FastGaussianBlurOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data)
 {
        MemoryBuffer *newData = (MemoryBuffer*)data;
-       
        newData->read(color, x, y);     
 }
 
@@ -51,10 +50,7 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, Re
        }
        else {
                if (this->iirgaus) {
-                       newInput.xmax = input->xmax + (sx);
-                       newInput.xmin = input->xmin - (sx);
-                       newInput.ymax = input->ymax + (sy);
-                       newInput.ymin = input->ymin - (sy);
+                       return false;
                }
                else {
                        newInput.xmin = 0;
@@ -66,38 +62,51 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, Re
        }
 }
 
-void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+void FastGaussianBlurOperation::initExecution()
 {
-       MemoryBuffer *newBuf = (MemoryBuffer*)this->inputProgram->initializeTileData(rect, memoryBuffers);
-       MemoryBuffer *copy = newBuf->duplicate();
-       updateSize(memoryBuffers);
-       
-       int c;
-       sx = data->sizex * this->size/2.0f;
-       sy = data->sizey * this->size/2.0f;     
-       this->iirgaus = true;
-       
-       if ((sx == sy) && (sx > 0.f)) {
-               for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
-                       IIR_gauss(copy, sx, c, 3);
+       BlurBaseOperation::initExecution();
+       BlurBaseOperation::initMutex();
+}
+
+void FastGaussianBlurOperation::deinitExecution() 
+{
+       if (this->iirgaus) {
+               delete this->iirgaus;
+               this->iirgaus = NULL;
        }
-       else {
-               if (sx > 0.f) {
+       BlurBaseOperation::deinitMutex();       
+}
+
+void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+{
+       BLI_mutex_lock(this->getMutex());
+       if (!iirgaus) {
+               MemoryBuffer *newBuf = (MemoryBuffer*)this->inputProgram->initializeTileData(rect, memoryBuffers);
+               MemoryBuffer *copy = newBuf->duplicate();
+               updateSize(memoryBuffers);
+               
+               int c;
+               sx = data->sizex * this->size/2.0f;
+               sy = data->sizey * this->size/2.0f;     
+               
+               if ((sx == sy) && (sx > 0.f)) {
                        for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
-                               IIR_gauss(copy, sx, c, 1);
+                               IIR_gauss(copy, sx, c, 3);
                }
-               if (sy > 0.f) {
-                       for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
-                               IIR_gauss(copy, sy, c, 2);
+               else {
+                       if (sx > 0.f) {
+                               for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
+                                       IIR_gauss(copy, sx, c, 1);
+                       }
+                       if (sy > 0.f) {
+                               for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
+                                       IIR_gauss(copy, sy, c, 2);
+                       }
                }
+               this->iirgaus = copy;
        }
-       return copy;
-}
-
-void FastGaussianBlurOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data)
-{
-       MemoryBuffer *newData = (MemoryBuffer*)data;
-       delete newData;
+       BLI_mutex_unlock(this->getMutex());
+       return iirgaus;
 }
 
 void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int chan, int xy)
index 6c3e373472bbf2a451b2027fb8e7daeca87d32ad..1f71fe7f9ed49188121daf8d92acf9c8385a4ffb 100644 (file)
@@ -30,7 +30,7 @@ class FastGaussianBlurOperation: public BlurBaseOperation {
 private:
        float sx;
        float sy;
-       bool iirgaus;
+       MemoryBuffer* iirgaus;
 public:
        FastGaussianBlurOperation();
        bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
@@ -38,7 +38,8 @@ public:
        
        static void IIR_gauss(MemoryBuffer *src, float sigma, int channel, int xy);
        void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
-       void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data);
+       void deinitExecution();
+       void initExecution();
        
 };
 #endif
index 44b4c26fb644641a1f5efe599cc292f36174ded8..71fc53e8f8e167efe48c8f548bd5bccb9fa30327 100644 (file)
@@ -50,8 +50,9 @@ ViewerBaseOperation::ViewerBaseOperation() : NodeOperation()
 
 void ViewerBaseOperation::initExecution()
 {
-       // When initializing the tree during initial load the width and height can be zero.
-       initImage();
+       if (isActiveViewerOutput()) {
+               initImage();
+       }
 }
 
 void ViewerBaseOperation::initImage()
@@ -79,7 +80,6 @@ void ViewerBaseOperation::initImage()
 }
 void ViewerBaseOperation:: updateImage(rcti *rect)
 {
-       /// @todo: introduce new event to update smaller area
        WM_main_add_notifier(NC_WINDOW|ND_DRAW, NULL);
 }
 
index 58101911550657ff4d3f9fc3c1e6244ce21e3100..f5f30809f6504969d0c79ed464fa3224e202f1a5 100644 (file)
@@ -42,7 +42,7 @@ protected:
        bool doColorPredivide;
 
 public:
-       bool isOutputOperation(bool rendering) const {return true;}
+       bool isOutputOperation(bool rendering) const {return isActiveViewerOutput();}
        void initExecution();
        void deinitExecution();
        void setImage(Image *image) {this->image = image;}