mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add a new CefBrowserHost::SetWindowlessFrameRate method to support
dynamic configuration of the windowless frame rate (issue #1629).
This commit is contained in:
@@ -171,6 +171,29 @@ void ModifyZoom(CefRefPtr<CefBrowser> browser, double delta) {
|
||||
browser->GetHost()->GetZoomLevel() + delta);
|
||||
}
|
||||
|
||||
void ModifyFPS(CefRefPtr<CefBrowser> browser, int fps_delta) {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
// Execute on the UI thread.
|
||||
CefPostTask(TID_UI, base::Bind(&ModifyFPS, browser, fps_delta));
|
||||
return;
|
||||
}
|
||||
|
||||
int fps;
|
||||
if (fps_delta == 0) {
|
||||
// Reset to the default value.
|
||||
CefBrowserSettings settings;
|
||||
MainContext::Get()->PopulateBrowserSettings(&settings);
|
||||
fps = settings.windowless_frame_rate;
|
||||
} else {
|
||||
// Modify the existing value.
|
||||
fps = browser->GetHost()->GetWindowlessFrameRate() + fps_delta;
|
||||
if (fps <= 0)
|
||||
fps = 1;
|
||||
}
|
||||
|
||||
browser->GetHost()->SetWindowlessFrameRate(fps);
|
||||
}
|
||||
|
||||
void BeginTracing() {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
// Execute on the UI thread.
|
||||
@@ -318,6 +341,15 @@ void RunTest(CefRefPtr<CefBrowser> browser, int id) {
|
||||
case ID_TESTS_ZOOM_RESET:
|
||||
browser->GetHost()->SetZoomLevel(0.0);
|
||||
break;
|
||||
case ID_TESTS_FPS_INCREASE:
|
||||
ModifyFPS(browser, 10);
|
||||
break;
|
||||
case ID_TESTS_FPS_DECREASE:
|
||||
ModifyFPS(browser, -10);
|
||||
break;
|
||||
case ID_TESTS_FPS_RESET:
|
||||
ModifyFPS(browser, 0);
|
||||
break;
|
||||
case ID_TESTS_TRACING_BEGIN:
|
||||
BeginTracing();
|
||||
break;
|
||||
|
Reference in New Issue
Block a user