Diff
Modified: trunk/LayoutTests/ChangeLog (101119 => 101120)
--- trunk/LayoutTests/ChangeLog 2011-11-24 06:03:59 UTC (rev 101119)
+++ trunk/LayoutTests/ChangeLog 2011-11-24 06:06:31 UTC (rev 101120)
@@ -1,3 +1,18 @@
+2011-11-23 Jeff Timanus <[email protected]>
+
+ [Chromium] Prevent DrawingBuffer instances from corrupting the active
+ texture state of the WebGL contexts. The DrawingBuffer now tracks the
+ state of texture unit 0, and the active texture unit, so that state can
+ be restored.
+ https://bugs.webkit.org/show_bug.cgi?id=73033
+
+ Reviewed by Kenneth Russell.
+
+ Test: fast/canvas/webgl/webgl-texture-binding-preserved.html
+
+ * fast/canvas/webgl/webgl-texture-binding-preserved-expected.txt: Added.
+ * fast/canvas/webgl/webgl-texture-binding-preserved.html: Added.
+
2011-11-23 Dmitry Lomov <[email protected]>
https://bugs.webkit.org/show_bug.cgi?id=73054
Added: trunk/LayoutTests/fast/canvas/webgl/webgl-texture-binding-preserved-expected.txt (0 => 101120)
--- trunk/LayoutTests/fast/canvas/webgl/webgl-texture-binding-preserved-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/webgl-texture-binding-preserved-expected.txt 2011-11-24 06:06:31 UTC (rev 101120)
@@ -0,0 +1,9 @@
+Checks that painting WebGL contents doesn't pollute the context state.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS Should have rendered blue.
+
Property changes on: trunk/LayoutTests/fast/canvas/webgl/webgl-texture-binding-preserved-expected.txt
___________________________________________________________________
Added: svn:executable
Added: trunk/LayoutTests/fast/canvas/webgl/webgl-texture-binding-preserved.html (0 => 101120)
--- trunk/LayoutTests/fast/canvas/webgl/webgl-texture-binding-preserved.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/webgl-texture-binding-preserved.html 2011-11-24 06:06:31 UTC (rev 101120)
@@ -0,0 +1,69 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script src="" </script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("Checks that painting WebGL contents doesn't pollute the context state.");
+
+var wtu = WebGLTestUtils;
+
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+var canvas;
+var context;
+var requestAnimationFrame;
+
+function draw() {
+ // Draw a blue quad to the screen. The compositor should have executed
+ // before reaching this point. If the texture state was corruted, then
+ // a red quad will be drawn. See crbug.com/105045.
+ wtu.drawQuad(context);
+
+ wtu.checkCanvasRect(context, 0, 0, 1, 1, [0, 0, 255, 255], "Should have rendered blue.", 1);
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+window._onload_ = function()
+{
+ if (window.initNonKhronosFramework) {
+ window.initNonKhronosFramework(false);
+ }
+
+ canvas = document.getElementById("webgl-canvas");
+ canvas.width = 50; canvas.height = 50;
+ context = create3DContext(canvas);
+
+ requestAnimationFrame = window.webkitRequestAnimationFrame
+
+ var program = wtu.setupTexturedQuad(context);
+ var bufferObjects = wtu.setupUnitQuad(context);
+ var texture = wtu.createColoredTexture(context, 1, 1, [0, 0, 255, 255]);
+
+ context.uniform1i(context.getUniformLocation(program, "tex"), 0);
+
+ context.activeTexture(context.TEXTURE_0 + 5);
+ context.bindTexture(context.TEXTURE_2D, texture);
+
+ context.viewport(0, 0, canvas.width, canvas.height);
+
+ context.clearColor(255, 0, 0, 255);
+ context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT);
+
+ // We need to ensure that the compositor has run before the drawing
+ // takes place.
+ setTimeout(draw, 100);
+}
+</script>
+<script src=""
+<canvas id="webgl-canvas" width="32px" height="32px"></canvas>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/canvas/webgl/webgl-texture-binding-preserved.html
___________________________________________________________________
Added: svn:executable
Modified: trunk/Source/WebCore/ChangeLog (101119 => 101120)
--- trunk/Source/WebCore/ChangeLog 2011-11-24 06:03:59 UTC (rev 101119)
+++ trunk/Source/WebCore/ChangeLog 2011-11-24 06:06:31 UTC (rev 101120)
@@ -1,3 +1,31 @@
+2011-11-23 Jeff Timanus <[email protected]>
+
+ [Chromium] Prevent DrawingBuffer instances from corrupting the active
+ texture state of the WebGL contexts. The DrawingBuffer now tracks the
+ state of texture unit 0, and the active texture unit, so that state can
+ be restored.
+ https://bugs.webkit.org/show_bug.cgi?id=73033
+
+ Reviewed by Kenneth Russell.
+
+ Test: fast/canvas/webgl/webgl-texture-binding-preserved.html
+
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::activeTexture):
+ (WebCore::WebGLRenderingContext::bindTexture):
+ * platform/graphics/chromium/DrawingBufferChromium.cpp:
+ (WebCore::DrawingBuffer::DrawingBuffer):
+ (WebCore::DrawingBuffer::publishToPlatformLayer):
+ * platform/graphics/gpu/DrawingBuffer.h:
+ (WebCore::DrawingBuffer::setTexture2DBinding):
+ (WebCore::DrawingBuffer::setActiveTextureUnit):
+ * platform/graphics/gpu/mac/DrawingBufferMac.mm:
+ (WebCore::DrawingBuffer::DrawingBuffer):
+ * platform/graphics/gpu/qt/DrawingBufferQt.cpp:
+ (WebCore::DrawingBuffer::DrawingBuffer):
+ * platform/graphics/gtk/DrawingBufferGtk.cpp:
+ (WebCore::DrawingBuffer::DrawingBuffer):
+
2011-11-23 Luke Macpherson <[email protected]>
CSSValue: reorder ClassType enum to allow faster comparisons, add COMPILE_ASSERT on class size.
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (101119 => 101120)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2011-11-24 06:03:59 UTC (rev 101119)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2011-11-24 06:06:31 UTC (rev 101120)
@@ -758,6 +758,10 @@
}
m_activeTextureUnit = texture - GraphicsContext3D::TEXTURE0;
m_context->activeTexture(texture);
+
+ if (m_drawingBuffer)
+ m_drawingBuffer->setActiveTextureUnit(texture);
+
cleanupAfterGraphicsCall(false);
}
@@ -888,6 +892,10 @@
if (target == GraphicsContext3D::TEXTURE_2D) {
m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture;
maxLevel = m_maxTextureLevel;
+
+ if (m_drawingBuffer && !m_activeTextureUnit)
+ m_drawingBuffer->setTexture2DBinding(objectOrZero(texture));
+
} else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) {
m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture;
maxLevel = m_maxCubeMapTextureLevel;
Modified: trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp (101119 => 101120)
--- trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp 2011-11-24 06:03:59 UTC (rev 101119)
+++ trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp 2011-11-24 06:06:31 UTC (rev 101120)
@@ -62,6 +62,8 @@
bool separateBackingTexture)
: m_separateBackingTexture(separateBackingTexture)
, m_scissorEnabled(false)
+ , m_texture2DBinding(0)
+ , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
, m_context(context)
, m_size(-1, -1)
, m_multisampleExtensionSupported(multisampleExtensionSupported)
@@ -118,9 +120,16 @@
if (m_separateBackingTexture) {
m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
+
+ // This path always uses TEXTURE0, and restores its state below.
+ m_context->activeTexture(GraphicsContext3D::TEXTURE0);
m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_backingColorBuffer);
+
unsigned colorFormat = m_context->getContextAttributes().alpha ? GraphicsContext3D::RGBA : GraphicsContext3D::RGB;
m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, colorFormat, 0, 0, size().width(), size().height(), 0);
+
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_texture2DBinding);
+ m_context->activeTexture(m_activeTextureUnit);
}
if (multisample())
Modified: trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h (101119 => 101120)
--- trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h 2011-11-24 06:03:59 UTC (rev 101119)
+++ trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h 2011-11-24 06:06:31 UTC (rev 101120)
@@ -85,6 +85,14 @@
// can be disabled during calls to commit.
void setScissorEnabled(bool scissorEnabled) { m_scissorEnabled = scissorEnabled; }
+ // The DrawingBuffer needs to track the texture bound to texture unit 0.
+ // The bound texture is tracked to avoid costly queries during rendering.
+ void setTexture2DBinding(GC3Dint texture) { m_texture2DBinding = texture; }
+
+ // Track the currently active texture unit. Texture unit 0 is used as host for a scratch
+ // texture.
+ void setActiveTextureUnit(GC3Dint textureUnit) { m_activeTextureUnit = textureUnit; }
+
bool multisample() const;
Platform3DObject platformColorBuffer() const;
@@ -112,6 +120,8 @@
bool m_separateBackingTexture;
bool m_scissorEnabled;
+ Platform3DObject m_texture2DBinding;
+ GC3Denum m_activeTextureUnit;
RefPtr<GraphicsContext3D> m_context;
IntSize m_size;
Modified: trunk/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm (101119 => 101120)
--- trunk/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm 2011-11-24 06:03:59 UTC (rev 101119)
+++ trunk/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm 2011-11-24 06:06:31 UTC (rev 101120)
@@ -43,6 +43,8 @@
bool separateBackingTexture)
: m_separateBackingTexture(separateBackingTexture)
, m_scissorEnabled(false)
+ , m_texture2DBinding(0)
+ , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
, m_context(context)
, m_size(-1, -1)
, m_multisampleExtensionSupported(multisampleExtensionSupported)
Modified: trunk/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp (101119 => 101120)
--- trunk/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp 2011-11-24 06:03:59 UTC (rev 101119)
+++ trunk/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp 2011-11-24 06:06:31 UTC (rev 101120)
@@ -38,6 +38,8 @@
bool separateBackingTexture)
: m_separateBackingTexture(separateBackingTexture)
, m_scissorEnabled(false)
+ , m_texture2DBinding(0)
+ , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
, m_context(context)
, m_size(-1, -1)
, m_multisampleExtensionSupported(multisampleExtensionSupported)
Modified: trunk/Source/WebCore/platform/graphics/gtk/DrawingBufferGtk.cpp (101119 => 101120)
--- trunk/Source/WebCore/platform/graphics/gtk/DrawingBufferGtk.cpp 2011-11-24 06:03:59 UTC (rev 101119)
+++ trunk/Source/WebCore/platform/graphics/gtk/DrawingBufferGtk.cpp 2011-11-24 06:06:31 UTC (rev 101120)
@@ -40,6 +40,8 @@
bool separateBackingTexture)
: m_separateBackingTexture(separateBackingTexture)
, m_scissorEnabled(false)
+ , m_texture2DBinding(0)
+ , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
, m_context(context)
, m_size(-1, -1)
, m_multisampleExtensionSupported(multisampleExtensionSupported)