| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/html/canvas/WebGL2RenderingContextBase.h" | 6 #include "core/html/canvas/WebGL2RenderingContextBase.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/WebGLAny.h" | 8 #include "bindings/core/v8/WebGLAny.h" |
| 9 #include "core/html/HTMLCanvasElement.h" | 9 #include "core/html/HTMLCanvasElement.h" |
| 10 #include "core/html/HTMLImageElement.h" | 10 #include "core/html/HTMLImageElement.h" |
| 11 #include "core/html/HTMLVideoElement.h" | 11 #include "core/html/HTMLVideoElement.h" |
| 12 #include "core/html/ImageData.h" | 12 #include "core/html/ImageData.h" |
| 13 #include "core/html/canvas/WebGLActiveInfo.h" | 13 #include "core/html/canvas/WebGLActiveInfo.h" |
| 14 #include "core/html/canvas/WebGLBuffer.h" | 14 #include "core/html/canvas/WebGLBuffer.h" |
| 15 #include "core/html/canvas/WebGLFenceSync.h" | 15 #include "core/html/canvas/WebGLFenceSync.h" |
| 16 #include "core/html/canvas/WebGLFramebuffer.h" | 16 #include "core/html/canvas/WebGLFramebuffer.h" |
| 17 #include "core/html/canvas/WebGLProgram.h" | 17 #include "core/html/canvas/WebGLProgram.h" |
| 18 #include "core/html/canvas/WebGLQuery.h" | 18 #include "core/html/canvas/WebGLQuery.h" |
| 19 #include "core/html/canvas/WebGLSampler.h" | 19 #include "core/html/canvas/WebGLSampler.h" |
| 20 #include "core/html/canvas/WebGLSync.h" | 20 #include "core/html/canvas/WebGLSync.h" |
| 21 #include "core/html/canvas/WebGLTexture.h" | 21 #include "core/html/canvas/WebGLTexture.h" |
| 22 #include "core/html/canvas/WebGLTransformFeedback.h" | 22 #include "core/html/canvas/WebGLTransformFeedback.h" |
| 23 #include "core/html/canvas/WebGLUniformLocation.h" | 23 #include "core/html/canvas/WebGLUniformLocation.h" |
| 24 #include "core/html/canvas/WebGLVertexArrayObjectOES.h" | 24 #include "core/html/canvas/WebGLVertexArrayObject.h" |
| 25 | 25 |
| 26 #include "platform/NotImplemented.h" | 26 #include "platform/NotImplemented.h" |
| 27 | 27 |
| 28 namespace blink { | 28 namespace blink { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 const GLuint webGLTimeoutIgnored = 0xFFFFFFFF; | 32 const GLuint webGLTimeoutIgnored = 0xFFFFFFFF; |
| 33 | 33 |
| 34 WGC3Dsync syncObjectOrZero(const WebGLSync* object) | 34 WGC3Dsync syncObjectOrZero(const WebGLSync* object) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 54 void WebGL2RenderingContextBase::initializeNewContext() | 54 void WebGL2RenderingContextBase::initializeNewContext() |
| 55 { | 55 { |
| 56 ASSERT(!isContextLost()); | 56 ASSERT(!isContextLost()); |
| 57 | 57 |
| 58 m_readFramebufferBinding = nullptr; | 58 m_readFramebufferBinding = nullptr; |
| 59 | 59 |
| 60 m_max3DTextureSize = 0; | 60 m_max3DTextureSize = 0; |
| 61 webContext()->getIntegerv(GL_MAX_3D_TEXTURE_SIZE, &m_max3DTextureSize); | 61 webContext()->getIntegerv(GL_MAX_3D_TEXTURE_SIZE, &m_max3DTextureSize); |
| 62 m_max3DTextureLevel = WebGLTexture::computeLevelCount(m_max3DTextureSize, m_
max3DTextureSize, m_max3DTextureSize); | 62 m_max3DTextureLevel = WebGLTexture::computeLevelCount(m_max3DTextureSize, m_
max3DTextureSize, m_max3DTextureSize); |
| 63 | 63 |
| 64 GLint numVertexAttribs = 0; |
| 65 webContext()->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs); |
| 66 m_maxVertexAttribs = numVertexAttribs; |
| 67 |
| 68 m_defaultVertexArrayObject = WebGLVertexArrayObject::create(this, WebGLVerte
xArrayObjectBase::VaoTypeDefault); |
| 69 addContextObject(m_defaultVertexArrayObject.get()); |
| 70 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
| 71 |
| 64 WebGLRenderingContextBase::initializeNewContext(); | 72 WebGLRenderingContextBase::initializeNewContext(); |
| 65 } | 73 } |
| 66 | 74 |
| 67 void WebGL2RenderingContextBase::copyBufferSubData(GLenum readTarget, GLenum wri
teTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) | 75 void WebGL2RenderingContextBase::copyBufferSubData(GLenum readTarget, GLenum wri
teTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 68 { | 76 { |
| 69 if (isContextLost()) | 77 if (isContextLost()) |
| 70 return; | 78 return; |
| 71 | 79 |
| 72 webContext()->copyBufferSubData(readTarget, writeTarget, readOffset, writeOf
fset, size); | 80 webContext()->copyBufferSubData(readTarget, writeTarget, readOffset, writeOf
fset, size); |
| 73 } | 81 } |
| (...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 } | 1375 } |
| 1368 | 1376 |
| 1369 void WebGL2RenderingContextBase::uniformBlockBinding(WebGLProgram* program, GLui
nt uniformBlockIndex, GLuint uniformBlockBinding) | 1377 void WebGL2RenderingContextBase::uniformBlockBinding(WebGLProgram* program, GLui
nt uniformBlockIndex, GLuint uniformBlockBinding) |
| 1370 { | 1378 { |
| 1371 if (isContextLost() || !validateWebGLObject("uniformBlockBinding", program)) | 1379 if (isContextLost() || !validateWebGLObject("uniformBlockBinding", program)) |
| 1372 return; | 1380 return; |
| 1373 | 1381 |
| 1374 webContext()->uniformBlockBinding(objectOrZero(program), uniformBlockIndex,
uniformBlockBinding); | 1382 webContext()->uniformBlockBinding(objectOrZero(program), uniformBlockIndex,
uniformBlockBinding); |
| 1375 } | 1383 } |
| 1376 | 1384 |
| 1377 PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> WebGL2RenderingContextBase::cr
eateVertexArray() | 1385 PassRefPtrWillBeRawPtr<WebGLVertexArrayObject> WebGL2RenderingContextBase::creat
eVertexArray() |
| 1378 { | 1386 { |
| 1379 if (isContextLost()) | 1387 if (isContextLost()) |
| 1380 return nullptr; | 1388 return nullptr; |
| 1381 | 1389 |
| 1382 RefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> o = WebGLVertexArrayObjectOES:
:create(this, WebGLVertexArrayObjectOES::VaoTypeUser); | 1390 RefPtrWillBeRawPtr<WebGLVertexArrayObject> o = WebGLVertexArrayObject::creat
e(this, WebGLVertexArrayObjectBase::VaoTypeUser); |
| 1383 addContextObject(o.get()); | 1391 addContextObject(o.get()); |
| 1384 return o.release(); | 1392 return o.release(); |
| 1385 } | 1393 } |
| 1386 | 1394 |
| 1387 void WebGL2RenderingContextBase::deleteVertexArray(WebGLVertexArrayObjectOES* ve
rtexArray) | 1395 void WebGL2RenderingContextBase::deleteVertexArray(WebGLVertexArrayObject* verte
xArray) |
| 1388 { | 1396 { |
| 1389 if (isContextLost() || !vertexArray) | 1397 if (isContextLost() || !vertexArray) |
| 1390 return; | 1398 return; |
| 1391 | 1399 |
| 1392 if (!vertexArray->isDefaultObject() && vertexArray == m_boundVertexArrayObje
ct) | 1400 if (!vertexArray->isDefaultObject() && vertexArray == m_boundVertexArrayObje
ct) |
| 1393 setBoundVertexArrayObject(nullptr); | 1401 setBoundVertexArrayObject(nullptr); |
| 1394 | 1402 |
| 1395 vertexArray->deleteObject(webContext()); | 1403 vertexArray->deleteObject(webContext()); |
| 1396 } | 1404 } |
| 1397 | 1405 |
| 1398 GLboolean WebGL2RenderingContextBase::isVertexArray(WebGLVertexArrayObjectOES* v
ertexArray) | 1406 GLboolean WebGL2RenderingContextBase::isVertexArray(WebGLVertexArrayObject* vert
exArray) |
| 1399 { | 1407 { |
| 1400 if (isContextLost() || !vertexArray) | 1408 if (isContextLost() || !vertexArray) |
| 1401 return 0; | 1409 return 0; |
| 1402 | 1410 |
| 1403 if (!vertexArray->hasEverBeenBound()) | 1411 if (!vertexArray->hasEverBeenBound()) |
| 1404 return 0; | 1412 return 0; |
| 1405 | 1413 |
| 1406 return webContext()->isVertexArrayOES(vertexArray->object()); | 1414 return webContext()->isVertexArrayOES(vertexArray->object()); |
| 1407 } | 1415 } |
| 1408 | 1416 |
| 1409 void WebGL2RenderingContextBase::bindVertexArray(WebGLVertexArrayObjectOES* vert
exArray) | 1417 void WebGL2RenderingContextBase::bindVertexArray(WebGLVertexArrayObject* vertexA
rray) |
| 1410 { | 1418 { |
| 1411 if (isContextLost()) | 1419 if (isContextLost()) |
| 1412 return; | 1420 return; |
| 1413 | 1421 |
| 1414 if (vertexArray && (vertexArray->isDeleted() || !vertexArray->validate(0, th
is))) { | 1422 if (vertexArray && (vertexArray->isDeleted() || !vertexArray->validate(0, th
is))) { |
| 1415 webContext()->synthesizeGLError(GL_INVALID_OPERATION); | 1423 webContext()->synthesizeGLError(GL_INVALID_OPERATION); |
| 1416 return; | 1424 return; |
| 1417 } | 1425 } |
| 1418 | 1426 |
| 1419 if (vertexArray && !vertexArray->isDefaultObject() && vertexArray->object())
{ | 1427 if (vertexArray && !vertexArray->isDefaultObject() && vertexArray->object())
{ |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 GLfloat value = 0.f; | 1840 GLfloat value = 0.f; |
| 1833 webContext()->getTexParameterfv(target, pname, &value); | 1841 webContext()->getTexParameterfv(target, pname, &value); |
| 1834 return WebGLAny(scriptState, value); | 1842 return WebGLAny(scriptState, value); |
| 1835 } | 1843 } |
| 1836 default: | 1844 default: |
| 1837 return WebGLRenderingContextBase::getTexParameter(scriptState, target, p
name); | 1845 return WebGLRenderingContextBase::getTexParameter(scriptState, target, p
name); |
| 1838 } | 1846 } |
| 1839 } | 1847 } |
| 1840 | 1848 |
| 1841 } // namespace blink | 1849 } // namespace blink |
| OLD | NEW |