r1009: Move the dependencies to newer package names
[cinelerra_cv/mob.git] / cinelerra / virtualvconsole.C
blob3addf192e32405999609ca0af552d759b5954e72
1 #include "bcsignals.h"
2 #include "bctimer.h"
3 #include "datatype.h"
4 #include "edl.h"
5 #include "edlsession.h"
6 #include "mwindow.h"
7 #include "playabletracks.h"
8 #include "preferences.h"
9 #include "renderengine.h"
10 #include "tracks.h"
11 #include "transportque.h"
12 #include "vdevicex11.h"
13 #include "vframe.h"
14 #include "videodevice.h"
15 #include "virtualvconsole.h"
16 #include "virtualvnode.h"
17 #include "vmodule.h"
18 #include "vrender.h"
19 #include "vtrack.h"
21 VirtualVConsole::VirtualVConsole(RenderEngine *renderengine, VRender *vrender)
22  : VirtualConsole(renderengine, vrender, TRACK_VIDEO)
24         this->vrender = vrender;
25         output_temp = 0;
28 VirtualVConsole::~VirtualVConsole()
30         if(output_temp)
31         {
32                 delete output_temp;
33         }
36 VDeviceBase* VirtualVConsole::get_vdriver()
38         return renderengine->video->get_output_base();
41 void VirtualVConsole::get_playable_tracks()
43         if(!playable_tracks)
44                 playable_tracks = new PlayableTracks(renderengine, 
45                         commonrender->current_position, 
46                         TRACK_VIDEO,
47                         1);
50 VirtualNode* VirtualVConsole::new_entry_node(Track *track, 
51         Module *module,
52         int track_number)
54         return new VirtualVNode(renderengine, 
55                 this, 
56                 module,
57                 0,
58                 track,
59                 0);
62 // start of buffer in project if forward / end of buffer if reverse
63 int VirtualVConsole::process_buffer(int64_t input_position)
65         int i, j, k;
66         int result = 0;
70 // The use of single frame is determined in RenderEngine::arm_command
71         use_opengl = (renderengine->video && 
72                 renderengine->video->out_config->driver == PLAYBACK_X11_GL);
73 // printf("VirtualVConsole::process_buffer %p %d %d\n", 
74 // renderengine->video, 
75 // renderengine->video->out_config->driver,
76 // use_opengl);
78         if(debug_tree) 
79                 printf("VirtualVConsole::process_buffer begin exit_nodes=%d\n", 
80                         exit_nodes.total);
83         if(use_opengl)
84         {
85 // clear hardware framebuffer
87                 ((VDeviceX11*)get_vdriver())->clear_output();
89 // que OpenGL driver that everything is overlaid in the framebuffer
90                 vrender->video_out->set_opengl_state(VFrame::SCREEN);
92         }
93         else
94         {
95 // clear device buffer
96                 vrender->video_out->clear_frame();
97         }
104 // Reset plugin rendering status
105         reset_attachments();
107 Timer timer;
108 // Render exit nodes from bottom to top
109         for(current_exit_node = exit_nodes.total - 1; current_exit_node >= 0; current_exit_node--)
110         {
111                 VirtualVNode *node = (VirtualVNode*)exit_nodes.values[current_exit_node];
112                 Track *track = node->track;
114 // Create temporary output to match the track size, which is acceptable since
115 // most projects don't have variable track sizes.
116 // If the project has variable track sizes, this object is recreated for each track.
122                 if(output_temp && 
123                         (output_temp->get_w() != track->track_w ||
124                         output_temp->get_h() != track->track_h))
125                 {
126                         delete output_temp;
127                         output_temp = 0;
128                 }
131                 if(!output_temp)
132                 {
133 // Texture is created on demand
134                         output_temp = new VFrame(0, 
135                                 track->track_w, 
136                                 track->track_h, 
137                                 renderengine->edl->session->color_model,
138                                 -1);
139                 }
141 // Reset OpenGL state
142                 if(use_opengl)
143                         output_temp->set_opengl_state(VFrame::RAM);
146 // Assume openGL is used for the final stage and let console
147 // disable.
148                 output_temp->clear_stacks();
149                 result |= node->render(output_temp,
150                         input_position + track->nudge,
151                         renderengine->edl->session->frame_rate,
152                         use_opengl);
154         }
155 //printf("VirtualVConsole::process_buffer timer=%lld\n", timer.get_difference());
157         if(debug_tree) printf("VirtualVConsole::process_buffer end\n");
158         return result;