OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/webgl/WebGL2RenderingContextBase.h" | 5 #include "modules/webgl/WebGL2RenderingContextBase.h" |
6 | 6 |
7 #include "bindings/modules/v8/WebGLAny.h" | 7 #include "bindings/modules/v8/WebGLAny.h" |
8 #include "core/html/HTMLCanvasElement.h" | 8 #include "core/html/HTMLCanvasElement.h" |
9 #include "core/html/HTMLImageElement.h" | 9 #include "core/html/HTMLImageElement.h" |
10 #include "core/html/HTMLVideoElement.h" | 10 #include "core/html/HTMLVideoElement.h" |
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 | 1440 |
1441 webContext()->vertexAttribI4uiv(index, value); | 1441 webContext()->vertexAttribI4uiv(index, value); |
1442 VertexAttribValue& attribValue = m_vertexAttribValue[index]; | 1442 VertexAttribValue& attribValue = m_vertexAttribValue[index]; |
1443 attribValue.type = Uint32ArrayType; | 1443 attribValue.type = Uint32ArrayType; |
1444 attribValue.value.uintValue[0] = value[0]; | 1444 attribValue.value.uintValue[0] = value[0]; |
1445 attribValue.value.uintValue[1] = value[1]; | 1445 attribValue.value.uintValue[1] = value[1]; |
1446 attribValue.value.uintValue[2] = value[2]; | 1446 attribValue.value.uintValue[2] = value[2]; |
1447 attribValue.value.uintValue[3] = value[3]; | 1447 attribValue.value.uintValue[3] = value[3]; |
1448 } | 1448 } |
1449 | 1449 |
| 1450 unsigned WebGL2RenderingContextBase::sizeInBytes(GLenum type, bool isIntegerAPI)
const |
| 1451 { |
| 1452 switch (type) { |
| 1453 case GL_HALF_FLOAT: |
| 1454 ASSERT(!isIntegerAPI); |
| 1455 return sizeof(GLushort); |
| 1456 case GL_INT_2_10_10_10_REV: |
| 1457 ASSERT(!isIntegerAPI); |
| 1458 return sizeof(GLint); |
| 1459 case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 1460 ASSERT(!isIntegerAPI); |
| 1461 return sizeof(GLuint); |
| 1462 default: |
| 1463 return WebGLRenderingContextBase::sizeInBytes(type, isIntegerAPI); |
| 1464 } |
| 1465 } |
| 1466 |
1450 bool WebGL2RenderingContextBase::validateVertexAttribPointerTypeAndSize(GLenum t
ype, GLint size) | 1467 bool WebGL2RenderingContextBase::validateVertexAttribPointerTypeAndSize(GLenum t
ype, GLint size) |
1451 { | 1468 { |
1452 switch (type) { | 1469 switch (type) { |
1453 case GL_BYTE: | 1470 case GL_BYTE: |
1454 case GL_UNSIGNED_BYTE: | 1471 case GL_UNSIGNED_BYTE: |
1455 case GL_SHORT: | 1472 case GL_SHORT: |
1456 case GL_UNSIGNED_SHORT: | 1473 case GL_UNSIGNED_SHORT: |
1457 case GL_INT: | 1474 case GL_INT: |
1458 case GL_UNSIGNED_INT: | 1475 case GL_UNSIGNED_INT: |
1459 case GL_FLOAT: | 1476 case GL_FLOAT: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 if (size < 1 || size > 4 || stride < 0 || stride > 255) { | 1521 if (size < 1 || size > 4 || stride < 0 || stride > 255) { |
1505 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribIPointer", "bad size or
stride"); | 1522 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribIPointer", "bad size or
stride"); |
1506 return; | 1523 return; |
1507 } | 1524 } |
1508 if (!validateValueFitNonNegInt32("vertexAttribIPointer", "offset", offset)) | 1525 if (!validateValueFitNonNegInt32("vertexAttribIPointer", "offset", offset)) |
1509 return; | 1526 return; |
1510 if (!m_boundArrayBuffer) { | 1527 if (!m_boundArrayBuffer) { |
1511 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribIPointer", "no boun
d ARRAY_BUFFER"); | 1528 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribIPointer", "no boun
d ARRAY_BUFFER"); |
1512 return; | 1529 return; |
1513 } | 1530 } |
1514 unsigned typeSize = sizeInBytes(type); | 1531 unsigned typeSize = sizeInBytes(type, true); |
1515 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. | 1532 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. |
1516 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize
- 1))) { | 1533 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize
- 1))) { |
1517 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribIPointer", "stride
or offset not valid for type"); | 1534 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribIPointer", "stride
or offset not valid for type"); |
1518 return; | 1535 return; |
1519 } | 1536 } |
1520 GLsizei bytesPerElement = size * typeSize; | 1537 GLsizei bytesPerElement = size * typeSize; |
1521 | 1538 |
1522 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size,
type, false, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); | 1539 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size,
type, false, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); |
1523 webContext()->vertexAttribIPointer(index, size, type, stride, static_cast<GL
intptr>(offset)); | 1540 webContext()->vertexAttribIPointer(index, size, type, stride, static_cast<GL
intptr>(offset)); |
1524 } | 1541 } |
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3468 | 3485 |
3469 WebGLSampler* sampler = m_samplerUnits[unit]; | 3486 WebGLSampler* sampler = m_samplerUnits[unit]; |
3470 | 3487 |
3471 if (sampler) | 3488 if (sampler) |
3472 return sampler->getSamplerState(); | 3489 return sampler->getSamplerState(); |
3473 | 3490 |
3474 return WebGLRenderingContextBase::getTextureUnitSamplerState(target, unit); | 3491 return WebGLRenderingContextBase::getTextureUnitSamplerState(target, unit); |
3475 } | 3492 } |
3476 | 3493 |
3477 } // namespace blink | 3494 } // namespace blink |
OLD | NEW |