[chromium] Need a way to test lost compositor context recovery
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Aug 2011 01:33:12 +0000 (01:33 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Aug 2011 01:33:12 +0000 (01:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=66820

Reviewed by Kenneth Russell.

Source/WebCore:

Adds support for recreating a context as if it was lost, and fixes
compositeAndReadback() to attempt context recovery.

Test: platform/chromium/compositing/lost-compositor-context.html

* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::compositeAndReadback):
(WebCore::CCLayerTreeHost::loseCompositorContext):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:

Source/WebKit/chromium:

Adds a testing-only API to simulate a lost compositor context.

* public/WebView.h:
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::loseCompositorContext):
* src/WebViewImpl.h:

Tools:

Exposes a LayoutTestController interface in chromium to simulate a
lost compositor context.

* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController):
(LayoutTestController::loseCompositorContext):
* DumpRenderTree/chromium/LayoutTestController.h:

LayoutTests:

Adds a simple test for losing the compositor context in a recoverable
way on a composited page. Tests that we recover without crashing and
render the updated content on the next frame.

* platform/chromium/compositing/lost-compositor-context.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93681 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/compositing/lost-compositor-context-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium/compositing/lost-compositor-context-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/compositing/lost-compositor-context.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebView.h
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.h
Tools/ChangeLog
Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Tools/DumpRenderTree/chromium/LayoutTestController.h

index 810e746..18cbb60 100644 (file)
@@ -1,3 +1,16 @@
+2011-08-23  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Need a way to test lost compositor context recovery
+        https://bugs.webkit.org/show_bug.cgi?id=66820
+
+        Reviewed by Kenneth Russell.
+
+        Adds a simple test for losing the compositor context in a recoverable
+        way on a composited page. Tests that we recover without crashing and
+        render the updated content on the next frame.
+
+        * platform/chromium/compositing/lost-compositor-context.html: Added.
+
 2011-08-23  Adam Barth  <abarth@webkit.org>
 
         Fix baselines for fast/block/float/fit_line_below_floats.html.  I forgot Windows in my previous patch.
diff --git a/LayoutTests/platform/chromium/compositing/lost-compositor-context-expected.png b/LayoutTests/platform/chromium/compositing/lost-compositor-context-expected.png
new file mode 100644 (file)
index 0000000..6cda17a
Binary files /dev/null and b/LayoutTests/platform/chromium/compositing/lost-compositor-context-expected.png differ
diff --git a/LayoutTests/platform/chromium/compositing/lost-compositor-context-expected.txt b/LayoutTests/platform/chromium/compositing/lost-compositor-context-expected.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/LayoutTests/platform/chromium/compositing/lost-compositor-context.html b/LayoutTests/platform/chromium/compositing/lost-compositor-context.html
new file mode 100644 (file)
index 0000000..3208b95
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style type="text/css" media="screen">
+    .red {
+        background-color: red;
+    }
+
+    .green {
+        background-color: green;
+    }
+
+    div {
+      height: 100px;
+      width: 100px;
+    }
+
+    .composited {
+      -webkit-transform: translateZ(0);
+    }
+  </style>
+</head>
+<body>
+  <!-- In the pixel results, one green squares should be visible. -->
+  <div class="red">
+    <div id="target" class="red composited">
+    </div>
+  </div>
+  <p>
+  <script>
+  if (window.layoutTestController) {
+    layoutTestController.dumpAsText(true);  // This is only useful as a pixel test.
+    layoutTestController.display();
+    layoutTestController.loseCompositorContext();
+  }
+  var target = document.getElementById("target");
+  target.classList.remove("red");
+  target.classList.add("green");
+  </script>
+</body>
+</html>
index 5dea3fb..ddb9307 100644 (file)
@@ -1,3 +1,20 @@
+2011-08-23  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Need a way to test lost compositor context recovery
+        https://bugs.webkit.org/show_bug.cgi?id=66820
+
+        Reviewed by Kenneth Russell.
+
+        Adds support for recreating a context as if it was lost, and fixes
+        compositeAndReadback() to attempt context recovery.
+
+        Test: platform/chromium/compositing/lost-compositor-context.html
+
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::compositeAndReadback):
+        (WebCore::CCLayerTreeHost::loseCompositorContext):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+
 2011-08-23  Nat Duca  <nduca@chromium.org>
 
         [chromium] Implement CCThread in terms of WebThread
index 9f35918..97e742c 100644 (file)
@@ -134,7 +134,7 @@ void CCLayerTreeHost::compositeAndReadback(void *pixels, const IntRect& rect)
 #if USE(THREADED_COMPOSITING)
     // FIXME: need to implement this.
 #else
-    doComposite();
+    composite(false);
     m_layerRenderer->getFramebufferPixels(pixels, rect);
 #endif
 }
@@ -275,6 +275,11 @@ void CCLayerTreeHost::composite(bool finish)
     }
 }
 
+void CCLayerTreeHost::loseCompositorContext()
+{
+    m_recreatingGraphicsContext = true;
+}
+
 void CCLayerTreeHost::reallocateRenderer()
 {
     RefPtr<LayerRendererChromium> layerRenderer = createLayerRenderer();
index d3c91eb..fda7220 100644 (file)
@@ -118,6 +118,9 @@ public:
     // Temporary home for the non-threaded rendering path.
 #if !USE(THREADED_COMPOSITING)
     void composite(bool finish);
+
+    void loseCompositorContext();
+
     LayerRendererChromium* layerRenderer() const { return m_layerRenderer.get(); }
 #endif
 
index 48fc8d8..94fe37f 100644 (file)
@@ -1,3 +1,17 @@
+2011-08-23  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Need a way to test lost compositor context recovery
+        https://bugs.webkit.org/show_bug.cgi?id=66820
+
+        Reviewed by Kenneth Russell.
+
+        Adds a testing-only API to simulate a lost compositor context.
+
+        * public/WebView.h:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::loseCompositorContext):
+        * src/WebViewImpl.h:
+
 2011-08-23  Nat Duca  <nduca@chromium.org>
 
         [chromium] Implement CCThread in terms of WebThread
index 1797dc5..0a5714a 100644 (file)
@@ -390,6 +390,11 @@ public:
 
     virtual void exitFullscreen() = 0;
 
+    // Testing functionality for LayoutTestController -----------------------
+
+    // Simulates a compositor lost context.
+    virtual void loseCompositorContext() = 0;
+
 
 protected:
     ~WebView() {}
index be214f7..b87fdd0 100644 (file)
@@ -1186,6 +1186,14 @@ void WebViewImpl::composite(bool finish)
 #endif
 }
 
+void WebViewImpl::loseCompositorContext()
+{
+#if USE(ACCELERATED_COMPOSITING)
+    if (m_layerTreeHost)
+        m_layerTreeHost->loseCompositorContext();
+#endif
+}
+
 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0;
 
 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent)
index d266712..01fc910 100644 (file)
@@ -406,6 +406,8 @@ public:
     void resetGestureRecognizer();
 #endif
 
+    void loseCompositorContext();
+
 private:
     friend class WebView;  // So WebView::Create can call our constructor
     friend class WTF::RefCounted<WebViewImpl>;
index cbcd2b4..e31c7b0 100644 (file)
@@ -1,3 +1,18 @@
+2011-08-23  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Need a way to test lost compositor context recovery
+        https://bugs.webkit.org/show_bug.cgi?id=66820
+
+        Reviewed by Kenneth Russell.
+
+        Exposes a LayoutTestController interface in chromium to simulate a
+        lost compositor context.
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::loseCompositorContext):
+        * DumpRenderTree/chromium/LayoutTestController.h:
+
 2011-08-23  Dimitri Glazkov  <dglazkov@chromium.org>
 
         Change garden-o-matic frontend builder array to be a configuration map.
index 409f853..ad23aab 100644 (file)
@@ -118,6 +118,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("hasSpellingMarker", &LayoutTestController::hasSpellingMarker);
     bindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled);
     bindMethod("layerTreeAsText", &LayoutTestController::layerTreeAsText);
+    bindMethod("loseCompositorContext", &LayoutTestController::loseCompositorContext);
     bindMethod("markerTextForListItem", &LayoutTestController::markerTextForListItem);
     bindMethod("notifyDone", &LayoutTestController::notifyDone);
     bindMethod("numberOfActiveAnimations", &LayoutTestController::numberOfActiveAnimations);
@@ -1721,6 +1722,11 @@ void LayoutTestController::layerTreeAsText(const CppArgumentList& args, CppVaria
     result->set(m_shell->webView()->mainFrame()->layerTreeAsText(m_showDebugLayerTree).utf8());
 }
 
+void LayoutTestController::loseCompositorContext(const CppArgumentList&, CppVariant*)
+{
+    m_shell->webView()->loseCompositorContext();
+}
+
 void LayoutTestController::markerTextForListItem(const CppArgumentList& args, CppVariant* result)
 {
     WebElement element;
index 6aea7ec..b0e7199 100644 (file)
@@ -358,6 +358,8 @@ public:
 
     void layerTreeAsText(const CppArgumentList& args, CppVariant* result);
 
+    void loseCompositorContext(const CppArgumentList& args, CppVariant* result);
+
     void markerTextForListItem(const CppArgumentList&, CppVariant*);
     void hasSpellingMarker(const CppArgumentList&, CppVariant*);