Changeset 116221 in webkit


Ignore:
Timestamp:
May 5, 2012, 7:51:39 AM (13 years ago)
Author:
zmo@google.com
Message:

vertexAttribPointer needs to reject large negative offsets
https://bugs.webkit.org/show_bug.cgi?id=85117

Reviewed by Kenneth Russell.

Source/WebCore:

  • html/canvas/WebGLRenderingContext.cpp: Use long long for GLsizeiptr and GLintptr

(WebCore):
(WebCore::WebGLRenderingContext::bufferData):
(WebCore::WebGLRenderingContext::bufferSubData):
(WebCore::WebGLRenderingContext::drawElements):
(WebCore::WebGLRenderingContext::getVertexAttribOffset):
(WebCore::WebGLRenderingContext::vertexAttribPointer):

  • html/canvas/WebGLRenderingContext.h: Ditto

(WebGLRenderingContext):

  • html/canvas/WebGLRenderingContext.idl: Ditto

LayoutTests:

  • fast/canvas/webgl/index-validation-expected.txt:
  • fast/canvas/webgl/index-validation.html: Add a test case for large negative offset.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r116219 r116221  
     12012-05-05  Zhenyao Mo  <zmo@google.com>
     2
     3        vertexAttribPointer needs to reject large negative offsets
     4        https://bugs.webkit.org/show_bug.cgi?id=85117
     5
     6        Reviewed by Kenneth Russell.
     7
     8        * fast/canvas/webgl/index-validation-expected.txt:
     9        * fast/canvas/webgl/index-validation.html: Add a test case for large negative offset.
     10
    1112012-05-05  'Pavel Feldman'  <pfeldman@chromium.org>
    212
  • trunk/LayoutTests/fast/canvas/webgl/index-validation-expected.txt

    r63444 r116221  
    55Testing with valid indices
    66PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is gl.FRAMEBUFFER_COMPLETE
    7 PASS gl.getError() is 0
     7PASS getError was expected value: NO_ERROR :
    88PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined.
    9 PASS gl.getError() is 0
     9PASS getError was expected value: NO_ERROR :
    1010Testing with out-of-range indices
    1111Enable vertices, valid
    12 PASS gl.getError() is 0
     12PASS getError was expected value: NO_ERROR :
    1313PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined.
    14 PASS gl.getError() is 0
     14PASS getError was expected value: NO_ERROR :
    1515Enable normals, out-of-range
    16 PASS gl.getError() is 0
     16PASS getError was expected value: NO_ERROR :
    1717PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined.
    18 PASS gl.getError() is gl.INVALID_OPERATION
     18PASS getError was expected value: INVALID_OPERATION :
    1919Test with enabled attribute that does not belong to current program
    2020Enable an extra attribute with null
    21 PASS gl.getError() is 0
     21PASS getError was expected value: NO_ERROR :
    2222PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined.
    23 PASS gl.getError() is gl.INVALID_OPERATION
     23PASS getError was expected value: INVALID_OPERATION :
    2424Enable an extra attribute with insufficient data buffer
    25 PASS gl.getError() is 0
     25PASS getError was expected value: NO_ERROR :
    2626PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined.
    27 PASS gl.getError() is 0
     27Pass large negative index to vertexAttribPointer
     28PASS getError was expected value: INVALID_VALUE :
     29PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined.
    2830PASS successfullyParsed is true
    2931
  • trunk/LayoutTests/fast/canvas/webgl/index-validation.html

    r98407 r116221  
     1<!DOCTYPE html>
    12<html>
    23<head>
     4<meta charset="utf-8">
     5<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
    36<script src="../../js/resources/js-test-pre.js"></script>
    47<script src="resources/webgl-test.js"></script>
     
    6164gl.enableVertexAttribArray(normalLoc);
    6265shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
    63 shouldBe('gl.getError()', '0');
     66glErrorShouldBe(gl, gl.NO_ERROR);
    6467shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
    65 shouldBe('gl.getError()', '0');
     68glErrorShouldBe(gl, gl.NO_ERROR);
    6669
    6770debug("Testing with out-of-range indices");
     
    7477gl.disableVertexAttribArray(normalLoc);
    7578debug("Enable vertices, valid");
    76 shouldBe('gl.getError()', '0');
     79glErrorShouldBe(gl, gl.NO_ERROR);
    7780shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
    78 shouldBe('gl.getError()', '0');
     81glErrorShouldBe(gl, gl.NO_ERROR);
    7982debug("Enable normals, out-of-range");
    8083gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
    8184gl.enableVertexAttribArray(normalLoc);
    82 shouldBe('gl.getError()', '0');
     85glErrorShouldBe(gl, gl.NO_ERROR);
    8386shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
    84 shouldBe('gl.getError()', 'gl.INVALID_OPERATION');
     87glErrorShouldBe(gl, gl.INVALID_OPERATION);
    8588
    8689debug("Test with enabled attribute that does not belong to current program");
     
    9093gl.enableVertexAttribArray(extraLoc);
    9194debug("Enable an extra attribute with null");
    92 shouldBe('gl.getError()', '0');
     95glErrorShouldBe(gl, gl.NO_ERROR);
    9396shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
    94 shouldBe('gl.getError()', 'gl.INVALID_OPERATION');
     97glErrorShouldBe(gl, gl.INVALID_OPERATION);
    9598debug("Enable an extra attribute with insufficient data buffer");
    9699gl.vertexAttribPointer(extraLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
    97 shouldBe('gl.getError()', '0');
     100glErrorShouldBe(gl, gl.NO_ERROR);
    98101shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
    99 shouldBe('gl.getError()', '0');
     102debug("Pass large negative index to vertexAttribPointer");
     103gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), -2000000000 * sizeInBytes(gl.FLOAT));
     104glErrorShouldBe(gl, gl.INVALID_VALUE);
     105shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
     106
     107successfullyParsed = true;
    100108</script>
    101109
  • trunk/Source/WebCore/ChangeLog

    r116220 r116221  
     12012-05-05  Zhenyao Mo  <zmo@google.com>
     2
     3        vertexAttribPointer needs to reject large negative offsets
     4        https://bugs.webkit.org/show_bug.cgi?id=85117
     5
     6        Reviewed by Kenneth Russell.
     7
     8        * html/canvas/WebGLRenderingContext.cpp: Use long long for GLsizeiptr and GLintptr
     9        (WebCore):
     10        (WebCore::WebGLRenderingContext::bufferData):
     11        (WebCore::WebGLRenderingContext::bufferSubData):
     12        (WebCore::WebGLRenderingContext::drawElements):
     13        (WebCore::WebGLRenderingContext::getVertexAttribOffset):
     14        (WebCore::WebGLRenderingContext::vertexAttribPointer):
     15        * html/canvas/WebGLRenderingContext.h: Ditto
     16        (WebGLRenderingContext):
     17        * html/canvas/WebGLRenderingContext.idl: Ditto
     18
    1192012-05-05  Andrey Kosyakov  <caseq@chromium.org>
    220
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r115870 r116221  
    10371037}
    10381038
    1039 void WebGLRenderingContext::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage, ExceptionCode& ec)
     1039void WebGLRenderingContext::bufferData(GC3Denum target, long long size, GC3Denum usage, ExceptionCode& ec)
    10401040{
    10411041    UNUSED_PARAM(ec);
     
    11061106}
    11071107
    1108 void WebGLRenderingContext::bufferSubData(GC3Denum target, GC3Dintptr offset, ArrayBuffer* data, ExceptionCode& ec)
     1108void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, ArrayBuffer* data, ExceptionCode& ec)
    11091109{
    11101110    UNUSED_PARAM(ec);
     
    11311131}
    11321132
    1133 void WebGLRenderingContext::bufferSubData(GC3Denum target, GC3Dintptr offset, ArrayBufferView* data, ExceptionCode& ec)
     1133void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, ArrayBufferView* data, ExceptionCode& ec)
    11341134{
    11351135    UNUSED_PARAM(ec);
     
    18991899}
    19001900
    1901 void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, ExceptionCode& ec)
     1901void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, ExceptionCode& ec)
    19021902{
    19031903    UNUSED_PARAM(ec);
     
    30393039}
    30403040
    3041 GC3Dsizeiptr WebGLRenderingContext::getVertexAttribOffset(GC3Duint index, GC3Denum pname)
     3041long long WebGLRenderingContext::getVertexAttribOffset(GC3Duint index, GC3Denum pname)
    30423042{
    30433043    if (isContextLost())
     
    42514251}
    42524252
    4253 void WebGLRenderingContext::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset, ExceptionCode& ec)
     4253void WebGLRenderingContext::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, long long offset, ExceptionCode& ec)
    42544254{
    42554255    UNUSED_PARAM(ec);
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h

    r115870 r116221  
    9797    void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha);
    9898
    99     void bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage, ExceptionCode&);
     99    void bufferData(GC3Denum target, long long size, GC3Denum usage, ExceptionCode&);
    100100    void bufferData(GC3Denum target, ArrayBuffer* data, GC3Denum usage, ExceptionCode&);
    101101    void bufferData(GC3Denum target, ArrayBufferView* data, GC3Denum usage, ExceptionCode&);
    102     void bufferSubData(GC3Denum target, GC3Dintptr offset, ArrayBuffer* data, ExceptionCode&);
    103     void bufferSubData(GC3Denum target, GC3Dintptr offset, ArrayBufferView* data, ExceptionCode&);
     102    void bufferSubData(GC3Denum target, long long offset, ArrayBuffer* data, ExceptionCode&);
     103    void bufferSubData(GC3Denum target, long long offset, ArrayBufferView* data, ExceptionCode&);
    104104
    105105    GC3Denum checkFramebufferStatus(GC3Denum target);
     
    142142    void disableVertexAttribArray(GC3Duint index, ExceptionCode&);
    143143    void drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count, ExceptionCode&);
    144     void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, ExceptionCode&);
     144    void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, ExceptionCode&);
    145145
    146146    void enable(GC3Denum cap);
     
    175175    PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const String&, ExceptionCode&);
    176176    WebGLGetInfo getVertexAttrib(GC3Duint index, GC3Denum pname, ExceptionCode&);
    177     GC3Dsizeiptr getVertexAttribOffset(GC3Duint index, GC3Denum pname);
     177    long long getVertexAttribOffset(GC3Duint index, GC3Denum pname);
    178178
    179179    void hint(GC3Denum target, GC3Denum mode);
     
    282282    void vertexAttrib4fv(GC3Duint index, GC3Dfloat* values, GC3Dsizei size);
    283283    void vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized,
    284                              GC3Dsizei stride, GC3Dintptr offset, ExceptionCode&);
     284                             GC3Dsizei stride, long long offset, ExceptionCode&);
    285285
    286286    void viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.idl

    r115531 r116221  
    464464        [StrictTypeChecking] void         bufferData(in unsigned long target, in ArrayBuffer data, in unsigned long usage) raises (DOMException);
    465465        [StrictTypeChecking] void         bufferData(in unsigned long target, in ArrayBufferView data, in unsigned long usage) raises (DOMException);
    466         [StrictTypeChecking] void         bufferData(in unsigned long target, in long size, in unsigned long usage) raises (DOMException);
    467         [StrictTypeChecking] void         bufferSubData(in unsigned long target, in long offset, in ArrayBuffer data) raises (DOMException);
    468         [StrictTypeChecking] void         bufferSubData(in unsigned long target, in long offset, in ArrayBufferView data) raises (DOMException);
     466        [StrictTypeChecking] void         bufferData(in unsigned long target, in long long size, in unsigned long usage) raises (DOMException);
     467        [StrictTypeChecking] void         bufferSubData(in unsigned long target, in long long offset, in ArrayBuffer data) raises (DOMException);
     468        [StrictTypeChecking] void         bufferSubData(in unsigned long target, in long long offset, in ArrayBufferView data) raises (DOMException);
    469469
    470470        [StrictTypeChecking] unsigned long checkFramebufferStatus(in unsigned long target);
     
    508508        [StrictTypeChecking] void         disableVertexAttribArray(in unsigned long index) raises(DOMException);
    509509        [StrictTypeChecking] void         drawArrays(in unsigned long mode, in long first, in long count) raises(DOMException);
    510         [StrictTypeChecking] void         drawElements(in unsigned long mode, in long count, in unsigned long type, in long offset) raises(DOMException);
     510        [StrictTypeChecking] void         drawElements(in unsigned long mode, in long count, in unsigned long type, in long long offset) raises(DOMException);
    511511
    512512        [StrictTypeChecking] void         enable(in unsigned long cap);
     
    568568        [StrictTypeChecking, Custom] void getVertexAttrib();
    569569
    570         [StrictTypeChecking] long getVertexAttribOffset(in unsigned long index, in unsigned long pname);
     570        [StrictTypeChecking] long long getVertexAttribOffset(in unsigned long index, in unsigned long pname);
    571571
    572572        [StrictTypeChecking] void         hint(in unsigned long target, in unsigned long mode);
     
    662662        [StrictTypeChecking, Custom] void         vertexAttrib4fv(in unsigned long indx, in Float32Array values);
    663663        [StrictTypeChecking] void         vertexAttribPointer(in unsigned long indx, in long size, in unsigned long type, in boolean normalized,
    664                                                               in long stride, in long offset) raises(DOMException);
     664                                                              in long stride, in long long offset) raises(DOMException);
    665665
    666666        [StrictTypeChecking] void         viewport(in long x, in long y, in long width, in long height);
Note: See TracChangeset for help on using the changeset viewer.