[EFL][WebGL] WebGL content is not painted after resizing the viewport.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2013 07:24:46 +0000 (07:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2013 07:24:46 +0000 (07:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106358

Patch by Viatcheslav Ostapenko <sl.ostapenko@samsung.com> on 2013-02-11
Reviewed by Noam Rosenthal.

Source/WebCore:

When page size changes and layer parameters get updated LayerTreeRenderer::setLayerState
clears the layer backing store and detaches the canvas surface from the layer. If the layer
size is not changed then the canvas is not recreated. This leaves the canvas detached from
the layer, but still referenced from m_surfaceBackingStores.
Don't assign layer backing store to layer in assignImageBackingToLayer if there is a canvas
surface already attached to the layer.

Test: fast/canvas/webgl/webgl-layer-update.html

* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
(WebCore::CoordinatedGraphicsScene::setLayerState):
(WebCore::CoordinatedGraphicsScene::assignImageBackingToLayer):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:

LayoutTests:

Add test checking that canvas painting is correct if layer parameters were changed,
but webgl canvas didn't change.

* fast/canvas/webgl/webgl-layer-update-expected.png: Added.
* fast/canvas/webgl/webgl-layer-update-expected.txt: Added.
* fast/canvas/webgl/webgl-layer-update.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/canvas/webgl/webgl-layer-update-expected.png [new file with mode: 0644]
LayoutTests/fast/canvas/webgl/webgl-layer-update-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/webgl/webgl-layer-update.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h

index 6e53d1fac3e1294df8302bf14c16f05322858997..b7ab460e33076a9a54d50ceb083ba17f1c9af7ce 100644 (file)
@@ -1,3 +1,17 @@
+2013-02-11  Viatcheslav Ostapenko  <sl.ostapenko@samsung.com>
+
+        [EFL][WebGL] WebGL content is not painted after resizing the viewport.
+        https://bugs.webkit.org/show_bug.cgi?id=106358
+
+        Reviewed by Noam Rosenthal.
+
+        Add test checking that canvas painting is correct if layer parameters were changed,
+        but webgl canvas didn't change.
+
+        * fast/canvas/webgl/webgl-layer-update-expected.png: Added.
+        * fast/canvas/webgl/webgl-layer-update-expected.txt: Added.
+        * fast/canvas/webgl/webgl-layer-update.html: Added.
+
 2013-02-11  KwangYong Choi  <ky0.choi@samsung.com>
 
         [EFL] Some placeholder paint order tests are passing now
diff --git a/LayoutTests/fast/canvas/webgl/webgl-layer-update-expected.png b/LayoutTests/fast/canvas/webgl/webgl-layer-update-expected.png
new file mode 100644 (file)
index 0000000..c52dc10
Binary files /dev/null and b/LayoutTests/fast/canvas/webgl/webgl-layer-update-expected.png differ
diff --git a/LayoutTests/fast/canvas/webgl/webgl-layer-update-expected.txt b/LayoutTests/fast/canvas/webgl/webgl-layer-update-expected.txt
new file mode 100644 (file)
index 0000000..28be962
--- /dev/null
@@ -0,0 +1,2 @@
+This test is only useful as a pixel test. You should see red canvas of size 100x100.
+
diff --git a/LayoutTests/fast/canvas/webgl/webgl-layer-update.html b/LayoutTests/fast/canvas/webgl/webgl-layer-update.html
new file mode 100644 (file)
index 0000000..6caeca9
--- /dev/null
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+<script>
+    function doUpdate()
+    {
+        document.getElementsByTagName('canvas')[0].style.top = "60px";
+
+        if (window.testRunner) {
+            testRunner.display();
+            testRunner.notifyDone();
+        }
+    }
+
+    function init()
+    {
+        if (window.testRunner)
+            doUpdate();
+        else {
+            // Delay canvas layer update if test runs without testRunner to
+            // allow first layer update to be processed on UI side.
+            window.setTimeout(doUpdate, 100);
+        }
+    }
+</script>
+<body onload="init()">
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+</script>
+<span id="description" style="color: white">
+This test is only useful as a pixel test. You should see red canvas of size 100x100.
+</span>
+<br>
+<style>
+canvas {
+    outline: 1px solid blue;
+}
+body {
+    background-color: darkblue;
+}
+</style>
+<script>
+
+if (window.testRunner) {
+    testRunner.overridePreference("WebKitWebGLEnabled", "1");
+    testRunner.dumpAsText(true);
+    document.getElementById("description").style.position = "absolute";
+    document.getElementById("description").style.top = "-5000px"; 
+}
+
+var can = document.createElement('canvas');
+can.width = can.height = 100;
+can.style.position = "absolute";
+can.style.left = "40px";
+can.style.top = "40px";
+document.body.appendChild(can);
+var ctx = can.getContext("experimental-webgl");
+ctx.clearColor(1, 0, 0, 1);
+ctx.clear(ctx.COLOR_BUFFER_BIT);
+
+if (window.testRunner)
+    testRunner.display();
+</script>
+</body>
+</html>
+
index df2a63aeafd6f56f0022c416f2bd7f82d2023dcb..6e4f1075e5d228dd4991ba8d74fd4c9364ae6a23 100644 (file)
@@ -1,3 +1,24 @@
+2013-02-11  Viatcheslav Ostapenko  <sl.ostapenko@samsung.com>
+
+        [EFL][WebGL] WebGL content is not painted after resizing the viewport.
+        https://bugs.webkit.org/show_bug.cgi?id=106358
+
+        Reviewed by Noam Rosenthal.
+
+        When page size changes and layer parameters get updated LayerTreeRenderer::setLayerState
+        clears the layer backing store and detaches the canvas surface from the layer. If the layer
+        size is not changed then the canvas is not recreated. This leaves the canvas detached from
+        the layer, but still referenced from m_surfaceBackingStores.
+        Don't assign layer backing store to layer in assignImageBackingToLayer if there is a canvas
+        surface already attached to the layer.
+
+        Test: fast/canvas/webgl/webgl-layer-update.html
+
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
+        (WebCore::CoordinatedGraphicsScene::setLayerState):
+        (WebCore::CoordinatedGraphicsScene::assignImageBackingToLayer):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
+
 2013-02-11  Eric Carlson  <eric.carlson@apple.com>
 
         [Mac] Track language selection should be sticky
index 8e55920dea5f4834b68c3ea126047c597a37fad1..5910a9a14c03c77bee831a1a9f31e31a313c4099 100644 (file)
@@ -344,7 +344,7 @@ void CoordinatedGraphicsScene::setLayerState(CoordinatedLayerID id, const Coordi
     else
         m_fixedLayers.remove(id);
 
-    assignImageBackingToLayer(layer, layerInfo.imageID);
+    assignImageBackingToLayer(id, layer, layerInfo.imageID);
     prepareContentBackingStore(layer);
 
     // Never make the root layer clip.
@@ -526,8 +526,13 @@ void CoordinatedGraphicsScene::removeImageBacking(CoordinatedImageBackingID imag
     m_releasedImageBackings.append(m_imageBackings.take(imageID));
 }
 
-void CoordinatedGraphicsScene::assignImageBackingToLayer(GraphicsLayer* layer, CoordinatedImageBackingID imageID)
+void CoordinatedGraphicsScene::assignImageBackingToLayer(CoordinatedLayerID id, GraphicsLayer* layer, CoordinatedImageBackingID imageID)
 {
+#if USE(GRAPHICS_SURFACE)
+    if (m_surfaceBackingStores.contains(id))
+        return;
+#endif
+
     if (imageID == InvalidCoordinatedImageBackingID) {
         layer->setContentsToMedia(0);
         return;
index c7cc83cab3bc6878b6c7d7b68102e8e41c7289b7..b25d00d30275a6cb5fb4acb976cbaaf671949f48 100644 (file)
@@ -162,7 +162,7 @@ private:
     void createLayer(CoordinatedLayerID);
     void deleteLayer(CoordinatedLayerID);
 
-    void assignImageBackingToLayer(GraphicsLayer*, CoordinatedImageBackingID);
+    void assignImageBackingToLayer(CoordinatedLayerID, GraphicsLayer*, CoordinatedImageBackingID);
     void removeReleasedImageBackingsIfNeeded();
     void ensureRootLayer();
     void commitPendingBackingStoreOperations();