Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable building with CEF 6261 & 6367 (Chromium 122 & 124) #434

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions browser-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ void BrowserApp::ExecuteJSFunction(CefRefPtr<CefBrowser> browser,
std::vector<CefString> names;
browser->GetFrameNames(names);
for (auto &name : names) {
CefRefPtr<CefFrame> frame = browser->GetFrame(name);
CefRefPtr<CefFrame> frame =
#if CHROME_VERSION_BUILD >= 6261
browser->GetFrameByName(name);
#else
browser->GetFrame(name);
#endif
CefRefPtr<CefV8Context> context = frame->GetV8Context();

context->Enter();
Expand Down Expand Up @@ -346,7 +351,12 @@ bool BrowserApp::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
std::vector<CefString> names;
browser->GetFrameNames(names);
for (auto &name : names) {
CefRefPtr<CefFrame> frame = browser->GetFrame(name);
CefRefPtr<CefFrame> frame =
#if CHROME_VERSION_BUILD >= 6261
browser->GetFrameByName(name);
#else
browser->GetFrame(name);
#endif
CefRefPtr<CefV8Context> context = frame->GetV8Context();

context->Enter();
Expand Down Expand Up @@ -517,7 +527,11 @@ void ProcessCef()

#define MAX_DELAY (1000 / 30)

#if CHROME_VERSION_BUILD < 5938
void BrowserApp::OnScheduleMessagePumpWork(int64 delay_ms)
#else
void BrowserApp::OnScheduleMessagePumpWork(int64_t delay_ms)
#endif
{
if (delay_ms < 0)
delay_ms = 0;
Expand Down
4 changes: 4 additions & 0 deletions browser-app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ class BrowserApp : public CefApp,
CefString &exception) override;

#ifdef ENABLE_BROWSER_QT_LOOP
#if CHROME_VERSION_BUILD < 5938
virtual void OnScheduleMessagePumpWork(int64 delay_ms) override;
#else
virtual void OnScheduleMessagePumpWork(int64_t delay_ms) override;
#endif
QTimer frameTimer;
#endif

Expand Down
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
WizardCM marked this conversation as resolved.
Show resolved Hide resolved
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: 2 additions & 0 deletions obs-browser-page/obs-browser-page-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
std::thread shutdown_check;

CefMainArgs mainArgs(nullptr);
#if CHROME_VERSION_BUILD < 5615
if (!SetHighDPIv2Scaling())
PatTheMav marked this conversation as resolved.
Show resolved Hide resolved
CefEnableHighDPISupport();
#endif

CefRefPtr<CefCommandLine> command_line =
CefCommandLine::CreateCommandLine();
Expand Down
5 changes: 4 additions & 1 deletion obs-browser-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,12 @@ bool obs_module_load(void)

os_event_init(&cef_started_event, OS_EVENT_TYPE_MANUAL);

#ifdef _WIN32
#if defined(_WIN32) && CHROME_VERSION_BUILD < 5615
/* CefEnableHighDPISupport doesn't do anything on OS other than Windows. Would also crash macOS at this point as CEF is not directly linked */
CefEnableHighDPISupport();
#endif

#ifdef _WIN32
EnumAdapterCount();
#else
#if defined(__APPLE__) && !defined(ENABLE_BROWSER_LEGACY)
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