Diff
Modified: trunk/LayoutTests/ChangeLog (89392 => 89393)
--- trunk/LayoutTests/ChangeLog 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/LayoutTests/ChangeLog 2011-06-21 23:46:49 UTC (rev 89393)
@@ -1,3 +1,17 @@
+2011-06-21 Zhenyao Mo <z...@google.com>
+
+ Reviewed by Kenneth Russell.
+
+ Implement drawingBufferWidth/drawingBufferHeight in WebGL
+ https://bugs.webkit.org/show_bug.cgi?id=58497
+
+ * fast/canvas/webgl/webgl-specific-expected.txt:
+ * fast/canvas/webgl/webgl-specific.html: Test drawingBufferWidth/Height attributes.
+ * fast/canvas/webgl/canvas-zero-size-expected.txt:
+ * fast/canvas/webgl/canvas-zero-size.html: Added.
+ * fast/canvas/webgl/drawingbuffer-test-expected.txt:
+ * fast/canvas/webgl/drawingbuffer-test.html: Added.
+
2011-06-21 Dmitry Titov <dim...@chromium.org>
[Chromium] Unreviewed update of test expectations.
Added: trunk/LayoutTests/fast/canvas/webgl/canvas-zero-size-expected.txt (0 => 89393)
--- trunk/LayoutTests/fast/canvas/webgl/canvas-zero-size-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/canvas-zero-size-expected.txt 2011-06-21 23:46:49 UTC (rev 89393)
@@ -0,0 +1,10 @@
+Tests that a zero size canvas does not fail.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS program != null is true
+PASS getError was expected value: NO_ERROR : Should be no errors from setup.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/canvas/webgl/canvas-zero-size-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/canvas/webgl/canvas-zero-size.html (0 => 89393)
--- trunk/LayoutTests/fast/canvas/webgl/canvas-zero-size.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/canvas-zero-size.html 2011-06-21 23:46:49 UTC (rev 89393)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Zero Size Canvas Test</title>
+ <link rel="stylesheet" href=""
+ <script src=""
+ <script src="" </script>
+ <script src="" </script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("Tests that a zero size canvas does not fail.");
+var wtu = WebGLTestUtils;
+var canvas = document.createElement('canvas');
+var gl = wtu.create3DContext(canvas);
+canvas.width = 0;
+canvas.height = 0;
+gl.viewport(0, 0, 0, 0);
+var program = wtu.setupTexturedQuad(gl);
+shouldBeTrue("program != null");
+var tex = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, tex);
+var pixel = new Uint8Array([0, 255, 0, 255]);
+gl.texImage2D(
+ gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, pixel);
+wtu.drawQuad(gl);
+
+glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+successfullyParsed = true;
+</script>
+<script src=""
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/canvas/webgl/canvas-zero-size.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/canvas/webgl/drawingbuffer-test-expected.txt (0 => 89393)
--- trunk/LayoutTests/fast/canvas/webgl/drawingbuffer-test-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/drawingbuffer-test-expected.txt 2011-06-21 23:46:49 UTC (rev 89393)
@@ -0,0 +1,21 @@
+This test ensures WebGL implementations correctly implement drawingbufferWidth/Height.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS context exists
+
+Checking drawingBufferWidth/drawingBufferHeight
+PASS gl.drawingBufferWidth is canvas.width
+PASS gl.drawingBufferHeight is canvas.height
+PASS maxSize[0] > 0 is true
+PASS maxSize[1] > 0 is true
+PASS gl.drawingBufferWidth > 0 is true
+PASS gl.drawingBufferHeight > 0 is true
+PASS gl.drawingBufferWidth <= maxSize[0] is true
+PASS gl.drawingBufferHeight <= maxSize[1] is true
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/canvas/webgl/drawingbuffer-test-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/canvas/webgl/drawingbuffer-test.html (0 => 89393)
--- trunk/LayoutTests/fast/canvas/webgl/drawingbuffer-test.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/drawingbuffer-test.html 2011-06-21 23:46:49 UTC (rev 89393)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Canvas Conformance Tests</title>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("This test ensures WebGL implementations correctly implement drawingbufferWidth/Height.");
+
+debug("");
+
+var wtu = WebGLTestUtils;
+var err;
+var maxSize;
+var canvas = document.createElement("canvas");
+var gl = wtu.create3DContext(canvas);
+if (!gl) {
+ testFailed("context does not exist");
+} else {
+ testPassed("context exists");
+
+ debug("");
+ debug("Checking drawingBufferWidth/drawingBufferHeight");
+
+ // Check that a canvas with no width or height is 300x150 pixels
+ shouldBe('gl.drawingBufferWidth', 'canvas.width');
+ shouldBe('gl.drawingBufferHeight', 'canvas.height');
+
+ // Check that changing the canvas size to something too large falls back to reasonable values.
+ maxSize = gl.getParameter(gl.MAX_VIEWPORT_DIMS);
+ shouldBeTrue('maxSize[0] > 0');
+ shouldBeTrue('maxSize[1] > 0');
+
+ // debug("MAX_VIEWPORT_DIMS = " + maxSize[0] + "x" + maxSize[1]);
+ canvas.width = maxSize[0] * 4;
+ canvas.height = maxSize[1] * 4;
+ shouldBeTrue('gl.drawingBufferWidth > 0');
+ shouldBeTrue('gl.drawingBufferHeight > 0');
+ shouldBeTrue('gl.drawingBufferWidth <= maxSize[0]');
+ shouldBeTrue('gl.drawingBufferHeight <= maxSize[1]');
+}
+debug("")
+successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/canvas/webgl/drawingbuffer-test.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/LayoutTests/fast/canvas/webgl/webgl-specific-expected.txt (89392 => 89393)
--- trunk/LayoutTests/fast/canvas/webgl/webgl-specific-expected.txt 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/LayoutTests/fast/canvas/webgl/webgl-specific-expected.txt 2011-06-21 23:46:49 UTC (rev 89393)
@@ -47,10 +47,19 @@
PASS undefined is undefined.
PASS undefined is undefined.
+Verify that *LENGTH are undefined
+PASS undefined is undefined.
+PASS undefined is undefined.
+PASS undefined is undefined.
+PASS undefined is undefined.
+
Verify that UNPACK_COLORSPACE_CONVERSION_WEBGL is supported
PASS gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL) is gl.BROWSER_DEFAULT_WEBGL
PASS gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL) is gl.NONE
PASS getError was expected value: NO_ERROR : set/get UNPACK_COLORSPACE_CONVERSION_WEBGL should generate no error
+
+Verify that drawingBufferWidth and drawingBufferHeights are implemented
+PASS gl.drawingBufferWidth >= 0 && gl.drawingBufferHeight >= 0 is true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/canvas/webgl/webgl-specific.html (89392 => 89393)
--- trunk/LayoutTests/fast/canvas/webgl/webgl-specific.html 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/LayoutTests/fast/canvas/webgl/webgl-specific.html 2011-06-21 23:46:49 UTC (rev 89393)
@@ -1,7 +1,7 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html>
<html>
<head>
+<meta charset="utf-8">
<title>WebGL GLES2 difference test.</title>
<link rel="stylesheet" href=""
<script src=""
@@ -74,12 +74,23 @@
shouldBeUndefined(gl.IMPLEMENTATION_COLOR_READ_TYPE);
debug("");
+debug("Verify that *LENGTH are undefined");
+shouldBeUndefined(gl.INFO_LOG_LENGTH);
+shouldBeUndefined(gl.SHADER_SOURCE_LENGTH);
+shouldBeUndefined(gl.ACTIVE_UNIFORM_MAX_LENGTH);
+shouldBeUndefined(gl.ACTIVE_ATTRIB_MAX_LENGTH);
+
+debug("");
debug("Verify that UNPACK_COLORSPACE_CONVERSION_WEBGL is supported");
shouldBe("gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL)", "gl.BROWSER_DEFAULT_WEBGL");
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
shouldBe("gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL)", "gl.NONE");
glErrorShouldBe(gl, gl.NO_ERROR, "set/get UNPACK_COLORSPACE_CONVERSION_WEBGL should generate no error");
+debug("");
+debug("Verify that drawingBufferWidth and drawingBufferHeights are implemented");
+shouldBeTrue("gl.drawingBufferWidth >= 0 && gl.drawingBufferHeight >= 0");
+
successfullyParsed = true;
</script>
Modified: trunk/Source/WebCore/ChangeLog (89392 => 89393)
--- trunk/Source/WebCore/ChangeLog 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/Source/WebCore/ChangeLog 2011-06-21 23:46:49 UTC (rev 89393)
@@ -1,3 +1,21 @@
+2011-06-21 Zhenyao Mo <z...@google.com>
+
+ Reviewed by Kenneth Russell.
+
+ Implement drawingBufferWidth/drawingBufferHeight in WebGL
+ https://bugs.webkit.org/show_bug.cgi?id=58497
+
+ * html/canvas/WebGLRenderingContext.cpp: Add drawingBufferWidth/Height method and call getInternalFramebufferSize().
+ (WebCore::WebGLRenderingContext::drawingBufferWidth):
+ (WebCore::WebGLRenderingContext::drawingBufferHeight):
+ * html/canvas/WebGLRenderingContext.h:
+ * html/canvas/WebGLRenderingContext.idl: Add readonly attributes drawingBufferWidth/Height.
+ * platform/graphics/GraphicsContext3D.h:
+ * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: Make getInternalFramebufferSize const.
+ (WebCore::GraphicsContext3D::getInternalFramebufferSize):
+ * platform/graphics/qt/GraphicsContext3DQt.cpp: Ditto.
+ (WebCore::GraphicsContext3D::getInternalFramebufferSize):
+
2011-06-21 Dmitry Lomov <dslo...@google.com>
Reviewed by Adam Barth.
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (89392 => 89393)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2011-06-21 23:46:49 UTC (rev 89393)
@@ -109,6 +109,15 @@
return (*clippedX != x || *clippedY != y || *clippedWidth != width || *clippedHeight != height);
}
+ GC3Dint clamp(GC3Dint value, GC3Dint min, GC3Dint max)
+ {
+ if (value < min)
+ value = min;
+ if (value > max)
+ value = max;
+ return value;
+ }
+
// Return true if a character belongs to the ASCII subset as defined in
// GLSL ES 1.0 spec section 3.1.
bool validateCharacter(unsigned char c)
@@ -439,7 +448,11 @@
m_maxCubeMapTextureSize = 0;
m_context->getIntegerv(GraphicsContext3D::MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTextureSize);
m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextureSize, m_maxCubeMapTextureSize);
-
+ m_maxRenderbufferSize = 0;
+ m_context->getIntegerv(GraphicsContext3D::MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize);
+ m_maxViewportDims[0] = m_maxViewportDims[1] = 0;
+ m_context->getIntegerv(GraphicsContext3D::MAX_VIEWPORT_DIMS, m_maxViewportDims);
+
m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVertexArrayObjectOES::VaoTypeDefault);
addObject(m_defaultVertexArrayObject.get());
m_boundVertexArrayObject = m_defaultVertexArrayObject;
@@ -593,6 +606,14 @@
void WebGLRenderingContext::reshape(int width, int height)
{
+ // This is an approximation because at WebGLRenderingContext level we don't
+ // know if the underlying FBO uses textures or renderbuffers.
+ GC3Dint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize);
+ GC3Dint maxWidth = std::min(maxSize, m_maxViewportDims[0]);
+ GC3Dint maxHeight = std::min(maxSize, m_maxViewportDims[1]);
+ width = clamp(width, 1, maxWidth);
+ height = clamp(height, 1, maxHeight);
+
if (m_needsUpdate) {
#if USE(ACCELERATED_COMPOSITING)
RenderBox* renderBox = canvas()->renderBox();
@@ -607,6 +628,16 @@
m_context->reshape(width, height);
}
+int WebGLRenderingContext::drawingBufferWidth() const
+{
+ return m_context->getInternalFramebufferSize().width();
+}
+
+int WebGLRenderingContext::drawingBufferHeight() const
+{
+ return m_context->getInternalFramebufferSize().height();
+}
+
unsigned int WebGLRenderingContext::sizeInBytes(GC3Denum type)
{
switch (type) {
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h (89392 => 89393)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h 2011-06-21 23:46:49 UTC (rev 89393)
@@ -71,6 +71,9 @@
virtual bool isAccelerated() const { return true; }
virtual bool paintsIntoCanvasBuffer() const;
+ int drawingBufferWidth() const;
+ int drawingBufferHeight() const;
+
void activeTexture(GC3Denum texture, ExceptionCode&);
void attachShader(WebGLProgram*, WebGLShader*, ExceptionCode&);
void bindAttribLocation(WebGLProgram*, GC3Duint index, const String& name, ExceptionCode&);
@@ -430,6 +433,8 @@
GC3Dint m_maxTextureSize;
GC3Dint m_maxCubeMapTextureSize;
+ GC3Dint m_maxRenderbufferSize;
+ GC3Dint m_maxViewportDims[2];
GC3Dint m_maxTextureLevel;
GC3Dint m_maxCubeMapTextureLevel;
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.idl (89392 => 89393)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.idl 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.idl 2011-06-21 23:46:49 UTC (rev 89393)
@@ -451,6 +451,9 @@
const unsigned int UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;
const unsigned int BROWSER_DEFAULT_WEBGL = 0x9244;
+ readonly attribute long drawingBufferWidth;
+ readonly attribute long drawingBufferHeight;
+
[StrictTypeChecking] void activeTexture(in unsigned long texture) raises(DOMException);
[StrictTypeChecking] void attachShader(in WebGLProgram program, in WebGLShader shader) raises(DOMException);
[StrictTypeChecking] void bindAttribLocation(in WebGLProgram program, in unsigned long index, in DOMString name) raises(DOMException);
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (89392 => 89393)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2011-06-21 23:46:49 UTC (rev 89393)
@@ -820,7 +820,7 @@
// determine this.
Extensions3D* getExtensions();
- IntSize getInternalFramebufferSize();
+ IntSize getInternalFramebufferSize() const;
private:
GraphicsContext3D(Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow);
Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp (89392 => 89393)
--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp 2011-06-21 23:46:49 UTC (rev 89393)
@@ -317,7 +317,7 @@
::glFlush();
}
-IntSize GraphicsContext3D::getInternalFramebufferSize()
+IntSize GraphicsContext3D::getInternalFramebufferSize() const
{
return IntSize(m_currentWidth, m_currentHeight);
}
Modified: trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp (89392 => 89393)
--- trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp 2011-06-21 23:46:49 UTC (rev 89393)
@@ -750,7 +750,7 @@
m_internal->reshape(width, height);
}
-IntSize GraphicsContext3D::getInternalFramebufferSize()
+IntSize GraphicsContext3D::getInternalFramebufferSize() const
{
return IntSize(m_currentWidth, m_currentHeight);
}
Modified: trunk/Source/WebKit/chromium/ChangeLog (89392 => 89393)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-06-21 23:46:49 UTC (rev 89393)
@@ -1,3 +1,15 @@
+2011-06-21 Zhenyao Mo <z...@google.com>
+
+ Reviewed by Kenneth Russell.
+
+ Implement drawingBufferWidth/drawingBufferHeight in WebGL
+ https://bugs.webkit.org/show_bug.cgi?id=58497
+
+ * src/GraphicsContext3DChromium.cpp: Make getInternalFramebufferSize method const.
+ (WebCore::GraphicsContext3DInternal::getInternalFramebufferSize):
+ (WebCore::GraphicsContext3D::getInternalFramebufferSize):
+ * src/GraphicsContext3DInternal.h:
+
2011-06-21 Dmitry Lomov <dslo...@google.com>
Reviewed by Adam Barth.
Modified: trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp (89392 => 89393)
--- trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp 2011-06-21 23:46:49 UTC (rev 89393)
@@ -287,7 +287,7 @@
#endif // USE(CG)
}
-IntSize GraphicsContext3DInternal::getInternalFramebufferSize()
+IntSize GraphicsContext3DInternal::getInternalFramebufferSize() const
{
return IntSize(m_impl->width(), m_impl->height());
}
@@ -967,6 +967,11 @@
return m_internal->prepareTexture();
}
+IntSize GraphicsContext3D::getInternalFramebufferSize() const
+{
+ return m_internal->getInternalFramebufferSize();
+}
+
#if USE(ACCELERATED_COMPOSITING)
PlatformLayer* GraphicsContext3D::platformLayer() const
{
@@ -978,7 +983,6 @@
DELEGATE_TO_INTERNAL(makeContextCurrent)
DELEGATE_TO_INTERNAL_2(reshape, int, int)
-DELEGATE_TO_INTERNAL_R(getInternalFramebufferSize, IntSize)
DELEGATE_TO_INTERNAL_1(activeTexture, GC3Denum)
DELEGATE_TO_INTERNAL_2(attachShader, Platform3DObject, Platform3DObject)
Modified: trunk/Source/WebKit/chromium/src/GraphicsContext3DInternal.h (89392 => 89393)
--- trunk/Source/WebKit/chromium/src/GraphicsContext3DInternal.h 2011-06-21 23:39:28 UTC (rev 89392)
+++ trunk/Source/WebKit/chromium/src/GraphicsContext3DInternal.h 2011-06-21 23:46:49 UTC (rev 89393)
@@ -66,7 +66,7 @@
bool makeContextCurrent();
void reshape(int width, int height);
- IntSize getInternalFramebufferSize();
+ IntSize getInternalFramebufferSize() const;
void markContextChanged();
bool layerComposited() const;