First set of 50 GPL attribution for CV-Contributors added
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / maskauto.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * Copyright (C) 2003-2016 Cinelerra CV contributors
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22
23 #ifndef MASKAUTO_H
24 #define MASKAUTO_H
25
26
27 #include "arraylist.h"
28 #include "auto.h"
29 #include "maskauto.inc"
30 #include "maskautos.inc"
31
32 class MaskPoint
33 {
34 public:
35         MaskPoint();
36
37         int operator==(MaskPoint& ptr);
38         MaskPoint& operator=(MaskPoint& ptr);
39         void copy_from(MaskPoint &ptr);
40
41         float x, y;
42 // Incoming acceleration
43         float control_x1, control_y1;
44 // Outgoing acceleration
45         float control_x2, control_y2;
46 };
47
48 class MaskCoord { public: double x, y, z; };
49
50 class MaskEdge : public ArrayList<MaskCoord>
51 {
52 public:
53         MaskCoord &append(double x, double y, double z=0) {
54                 MaskCoord &c = ArrayList<MaskCoord>::append();
55                 c.x = x;  c.y = y;  c.z = z;
56                 return c;
57         }
58         void load(MaskPoints &points, float ofs);
59 };
60
61 class MaskEdges : public ArrayList<MaskEdge*> {
62 public:
63         MaskEdges() {}
64         ~MaskEdges() { remove_all_objects(); }
65 };
66
67 class MaskPoints : public ArrayList<MaskPoint *>
68 {
69 public:
70         void clear() { remove_all_objects(); }
71         MaskPoints() {}
72         ~MaskPoints() { clear(); }
73 };
74
75 class MaskPointSets : public ArrayList<MaskPoints*>
76 {
77 public:
78         void clear() { remove_all_objects(); }
79         MaskPointSets() {}
80         ~MaskPointSets() { clear(); }
81 };
82
83 #define FEATHER_MAX 100
84 // GL reg limit 1024 incls shader param list
85 #define MAX_FEATHER 1000
86
87 class SubMask
88 {
89 public:
90         SubMask(MaskAuto *keyframe, int no);
91         ~SubMask();
92
93         int operator==(SubMask& ptr);
94         int equivalent(SubMask& ptr);
95         void copy_from(SubMask& ptr, int do_name=1);
96         void load(FileXML *file);
97         void copy(FileXML *file);
98         void dump(FILE *fp);
99
100         char name[BCSTRLEN];
101         float fader;
102         float feather;
103         MaskPoints points;
104         MaskAuto *keyframe;
105 };
106
107 class MaskAuto : public Auto
108 {
109 public:
110         MaskAuto(EDL *edl, MaskAutos *autos);
111         ~MaskAuto();
112
113         int operator==(Auto &that);
114         int operator==(MaskAuto &that);
115         bool is_maskauto() { return true; }
116         int identical(MaskAuto *src);
117         void load(FileXML *file);
118         void copy(int64_t start, int64_t end, FileXML *file, int default_auto);
119         void copy_from(Auto *src);
120         int interpolate_from(Auto *a1, Auto *a2, int64_t position, Auto *templ=0);
121         void copy_from(MaskAuto *src);
122 // Copy data but not position
123         void copy_data(MaskAuto *src);
124         void get_points(MaskPoints *points,
125                 int submask);
126         void set_points(MaskPoints *points,
127                 int submask);
128
129 // Copy parameters to this which differ between ref & src
130         void update_parameter(MaskAuto *ref, MaskAuto *src);
131
132         void dump(FILE *fp);
133 // Retrieve submask with clamping
134         SubMask* get_submask(int number);
135 // Translates all submasks
136         void translate_submasks(float translate_x, float translate_y);
137 // scale all submasks
138         void scale_submasks(int orig_scale, int new_scale);
139         int has_active_mask();
140
141         ArrayList<SubMask*> masks;
142         int apply_before_plugins;
143         int disable_opengl_masking;
144 };
145
146 // shader buffer unsized array vec only seems to work for dvec (05/2019)
147 class MaskSpot { public: double x, y; };
148
149 class MaskSpots : public ArrayList<MaskSpot>
150 {
151 public:
152         MaskSpot &append() { return ArrayList<MaskSpot>::append(); }
153         MaskSpot &append(double x, double y) {
154                 MaskSpot &s = append();
155                 s.x = x;  s.y = y;
156                 return s;
157         }
158 };
159
160 #endif