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

@ -72,6 +72,7 @@ class CefCriticalSection {
#define CefCursorHandle cef_cursor_handle_t
#define CefEventHandle cef_event_handle_t
#define CefWindowHandle cef_window_handle_t
#define CefTextInputContext cef_text_input_context_t
struct CefMainArgsTraits {
typedef cef_main_args_t struct_type;
@ -113,6 +114,8 @@ struct CefWindowInfoTraits {
target->width = src->width;
target->height = src->height;
target->parent_window = src->parent_window;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->transparent_painting_enabled = src->transparent_painting_enabled;
target->window = src->window;
}
};
@ -137,6 +140,24 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
width = windowRect.width;
height = windowRect.height;
}
///
// Create the browser using windowless (off-screen) rendering. No window
// will be created for the browser and all rendering will occur via the
// CefRenderHandler interface. The |parent| value will be used to identify
// monitor info and to act as the parent window for dialogs, context menus,
// etc. If |parent| is not provided then the main screen monitor will be used
// and some functionality that requires a parent window may not function
// correctly. If |transparent| is true a transparent background color will be
// used (RGBA=0x00000000). If |transparent| is false the background will be
// white and opaque. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
void SetAsWindowless(CefWindowHandle parent, bool transparent) {
windowless_rendering_enabled = true;
parent_window = parent;
transparent_painting_enabled = transparent;
}
};
#endif // OS_LINUX

View File

@ -72,6 +72,7 @@ class CefCriticalSection {
#define CefCursorHandle cef_cursor_handle_t
#define CefEventHandle cef_event_handle_t
#define CefWindowHandle cef_window_handle_t
#define CefTextInputContext cef_text_input_context_t
struct CefMainArgsTraits {
typedef cef_main_args_t struct_type;
@ -119,6 +120,8 @@ struct CefWindowInfoTraits {
target->height = src->height;
target->hidden = src->hidden;
target->parent_view = src->parent_view;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->transparent_painting_enabled = src->transparent_painting_enabled;
target->view = src->view;
}
};
@ -144,6 +147,24 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
this->height = height;
hidden = false;
}
///
// Create the browser using windowless (off-screen) rendering. No view
// will be created for the browser and all rendering will occur via the
// CefRenderHandler interface. The |parent| value will be used to identify
// monitor info and to act as the parent view for dialogs, context menus,
// etc. If |parent| is not provided then the main screen monitor will be used
// and some functionality that requires a parent view may not function
// correctly. If |transparent| is true a transparent background color will be
// used (RGBA=0x00000000). If |transparent| is false the background will be
// white and opaque. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
void SetAsWindowless(CefWindowHandle parent, bool transparent) {
windowless_rendering_enabled = true;
parent_view = parent;
transparent_painting_enabled = transparent;
}
};
#endif // OS_MACOSX

View File

@ -223,6 +223,13 @@ typedef struct _cef_settings_t {
///
int multi_threaded_message_loop;
///
// Set to true (1) to enable windowless (off-screen) rendering support. Do not
// enable this value if the application does not use windowless rendering as
// it may reduce rendering performance on some systems.
///
int windowless_rendering_enabled;
///
// Set to true (1) to disable configuration of browser process features using
// standard CEF and Chromium command-line arguments. Configuration can still
@ -393,6 +400,14 @@ typedef struct _cef_browser_settings_t {
///
size_t size;
///
// The maximum rate in frames per second (fps) that CefRenderHandler::OnPaint
// will be called for a windowless browser. The actual fps may be lower if
// the browser cannot generate frames at the requested rate. The minimum
// value is 1 and the maximum value is 60 (default 30).
///
int windowless_frame_rate;
// The below values map to WebPreferences settings.
///
@ -1306,6 +1321,14 @@ typedef struct _cef_mouse_event_t {
uint32 modifiers;
} cef_mouse_event_t;
///
// Paint element types.
///
typedef enum {
PET_VIEW = 0,
PET_POPUP,
} cef_paint_element_type_t;
///
// Supported event bit flags.
///

View File

@ -60,6 +60,7 @@ extern "C" {
// thread-safe and must only be accessed on the browser process UI thread.
///
CEF_EXPORT XDisplay* cef_get_xdisplay();
#define cef_text_input_context_t void*
///
// Structure representing CefExecuteProcess arguments.
@ -83,6 +84,26 @@ typedef struct _cef_window_info_t {
///
cef_window_handle_t parent_window;
///
// Set to true (1) to create the browser using windowless (off-screen)
// rendering. No window will be created for the browser and all rendering will
// occur via the CefRenderHandler interface. The |parent_window| value will be
// used to identify monitor info and to act as the parent window for dialogs,
// context menus, etc. If |parent_window| is not provided then the main screen
// monitor will be used and some functionality that requires a parent window
// may not function correctly. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
int windowless_rendering_enabled;
///
// Set to true (1) to enable transparent painting in combination with
// windowless rendering. When this value is true a transparent background
// color will be used (RGBA=0x00000000). When this value is false the
// background will be white and opaque.
///
int transparent_painting_enabled;
///
// Pointer for the new browser window. Only used with windowed rendering.
///

View File

@ -43,18 +43,22 @@
@class NSCursor;
@class NSEvent;
@class NSView;
@class NSTextInputContext;
#else
class NSCursor;
class NSEvent;
struct NSView;
class NSTextInputContext;
#endif
#define cef_cursor_handle_t NSCursor*
#define cef_event_handle_t NSEvent*
#define cef_window_handle_t NSView*
#define cef_text_input_context_t NSTextInputContext*
#else
#define cef_cursor_handle_t void*
#define cef_event_handle_t void*
#define cef_window_handle_t void*
#define cef_text_input_context_t void*
#endif
#define kNullCursorHandle NULL
@ -93,6 +97,26 @@ typedef struct _cef_window_info_t {
///
cef_window_handle_t parent_view;
///
// Set to true (1) to create the browser using windowless (off-screen)
// rendering. No view will be created for the browser and all rendering will
// occur via the CefRenderHandler interface. The |parent_view| value will be
// used to identify monitor info and to act as the parent view for dialogs,
// context menus, etc. If |parent_view| is not provided then the main screen
// monitor will be used and some functionality that requires a parent view
// may not function correctly. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
int windowless_rendering_enabled;
///
// Set to true (1) to enable transparent painting in combination with
// windowless rendering. When this value is true a transparent background
// color will be used (RGBA=0x00000000). When this value is false the
// background will be white and opaque.
///
int transparent_painting_enabled;
///
// NSView pointer for the new browser view. Only used with windowed rendering.
///

View File

@ -42,6 +42,7 @@
#define cef_cursor_handle_t HCURSOR
#define cef_event_handle_t MSG*
#define cef_window_handle_t HWND
#define cef_text_input_context_t void*
#define kNullCursorHandle NULL
#define kNullEventHandle NULL
@ -73,6 +74,26 @@ typedef struct _cef_window_info_t {
cef_window_handle_t parent_window;
HMENU menu;
///
// Set to true (1) to create the browser using windowless (off-screen)
// rendering. No window will be created for the browser and all rendering will
// occur via the CefRenderHandler interface. The |parent_window| value will be
// used to identify monitor info and to act as the parent window for dialogs,
// context menus, etc. If |parent_window| is not provided then the main screen
// monitor will be used and some functionality that requires a parent window
// may not function correctly. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
int windowless_rendering_enabled;
///
// Set to true (1) to enable transparent painting in combination with
// windowless rendering. When this value is true a transparent background
// color will be used (RGBA=0x00000000). When this value is false the
// background will be white and opaque.
///
int transparent_painting_enabled;
///
// Handle for the new browser window. Only used with windowed rendering.
///

View File

@ -349,6 +349,7 @@ struct CefSettingsTraits {
src->browser_subprocess_path.length,
&target->browser_subprocess_path, copy);
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->command_line_args_disabled = src->command_line_args_disabled;
cef_string_set(src->cache_path.str, src->cache_path.length,
@ -405,6 +406,8 @@ struct CefBrowserSettingsTraits {
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->windowless_frame_rate = src->windowless_frame_rate;
cef_string_set(src->standard_font_family.str,
src->standard_font_family.length, &target->standard_font_family, copy);
cef_string_set(src->fixed_font_family.str, src->fixed_font_family.length,

View File

@ -71,6 +71,7 @@ class CefCriticalSection {
#define CefCursorHandle cef_cursor_handle_t
#define CefEventHandle cef_event_handle_t
#define CefWindowHandle cef_window_handle_t
#define CefTextInputContext cef_text_input_context_t
struct CefMainArgsTraits {
typedef cef_main_args_t struct_type;
@ -118,6 +119,8 @@ struct CefWindowInfoTraits {
target->height = src->height;
target->parent_window = src->parent_window;
target->menu = src->menu;
target->transparent_painting_enabled = src->transparent_painting_enabled;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->window = src->window;
}
};
@ -160,6 +163,24 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
cef_string_copy(windowName.c_str(), windowName.length(), &window_name);
}
///
// Create the browser using windowless (off-screen) rendering. No window
// will be created for the browser and all rendering will occur via the
// CefRenderHandler interface. The |parent| value will be used to identify
// monitor info and to act as the parent window for dialogs, context menus,
// etc. If |parent| is not provided then the main screen monitor will be used
// and some functionality that requires a parent window may not function
// correctly. If |transparent| is true a transparent background color will be
// used (RGBA=0x00000000). If |transparent| is false the background will be
// white and opaque. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
void SetAsWindowless(CefWindowHandle parent, bool transparent) {
windowless_rendering_enabled = TRUE;
parent_window = parent;
transparent_painting_enabled = transparent;
}
};
#endif // OS_WIN