[WebGL] Vertex attribute binding validation method
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Aug 2013 07:17:10 +0000 (07:17 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Aug 2013 07:17:10 +0000 (07:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=119515

This patch refactors WebGLRenderingContext code by moving the vertex
attribute binding validation to a separate method. It is now
possible to use that validation in other parts of the code. The
code is more clear now.

Patch by Przemyslaw Szymanski <p.szymanski3@samsung.com> on 2013-08-16
Reviewed by Christophe Dumez.

No new tests. Covered by existing tests. No behaviour changed.
LayoutTests/webgl/resources/webgl_test_files/conformance/rendering/gl-drawelements.html
LayoutTests/webgl/resources/webgl_test_files/conformance/rendering/draw-elements-out-of-bounds.html
LayoutTests/webgl/resources/webgl_test_files/conformance/rendering/draw-arrays-out-of-bounds.html

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::validateVertexAttributes):
* html/canvas/WebGLVertexArrayObjectOES.h:
(WebCore::WebGLVertexArrayObjectOES::VertexAttribState::isBound):
(WebCore::WebGLVertexArrayObjectOES::VertexAttribState::validateBinding):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154166 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/canvas/WebGLRenderingContext.cpp
Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h

index 2c39952..b345c62 100644 (file)
@@ -1,3 +1,26 @@
+2013-08-16  Przemyslaw Szymanski  <p.szymanski3@samsung.com>
+
+        [WebGL] Vertex attribute binding validation method
+        https://bugs.webkit.org/show_bug.cgi?id=119515
+
+        This patch refactors WebGLRenderingContext code by moving the vertex
+        attribute binding validation to a separate method. It is now
+        possible to use that validation in other parts of the code. The
+        code is more clear now. 
+
+        Reviewed by Christophe Dumez.
+
+        No new tests. Covered by existing tests. No behaviour changed.
+        LayoutTests/webgl/resources/webgl_test_files/conformance/rendering/gl-drawelements.html
+        LayoutTests/webgl/resources/webgl_test_files/conformance/rendering/draw-elements-out-of-bounds.html
+        LayoutTests/webgl/resources/webgl_test_files/conformance/rendering/draw-arrays-out-of-bounds.html
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::validateVertexAttributes):
+        * html/canvas/WebGLVertexArrayObjectOES.h:
+        (WebCore::WebGLVertexArrayObjectOES::VertexAttribState::isBound):
+        (WebCore::WebGLVertexArrayObjectOES::VertexAttribState::validateBinding):
+
 2013-08-15  Antti Koivisto  <antti@apple.com>
 
         <https://webkit.org/b/119865> Parent pointer and shadow root host pointer should not be shared
index d9a01d3..c5610d3 100644 (file)
@@ -1881,9 +1881,7 @@ bool WebGLRenderingContext::validateVertexAttributes(unsigned numElementsRequire
 
     // Look in each enabled vertex attrib and check if they've been bound to a buffer.
     for (unsigned i = 0; i < m_maxVertexAttribs; ++i) {
-        const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(i);
-        if (state.enabled
-            && (!state.bufferBinding || !state.bufferBinding->object()))
+        if (!m_boundVertexArrayObject->getVertexAttribState(i).validateBinding())
             return false;
     }
 
index 4b98955..4f97dcd 100644 (file)
@@ -58,6 +58,9 @@ public:
         {
         }
         
+        bool isBound() const { return bufferBinding && bufferBinding->object(); }
+        bool validateBinding() const { return !enabled || isBound(); }
+
         bool enabled;
         RefPtr<WebGLBuffer> bufferBinding;
         GC3Dsizei bytesPerElement;