svn merge ^/trunk/blender -r49520:49531
[blender.git] / source / blender / compositor / operations / COM_VariableSizeBokehBlurOperation.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_BokehVariableSizeBokehBlurOperation_h
24 #define _COM_VariableSizeBokehBlurOperation_h
25 #include "COM_NodeOperation.h"
26 #include "COM_QualityStepHelper.h"
27
28 //#define COM_DEFOCUS_SEARCH
29
30 class VariableSizeBokehBlurOperation : public NodeOperation, public QualityStepHelper {
31 private:
32         int m_maxBlur;
33         float m_threshold;
34         SocketReader *m_inputProgram;
35         SocketReader *m_inputBokehProgram;
36         SocketReader *m_inputSizeProgram;
37 #ifdef COM_DEFOCUS_SEARCH
38         SocketReader *m_inputSearchProgram;
39 #endif
40
41 public:
42         VariableSizeBokehBlurOperation();
43
44         /**
45          * the inner loop of this program
46          */
47         void executePixel(float *color, int x, int y, void *data);
48         
49         /**
50          * Initialize the execution
51          */
52         void initExecution();
53         
54         void *initializeTileData(rcti *rect);
55         
56         void deinitializeTileData(rcti *rect, void *data);
57         
58         /**
59          * Deinitialize the execution
60          */
61         void deinitExecution();
62         
63         bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
64         
65         void setMaxBlur(int maxRadius) { this->m_maxBlur = maxRadius; }
66
67         void setThreshold(float threshold) { this->m_threshold = threshold; }
68
69         void executeOpenCL(OpenCLDevice *device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp);
70 };
71
72 #ifdef COM_DEFOCUS_SEARCH
73 class InverseSearchRadiusOperation : public NodeOperation {
74 private:
75         int m_maxBlur;
76         SocketReader *m_inputRadius;
77 public:
78         static const int DIVIDER = 4;
79         
80         InverseSearchRadiusOperation();
81
82         /**
83          * the inner loop of this program
84          */
85         void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
86         
87         /**
88          * Initialize the execution
89          */
90         void initExecution();
91         void *initializeTileData(rcti *rect);
92         void deinitializeTileData(rcti *rect, void *data);
93         
94         /**
95          * Deinitialize the execution
96          */
97         void deinitExecution();
98         
99         bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
100         void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
101         
102         void setMaxBlur(int maxRadius) { this->m_maxBlur = maxRadius; }
103 };
104 #endif
105 #endif