Skip to content

Commit

Permalink
Enable building with CEF 6367
Browse files Browse the repository at this point in the history
This allows compiling OBS Browser with Chromium 124-based CEF versions.

This also enables basic support for the new, official, shared texture
API, purely because building without it would be *more* difficult.

Sources:
 - https://bitbucket.org/chromiumembedded/cef/commits/260dd0ca2
  • Loading branch information
WizardCM committed Jun 9, 2024
1 parent bd12b9c commit a03b602
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
22 changes: 20 additions & 2 deletions browser-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,11 @@ void BrowserClient::UpdateExtraTexture()

void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>,
PaintElementType type, const RectList &,
#if CHROME_VERSION_BUILD >= 6367
const CefAcceleratedPaintInfo &info)
#else
void *shared_handle)
#endif
{
if (type != PET_VIEW) {
// TODO Overlay texture on top of bs->texture
Expand All @@ -384,7 +388,7 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>,
return;
}

#ifndef _WIN32
#if !defined(_WIN32) && CHROME_VERSION_BUILD < 6367
if (shared_handle == bs->last_handle)
return;
#endif
Expand All @@ -399,12 +403,20 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>,
bs->texture = nullptr;
}

#if defined(__APPLE__) && CHROME_VERSION_BUILD > 4183
#if defined(__APPLE__) && CHROME_VERSION_BUILD > 6367
bs->texture = gs_texture_create_from_iosurface(
(IOSurfaceRef)(uintptr_t)info.shared_texture_io_surface);
#elif defined(__APPLE__) && CHROME_VERSION_BUILD > 4183
bs->texture = gs_texture_create_from_iosurface(
(IOSurfaceRef)(uintptr_t)shared_handle);
#elif defined(_WIN32) && CHROME_VERSION_BUILD > 4183
bs->texture =
#if CHROME_VERSION_BUILD >= 6367
gs_texture_open_nt_shared(
(uint32_t)(uintptr_t)info.shared_texture_handle);
#else
gs_texture_open_nt_shared((uint32_t)(uintptr_t)shared_handle);
#endif
//if (bs->texture)
// gs_texture_acquire_sync(bs->texture, 1, INFINITE);

Expand All @@ -415,7 +427,13 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>,
UpdateExtraTexture();
obs_leave_graphics();

#if defined(__APPLE__) && CHROME_VERSION_BUILD >= 6367
bs->last_handle = info.shared_texture_io_surface;
#elif CHROME_VERSION_BUILD >= 6367
bs->last_handle = info.shared_texture_handle;
#else
bs->last_handle = shared_handle;
#endif
}

#ifdef CEF_ON_ACCELERATED_PAINT2
Expand Down
12 changes: 8 additions & 4 deletions browser-client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,14 @@ class BrowserClient : public CefClient,
const void *buffer, int width,
int height) override;
#ifdef ENABLE_BROWSER_SHARED_TEXTURE
virtual void OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList &dirtyRects,
void *shared_handle) override;
virtual void
OnAcceleratedPaint(CefRefPtr<CefBrowser> browser, PaintElementType type,
const RectList &dirtyRects,
#if CHROME_VERSION_BUILD >= 6367
const CefAcceleratedPaintInfo &info) override;
#else
void *shared_handle) override;
#endif
#ifdef CEF_ON_ACCELERATED_PAINT2
virtual void OnAcceleratedPaint2(CefRefPtr<CefBrowser> browser,
PaintElementType type,
Expand Down
2 changes: 1 addition & 1 deletion obs-browser-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ extern void ProcessCef();
void BrowserSource::Render()
{
bool flip = false;
#ifdef ENABLE_BROWSER_SHARED_TEXTURE
#if defined(ENABLE_BROWSER_SHARED_TEXTURE) && CHROME_VERSION_BUILD < 6367
flip = hwaccel;
#endif

Expand Down

0 comments on commit a03b602

Please sign in to comment.