From f62811f06574edc686c25f4bac35e2a0efe96615 Mon Sep 17 00:00:00 2001 From: "jochen@chromium.org" Date: Thu, 14 Feb 2013 09:55:49 +0000 Subject: [content shell] remove paint methods from WebKitTestRunner This is in preparation of the TestRunner library doing all the painting BUG=111316 R=marja@chromium.org Review URL: https://codereview.chromium.org/12207175 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182435 0039d316-1c4b-4281-b951-d872f2087c98 --- content/shell/webkit_test_runner.cc | 98 +------------------------------------ content/shell/webkit_test_runner.h | 5 -- 2 files changed, 2 insertions(+), 101 deletions(-) (limited to 'content') diff --git a/content/shell/webkit_test_runner.cc b/content/shell/webkit_test_runner.cc index 4ee07e3..004f73b 100644 --- a/content/shell/webkit_test_runner.cc +++ b/content/shell/webkit_test_runner.cc @@ -491,38 +491,9 @@ void WebKitTestRunner::CaptureTextDump() { } void WebKitTestRunner::CaptureImageDump() { - SkBitmap snapshot; - PaintInvalidatedRegion(); - CopyCanvasToBitmap(GetCanvas(), &snapshot); - - SkAutoLockPixels snapshot_lock(snapshot); - base::MD5Digest digest; -#if defined(OS_ANDROID) - // On Android, pixel layout is RGBA, however, other Chrome platforms use BGRA. - const uint8_t* raw_pixels = - reinterpret_cast(snapshot.getPixels()); - size_t snapshot_size = snapshot.getSize(); - scoped_array reordered_pixels(new uint8_t[snapshot_size]); - for (size_t i = 0; i < snapshot_size; i += 4) { - reordered_pixels[i] = raw_pixels[i + 2]; - reordered_pixels[i + 1] = raw_pixels[i + 1]; - reordered_pixels[i + 2] = raw_pixels[i]; - reordered_pixels[i + 3] = raw_pixels[i + 3]; - } - base::MD5Sum(reordered_pixels.get(), snapshot_size, &digest); -#else - base::MD5Sum(snapshot.getPixels(), snapshot.getSize(), &digest); -#endif - std::string actual_pixel_hash = base::MD5DigestToBase16(digest); - - if (actual_pixel_hash == expected_pixel_hash_) { - SkBitmap empty_image; - Send(new ShellViewHostMsg_ImageDump( - routing_id(), actual_pixel_hash, empty_image)); - return; - } + SkBitmap empty_image; Send(new ShellViewHostMsg_ImageDump( - routing_id(), actual_pixel_hash, snapshot)); + routing_id(), expected_pixel_hash_, empty_image)); } void WebKitTestRunner::OnSetTestConfiguration( @@ -538,69 +509,4 @@ void WebKitTestRunner::OnSetTestConfiguration( expected_pixel_hash_ = expected_pixel_hash; } -SkCanvas* WebKitTestRunner::GetCanvas() { - WebView* view = render_view()->GetWebView(); - const WebSize& size = view->size(); - float device_scale_factor = view->deviceScaleFactor(); - int width = std::ceil(device_scale_factor * size.width); - int height = std::ceil(device_scale_factor * size.height); - - if (canvas_ && - canvas_->getDeviceSize().width() == width && - canvas_->getDeviceSize().height() == height) { - return canvas_.get(); - } - canvas_.reset(skia::CreatePlatformCanvas( - size.width, size.height, true, 0, skia::RETURN_NULL_ON_FAILURE)); - return canvas_.get(); -} - -void WebKitTestRunner::PaintRect(const WebRect& rect) { - WebView* view = render_view()->GetWebView(); - float device_scale_factor = view->deviceScaleFactor(); - int scaled_x = device_scale_factor * rect.x; - int scaled_y = device_scale_factor * rect.y; - int scaled_width = std::ceil(device_scale_factor * rect.width); - int scaled_height = std::ceil(device_scale_factor * rect.height); - // TODO(jochen): Verify that the scaling is correct once the HiDPI tests - // actually work. - WebRect device_rect(scaled_x, scaled_y, scaled_width, scaled_height); - view->paint(webkit_glue::ToWebCanvas(GetCanvas()), device_rect); -} - -void WebKitTestRunner::PaintInvalidatedRegion() { - WebView* view = render_view()->GetWebView(); - view->animate(0.0); - view->layout(); - const WebSize& widget_size = view->size(); - WebRect client_rect(0, 0, widget_size.width, widget_size.height); - - // Paint the canvas if necessary. Allow painting to generate extra rects - // for the first two calls. This is necessary because some WebCore rendering - // objects update their layout only when painted. - for (int i = 0; i < 3; ++i) { - // Make sure that paint_rect is always inside the RenderView's visible - // area. - WebRect paint_rect = proxy_->paintRect(); - int left = std::max(paint_rect.x, client_rect.x); - int top = std::max(paint_rect.y, client_rect.y); - int right = std::min(paint_rect.x + paint_rect.width, - client_rect.x + client_rect.width); - int bottom = std::min(paint_rect.y + paint_rect.height, - client_rect.y + client_rect.height); - WebRect rect; - if (left < right && top < bottom) - rect = WebRect(left, top, right - left, bottom - top); - proxy_->setPaintRect(WebRect()); - if (rect.isEmpty()) - continue; - PaintRect(rect); - } - CHECK(proxy_->paintRect().isEmpty()); -} - -void WebKitTestRunner::DisplayRepaintMask() { - GetCanvas()->drawARGB(167, 0, 0, 0); -} - } // namespace content diff --git a/content/shell/webkit_test_runner.h b/content/shell/webkit_test_runner.h index cf23b5f..e4c0b1f 100644 --- a/content/shell/webkit_test_runner.h +++ b/content/shell/webkit_test_runner.h @@ -87,12 +87,7 @@ class WebKitTestRunner : public RenderViewObserver, void CaptureDump(); void CaptureTextDump(); void CaptureImageDump(); - SkCanvas* GetCanvas(); - void PaintRect(const WebKit::WebRect& rect); - void PaintInvalidatedRegion(); - void DisplayRepaintMask(); - scoped_ptr canvas_; scoped_ptr last_context_menu_data_; base::FilePath current_working_directory_; -- cgit v1.1