speedup to inpaint node in my tests was about ~30% for an optimized build.
[blender.git] / source / blender / compositor / operations / COM_InpaintOperation.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: Peter Schlaile
19  *              Jeroen Bakker 
20  *              Monique Dewanchand
21  */
22
23 #ifndef _COM_InpaintOperation_h
24 #define _COM_InpaintOperation_h
25 #include "COM_NodeOperation.h"
26
27 class InpaintSimpleOperation : public NodeOperation {
28 protected:
29         /**
30          * Cached reference to the inputProgram
31          */
32         SocketReader *m_inputImageProgram;
33         
34         int m_iterations;
35         
36         float *m_cached_buffer;
37         bool m_cached_buffer_ready;
38
39         int *m_pixelorder;
40         int m_area_size;
41         short *m_manhatten_distance;
42 public:
43         InpaintSimpleOperation();
44         
45         /**
46          * the inner loop of this program
47          */
48         void executePixel(float *color, int x, int y, void *data);
49         
50         /**
51          * Initialize the execution
52          */
53         void initExecution();
54         
55         void *initializeTileData(rcti *rect);
56         /**
57          * Deinitialize the execution
58          */
59         void deinitExecution();
60         
61         void setIterations(int iterations) { this->m_iterations = iterations; }
62         
63         bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
64
65 private:
66         void calc_manhatten_distance();
67         void clamp_xy(int &x, int &y);
68         float *get_pixel(int x, int y);
69         int mdist(int x, int y);
70         bool next_pixel(int &x, int &y, int &curr, int iters);
71         void pix_step(int x, int y);
72 };
73
74
75 #endif