Add support for begin frame scheduling and direct rendering when GPU compositing is disabled (issue #1368).

- Always set the browser process VSync rate (frame rate) to CefSettings.windowless_frame_rate.
- When the `enable-begin-frame-scheduling` command-line flag is specified the VSync rate for all processes will be synchronized to CefSettings.windowless_frame_rate. This flag cannot be used in combination with windowed rendering.
- When the `disable-gpu` and `disable-gpu-compositing` command-line flags are specified the CefRenderHandler::OnPaint method will be called directly from the compositor instead of requiring an additional copy for each frame.
- CefRenderHandler::OnPopupSize now passes view coordinates instead of (potentially scaled) pixel coordinates.
- Add OSR unit tests for 2x (HiDPI) pixel scaling.
- Improve CefRenderHandler documentation.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1960 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2015-01-01 16:51:56 +00:00
parent 3aec2e1a72
commit d0a45cfbbb
12 changed files with 1016 additions and 457 deletions

View File

@@ -82,6 +82,7 @@ class ScopedGLContext {
button: (CefBrowserHost::MouseButtonType)type
isUp: (bool)isUp;
- (CefRect) convertRectToBackingInternal: (const CefRect&) rect;
- (CefRect) convertRectFromBackingInternal: (const CefRect&) rect;
@property (readwrite, atomic) bool was_last_mouse_down_on_view;
@@ -235,7 +236,8 @@ void ClientOSRHandler::OnPopupSize(CefRefPtr<CefBrowser> browser,
if (!view_)
return;
view_->renderer_->OnPopupSize(browser, rect);
view_->renderer_->OnPopupSize(browser,
[view_ convertRectToBackingInternal:rect]);
}
void ClientOSRHandler::OnPaint(CefRefPtr<CefBrowser> browser,
@@ -259,10 +261,6 @@ void ClientOSRHandler::OnPaint(CefRefPtr<CefBrowser> browser,
if (type == PET_VIEW && !view_->renderer_->popup_rect().IsEmpty()) {
painting_popup_ = true;
CefRect client_popup_rect(0, 0,
view_->renderer_->popup_rect().width,
view_->renderer_->popup_rect().height);
browser->GetHost()->Invalidate(PET_POPUP);
painting_popup_ = false;
}
@@ -333,7 +331,8 @@ void ClientOSRHandler::SetLoading(bool isLoading) {
[self addTrackingArea:tracking_area_];
}
if ([self respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
if ([self respondsToSelector:
@selector(setWantsBestResolutionOpenGLSurface:)]) {
// enable HiDPI buffer
[self setWantsBestResolutionOpenGLSurface:YES];
}
@@ -1193,10 +1192,11 @@ void ClientOSRHandler::SetLoading(bool isLoading) {
}
}
- (CefRect) convertRectFromBackingInternal: (const CefRect&) rect {
if ([self respondsToSelector:@selector(convertRectFromBacking:)]) {
NSRect old_rect = NSMakeRect(rect.x, rect.y, rect.width, rect.height);
NSRect scaled_rect = [self convertRectFromBacking:old_rect];
// Convert the rect from view coordinates to scaled coordinates.
- (CefRect) convertRectToBackingInternal: (const CefRect&) rect {
if ([self respondsToSelector:@selector(convertRectToBacking:)]) {
NSRect view_rect = NSMakeRect(rect.x, rect.y, rect.width, rect.height);
NSRect scaled_rect = [self convertRectToBacking:view_rect];
return CefRect((int)scaled_rect.origin.x,
(int)scaled_rect.origin.y,
(int)scaled_rect.size.width,
@@ -1206,6 +1206,20 @@ void ClientOSRHandler::SetLoading(bool isLoading) {
return rect;
}
// Convert the rect from scaled coordinates to view coordinates.
- (CefRect) convertRectFromBackingInternal: (const CefRect&) rect {
if ([self respondsToSelector:@selector(convertRectFromBacking:)]) {
NSRect scaled_rect = NSMakeRect(rect.x, rect.y, rect.width, rect.height);
NSRect view_rect = [self convertRectFromBacking:scaled_rect];
return CefRect((int)view_rect.origin.x,
(int)view_rect.origin.y,
(int)view_rect.size.width,
(int)view_rect.size.height);
}
return rect;
}
@end

View File

@@ -27,6 +27,7 @@ class ClientOSRenderer {
// Forwarded from CefRenderHandler callbacks.
void OnPopupShow(CefRefPtr<CefBrowser> browser,
bool show);
// |rect| must be in pixel coordinates.
void OnPopupSize(CefRefPtr<CefBrowser> browser,
const CefRect& rect);
void OnPaint(CefRefPtr<CefBrowser> browser,