Changeset 51400 in webkit


Ignore:
Timestamp:
Nov 25, 2009 4:44:39 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-11-25 Kenneth Russell <kbr@google.com>

Reviewed by Oliver Hunt.

Off-by-one error in index validation for drawElements and drawArrays
https://bugs.webkit.org/show_bug.cgi?id=31891

Fixed computation of number of elements for bound array objects.

Test: fast/canvas/webgl/index-validation.html

  • fast/canvas/webgl/index-validation-expected.txt: Added.
  • fast/canvas/webgl/index-validation.html: Added.
  • fast/canvas/webgl/script-tests/index-validation.js: Added.

2009-11-25 Kenneth Russell <kbr@google.com>

Reviewed by Oliver Hunt.

Off-by-one error in index validation for drawElements and drawArrays
https://bugs.webkit.org/show_bug.cgi?id=31891

Fixed computation of number of elements for bound array objects.

Test: fast/canvas/webgl/index-validation.html

  • html/canvas/WebGLRenderingContext.cpp: (WebCore::WebGLRenderingContext::vertexAttribPointer):
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r51398 r51400  
     12009-11-25  Kenneth Russell  <kbr@google.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Off-by-one error in index validation for drawElements and drawArrays
     6        https://bugs.webkit.org/show_bug.cgi?id=31891
     7
     8        Fixed computation of number of elements for bound array objects.
     9
     10        Test: fast/canvas/webgl/index-validation.html
     11
     12        * fast/canvas/webgl/index-validation-expected.txt: Added.
     13        * fast/canvas/webgl/index-validation.html: Added.
     14        * fast/canvas/webgl/script-tests/index-validation.js: Added.
     15
    1162009-11-25  Csaba Osztrogonác  <ossy@webkit.org>
    217
  • trunk/WebCore/ChangeLog

    r51397 r51400  
     12009-11-25  Kenneth Russell  <kbr@google.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Off-by-one error in index validation for drawElements and drawArrays
     6        https://bugs.webkit.org/show_bug.cgi?id=31891
     7
     8        Fixed computation of number of elements for bound array objects.
     9
     10        Test: fast/canvas/webgl/index-validation.html
     11
     12        * html/canvas/WebGLRenderingContext.cpp:
     13        (WebCore::WebGLRenderingContext::vertexAttribPointer):
     14
    1152009-11-25  Dmitry Titov  <dimich@chromium.org>
    216
  • trunk/WebCore/html/canvas/WebGLRenderingContext.cpp

    r51370 r51400  
    20472047{
    20482048    if (!m_boundArrayBuffer || indx >= m_maxVertexAttribs) {
     2049        // FIXME: raise GL_INVALID_VALUE error
    20492050        ec = INVALID_STATE_ERR;
    20502051        return;
     
    20592060    if (ec != 0)
    20602061        return;
    2061        
     2062    long validatedStride = bytesPerElement;
    20622063    if (stride != 0) {
    20632064        if ((long) stride < bytesPerElement) {
     2065            // FIXME: raise GL_INVALID_VALUE error
    20642066            ec = SYNTAX_ERR;
    20652067            return;
    20662068        }
    20672069       
    2068         bytesPerElement = stride;
    2069     }
    2070        
    2071     m_vertexAttribState[indx].numElements = (m_boundArrayBuffer->byteLength(GraphicsContext3D::ARRAY_BUFFER) - offset) / bytesPerElement;
     2070        validatedStride = stride;
     2071    }
     2072       
     2073    // Avoid off-by-one errors in numElements computation.
     2074    // For the last element, we will only touch the data for the
     2075    // element and nothing beyond it.
     2076    long bytesRemaining = m_boundArrayBuffer->byteLength(GraphicsContext3D::ARRAY_BUFFER) - offset;
     2077    if (bytesRemaining < bytesPerElement)
     2078        m_vertexAttribState[indx].numElements = 0;
     2079    else
     2080        m_vertexAttribState[indx].numElements = 1 + (bytesRemaining - bytesPerElement) / validatedStride;
    20722081
    20732082    m_context->vertexAttribPointer(indx, size, type, normalized, stride, offset);
Note: See TracChangeset for help on using the changeset viewer.