| 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/WebGLVertexArrayObjectBase.h" | 5 #include "modules/webgl/WebGLVertexArrayObjectBase.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" | 7 #include "gpu/command_buffer/client/gles2_interface.h" |
| 8 #include "modules/webgl/WebGLRenderingContextBase.h" | 8 #include "modules/webgl/WebGLRenderingContextBase.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 { | 32 { |
| 33 m_destructionInProgress = true; | 33 m_destructionInProgress = true; |
| 34 | 34 |
| 35 // Delete the platform framebuffer resource, in case | 35 // Delete the platform framebuffer resource, in case |
| 36 // where this vertex array object isn't detached when it and | 36 // where this vertex array object isn't detached when it and |
| 37 // the WebGLRenderingContextBase object it is registered with | 37 // the WebGLRenderingContextBase object it is registered with |
| 38 // are both finalized. | 38 // are both finalized. |
| 39 detachAndDeleteObject(); | 39 detachAndDeleteObject(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void WebGLVertexArrayObjectBase::dispatchDetached(WebGraphicsContext3D* context3
d, gpu::gles2::GLES2Interface* gl) | 42 void WebGLVertexArrayObjectBase::dispatchDetached(gpu::gles2::GLES2Interface* gl
) |
| 43 { | 43 { |
| 44 if (m_boundElementArrayBuffer) | 44 if (m_boundElementArrayBuffer) |
| 45 m_boundElementArrayBuffer->onDetached(context3d, gl); | 45 m_boundElementArrayBuffer->onDetached(gl); |
| 46 | 46 |
| 47 for (size_t i = 0; i < m_arrayBufferList.size(); ++i) { | 47 for (size_t i = 0; i < m_arrayBufferList.size(); ++i) { |
| 48 if (m_arrayBufferList[i]) | 48 if (m_arrayBufferList[i]) |
| 49 m_arrayBufferList[i]->onDetached(context3d, gl); | 49 m_arrayBufferList[i]->onDetached(gl); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 void WebGLVertexArrayObjectBase::deleteObjectImpl(WebGraphicsContext3D* context3
d, gpu::gles2::GLES2Interface* gl) | 53 void WebGLVertexArrayObjectBase::deleteObjectImpl(gpu::gles2::GLES2Interface* gl
) |
| 54 { | 54 { |
| 55 switch (m_type) { | 55 switch (m_type) { |
| 56 case VaoTypeDefault: | 56 case VaoTypeDefault: |
| 57 break; | 57 break; |
| 58 default: | 58 default: |
| 59 gl->DeleteVertexArraysOES(1, &m_object); | 59 gl->DeleteVertexArraysOES(1, &m_object); |
| 60 m_object = 0; | 60 m_object = 0; |
| 61 break; | 61 break; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Member<> objects must not be accessed during the destruction, | 64 // Member<> objects must not be accessed during the destruction, |
| 65 // since they could have been already finalized. | 65 // since they could have been already finalized. |
| 66 // The finalizers of these objects will handle their detachment | 66 // The finalizers of these objects will handle their detachment |
| 67 // by themselves. | 67 // by themselves. |
| 68 if (!m_destructionInProgress) | 68 if (!m_destructionInProgress) |
| 69 dispatchDetached(context3d, gl); | 69 dispatchDetached(gl); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void WebGLVertexArrayObjectBase::setElementArrayBuffer(WebGLBuffer* buffer) | 72 void WebGLVertexArrayObjectBase::setElementArrayBuffer(WebGLBuffer* buffer) |
| 73 { | 73 { |
| 74 if (buffer) | 74 if (buffer) |
| 75 buffer->onAttached(); | 75 buffer->onAttached(); |
| 76 if (m_boundElementArrayBuffer) | 76 if (m_boundElementArrayBuffer) |
| 77 m_boundElementArrayBuffer->onDetached(context()->webContext(), context()
->contextGL()); | 77 m_boundElementArrayBuffer->onDetached(context()->contextGL()); |
| 78 m_boundElementArrayBuffer = buffer; | 78 m_boundElementArrayBuffer = buffer; |
| 79 } | 79 } |
| 80 | 80 |
| 81 WebGLBuffer* WebGLVertexArrayObjectBase::getArrayBufferForAttrib(size_t index) | 81 WebGLBuffer* WebGLVertexArrayObjectBase::getArrayBufferForAttrib(size_t index) |
| 82 { | 82 { |
| 83 ASSERT(index < context()->maxVertexAttribs()); | 83 ASSERT(index < context()->maxVertexAttribs()); |
| 84 return m_arrayBufferList[index].get(); | 84 return m_arrayBufferList[index].get(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void WebGLVertexArrayObjectBase::setArrayBufferForAttrib(GLuint index, WebGLBuff
er* buffer) | 87 void WebGLVertexArrayObjectBase::setArrayBufferForAttrib(GLuint index, WebGLBuff
er* buffer) |
| 88 { | 88 { |
| 89 if (buffer) | 89 if (buffer) |
| 90 buffer->onAttached(); | 90 buffer->onAttached(); |
| 91 if (m_arrayBufferList[index]) | 91 if (m_arrayBufferList[index]) |
| 92 m_arrayBufferList[index]->onDetached(context()->webContext(), context()-
>contextGL()); | 92 m_arrayBufferList[index]->onDetached(context()->contextGL()); |
| 93 | 93 |
| 94 m_arrayBufferList[index] = buffer; | 94 m_arrayBufferList[index] = buffer; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void WebGLVertexArrayObjectBase::unbindBuffer(WebGLBuffer* buffer) | 97 void WebGLVertexArrayObjectBase::unbindBuffer(WebGLBuffer* buffer) |
| 98 { | 98 { |
| 99 if (m_boundElementArrayBuffer == buffer) { | 99 if (m_boundElementArrayBuffer == buffer) { |
| 100 m_boundElementArrayBuffer->onDetached(context()->webContext(), context()
->contextGL()); | 100 m_boundElementArrayBuffer->onDetached(context()->contextGL()); |
| 101 m_boundElementArrayBuffer = nullptr; | 101 m_boundElementArrayBuffer = nullptr; |
| 102 } | 102 } |
| 103 | 103 |
| 104 for (size_t i = 0; i < m_arrayBufferList.size(); ++i) { | 104 for (size_t i = 0; i < m_arrayBufferList.size(); ++i) { |
| 105 if (m_arrayBufferList[i] == buffer) { | 105 if (m_arrayBufferList[i] == buffer) { |
| 106 m_arrayBufferList[i]->onDetached(context()->webContext(), context()-
>contextGL()); | 106 m_arrayBufferList[i]->onDetached(context()->contextGL()); |
| 107 m_arrayBufferList[i] = nullptr; | 107 m_arrayBufferList[i] = nullptr; |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 DEFINE_TRACE(WebGLVertexArrayObjectBase) | 112 DEFINE_TRACE(WebGLVertexArrayObjectBase) |
| 113 { | 113 { |
| 114 visitor->trace(m_boundElementArrayBuffer); | 114 visitor->trace(m_boundElementArrayBuffer); |
| 115 visitor->trace(m_arrayBufferList); | 115 visitor->trace(m_arrayBufferList); |
| 116 WebGLContextObject::trace(visitor); | 116 WebGLContextObject::trace(visitor); |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace blink | 119 } // namespace blink |
| OLD | NEW |