OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef WebGLRenderingContextBase_h | 26 #ifndef WebGLRenderingContextBase_h |
27 #define WebGLRenderingContextBase_h | 27 #define WebGLRenderingContextBase_h |
28 | 28 |
| 29 #include <memory> |
| 30 #include <set> |
29 #include "bindings/core/v8/Nullable.h" | 31 #include "bindings/core/v8/Nullable.h" |
30 #include "bindings/core/v8/ScriptState.h" | 32 #include "bindings/core/v8/ScriptState.h" |
31 #include "bindings/core/v8/ScriptValue.h" | 33 #include "bindings/core/v8/ScriptValue.h" |
32 #include "bindings/core/v8/ScriptWrappable.h" | 34 #include "bindings/core/v8/ScriptWrappable.h" |
33 #include "bindings/core/v8/ScriptWrappableVisitor.h" | 35 #include "bindings/core/v8/ScriptWrappableVisitor.h" |
34 #include "core/CoreExport.h" | 36 #include "core/CoreExport.h" |
35 #include "core/dom/DOMTypedArray.h" | 37 #include "core/dom/DOMTypedArray.h" |
| 38 #include "core/dom/MaybeShared.h" |
36 #include "core/dom/TypedFlexibleArrayBufferView.h" | 39 #include "core/dom/TypedFlexibleArrayBufferView.h" |
37 #include "core/html/canvas/CanvasContextCreationAttributes.h" | 40 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
38 #include "core/html/canvas/CanvasRenderingContext.h" | 41 #include "core/html/canvas/CanvasRenderingContext.h" |
39 #include "core/layout/ContentChangeType.h" | 42 #include "core/layout/ContentChangeType.h" |
40 #include "modules/webgl/WebGLContextAttributes.h" | 43 #include "modules/webgl/WebGLContextAttributes.h" |
41 #include "modules/webgl/WebGLExtensionName.h" | 44 #include "modules/webgl/WebGLExtensionName.h" |
42 #include "modules/webgl/WebGLTexture.h" | 45 #include "modules/webgl/WebGLTexture.h" |
43 #include "modules/webgl/WebGLVertexArrayObjectBase.h" | 46 #include "modules/webgl/WebGLVertexArrayObjectBase.h" |
44 #include "platform/Timer.h" | 47 #include "platform/Timer.h" |
45 #include "platform/graphics/ImageBuffer.h" | 48 #include "platform/graphics/ImageBuffer.h" |
46 #include "platform/graphics/gpu/DrawingBuffer.h" | 49 #include "platform/graphics/gpu/DrawingBuffer.h" |
47 #include "platform/graphics/gpu/Extensions3DUtil.h" | 50 #include "platform/graphics/gpu/Extensions3DUtil.h" |
48 #include "platform/graphics/gpu/WebGLImageConversion.h" | 51 #include "platform/graphics/gpu/WebGLImageConversion.h" |
49 #include "public/platform/Platform.h" | 52 #include "public/platform/Platform.h" |
50 #include "public/platform/WebGraphicsContext3DProvider.h" | 53 #include "public/platform/WebGraphicsContext3DProvider.h" |
51 #include "third_party/khronos/GLES2/gl2.h" | 54 #include "third_party/khronos/GLES2/gl2.h" |
52 #include "wtf/CheckedNumeric.h" | 55 #include "wtf/CheckedNumeric.h" |
53 #include "wtf/text/WTFString.h" | 56 #include "wtf/text/WTFString.h" |
54 #include <memory> | |
55 #include <set> | |
56 | 57 |
57 namespace blink { | 58 namespace blink { |
58 class WebLayer; | 59 class WebLayer; |
59 } | 60 } |
60 | 61 |
61 namespace gpu { | 62 namespace gpu { |
62 namespace gles2 { | 63 namespace gles2 { |
63 class GLES2Interface; | 64 class GLES2Interface; |
64 } | 65 } |
65 } | 66 } |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 void uniform4fv(const WebGLUniformLocation*, Vector<GLfloat>&); | 461 void uniform4fv(const WebGLUniformLocation*, Vector<GLfloat>&); |
461 void uniform4i(const WebGLUniformLocation*, | 462 void uniform4i(const WebGLUniformLocation*, |
462 GLint x, | 463 GLint x, |
463 GLint y, | 464 GLint y, |
464 GLint z, | 465 GLint z, |
465 GLint w); | 466 GLint w); |
466 void uniform4iv(const WebGLUniformLocation*, const FlexibleInt32ArrayView&); | 467 void uniform4iv(const WebGLUniformLocation*, const FlexibleInt32ArrayView&); |
467 void uniform4iv(const WebGLUniformLocation*, Vector<GLint>&); | 468 void uniform4iv(const WebGLUniformLocation*, Vector<GLint>&); |
468 void uniformMatrix2fv(const WebGLUniformLocation*, | 469 void uniformMatrix2fv(const WebGLUniformLocation*, |
469 GLboolean transpose, | 470 GLboolean transpose, |
470 DOMFloat32Array* value); | 471 const MaybeShared<DOMFloat32Array>& value); |
471 void uniformMatrix2fv(const WebGLUniformLocation*, | 472 void uniformMatrix2fv(const WebGLUniformLocation*, |
472 GLboolean transpose, | 473 GLboolean transpose, |
473 Vector<GLfloat>& value); | 474 Vector<GLfloat>& value); |
474 void uniformMatrix3fv(const WebGLUniformLocation*, | 475 void uniformMatrix3fv(const WebGLUniformLocation*, |
475 GLboolean transpose, | 476 GLboolean transpose, |
476 DOMFloat32Array* value); | 477 const MaybeShared<DOMFloat32Array>& value); |
477 void uniformMatrix3fv(const WebGLUniformLocation*, | 478 void uniformMatrix3fv(const WebGLUniformLocation*, |
478 GLboolean transpose, | 479 GLboolean transpose, |
479 Vector<GLfloat>& value); | 480 Vector<GLfloat>& value); |
480 void uniformMatrix4fv(const WebGLUniformLocation*, | 481 void uniformMatrix4fv(const WebGLUniformLocation*, |
481 GLboolean transpose, | 482 GLboolean transpose, |
482 DOMFloat32Array* value); | 483 const MaybeShared<DOMFloat32Array>& value); |
483 void uniformMatrix4fv(const WebGLUniformLocation*, | 484 void uniformMatrix4fv(const WebGLUniformLocation*, |
484 GLboolean transpose, | 485 GLboolean transpose, |
485 Vector<GLfloat>& value); | 486 Vector<GLfloat>& value); |
486 | 487 |
487 void useProgram(WebGLProgram*); | 488 void useProgram(WebGLProgram*); |
488 void validateProgram(WebGLProgram*); | 489 void validateProgram(WebGLProgram*); |
489 | 490 |
490 void vertexAttrib1f(GLuint index, GLfloat x); | 491 void vertexAttrib1f(GLuint index, GLfloat x); |
491 void vertexAttrib1fv(GLuint index, const DOMFloat32Array* values); | 492 void vertexAttrib1fv(GLuint index, |
| 493 const MaybeShared<const DOMFloat32Array>& values); |
492 void vertexAttrib1fv(GLuint index, const Vector<GLfloat>& values); | 494 void vertexAttrib1fv(GLuint index, const Vector<GLfloat>& values); |
493 void vertexAttrib2f(GLuint index, GLfloat x, GLfloat y); | 495 void vertexAttrib2f(GLuint index, GLfloat x, GLfloat y); |
494 void vertexAttrib2fv(GLuint index, const DOMFloat32Array* values); | 496 void vertexAttrib2fv(GLuint index, |
| 497 const MaybeShared<const DOMFloat32Array>& values); |
495 void vertexAttrib2fv(GLuint index, const Vector<GLfloat>& values); | 498 void vertexAttrib2fv(GLuint index, const Vector<GLfloat>& values); |
496 void vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z); | 499 void vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z); |
497 void vertexAttrib3fv(GLuint index, const DOMFloat32Array* values); | 500 void vertexAttrib3fv(GLuint index, |
| 501 const MaybeShared<const DOMFloat32Array>& values); |
498 void vertexAttrib3fv(GLuint index, const Vector<GLfloat>& values); | 502 void vertexAttrib3fv(GLuint index, const Vector<GLfloat>& values); |
499 void vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); | 503 void vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); |
500 void vertexAttrib4fv(GLuint index, const DOMFloat32Array* values); | 504 void vertexAttrib4fv(GLuint index, |
| 505 const MaybeShared<const DOMFloat32Array>& values); |
501 void vertexAttrib4fv(GLuint index, const Vector<GLfloat>& values); | 506 void vertexAttrib4fv(GLuint index, const Vector<GLfloat>& values); |
502 void vertexAttribPointer(GLuint index, | 507 void vertexAttribPointer(GLuint index, |
503 GLint size, | 508 GLint size, |
504 GLenum type, | 509 GLenum type, |
505 GLboolean normalized, | 510 GLboolean normalized, |
506 GLsizei stride, | 511 GLsizei stride, |
507 long long offset); | 512 long long offset); |
508 | 513 |
509 void vertexAttribDivisorANGLE(GLuint index, GLuint divisor); | 514 void vertexAttribDivisorANGLE(GLuint index, GLuint divisor); |
510 | 515 |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 bool validateUniformParameters(const char* functionName, | 1356 bool validateUniformParameters(const char* functionName, |
1352 const WebGLUniformLocation*, | 1357 const WebGLUniformLocation*, |
1353 void*, | 1358 void*, |
1354 GLsizei, | 1359 GLsizei, |
1355 GLsizei mod, | 1360 GLsizei mod, |
1356 GLuint srcOffset, | 1361 GLuint srcOffset, |
1357 GLuint srcLength); | 1362 GLuint srcLength); |
1358 bool validateUniformMatrixParameters(const char* functionName, | 1363 bool validateUniformMatrixParameters(const char* functionName, |
1359 const WebGLUniformLocation*, | 1364 const WebGLUniformLocation*, |
1360 GLboolean transpose, | 1365 GLboolean transpose, |
1361 DOMFloat32Array*, | 1366 const MaybeShared<DOMFloat32Array>&, |
1362 GLsizei mod, | 1367 GLsizei mod, |
1363 GLuint srcOffset, | 1368 GLuint srcOffset, |
1364 GLuint srcLength); | 1369 GLuint srcLength); |
1365 bool validateUniformMatrixParameters(const char* functionName, | 1370 bool validateUniformMatrixParameters(const char* functionName, |
1366 const WebGLUniformLocation*, | 1371 const WebGLUniformLocation*, |
1367 GLboolean transpose, | 1372 GLboolean transpose, |
1368 void*, | 1373 void*, |
1369 GLsizei, | 1374 GLsizei, |
1370 GLsizei mod, | 1375 GLsizei mod, |
1371 GLuint srcOffset, | 1376 GLuint srcOffset, |
1372 GLuint srcLength); | 1377 GLuint srcLength); |
1373 | 1378 |
1374 template <typename WTFTypedArray> | 1379 template <typename WTFTypedArray> |
1375 bool validateUniformParameters( | 1380 bool validateUniformParameters( |
1376 const char* functionName, | 1381 const char* functionName, |
1377 const WebGLUniformLocation* location, | 1382 const WebGLUniformLocation* location, |
1378 const TypedFlexibleArrayBufferView<WTFTypedArray>& v, | 1383 const TypedFlexibleArrayBufferView<WTFTypedArray>& v, |
1379 GLsizei requiredMinSize, | 1384 GLsizei requiredMinSize, |
1380 GLuint srcOffset, | 1385 GLuint srcOffset, |
1381 GLuint srcLength) { | 1386 GLuint srcLength) { |
1382 if (!v.dataMaybeOnStack()) { | 1387 if (!v.dataMaybeOnStack()) { |
1383 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); | 1388 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); |
1384 return false; | 1389 return false; |
1385 } | 1390 } |
1386 return validateUniformMatrixParameters( | 1391 return validateUniformMatrixParameters( |
1387 functionName, location, false, v.dataMaybeOnStack(), v.length(), | 1392 functionName, location, false, v.dataMaybeOnStack(), v.length(), |
1388 requiredMinSize, srcOffset, srcLength); | 1393 requiredMinSize, srcOffset, srcLength); |
1389 } | 1394 } |
1390 | 1395 |
| 1396 template <typename TypedArray> |
| 1397 bool validateNotSharedArrayBuffer(const char* functionName, |
| 1398 const MaybeShared<TypedArray>& v) { |
| 1399 // TODO(binji): Disallow for now. |
| 1400 if (v.isShared()) { |
| 1401 synthesizeGLError(GL_INVALID_VALUE, functionName, |
| 1402 "array is backed by SharedArrayBuffer."); |
| 1403 return false; |
| 1404 } |
| 1405 return true; |
| 1406 } |
| 1407 |
1391 // Helper function to validate the target for bufferData and | 1408 // Helper function to validate the target for bufferData and |
1392 // getBufferParameter. | 1409 // getBufferParameter. |
1393 virtual bool validateBufferTarget(const char* functionName, GLenum target); | 1410 virtual bool validateBufferTarget(const char* functionName, GLenum target); |
1394 | 1411 |
1395 // Helper function to validate the target for bufferData. | 1412 // Helper function to validate the target for bufferData. |
1396 // Return the current bound buffer to target, or 0 if the target is invalid. | 1413 // Return the current bound buffer to target, or 0 if the target is invalid. |
1397 virtual WebGLBuffer* validateBufferDataTarget(const char* functionName, | 1414 virtual WebGLBuffer* validateBufferDataTarget(const char* functionName, |
1398 GLenum target); | 1415 GLenum target); |
1399 // Helper function to validate the usage for bufferData. | 1416 // Helper function to validate the usage for bufferData. |
1400 virtual bool validateBufferDataUsage(const char* functionName, GLenum usage); | 1417 virtual bool validateBufferDataUsage(const char* functionName, GLenum usage); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 context, | 1678 context, |
1662 context->is3d(), | 1679 context->is3d(), |
1663 context.is3d()); | 1680 context.is3d()); |
1664 | 1681 |
1665 } // namespace blink | 1682 } // namespace blink |
1666 | 1683 |
1667 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( | 1684 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( |
1668 blink::WebGLRenderingContextBase::TextureUnitState); | 1685 blink::WebGLRenderingContextBase::TextureUnitState); |
1669 | 1686 |
1670 #endif // WebGLRenderingContextBase_h | 1687 #endif // WebGLRenderingContextBase_h |
OLD | NEW |