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
22 #include "bcsignals.h"
26 #include "edlsession.h"
28 #include "playabletracks.h"
29 #include "preferences.h"
30 #include "renderengine.h"
32 #include "transportque.h"
33 #include "vdevicex11.h"
35 #include "videodevice.h"
36 #include "virtualvconsole.h"
37 #include "virtualvnode.h"
42 VirtualVConsole::VirtualVConsole(RenderEngine *renderengine, VRender *vrender)
43 : VirtualConsole(renderengine, vrender, TRACK_VIDEO)
45 this->vrender = vrender;
49 VirtualVConsole::~VirtualVConsole()
57 VDeviceBase* VirtualVConsole::get_vdriver()
59 return renderengine->video->get_output_base();
62 void VirtualVConsole::get_playable_tracks()
65 playable_tracks = new PlayableTracks(renderengine->get_edl(),
66 commonrender->current_position,
67 renderengine->command->get_direction(),
70 //printf("VirtualVConsole::get_playable_tracks %d %d\n", __LINE__, playable_tracks->size());
73 VirtualNode* VirtualVConsole::new_entry_node(Track *track,
77 return new VirtualVNode(renderengine,
85 // start of buffer in project if forward / end of buffer if reverse
86 int VirtualVConsole::process_buffer(int64_t input_position,
93 // The use of single frame is determined in RenderEngine::arm_command
94 // printf("VirtualVConsole::process_buffer %d this=%p %d\n",
100 printf("VirtualVConsole::process_buffer %d exit_nodes=%d\n",
107 // clear hardware framebuffer
109 ((VDeviceX11*)get_vdriver())->clear_output();
111 // que OpenGL driver that everything is overlaid in the framebuffer
112 vrender->video_out->set_opengl_state(VFrame::SCREEN);
117 // clear device buffer
118 //printf("VirtualVConsole::process_buffer %d %p\n", __LINE__, vrender->video_out);
119 //vrender->video_out->dump();
120 vrender->video_out->clear_frame();
121 //printf("VirtualVConsole::process_buffer %d\n", __LINE__);
129 // Reset plugin rendering status
133 // Render exit nodes from bottom to top
134 for(current_exit_node = exit_nodes.total - 1; current_exit_node >= 0; current_exit_node--)
136 VirtualVNode *node = (VirtualVNode*)exit_nodes.values[current_exit_node];
137 Track *track = node->track;
139 // Create temporary output to match the track size, which is acceptable since
140 // most projects don't have variable track sizes.
141 // If the project has variable track sizes, this object is recreated for each track.
148 (output_temp->get_w() != track->track_w ||
149 output_temp->get_h() != track->track_h))
158 // Texture is created on demand
159 output_temp = new VFrame( track->track_w, track->track_h,
160 renderengine->get_edl()->session->color_model);
163 // Reset OpenGL state
165 output_temp->set_opengl_state(VFrame::RAM);
168 // Assume openGL is used for the final stage and let console
170 output_temp->clear_stacks();
171 result |= node->render(output_temp,
172 input_position + track->nudge,
173 renderengine->get_edl()->session->frame_rate,
177 //printf("VirtualVConsole::process_buffer timer=%jd\n", timer.get_difference());
179 if(debug_tree) printf("VirtualVConsole::process_buffer %d\n", __LINE__);