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 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);
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,
112 float alpha, // 0 - 1
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);
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);
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_best_colormodel(int colormodel);
135 // Bitmap to be written to device
137 // Wrapper for bitmap or intermediate buffer for user to write to
138 VFrame *output_frame;
139 // Type of output_frame
141 // dimensions of buffers written to window
142 int bitmap_w, bitmap_h;
143 ArrayList<int> render_strategies;
146 // Parameters the output texture conforms to, for OpenGL
147 // window_id is probably not going to be used
152 int color_model_selected;
153 // Transfer coordinates from the output frame to the canvas
154 // for last frame rendered.
155 // These stick the last frame to the display.
156 // Must be floats to support OpenGL
157 float output_x1, output_y1, output_x2, output_y2;
158 float canvas_x1, canvas_y1, canvas_x2, canvas_y2;
160 BC_Capture *capture_bitmap;
161 // Set when OpenGL rendering has cleared the frame buffer before write_buffer