4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
28 #include "maskauto.inc"
29 #include "maskautos.inc"
30 #include "pluginclient.inc"
32 #include "vdevicebase.h"
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
39 class VDeviceX11 : public VDeviceBase
42 VDeviceX11(VideoDevice *device, Canvas *output);
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);
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);
62 //=========================== compositing stages ===============================
63 // For compositing with OpenGL, must clear the frame buffer
64 // before overlaying tracks.
67 // Called by VModule::import_frame
68 void do_camera(VFrame *output,
79 // Called by VModule::import_frame for cases with no media.
80 void clear_input(VFrame *frame);
82 void do_fade(VFrame *output_temp, float fade);
84 // Hardware version of MaskEngine
85 void do_mask(VFrame *output_temp,
86 int64_t start_position_project,
87 MaskAutos *keyframe_set,
89 MaskAuto *default_auto);
90 void convert_cmodel(VFrame *output, int dst_cmodel);
92 // The idea is to composite directly in the frame buffer if OpenGL.
93 // OpenGL can do all the blending using the frame buffer.
94 // Unfortunately if the output is lower resolution than the frame buffer, the
95 // rendered output is the resolution of the frame buffer, not the output.
96 // Also, the frame buffer has to be copied back to textures for nonstandard
97 // blending equations and blended at the framebuffer resolution.
98 // If the frame buffer is higher resolution than the
99 // output frame, like a 2560x1600 display, it could cause unnecessary slowness.
100 // Finally, there's the problem of updating the refresh frame.
101 // It requires recompositing the previous frame in software every time playback was
102 // stops, a complicated operation.
103 void overlay(VFrame *output_frame,
113 float alpha, // 0 - 1
118 // For plugins, lock the canvas, enable opengl, and run a function in the
119 // plugin client in the synchronous thread. The user must override the
120 // pluginclient function.
121 void run_plugin(PluginClient *client);
123 // For multichannel plugins, copy from the temporary pbuffer to
124 // the plugin output texture.
125 // Set the output OpenGL state to TEXTURE.
126 void copy_frame(VFrame *dst, VFrame *src);
129 // Closest colormodel the hardware can do for playback.
130 // Only used by VDeviceX11::new_output_buffer. The value from File::get_best_colormodel
131 // is passed to this to create the VFrame to which the output is rendered.
132 // For OpenGL, it creates the array of row pointers used to upload the video
133 // frame to the texture, the texture, and the PBuffer.
134 int get_best_colormodel(int colormodel);
136 // Bitmap to be written to device
138 // Wrapper for bitmap or intermediate buffer for user to write to
139 VFrame *output_frame;
140 // Type of output_frame
142 // dimensions of buffers written to window
143 int bitmap_w, bitmap_h;
144 ArrayList<int> render_strategies;
147 // Parameters the output texture conforms to, for OpenGL
148 // window_id is probably not going to be used
153 int color_model_selected;
154 // Transfer coordinates from the output frame to the canvas
155 // for last frame rendered.
156 // These stick the last frame to the display.
157 // Must be floats to support OpenGL
158 float output_x1, output_y1, output_x2, output_y2;
159 float canvas_x1, canvas_y1, canvas_x2, canvas_y2;
161 BC_Capture *capture_bitmap;
162 // Set when OpenGL rendering has cleared the frame buffer before write_buffer