mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Implement off-screen rendering support using delegated rendering (issue #1257).
This implementation supports both GPU compositing and software compositing (used when GPU is not supported or when passing `--disable-gpu --disable-gpu-compositing` command-line flags). GPU-accelerated features (WebGL and 3D CSS) that did not work with the previous off-screen rendering implementation do work with this implementation when GPU support is available. Rendering now operates on a per-frame basis. The frame rate is configurable via CefBrowserSettings.windowless_frame_rate up to a maximum of 60fps (potentially limited by how fast the system can generate new frames). CEF generates a bitmap from the compositor backing and passes it to CefRenderHandler::OnPaint. The previous CefRenderHandler/CefBrowserHost API for off-screen rendering has been restored mostly as-is with some minor changes: - CefBrowserHost::Invalidate no longer accepts a CefRect region argument. Instead of invalidating a specific region it now triggers generation of a new frame. - The |dirtyRects| argument to CefRenderHandler::OnPaint will now always be a single CefRect representing the whole view (frame) size. Previously, invalidated regions were listed separately. - Linux: CefBrowserHost::SendKeyEvent now expects X11 event information instead of GTK event information. See cefclient for an example of converting GTK events to the necessary format. - Sizes passed to the CefRenderHandler OnPaint and OnPopupSize methods are now already DPI scaled. Previously, the client had to perform DPI scaling. - Includes drag&drop implementation from issue #1032. - Includes unit test fixes from issue #1245. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1751 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -36,8 +36,15 @@ class ClientHandler : public CefClient,
|
||||
public CefKeyboardHandler,
|
||||
public CefLifeSpanHandler,
|
||||
public CefLoadHandler,
|
||||
public CefRenderHandler,
|
||||
public CefRequestHandler {
|
||||
public:
|
||||
// Interface implemented to handle off-screen rendering.
|
||||
class RenderHandler : public CefRenderHandler {
|
||||
public:
|
||||
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) =0;
|
||||
};
|
||||
|
||||
typedef std::set<CefMessageRouterBrowserSide::Handler*> MessageHandlerSet;
|
||||
|
||||
ClientHandler();
|
||||
@@ -68,6 +75,9 @@ class ClientHandler : public CefClient,
|
||||
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
@@ -112,7 +122,7 @@ class ClientHandler : public CefClient,
|
||||
// CefDragHandler methods
|
||||
virtual bool OnDragEnter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> dragData,
|
||||
DragOperationsMask mask) OVERRIDE;
|
||||
CefDragHandler::DragOperationsMask mask) OVERRIDE;
|
||||
|
||||
// CefGeolocationHandler methods
|
||||
virtual void OnRequestGeolocationPermission(
|
||||
@@ -128,6 +138,15 @@ class ClientHandler : public CefClient,
|
||||
bool* is_keyboard_shortcut) OVERRIDE;
|
||||
|
||||
// CefLifeSpanHandler methods
|
||||
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& target_url,
|
||||
const CefString& target_frame_name,
|
||||
const CefPopupFeatures& popupFeatures,
|
||||
CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient>& client,
|
||||
CefBrowserSettings& settings,
|
||||
bool* no_javascript_access) OVERRIDE;
|
||||
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
@@ -162,9 +181,44 @@ class ClientHandler : public CefClient,
|
||||
virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
|
||||
TerminationStatus status) OVERRIDE;
|
||||
|
||||
// CefRenderHandler methods
|
||||
virtual bool GetRootScreenRect(CefRefPtr<CefBrowser> browser,
|
||||
CefRect& rect) OVERRIDE;
|
||||
virtual bool GetViewRect(CefRefPtr<CefBrowser> browser,
|
||||
CefRect& rect) OVERRIDE;
|
||||
virtual bool GetScreenPoint(CefRefPtr<CefBrowser> browser,
|
||||
int viewX,
|
||||
int viewY,
|
||||
int& screenX,
|
||||
int& screenY) OVERRIDE;
|
||||
virtual bool GetScreenInfo(CefRefPtr<CefBrowser> browser,
|
||||
CefScreenInfo& screen_info) OVERRIDE;
|
||||
virtual void OnPopupShow(CefRefPtr<CefBrowser> browser, bool show) OVERRIDE;
|
||||
virtual void OnPopupSize(CefRefPtr<CefBrowser> browser,
|
||||
const CefRect& rect) OVERRIDE;
|
||||
virtual void OnPaint(CefRefPtr<CefBrowser> browser,
|
||||
PaintElementType type,
|
||||
const RectList& dirtyRects,
|
||||
const void* buffer,
|
||||
int width,
|
||||
int height) OVERRIDE;
|
||||
virtual void OnCursorChange(CefRefPtr<CefBrowser> browser,
|
||||
CefCursorHandle cursor) OVERRIDE;
|
||||
virtual bool StartDragging(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> drag_data,
|
||||
CefRenderHandler::DragOperationsMask allowed_ops,
|
||||
int x, int y) OVERRIDE;
|
||||
virtual void UpdateDragCursor(CefRefPtr<CefBrowser> browser,
|
||||
CefRenderHandler::DragOperation operation)
|
||||
OVERRIDE;
|
||||
|
||||
void SetMainHwnd(ClientWindowHandle hwnd);
|
||||
ClientWindowHandle GetMainHwnd() { return m_MainHwnd; }
|
||||
void SetEditHwnd(ClientWindowHandle hwnd);
|
||||
void SetOSRHandler(CefRefPtr<RenderHandler> handler) {
|
||||
m_OSRHandler = handler;
|
||||
}
|
||||
CefRefPtr<RenderHandler> GetOSRHandler() { return m_OSRHandler; }
|
||||
void SetButtonHwnds(ClientWindowHandle backHwnd,
|
||||
ClientWindowHandle forwardHwnd,
|
||||
ClientWindowHandle reloadHwnd,
|
||||
@@ -252,6 +306,8 @@ class ClientHandler : public CefClient,
|
||||
ClientWindowHandle m_StopHwnd;
|
||||
ClientWindowHandle m_ReloadHwnd;
|
||||
|
||||
CefRefPtr<RenderHandler> m_OSRHandler;
|
||||
|
||||
// Support for logging.
|
||||
std::string m_LogFile;
|
||||
|
||||
|
Reference in New Issue
Block a user