compositor: bokeh blur size input can now be an image, in this case it uses VariableS...
[blender-staging.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         bool m_do_size_scale;  /* scale size, matching 'BokehBlurNode' */
35         SocketReader *m_inputProgram;
36         SocketReader *m_inputBokehProgram;
37         SocketReader *m_inputSizeProgram;
38 #ifdef COM_DEFOCUS_SEARCH
39         SocketReader *m_inputSearchProgram;
40 #endif
41
42 public:
43         VariableSizeBokehBlurOperation();
44
45         /**
46          * the inner loop of this program
47          */
48         void executePixel(float output[4], int x, int y, void *data);
49         
50         /**
51          * Initialize the execution
52          */
53         void initExecution();
54         
55         void *initializeTileData(rcti *rect);
56         
57         void deinitializeTileData(rcti *rect, void *data);
58         
59         /**
60          * Deinitialize the execution
61          */
62         void deinitExecution();
63         
64         bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
65         
66         void setMaxBlur(int maxRadius) { this->m_maxBlur = maxRadius; }
67
68         void setThreshold(float threshold) { this->m_threshold = threshold; }
69
70         void setDoScaleSize(bool scale_size) { this->m_do_size_scale = scale_size; }
71
72         void executeOpenCL(OpenCLDevice *device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp);
73 };
74
75 #ifdef COM_DEFOCUS_SEARCH
76 class InverseSearchRadiusOperation : public NodeOperation {
77 private:
78         int m_maxBlur;
79         SocketReader *m_inputRadius;
80 public:
81         static const int DIVIDER = 4;
82         
83         InverseSearchRadiusOperation();
84
85         /**
86          * the inner loop of this program
87          */
88         void executePixel(float output[4], int x, int y, MemoryBuffer *inputBuffers[], void *data);
89         
90         /**
91          * Initialize the execution
92          */
93         void initExecution();
94         void *initializeTileData(rcti *rect);
95         void deinitializeTileData(rcti *rect, void *data);
96         
97         /**
98          * Deinitialize the execution
99          */
100         void deinitExecution();
101         
102         bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
103         void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
104         
105         void setMaxBlur(int maxRadius) { this->m_maxBlur = maxRadius; }
106 };
107 #endif
108 #endif