2 #include "edlsession.h"
3 #include "formattools.h"
5 #include "performanceprefs.h"
6 #include "preferences.h"
10 #define _(String) gettext(String)
11 #define gettext_noop(String) String
12 #define N_(String) gettext_noop (String)
15 PerformancePrefs::PerformancePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
16 : PreferencesDialog(mwindow, pwindow)
21 PerformancePrefs::~PerformancePrefs()
24 nodes[0].remove_all_objects();
25 nodes[1].remove_all_objects();
26 nodes[2].remove_all_objects();
27 nodes[3].remove_all_objects();
30 int PerformancePrefs::create_objects()
37 char string[BCTEXTLEN];
42 // add_border(get_resources()->get_bg_shadow1(),
43 // get_resources()->get_bg_shadow2(),
44 // get_resources()->get_bg_color(),
45 // get_resources()->get_bg_light2(),
46 // get_resources()->get_bg_light1());
47 add_subwindow(new BC_Title(x, y, _("Performance"), LARGEFONT, BLACK));
50 add_subwindow(new BC_Title(x, y + 5, _("Cache items:"), MEDIUMFONT, BLACK));
51 sprintf(string, "%ld", pwindow->thread->preferences->cache_size);
52 add_subwindow(csize = new CICacheSize(x + 230, y, pwindow, string));
54 add_subwindow(new BC_Title(x, y + 5, _("Seconds to preroll renders:")));
55 PrefsRenderPreroll *preroll = new PrefsRenderPreroll(pwindow,
59 preroll->create_objects();
61 add_subwindow(new PrefsForceUniprocessor(pwindow, x, y));
66 add_subwindow(new BC_Title(x, y, _("Background Rendering"), LARGEFONT, BLACK));
69 add_subwindow(new PrefsUseBRender(pwindow,
74 add_subwindow(new BC_Title(x, y + 40, _("Frames per background rendering job:")));
75 PrefsBRenderFragment *brender_fragment = new PrefsBRenderFragment(pwindow,
79 brender_fragment->create_objects();
80 add_subwindow(new BC_Title(x, y + 95, _("Frames to preroll background:")));
81 PrefsBRenderPreroll *bpreroll = new PrefsBRenderPreroll(pwindow,
85 bpreroll->create_objects();
89 add_subwindow(new BC_Title(x, y, _("Output for background rendering:")));
92 new FormatTools(mwindow,
94 pwindow->thread->preferences->brender_asset);
95 brender_tools->create_objects(x,
97 0, // Include tools for audio
98 1, // Include tools for video
99 0, // Include checkbox for audio
100 0, // Include checkbox for video
103 0, // Select compressors to be offered
104 0, // Change captions for recording
105 0, // If nonzero, prompt for insertion strategy
106 1); // Supply file formats for background rendering
109 add_subwindow(new BC_Title(x, y, _("Render Farm"), LARGEFONT, BLACK));
112 add_subwindow(new PrefsRenderFarm(pwindow, x, y));
113 add_subwindow(new BC_Title(x + xmargin4, y, _("Nodes:")));
115 add_subwindow(new BC_Title(x, y, _("Hostname:")));
116 add_subwindow(new BC_Title(x + xmargin3, y, _("Port:")));
117 add_subwindow(node_list = new PrefsRenderFarmNodes(pwindow,
122 N_("Master node framerate: %0.3f")
124 #define MASTER_NODE_FRAMERATE_TEXT "Master node framerate: %0.3f"
125 sprintf(string, _(MASTER_NODE_FRAMERATE_TEXT),
126 pwindow->thread->preferences->local_rate);
127 add_subwindow(master_rate = new BC_Title(x + xmargin4, y + node_list->get_h(), string));
130 add_subwindow(edit_node = new PrefsRenderFarmEditNode(pwindow,
134 edit_port = new PrefsRenderFarmPort(pwindow,
138 edit_port->create_objects();
143 add_subwindow(new PrefsRenderFarmReplaceNode(pwindow,
147 add_subwindow(new PrefsRenderFarmNewNode(pwindow,
152 add_subwindow(new PrefsRenderFarmDelNode(pwindow,
156 add_subwindow(new PrefsRenderFarmSortNodes(pwindow,
161 add_subwindow(new PrefsRenderFarmReset(pwindow,
166 add_subwindow(new BC_Title(x,
168 _("Total jobs to create:")));
169 add_subwindow(new BC_Title(x,
171 _("(overridden if new file at each label is checked)")));
172 PrefsRenderFarmJobs *jobs = new PrefsRenderFarmJobs(pwindow,
176 jobs->create_objects();
178 add_subwindow(new PrefsRenderFarmVFS(pwindow,
182 // add_subwindow(new BC_Title(x,
184 // _("Filesystem prefix on remote nodes:")));
185 // add_subwindow(new PrefsRenderFarmMountpoint(pwindow,
194 void PerformancePrefs::generate_node_list()
196 int selected_row = node_list ? node_list->get_selection_number(0, 0) : -1;
197 nodes[0].remove_all_objects();
198 nodes[1].remove_all_objects();
199 nodes[2].remove_all_objects();
200 nodes[3].remove_all_objects();
202 i < pwindow->thread->preferences->renderfarm_nodes.total;
205 BC_ListBoxItem *item;
206 nodes[0].append(item = new BC_ListBoxItem(
207 (char*)(pwindow->thread->preferences->renderfarm_enabled.values[i] ? "X" : " ")));
208 if(i == selected_row) item->set_selected(1);
210 nodes[1].append(item = new BC_ListBoxItem(
211 pwindow->thread->preferences->renderfarm_nodes.values[i]));
212 if(i == selected_row) item->set_selected(1);
214 char string[BCTEXTLEN];
215 sprintf(string, "%d", pwindow->thread->preferences->renderfarm_ports.values[i]);
216 nodes[2].append(item = new BC_ListBoxItem(string));
217 if(i == selected_row) item->set_selected(1);
219 sprintf(string, "%0.3f", pwindow->thread->preferences->renderfarm_rate.values[i]);
220 nodes[3].append(item = new BC_ListBoxItem(string));
221 if(i == selected_row) item->set_selected(1);
225 static char *titles[] =
233 static int widths[] =
242 void PerformancePrefs::update_node_list()
244 node_list->update(nodes,
248 node_list->get_xposition(),
249 node_list->get_yposition(),
250 node_list->get_selection_number(0, 0));
255 PrefsUseBRender::PrefsUseBRender(PreferencesWindow *pwindow,
260 pwindow->thread->preferences->use_brender,
261 _("Use background rendering"))
263 this->pwindow = pwindow;
266 int PrefsUseBRender::handle_event()
268 pwindow->thread->redraw_overlays = 1;
269 pwindow->thread->redraw_times = 1;
270 pwindow->thread->preferences->use_brender = get_value();
279 PrefsBRenderFragment::PrefsBRenderFragment(PreferencesWindow *pwindow,
280 PerformancePrefs *subwindow,
283 : BC_TumbleTextBox(subwindow,
284 (int64_t)pwindow->thread->preferences->brender_fragment,
291 this->pwindow = pwindow;
293 int PrefsBRenderFragment::handle_event()
295 pwindow->thread->preferences->brender_fragment = atol(get_text());
308 PrefsSMP::PrefsSMP(int x, int y, PreferencesWindow *pwindow)
309 : BC_TextBox(x, y, 100, 1, pwindow->thread->edl->session->smp + 1)
311 this->pwindow = pwindow;
314 PrefsSMP::~PrefsSMP()
318 int PrefsSMP::handle_event()
320 pwindow->thread->edl->session->smp = atol(get_text()) - 1;
321 if(pwindow->thread->edl->session->smp < 0) pwindow->thread->edl->session->smp = 0;
326 CICacheSize::CICacheSize(int x, int y, PreferencesWindow *pwindow, char *text)
327 : BC_TextBox(x, y, 100, 1, text)
329 this->pwindow = pwindow;
332 int CICacheSize::handle_event()
336 result = atol(get_text());
337 pwindow->thread->preferences->cache_size = result;
342 PrefsRenderPreroll::PrefsRenderPreroll(PreferencesWindow *pwindow,
343 PerformancePrefs *subwindow,
346 : BC_TumbleTextBox(subwindow,
347 (float)pwindow->thread->preferences->render_preroll,
354 this->pwindow = pwindow;
356 PrefsRenderPreroll::~PrefsRenderPreroll()
359 int PrefsRenderPreroll::handle_event()
361 pwindow->thread->preferences->render_preroll = atof(get_text());
366 PrefsBRenderPreroll::PrefsBRenderPreroll(PreferencesWindow *pwindow,
367 PerformancePrefs *subwindow,
370 : BC_TumbleTextBox(subwindow,
371 (int64_t)pwindow->thread->preferences->brender_preroll,
378 this->pwindow = pwindow;
380 int PrefsBRenderPreroll::handle_event()
382 pwindow->thread->preferences->brender_preroll = atol(get_text());
396 PrefsRenderFarm::PrefsRenderFarm(PreferencesWindow *pwindow, int x, int y)
399 pwindow->thread->preferences->use_renderfarm,
400 _("Use render farm"))
402 this->pwindow = pwindow;
404 PrefsRenderFarm::~PrefsRenderFarm()
407 int PrefsRenderFarm::handle_event()
409 pwindow->thread->preferences->use_renderfarm = get_value();
416 PrefsForceUniprocessor::PrefsForceUniprocessor(PreferencesWindow *pwindow, int x, int y)
419 pwindow->thread->edl->session->force_uniprocessor,
420 _("Force single processor use"))
422 this->pwindow = pwindow;
424 PrefsForceUniprocessor::~PrefsForceUniprocessor()
427 int PrefsForceUniprocessor::handle_event()
429 pwindow->thread->edl->session->force_uniprocessor = get_value();
439 PrefsRenderFarmConsolidate::PrefsRenderFarmConsolidate(PreferencesWindow *pwindow, int x, int y)
442 pwindow->thread->preferences->renderfarm_consolidate,
443 _("Consolidate output files on completion"))
445 this->pwindow = pwindow;
447 PrefsRenderFarmConsolidate::~PrefsRenderFarmConsolidate()
450 int PrefsRenderFarmConsolidate::handle_event()
452 pwindow->thread->preferences->renderfarm_consolidate = get_value();
460 PrefsRenderFarmPort::PrefsRenderFarmPort(PreferencesWindow *pwindow,
461 PerformancePrefs *subwindow,
464 : BC_TumbleTextBox(subwindow,
465 (int64_t)pwindow->thread->preferences->renderfarm_port,
472 this->pwindow = pwindow;
475 PrefsRenderFarmPort::~PrefsRenderFarmPort()
479 int PrefsRenderFarmPort::handle_event()
481 pwindow->thread->preferences->renderfarm_port = atol(get_text());
487 PrefsRenderFarmNodes::PrefsRenderFarmNodes(PreferencesWindow *pwindow,
488 PerformancePrefs *subwindow, int x, int y)
493 LISTBOX_TEXT, // Display text list or icons
499 this->subwindow = subwindow;
500 this->pwindow = pwindow;
502 PrefsRenderFarmNodes::~PrefsRenderFarmNodes()
506 int PrefsRenderFarmNodes::column_resize_event()
508 for(int i = 0; i < 3; i++)
509 widths[i] = get_column_width(i);
513 int PrefsRenderFarmNodes::handle_event()
515 if(get_selection_number(0, 0) >= 0)
517 subwindow->hot_node = get_selection_number(1, 0);
518 subwindow->edit_node->update(get_selection(1, 0)->get_text());
519 subwindow->edit_port->update(get_selection(2, 0)->get_text());
520 if(get_cursor_x() < widths[0])
522 pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node] =
523 !pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node];
524 subwindow->generate_node_list();
525 subwindow->update_node_list();
530 subwindow->hot_node = -1;
531 subwindow->edit_node->update("");
535 int PrefsRenderFarmNodes::selection_changed()
547 PrefsRenderFarmEditNode::PrefsRenderFarmEditNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
548 : BC_TextBox(x, y, 240, 1, "")
550 this->pwindow = pwindow;
551 this->subwindow = subwindow;
554 PrefsRenderFarmEditNode::~PrefsRenderFarmEditNode()
558 int PrefsRenderFarmEditNode::handle_event()
568 PrefsRenderFarmNewNode::PrefsRenderFarmNewNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
569 : BC_GenericButton(x, y, _("Add Node"))
571 this->pwindow = pwindow;
572 this->subwindow = subwindow;
574 PrefsRenderFarmNewNode::~PrefsRenderFarmNewNode()
577 int PrefsRenderFarmNewNode::handle_event()
579 pwindow->thread->preferences->add_node(subwindow->edit_node->get_text(),
580 pwindow->thread->preferences->renderfarm_port,
583 pwindow->thread->preferences->reset_rates();
584 subwindow->generate_node_list();
585 subwindow->update_node_list();
586 subwindow->hot_node = -1;
596 PrefsRenderFarmReplaceNode::PrefsRenderFarmReplaceNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
597 : BC_GenericButton(x, y, _("Apply Changes"))
599 this->pwindow = pwindow;
600 this->subwindow = subwindow;
602 PrefsRenderFarmReplaceNode::~PrefsRenderFarmReplaceNode()
605 int PrefsRenderFarmReplaceNode::handle_event()
607 if(subwindow->hot_node >= 0)
609 pwindow->thread->preferences->edit_node(subwindow->hot_node,
610 subwindow->edit_node->get_text(),
611 pwindow->thread->preferences->renderfarm_port,
612 pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node]);
613 subwindow->generate_node_list();
614 subwindow->update_node_list();
623 PrefsRenderFarmDelNode::PrefsRenderFarmDelNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
624 : BC_GenericButton(x, y, _("Delete Node"))
626 this->pwindow = pwindow;
627 this->subwindow = subwindow;
629 PrefsRenderFarmDelNode::~PrefsRenderFarmDelNode()
632 int PrefsRenderFarmDelNode::handle_event()
634 if(strlen(subwindow->edit_node->get_text()))
636 pwindow->thread->preferences->delete_node(subwindow->hot_node);
637 subwindow->generate_node_list();
638 subwindow->update_node_list();
639 subwindow->hot_node = -1;
648 PrefsRenderFarmSortNodes::PrefsRenderFarmSortNodes(PreferencesWindow *pwindow,
649 PerformancePrefs *subwindow,
652 : BC_GenericButton(x, y, _("Sort nodes"))
654 this->pwindow = pwindow;
655 this->subwindow = subwindow;
658 PrefsRenderFarmSortNodes::~PrefsRenderFarmSortNodes()
662 int PrefsRenderFarmSortNodes::handle_event()
664 pwindow->thread->preferences->sort_nodes();
665 subwindow->generate_node_list();
666 subwindow->update_node_list();
667 subwindow->hot_node = -1;
675 PrefsRenderFarmReset::PrefsRenderFarmReset(PreferencesWindow *pwindow,
676 PerformancePrefs *subwindow,
679 : BC_GenericButton(x, y, _("Reset rates"))
681 this->pwindow = pwindow;
682 this->subwindow = subwindow;
685 int PrefsRenderFarmReset::handle_event()
687 pwindow->thread->preferences->reset_rates();
688 subwindow->generate_node_list();
689 subwindow->update_node_list();
691 char string[BCTEXTLEN];
693 MASTER_NODE_FRAMERATE_TEXT,
694 pwindow->thread->preferences->local_rate);
695 subwindow->master_rate->update(string);
696 subwindow->hot_node = -1;
706 PrefsRenderFarmJobs::PrefsRenderFarmJobs(PreferencesWindow *pwindow,
707 PerformancePrefs *subwindow,
710 : BC_TumbleTextBox(subwindow,
711 (int64_t)pwindow->thread->preferences->renderfarm_job_count,
718 this->pwindow = pwindow;
720 PrefsRenderFarmJobs::~PrefsRenderFarmJobs()
723 int PrefsRenderFarmJobs::handle_event()
725 pwindow->thread->preferences->renderfarm_job_count = atol(get_text());
731 PrefsRenderFarmMountpoint::PrefsRenderFarmMountpoint(PreferencesWindow *pwindow,
732 PerformancePrefs *subwindow,
739 pwindow->thread->preferences->renderfarm_mountpoint)
741 this->pwindow = pwindow;
742 this->subwindow = subwindow;
744 PrefsRenderFarmMountpoint::~PrefsRenderFarmMountpoint()
747 int PrefsRenderFarmMountpoint::handle_event()
749 strcpy(pwindow->thread->preferences->renderfarm_mountpoint, get_text());
756 PrefsRenderFarmVFS::PrefsRenderFarmVFS(PreferencesWindow *pwindow,
757 PerformancePrefs *subwindow,
760 : BC_CheckBox(x, y, pwindow->thread->preferences->renderfarm_vfs, _("Use virtual filesystem"))
762 this->pwindow = pwindow;
763 this->subwindow = subwindow;
766 int PrefsRenderFarmVFS::handle_event()
768 pwindow->thread->preferences->renderfarm_vfs = get_value();