[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

zmo at google.com zmo at google.com
Wed Dec 22 13:48:08 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit ca10f4edea61e45e118cbfdb967ec09a6bb90184
Author: zmo at google.com <zmo at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Sep 27 17:23:02 2010 +0000

    2010-09-14  Zhenyao Mo  <zmo at google.com>
    
            Reviewed by Kenneth Russell.
    
            drawElements with count=0 and offset = 0 should not generate GL error or crash
            https://bugs.webkit.org/show_bug.cgi?id=45769
    
            * html/canvas/WebGLRenderingContext.cpp: Deal with count=0 case.
            (WebCore::WebGLRenderingContext::validateIndexArrayConservative):
            (WebCore::WebGLRenderingContext::validateIndexArrayPrecise):
            (WebCore::WebGLRenderingContext::drawElements):
    2010-09-14  Zhenyao Mo  <zmo at google.com>
    
            Reviewed by Kenneth Russell.
    
            drawElements with count=0 and offset = 0 should not generate GL error or crash
            https://bugs.webkit.org/show_bug.cgi?id=45769
    
            * fast/canvas/webgl/draw-elements-out-of-bounds-expected.txt: Test count=0 cases.
            * fast/canvas/webgl/draw-elements-out-of-bounds.html: Ditto.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68401 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 70baf37..dc67faa 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-09-14  Zhenyao Mo  <zmo at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        drawElements with count=0 and offset = 0 should not generate GL error or crash
+        https://bugs.webkit.org/show_bug.cgi?id=45769
+
+        * fast/canvas/webgl/draw-elements-out-of-bounds-expected.txt: Test count=0 cases.
+        * fast/canvas/webgl/draw-elements-out-of-bounds.html: Ditto.
+
 2010-09-16  Zhenyao Mo  <zmo at google.com>
 
         Reviewed by Kenneth Russell.
diff --git a/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-expected.txt b/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-expected.txt
index 3d8deb8..8e52dfd 100644
--- a/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-expected.txt
@@ -34,6 +34,7 @@ PASS context.bufferSubData(context.ELEMENT_ARRAY_BUFFER, 0, new Uint8Array([ 3,
 PASS context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0) generated expected GL error: INVALID_OPERATION.
 PASS context.bufferSubData(context.ELEMENT_ARRAY_BUFFER, 0, (new Uint8Array([ 3, 0, 1, 2 ])).slice(1)) generated expected GL error: NO_ERROR.
 PASS context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0) generated expected GL error: NO_ERROR.
+PASS context.drawElements(context.TRIANGLES, 0, context.UNSIGNED_BYTE, 0) generated expected GL error: NO_ERROR.
 
 Test buffer with interleaved (3+2) float vectors
 PASS context.drawElements(context.TRIANGLES, 9, context.UNSIGNED_SHORT, 0) generated expected GL error: NO_ERROR.
@@ -47,6 +48,7 @@ PASS context.drawElements(context.TRIANGLES, 18, context.UNSIGNED_SHORT, 0) gene
 PASS context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_SHORT, 2*15) generated expected GL error: INVALID_OPERATION.
 PASS context.drawElements(context.TRIANGLES, 0xffffffff, context.UNSIGNED_SHORT, 0) generated expected GL error: INVALID_VALUE.
 PASS context.drawElements(context.TRIANGLES, 0x7fffffff, context.UNSIGNED_SHORT, 0) generated expected GL error: INVALID_OPERATION.
+PASS context.drawElements(context.TRIANGLES, 0, context.UNSIGNED_SHORT, 0) generated expected GL error: NO_ERROR.
 
 PASS successfullyParsed is true
 
diff --git a/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds.html b/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds.html
index cd32c1c..a8054d4 100644
--- a/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds.html
+++ b/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds.html
@@ -61,6 +61,7 @@ shouldGenerateGLError(context, context.NO_ERROR, "context.bufferSubData(context.
 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0)");
 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferSubData(context.ELEMENT_ARRAY_BUFFER, 0, (new Uint8Array([ 3, 0, 1, 2 ])).slice(1))");
 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 0, context.UNSIGNED_BYTE, 0)");
 
 debug("")
 debug("Test buffer with interleaved (3+2) float vectors")
@@ -117,6 +118,8 @@ shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(
 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(context.TRIANGLES, 0xffffffff, context.UNSIGNED_SHORT, 0)");
 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLES, 0x7fffffff, context.UNSIGNED_SHORT, 0)");
 
+shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 0, context.UNSIGNED_SHORT, 0)");
+
 debug("")
 successfullyParsed = true;
 </script>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d4e8ad5..dfc3140 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,15 @@
+2010-09-14  Zhenyao Mo  <zmo at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        drawElements with count=0 and offset = 0 should not generate GL error or crash
+        https://bugs.webkit.org/show_bug.cgi?id=45769
+
+        * html/canvas/WebGLRenderingContext.cpp: Deal with count=0 case.
+        (WebCore::WebGLRenderingContext::validateIndexArrayConservative):
+        (WebCore::WebGLRenderingContext::validateIndexArrayPrecise):
+        (WebCore::WebGLRenderingContext::drawElements):
+
 2010-09-16  Zhenyao Mo  <zmo at google.com>
 
         Reviewed by Kenneth Russell.
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 8c371a4..ff64c95 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -775,30 +775,31 @@ bool WebGLRenderingContext::validateIndexArrayConservative(unsigned long type, l
     // index, skips the expensive per-draw-call iteration in
     // validateIndexArrayPrecise.
 
+    if (!m_boundElementArrayBuffer)
+        return false;
+
+    unsigned numElements = m_boundElementArrayBuffer->byteLength();
+    // The case count==0 is already dealt with in drawElements before validateIndexArrayConservative.
+    if (!numElements)
+        return false;
+    const ArrayBuffer* buffer = m_boundElementArrayBuffer->elementArrayBuffer();
+    ASSERT(buffer);
+
     long maxIndex = m_boundElementArrayBuffer->getCachedMaxIndex(type);
     if (maxIndex < 0) {
         // Compute the maximum index in the entire buffer for the given type of index.
         switch (type) {
         case GraphicsContext3D::UNSIGNED_BYTE: {
-            unsigned numElements = m_boundElementArrayBuffer->byteLength();
-            if (!numElements)
-                maxIndex = 0;
-            else {
-                const unsigned char* p = static_cast<const unsigned char*>(m_boundElementArrayBuffer->elementArrayBuffer()->data());
-                for (unsigned i = 0; i < numElements; i++)
-                    maxIndex = max(maxIndex, static_cast<long>(p[i]));
-            }
+            const unsigned char* p = static_cast<const unsigned char*>(buffer->data());
+            for (unsigned i = 0; i < numElements; i++)
+                maxIndex = max(maxIndex, static_cast<long>(p[i]));
             break;
         }
         case GraphicsContext3D::UNSIGNED_SHORT: {
-            unsigned numElements = m_boundElementArrayBuffer->byteLength() / sizeof(unsigned short);
-            if (!numElements)
-                maxIndex = 0;
-            else {
-                const unsigned short* p = static_cast<const unsigned short*>(m_boundElementArrayBuffer->elementArrayBuffer()->data());
-                for (unsigned i = 0; i < numElements; i++)
-                    maxIndex = max(maxIndex, static_cast<long>(p[i]));
-            }
+            numElements /= sizeof(unsigned short);
+            const unsigned short* p = static_cast<const unsigned short*>(buffer->data());
+            for (unsigned i = 0; i < numElements; i++)
+                maxIndex = max(maxIndex, static_cast<long>(p[i]));
             break;
         }
         default:
@@ -824,6 +825,14 @@ bool WebGLRenderingContext::validateIndexArrayPrecise(unsigned long count, unsig
     if (!m_boundElementArrayBuffer)
         return false;
 
+    if (!count) {
+        numElementsRequired = 0;
+        return true;
+    }
+
+    if (!m_boundElementArrayBuffer->elementArrayBuffer())
+        return false;
+
     unsigned long uoffset = static_cast<unsigned long>(offset);
     unsigned long n = count;
 
@@ -968,6 +977,8 @@ void WebGLRenderingContext::drawElements(unsigned long mode, long count, unsigne
             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
             return;
         }
+        if (!count)
+            return;
         if (!validateIndexArrayConservative(type, numElements) || !validateRenderingState(numElements)) {
             if (!validateIndexArrayPrecise(count, type, offset, numElements) || !validateRenderingState(numElements)) {
                 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list