| Index: webkit/tools/test_shell/webwidget_host_win.cc
|
| ===================================================================
|
| --- webkit/tools/test_shell/webwidget_host_win.cc (revision 73503)
|
| +++ webkit/tools/test_shell/webwidget_host_win.cc (working copy)
|
| @@ -21,6 +21,7 @@
|
| using WebKit::WebKeyboardEvent;
|
| using WebKit::WebMouseEvent;
|
| using WebKit::WebMouseWheelEvent;
|
| +using WebKit::WebPaintSurface;
|
| using WebKit::WebPopupMenu;
|
| using WebKit::WebScreenInfo;
|
| using WebKit::WebScreenInfoFactory;
|
| @@ -137,6 +138,22 @@
|
| return DefWindowProc(hwnd, message, wparam, lparam);;
|
| }
|
|
|
| +#if WEBKIT_USING_PAINTSURFACE
|
| +
|
| +WebPaintSurface* WebWidgetHost::GetPaintSurface() {
|
| + gfx::Size widget_size = webwidget_->size();
|
| + if (!paint_surface_.get() || paint_surface_->size() != widget_size) {
|
| + // This may result in discarding a previously allocated paint surface,
|
| + // which had not yet been fully rendered (see DidModifyPaintSurface).
|
| + pending_paint_surface_.reset(
|
| + new SimpleWebPaintSurfaceImpl(this, widget_size));
|
| + return pending_paint_surface_.get();
|
| + }
|
| + return paint_surface_.get();
|
| +}
|
| +
|
| +#else // WEBKIT_USING_PAINTSURFACE
|
| +
|
| void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) {
|
| DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
|
|
|
| @@ -176,6 +193,8 @@
|
| InvalidateRect(view_, &r, FALSE);
|
| }
|
|
|
| +#endif // WEBKIT_USING_PAINTSURFACE
|
| +
|
| void WebWidgetHost::ScheduleComposite() {
|
| if (!webwidget_)
|
| return;
|
| @@ -231,6 +250,49 @@
|
| }
|
|
|
| void WebWidgetHost::Paint() {
|
| +#if WEBKIT_USING_PAINTSURFACE
|
| + // Paint to the screen
|
| + PAINTSTRUCT ps;
|
| + BeginPaint(view_, &ps);
|
| +
|
| + gfx::Rect damage_rect(ps.rcPaint);
|
| + gfx::Rect canvas_rect;
|
| +
|
| + if (paint_surface_.get()) {
|
| + canvas_rect.set_size(paint_surface_->size());
|
| + canvas_rect = canvas_rect.Intersect(damage_rect);
|
| + if (!canvas_rect.IsEmpty()) {
|
| + skia::PlatformCanvas* canvas = paint_surface_->canvas();
|
| + canvas->getTopPlatformDevice().drawToHDC(ps.hdc,
|
| + canvas_rect.x(),
|
| + canvas_rect.y(),
|
| + &canvas_rect.ToRECT());
|
| + }
|
| + }
|
| +
|
| + if (damage_rect.right() > canvas_rect.right()) {
|
| + // Paint right edge.
|
| + gfx::Rect r(canvas_rect.right(),
|
| + damage_rect.y(),
|
| + damage_rect.right() - canvas_rect.right(),
|
| + damage_rect.height());
|
| + FillRect(ps.hdc, &r.ToRECT(), (HBRUSH)GetStockObject(WHITE_BRUSH));
|
| + }
|
| +
|
| + if (damage_rect.bottom() > canvas_rect.bottom()) {
|
| + // Paint bottom edge, possibly overpainting the corner for simplicity.
|
| + gfx::Rect r(damage_rect.x(),
|
| + canvas_rect.bottom(),
|
| + damage_rect.width(),
|
| + damage_rect.bottom() - canvas_rect.bottom());
|
| + FillRect(ps.hdc, &r.ToRECT(), (HBRUSH)GetStockObject(WHITE_BRUSH));
|
| + }
|
| +
|
| + EndPaint(view_, &ps);
|
| +
|
| + if (paint_surface_.get())
|
| + paint_surface_->DidCopyPaintSurface();
|
| +#else
|
| RECT r;
|
| GetClientRect(view_, &r);
|
| gfx::Rect client_rect(r);
|
| @@ -286,6 +348,7 @@
|
|
|
| // Draw children
|
| UpdateWindow(view_);
|
| +#endif
|
| }
|
|
|
| WebScreenInfo WebWidgetHost::GetScreenInfo() {
|
| @@ -371,6 +434,15 @@
|
| scroll_dy_ = 0;
|
| }
|
|
|
| +void WebWidgetHost::DidModifyPaintSurface(const gfx::Rect& bounds) {
|
| + // If there is a pending paint surface, then we can now consider it
|
| + // up-to-date and usable.
|
| + if (pending_paint_surface_.get())
|
| + paint_surface_.reset(pending_paint_surface_.release());
|
| +
|
| + InvalidateRect(view_, &bounds.ToRECT(), FALSE);
|
| +}
|
| +
|
| void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
|
| #ifndef NDEBUG
|
| DCHECK(!painting_);
|
|
|