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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 , m_hasEverBeenBound(false) | 42 , m_hasEverBeenBound(false) |
43 , m_boundElementArrayBuffer(nullptr) | 43 , m_boundElementArrayBuffer(nullptr) |
44 { | 44 { |
45 ScriptWrappable::init(this); | 45 ScriptWrappable::init(this); |
46 m_vertexAttribState.resize(ctx->maxVertexAttribs()); | 46 m_vertexAttribState.resize(ctx->maxVertexAttribs()); |
47 | 47 |
48 switch (m_type) { | 48 switch (m_type) { |
49 case VaoTypeDefault: | 49 case VaoTypeDefault: |
50 break; | 50 break; |
51 default: | 51 default: |
52 setObject(context()->webGraphicsContext3D()->createVertexArrayOES()); | 52 setObject(context()->webContext()->createVertexArrayOES()); |
53 break; | 53 break; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES() | 57 WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES() |
58 { | 58 { |
59 deleteObject(0); | 59 deleteObject(0); |
60 } | 60 } |
61 | 61 |
62 void WebGLVertexArrayObjectOES::deleteObjectImpl(blink::WebGraphicsContext3D* co
ntext3d, Platform3DObject object) | 62 void WebGLVertexArrayObjectOES::deleteObjectImpl(blink::WebGraphicsContext3D* co
ntext3d, Platform3DObject object) |
63 { | 63 { |
64 switch (m_type) { | 64 switch (m_type) { |
65 case VaoTypeDefault: | 65 case VaoTypeDefault: |
66 break; | 66 break; |
67 default: | 67 default: |
68 context()->webGraphicsContext3D()->deleteVertexArrayOES(object); | 68 context()->webContext()->deleteVertexArrayOES(object); |
69 break; | 69 break; |
70 } | 70 } |
71 | 71 |
72 if (m_boundElementArrayBuffer) | 72 if (m_boundElementArrayBuffer) |
73 m_boundElementArrayBuffer->onDetached(context3d); | 73 m_boundElementArrayBuffer->onDetached(context3d); |
74 | 74 |
75 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { | 75 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { |
76 VertexAttribState& state = m_vertexAttribState[i]; | 76 VertexAttribState& state = m_vertexAttribState[i]; |
77 if (state.bufferBinding) | 77 if (state.bufferBinding) |
78 state.bufferBinding->onDetached(context3d); | 78 state.bufferBinding->onDetached(context3d); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtr<WebGLBuffer> bu
ffer) | 82 void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtr<WebGLBuffer> bu
ffer) |
83 { | 83 { |
84 if (buffer) | 84 if (buffer) |
85 buffer->onAttached(); | 85 buffer->onAttached(); |
86 if (m_boundElementArrayBuffer) | 86 if (m_boundElementArrayBuffer) |
87 m_boundElementArrayBuffer->onDetached(context()->webGraphicsContext3D())
; | 87 m_boundElementArrayBuffer->onDetached(context()->webContext()); |
88 m_boundElementArrayBuffer = buffer; | 88 m_boundElementArrayBuffer = buffer; |
89 | 89 |
90 } | 90 } |
91 | 91 |
92 void WebGLVertexArrayObjectOES::setVertexAttribState( | 92 void WebGLVertexArrayObjectOES::setVertexAttribState( |
93 GLuint index, GLsizei bytesPerElement, GLint size, GLenum type, GLboolean no
rmalized, GLsizei stride, GLintptr offset, PassRefPtr<WebGLBuffer> buffer) | 93 GLuint index, GLsizei bytesPerElement, GLint size, GLenum type, GLboolean no
rmalized, GLsizei stride, GLintptr offset, PassRefPtr<WebGLBuffer> buffer) |
94 { | 94 { |
95 GLsizei validatedStride = stride ? stride : bytesPerElement; | 95 GLsizei validatedStride = stride ? stride : bytesPerElement; |
96 | 96 |
97 VertexAttribState& state = m_vertexAttribState[index]; | 97 VertexAttribState& state = m_vertexAttribState[index]; |
98 | 98 |
99 if (buffer) | 99 if (buffer) |
100 buffer->onAttached(); | 100 buffer->onAttached(); |
101 if (state.bufferBinding) | 101 if (state.bufferBinding) |
102 state.bufferBinding->onDetached(context()->webGraphicsContext3D()); | 102 state.bufferBinding->onDetached(context()->webContext()); |
103 | 103 |
104 state.bufferBinding = buffer; | 104 state.bufferBinding = buffer; |
105 state.bytesPerElement = bytesPerElement; | 105 state.bytesPerElement = bytesPerElement; |
106 state.size = size; | 106 state.size = size; |
107 state.type = type; | 107 state.type = type; |
108 state.normalized = normalized; | 108 state.normalized = normalized; |
109 state.stride = validatedStride; | 109 state.stride = validatedStride; |
110 state.originalStride = stride; | 110 state.originalStride = stride; |
111 state.offset = offset; | 111 state.offset = offset; |
112 } | 112 } |
113 | 113 |
114 void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtr<WebGLBuffer> buffer) | 114 void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtr<WebGLBuffer> buffer) |
115 { | 115 { |
116 if (m_boundElementArrayBuffer == buffer) { | 116 if (m_boundElementArrayBuffer == buffer) { |
117 m_boundElementArrayBuffer->onDetached(context()->webGraphicsContext3D())
; | 117 m_boundElementArrayBuffer->onDetached(context()->webContext()); |
118 m_boundElementArrayBuffer = nullptr; | 118 m_boundElementArrayBuffer = nullptr; |
119 } | 119 } |
120 | 120 |
121 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { | 121 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { |
122 VertexAttribState& state = m_vertexAttribState[i]; | 122 VertexAttribState& state = m_vertexAttribState[i]; |
123 if (state.bufferBinding == buffer) { | 123 if (state.bufferBinding == buffer) { |
124 buffer->onDetached(context()->webGraphicsContext3D()); | 124 buffer->onDetached(context()->webContext()); |
125 state.bufferBinding = nullptr; | 125 state.bufferBinding = nullptr; |
126 } | 126 } |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GLuint index, GLuint divi
sor) | 130 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GLuint index, GLuint divi
sor) |
131 { | 131 { |
132 VertexAttribState& state = m_vertexAttribState[index]; | 132 VertexAttribState& state = m_vertexAttribState[index]; |
133 state.divisor = divisor; | 133 state.divisor = divisor; |
134 } | 134 } |
135 | 135 |
136 } | 136 } |
OLD | NEW |