Commit 54fd1633 authored by enne@chromium.org's avatar enne@chromium.org

Remove software paint path from WebTestProxy

BUG=none

Review URL: https://codereview.chromium.org/284073002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270959 0039d316-1c4b-4281-b951-d872f2087c98
parent d7760592
...@@ -397,19 +397,6 @@ string WebTestProxyBase::CaptureTree(bool debugRenderTree) { ...@@ -397,19 +397,6 @@ string WebTestProxyBase::CaptureTree(bool debugRenderTree) {
return dataUtf8; return dataUtf8;
} }
SkCanvas* WebTestProxyBase::CapturePixels() {
TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixels");
web_widget_->layout();
if (test_interfaces_->testRunner()->isPrinting())
PaintPagesWithBoundaries();
else
PaintInvalidatedRegion();
DrawSelectionRect(GetCanvas());
return GetCanvas();
}
void WebTestProxyBase::DrawSelectionRect(SkCanvas* canvas) { void WebTestProxyBase::DrawSelectionRect(SkCanvas* canvas) {
// See if we need to draw the selection bounds rect. Selection bounds // See if we need to draw the selection bounds rect. Selection bounds
// rect is the rect enclosing the (possibly transformed) selection. // rect is the rect enclosing the (possibly transformed) selection.
...@@ -472,55 +459,6 @@ void WebTestProxyBase::SetLogConsoleOutput(bool enabled) { ...@@ -472,55 +459,6 @@ void WebTestProxyBase::SetLogConsoleOutput(bool enabled) {
log_console_output_ = enabled; log_console_output_ = enabled;
} }
void WebTestProxyBase::PaintRect(const WebRect& rect) {
DCHECK(!is_painting_);
DCHECK(GetCanvas());
is_painting_ = true;
float deviceScaleFactor = GetWebView()->deviceScaleFactor();
int scaledX =
static_cast<int>(static_cast<float>(rect.x) * deviceScaleFactor);
int scaledY =
static_cast<int>(static_cast<float>(rect.y) * deviceScaleFactor);
int scaledWidth = static_cast<int>(
ceil(static_cast<float>(rect.width) * deviceScaleFactor));
int scaledHeight = static_cast<int>(
ceil(static_cast<float>(rect.height) * deviceScaleFactor));
WebRect deviceRect(scaledX, scaledY, scaledWidth, scaledHeight);
web_widget_->paint(GetCanvas(), deviceRect);
is_painting_ = false;
}
void WebTestProxyBase::PaintInvalidatedRegion() {
web_widget_->animate(0.0);
web_widget_->layout();
WebSize widgetSize = web_widget_->size();
WebRect clientRect(0, 0, widgetSize.width, widgetSize.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.
// Store the total area painted in total_paint. Then tell the gdk window
// to update that area after we're done painting it.
for (int i = 0; i < 3; ++i) {
// rect = intersect(paint_rect_ , clientRect)
WebRect damageRect = paint_rect_;
int left = max(damageRect.x, clientRect.x);
int top = max(damageRect.y, clientRect.y);
int right =
min(damageRect.x + damageRect.width, clientRect.x + clientRect.width);
int bottom =
min(damageRect.y + damageRect.height, clientRect.y + clientRect.height);
WebRect rect;
if (left < right && top < bottom)
rect = WebRect(left, top, right - left, bottom - top);
paint_rect_ = WebRect();
if (rect.isEmpty()) continue;
PaintRect(rect);
}
DCHECK(paint_rect_.isEmpty());
}
void WebTestProxyBase::PaintPagesWithBoundaries() { void WebTestProxyBase::PaintPagesWithBoundaries() {
DCHECK(!is_painting_); DCHECK(!is_painting_);
DCHECK(GetCanvas()); DCHECK(GetCanvas());
...@@ -563,15 +501,6 @@ SkCanvas* WebTestProxyBase::GetCanvas() { ...@@ -563,15 +501,6 @@ SkCanvas* WebTestProxyBase::GetCanvas() {
return canvas_.get(); return canvas_.get();
} }
void WebTestProxyBase::DisplayForSoftwareMode(const base::Closure& callback) {
const blink::WebSize& size = web_widget_->size();
WebRect rect(0, 0, size.width, size.height);
paint_rect_ = rect;
PaintInvalidatedRegion();
if (!callback.is_null()) callback.Run();
}
void WebTestProxyBase::DidDisplayAsync(const base::Closure& callback, void WebTestProxyBase::DidDisplayAsync(const base::Closure& callback,
const SkBitmap& bitmap) { const SkBitmap& bitmap) {
// Verify we actually composited. // Verify we actually composited.
...@@ -583,17 +512,7 @@ void WebTestProxyBase::DidDisplayAsync(const base::Closure& callback, ...@@ -583,17 +512,7 @@ void WebTestProxyBase::DidDisplayAsync(const base::Closure& callback,
void WebTestProxyBase::DisplayAsyncThen(const base::Closure& callback) { void WebTestProxyBase::DisplayAsyncThen(const base::Closure& callback) {
TRACE_EVENT0("shell", "WebTestProxyBase::DisplayAsyncThen"); TRACE_EVENT0("shell", "WebTestProxyBase::DisplayAsyncThen");
// TODO(danakj): Remove when we have kForceCompositingMode everywhere. CHECK(web_widget_->isAcceleratedCompositingActive());
if (!web_widget_->isAcceleratedCompositingActive()) {
TRACE_EVENT0("shell",
"WebTestProxyBase::DisplayAsyncThen "
"isAcceleratedCompositingActive false");
base::MessageLoopProxy::current()->PostTask(
FROM_HERE, base::Bind(&WebTestProxyBase::DisplayForSoftwareMode,
base::Unretained(this), callback));
return;
}
CapturePixelsAsync(base::Bind(&WebTestProxyBase::DidDisplayAsync, CapturePixelsAsync(base::Bind(&WebTestProxyBase::DidDisplayAsync,
base::Unretained(this), callback)); base::Unretained(this), callback));
} }
......
...@@ -104,7 +104,6 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback { ...@@ -104,7 +104,6 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback {
void MoveValidationMessage(const blink::WebRect& anchorInRootView); void MoveValidationMessage(const blink::WebRect& anchorInRootView);
std::string CaptureTree(bool debugRenderTree); std::string CaptureTree(bool debugRenderTree);
SkCanvas* CapturePixels();
void CapturePixelsForPrinting( void CapturePixelsForPrinting(
const base::Callback<void(const SkBitmap&)>& callback); const base::Callback<void(const SkBitmap&)>& callback);
void CapturePixelsAsync( void CapturePixelsAsync(
...@@ -225,14 +224,11 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback { ...@@ -225,14 +224,11 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback {
template <class, typename, typename> template <class, typename, typename>
friend class WebFrameTestProxy; friend class WebFrameTestProxy;
void LocationChangeDone(blink::WebFrame*); void LocationChangeDone(blink::WebFrame*);
void PaintRect(const blink::WebRect&);
void PaintInvalidatedRegion();
void PaintPagesWithBoundaries(); void PaintPagesWithBoundaries();
SkCanvas* GetCanvas(); SkCanvas* GetCanvas();
void InvalidateAll(); void InvalidateAll();
void AnimateNow(); void AnimateNow();
void DrawSelectionRect(SkCanvas* canvas); void DrawSelectionRect(SkCanvas* canvas);
void DisplayForSoftwareMode(const base::Closure& callback);
void DidDisplayAsync(const base::Closure& callback, const SkBitmap& bitmap); void DidDisplayAsync(const base::Closure& callback, const SkBitmap& bitmap);
blink::WebWidget* web_widget() const { return web_widget_; } blink::WebWidget* web_widget() const { return web_widget_; }
......
...@@ -98,32 +98,6 @@ void InvokeTaskHelper(void* context) { ...@@ -98,32 +98,6 @@ void InvokeTaskHelper(void* context) {
delete task; delete task;
} }
#if !defined(OS_MACOSX)
void MakeBitmapOpaque(SkBitmap* bitmap) {
SkAutoLockPixels lock(*bitmap);
DCHECK_EQ(bitmap->config(), SkBitmap::kARGB_8888_Config);
for (int y = 0; y < bitmap->height(); ++y) {
uint32_t* row = bitmap->getAddr32(0, y);
for (int x = 0; x < bitmap->width(); ++x)
row[x] |= 0xFF000000; // Set alpha bits to 1.
}
}
#endif
void CopyCanvasToBitmap(SkCanvas* canvas, SkBitmap* snapshot) {
SkBaseDevice* device = skia::GetTopDevice(*canvas);
const SkBitmap& bitmap = device->accessBitmap(false);
const bool success = bitmap.copyTo(snapshot, kPMColor_SkColorType);
DCHECK(success);
#if !defined(OS_MACOSX)
// Only the expected PNGs for Mac have a valid alpha channel.
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableOverlayFullscreenVideo))
MakeBitmapOpaque(snapshot);
#endif
}
class SyncNavigationStateVisitor : public RenderViewVisitor { class SyncNavigationStateVisitor : public RenderViewVisitor {
public: public:
SyncNavigationStateVisitor() {} SyncNavigationStateVisitor() {}
...@@ -653,15 +627,9 @@ void WebKitTestRunner::CaptureDump() { ...@@ -653,15 +627,9 @@ void WebKitTestRunner::CaptureDump() {
if (test_config_.enable_pixel_dumping && if (test_config_.enable_pixel_dumping &&
interfaces->testRunner()->shouldGeneratePixelResults()) { interfaces->testRunner()->shouldGeneratePixelResults()) {
// TODO(danakj): Remove when kForceCompositingMode is everywhere. CHECK(render_view()->GetWebView()->isAcceleratedCompositingActive());
if (!render_view()->GetWebView()->isAcceleratedCompositingActive()) { proxy()->CapturePixelsAsync(base::Bind(
SkBitmap snapshot; &WebKitTestRunner::CaptureDumpPixels, base::Unretained(this)));
CopyCanvasToBitmap(proxy()->CapturePixels(), &snapshot);
CaptureDumpPixels(snapshot);
} else {
proxy()->CapturePixelsAsync(base::Bind(
&WebKitTestRunner::CaptureDumpPixels, base::Unretained(this)));
}
return; return;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment