remove auto kfrm for gang, btn2 select kfrm pos
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / vdevicex11.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 VDEVICEX11_H
23 #define VDEVICEX11_H
24
25 #include "canvas.inc"
26 #include "edl.inc"
27 #include "guicast.h"
28 #include "maskauto.inc"
29 #include "maskautos.inc"
30 #include "pluginclient.inc"
31 #include "thread.h"
32 #include "vdevicebase.h"
33
34 // output_frame is the same one written to device
35 #define BITMAP_PRIMARY 0
36 // output_frame is a temporary converted to the device format
37 #define BITMAP_TEMP    1
38
39 class VDeviceX11 : public VDeviceBase
40 {
41 public:
42         VDeviceX11(VideoDevice *device, Canvas *output);
43         ~VDeviceX11();
44
45         int open_input();
46         int close_all();
47         int read_buffer(VFrame *frame);
48         int reset_parameters();
49 // User always gets the colormodel requested
50         void new_output_buffer(VFrame **output, int colormodel, EDL *edl);
51
52         int open_output();
53         int start_playback();
54         int stop_playback();
55         int output_visible();
56 // After loading the bitmap with a picture, write it
57         int write_buffer(VFrame *result, EDL *edl);
58 // Get best colormodel for recording
59         int get_best_colormodel(Asset *asset);
60
61
62 //=========================== compositing stages ===============================
63 // For compositing with OpenGL, must clear the frame buffer
64 // before overlaying tracks.
65         void clear_output();
66
67 // Called by VModule::import_frame
68         void do_camera(VFrame *output,
69                 VFrame *input,
70                 float in_x1,
71                 float in_y1,
72                 float in_x2,
73                 float in_y2,
74                 float out_x1,
75                 float out_y1,
76                 float out_x2,
77                 float out_y2);
78
79 // Called by VModule::import_frame for cases with no media.
80         void clear_input(VFrame *frame);
81
82         void do_fade(VFrame *output_temp, float fade);
83
84 // Hardware version of MaskEngine
85         bool can_mask(int64_t start_position_project, MaskAutos *keyframe_set);
86         void do_mask(VFrame *output,
87                 int64_t start_position_project, MaskAutos *keyframe_set,
88                 MaskAuto *keyframe, MaskAuto *default_auto);
89         void convert_cmodel(VFrame *output, int dst_cmodel);
90
91 // The idea is to composite directly in the frame buffer if OpenGL.
92 // OpenGL can do all the blending using the frame buffer.
93 // Unfortunately if the output is lower resolution than the frame buffer, the
94 // rendered output is the resolution of the frame buffer, not the output.
95 // Also, the frame buffer has to be copied back to textures for nonstandard
96 // blending equations and blended at the framebuffer resolution.
97 // If the frame buffer is higher resolution than the
98 // output frame, like a 2560x1600 display, it could cause unnecessary slowness.
99 // Finally, there's the problem of updating the refresh frame.
100 // It requires recompositing the previous frame in software every time playback was
101 // stops, a complicated operation.
102         void overlay(VFrame *output_frame,
103                 VFrame *input,
104                 float in_x1,
105                 float in_y1,
106                 float in_x2,
107                 float in_y2,
108                 float out_x1,
109                 float out_y1,
110                 float out_x2,
111                 float out_y2,
112                 float alpha,        // 0 - 1
113                 int mode,
114                 EDL *edl,
115                 int is_nested);
116
117 // For plugins, lock the canvas, enable opengl, and run a function in the
118 // plugin client in the synchronous thread.  The user must override the
119 // pluginclient function.
120         void run_plugin(PluginClient *client);
121
122 // For multichannel plugins, copy from the temporary pbuffer to
123 // the plugin output texture.
124 // Set the output OpenGL state to TEXTURE.
125         void copy_frame(VFrame *dst, VFrame *src);
126
127 private:
128 // Closest colormodel the hardware can do for playback.
129 // Only used by VDeviceX11::new_output_buffer.  The value from File::get_best_colormodel
130 // is passed to this to create the VFrame to which the output is rendered.
131 // For OpenGL, it creates the array of row pointers used to upload the video
132 // frame to the texture, the texture, and the PBuffer.
133         int get_display_colormodel(int file_colormodel);
134
135 // windows which overlay the screencap area
136 #define SCREENCAP_BORDERS 4
137 #define SCREENCAP_PIXELS 5
138 #define SCREENCAP_COLOR GREEN
139         BC_Popup *screencap_border[SCREENCAP_BORDERS];
140
141 // Bitmap to be written to device
142         BC_Bitmap *bitmap;
143 // Wrapper for bitmap or intermediate buffer for user to write to
144         VFrame *output_frame;
145 // Type of output_frame
146         int bitmap_type;
147 // dimensions of buffers written to window
148         int bitmap_w, bitmap_h;
149         ArrayList<int> render_strategies;
150 // Canvas for output
151         Canvas *output;
152 // Parameters the output texture conforms to, for OpenGL
153 // window_id is probably not going to be used
154         int window_id;
155         int texture_w;
156         int texture_h;
157         int color_model;
158         int color_model_selected;
159 // Transfer coordinates from the output frame to the canvas.
160 // Calculated in new_output_buffer & retained for write_buffer
161 // These stick the last frame to the display.
162 // Must be floats to support OpenGL
163         float output_x1, output_y1, output_x2, output_y2;
164         float canvas_x1, canvas_y1, canvas_x2, canvas_y2;
165 // rounded integer dimensions
166         int canvas_w, canvas_h;
167 // Screen capture
168         BC_Capture *capture_bitmap;
169 // Set when OpenGL rendering has cleared the frame buffer before write_buffer
170         int is_cleared;
171 };
172
173 #endif