4 #include "edlsession.h"
5 #include "formattools.h"
8 #include "performanceprefs.h"
9 #include "preferences.h"
14 PerformancePrefs::PerformancePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
15 : PreferencesDialog(mwindow, pwindow)
20 PerformancePrefs::~PerformancePrefs()
23 nodes[0].remove_all_objects();
24 nodes[1].remove_all_objects();
25 nodes[2].remove_all_objects();
26 nodes[3].remove_all_objects();
29 int PerformancePrefs::create_objects()
36 char string[BCTEXTLEN];
37 BC_Resources *resources = BC_WindowBase::get_resources();
42 xmargin1 = x = mwindow->theme->preferencesoptions_x;
43 y = mwindow->theme->preferencesoptions_y;
45 // add_subwindow(new BC_Title(x,
49 // resources->text_default));
51 // y += get_text_height(LARGEFONT) + 5;
53 add_subwindow(new BC_Title(x, y + 5, _("Cache size (MB):"), MEDIUMFONT, resources->text_default));
54 cache_size = new CICacheSize(x + 230,
58 cache_size->create_objects();
61 add_subwindow(new BC_Title(x, y + 5, _("Seconds to preroll renders:")));
62 PrefsRenderPreroll *preroll = new PrefsRenderPreroll(pwindow,
66 preroll->create_objects();
68 add_subwindow(new PrefsForceUniprocessor(pwindow, x, y));
75 // Background rendering
76 add_subwindow(new BC_Bar(5, y, get_w() - 10));
80 add_subwindow(new BC_Title(x, y, _("Background Rendering (Video only)"), LARGEFONT, resources->text_default));
83 add_subwindow(new PrefsUseBRender(pwindow,
88 add_subwindow(new BC_Title(x, y + 40, _("Frames per background rendering job:")));
89 PrefsBRenderFragment *brender_fragment = new PrefsBRenderFragment(pwindow,
93 brender_fragment->create_objects();
94 add_subwindow(new BC_Title(x, y + 95, _("Frames to preroll background:")));
95 PrefsBRenderPreroll *bpreroll = new PrefsBRenderPreroll(pwindow,
99 bpreroll->create_objects();
103 add_subwindow(new BC_Title(x, y, _("Output for background rendering:")));
106 new FormatTools(mwindow,
108 pwindow->thread->preferences->brender_asset);
109 brender_tools->create_objects(x,
111 0, // Include tools for audio
112 1, // Include tools for video
113 0, // Include checkbox for audio
114 0, // Include checkbox for video
117 0, // Select compressors to be offered
118 0, // Prompt for recording options
119 0, // If nonzero, prompt for insertion strategy
120 1); // Supply file formats for background rendering
125 add_subwindow(new BC_Bar(5, y, get_w() - 10));
129 add_subwindow(new BC_Title(x, y, _("Render Farm"), LARGEFONT, resources->text_default));
132 add_subwindow(new PrefsRenderFarm(pwindow, x, y));
133 add_subwindow(new BC_Title(x + xmargin4, y, _("Nodes:")));
135 add_subwindow(new BC_Title(x, y, _("Hostname:")));
136 add_subwindow(new BC_Title(x + xmargin3, y, _("Port:")));
137 add_subwindow(node_list = new PrefsRenderFarmNodes(pwindow,
142 N_("Master node framerate: %0.3f")
144 #define MASTER_NODE_FRAMERATE_TEXT "Master node framerate: %0.3f"
145 sprintf(string, _(MASTER_NODE_FRAMERATE_TEXT),
146 pwindow->thread->preferences->local_rate);
147 add_subwindow(master_rate = new BC_Title(x + xmargin4, y + node_list->get_h(), string));
150 add_subwindow(edit_node = new PrefsRenderFarmEditNode(pwindow,
154 edit_port = new PrefsRenderFarmPort(pwindow,
158 edit_port->create_objects();
163 add_subwindow(new PrefsRenderFarmReplaceNode(pwindow,
167 add_subwindow(new PrefsRenderFarmNewNode(pwindow,
172 add_subwindow(new PrefsRenderFarmDelNode(pwindow,
176 add_subwindow(new PrefsRenderFarmSortNodes(pwindow,
181 add_subwindow(new PrefsRenderFarmReset(pwindow,
186 add_subwindow(new BC_Title(x,
188 _("Total jobs to create:")));
189 add_subwindow(new BC_Title(x,
191 _("(overridden if new file at each label is checked)")));
192 PrefsRenderFarmJobs *jobs = new PrefsRenderFarmJobs(pwindow,
196 jobs->create_objects();
198 // add_subwindow(new PrefsRenderFarmVFS(pwindow,
202 // add_subwindow(new BC_Title(x,
204 // _("Filesystem prefix on remote nodes:")));
205 // add_subwindow(new PrefsRenderFarmMountpoint(pwindow,
214 void PerformancePrefs::generate_node_list()
216 int selected_row = node_list ? node_list->get_selection_number(0, 0) : -1;
217 nodes[0].remove_all_objects();
218 nodes[1].remove_all_objects();
219 nodes[2].remove_all_objects();
220 nodes[3].remove_all_objects();
222 i < pwindow->thread->preferences->renderfarm_nodes.total;
225 BC_ListBoxItem *item;
226 nodes[0].append(item = new BC_ListBoxItem(
227 (char*)(pwindow->thread->preferences->renderfarm_enabled.values[i] ? "X" : " ")));
228 if(i == selected_row) item->set_selected(1);
230 nodes[1].append(item = new BC_ListBoxItem(
231 pwindow->thread->preferences->renderfarm_nodes.values[i]));
232 if(i == selected_row) item->set_selected(1);
234 char string[BCTEXTLEN];
235 sprintf(string, "%d", pwindow->thread->preferences->renderfarm_ports.values[i]);
236 nodes[2].append(item = new BC_ListBoxItem(string));
237 if(i == selected_row) item->set_selected(1);
239 sprintf(string, "%0.3f", pwindow->thread->preferences->renderfarm_rate.values[i]);
240 nodes[3].append(item = new BC_ListBoxItem(string));
241 if(i == selected_row) item->set_selected(1);
245 static char *titles[] =
253 static int widths[] =
262 void PerformancePrefs::update_node_list()
264 node_list->update(nodes,
268 node_list->get_xposition(),
269 node_list->get_yposition(),
270 node_list->get_selection_number(0, 0));
275 PrefsUseBRender::PrefsUseBRender(PreferencesWindow *pwindow,
280 pwindow->thread->preferences->use_brender,
281 _("Use background rendering"))
283 this->pwindow = pwindow;
286 int PrefsUseBRender::handle_event()
288 pwindow->thread->redraw_overlays = 1;
289 pwindow->thread->redraw_times = 1;
290 pwindow->thread->preferences->use_brender = get_value();
299 PrefsBRenderFragment::PrefsBRenderFragment(PreferencesWindow *pwindow,
300 PerformancePrefs *subwindow,
303 : BC_TumbleTextBox(subwindow,
304 (int64_t)pwindow->thread->preferences->brender_fragment,
311 this->pwindow = pwindow;
313 int PrefsBRenderFragment::handle_event()
315 pwindow->thread->preferences->brender_fragment = atol(get_text());
329 CICacheSize::CICacheSize(int x,
331 PreferencesWindow *pwindow,
332 PerformancePrefs *subwindow)
333 : BC_TumbleTextBox(subwindow,
334 (int64_t)pwindow->thread->preferences->cache_size / 0x100000,
335 (int64_t)MIN_CACHE_SIZE / 0x100000,
336 (int64_t)MAX_CACHE_SIZE / 0x100000,
341 this->pwindow = pwindow;
345 int CICacheSize::handle_event()
348 result = (int64_t)atol(get_text()) * 0x100000;
349 CLAMP(result, MIN_CACHE_SIZE, MAX_CACHE_SIZE);
350 pwindow->thread->preferences->cache_size = result;
355 PrefsRenderPreroll::PrefsRenderPreroll(PreferencesWindow *pwindow,
356 PerformancePrefs *subwindow,
359 : BC_TumbleTextBox(subwindow,
360 (float)pwindow->thread->preferences->render_preroll,
367 this->pwindow = pwindow;
370 PrefsRenderPreroll::~PrefsRenderPreroll()
373 int PrefsRenderPreroll::handle_event()
375 pwindow->thread->preferences->render_preroll = atof(get_text());
380 PrefsBRenderPreroll::PrefsBRenderPreroll(PreferencesWindow *pwindow,
381 PerformancePrefs *subwindow,
384 : BC_TumbleTextBox(subwindow,
385 (int64_t)pwindow->thread->preferences->brender_preroll,
392 this->pwindow = pwindow;
394 int PrefsBRenderPreroll::handle_event()
396 pwindow->thread->preferences->brender_preroll = atol(get_text());
410 PrefsRenderFarm::PrefsRenderFarm(PreferencesWindow *pwindow, int x, int y)
413 pwindow->thread->preferences->use_renderfarm,
414 _("Use render farm"))
416 this->pwindow = pwindow;
418 PrefsRenderFarm::~PrefsRenderFarm()
421 int PrefsRenderFarm::handle_event()
423 pwindow->thread->preferences->use_renderfarm = get_value();
430 PrefsForceUniprocessor::PrefsForceUniprocessor(PreferencesWindow *pwindow, int x, int y)
433 pwindow->thread->preferences->force_uniprocessor,
434 _("Force single processor use"))
436 this->pwindow = pwindow;
438 PrefsForceUniprocessor::~PrefsForceUniprocessor()
441 int PrefsForceUniprocessor::handle_event()
443 pwindow->thread->preferences->force_uniprocessor = get_value();
453 PrefsRenderFarmConsolidate::PrefsRenderFarmConsolidate(PreferencesWindow *pwindow, int x, int y)
456 pwindow->thread->preferences->renderfarm_consolidate,
457 _("Consolidate output files on completion"))
459 this->pwindow = pwindow;
461 PrefsRenderFarmConsolidate::~PrefsRenderFarmConsolidate()
464 int PrefsRenderFarmConsolidate::handle_event()
466 pwindow->thread->preferences->renderfarm_consolidate = get_value();
474 PrefsRenderFarmPort::PrefsRenderFarmPort(PreferencesWindow *pwindow,
475 PerformancePrefs *subwindow,
478 : BC_TumbleTextBox(subwindow,
479 (int64_t)pwindow->thread->preferences->renderfarm_port,
486 this->pwindow = pwindow;
489 PrefsRenderFarmPort::~PrefsRenderFarmPort()
493 int PrefsRenderFarmPort::handle_event()
495 pwindow->thread->preferences->renderfarm_port = atol(get_text());
501 PrefsRenderFarmNodes::PrefsRenderFarmNodes(PreferencesWindow *pwindow,
502 PerformancePrefs *subwindow, int x, int y)
507 LISTBOX_TEXT, // Display text list or icons
513 this->subwindow = subwindow;
514 this->pwindow = pwindow;
516 PrefsRenderFarmNodes::~PrefsRenderFarmNodes()
520 int PrefsRenderFarmNodes::column_resize_event()
522 for(int i = 0; i < 3; i++)
523 widths[i] = get_column_width(i);
527 int PrefsRenderFarmNodes::handle_event()
530 if(get_selection_number(0, 0) >= 0)
532 subwindow->hot_node = get_selection_number(1, 0);
533 subwindow->edit_node->update(get_selection(1, 0)->get_text());
534 subwindow->edit_port->update(get_selection(2, 0)->get_text());
535 if(get_cursor_x() < widths[0])
537 pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node] =
538 !pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node];
539 subwindow->generate_node_list();
540 subwindow->update_node_list();
545 subwindow->hot_node = -1;
546 subwindow->edit_node->update("");
551 int PrefsRenderFarmNodes::selection_changed()
563 PrefsRenderFarmEditNode::PrefsRenderFarmEditNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
564 : BC_TextBox(x, y, 240, 1, "")
566 this->pwindow = pwindow;
567 this->subwindow = subwindow;
570 PrefsRenderFarmEditNode::~PrefsRenderFarmEditNode()
574 int PrefsRenderFarmEditNode::handle_event()
584 PrefsRenderFarmNewNode::PrefsRenderFarmNewNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
585 : BC_GenericButton(x, y, _("Add Node"))
587 this->pwindow = pwindow;
588 this->subwindow = subwindow;
590 PrefsRenderFarmNewNode::~PrefsRenderFarmNewNode()
593 int PrefsRenderFarmNewNode::handle_event()
595 pwindow->thread->preferences->add_node(subwindow->edit_node->get_text(),
596 pwindow->thread->preferences->renderfarm_port,
599 pwindow->thread->preferences->reset_rates();
600 subwindow->generate_node_list();
601 subwindow->update_node_list();
602 subwindow->hot_node = -1;
612 PrefsRenderFarmReplaceNode::PrefsRenderFarmReplaceNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
613 : BC_GenericButton(x, y, _("Apply Changes"))
615 this->pwindow = pwindow;
616 this->subwindow = subwindow;
618 PrefsRenderFarmReplaceNode::~PrefsRenderFarmReplaceNode()
621 int PrefsRenderFarmReplaceNode::handle_event()
623 if(subwindow->hot_node >= 0)
625 pwindow->thread->preferences->edit_node(subwindow->hot_node,
626 subwindow->edit_node->get_text(),
627 pwindow->thread->preferences->renderfarm_port,
628 pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node]);
629 subwindow->generate_node_list();
630 subwindow->update_node_list();
639 PrefsRenderFarmDelNode::PrefsRenderFarmDelNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
640 : BC_GenericButton(x, y, _("Delete Node"))
642 this->pwindow = pwindow;
643 this->subwindow = subwindow;
645 PrefsRenderFarmDelNode::~PrefsRenderFarmDelNode()
648 int PrefsRenderFarmDelNode::handle_event()
650 if(strlen(subwindow->edit_node->get_text()))
652 pwindow->thread->preferences->delete_node(subwindow->hot_node);
653 subwindow->generate_node_list();
654 subwindow->update_node_list();
655 subwindow->hot_node = -1;
664 PrefsRenderFarmSortNodes::PrefsRenderFarmSortNodes(PreferencesWindow *pwindow,
665 PerformancePrefs *subwindow,
668 : BC_GenericButton(x, y, _("Sort nodes"))
670 this->pwindow = pwindow;
671 this->subwindow = subwindow;
674 PrefsRenderFarmSortNodes::~PrefsRenderFarmSortNodes()
678 int PrefsRenderFarmSortNodes::handle_event()
680 pwindow->thread->preferences->sort_nodes();
681 subwindow->generate_node_list();
682 subwindow->update_node_list();
683 subwindow->hot_node = -1;
691 PrefsRenderFarmReset::PrefsRenderFarmReset(PreferencesWindow *pwindow,
692 PerformancePrefs *subwindow,
695 : BC_GenericButton(x, y, _("Reset rates"))
697 this->pwindow = pwindow;
698 this->subwindow = subwindow;
701 int PrefsRenderFarmReset::handle_event()
703 pwindow->thread->preferences->reset_rates();
704 subwindow->generate_node_list();
705 subwindow->update_node_list();
707 char string[BCTEXTLEN];
709 MASTER_NODE_FRAMERATE_TEXT,
710 pwindow->thread->preferences->local_rate);
711 subwindow->master_rate->update(string);
712 subwindow->hot_node = -1;
722 PrefsRenderFarmJobs::PrefsRenderFarmJobs(PreferencesWindow *pwindow,
723 PerformancePrefs *subwindow,
726 : BC_TumbleTextBox(subwindow,
727 (int64_t)pwindow->thread->preferences->renderfarm_job_count,
734 this->pwindow = pwindow;
736 PrefsRenderFarmJobs::~PrefsRenderFarmJobs()
739 int PrefsRenderFarmJobs::handle_event()
741 pwindow->thread->preferences->renderfarm_job_count = atol(get_text());
747 PrefsRenderFarmMountpoint::PrefsRenderFarmMountpoint(PreferencesWindow *pwindow,
748 PerformancePrefs *subwindow,
755 pwindow->thread->preferences->renderfarm_mountpoint)
757 this->pwindow = pwindow;
758 this->subwindow = subwindow;
760 PrefsRenderFarmMountpoint::~PrefsRenderFarmMountpoint()
763 int PrefsRenderFarmMountpoint::handle_event()
765 strcpy(pwindow->thread->preferences->renderfarm_mountpoint, get_text());
772 PrefsRenderFarmVFS::PrefsRenderFarmVFS(PreferencesWindow *pwindow,
773 PerformancePrefs *subwindow,
776 : BC_CheckBox(x, y, pwindow->thread->preferences->renderfarm_vfs, _("Use virtual filesystem"))
778 this->pwindow = pwindow;
779 this->subwindow = subwindow;
782 int PrefsRenderFarmVFS::handle_event()
784 pwindow->thread->preferences->renderfarm_vfs = get_value();
791 // c-file-style: "linux"