Title: [126810] trunk
Revision
126810
Author
jam...@google.com
Date
2012-08-27 15:42:30 -0700 (Mon, 27 Aug 2012)

Log Message

WebGL should not flip textures on presentation if contents are unchanged
https://bugs.webkit.org/show_bug.cgi?id=94961

Reviewed by Kenneth Russell.

Source/WebCore:

For WebGL contexts where antialias and preserveDrawingBuffer are false, chromium implements DrawingBuffer using
two textures and flips them on presentation. If the page hasn't actually rendered anything into the WebGL
context since the last presentation, this makes an old frame available. This fixes the bug by marking the
DrawingBuffer when its contents change.

Test: compositing/webgl/webgl-repaint.html

* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::markContextChanged):
* platform/graphics/chromium/DrawingBufferChromium.cpp:
(WebCore::DrawingBuffer::DrawingBuffer):
(WebCore::DrawingBuffer::prepareBackBuffer):
* platform/graphics/gpu/DrawingBuffer.h:
(WebCore::DrawingBuffer::markContentsChanged):
(DrawingBuffer):

Tools:

Run some compositing webgl tests in threaded mode to catch regressions specific to that mode.

* Scripts/webkitpy/layout_tests/port/chromium.py:
(ChromiumPort.virtual_test_suites):

LayoutTests:

Adds a test to make sure multiple displays without any WebGL draw calls leave the WebGL output alone.

* compositing/webgl/webgl-repaint-expected.png: Added.
* compositing/webgl/webgl-repaint-expected.txt: Added.
* compositing/webgl/webgl-repaint.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (126809 => 126810)


--- trunk/LayoutTests/ChangeLog	2012-08-27 22:36:09 UTC (rev 126809)
+++ trunk/LayoutTests/ChangeLog	2012-08-27 22:42:30 UTC (rev 126810)
@@ -1,3 +1,16 @@
+2012-08-24  James Robinson  <jam...@chromium.org>
+
+        WebGL should not flip textures on presentation if contents are unchanged
+        https://bugs.webkit.org/show_bug.cgi?id=94961
+
+        Reviewed by Kenneth Russell.
+
+        Adds a test to make sure multiple displays without any WebGL draw calls leave the WebGL output alone.
+
+        * compositing/webgl/webgl-repaint-expected.png: Added.
+        * compositing/webgl/webgl-repaint-expected.txt: Added.
+        * compositing/webgl/webgl-repaint.html: Added.
+
 2012-08-27  Leo Yang  <leoy...@rim.com>
 
         [BlackBerry] Test expectation for fast/js/constructor-length.html

Added: trunk/LayoutTests/compositing/webgl/webgl-repaint-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/compositing/webgl/webgl-repaint-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/compositing/webgl/webgl-repaint-expected.txt (0 => 126810)


--- trunk/LayoutTests/compositing/webgl/webgl-repaint-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/webgl/webgl-repaint-expected.txt	2012-08-27 22:42:30 UTC (rev 126810)
@@ -0,0 +1 @@
+
Property changes on: trunk/LayoutTests/compositing/webgl/webgl-repaint-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/webgl/webgl-repaint.html (0 => 126810)


--- trunk/LayoutTests/compositing/webgl/webgl-repaint.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/webgl/webgl-repaint.html	2012-08-27 22:42:30 UTC (rev 126810)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css" media="screen">
+canvas {
+    margin: 20px;
+    width: 200px;
+    height: 200px;
+    padding: 0 0;
+}
+.border {
+    border: 1px solid black;
+}
+</style>
+<script>
+if (window.testRunner)
+    testRunner.overridePreference("WebKitWebGLEnabled", "1");
+
+function initWebGL()
+{
+    var canvas = document.getElementById('canvas');
+    var gl = canvas.getContext("experimental-webgl", {'antialias': false});
+    if (!gl) {
+        alert("No WebGL context found");
+        return null;
+    }
+
+    return gl;
+}
+
+var gl = null;
+
+function init()
+{
+  gl = initWebGL();
+  gl.viewport(0, 0, 200, 200);
+  gl.clearColor(1, 0, 0, 1); // red
+  gl.clear(gl.COLOR_BUFFER_BIT);
+  if (window.testRunner) {
+      testRunner.display();
+      testRunner.dumpAsText(true);
+      drawGreen();
+  } else
+      window.setTimeout(drawGreen, 50);
+}
+
+function drawGreen()
+{
+  gl.clearColor(0, 1, 0, 1); // green
+  gl.clear(gl.COLOR_BUFFER_BIT);
+  if (window.testRunner) {
+      testRunner.display();
+      testRunner.display();
+  } else
+      window.setInterval(function() {
+        document.getElementById('canvas').classList.toggle('border');
+      }, 50);
+}
+
+</script>
+</head>
+<body _onload_="init()">
+<canvas id="canvas" width="200" height="200"></canvas>
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/webgl/webgl-repaint.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (126809 => 126810)


--- trunk/Source/WebCore/ChangeLog	2012-08-27 22:36:09 UTC (rev 126809)
+++ trunk/Source/WebCore/ChangeLog	2012-08-27 22:42:30 UTC (rev 126810)
@@ -1,3 +1,27 @@
+2012-08-24  James Robinson  <jam...@chromium.org>
+
+        WebGL should not flip textures on presentation if contents are unchanged
+        https://bugs.webkit.org/show_bug.cgi?id=94961
+
+        Reviewed by Kenneth Russell.
+
+        For WebGL contexts where antialias and preserveDrawingBuffer are false, chromium implements DrawingBuffer using
+        two textures and flips them on presentation. If the page hasn't actually rendered anything into the WebGL
+        context since the last presentation, this makes an old frame available. This fixes the bug by marking the
+        DrawingBuffer when its contents change.
+
+        Test: compositing/webgl/webgl-repaint.html
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore):
+        (WebCore::WebGLRenderingContext::markContextChanged):
+        * platform/graphics/chromium/DrawingBufferChromium.cpp:
+        (WebCore::DrawingBuffer::DrawingBuffer):
+        (WebCore::DrawingBuffer::prepareBackBuffer):
+        * platform/graphics/gpu/DrawingBuffer.h:
+        (WebCore::DrawingBuffer::markContentsChanged):
+        (DrawingBuffer):
+
 2012-08-27  Adam Barth  <aba...@webkit.org>
 
         [V8] Clean up V8DOMWindowShell's findFrame

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (126809 => 126810)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-08-27 22:36:09 UTC (rev 126809)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-08-27 22:42:30 UTC (rev 126810)
@@ -602,6 +602,9 @@
 
     m_context->markContextChanged();
 
+    if (m_drawingBuffer)
+        m_drawingBuffer->markContentsChanged();
+
     m_layerCleared = false;
 #if USE(ACCELERATED_COMPOSITING)
     RenderBox* renderBox = canvas()->renderBox();

Modified: trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp (126809 => 126810)


--- trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp	2012-08-27 22:36:09 UTC (rev 126809)
+++ trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp	2012-08-27 22:42:30 UTC (rev 126810)
@@ -87,6 +87,7 @@
     , m_stencilBuffer(0)
     , m_multisampleFBO(0)
     , m_multisampleColorBuffer(0)
+    , m_contentsChanged(true)
 {
     initialize(size);
 }
@@ -119,6 +120,9 @@
 #if USE(ACCELERATED_COMPOSITING)
 void DrawingBuffer::prepareBackBuffer()
 {
+    if (!m_contentsChanged)
+        return;
+
     m_context->makeContextCurrent();
 
     if (multisample())
@@ -138,6 +142,8 @@
         bind();
     else
         restoreFramebufferBinding();
+
+    m_contentsChanged = false;
 }
 
 bool DrawingBuffer::requiresCopyFromBackToFrontBuffer() const

Modified: trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h (126809 => 126810)


--- trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h	2012-08-27 22:36:09 UTC (rev 126809)
+++ trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h	2012-08-27 22:42:30 UTC (rev 126810)
@@ -124,6 +124,7 @@
 #if USE(ACCELERATED_COMPOSITING)
     PlatformLayer* platformLayer();
     void prepareBackBuffer();
+    void markContentsChanged() { m_contentsChanged = true; }
     bool requiresCopyFromBackToFrontBuffer() const;
     unsigned frontColorBuffer() const;
     void paintCompositedResultsToCanvas(ImageBuffer*);
@@ -164,6 +165,9 @@
     Platform3DObject m_multisampleFBO;
     Platform3DObject m_multisampleColorBuffer;
 
+    // True if our contents have been modified since the last presentation of this buffer.
+    bool m_contentsChanged;
+
 #if PLATFORM(CHROMIUM)
     OwnPtr<DrawingBufferPrivate> m_private;
 #endif

Modified: trunk/Tools/ChangeLog (126809 => 126810)


--- trunk/Tools/ChangeLog	2012-08-27 22:36:09 UTC (rev 126809)
+++ trunk/Tools/ChangeLog	2012-08-27 22:42:30 UTC (rev 126810)
@@ -1,3 +1,15 @@
+2012-08-24  James Robinson  <jam...@chromium.org>
+
+        WebGL should not flip textures on presentation if contents are unchanged
+        https://bugs.webkit.org/show_bug.cgi?id=94961
+
+        Reviewed by Kenneth Russell.
+
+        Run some compositing webgl tests in threaded mode to catch regressions specific to that mode.
+
+        * Scripts/webkitpy/layout_tests/port/chromium.py:
+        (ChromiumPort.virtual_test_suites):
+
 2012-08-27  Gavin Peters  <gav...@chromium.org>
 
         [webkit-patch] Don't crash chrome-channels command when a previously unknown platform shows up.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py (126809 => 126810)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py	2012-08-27 22:36:09 UTC (rev 126809)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py	2012-08-27 22:42:30 UTC (rev 126810)
@@ -367,6 +367,9 @@
             VirtualTestSuite('platform/chromium/virtual/threaded/compositing/visibility',
                              'compositing/visibility',
                              ['--enable-threaded-compositing']),
+            VirtualTestSuite('platform/chromium/virtual/threaded/compositing/webgl',
+                             'compositing/webgl',
+                             ['--enable-threaded-compositing']),
         ]
 
     #
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to