| 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 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 | 1399 |
| 1400 webContext()->vertexAttribI4uiv(index, value); | 1400 webContext()->vertexAttribI4uiv(index, value); |
| 1401 VertexAttribValue& attribValue = m_vertexAttribValue[index]; | 1401 VertexAttribValue& attribValue = m_vertexAttribValue[index]; |
| 1402 attribValue.type = Uint32ArrayType; | 1402 attribValue.type = Uint32ArrayType; |
| 1403 attribValue.value.uintValue[0] = value[0]; | 1403 attribValue.value.uintValue[0] = value[0]; |
| 1404 attribValue.value.uintValue[1] = value[1]; | 1404 attribValue.value.uintValue[1] = value[1]; |
| 1405 attribValue.value.uintValue[2] = value[2]; | 1405 attribValue.value.uintValue[2] = value[2]; |
| 1406 attribValue.value.uintValue[3] = value[3]; | 1406 attribValue.value.uintValue[3] = value[3]; |
| 1407 } | 1407 } |
| 1408 | 1408 |
| 1409 bool WebGL2RenderingContextBase::validateVertexAttribPointerTypeAndSize(GLenum t
ype, GLint size) | |
| 1410 { | |
| 1411 switch (type) { | |
| 1412 case GL_BYTE: | |
| 1413 case GL_UNSIGNED_BYTE: | |
| 1414 case GL_SHORT: | |
| 1415 case GL_UNSIGNED_SHORT: | |
| 1416 case GL_INT: | |
| 1417 case GL_UNSIGNED_INT: | |
| 1418 case GL_FLOAT: | |
| 1419 case GL_HALF_FLOAT: | |
| 1420 if (size < 1 || size > 4) { | |
| 1421 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribPointer", "invalid
size"); | |
| 1422 return false; | |
| 1423 } | |
| 1424 return true; | |
| 1425 case GL_INT_2_10_10_10_REV: | |
| 1426 case GL_UNSIGNED_INT_2_10_10_10_REV: | |
| 1427 if (size < 1 || size > 4) { | |
| 1428 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribPointer", "invalid
size"); | |
| 1429 return false; | |
| 1430 } | |
| 1431 if (size != 4) { | |
| 1432 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "size
!= 4"); | |
| 1433 return false; | |
| 1434 } | |
| 1435 return true; | |
| 1436 default: | |
| 1437 synthesizeGLError(GL_INVALID_ENUM, "vertexAttribPointer", "invalid type"
); | |
| 1438 return false; | |
| 1439 } | |
| 1440 } | |
| 1441 | |
| 1442 void WebGL2RenderingContextBase::vertexAttribIPointer(GLuint index, GLint size,
GLenum type, GLsizei stride, long long offset) | 1409 void WebGL2RenderingContextBase::vertexAttribIPointer(GLuint index, GLint size,
GLenum type, GLsizei stride, long long offset) |
| 1443 { | 1410 { |
| 1444 if (isContextLost()) | 1411 if (isContextLost()) |
| 1445 return; | 1412 return; |
| 1446 | |
| 1447 switch (type) { | |
| 1448 case GL_BYTE: | |
| 1449 case GL_UNSIGNED_BYTE: | |
| 1450 case GL_SHORT: | |
| 1451 case GL_UNSIGNED_SHORT: | |
| 1452 case GL_INT: | |
| 1453 case GL_UNSIGNED_INT: | |
| 1454 break; | |
| 1455 default: | |
| 1456 synthesizeGLError(GL_INVALID_ENUM, "vertexAttribIPointer", "invalid type
"); | |
| 1457 return; | |
| 1458 } | |
| 1459 if (index >= m_maxVertexAttribs) { | 1413 if (index >= m_maxVertexAttribs) { |
| 1460 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribIPointer", "index out o
f range"); | 1414 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribIPointer", "index out o
f range"); |
| 1461 return; | 1415 return; |
| 1462 } | 1416 } |
| 1463 if (size < 1 || size > 4 || stride < 0 || stride > 255) { | |
| 1464 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribIPointer", "bad size or
stride"); | |
| 1465 return; | |
| 1466 } | |
| 1467 if (!validateValueFitNonNegInt32("vertexAttribIPointer", "offset", offset)) | 1417 if (!validateValueFitNonNegInt32("vertexAttribIPointer", "offset", offset)) |
| 1468 return; | 1418 return; |
| 1469 if (!m_boundArrayBuffer) { | 1419 if (!m_boundArrayBuffer) { |
| 1470 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribIPointer", "no boun
d ARRAY_BUFFER"); | 1420 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribIPointer", "no boun
d ARRAY_BUFFER"); |
| 1471 return; | 1421 return; |
| 1472 } | 1422 } |
| 1473 unsigned typeSize = sizeInBytes(type); | |
| 1474 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. | |
| 1475 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize
- 1))) { | |
| 1476 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribIPointer", "stride
or offset not valid for type"); | |
| 1477 return; | |
| 1478 } | |
| 1479 GLsizei bytesPerElement = size * typeSize; | |
| 1480 | 1423 |
| 1481 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size,
type, false, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); | 1424 m_boundVertexArrayObject->setArrayBufferForAttrib(index, m_boundArrayBuffer)
; |
| 1482 webContext()->vertexAttribIPointer(index, size, type, stride, static_cast<GL
intptr>(offset)); | 1425 webContext()->vertexAttribIPointer(index, size, type, stride, static_cast<GL
intptr>(offset)); |
| 1483 } | 1426 } |
| 1484 | 1427 |
| 1485 /* Writing to the drawing buffer */ | 1428 /* Writing to the drawing buffer */ |
| 1486 void WebGL2RenderingContextBase::vertexAttribDivisor(GLuint index, GLuint diviso
r) | 1429 void WebGL2RenderingContextBase::vertexAttribDivisor(GLuint index, GLuint diviso
r) |
| 1487 { | 1430 { |
| 1488 if (isContextLost()) | 1431 if (isContextLost()) |
| 1489 return; | 1432 return; |
| 1490 | 1433 |
| 1491 if (index >= m_maxVertexAttribs) { | 1434 if (index >= m_maxVertexAttribs) { |
| 1492 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisor", "index out of
range"); | 1435 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisor", "index out of
range"); |
| 1493 return; | 1436 return; |
| 1494 } | 1437 } |
| 1495 | 1438 |
| 1496 m_boundVertexArrayObject->setVertexAttribDivisor(index, divisor); | |
| 1497 webContext()->vertexAttribDivisorANGLE(index, divisor); | 1439 webContext()->vertexAttribDivisorANGLE(index, divisor); |
| 1498 } | 1440 } |
| 1499 | 1441 |
| 1500 void WebGL2RenderingContextBase::drawArraysInstanced(GLenum mode, GLint first, G
Lsizei count, GLsizei instanceCount) | 1442 void WebGL2RenderingContextBase::drawArraysInstanced(GLenum mode, GLint first, G
Lsizei count, GLsizei instanceCount) |
| 1501 { | 1443 { |
| 1502 if (!validateDrawArrays("drawArraysInstanced", mode, first, count)) | 1444 if (!validateDrawArrays("drawArraysInstanced", mode, first, count)) |
| 1503 return; | 1445 return; |
| 1504 | 1446 |
| 1505 if (!validateDrawInstanced("drawArraysInstanced", instanceCount)) | 1447 if (!validateDrawInstanced("drawArraysInstanced", instanceCount)) |
| 1506 return; | 1448 return; |
| (...skipping 1940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3447 | 3389 |
| 3448 WebGLSampler* sampler = m_samplerUnits[unit]; | 3390 WebGLSampler* sampler = m_samplerUnits[unit]; |
| 3449 | 3391 |
| 3450 if (sampler) | 3392 if (sampler) |
| 3451 return sampler->getSamplerState(); | 3393 return sampler->getSamplerState(); |
| 3452 | 3394 |
| 3453 return WebGLRenderingContextBase::getTextureUnitSamplerState(target, unit); | 3395 return WebGLRenderingContextBase::getTextureUnitSamplerState(target, unit); |
| 3454 } | 3396 } |
| 3455 | 3397 |
| 3456 } // namespace blink | 3398 } // namespace blink |
| OLD | NEW |