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.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@126810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/compositing/webgl/webgl-repaint.html b/LayoutTests/compositing/webgl/webgl-repaint.html
new file mode 100644
index 0000000..7c9e852
--- /dev/null
+++ b/LayoutTests/compositing/webgl/webgl-repaint.html
@@ -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>