Skip to content
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ output
CMakeLists.txt.user
out
__pycache__
obj/
obj/
.agent/
AGENTS.md
4 changes: 4 additions & 0 deletions src/CCefView/capi/CefBrowser_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ void CCefBrowser_setWindowlessFrameRate(ccefbrowser_class * thiz, int rate) {
thiz->setWindowlessFrameRate(rate);
}

void CCefBrowser_sendExternalBeginFrame(ccefbrowser_class * thiz) {
thiz->sendExternalBeginFrame();
}

void CCefBrowser_setFocus(ccefbrowser_class * thiz, bool focused) {
thiz->setFocus(focused);
}
Expand Down
1 change: 1 addition & 0 deletions src/CCefView/capi/CefBrowser_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ extern "C"
CCEFVIEW_EXPORT void CCefBrowser_setDisablePopupContextMenu(ccefbrowser_class * thiz, bool disable);
CCEFVIEW_EXPORT bool CCefBrowser_isPopupContextMenuDisabled(ccefbrowser_class * thiz);
CCEFVIEW_EXPORT void CCefBrowser_setWindowlessFrameRate(ccefbrowser_class * thiz, int rate);
CCEFVIEW_EXPORT void CCefBrowser_sendExternalBeginFrame(ccefbrowser_class * thiz);
CCEFVIEW_EXPORT void CCefBrowser_setFocus(ccefbrowser_class * thiz, bool focused);
CCEFVIEW_EXPORT void CCefBrowser_wasResized(ccefbrowser_class * thiz);
CCEFVIEW_EXPORT void CCefBrowser_wasHidden(ccefbrowser_class * thiz, bool hidden);
Expand Down
3 changes: 2 additions & 1 deletion src/CCefView/include/CefBrowser.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef CCEFVIEW_H
#ifndef CCEFVIEW_H
#define CCEFVIEW_H

#pragma once
Expand Down Expand Up @@ -228,6 +228,7 @@ class CCefBrowser

#pragma region Control CEF
void setWindowlessFrameRate(int rate);
void sendExternalBeginFrame();
void setFocus(bool focused);
void wasResized();
void wasHidden(bool hidden);
Expand Down
29 changes: 25 additions & 4 deletions src/CCefView/source/CefBrowser.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "CefBrowser.h"
#include "CefBrowser.h"

#pragma region cef_headers
#include <include/cef_browser.h>
Expand Down Expand Up @@ -33,10 +33,18 @@ CCefBrowser::CCefBrowser(CefBrowserCallback callback, const std::string& url, co
CefBrowserSettings browserSettings;
CCefSetting::CopyToCefBrowserSettings(setting, browserSettings);

// Set window info
// Set window info based on configured rendering mode.
CefWindowInfo window_info;
window_info.SetAsWindowless(0);
window_info.shared_texture_enabled = (setting && setting->hardwareAcceleration_);
bool windowlessRenderingEnabled = false;
if (pContext && pContext->cefConfig()) {
windowlessRenderingEnabled = pContext->cefConfig()->windowlessRendering();
}

if (windowlessRenderingEnabled) {
window_info.SetAsWindowless(0);
window_info.shared_texture_enabled = (setting && setting->hardwareAcceleration_);
window_info.external_begin_frame_enabled = true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep external begin frame opt-in for OSR browsers

Setting window_info.external_begin_frame_enabled = true for every windowless browser changes OSR into externally driven frame scheduling, which requires callers to invoke SendExternalBeginFrame() each frame. This commit only exposes a new API but does not wire any internal scheduling path, so existing consumers that relied on normal SetWindowlessFrameRate-driven repainting can stop receiving paint updates after this change unless they add new per-frame calls.

Useful? React with 👍 / 👎.

}

if (CefColorGetA(browserSettings.background_color) == 0)
transparentPaintingEnabled_ = true;
Expand Down Expand Up @@ -332,6 +340,19 @@ CCefBrowser::setWindowlessFrameRate(int rate)
pCefBrowser_->GetHost()->SetWindowlessFrameRate(rate);
}

void
CCefBrowser::sendExternalBeginFrame()
{
if (!pCefBrowser_)
return;

auto host = pCefBrowser_->GetHost();
if (!host || !host->IsWindowRenderingDisabled())
return;

host->SendExternalBeginFrame();
}

void
CCefBrowser::setFocus(bool focused)
{
Expand Down
6 changes: 5 additions & 1 deletion src/CCefView/source/CefContext.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "CefContext.h"
#include "CefContext.h"

#include <list>

CCefContext* CCefContext::instance_ = nullptr;

CCefContext::CCefContext(const CCefConfig* config)
: config_(config)
{
instance_ = this;
init(config);
Expand Down Expand Up @@ -54,6 +55,9 @@ CCefContext::doCefMessageLoopWork()
bool
CCefContext::isSafeToShutdown()
{
if (!pApp_)
return true;

return pApp_->IsSafeToExit();
}

Expand Down
9 changes: 7 additions & 2 deletions src/CCefView/source/win/CefContext_win.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <CefContext.h>
#include <CefContext.h>

#undef OS_WINDOWS
#include <Shlwapi.h>
Expand All @@ -15,6 +15,8 @@
bool
CCefContext::init(const CCefConfig* config)
{
config_ = config;

// get current dll handle
HMODULE hCurrentModule = nullptr;
::GetModuleHandleEx(
Expand Down Expand Up @@ -108,12 +110,15 @@ CCefContext::init(const CCefConfig* config)
void
CCefContext::uninit()
{
if (!pApp_)
if (!pApp_) {
config_ = nullptr;
return;
}

pAppDelegate_ = nullptr;
pApp_ = nullptr;

// shutdown the cef
CefShutdown();
config_ = nullptr;
}
8 changes: 8 additions & 0 deletions src/DNCefView/AutoGen/CefBrowser+AutoGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ public void SetWindowlessFrameRate(int rate)
CCefBrowser_setWindowlessFrameRate(_native, rate);
}

// Source: void sendExternalBeginFrame()
[DllImport("CCefView")]
private static extern void CCefBrowser_sendExternalBeginFrame(IntPtr thiz);
public void SendExternalBeginFrame()
{
CCefBrowser_sendExternalBeginFrame(_native);
}

// Source: void setFocus(bool)
[DllImport("CCefView")]
private static extern void CCefBrowser_setFocus(IntPtr thiz, bool focused);
Expand Down