Title: [142929] trunk/Tools
Revision
142929
Author
joc...@chromium.org
Date
2013-02-14 15:49:53 -0800 (Thu, 14 Feb 2013)

Log Message

[chromium] move pixel generation logic to TestRunner library
https://bugs.webkit.org/show_bug.cgi?id=109686

Reviewed by Stephen White.

* DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:
* DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h:
* DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h:
(WebTestRunner):
* DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h:
* DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h:
(WebTestRunner):
* DumpRenderTree/chromium/TestRunner/src/TestInterfaces.cpp:
(WebTestRunner::TestInterfaces::~TestInterfaces):
(WebTestRunner::TestInterfaces::setWebView):
(WebTestRunner::TestInterfaces::proxy):
(WebTestRunner):
* DumpRenderTree/chromium/TestRunner/src/TestInterfaces.h:
(WebTestRunner):
(TestInterfaces):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
(WebTestRunner::TestRunner::setWebView):
(WebTestRunner):
(WebTestRunner::TestRunner::setBackingScaleFactor):
(WebTestRunner::TestRunner::display):
(WebTestRunner::TestRunner::displayInvalidatedRegion):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
(WebTestRunner):
(TestRunner):
* DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp:
(WebTestRunner::WebTestInterfaces::setWebView):
* DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp:
(WebTestRunner::WebTestProxyBase::reset):
(WebTestRunner::WebTestProxyBase::capturePixels):
(WebTestRunner):
(WebTestRunner::WebTestProxyBase::paintRect):
(WebTestRunner::WebTestProxyBase::paintInvalidatedRegion):
(WebTestRunner::WebTestProxyBase::paintPagesWithBoundaries):
(WebTestRunner::WebTestProxyBase::canvas):
(WebTestRunner::WebTestProxyBase::displayRepaintMask):
(WebTestRunner::WebTestProxyBase::display):
(WebTestRunner::WebTestProxyBase::displayInvalidatedRegion):
(WebTestRunner::WebTestProxyBase::discardBackingStore):
(WebTestRunner::WebTestProxyBase::setWindowRect):
(WebTestRunner::WebTestProxyBase::userMediaClient):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::createMainWindow):
(TestShell::~TestShell):
(TestShell::showDevTools):
(TestShell::closeDevTools):
(TestShell::dump):
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::setWindowRect):
(WebViewHost::setDeviceScaleFactor):
(WebViewHost::reset):
* DumpRenderTree/chromium/WebViewHost.h:
(WebViewHost):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (142928 => 142929)


--- trunk/Tools/ChangeLog	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/ChangeLog	2013-02-14 23:49:53 UTC (rev 142929)
@@ -1,3 +1,63 @@
+2013-02-14  Jochen Eisinger  <joc...@chromium.org>
+
+        [chromium] move pixel generation logic to TestRunner library
+        https://bugs.webkit.org/show_bug.cgi?id=109686
+
+        Reviewed by Stephen White.
+
+        * DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:
+        * DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h:
+        * DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h:
+        (WebTestRunner):
+        * DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h:
+        * DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h:
+        (WebTestRunner):
+        * DumpRenderTree/chromium/TestRunner/src/TestInterfaces.cpp:
+        (WebTestRunner::TestInterfaces::~TestInterfaces):
+        (WebTestRunner::TestInterfaces::setWebView):
+        (WebTestRunner::TestInterfaces::proxy):
+        (WebTestRunner):
+        * DumpRenderTree/chromium/TestRunner/src/TestInterfaces.h:
+        (WebTestRunner):
+        (TestInterfaces):
+        * DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
+        (WebTestRunner::TestRunner::setWebView):
+        (WebTestRunner):
+        (WebTestRunner::TestRunner::setBackingScaleFactor):
+        (WebTestRunner::TestRunner::display):
+        (WebTestRunner::TestRunner::displayInvalidatedRegion):
+        * DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
+        (WebTestRunner):
+        (TestRunner):
+        * DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp:
+        (WebTestRunner::WebTestInterfaces::setWebView):
+        * DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp:
+        (WebTestRunner::WebTestProxyBase::reset):
+        (WebTestRunner::WebTestProxyBase::capturePixels):
+        (WebTestRunner):
+        (WebTestRunner::WebTestProxyBase::paintRect):
+        (WebTestRunner::WebTestProxyBase::paintInvalidatedRegion):
+        (WebTestRunner::WebTestProxyBase::paintPagesWithBoundaries):
+        (WebTestRunner::WebTestProxyBase::canvas):
+        (WebTestRunner::WebTestProxyBase::displayRepaintMask):
+        (WebTestRunner::WebTestProxyBase::display):
+        (WebTestRunner::WebTestProxyBase::displayInvalidatedRegion):
+        (WebTestRunner::WebTestProxyBase::discardBackingStore):
+        (WebTestRunner::WebTestProxyBase::setWindowRect):
+        (WebTestRunner::WebTestProxyBase::userMediaClient):
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::createMainWindow):
+        (TestShell::~TestShell):
+        (TestShell::showDevTools):
+        (TestShell::closeDevTools):
+        (TestShell::dump):
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::setWindowRect):
+        (WebViewHost::setDeviceScaleFactor):
+        (WebViewHost::reset):
+        * DumpRenderTree/chromium/WebViewHost.h:
+        (WebViewHost):
+
 2013-02-14  Tony Chang  <t...@chromium.org>
 
         Unreviewed, set svn:eol-style native for .sln, .vcproj, and .vsprops files.

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp (142928 => 142929)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp	2013-02-14 23:49:53 UTC (rev 142929)
@@ -114,6 +114,7 @@
                             'dependencies': [
                                 '<(chromium_src_dir)/base/base.gyp:base',
                                 '<(chromium_src_dir)/build/temp_gyp/googleurl.gyp:googleurl',
+                                '<(chromium_src_dir)/skia/skia.gyp:skia',
                                 '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
                             ],
                             'direct_dependent_settings': {

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h	2013-02-14 23:49:53 UTC (rev 142929)
@@ -99,8 +99,6 @@
     virtual void addMockSpeechRecognitionResult(const std::string&, double) { }
     virtual void setMockSpeechRecognitionError(const std::string&, const std::string&) { }
     virtual bool wasMockSpeechRecognitionAborted() { return false; }
-    virtual void display() { }
-    virtual void displayInvalidatedRegion() { }
     virtual void testFinished() { }
     virtual void testTimedOut() { }
     virtual bool isBeingDebugged() { return false; }

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h	2013-02-14 23:49:53 UTC (rev 142929)
@@ -48,6 +48,7 @@
 
 class TestInterfaces;
 class WebTestDelegate;
+class WebTestProxyBase;
 class WebTestRunner;
 
 class WEBTESTRUNNER_EXPORT WebTestInterfaces {
@@ -55,7 +56,7 @@
     WebTestInterfaces();
     ~WebTestInterfaces();
 
-    void setWebView(WebKit::WebView*);
+    void setWebView(WebKit::WebView*, WebTestProxyBase*);
     void setDelegate(WebTestDelegate*);
     void bindTo(WebKit::WebFrame*);
     void resetAll();

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h	2013-02-14 23:49:53 UTC (rev 142929)
@@ -74,6 +74,8 @@
 struct WebWindowFeatures;
 }
 
+class SkCanvas;
+
 namespace WebTestRunner {
 
 class SpellCheckClient;
@@ -92,13 +94,15 @@
 
     WebKit::WebSpellCheckClient *spellCheckClient() const;
 
-    void setPaintRect(const WebKit::WebRect&);
-    WebKit::WebRect paintRect() const;
-
     std::string captureTree(bool debugRenderTree);
+    SkCanvas* capturePixels();
 
     void setLogConsoleOutput(bool enabled);
 
+    void display();
+    void displayInvalidatedRegion();
+    void discardBackingStore();
+
 protected:
     WebTestProxyBase();
     ~WebTestProxyBase();
@@ -169,6 +173,11 @@
 
 private:
     void locationChangeDone(WebKit::WebFrame*);
+    void paintRect(const WebKit::WebRect&);
+    void paintInvalidatedRegion();
+    void paintPagesWithBoundaries();
+    SkCanvas* canvas();
+    void displayRepaintMask();
 
     TestInterfaces* m_testInterfaces;
     WebTestDelegate* m_delegate;
@@ -176,7 +185,10 @@
     std::auto_ptr<SpellCheckClient> m_spellcheck;
     std::auto_ptr<WebUserMediaClientMock> m_userMediaClient;
 
+    // Painting.
+    std::auto_ptr<SkCanvas> m_canvas;
     WebKit::WebRect m_paintRect;
+    bool m_isPainting;
     std::map<unsigned, std::string> m_resourceIdentifierMap;
 
     bool m_logConsoleOutput;

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h	2013-02-14 23:49:53 UTC (rev 142929)
@@ -44,10 +44,6 @@
     virtual bool shouldDumpAsAudio() const = 0;
     virtual const WebKit::WebArrayBufferView* audioData() const = 0;
     virtual WebKit::WebPermissionClient* webPermissions() const = 0;
-    virtual bool shouldDumpSelectionRect() const = 0;
-    virtual bool testRepaint() const = 0;
-    virtual bool sweepHorizontally() const = 0;
-    virtual bool isPrinting() const = 0;
 };
 
 }

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestInterfaces.cpp (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestInterfaces.cpp	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestInterfaces.cpp	2013-02-14 23:49:53 UTC (rev 142929)
@@ -63,7 +63,7 @@
     m_eventSender->setWebView(0);
     // m_gamepadController doesn't depend on WebView.
     m_textInputController->setWebView(0);
-    m_testRunner->setWebView(0);
+    m_testRunner->setWebView(0, 0);
 
     m_accessibilityController->setDelegate(0);
     m_eventSender->setDelegate(0);
@@ -72,14 +72,15 @@
     m_testRunner->setDelegate(0);
 }
 
-void TestInterfaces::setWebView(WebView* webView)
+void TestInterfaces::setWebView(WebView* webView, WebTestProxyBase* proxy)
 {
     m_webView = webView;
+    m_proxy = proxy;
     m_accessibilityController->setWebView(webView);
     m_eventSender->setWebView(webView);
     // m_gamepadController doesn't depend on WebView.
     m_textInputController->setWebView(webView);
-    m_testRunner->setWebView(webView);
+    m_testRunner->setWebView(webView, proxy);
 }
 
 void TestInterfaces::setDelegate(WebTestDelegate* delegate)
@@ -156,4 +157,9 @@
     return m_delegate;
 }
 
+WebTestProxyBase* TestInterfaces::proxy()
+{
+    return m_proxy;
 }
+
+}

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestInterfaces.h (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestInterfaces.h	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestInterfaces.h	2013-02-14 23:49:53 UTC (rev 142929)
@@ -47,13 +47,14 @@
 class TestRunner;
 class TextInputController;
 class WebTestDelegate;
+class WebTestProxyBase;
 
 class TestInterfaces {
 public:
     TestInterfaces();
     ~TestInterfaces();
 
-    void setWebView(WebKit::WebView*);
+    void setWebView(WebKit::WebView*, WebTestProxyBase*);
     void setDelegate(WebTestDelegate*);
     void bindTo(WebKit::WebFrame*);
     void resetAll();
@@ -65,6 +66,7 @@
     TestRunner* testRunner();
     WebKit::WebView* webView();
     WebTestDelegate* delegate();
+    WebTestProxyBase* proxy();
 
 
 private:
@@ -75,6 +77,7 @@
     std::auto_ptr<TestRunner> m_testRunner;
     WebKit::WebView* m_webView;
     WebTestDelegate* m_delegate;
+    WebTestProxyBase* m_proxy;
 };
 
 }

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp	2013-02-14 23:49:53 UTC (rev 142929)
@@ -51,6 +51,7 @@
 #include "WebSurroundingText.h"
 #include "WebTask.h"
 #include "WebTestDelegate.h"
+#include "WebTestProxy.h"
 #include "WebView.h"
 #include "v8/include/v8.h"
 #include <limits>
@@ -339,6 +340,12 @@
 #endif
 }
 
+void TestRunner::setWebView(WebView* webView, WebTestProxyBase* proxy)
+{
+    m_webView = webView;
+    m_proxy = proxy;
+}
+
 void TestRunner::reset()
 {
     if (m_webView) {
@@ -1734,6 +1741,7 @@
 
     float value = arguments[0].value.doubleValue;
     m_delegate->setDeviceScaleFactor(value);
+    m_proxy->discardBackingStore();
 
     auto_ptr<CppVariant> callbackArguments(new CppVariant());
     callbackArguments->set(arguments[1]);
@@ -1843,13 +1851,13 @@
 
 void TestRunner::display(const CppArgumentList& arguments, CppVariant* result)
 {
-    m_delegate->display();
+    m_proxy->display();
     result->setNull();
 }
 
 void TestRunner::displayInvalidatedRegion(const CppArgumentList& arguments, CppVariant* result)
 {
-    m_delegate->displayInvalidatedRegion();
+    m_proxy->displayInvalidatedRegion();
     result->setNull();
 }
 

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h	2013-02-14 23:49:53 UTC (rev 142929)
@@ -57,6 +57,7 @@
 class NotificationPresenter;
 class WebPermissions;
 class WebTestDelegate;
+class WebTestProxyBase;
 
 class TestRunner : public WebTestRunner, public CppBoundClass {
 public:
@@ -64,7 +65,7 @@
     virtual ~TestRunner();
 
     void setDelegate(WebTestDelegate*);
-    void setWebView(WebKit::WebView* webView) { m_webView = webView; }
+    void setWebView(WebKit::WebView*, WebTestProxyBase*);
 
     void reset();
 
@@ -77,12 +78,12 @@
     virtual bool shouldDumpAsAudio() const OVERRIDE;
     virtual const WebKit::WebArrayBufferView* audioData() const OVERRIDE;
     virtual WebKit::WebPermissionClient* webPermissions() const OVERRIDE;
-    virtual bool shouldDumpSelectionRect() const OVERRIDE;
-    virtual bool testRepaint() const OVERRIDE;
-    virtual bool sweepHorizontally() const OVERRIDE;
-    virtual bool isPrinting() const OVERRIDE;
 
     // Methods used by WebTestProxyBase.
+    bool shouldDumpSelectionRect() const;
+    bool testRepaint() const;
+    bool sweepHorizontally() const;
+    bool isPrinting() const;
     bool shouldDumpAsText();
     bool shouldDumpBackForwardList() const;
     bool shouldDumpChildFrameScrollPositions() const;
@@ -661,6 +662,7 @@
 
     WebTestDelegate* m_delegate;
     WebKit::WebView* m_webView;
+    WebTestProxyBase* m_proxy;
 
     // This is non-0 IFF a load is in progress.
     WebKit::WebFrame* m_topLoadingFrame;

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp	2013-02-14 23:49:53 UTC (rev 142929)
@@ -49,9 +49,9 @@
 {
 }
 
-void WebTestInterfaces::setWebView(WebView* webView)
+void WebTestInterfaces::setWebView(WebView* webView, WebTestProxyBase* proxy)
 {
-    m_interfaces->setWebView(webView);
+    m_interfaces->setWebView(webView, proxy);
 }
 
 void WebTestInterfaces::setDelegate(WebTestDelegate* delegate)

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp	2013-02-14 23:49:53 UTC (rev 142929)
@@ -57,6 +57,8 @@
 #include "WebTestRunner.h"
 #include "WebUserMediaClientMock.h"
 #include "WebView.h"
+// FIXME: Including platform_canvas.h here is a layering violation.
+#include "skia/ext/platform_canvas.h"
 #include <cctype>
 #include <public/WebCString.h>
 #include <public/WebURLError.h>
@@ -436,6 +438,8 @@
 void WebTestProxyBase::reset()
 {
     m_paintRect = WebRect();
+    m_canvas.reset();
+    m_isPainting = false;
     m_resourceIdentifierMap.clear();
     m_logConsoleOutput = true;
 }
@@ -445,16 +449,6 @@
     return m_spellcheck.get();
 }
 
-void WebTestProxyBase::setPaintRect(const WebRect& rect)
-{
-    m_paintRect = rect;
-}
-
-WebRect WebTestProxyBase::paintRect() const
-{
-    return m_paintRect;
-}
-
 string WebTestProxyBase::captureTree(bool debugRenderTree)
 {
     WebScriptController::flushConsoleMessages();
@@ -483,11 +477,164 @@
     return dataUtf8;
 }
 
+SkCanvas* WebTestProxyBase::capturePixels()
+{
+    m_testInterfaces->webView()->layout();
+    if (m_testInterfaces->testRunner()->testRepaint()) {
+        WebSize viewSize = m_testInterfaces->webView()->size();
+        int width = viewSize.width;
+        int height = viewSize.height;
+        if (m_testInterfaces->testRunner()->sweepHorizontally()) {
+            for (WebRect column(0, 0, 1, height); column.x < width; column.x++)
+                paintRect(column);
+        } else {
+            for (WebRect line(0, 0, width, 1); line.y < height; line.y++)
+                paintRect(line);
+        }
+    } else if (m_testInterfaces->testRunner()->isPrinting())
+        paintPagesWithBoundaries();
+    else
+        paintInvalidatedRegion();
+
+    // See if we need to draw the selection bounds rect. Selection bounds
+    // rect is the rect enclosing the (possibly transformed) selection.
+    // The rect should be drawn after everything is laid out and painted.
+    if (m_testInterfaces->testRunner()->shouldDumpSelectionRect()) {
+        // If there is a selection rect - draw a red 1px border enclosing rect
+        WebRect wr = m_testInterfaces->webView()->mainFrame()->selectionBoundsRect();
+        if (!wr.isEmpty()) {
+            // Render a red rectangle bounding selection rect
+            SkPaint paint;
+            paint.setColor(0xFFFF0000); // Fully opaque red
+            paint.setStyle(SkPaint::kStroke_Style);
+            paint.setFlags(SkPaint::kAntiAlias_Flag);
+            paint.setStrokeWidth(1.0f);
+            SkIRect rect; // Bounding rect
+            rect.set(wr.x, wr.y, wr.x + wr.width, wr.y + wr.height);
+            canvas()->drawIRect(rect, paint);
+        }
+    }
+
+    return canvas();
+}
+
 void WebTestProxyBase::setLogConsoleOutput(bool enabled)
 {
     m_logConsoleOutput = enabled;
 }
 
+void WebTestProxyBase::paintRect(const WebRect& rect)
+{
+    WEBKIT_ASSERT(!m_isPainting);
+    WEBKIT_ASSERT(canvas());
+    m_isPainting = true;
+    float deviceScaleFactor = m_testInterfaces->webView()->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);
+    m_testInterfaces->webView()->paint(canvas(), deviceRect);
+    m_isPainting = false;
+}
+
+void WebTestProxyBase::paintInvalidatedRegion()
+{
+    m_testInterfaces->webView()->animate(0.0);
+    m_testInterfaces->webView()->layout();
+    WebSize widgetSize = m_testInterfaces->webView()->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(m_paintRect , clientRect)
+        WebRect damageRect = m_paintRect;
+        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);
+
+        m_paintRect = WebRect();
+        if (rect.isEmpty())
+            continue;
+        paintRect(rect);
+    }
+    WEBKIT_ASSERT(m_paintRect.isEmpty());
+}
+
+void WebTestProxyBase::paintPagesWithBoundaries()
+{
+    WEBKIT_ASSERT(!m_isPainting);
+    WEBKIT_ASSERT(canvas());
+    m_isPainting = true;
+
+    WebSize pageSizeInPixels = m_testInterfaces->webView()->size();
+    WebFrame* webFrame = m_testInterfaces->webView()->mainFrame();
+
+    int pageCount = webFrame->printBegin(pageSizeInPixels);
+    int totalHeight = pageCount * (pageSizeInPixels.height + 1) - 1;
+
+    SkCanvas* testCanvas = skia::TryCreateBitmapCanvas(pageSizeInPixels.width, totalHeight, true);
+    if (testCanvas) {
+        discardBackingStore();
+        m_canvas.reset(testCanvas);
+    } else {
+        webFrame->printEnd();
+        return;
+    }
+
+    webFrame->printPagesWithBoundaries(canvas(), pageSizeInPixels);
+    webFrame->printEnd();
+
+    m_isPainting = false;
+}
+
+SkCanvas* WebTestProxyBase::canvas()
+{
+    if (m_canvas.get())
+        return m_canvas.get();
+    WebSize widgetSize = m_testInterfaces->webView()->size();
+    float deviceScaleFactor = m_testInterfaces->webView()->deviceScaleFactor();
+    int scaledWidth = static_cast<int>(ceil(static_cast<float>(widgetSize.width) * deviceScaleFactor));
+    int scaledHeight = static_cast<int>(ceil(static_cast<float>(widgetSize.height) * deviceScaleFactor));
+    m_canvas.reset(skia::CreateBitmapCanvas(scaledWidth, scaledHeight, true));
+    return m_canvas.get();
+}
+
+// Paints the entire canvas a semi-transparent black (grayish). This is used
+// by the layout tests in fast/repaint. The alpha value matches upstream.
+void WebTestProxyBase::displayRepaintMask()
+{
+    canvas()->drawARGB(167, 0, 0, 0);
+}
+
+void WebTestProxyBase::display()
+{
+    const WebKit::WebSize& size = m_testInterfaces->webView()->size();
+    WebRect rect(0, 0, size.width, size.height);
+    m_paintRect = rect;
+    paintInvalidatedRegion();
+    displayRepaintMask();
+}
+
+void WebTestProxyBase::displayInvalidatedRegion()
+{
+    paintInvalidatedRegion();
+    displayRepaintMask();
+}
+
+void WebTestProxyBase::discardBackingStore()
+{
+    m_canvas.reset();
+}
+
 void WebTestProxyBase::didInvalidateRect(const WebRect& rect)
 {
     // m_paintRect = m_paintRect U rect
@@ -527,6 +674,7 @@
 void WebTestProxyBase::setWindowRect(const WebRect& rect)
 {
     scheduleComposite();
+    discardBackingStore();
 }
 
 void WebTestProxyBase::didAutoResize(const WebSize&)
@@ -782,7 +930,7 @@
 {
 #if ENABLE_WEBRTC
     if (!m_userMediaClient.get())
-        m_userMediaClient = auto_ptr<WebUserMediaClientMock>(new WebUserMediaClientMock(m_delegate));
+        m_userMediaClient.reset(new WebUserMediaClientMock(m_delegate));
     return m_userMediaClient.get();
 #else
     return 0;

Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.cpp (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2013-02-14 23:49:53 UTC (rev 142929)
@@ -182,16 +182,16 @@
     m_webViewHost = adoptPtr(createNewWindow(WebURL(), m_drtDevToolsAgent.get(), m_testInterfaces.get()));
     m_webView = m_webViewHost->webView();
     m_testInterfaces->setDelegate(m_webViewHost.get());
-    m_testInterfaces->setWebView(m_webView);
+    m_testInterfaces->setWebView(m_webView, m_webViewHost->proxy());
     m_drtDevToolsAgent->setWebView(m_webView);
 }
 
 TestShell::~TestShell()
 {
     m_testInterfaces->setDelegate(0);
-    m_testInterfaces->setWebView(0);
+    m_testInterfaces->setWebView(0, 0);
     m_devToolsTestInterfaces->setDelegate(0);
-    m_devToolsTestInterfaces->setWebView(0);
+    m_devToolsTestInterfaces->setWebView(0, 0);
     m_drtDevToolsAgent->setWebView(0);
     if (m_webViewHost)
         m_webViewHost->shutdown();
@@ -214,7 +214,7 @@
         m_devTools->webView()->settings()->setMemoryInfoEnabled(true);
         m_devTools->proxy()->setLogConsoleOutput(false);
         m_devToolsTestInterfaces->setDelegate(m_devTools);
-        m_devToolsTestInterfaces->setWebView(m_devTools->webView());
+        m_devToolsTestInterfaces->setWebView(m_devTools->webView(), m_devTools->proxy());
         ASSERT(m_devTools);
         createDRTDevToolsClient(m_drtDevToolsAgent.get());
     }
@@ -228,7 +228,7 @@
         m_drtDevToolsAgent->reset();
         m_drtDevToolsClient.clear();
         m_devToolsTestInterfaces->setDelegate(0);
-        m_devToolsTestInterfaces->setWebView(0);
+        m_devToolsTestInterfaces->setWebView(0, 0);
         closeWindow(m_devTools);
         m_devTools = 0;
     }
@@ -421,43 +421,7 @@
         // command line (for the dump pixels argument), and the MD5 sum to
         // stdout.
         dumpedAnything = true;
-        m_webView->layout();
-        if (m_testInterfaces->testRunner()->testRepaint()) {
-            WebSize viewSize = m_webView->size();
-            int width = viewSize.width;
-            int height = viewSize.height;
-            if (m_testInterfaces->testRunner()->sweepHorizontally()) {
-                for (WebRect column(0, 0, 1, height); column.x < width; column.x++)
-                    m_webViewHost->paintRect(column);
-            } else {
-                for (WebRect line(0, 0, width, 1); line.y < height; line.y++)
-                    m_webViewHost->paintRect(line);
-            }
-        } else if (m_testInterfaces->testRunner()->isPrinting())
-            m_webViewHost->paintPagesWithBoundaries();
-        else
-            m_webViewHost->paintInvalidatedRegion();
-
-        // See if we need to draw the selection bounds rect. Selection bounds
-        // rect is the rect enclosing the (possibly transformed) selection.
-        // The rect should be drawn after everything is laid out and painted.
-        if (m_testInterfaces->testRunner()->shouldDumpSelectionRect()) {
-            // If there is a selection rect - draw a red 1px border enclosing rect
-            WebRect wr = frame->selectionBoundsRect();
-            if (!wr.isEmpty()) {
-                // Render a red rectangle bounding selection rect
-                SkPaint paint;
-                paint.setColor(0xFFFF0000); // Fully opaque red
-                paint.setStyle(SkPaint::kStroke_Style);
-                paint.setFlags(SkPaint::kAntiAlias_Flag);
-                paint.setStrokeWidth(1.0f);
-                SkIRect rect; // Bounding rect
-                rect.set(wr.x, wr.y, wr.x + wr.width, wr.y + wr.height);
-                m_webViewHost->canvas()->drawIRect(rect, paint);
-            }
-        }
-
-        dumpImage(m_webViewHost->canvas());
+        dumpImage(m_webViewHost->proxy()->capturePixels());
     }
     m_printer.handleTestFooter(dumpedAnything);
     fflush(stdout);

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2013-02-14 23:49:53 UTC (rev 142929)
@@ -60,7 +60,6 @@
 #include "WebStorageNamespace.h"
 #include "WebView.h"
 #include "WebWindowFeatures.h"
-#include "skia/ext/platform_canvas.h"
 #include "webkit/support/test_media_stream_client.h"
 #include "webkit/support/webkit_support.h"
 #include <cctype>
@@ -462,7 +461,6 @@
         m_windowRect.height = 1 + border2;
     int width = m_windowRect.width - border2;
     int height = m_windowRect.height - border2;
-    discardBackingStore();
     webWidget()->resize(WebSize(width, height));
 }
 
@@ -715,7 +713,6 @@
 void WebViewHost::setDeviceScaleFactor(float deviceScaleFactor)
 {
     webView()->setDeviceScaleFactor(deviceScaleFactor);
-    discardBackingStore();
 }
 
 void WebViewHost::setFocus(bool focused)
@@ -831,21 +828,6 @@
 }
 #endif
 
-void WebViewHost::display()
-{
-    const WebKit::WebSize& size = webView()->size();
-    WebRect rect(0, 0, size.width, size.height);
-    proxy()->setPaintRect(rect);
-    paintInvalidatedRegion();
-    displayRepaintMask();
-}
-
-void WebViewHost::displayInvalidatedRegion()
-{
-    paintInvalidatedRegion();
-    displayRepaintMask();
-}
-
 void WebViewHost::testFinished()
 {
     m_shell->testFinished(this);
@@ -989,8 +971,6 @@
     m_lastPageIdUpdated = -1;
     m_hasWindow = false;
     m_inModalLoop = false;
-    m_isPainting = false;
-    m_canvas.clear();
 #if ENABLE(POINTER_LOCK)
     m_pointerLocked = false;
     m_pointerLockPlannedResult = PointerLockWillSucceed;
@@ -1184,109 +1164,3 @@
     return m_testMediaStreamClient.get();
 }
 #endif
-
-// Painting functions ---------------------------------------------------------
-
-void WebViewHost::paintRect(const WebRect& rect)
-{
-    ASSERT(!m_isPainting);
-    ASSERT(canvas());
-    m_isPainting = true;
-    float deviceScaleFactor = webView()->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);
-    webWidget()->paint(canvas(), deviceRect);
-    m_isPainting = false;
-}
-
-void WebViewHost::paintInvalidatedRegion()
-{
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-    webWidget()->animate(0.0);
-#endif
-    webWidget()->layout();
-    WebSize widgetSize = webWidget()->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(proxy()->paintRect() , clientRect)
-        WebRect damageRect = proxy()->paintRect();
-        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);
-
-        proxy()->setPaintRect(WebRect());
-        if (rect.isEmpty())
-            continue;
-        paintRect(rect);
-    }
-    ASSERT(proxy()->paintRect().isEmpty());
-}
-
-void WebViewHost::paintPagesWithBoundaries()
-{
-    ASSERT(!m_isPainting);
-    ASSERT(canvas());
-    m_isPainting = true;
-
-    WebSize pageSizeInPixels = webWidget()->size();
-    WebFrame* webFrame = webView()->mainFrame();
-
-    int pageCount = webFrame->printBegin(pageSizeInPixels);
-    int totalHeight = pageCount * (pageSizeInPixels.height + 1) - 1;
-
-    SkCanvas* testCanvas = skia::TryCreateBitmapCanvas(pageSizeInPixels.width, totalHeight, true);
-    if (testCanvas) {
-        discardBackingStore();
-        m_canvas = adoptPtr(testCanvas);
-    } else {
-        webFrame->printEnd();
-        return;
-    }
-
-    webFrame->printPagesWithBoundaries(canvas(), pageSizeInPixels);
-    webFrame->printEnd();
-
-    m_isPainting = false;
-}
-
-SkCanvas* WebViewHost::canvas()
-{
-    if (m_canvas)
-        return m_canvas.get();
-    WebSize widgetSize = webWidget()->size();
-    float deviceScaleFactor = webView()->deviceScaleFactor();
-    int scaledWidth = static_cast<int>(ceil(static_cast<float>(widgetSize.width) * deviceScaleFactor));
-    int scaledHeight = static_cast<int>(ceil(static_cast<float>(widgetSize.height) * deviceScaleFactor));
-    resetScrollRect();
-    m_canvas = adoptPtr(skia::CreateBitmapCanvas(scaledWidth, scaledHeight, true));
-    return m_canvas.get();
-}
-
-void WebViewHost::resetScrollRect()
-{
-}
-
-void WebViewHost::discardBackingStore()
-{
-    m_canvas.clear();
-}
-
-// Paints the entire canvas a semi-transparent black (grayish). This is used
-// by the layout tests in fast/repaint. The alpha value matches upstream.
-void WebViewHost::displayRepaintMask()
-{
-    canvas()->drawARGB(167, 0, 0, 0);
-}

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.h (142928 => 142929)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2013-02-14 23:45:07 UTC (rev 142928)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2013-02-14 23:49:53 UTC (rev 142929)
@@ -88,12 +88,6 @@
     void reset();
     void setPendingExtraData(PassOwnPtr<TestShellExtraData>);
 
-    void paintRect(const WebKit::WebRect&);
-    void paintInvalidatedRegion();
-    void paintPagesWithBoundaries();
-    SkCanvas* canvas();
-    void displayRepaintMask();
-
     TestNavigationController* navigationController() { return m_navigationController.get(); }
 
     void closeWidget();
@@ -153,8 +147,6 @@
     virtual void setMockSpeechRecognitionError(const std::string&, const std::string&) OVERRIDE;
     virtual bool wasMockSpeechRecognitionAborted() OVERRIDE;
 #endif
-    virtual void display() OVERRIDE;
-    virtual void displayInvalidatedRegion() OVERRIDE;
     virtual void testFinished() OVERRIDE;
     virtual void testTimedOut() OVERRIDE;
     virtual bool isBeingDebugged() OVERRIDE;
@@ -298,8 +290,6 @@
     void printFrameDescription(WebKit::WebFrame*);
 
     bool hasWindow() const { return m_hasWindow; }
-    void resetScrollRect();
-    void discardBackingStore();
 
 #if ENABLE(MEDIA_STREAM)
     webkit_support::TestMediaStreamClient* testMediaStreamClient();
@@ -333,10 +323,6 @@
     std::string m_editCommandName;
     std::string m_editCommandValue;
 
-    // Painting.
-    OwnPtr<SkCanvas> m_canvas;
-    WebKit::WebRect m_paintRect;
-    bool m_isPainting;
 
     OwnPtr<WebKit::WebContextMenuData> m_lastContextMenuData;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to