From 4d38e054e32abac858e710c00d3a23f757d32af5 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Fri, 10 Aug 2018 06:12:16 -0700 Subject: [PATCH] UI: Add adv. settings checkbox for browser HW accel Adds a checkbox to advanced settings that allows the user to enable/disable browser source hardware acceleration on windows. --- UI/data/locale/en-US.ini | 3 + UI/forms/OBSBasicSettings.ui | 126 ++++++++++++++++++++++++----------- UI/obs-app.cpp | 14 ++++ UI/window-basic-settings.cpp | 13 ++++ plugins/obs-browser | 2 +- 5 files changed, 118 insertions(+), 40 deletions(-) diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index 448dda799..0b0603110 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -855,3 +855,6 @@ NoSources.Text.AddSource="You can add sources by clicking the + icon under the S # Scene item color selection ChangeBG="Set Color" CustomColor="Custom Color" + +# Global settings for the browser source +BrowserSource.EnableHardwareAcceleration="Enable Browser Source Hardware Acceleration" diff --git a/UI/forms/OBSBasicSettings.ui b/UI/forms/OBSBasicSettings.ui index 8144f7ec4..4c8e023b2 100644 --- a/UI/forms/OBSBasicSettings.ui +++ b/UI/forms/OBSBasicSettings.ui @@ -144,9 +144,9 @@ 0 - -44 + 0 801 - 741 + 836 @@ -797,8 +797,8 @@ 0 0 - 601 - 640 + 818 + 697 @@ -3436,8 +3436,8 @@ 0 0 - 63 - 16 + 800 + 69 @@ -3832,8 +3832,8 @@ 0 0 - 98 - 28 + 818 + 697 @@ -3850,7 +3850,7 @@ - + 0 @@ -3880,10 +3880,10 @@ 0 0 803 - 793 + 807 - + 0 @@ -3896,9 +3896,9 @@ 9 - + - + @@ -4568,6 +4568,38 @@ + + + + Basic.Main.Sources + + + + 2 + + + + + Qt::Horizontal + + + + 170 + 20 + + + + + + + + BrowserSource.EnableHardwareAcceleration + + + + + + @@ -4600,32 +4632,6 @@ - - - - color: rgb(255, 0, 4); - - - - - - true - - - - - - - color: rgb(255, 0, 4); - - - - - - true - - - @@ -4633,6 +4639,48 @@ + + + + 10 + + + 10 + + + 10 + + + 10 + + + + + color: rgb(255, 0, 4); + + + + + + true + + + + + + + color: rgb(255, 0, 4); + + + + + + true + + + + + diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp index 66519f78a..a855acce6 100644 --- a/UI/obs-app.cpp +++ b/UI/obs-app.cpp @@ -437,6 +437,7 @@ bool OBSApp::InitGlobalConfigDefaults() #ifdef _WIN32 config_set_default_bool(globalConfig, "Audio", "DisableAudioDucking", true); + config_set_default_bool(globalConfig, "General", "BrowserHWAccel", true); #endif #ifdef __APPLE__ @@ -1226,6 +1227,19 @@ bool OBSApp::OBSInit() if (!StartupOBS(locale.c_str(), GetProfilerNameStore())) return false; +#ifdef _WIN32 + bool browserHWAccel = config_get_bool(globalConfig, "General", + "BrowserHWAccel"); + + obs_data_t *settings = obs_data_create(); + obs_data_set_bool(settings, "BrowserHWAccel", browserHWAccel); + obs_apply_private_data(settings); + obs_data_release(settings); + + blog(LOG_INFO, "Browser Hardware Acceleration: %s", + browserHWAccel ? "true" : "false"); +#endif + blog(LOG_INFO, "Portable mode: %s", portable_mode ? "true" : "false"); diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 08e56f46c..4fb4ef24c 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -430,6 +430,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) #endif #ifdef _WIN32 HookWidget(ui->disableAudioDucking, CHECK_CHANGED, ADV_CHANGED); + HookWidget(ui->browserHWAccel, CHECK_CHANGED, ADV_RESTART); #endif HookWidget(ui->filenameFormatting, EDIT_CHANGED, ADV_CHANGED); HookWidget(ui->overwriteIfExists, CHECK_CHANGED, ADV_CHANGED); @@ -500,6 +501,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) delete ui->advancedGeneralGroupBox; delete ui->enableNewSocketLoop; delete ui->enableLowLatencyMode; + delete ui->browserHWAccel; + delete ui->sourcesGroup; #if defined(__APPLE__) || HAVE_PULSEAUDIO delete ui->disableAudioDucking; #endif @@ -512,6 +515,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) ui->advancedGeneralGroupBox = nullptr; ui->enableNewSocketLoop = nullptr; ui->enableLowLatencyMode = nullptr; + ui->browserHWAccel = nullptr; + ui->sourcesGroup = nullptr; #if defined(__APPLE__) || HAVE_PULSEAUDIO ui->disableAudioDucking = nullptr; #endif @@ -2295,6 +2300,10 @@ void OBSBasicSettings::LoadAdvancedSettings() ui->enableNewSocketLoop->setChecked(enableNewSocketLoop); ui->enableLowLatencyMode->setChecked(enableLowLatencyMode); + + bool browserHWAccel = config_get_bool(App()->GlobalConfig(), + "General", "BrowserHWAccel"); + ui->browserHWAccel->setChecked(browserHWAccel); #endif bool disableFocusHotkeys = config_get_bool(App()->GlobalConfig(), @@ -2832,6 +2841,10 @@ void OBSBasicSettings::SaveAdvancedSettings() SaveCheckBox(ui->enableNewSocketLoop, "Output", "NewSocketLoopEnable"); SaveCheckBox(ui->enableLowLatencyMode, "Output", "LowLatencyEnable"); + + bool browserHWAccel = ui->browserHWAccel->isChecked(); + config_set_bool(App()->GlobalConfig(), "General", + "BrowserHWAccel", browserHWAccel); #endif bool disableFocusHotkeys = ui->disableFocusHotkeys->isChecked(); diff --git a/plugins/obs-browser b/plugins/obs-browser index 48db938cc..c09562745 160000 --- a/plugins/obs-browser +++ b/plugins/obs-browser @@ -1 +1 @@ -Subproject commit 48db938cc087d59bb4241bcf153d42a345503f8f +Subproject commit c09562745c5dd066f7fb43e2904ea2498be558cc