From a245fbde02b82acaa1802e7ed42132aa516ff043 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 15 Aug 2012 15:16:39 +0000 Subject: [PATCH] Merge revision 741 changes: - Add the ability to customize the animation frame rate (issue #697). git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1180@742 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- cef1/include/capi/cef_render_handler_capi.h | 4 +++- cef1/include/cef_render_handler.h | 4 +++- cef1/include/internal/cef_types.h | 11 ++++++++--- cef1/libcef/webwidget_host.cc | 3 ++- cef1/tests/cefclient/osrplugin.cpp | 5 ++++- cef1/tests/cefclient/osrtest_mac.mm | 7 +++++-- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/cef1/include/capi/cef_render_handler_capi.h b/cef1/include/capi/cef_render_handler_capi.h index 53fc5d8e5..90f0cee28 100644 --- a/cef1/include/capi/cef_render_handler_capi.h +++ b/cef1/include/capi/cef_render_handler_capi.h @@ -96,7 +96,9 @@ typedef struct _cef_render_handler_t { // element is the view or the popup widget. |buffer| contains the pixel data // for the whole image. |dirtyRects| contains the set of rectangles that need // to be repainted. On Windows |buffer| will be width*height*4 bytes in size - // and represents a BGRA image with an upper-left origin. + // and represents a BGRA image with an upper-left origin. The + // cef_browser_tSettings.animation_frame_rate value controls the rate at which + // this function is called. /// void (CEF_CALLBACK *on_paint)(struct _cef_render_handler_t* self, struct _cef_browser_t* browser, enum cef_paint_element_type_t type, diff --git a/cef1/include/cef_render_handler.h b/cef1/include/cef_render_handler.h index 9bb9f68af..643fbbf56 100644 --- a/cef1/include/cef_render_handler.h +++ b/cef1/include/cef_render_handler.h @@ -100,7 +100,9 @@ class CefRenderHandler : public virtual CefBase { // element is the view or the popup widget. |buffer| contains the pixel data // for the whole image. |dirtyRects| contains the set of rectangles that need // to be repainted. On Windows |buffer| will be width*height*4 bytes in size - // and represents a BGRA image with an upper-left origin. + // and represents a BGRA image with an upper-left origin. The + // CefBrowserSettings.animation_frame_rate value controls the rate at which + // this method is called. /// /*--cef()--*/ virtual void OnPaint(CefRefPtr browser, diff --git a/cef1/include/internal/cef_types.h b/cef1/include/internal/cef_types.h index 15091a4d4..c629559b5 100644 --- a/cef1/include/internal/cef_types.h +++ b/cef1/include/internal/cef_types.h @@ -239,9 +239,14 @@ typedef struct _cef_browser_settings_t { bool history_disabled; /// - // The number of frames per second (fps) for the requestAnimationFrame timer - // and calls to CefRenderHandler::OnPaint(). The value must be between 0 and - // 90. Specify zero for the default frame rate of 30 fps. + // The number of frames per second (fps) for animation and windowless + // rendering. When window rendering is enabled and the JavaScript + // requestAnimationFrame method is used the browser client area will be + // invalidated at the rate specified. When window rendering is disabled the + // CefRenderHandler::OnPaint() method will be called at the rate specified. + // This value must be between 0 and 90. Specify a value of zero for the + // default frame rate of 30 fps. Changing this value may affect display + // performance and/or CPU usage. /// int animation_frame_rate; diff --git a/cef1/libcef/webwidget_host.cc b/cef1/libcef/webwidget_host.cc index 7b4488635..28cd276ba 100644 --- a/cef1/libcef/webwidget_host.cc +++ b/cef1/libcef/webwidget_host.cc @@ -105,7 +105,8 @@ void WebWidgetHost::SetFrameRate(int frames_per_second) { } void WebWidgetHost::ScheduleInvalidateTimer() { - if (invalidate_timer_.IsRunning()) + // Invalidation is only required when window rendering is enabled. + if (!view_ || invalidate_timer_.IsRunning()) return; // Maintain the desired rate. diff --git a/cef1/tests/cefclient/osrplugin.cpp b/cef1/tests/cefclient/osrplugin.cpp index e8d3befb3..1a2a99267 100644 --- a/cef1/tests/cefclient/osrplugin.cpp +++ b/cef1/tests/cefclient/osrplugin.cpp @@ -437,10 +437,13 @@ NPError NPP_SetWindowImpl(NPP instance, NPWindow* window_info) { // Create the off-screen rendering window. CefWindowInfo windowInfo; - CefBrowserSettings settings; windowInfo.SetAsOffScreen(plugin->hWnd); if (g_offscreenTransparent) windowInfo.SetTransparentPainting(TRUE); + + CefBrowserSettings settings; + AppGetBrowserSettings(settings); + CefBrowser::CreateBrowser(windowInfo, new ClientOSRHandler(plugin), "http://www.google.com", settings); } diff --git a/cef1/tests/cefclient/osrtest_mac.mm b/cef1/tests/cefclient/osrtest_mac.mm index 8fa8243c4..52c5692b5 100644 --- a/cef1/tests/cefclient/osrtest_mac.mm +++ b/cef1/tests/cefclient/osrtest_mac.mm @@ -7,8 +7,9 @@ #include "cefclient/osrtest_mac.h" #include "include/cef_browser.h" -#include "cefclient/osrenderer.h" +#include "cefclient/cefclient.h" #include "cefclient/client_popup_handler.h" +#include "cefclient/osrenderer.h" #include "cefclient/resource_util.h" #include "cefclient/util.h" @@ -735,12 +736,14 @@ void RunTest(bool transparent) { [view release]; CefWindowInfo info; - CefBrowserSettings settings; // Initialize the window info as off-screen. info.SetAsOffScreen(view); info.SetTransparentPainting(transparent); + CefBrowserSettings settings; + AppGetBrowserSettings(settings); + // Creat the browser window. CefBrowser::CreateBrowser(info, new ClientOSRHandler(view), "http://tests/osrtest", settings);