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 13 matching lines...) Expand all Loading... |
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/WebGLRenderingContextBase.h" | 30 #include "core/html/canvas/WebGLRenderingContextBase.h" |
31 | 31 |
32 namespace WebCore { | 32 namespace WebCore { |
33 | 33 |
34 PassRefPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::create(WebGLRen
deringContextBase* ctx, VaoType type) | 34 PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::cre
ate(WebGLRenderingContextBase* ctx, VaoType type) |
35 { | 35 { |
36 return adoptRef(new WebGLVertexArrayObjectOES(ctx, type)); | 36 return adoptRefWillBeNoop(new WebGLVertexArrayObjectOES(ctx, type)); |
37 } | 37 } |
38 | 38 |
39 WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContextBase*
ctx, VaoType type) | 39 WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContextBase*
ctx, VaoType type) |
40 : WebGLContextObject(ctx) | 40 : WebGLContextObject(ctx) |
41 , m_type(type) | 41 , m_type(type) |
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()->webContext()->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 #if ENABLE(OILPAN) |
| 60 m_boundElementArrayBuffer = nullptr; |
| 61 m_vertexAttribState.clear(); |
| 62 #endif |
| 63 detach(); |
59 deleteObject(0); | 64 deleteObject(0); |
60 } | 65 } |
61 | 66 |
62 void WebGLVertexArrayObjectOES::deleteObjectImpl(blink::WebGraphicsContext3D* co
ntext3d, Platform3DObject object) | 67 void WebGLVertexArrayObjectOES::deleteObjectImpl(blink::WebGraphicsContext3D* co
ntext3d, Platform3DObject object) |
63 { | 68 { |
64 switch (m_type) { | 69 switch (m_type) { |
65 case VaoTypeDefault: | 70 case VaoTypeDefault: |
66 break; | 71 break; |
67 default: | 72 default: |
68 context()->webContext()->deleteVertexArrayOES(object); | 73 context3d->deleteVertexArrayOES(object); |
69 break; | 74 break; |
70 } | 75 } |
71 | 76 |
72 if (m_boundElementArrayBuffer) | 77 if (m_boundElementArrayBuffer) |
73 m_boundElementArrayBuffer->onDetached(context3d); | 78 m_boundElementArrayBuffer->onDetached(context3d); |
74 | 79 |
75 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { | 80 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { |
76 VertexAttribState& state = m_vertexAttribState[i]; | 81 VertexAttribState& state = m_vertexAttribState[i]; |
77 if (state.bufferBinding) | 82 if (state.bufferBinding) |
78 state.bufferBinding->onDetached(context3d); | 83 state.bufferBinding->onDetached(context3d); |
79 } | 84 } |
80 } | 85 } |
81 | 86 |
82 void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtr<WebGLBuffer> bu
ffer) | 87 void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtrWillBeRawPtr<Web
GLBuffer> buffer) |
83 { | 88 { |
84 if (buffer) | 89 if (buffer) |
85 buffer->onAttached(); | 90 buffer->onAttached(); |
86 if (m_boundElementArrayBuffer) | 91 if (m_boundElementArrayBuffer) |
87 m_boundElementArrayBuffer->onDetached(context()->webContext()); | 92 m_boundElementArrayBuffer->onDetached(context()->webContext()); |
88 m_boundElementArrayBuffer = buffer; | 93 m_boundElementArrayBuffer = buffer; |
89 | |
90 } | 94 } |
91 | 95 |
92 void WebGLVertexArrayObjectOES::setVertexAttribState( | 96 void WebGLVertexArrayObjectOES::setVertexAttribState( |
93 GLuint index, GLsizei bytesPerElement, GLint size, GLenum type, GLboolean no
rmalized, GLsizei stride, GLintptr offset, PassRefPtr<WebGLBuffer> buffer) | 97 GLuint index, GLsizei bytesPerElement, GLint size, GLenum type, GLboolean no
rmalized, GLsizei stride, GLintptr offset, PassRefPtrWillBeRawPtr<WebGLBuffer> b
uffer) |
94 { | 98 { |
95 GLsizei validatedStride = stride ? stride : bytesPerElement; | 99 GLsizei validatedStride = stride ? stride : bytesPerElement; |
96 | 100 |
97 VertexAttribState& state = m_vertexAttribState[index]; | 101 VertexAttribState& state = m_vertexAttribState[index]; |
98 | 102 |
99 if (buffer) | 103 if (buffer) |
100 buffer->onAttached(); | 104 buffer->onAttached(); |
101 if (state.bufferBinding) | 105 if (state.bufferBinding) |
102 state.bufferBinding->onDetached(context()->webContext()); | 106 state.bufferBinding->onDetached(context()->webContext()); |
103 | 107 |
104 state.bufferBinding = buffer; | 108 state.bufferBinding = buffer; |
105 state.bytesPerElement = bytesPerElement; | 109 state.bytesPerElement = bytesPerElement; |
106 state.size = size; | 110 state.size = size; |
107 state.type = type; | 111 state.type = type; |
108 state.normalized = normalized; | 112 state.normalized = normalized; |
109 state.stride = validatedStride; | 113 state.stride = validatedStride; |
110 state.originalStride = stride; | 114 state.originalStride = stride; |
111 state.offset = offset; | 115 state.offset = offset; |
112 } | 116 } |
113 | 117 |
114 void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtr<WebGLBuffer> buffer) | 118 void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtrWillBeRawPtr<WebGLBuffer>
buffer) |
115 { | 119 { |
116 if (m_boundElementArrayBuffer == buffer) { | 120 if (m_boundElementArrayBuffer == buffer) { |
117 m_boundElementArrayBuffer->onDetached(context()->webContext()); | 121 m_boundElementArrayBuffer->onDetached(context()->webContext()); |
118 m_boundElementArrayBuffer = nullptr; | 122 m_boundElementArrayBuffer = nullptr; |
119 } | 123 } |
120 | 124 |
121 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { | 125 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { |
122 VertexAttribState& state = m_vertexAttribState[i]; | 126 VertexAttribState& state = m_vertexAttribState[i]; |
123 if (state.bufferBinding == buffer) { | 127 if (state.bufferBinding == buffer) { |
124 buffer->onDetached(context()->webContext()); | 128 buffer->onDetached(context()->webContext()); |
125 state.bufferBinding = nullptr; | 129 state.bufferBinding = nullptr; |
126 } | 130 } |
127 } | 131 } |
128 } | 132 } |
129 | 133 |
130 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GLuint index, GLuint divi
sor) | 134 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GLuint index, GLuint divi
sor) |
131 { | 135 { |
132 VertexAttribState& state = m_vertexAttribState[index]; | 136 VertexAttribState& state = m_vertexAttribState[index]; |
133 state.divisor = divisor; | 137 state.divisor = divisor; |
134 } | 138 } |
135 | 139 |
| 140 void WebGLVertexArrayObjectOES::VertexAttribState::trace(Visitor* visitor) |
| 141 { |
| 142 visitor->trace(bufferBinding); |
136 } | 143 } |
| 144 |
| 145 void WebGLVertexArrayObjectOES::trace(Visitor* visitor) |
| 146 { |
| 147 visitor->trace(m_boundElementArrayBuffer); |
| 148 visitor->trace(m_vertexAttribState); |
| 149 WebGLContextObject::trace(visitor); |
| 150 } |
| 151 |
| 152 } |
OLD | NEW |