Skip to content

Commit c095627

Browse files
committed
Make hardware acceleration option plugin global
It's not possible to mix software and hardware rendered browser sources, so instead of doing that, make the option global.
1 parent 51136c4 commit c095627

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

data/locale/en-US.ini

-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ RefreshBrowserActive="Refresh browser when scene becomes active"
99
RefreshNoCache="Refresh cache of current page"
1010
RestartCEF="Restart CEF"
1111
BrowserSource="Browser"
12-
HardwareAcceleration="Hardware Accelerated Rendering"

obs-browser-plugin.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ static thread manager_thread;
5050

5151
static int adapterCount = 0;
5252

53+
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
54+
bool hwaccel = false;
55+
#endif
56+
5357
/* ========================================================================= */
5458

5559
class BrowserTask : public CefTask {
@@ -86,9 +90,6 @@ static void browser_source_get_defaults(obs_data_t *settings)
8690
obs_data_set_default_bool(settings, "shutdown", false);
8791
obs_data_set_default_bool(settings, "restart_when_active", false);
8892
obs_data_set_default_string(settings, "css", default_css);
89-
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
90-
obs_data_set_default_bool(settings, "hwaccel", adapterCount == 1);
91-
#endif
9293
}
9394

9495
static bool is_local_file_modified(obs_properties_t *props,
@@ -143,11 +144,6 @@ static obs_properties_t *browser_source_get_properties(void *data)
143144
obs_properties_add_bool(props, "restart_when_active",
144145
obs_module_text("RefreshBrowserActive"));
145146

146-
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
147-
obs_properties_add_bool(props, "hwaccel",
148-
obs_module_text("HardwareAcceleration"));
149-
#endif
150-
151147
obs_properties_add_button(props, "refreshnocache",
152148
obs_module_text("RefreshNoCache"),
153149
[] (obs_properties_t *, obs_property_t *, void *data)
@@ -185,9 +181,11 @@ static void BrowserManagerThread(void)
185181
bool tex_sharing_avail = false;
186182

187183
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
188-
obs_enter_graphics();
189-
tex_sharing_avail = gs_shared_texture_available();
190-
obs_leave_graphics();
184+
if (hwaccel) {
185+
obs_enter_graphics();
186+
tex_sharing_avail = gs_shared_texture_available();
187+
obs_leave_graphics();
188+
}
191189
#endif
192190

193191
CefRefPtr<BrowserApp> app(new BrowserApp(tex_sharing_avail));
@@ -404,6 +402,12 @@ bool obs_module_load(void)
404402
#endif
405403
RegisterBrowserSource();
406404
obs_frontend_add_event_callback(handle_obs_frontend_event, nullptr);
405+
406+
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
407+
obs_data_t *private_data = obs_get_private_data();
408+
hwaccel = obs_data_get_bool(private_data, "BrowserHWAccel");
409+
obs_data_release(private_data);
410+
#endif
407411
return true;
408412
}
409413

obs-browser-source.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -342,21 +342,13 @@ void BrowserSource::Update(obs_data_t *settings)
342342
n_url = obs_data_get_string(settings,
343343
n_is_local ? "local_file" : "url");
344344

345-
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
346-
bool n_hwaccel;
347-
n_hwaccel = obs_data_get_bool(settings, "hwaccel");
348-
#endif
349-
350345
if (n_is_local == is_local &&
351346
n_width == width &&
352347
n_height == height &&
353348
n_fps == fps &&
354349
n_shutdown == shutdown_on_invisible &&
355350
n_restart == restart &&
356351
n_css == css &&
357-
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
358-
n_hwaccel == hwaccel &&
359-
#endif
360352
n_url == url) {
361353
return;
362354
}
@@ -369,9 +361,6 @@ void BrowserSource::Update(obs_data_t *settings)
369361
restart = n_restart;
370362
css = n_css;
371363
url = n_url;
372-
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
373-
hwaccel = n_hwaccel;
374-
#endif
375364
}
376365

377366
DestroyBrowser(true);

obs-browser-source.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
#include <functional>
2727
#include <string>
2828

29+
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
30+
extern bool hwaccel;
31+
#endif
32+
2933
struct BrowserSource {
3034
BrowserSource **p_prev_next = nullptr;
3135
BrowserSource *next = nullptr;
@@ -46,7 +50,6 @@ struct BrowserSource {
4650
bool shutdown_on_invisible = false;
4751
bool is_local = false;
4852
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
49-
bool hwaccel = false;
5053
bool reset_frame = false;
5154
#endif
5255

0 commit comments

Comments
 (0)