| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 #include "config.h" | 26 #include "config.h" |
| 27 | 27 |
| 28 #include "core/html/canvas/WebGLVertexArrayObjectOES.h" | 28 #include "core/html/canvas/WebGLVertexArrayObjectOES.h" |
| 29 | 29 |
| 30 #include "core/html/canvas/WebGLRenderingContext.h" | 30 #include "core/html/canvas/WebGLRenderingContext.h" |
| 31 #include "platform/graphics/Extensions3D.h" | |
| 32 | 31 |
| 33 namespace WebCore { | 32 namespace WebCore { |
| 34 | 33 |
| 35 PassRefPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::create(WebGLRen
deringContext* ctx, VaoType type) | 34 PassRefPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::create(WebGLRen
deringContext* ctx, VaoType type) |
| 36 { | 35 { |
| 37 return adoptRef(new WebGLVertexArrayObjectOES(ctx, type)); | 36 return adoptRef(new WebGLVertexArrayObjectOES(ctx, type)); |
| 38 } | 37 } |
| 39 | 38 |
| 40 WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContext* ctx,
VaoType type) | 39 WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContext* ctx,
VaoType type) |
| 41 : WebGLContextObject(ctx) | 40 : WebGLContextObject(ctx) |
| 42 , m_type(type) | 41 , m_type(type) |
| 43 , m_hasEverBeenBound(false) | 42 , m_hasEverBeenBound(false) |
| 44 , m_boundElementArrayBuffer(0) | 43 , m_boundElementArrayBuffer(0) |
| 45 { | 44 { |
| 46 ScriptWrappable::init(this); | 45 ScriptWrappable::init(this); |
| 47 m_vertexAttribState.resize(ctx->maxVertexAttribs()); | 46 m_vertexAttribState.resize(ctx->maxVertexAttribs()); |
| 48 | 47 |
| 49 Extensions3D* extensions = context()->graphicsContext3D()->extensions(); | |
| 50 switch (m_type) { | 48 switch (m_type) { |
| 51 case VaoTypeDefault: | 49 case VaoTypeDefault: |
| 52 break; | 50 break; |
| 53 default: | 51 default: |
| 54 setObject(extensions->createVertexArrayOES()); | 52 setObject(context()->webGraphicsContext3D()->createVertexArrayOES()); |
| 55 break; | 53 break; |
| 56 } | 54 } |
| 57 } | 55 } |
| 58 | 56 |
| 59 WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES() | 57 WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES() |
| 60 { | 58 { |
| 61 deleteObject(0); | 59 deleteObject(0); |
| 62 } | 60 } |
| 63 | 61 |
| 64 void WebGLVertexArrayObjectOES::deleteObjectImpl(GraphicsContext3D* context3d, P
latform3DObject object) | 62 void WebGLVertexArrayObjectOES::deleteObjectImpl(GraphicsContext3D* context3d, P
latform3DObject object) |
| 65 { | 63 { |
| 66 Extensions3D* extensions = context3d->extensions(); | |
| 67 switch (m_type) { | 64 switch (m_type) { |
| 68 case VaoTypeDefault: | 65 case VaoTypeDefault: |
| 69 break; | 66 break; |
| 70 default: | 67 default: |
| 71 extensions->deleteVertexArrayOES(object); | 68 context()->webGraphicsContext3D()->deleteVertexArrayOES(object); |
| 72 break; | 69 break; |
| 73 } | 70 } |
| 74 | 71 |
| 75 if (m_boundElementArrayBuffer) | 72 if (m_boundElementArrayBuffer) |
| 76 m_boundElementArrayBuffer->onDetached(context3d); | 73 m_boundElementArrayBuffer->onDetached(context3d); |
| 77 | 74 |
| 78 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { | 75 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { |
| 79 VertexAttribState& state = m_vertexAttribState[i]; | 76 VertexAttribState& state = m_vertexAttribState[i]; |
| 80 if (state.bufferBinding) | 77 if (state.bufferBinding) |
| 81 state.bufferBinding->onDetached(context3d); | 78 state.bufferBinding->onDetached(context3d); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 127 } |
| 131 } | 128 } |
| 132 | 129 |
| 133 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GLuint index, GLuint divi
sor) | 130 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GLuint index, GLuint divi
sor) |
| 134 { | 131 { |
| 135 VertexAttribState& state = m_vertexAttribState[index]; | 132 VertexAttribState& state = m_vertexAttribState[index]; |
| 136 state.divisor = divisor; | 133 state.divisor = divisor; |
| 137 } | 134 } |
| 138 | 135 |
| 139 } | 136 } |
| OLD | NEW |