Windows: Improvements to off-screen rendering support (issue #518).

- Implement support for transparency. Change the backing store to use Skia instead of GDI and to keep alpha values.
- Implement support for select popups. Requires a patch to Chromium (content_popups.patch).
- Implicitly disable accelerated compositing when using off-screen rendering.
- Introduce a new CefMouseEvent structure for representing mouse event information passed to CefBrowser methods.
- Merge cef_key_event_modifiers_t into cef_event_flags_t.
- Add a new argument to CefBrowser::Invalidate telling the browser whether to invalidate the select popup or the main view.
- Add a new cefclient "transparent-painting-enabled" command-line flag to test transparent off-screen rendering.
- Add a new cefclient "Transparency" test.
- Fix the cefclient off-screen rendering rotation effect to work even when the underlying web content is not updating.
- Add unit tests for transparent painting and select popups.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@979 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2013-01-11 23:00:39 +00:00
parent a463095bd9
commit 7d3bac19a9
41 changed files with 1571 additions and 470 deletions

View File

@@ -318,7 +318,7 @@ typedef struct _cef_browser_host_t {
// function is only used when window rendering is disabled.
///
void (CEF_CALLBACK *invalidate)(struct _cef_browser_host_t* self,
const cef_rect_t* dirtyRect);
const cef_rect_t* dirtyRect, enum cef_paint_element_type_t type);
///
// Send a key event to the browser.
@@ -331,23 +331,25 @@ typedef struct _cef_browser_host_t {
// relative to the upper-left corner of the view.
///
void (CEF_CALLBACK *send_mouse_click_event)(struct _cef_browser_host_t* self,
int x, int y, enum cef_mouse_button_type_t type, int mouseUp,
int clickCount);
const struct _cef_mouse_event_t* event,
enum cef_mouse_button_type_t type, int mouseUp, int clickCount);
///
// Send a mouse move event to the browser. The |x| and |y| coordinates are
// relative to the upper-left corner of the view.
///
void (CEF_CALLBACK *send_mouse_move_event)(struct _cef_browser_host_t* self,
int x, int y, int mouseLeave);
const struct _cef_mouse_event_t* event, int mouseLeave);
///
// Send a mouse wheel event to the browser. The |x| and |y| coordinates are
// relative to the upper-left corner of the view. The |deltaX| and |deltaY|
// values represent the movement delta in the X and Y directions respectively.
// In order to scroll inside select popups with window rendering disabled
// cef_render_handler_t::GetScreenPoint should be implemented properly.
///
void (CEF_CALLBACK *send_mouse_wheel_event)(struct _cef_browser_host_t* self,
int x, int y, int deltaX, int deltaY);
const struct _cef_mouse_event_t* event, int deltaX, int deltaY);
///
// Send a focus event to the browser.

View File

@@ -57,8 +57,7 @@ typedef struct _cef_render_handler_t {
///
// Called to retrieve the root window rectangle in screen coordinates. Return
// true (1) if the rectangle was provided. Return false (0) if the screen
// rectangle is the same as the view rectangle.
// true (1) if the rectangle was provided.
///
int (CEF_CALLBACK *get_root_screen_rect)(struct _cef_render_handler_t* self,
struct _cef_browser_t* browser, cef_rect_t* rect);
@@ -81,15 +80,13 @@ typedef struct _cef_render_handler_t {
///
// Called when the browser wants to show or hide the popup widget. The popup
// should be shown if |show| is true (1) and hidden if |show| is false (0).
// NOTE: Popup widgets are not yet supported.
///
void (CEF_CALLBACK *on_popup_show)(struct _cef_render_handler_t* self,
struct _cef_browser_t* browser, int show);
///
// Called when the browser wants to move or resize the popup widget. |rect|
// contains the new location and size. NOTE: Popup widgets are not yet
// supported.
// contains the new location and size.
///
void (CEF_CALLBACK *on_popup_size)(struct _cef_render_handler_t* self,
struct _cef_browser_t* browser, const cef_rect_t* rect);
@@ -99,8 +96,7 @@ 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. NOTE: Popup
// widgets are not yet supported.
// size and represents a BGRA image with an upper-left origin.
///
void (CEF_CALLBACK *on_paint)(struct _cef_render_handler_t* self,
struct _cef_browser_t* browser, enum cef_paint_element_type_t type,

View File

@@ -219,6 +219,7 @@ class CefBrowserHost : public virtual CefBase {
public:
typedef cef_file_dialog_mode_t FileDialogMode;
typedef cef_mouse_button_type_t MouseButtonType;
typedef cef_paint_element_type_t PaintElementType;
///
// Create a new browser window using the window parameters specified by
@@ -359,7 +360,7 @@ class CefBrowserHost : public virtual CefBase {
// method is only used when window rendering is disabled.
///
/*--cef()--*/
virtual void Invalidate(const CefRect& dirtyRect) =0;
virtual void Invalidate(const CefRect& dirtyRect, PaintElementType type) =0;
///
// Send a key event to the browser.
@@ -372,7 +373,8 @@ class CefBrowserHost : public virtual CefBase {
// relative to the upper-left corner of the view.
///
/*--cef()--*/
virtual void SendMouseClickEvent(int x, int y, MouseButtonType type,
virtual void SendMouseClickEvent(const CefMouseEvent& event,
MouseButtonType type,
bool mouseUp, int clickCount) =0;
///
@@ -380,15 +382,19 @@ class CefBrowserHost : public virtual CefBase {
// relative to the upper-left corner of the view.
///
/*--cef()--*/
virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave) =0;
virtual void SendMouseMoveEvent(const CefMouseEvent& event,
bool mouseLeave) =0;
///
// Send a mouse wheel event to the browser. The |x| and |y| coordinates are
// relative to the upper-left corner of the view. The |deltaX| and |deltaY|
// values represent the movement delta in the X and Y directions respectively.
// In order to scroll inside select popups with window rendering disabled
// CefRenderHandler::GetScreenPoint should be implemented properly.
///
/*--cef()--*/
virtual void SendMouseWheelEvent(int x, int y, int deltaX, int deltaY) =0;
virtual void SendMouseWheelEvent(const CefMouseEvent& event,
int deltaX, int deltaY) =0;
///
// Send a focus event to the browser.

View File

@@ -54,8 +54,7 @@ class CefRenderHandler : public virtual CefBase {
///
// Called to retrieve the root window rectangle in screen coordinates. Return
// true if the rectangle was provided. Return false if the screen rectangle is
// the same as the view rectangle.
// true if the rectangle was provided.
///
/*--cef()--*/
virtual bool GetRootScreenRect(CefRefPtr<CefBrowser> browser,
@@ -82,7 +81,6 @@ class CefRenderHandler : public virtual CefBase {
///
// Called when the browser wants to show or hide the popup widget. The popup
// should be shown if |show| is true and hidden if |show| is false.
// NOTE: Popup widgets are not yet supported.
///
/*--cef()--*/
virtual void OnPopupShow(CefRefPtr<CefBrowser> browser,
@@ -91,7 +89,6 @@ class CefRenderHandler : public virtual CefBase {
///
// Called when the browser wants to move or resize the popup widget. |rect|
// contains the new location and size.
// NOTE: Popup widgets are not yet supported.
///
/*--cef()--*/
virtual void OnPopupSize(CefRefPtr<CefBrowser> browser,
@@ -103,7 +100,6 @@ class CefRenderHandler : public virtual CefBase {
// 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.
// NOTE: Popup widgets are not yet supported.
///
/*--cef()--*/
virtual void OnPaint(CefRefPtr<CefBrowser> browser,

View File

@@ -975,6 +975,27 @@ enum cef_mouse_button_type_t {
MBT_RIGHT,
};
///
// Structure representing mouse event information.
///
typedef struct _cef_mouse_event_t {
///
// X coordinate relative to the left side of the view.
///
int x;
///
// Y coordinate relative to the top side of the view.
///
int y;
///
// Bit flags describing any pressed modifier keys. See
// cef_event_flags_t for values.
///
uint32 modifiers;
} cef_mouse_event_t;
///
// Paint element types.
///
@@ -988,7 +1009,7 @@ enum cef_paint_element_type_t {
///
enum cef_event_flags_t {
EVENTFLAG_NONE = 0,
EVENTFLAG_CAPS_LOCK_DOWN = 1 << 0,
EVENTFLAG_CAPS_LOCK_ON = 1 << 0,
EVENTFLAG_SHIFT_DOWN = 1 << 1,
EVENTFLAG_CONTROL_DOWN = 1 << 2,
EVENTFLAG_ALT_DOWN = 1 << 3,
@@ -997,8 +1018,10 @@ enum cef_event_flags_t {
EVENTFLAG_RIGHT_MOUSE_BUTTON = 1 << 6,
// Mac OS-X command key.
EVENTFLAG_COMMAND_DOWN = 1 << 7,
// Windows extended key (see WM_KEYDOWN doc).
EVENTFLAG_EXTENDED = 1 << 8,
EVENTFLAG_NUM_LOCK_ON = 1 << 8,
EVENTFLAG_IS_KEY_PAD = 1 << 9,
EVENTFLAG_IS_LEFT = 1 << 10,
EVENTFLAG_IS_RIGHT = 1 << 11,
};
///
@@ -1119,17 +1142,6 @@ enum cef_key_event_type_t {
KEYEVENT_CHAR
};
///
// Key event modifiers.
///
enum cef_key_event_modifiers_t {
KEY_SHIFT = 1 << 0,
KEY_CTRL = 1 << 1,
KEY_ALT = 1 << 2,
KEY_META = 1 << 3,
KEY_KEYPAD = 1 << 4, // Only used on Mac OS-X
};
///
// Structure representing keyboard event information.
///
@@ -1141,9 +1153,9 @@ typedef struct _cef_key_event_t {
///
// Bit flags describing any pressed modifier keys. See
// cef_key_event_modifiers_t for values.
// cef_event_flags_t for values.
///
int modifiers;
uint32 modifiers;
///
// The Windows key code for the key event. This value is used by the DOM

View File

@@ -76,6 +76,9 @@ typedef struct _cef_window_info_t {
BOOL window_rendering_disabled;
// Set to true to enable transparent painting.
// If window rendering is disabled and |transparent_painting| is set to true
// WebKit rendering will draw on a transparent background (RGBA=0x00000000).
// When this value is false the background will be white and opaque.
BOOL transparent_painting;
// Handle for the new browser window.

View File

@@ -199,6 +199,25 @@ struct CefKeyEventTraits {
///
typedef CefStructBase<CefKeyEventTraits> CefKeyEvent;
struct CefMouseEventTraits {
typedef cef_mouse_event_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->x = src->x;
target->y = src->y;
target->modifiers = src->modifiers;
}
};
///
// Class representing a mouse event.
///
typedef CefStructBase<CefMouseEventTraits> CefMouseEvent;
struct CefPopupFeaturesTraits {
typedef cef_popup_features_t struct_type;