prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.1 / cinelerra / maskengine.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #ifndef MASKENGINE_H
23 #define MASKENGINE_H
24
25
26 #include "condition.inc"
27 #include "loadbalance.h"
28 #include "maskautos.inc"
29 #include "maskauto.inc"
30 #include "mutex.inc"
31 #include "vframe.inc"
32
33
34 class MaskEngine;
35
36 // Values for step
37 enum
38 {
39         DO_MASK,
40         DO_X_FEATHER,
41         DO_Y_FEATHER,
42         DO_APPLY
43 };
44
45 class MaskPackage : public LoadPackage
46 {
47 public:
48         MaskPackage();
49         ~MaskPackage();
50
51         int start_x, end_x, start_y, end_y;
52 };
53
54 class MaskUnit : public LoadClient
55 {
56 public:
57         MaskUnit(MaskEngine *engine);
58         ~MaskUnit();
59
60         void process_package(LoadPackage *package);
61         void draw_line_clamped(VFrame *frame, 
62                 int &x1, 
63                 int &y1, 
64                 int x2, 
65                 int y2, 
66                 unsigned char value);
67         void do_feather(VFrame *output,
68                 VFrame *input, 
69                 double feather, 
70                 int start_y, 
71                 int end_y, 
72                 int start_x, 
73                 int end_x);
74         void blur_strip(double *val_p, 
75                 double *val_m, 
76                 double *dst, 
77                 double *src, 
78                 int size,
79                 int max);
80
81     double n_p[5], n_m[5];
82     double d_p[5], d_m[5];
83     double bd_p[5], bd_m[5];
84         MaskEngine *engine;
85         VFrame *temp;
86 };
87
88
89 class MaskEngine : public LoadServer
90 {
91 public:
92         MaskEngine(int cpus);
93         ~MaskEngine();
94
95
96         void do_mask(VFrame *output, 
97 // Position relative to project, compensated for playback direction
98                 int64_t start_position_project,
99                 MaskAutos *keyframe_set, 
100                 MaskAuto *keyframe,
101                 MaskAuto *default_auto);
102         int points_equivalent(ArrayList<MaskPoint*> *new_points, 
103                 ArrayList<MaskPoint*> *points);
104
105         void delete_packages();
106         void init_packages();
107         LoadClient* new_client();
108         LoadPackage* new_package();
109
110         VFrame *output;
111 // State of last mask
112         VFrame *mask;
113 // Temporary for feathering
114         VFrame *temp_mask;
115         ArrayList<ArrayList<MaskPoint*>*> point_sets;
116         int mode;
117         int step;
118         double feather;
119         int recalculate;
120         int value;
121 };
122
123
124
125 #endif