Add a new CefBrowserHost::SetWindowlessFrameRate method to support

dynamic configuration of the windowless frame rate (issue #1629).
This commit is contained in:
Marshall Greenblatt
2015-05-13 11:43:50 -04:00
parent 42341b40fa
commit 483a841348
17 changed files with 252 additions and 19 deletions

View File

@@ -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;