OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 if (m_vertexShader) { | 57 if (m_vertexShader) { |
58 m_vertexShader->onDetached(context3d); | 58 m_vertexShader->onDetached(context3d); |
59 m_vertexShader = 0; | 59 m_vertexShader = 0; |
60 } | 60 } |
61 if (m_fragmentShader) { | 61 if (m_fragmentShader) { |
62 m_fragmentShader->onDetached(context3d); | 62 m_fragmentShader->onDetached(context3d); |
63 m_fragmentShader = 0; | 63 m_fragmentShader = 0; |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 unsigned WebGLProgram::numActiveAttribLocations() | 67 unsigned WebGLProgram::numActiveAttribLocations(WebGLRenderingContext* context) |
68 { | 68 { |
69 cacheInfoIfNeeded(); | 69 cacheInfoIfNeeded(context); |
70 return m_activeAttribLocations.size(); | 70 return m_activeAttribLocations.size(); |
71 } | 71 } |
72 | 72 |
73 GC3Dint WebGLProgram::getActiveAttribLocation(GC3Duint index) | 73 GC3Dint WebGLProgram::getActiveAttribLocation(WebGLRenderingContext* context, GC
3Duint index) |
74 { | 74 { |
75 cacheInfoIfNeeded(); | 75 cacheInfoIfNeeded(context); |
76 if (index >= numActiveAttribLocations()) | 76 if (index >= numActiveAttribLocations(context)) |
77 return -1; | 77 return -1; |
78 return m_activeAttribLocations[index]; | 78 return m_activeAttribLocations[index]; |
79 } | 79 } |
80 | 80 |
81 bool WebGLProgram::isUsingVertexAttrib0() | 81 bool WebGLProgram::isUsingVertexAttrib0(WebGLRenderingContext* context) |
82 { | 82 { |
83 cacheInfoIfNeeded(); | 83 cacheInfoIfNeeded(context); |
84 for (unsigned ii = 0; ii < numActiveAttribLocations(); ++ii) { | 84 unsigned numLocations = numActiveAttribLocations(context); |
85 if (!getActiveAttribLocation(ii)) | 85 for (unsigned ii = 0; ii < numLocations; ++ii) { |
| 86 if (!getActiveAttribLocation(context, ii)) |
86 return true; | 87 return true; |
87 } | 88 } |
88 return false; | 89 return false; |
89 } | 90 } |
90 | 91 |
91 bool WebGLProgram::getLinkStatus() | 92 bool WebGLProgram::getLinkStatus(WebGLRenderingContext* context) |
92 { | 93 { |
93 cacheInfoIfNeeded(); | 94 cacheInfoIfNeeded(context); |
94 return m_linkStatus; | 95 return m_linkStatus; |
95 } | 96 } |
96 | 97 |
97 void WebGLProgram::setLinkStatus(bool status) | 98 void WebGLProgram::setLinkStatus(WebGLRenderingContext* context, bool status) |
98 { | 99 { |
99 cacheInfoIfNeeded(); | 100 cacheInfoIfNeeded(context); |
100 m_linkStatus = status; | 101 m_linkStatus = status; |
101 } | 102 } |
102 | 103 |
103 void WebGLProgram::increaseLinkCount() | 104 void WebGLProgram::increaseLinkCount() |
104 { | 105 { |
105 ++m_linkCount; | 106 ++m_linkCount; |
106 m_infoValid = false; | 107 m_infoValid = false; |
107 } | 108 } |
108 | 109 |
109 WebGLShader* WebGLProgram::getAttachedShader(GC3Denum type) | 110 WebGLShader* WebGLProgram::getAttachedShader(GC3Denum type) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 GC3Dint numAttribs = 0; | 166 GC3Dint numAttribs = 0; |
166 context3d->getProgramiv(object(), GraphicsContext3D::ACTIVE_ATTRIBUTES, &num
Attribs); | 167 context3d->getProgramiv(object(), GraphicsContext3D::ACTIVE_ATTRIBUTES, &num
Attribs); |
167 m_activeAttribLocations.resize(static_cast<size_t>(numAttribs)); | 168 m_activeAttribLocations.resize(static_cast<size_t>(numAttribs)); |
168 for (int i = 0; i < numAttribs; ++i) { | 169 for (int i = 0; i < numAttribs; ++i) { |
169 ActiveInfo info; | 170 ActiveInfo info; |
170 context3d->getActiveAttrib(object(), i, info); | 171 context3d->getActiveAttrib(object(), i, info); |
171 m_activeAttribLocations[i] = context3d->getAttribLocation(object(), info
.name.charactersWithNullTermination()); | 172 m_activeAttribLocations[i] = context3d->getAttribLocation(object(), info
.name.charactersWithNullTermination()); |
172 } | 173 } |
173 } | 174 } |
174 | 175 |
175 void WebGLProgram::cacheInfoIfNeeded() | 176 void WebGLProgram::cacheInfoIfNeeded(WebGLRenderingContext* context) |
176 { | 177 { |
177 if (m_infoValid) | 178 if (m_infoValid) |
178 return; | 179 return; |
179 | 180 |
180 if (!object()) | 181 if (!object()) |
181 return; | 182 return; |
182 | 183 |
183 GraphicsContext3D* context = getAGraphicsContext3D(); | 184 GraphicsContext3D* gc3d = context->graphicsContext3D(); |
184 if (!context) | 185 if (!context) |
185 return; | 186 return; |
186 GC3Dint linkStatus = 0; | 187 GC3Dint linkStatus = 0; |
187 context->getProgramiv(object(), GraphicsContext3D::LINK_STATUS, &linkStatus)
; | 188 gc3d->getProgramiv(object(), GraphicsContext3D::LINK_STATUS, &linkStatus); |
188 m_linkStatus = linkStatus; | 189 m_linkStatus = linkStatus; |
189 if (m_linkStatus) | 190 if (m_linkStatus) |
190 cacheActiveAttribLocations(context); | 191 cacheActiveAttribLocations(gc3d); |
191 m_infoValid = true; | 192 m_infoValid = true; |
192 } | 193 } |
193 | 194 |
194 } | 195 } |
OLD | NEW |