Added switch in dilate/erode between old (Step) and new (Distance)
[blender.git] / source / blender / compositor / operations / COM_DilateErodeOperation.h
1 /*
2  * Copyright 2011, Blender Foundation.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor: 
19  *              Jeroen Bakker 
20  *              Monique Dewanchand
21  */
22
23 #ifndef _COM_DilateErodeOperation_h
24 #define _COM_DilateErodeOperation_h
25 #include "COM_NodeOperation.h"
26
27
28 class DilateErodeDistanceOperation : public NodeOperation {
29 private:
30         /**
31           * Cached reference to the inputProgram
32           */
33         SocketReader * inputProgram;
34         
35         float distance;
36         float _switch;
37         float inset;
38         
39         /**
40           * determines the area of interest to track pixels
41           * keep this one as small as possible for speed gain.
42           */
43         int scope;
44 public:
45         DilateErodeDistanceOperation();
46         
47         /**
48           * the inner loop of this program
49           */
50         void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
51         
52         /**
53           * Initialize the execution
54           */
55         void initExecution();
56         
57         void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
58         /**
59           * Deinitialize the execution
60           */
61         void deinitExecution();
62         
63         void setDistance(float distance) {this->distance = distance;}
64         void setSwitch(float sw) {this->_switch = sw;}
65         void setInset(float inset) {this->inset = inset;}
66         
67         bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
68
69 };
70
71 class DilateStepOperation : public NodeOperation {
72 protected:
73         /**
74           * Cached reference to the inputProgram
75           */
76         SocketReader * inputProgram;
77         
78         int iterations;
79         
80         float *cached_buffer;
81 public:
82         DilateStepOperation();
83         
84         /**
85           * the inner loop of this program
86           */
87         void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
88         
89         /**
90           * Initialize the execution
91           */
92         void initExecution();
93         
94         void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
95         /**
96           * Deinitialize the execution
97           */
98         void deinitExecution();
99         
100         void setIterations(int iterations) {this->iterations = iterations;}
101         
102         bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
103 };
104
105 class ErodeStepOperation : public DilateStepOperation {
106 public:
107         ErodeStepOperation();
108         
109         void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
110 };
111
112 #endif