Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: webkit/tools/test_shell/mac/webwidget_host.mm

Issue 21192: Add support for the "repaint" layout tests (LayoutTests/fast/repaint/*), whic... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/tools/test_shell/mac/webwidget_host.mm
===================================================================
--- webkit/tools/test_shell/mac/webwidget_host.mm (revision 9433)
+++ webkit/tools/test_shell/mac/webwidget_host.mm (working copy)
@@ -144,10 +144,14 @@
}
void WebWidgetHost::Paint() {
+ PaintToCanvas();
+ PaintCanvasToView();
+}
+
+void WebWidgetHost::PaintToCanvas() {
NSRect r = [view_ frame];
gfx::Rect client_rect(NSRectToCGRect(r));
NSGraphicsContext* view_context = [NSGraphicsContext currentContext];
- CGContextRef context = static_cast<CGContextRef>([view_context graphicsPort]);
// Allocate a canvas if necessary
if (!canvas_.get()) {
@@ -192,21 +196,45 @@
// set the context back to our window
[NSGraphicsContext setCurrentContext: view_context];
+}
+void WebWidgetHost::PaintCanvasToView() {
// Paint to the screen
if ([view_ lockFocusIfCanDraw]) {
+ NSGraphicsContext* view_context = [NSGraphicsContext currentContext];
+ NSRect r = [view_ frame];
+ CGContextRef bitmap_context =
+ canvas_->getTopPlatformDevice().GetBitmapContext();
+ CGContextRef context =
+ static_cast<CGContextRef>([view_context graphicsPort]);
CGRect paint_rect = NSRectToCGRect(r);
int bitmap_height = CGBitmapContextGetHeight(bitmap_context);
int bitmap_width = CGBitmapContextGetWidth(bitmap_context);
CGRect bitmap_rect = { { 0, 0 },
{ bitmap_width, bitmap_height } };
canvas_->getTopPlatformDevice().DrawToContext(
- context, 0, client_rect.height() - bitmap_height, &bitmap_rect);
+ context, 0, r.size.height - bitmap_height, &bitmap_rect);
[view_ unlockFocus];
}
}
+void WebWidgetHost::DisplayForRepaint() {
+ PaintToCanvas();
+
+ // Paint a gray mask over everything for the repaint Layout tests.
+ CGContextRef bitmap_context =
+ canvas_->getTopPlatformDevice().GetBitmapContext();
+ CGRect bitmap_rect = { { 0, 0 },
+ { CGBitmapContextGetWidth(bitmap_context),
+ CGBitmapContextGetHeight(bitmap_context) } };
+ CGContextSetBlendMode(bitmap_context, kCGBlendModeNormal);
+ CGContextSetRGBFillColor(bitmap_context, 0, 0, 0, 0.66);
+ CGContextFillRect(bitmap_context, bitmap_rect);
+
+ PaintCanvasToView();
+}
+
void WebWidgetHost::Resize(const gfx::Rect& rect) {
// Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer.
DiscardBackingStore();

Powered by Google App Engine
This is Rietveld 408576698