Changeset 116374 in webkit
- Timestamp:
- May 7, 2012 4:56:47 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r116373 r116374 1 2012-05-04 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 1 11 2012-05-07 Pravin D <pravind.2k4@gmail.com> 2 12 -
trunk/LayoutTests/fast/canvas/webgl/index-validation-expected.txt
r116232 r116374 5 5 Testing with valid indices 6 6 PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is gl.FRAMEBUFFER_COMPLETE 7 PASS g l.getError() is 07 PASS getError was expected value: NO_ERROR : 8 8 PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined. 9 PASS g l.getError() is 09 PASS getError was expected value: NO_ERROR : 10 10 Testing with out-of-range indices 11 11 Enable vertices, valid 12 PASS g l.getError() is 012 PASS getError was expected value: NO_ERROR : 13 13 PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined. 14 PASS g l.getError() is 014 PASS getError was expected value: NO_ERROR : 15 15 Enable normals, out-of-range 16 PASS g l.getError() is 016 PASS getError was expected value: NO_ERROR : 17 17 PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined. 18 PASS g l.getError() is gl.INVALID_OPERATION18 PASS getError was expected value: INVALID_OPERATION : 19 19 Test with enabled attribute that does not belong to current program 20 20 Enable an extra attribute with null 21 PASS g l.getError() is 021 PASS getError was expected value: NO_ERROR : 22 22 PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined. 23 PASS g l.getError() is gl.INVALID_OPERATION23 PASS getError was expected value: INVALID_OPERATION : 24 24 Enable an extra attribute with insufficient data buffer 25 PASS g l.getError() is 025 PASS getError was expected value: NO_ERROR : 26 26 PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined. 27 PASS gl.getError() is 0 27 Pass large negative index to vertexAttribPointer 28 PASS getError was expected value: INVALID_VALUE : 29 PASS gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0) is undefined. 28 30 PASS successfullyParsed is true 29 31 -
trunk/LayoutTests/fast/canvas/webgl/index-validation.html
r116232 r116374 1 <!DOCTYPE html> 1 2 <html> 2 3 <head> 4 <meta charset="utf-8"> 5 <link rel="stylesheet" href="../../js/resources/js-test-style.css"/> 3 6 <script src="../../js/resources/js-test-pre.js"></script> 4 7 <script src="resources/webgl-test.js"></script> … … 61 64 gl.enableVertexAttribArray(normalLoc); 62 65 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE'); 63 shouldBe('gl.getError()', '0');66 glErrorShouldBe(gl, gl.NO_ERROR); 64 67 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)'); 65 shouldBe('gl.getError()', '0');68 glErrorShouldBe(gl, gl.NO_ERROR); 66 69 67 70 debug("Testing with out-of-range indices"); … … 74 77 gl.disableVertexAttribArray(normalLoc); 75 78 debug("Enable vertices, valid"); 76 shouldBe('gl.getError()', '0');79 glErrorShouldBe(gl, gl.NO_ERROR); 77 80 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)'); 78 shouldBe('gl.getError()', '0');81 glErrorShouldBe(gl, gl.NO_ERROR); 79 82 debug("Enable normals, out-of-range"); 80 83 gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT)); 81 84 gl.enableVertexAttribArray(normalLoc); 82 shouldBe('gl.getError()', '0');85 glErrorShouldBe(gl, gl.NO_ERROR); 83 86 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)'); 84 shouldBe('gl.getError()', 'gl.INVALID_OPERATION');87 glErrorShouldBe(gl, gl.INVALID_OPERATION); 85 88 86 89 debug("Test with enabled attribute that does not belong to current program"); … … 90 93 gl.enableVertexAttribArray(extraLoc); 91 94 debug("Enable an extra attribute with null"); 92 shouldBe('gl.getError()', '0');95 glErrorShouldBe(gl, gl.NO_ERROR); 93 96 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)'); 94 shouldBe('gl.getError()', 'gl.INVALID_OPERATION');97 glErrorShouldBe(gl, gl.INVALID_OPERATION); 95 98 debug("Enable an extra attribute with insufficient data buffer"); 96 99 gl.vertexAttribPointer(extraLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT)); 97 shouldBe('gl.getError()', '0');100 glErrorShouldBe(gl, gl.NO_ERROR); 98 101 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)'); 99 shouldBe('gl.getError()', '0'); 102 debug("Pass large negative index to vertexAttribPointer"); 103 gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), -2000000000 * sizeInBytes(gl.FLOAT)); 104 glErrorShouldBe(gl, gl.INVALID_VALUE); 105 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)'); 106 107 successfullyParsed = true; 100 108 </script> 101 109 -
trunk/Source/WebCore/ChangeLog
r116373 r116374 1 2012-05-04 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 1 19 2012-05-07 Pravin D <pravind.2k4@gmail.com> 2 20 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
r116232 r116374 1037 1037 } 1038 1038 1039 void WebGLRenderingContext::bufferData(GC3Denum target, GC3Dsizeiptrsize, GC3Denum usage, ExceptionCode& ec)1039 void WebGLRenderingContext::bufferData(GC3Denum target, long long size, GC3Denum usage, ExceptionCode& ec) 1040 1040 { 1041 1041 UNUSED_PARAM(ec); … … 1050 1050 } 1051 1051 if (!isErrorGeneratedOnOutOfBoundsAccesses()) { 1052 if (!buffer->associateBufferData(s ize)) {1052 if (!buffer->associateBufferData(static_cast<GC3Dsizeiptr>(size))) { 1053 1053 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "invalid buffer"); 1054 1054 return; … … 1056 1056 } 1057 1057 1058 m_context->bufferData(target, s ize, usage);1058 m_context->bufferData(target, static_cast<GC3Dsizeiptr>(size), usage); 1059 1059 cleanupAfterGraphicsCall(false); 1060 1060 } … … 1106 1106 } 1107 1107 1108 void WebGLRenderingContext::bufferSubData(GC3Denum target, GC3Dintptroffset, ArrayBuffer* data, ExceptionCode& ec)1108 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, ArrayBuffer* data, ExceptionCode& ec) 1109 1109 { 1110 1110 UNUSED_PARAM(ec); … … 1121 1121 return; 1122 1122 if (!isErrorGeneratedOnOutOfBoundsAccesses()) { 1123 if (!buffer->associateBufferSubData( offset, data)) {1123 if (!buffer->associateBufferSubData(static_cast<GC3Dintptr>(offset), data)) { 1124 1124 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "offset out of range"); 1125 1125 return; … … 1127 1127 } 1128 1128 1129 m_context->bufferSubData(target, offset, data->byteLength(), data->data());1130 cleanupAfterGraphicsCall(false); 1131 } 1132 1133 void WebGLRenderingContext::bufferSubData(GC3Denum target, GC3Dintptroffset, ArrayBufferView* data, ExceptionCode& ec)1129 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byteLength(), data->data()); 1130 cleanupAfterGraphicsCall(false); 1131 } 1132 1133 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, ArrayBufferView* data, ExceptionCode& ec) 1134 1134 { 1135 1135 UNUSED_PARAM(ec); … … 1146 1146 return; 1147 1147 if (!isErrorGeneratedOnOutOfBoundsAccesses()) { 1148 if (!buffer->associateBufferSubData( offset, data)) {1148 if (!buffer->associateBufferSubData(static_cast<GC3Dintptr>(offset), data)) { 1149 1149 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "offset out of range"); 1150 1150 return; … … 1152 1152 } 1153 1153 1154 m_context->bufferSubData(target, offset, data->byteLength(), data->baseAddress());1154 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byteLength(), data->baseAddress()); 1155 1155 cleanupAfterGraphicsCall(false); 1156 1156 } … … 1899 1899 } 1900 1900 1901 void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptroffset, ExceptionCode& ec)1901 void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, ExceptionCode& ec) 1902 1902 { 1903 1903 UNUSED_PARAM(ec); … … 1934 1934 if (!isErrorGeneratedOnOutOfBoundsAccesses()) { 1935 1935 // Ensure we have a valid rendering state 1936 if (!validateElementArraySize(count, type, offset)) {1936 if (!validateElementArraySize(count, type, static_cast<GC3Dintptr>(offset))) { 1937 1937 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "request out of bounds for current ELEMENT_ARRAY_BUFFER"); 1938 1938 return; … … 1941 1941 return; 1942 1942 if (!validateIndexArrayConservative(type, numElements) || !validateRenderingState(numElements)) { 1943 if (!validateIndexArrayPrecise(count, type, offset, numElements) || !validateRenderingState(numElements)) {1943 if (!validateIndexArrayPrecise(count, type, static_cast<GC3Dintptr>(offset), numElements) || !validateRenderingState(numElements)) { 1944 1944 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "attempt to access out of bounds arrays"); 1945 1945 return; … … 1962 1962 if (!isGLES2Compliant()) { 1963 1963 if (!numElements) 1964 validateIndexArrayPrecise(count, type, offset, numElements);1964 validateIndexArrayPrecise(count, type, static_cast<GC3Dintptr>(offset), numElements); 1965 1965 vertexAttrib0Simulated = simulateVertexAttrib0(numElements); 1966 1966 } 1967 1967 if (!isGLES2NPOTStrict()) 1968 1968 handleNPOTTextures(true); 1969 m_context->drawElements(mode, count, type, offset);1969 m_context->drawElements(mode, count, type, static_cast<GC3Dintptr>(offset)); 1970 1970 if (!isGLES2Compliant() && vertexAttrib0Simulated) 1971 1971 restoreStatesAfterVertexAttrib0Simulation(); … … 3039 3039 } 3040 3040 3041 GC3DsizeiptrWebGLRenderingContext::getVertexAttribOffset(GC3Duint index, GC3Denum pname)3041 long long WebGLRenderingContext::getVertexAttribOffset(GC3Duint index, GC3Denum pname) 3042 3042 { 3043 3043 if (isContextLost()) … … 3045 3045 GC3Dsizeiptr result = m_context->getVertexAttribOffset(index, pname); 3046 3046 cleanupAfterGraphicsCall(false); 3047 return result;3047 return static_cast<long long>(result); 3048 3048 } 3049 3049 … … 4251 4251 } 4252 4252 4253 void WebGLRenderingContext::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptroffset, ExceptionCode& ec)4253 void WebGLRenderingContext::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, long long offset, ExceptionCode& ec) 4254 4254 { 4255 4255 UNUSED_PARAM(ec); … … 4285 4285 return; 4286 4286 } 4287 if ((stride % typeSize) || ( offset% typeSize)) {4287 if ((stride % typeSize) || (static_cast<GC3Dintptr>(offset) % typeSize)) { 4288 4288 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPointer", "stride or offset not valid for type"); 4289 4289 return; … … 4301 4301 state.stride = validatedStride; 4302 4302 state.originalStride = stride; 4303 state.offset = offset;4304 m_context->vertexAttribPointer(index, size, type, normalized, stride, offset);4303 state.offset = static_cast<GC3Dintptr>(offset); 4304 m_context->vertexAttribPointer(index, size, type, normalized, stride, static_cast<GC3Dintptr>(offset)); 4305 4305 cleanupAfterGraphicsCall(false); 4306 4306 } -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h
r116232 r116374 97 97 void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha); 98 98 99 void bufferData(GC3Denum target, GC3Dsizeiptrsize, GC3Denum usage, ExceptionCode&);99 void bufferData(GC3Denum target, long long size, GC3Denum usage, ExceptionCode&); 100 100 void bufferData(GC3Denum target, ArrayBuffer* data, GC3Denum usage, ExceptionCode&); 101 101 void bufferData(GC3Denum target, ArrayBufferView* data, GC3Denum usage, ExceptionCode&); 102 void bufferSubData(GC3Denum target, GC3Dintptroffset, ArrayBuffer* data, ExceptionCode&);103 void bufferSubData(GC3Denum target, GC3Dintptroffset, 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&); 104 104 105 105 GC3Denum checkFramebufferStatus(GC3Denum target); … … 142 142 void disableVertexAttribArray(GC3Duint index, ExceptionCode&); 143 143 void drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count, ExceptionCode&); 144 void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptroffset, ExceptionCode&);144 void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, ExceptionCode&); 145 145 146 146 void enable(GC3Denum cap); … … 175 175 PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const String&, ExceptionCode&); 176 176 WebGLGetInfo getVertexAttrib(GC3Duint index, GC3Denum pname, ExceptionCode&); 177 GC3DsizeiptrgetVertexAttribOffset(GC3Duint index, GC3Denum pname);177 long long getVertexAttribOffset(GC3Duint index, GC3Denum pname); 178 178 179 179 void hint(GC3Denum target, GC3Denum mode); … … 282 282 void vertexAttrib4fv(GC3Duint index, GC3Dfloat* values, GC3Dsizei size); 283 283 void vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, 284 GC3Dsizei stride, GC3Dintptroffset, ExceptionCode&);284 GC3Dsizei stride, long long offset, ExceptionCode&); 285 285 286 286 void viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height); -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.idl
r116232 r116374 464 464 [StrictTypeChecking] void bufferData(in unsigned long target, in ArrayBuffer data, in unsigned long usage) raises (DOMException); 465 465 [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); 469 469 470 470 [StrictTypeChecking] unsigned long checkFramebufferStatus(in unsigned long target); … … 508 508 [StrictTypeChecking] void disableVertexAttribArray(in unsigned long index) raises(DOMException); 509 509 [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); 511 511 512 512 [StrictTypeChecking] void enable(in unsigned long cap); … … 568 568 [StrictTypeChecking, Custom] void getVertexAttrib(); 569 569 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); 571 571 572 572 [StrictTypeChecking] void hint(in unsigned long target, in unsigned long mode); … … 662 662 [StrictTypeChecking, Custom] void vertexAttrib4fv(in unsigned long indx, in Float32Array values); 663 663 [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); 665 665 666 666 [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.