Chromium Code Reviews| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 if (m_vertexShader) { | 66 if (m_vertexShader) { |
| 67 m_vertexShader->onDetached(context3d, gl); | 67 m_vertexShader->onDetached(context3d, gl); |
| 68 m_vertexShader = nullptr; | 68 m_vertexShader = nullptr; |
| 69 } | 69 } |
| 70 if (m_fragmentShader) { | 70 if (m_fragmentShader) { |
| 71 m_fragmentShader->onDetached(context3d, gl); | 71 m_fragmentShader->onDetached(context3d, gl); |
| 72 m_fragmentShader = nullptr; | 72 m_fragmentShader = nullptr; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 unsigned WebGLProgram::numActiveAttribLocations() | |
| 77 { | |
| 78 cacheInfoIfNeeded(); | |
| 79 return m_activeAttribLocations.size(); | |
| 80 } | |
| 81 | |
| 82 GLint WebGLProgram::getActiveAttribLocation(GLuint index) | |
| 83 { | |
| 84 cacheInfoIfNeeded(); | |
| 85 if (index >= numActiveAttribLocations()) | |
| 86 return -1; | |
| 87 return m_activeAttribLocations[index]; | |
| 88 } | |
| 89 | |
| 90 bool WebGLProgram::isUsingVertexAttrib0() | |
| 91 { | |
| 92 cacheInfoIfNeeded(); | |
| 93 for (unsigned ii = 0; ii < numActiveAttribLocations(); ++ii) { | |
| 94 if (!getActiveAttribLocation(ii)) | |
| 95 return true; | |
| 96 } | |
| 97 return false; | |
| 98 } | |
| 99 | |
| 100 bool WebGLProgram::linkStatus() | 76 bool WebGLProgram::linkStatus() |
| 101 { | 77 { |
| 102 cacheInfoIfNeeded(); | 78 cacheInfoIfNeeded(); |
| 103 return m_linkStatus; | 79 return m_linkStatus; |
| 104 } | 80 } |
| 105 | 81 |
| 106 void WebGLProgram::increaseLinkCount() | 82 void WebGLProgram::increaseLinkCount() |
| 107 { | 83 { |
| 108 ++m_linkCount; | 84 ++m_linkCount; |
| 109 m_infoValid = false; | 85 m_infoValid = false; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 case GL_FRAGMENT_SHADER: | 140 case GL_FRAGMENT_SHADER: |
| 165 if (m_fragmentShader != shader) | 141 if (m_fragmentShader != shader) |
| 166 return false; | 142 return false; |
| 167 m_fragmentShader = nullptr; | 143 m_fragmentShader = nullptr; |
| 168 return true; | 144 return true; |
| 169 default: | 145 default: |
| 170 return false; | 146 return false; |
| 171 } | 147 } |
| 172 } | 148 } |
| 173 | 149 |
| 174 void WebGLProgram::cacheActiveAttribLocations(WebGraphicsContext3D* context3d, g pu::gles2::GLES2Interface* gl) | |
| 175 { | |
| 176 m_activeAttribLocations.clear(); | |
| 177 | |
| 178 GLint numAttribs = 0; | |
| 179 gl->GetProgramiv(m_object, GL_ACTIVE_ATTRIBUTES, &numAttribs); | |
| 180 m_activeAttribLocations.resize(static_cast<size_t>(numAttribs)); | |
| 181 for (int i = 0; i < numAttribs; ++i) { | |
| 182 WebGraphicsContext3D::ActiveInfo info; | |
| 183 context3d->getActiveAttrib(m_object, i, info); | |
| 184 m_activeAttribLocations[i] = gl->GetAttribLocation(m_object, info.name.u tf8().data()); | |
| 185 } | |
| 186 } | |
| 187 | |
| 188 void WebGLProgram::cacheInfoIfNeeded() | 150 void WebGLProgram::cacheInfoIfNeeded() |
| 189 { | 151 { |
| 190 if (m_infoValid) | 152 if (m_infoValid) |
| 191 return; | 153 return; |
| 192 | 154 |
| 193 if (!m_object) | 155 if (!m_object) |
| 194 return; | 156 return; |
| 195 | 157 |
| 196 if (!contextGroup()) | 158 if (!contextGroup()) |
| 197 return; | 159 return; |
| 160 // TODO(danakj): Make this getAWebGLRenderingContextBase. | |
|
Ken Russell (switch to Gerrit)
2016/03/19 04:36:04
WebGLProgram::linkStatus() could be changed to tak
danakj
2016/03/21 22:45:13
Done.
| |
| 198 WebGraphicsContext3D* context = contextGroup()->getAWebGraphicsContext3D(); | 161 WebGraphicsContext3D* context = contextGroup()->getAWebGraphicsContext3D(); |
| 199 if (!context) | 162 if (!context) |
| 200 return; | 163 return; |
| 201 gpu::gles2::GLES2Interface* gl = context->getGLES2Interface(); | 164 gpu::gles2::GLES2Interface* gl = context->getGLES2Interface(); |
| 202 GLint linkStatus = 0; | 165 m_linkStatus = 0; |
| 203 gl->GetProgramiv(m_object, GL_LINK_STATUS, &linkStatus); | 166 gl->GetProgramiv(m_object, GL_LINK_STATUS, &m_linkStatus); |
| 204 m_linkStatus = linkStatus; | |
| 205 if (m_linkStatus) | |
| 206 cacheActiveAttribLocations(context, gl); | |
| 207 m_infoValid = true; | 167 m_infoValid = true; |
| 208 } | 168 } |
| 209 | 169 |
| 210 DEFINE_TRACE(WebGLProgram) | 170 DEFINE_TRACE(WebGLProgram) |
| 211 { | 171 { |
| 212 visitor->trace(m_vertexShader); | 172 visitor->trace(m_vertexShader); |
| 213 visitor->trace(m_fragmentShader); | 173 visitor->trace(m_fragmentShader); |
| 214 WebGLSharedPlatform3DObject::trace(visitor); | 174 WebGLSharedPlatform3DObject::trace(visitor); |
| 215 } | 175 } |
| 216 | 176 |
| 217 } // namespace blink | 177 } // namespace blink |
| OLD | NEW |