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()
54 VDeviceBase* VirtualVConsole::get_vdriver()
56 return renderengine->video->get_output_base();
59 void VirtualVConsole::get_playable_tracks()
62 playable_tracks = new PlayableTracks(renderengine->get_edl(),
63 commonrender->current_position,
64 renderengine->command->get_direction(),
67 //printf("VirtualVConsole::get_playable_tracks %d %d\n", __LINE__, playable_tracks->size());
70 VirtualNode* VirtualVConsole::new_entry_node(Track *track,
74 return new VirtualVNode(renderengine,
82 // start of buffer in project if forward / end of buffer if reverse
83 int VirtualVConsole::process_buffer(int64_t input_position,
90 // The use of single frame is determined in RenderEngine::arm_command
91 // printf("VirtualVConsole::process_buffer %d this=%p %d\n",
97 printf("VirtualVConsole::process_buffer %d exit_nodes=%d\n",
102 EDLSession *session = renderengine->get_edl()->session;
103 int clr_color = session->cwindow_clear_color;
104 vrender->video_out->set_clear_color(clr_color, 0x00);
108 // clear hardware framebuffer
110 ((VDeviceX11*)get_vdriver())->clear_output();
112 // que OpenGL driver that everything is overlaid in the framebuffer
113 vrender->video_out->set_opengl_state(VFrame::SCREEN);
118 // clear device buffer
119 //printf("VirtualVConsole::process_buffer %d %p\n", __LINE__, vrender->video_out);
120 //vrender->video_out->dump();
121 vrender->video_out->clear_frame();
122 //printf("VirtualVConsole::process_buffer %d\n", __LINE__);
130 // Reset plugin rendering status
134 // Render exit nodes from bottom to top
135 for(current_exit_node = exit_nodes.total - 1; current_exit_node >= 0; current_exit_node--)
137 VirtualVNode *node = (VirtualVNode*)exit_nodes.values[current_exit_node];
138 Track *track = node->track;
140 // Create temporary output to match the track size, which is acceptable since
141 // most projects don't have variable track sizes.
142 // If the project has variable track sizes, this object is recreated for each track.
149 (output_temp->get_w() != track->track_w ||
150 output_temp->get_h() != track->track_h))
159 // Texture is created on demand
160 EDL *edl = renderengine->get_edl();
161 output_temp = new VFrame( track->track_w, track->track_h,
162 edl->session->color_model);
165 // Reset OpenGL state
167 output_temp->set_opengl_state(VFrame::RAM);
170 // Assume openGL is used for the final stage and let console
172 output_temp->clear_stacks();
173 result |= node->render(output_temp,
174 input_position + track->nudge,
175 renderengine->get_edl()->session->frame_rate,
179 //printf("VirtualVConsole::process_buffer timer=%jd\n", timer.get_difference());
181 if(debug_tree) printf("VirtualVConsole::process_buffer %d\n", __LINE__);