Skip to content

Commit

Permalink
Make hardware acceleration option plugin global
Browse files Browse the repository at this point in the history
It's not possible to mix software and hardware rendered browser sources,
so instead of doing that, make the option global.
  • Loading branch information
jp9000 committed Aug 10, 2018
1 parent 51136c4 commit c095627
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
1 change: 0 additions & 1 deletion data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ RefreshBrowserActive="Refresh browser when scene becomes active"
RefreshNoCache="Refresh cache of current page"
RestartCEF="Restart CEF"
BrowserSource="Browser"
HardwareAcceleration="Hardware Accelerated Rendering"
26 changes: 15 additions & 11 deletions obs-browser-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ static thread manager_thread;

static int adapterCount = 0;

#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
bool hwaccel = false;
#endif

/* ========================================================================= */

class BrowserTask : public CefTask {
Expand Down Expand Up @@ -86,9 +90,6 @@ static void browser_source_get_defaults(obs_data_t *settings)
obs_data_set_default_bool(settings, "shutdown", false);
obs_data_set_default_bool(settings, "restart_when_active", false);
obs_data_set_default_string(settings, "css", default_css);
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
obs_data_set_default_bool(settings, "hwaccel", adapterCount == 1);
#endif
}

static bool is_local_file_modified(obs_properties_t *props,
Expand Down Expand Up @@ -143,11 +144,6 @@ static obs_properties_t *browser_source_get_properties(void *data)
obs_properties_add_bool(props, "restart_when_active",
obs_module_text("RefreshBrowserActive"));

#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
obs_properties_add_bool(props, "hwaccel",
obs_module_text("HardwareAcceleration"));
#endif

obs_properties_add_button(props, "refreshnocache",
obs_module_text("RefreshNoCache"),
[] (obs_properties_t *, obs_property_t *, void *data)
Expand Down Expand Up @@ -185,9 +181,11 @@ static void BrowserManagerThread(void)
bool tex_sharing_avail = false;

#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
obs_enter_graphics();
tex_sharing_avail = gs_shared_texture_available();
obs_leave_graphics();
if (hwaccel) {
obs_enter_graphics();
tex_sharing_avail = gs_shared_texture_available();
obs_leave_graphics();
}
#endif

CefRefPtr<BrowserApp> app(new BrowserApp(tex_sharing_avail));
Expand Down Expand Up @@ -404,6 +402,12 @@ bool obs_module_load(void)
#endif
RegisterBrowserSource();
obs_frontend_add_event_callback(handle_obs_frontend_event, nullptr);

#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
obs_data_t *private_data = obs_get_private_data();
hwaccel = obs_data_get_bool(private_data, "BrowserHWAccel");
obs_data_release(private_data);
#endif
return true;
}

Expand Down
11 changes: 0 additions & 11 deletions obs-browser-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,21 +342,13 @@ void BrowserSource::Update(obs_data_t *settings)
n_url = obs_data_get_string(settings,
n_is_local ? "local_file" : "url");

#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
bool n_hwaccel;
n_hwaccel = obs_data_get_bool(settings, "hwaccel");
#endif

if (n_is_local == is_local &&
n_width == width &&
n_height == height &&
n_fps == fps &&
n_shutdown == shutdown_on_invisible &&
n_restart == restart &&
n_css == css &&
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
n_hwaccel == hwaccel &&
#endif
n_url == url) {
return;
}
Expand All @@ -369,9 +361,6 @@ void BrowserSource::Update(obs_data_t *settings)
restart = n_restart;
css = n_css;
url = n_url;
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
hwaccel = n_hwaccel;
#endif
}

DestroyBrowser(true);
Expand Down
5 changes: 4 additions & 1 deletion obs-browser-source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include <functional>
#include <string>

#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
extern bool hwaccel;
#endif

struct BrowserSource {
BrowserSource **p_prev_next = nullptr;
BrowserSource *next = nullptr;
Expand All @@ -46,7 +50,6 @@ struct BrowserSource {
bool shutdown_on_invisible = false;
bool is_local = false;
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
bool hwaccel = false;
bool reset_frame = false;
#endif

Expand Down

0 comments on commit c095627

Please sign in to comment.