svn merge ^/trunk/blender -r49520:49531
[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 DilateErodeThresholdOperation : public NodeOperation {
29 private:
30         /**
31          * Cached reference to the inputProgram
32          */
33         SocketReader *m_inputProgram;
34         
35         float m_distance;
36         float m__switch;
37         float m_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 m_scope;
44 public:
45         DilateErodeThresholdOperation();
46         
47         /**
48          * the inner loop of this program
49          */
50         void executePixel(float *color, int x, int y, void *data);
51         
52         /**
53          * Initialize the execution
54          */
55         void initExecution();
56         
57         void *initializeTileData(rcti *rect);
58         /**
59          * Deinitialize the execution
60          */
61         void deinitExecution();
62         
63         void setDistance(float distance) { this->m_distance = distance; }
64         void setSwitch(float sw) { this->m__switch = sw; }
65         void setInset(float inset) { this->m_inset = inset; }
66         
67         bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
68
69 };
70
71 class DilateDistanceOperation : public NodeOperation {
72 private:
73 protected:
74         /**
75          * Cached reference to the inputProgram
76          */
77         SocketReader *m_inputProgram;
78         float m_distance;
79         int m_scope;
80 public:
81         DilateDistanceOperation();
82         
83         /**
84          * the inner loop of this program
85          */
86         void executePixel(float *color, int x, int y, void *data);
87         
88         /**
89          * Initialize the execution
90          */
91         void initExecution();
92         
93         void *initializeTileData(rcti *rect);
94         /**
95          * Deinitialize the execution
96          */
97         void deinitExecution();
98         
99         void setDistance(float distance) { this->m_distance = distance; }
100         bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
101         
102         void executeOpenCL(OpenCLDevice *device,
103                            MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, 
104                            MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
105                            list<cl_kernel> *clKernelsToCleanUp);
106 };
107 class ErodeDistanceOperation : public DilateDistanceOperation {
108 public:
109         ErodeDistanceOperation();
110         
111         /**
112          * the inner loop of this program
113          */
114         void executePixel(float *color, int x, int y, void *data);
115
116         void executeOpenCL(OpenCLDevice *device,
117                            MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, 
118                            MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, 
119                            list<cl_kernel> *clKernelsToCleanUp);
120 };
121
122 class DilateStepOperation : public NodeOperation {
123 protected:
124         /**
125          * Cached reference to the inputProgram
126          */
127         SocketReader *m_inputProgram;
128         
129         int m_iterations;
130         
131         float *m_cached_buffer;
132 public:
133         DilateStepOperation();
134         
135         /**
136          * the inner loop of this program
137          */
138         void executePixel(float *color, int x, int y, void *data);
139         
140         /**
141          * Initialize the execution
142          */
143         void initExecution();
144         
145         void *initializeTileData(rcti *rect);
146         /**
147          * Deinitialize the execution
148          */
149         void deinitExecution();
150         
151         void setIterations(int iterations) { this->m_iterations = iterations; }
152         
153         bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
154 };
155
156 class ErodeStepOperation : public DilateStepOperation {
157 public:
158         ErodeStepOperation();
159         
160         void *initializeTileData(rcti *rect);
161 };
162
163 #endif