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

@@ -3,7 +3,6 @@
// that can be found in the LICENSE file.
#include "cefclient/osrenderer.h"
#include "cefclient/util.h"
#if defined(OS_WIN)
#include <gl/gl.h>
@@ -14,6 +13,8 @@
#error Platform is not supported.
#endif
#include "cefclient/util.h"
#ifndef GL_BGR
#define GL_BGR 0x80E0
#endif
@@ -141,18 +142,41 @@ void ClientOSRenderer::Render() {
void ClientOSRenderer::OnPopupShow(CefRefPtr<CefBrowser> browser,
bool show) {
if (!show) {
// Invalidate the previous popup rectangle so that it will be repainted.
browser->GetHost()->Invalidate(popup_rect_);
// Clear the popup rectangle.
CefRect popup_rect = popup_rect_;
popup_rect_.Set(0, 0, 0, 0);
original_popup_rect_.Set(0, 0, 0, 0);
// Invalidate the previous popup rectangle so that it will be repainted.
browser->GetHost()->Invalidate(popup_rect, PET_VIEW);
}
}
void ClientOSRenderer::OnPopupSize(CefRefPtr<CefBrowser> browser,
const CefRect& rect) {
if (rect.width > 0 && rect.height > 0)
popup_rect_ = rect;
if (rect.width <= 0 || rect.height <= 0)
return;
original_popup_rect_ = rect;
popup_rect_ = GetPopupRectInWebView(original_popup_rect_);
}
CefRect ClientOSRenderer::GetPopupRectInWebView(const CefRect& original_rect) {
CefRect rc(original_rect);
// if x or y are negative, move them to 0.
if (rc.x < 0)
rc.x = 0;
if (rc.y < 0)
rc.y = 0;
// if popup goes outside the view, try to reposition origin
if (rc.x + rc.width > view_width_)
rc.x = view_width_ - rc.width;
if (rc.y + rc.height > view_height_)
rc.y = view_height_ - rc.height;
// if x or y became negative, move them to 0 again.
if (rc.x < 0)
rc.x = 0;
if (rc.y < 0)
rc.y = 0;
return rc;
}
void ClientOSRenderer::OnPaint(CefRefPtr<CefBrowser> browser,
@@ -204,8 +228,8 @@ void ClientOSRenderer::OnPaint(CefRefPtr<CefBrowser> browser,
popup_rect_.height > 0) {
int skip_pixels = 0, x = popup_rect_.x;
int skip_rows = 0, y = popup_rect_.y;
int width = popup_rect_.width;
int height = popup_rect_.height;
int w = width;
int h = height;
// Adjust the popup to fit inside the view.
if (x < 0) {
@@ -216,16 +240,16 @@ void ClientOSRenderer::OnPaint(CefRefPtr<CefBrowser> browser,
skip_rows = -y;
y = 0;
}
if (x + width > view_width_)
width -= x + width - view_width_;
if (y + height > view_height_)
height -= y + height - view_height_;
if (x + w > view_width_)
w -= x + w - view_width_;
if (y + h > view_height_)
h -= y + h - view_height_;
// Update the popup rectangle.
glPixelStorei(GL_UNPACK_ROW_LENGTH, popup_rect_.width);
glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_BGRA,
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV, buffer);
}