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:
Marshall Greenblatt
2014-06-30 22:30:29 +00:00
parent 133317eeec
commit dea4daffd7
106 changed files with 13053 additions and 176 deletions

View File

@@ -240,7 +240,7 @@ void ClientHandler::OnDownloadUpdated(
bool ClientHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData,
DragOperationsMask mask) {
CefDragHandler::DragOperationsMask mask) {
REQUIRE_UI_THREAD();
// Forbid dragging of link URLs.
@@ -279,6 +279,22 @@ bool ClientHandler::OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
return false;
}
bool ClientHandler::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) {
if (browser->GetHost()->IsWindowRenderingDisabled()) {
// Cancel popups in off-screen rendering mode.
return true;
}
return false;
}
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
REQUIRE_UI_THREAD();
@@ -341,6 +357,11 @@ void ClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
if (m_BrowserId == browser->GetIdentifier()) {
// Free the browser pointer so that the browser can be destroyed
m_Browser = NULL;
if (m_OSRHandler.get()) {
m_OSRHandler->OnBeforeClose(browser);
m_OSRHandler = NULL;
}
} else if (browser->IsPopup()) {
// Remove from the browser popup list.
BrowserList::iterator bit = m_PopupBrowsers.begin();
@@ -491,6 +512,84 @@ void ClientHandler::OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
}
}
bool ClientHandler::GetRootScreenRect(CefRefPtr<CefBrowser> browser,
CefRect& rect) {
if (!m_OSRHandler.get())
return false;
return m_OSRHandler->GetRootScreenRect(browser, rect);
}
bool ClientHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) {
if (!m_OSRHandler.get())
return false;
return m_OSRHandler->GetViewRect(browser, rect);
}
bool ClientHandler::GetScreenPoint(CefRefPtr<CefBrowser> browser,
int viewX,
int viewY,
int& screenX,
int& screenY) {
if (!m_OSRHandler.get())
return false;
return m_OSRHandler->GetScreenPoint(browser, viewX, viewY, screenX, screenY);
}
bool ClientHandler::GetScreenInfo(CefRefPtr<CefBrowser> browser,
CefScreenInfo& screen_info) {
if (!m_OSRHandler.get())
return false;
return m_OSRHandler->GetScreenInfo(browser, screen_info);
}
void ClientHandler::OnPopupShow(CefRefPtr<CefBrowser> browser,
bool show) {
if (!m_OSRHandler.get())
return;
return m_OSRHandler->OnPopupShow(browser, show);
}
void ClientHandler::OnPopupSize(CefRefPtr<CefBrowser> browser,
const CefRect& rect) {
if (!m_OSRHandler.get())
return;
return m_OSRHandler->OnPopupSize(browser, rect);
}
void ClientHandler::OnPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
const void* buffer,
int width,
int height) {
if (!m_OSRHandler.get())
return;
m_OSRHandler->OnPaint(browser, type, dirtyRects, buffer, width, height);
}
void ClientHandler::OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor) {
if (!m_OSRHandler.get())
return;
m_OSRHandler->OnCursorChange(browser, cursor);
}
bool ClientHandler::StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,
CefRenderHandler::DragOperationsMask allowed_ops,
int x, int y) {
if (!m_OSRHandler.get())
return false;
return m_OSRHandler->StartDragging(browser, drag_data, allowed_ops, x, y);
}
void ClientHandler::UpdateDragCursor(CefRefPtr<CefBrowser> browser,
CefRenderHandler::DragOperation operation) {
if (!m_OSRHandler.get())
return;
m_OSRHandler->UpdateDragCursor(browser, operation);
}
void ClientHandler::SetMainHwnd(ClientWindowHandle hwnd) {
AutoLock lock_scope(this);
m_MainHwnd = hwnd;