| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // Always call detach here to ensure that platform object deletion | 59 // Always call detach here to ensure that platform object deletion |
| 60 // happens with Oilpan enabled. It keeps the code regular to do it | 60 // happens with Oilpan enabled. It keeps the code regular to do it |
| 61 // with or without Oilpan enabled. | 61 // with or without Oilpan enabled. |
| 62 // | 62 // |
| 63 // See comment in WebGLBuffer's destructor for additional | 63 // See comment in WebGLBuffer's destructor for additional |
| 64 // information on why this is done for WebGLSharedObject-derived | 64 // information on why this is done for WebGLSharedObject-derived |
| 65 // objects. | 65 // objects. |
| 66 detachAndDeleteObject(); | 66 detachAndDeleteObject(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void WebGLProgram::deleteObjectImpl(blink::WebGraphicsContext3D* context3d) | 69 void WebGLProgram::deleteObjectImpl(WebGraphicsContext3D* context3d) |
| 70 { | 70 { |
| 71 context3d->deleteProgram(m_object); | 71 context3d->deleteProgram(m_object); |
| 72 m_object = 0; | 72 m_object = 0; |
| 73 if (m_vertexShader) { | 73 if (m_vertexShader) { |
| 74 m_vertexShader->onDetached(context3d); | 74 m_vertexShader->onDetached(context3d); |
| 75 m_vertexShader = nullptr; | 75 m_vertexShader = nullptr; |
| 76 } | 76 } |
| 77 if (m_fragmentShader) { | 77 if (m_fragmentShader) { |
| 78 m_fragmentShader->onDetached(context3d); | 78 m_fragmentShader->onDetached(context3d); |
| 79 m_fragmentShader = nullptr; | 79 m_fragmentShader = nullptr; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 case GL_FRAGMENT_SHADER: | 161 case GL_FRAGMENT_SHADER: |
| 162 if (m_fragmentShader != shader) | 162 if (m_fragmentShader != shader) |
| 163 return false; | 163 return false; |
| 164 m_fragmentShader = nullptr; | 164 m_fragmentShader = nullptr; |
| 165 return true; | 165 return true; |
| 166 default: | 166 default: |
| 167 return false; | 167 return false; |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 void WebGLProgram::cacheActiveAttribLocations(blink::WebGraphicsContext3D* conte
xt3d) | 171 void WebGLProgram::cacheActiveAttribLocations(WebGraphicsContext3D* context3d) |
| 172 { | 172 { |
| 173 m_activeAttribLocations.clear(); | 173 m_activeAttribLocations.clear(); |
| 174 | 174 |
| 175 GLint numAttribs = 0; | 175 GLint numAttribs = 0; |
| 176 context3d->getProgramiv(m_object, GL_ACTIVE_ATTRIBUTES, &numAttribs); | 176 context3d->getProgramiv(m_object, GL_ACTIVE_ATTRIBUTES, &numAttribs); |
| 177 m_activeAttribLocations.resize(static_cast<size_t>(numAttribs)); | 177 m_activeAttribLocations.resize(static_cast<size_t>(numAttribs)); |
| 178 for (int i = 0; i < numAttribs; ++i) { | 178 for (int i = 0; i < numAttribs; ++i) { |
| 179 blink::WebGraphicsContext3D::ActiveInfo info; | 179 WebGraphicsContext3D::ActiveInfo info; |
| 180 context3d->getActiveAttrib(m_object, i, info); | 180 context3d->getActiveAttrib(m_object, i, info); |
| 181 m_activeAttribLocations[i] = context3d->getAttribLocation(m_object, info
.name.utf8().data()); | 181 m_activeAttribLocations[i] = context3d->getAttribLocation(m_object, info
.name.utf8().data()); |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 void WebGLProgram::cacheInfoIfNeeded() | 185 void WebGLProgram::cacheInfoIfNeeded() |
| 186 { | 186 { |
| 187 if (m_infoValid) | 187 if (m_infoValid) |
| 188 return; | 188 return; |
| 189 | 189 |
| 190 if (!m_object) | 190 if (!m_object) |
| 191 return; | 191 return; |
| 192 | 192 |
| 193 if (!contextGroup()) | 193 if (!contextGroup()) |
| 194 return; | 194 return; |
| 195 blink::WebGraphicsContext3D* context = contextGroup()->getAWebGraphicsContex
t3D(); | 195 WebGraphicsContext3D* context = contextGroup()->getAWebGraphicsContext3D(); |
| 196 if (!context) | 196 if (!context) |
| 197 return; | 197 return; |
| 198 GLint linkStatus = 0; | 198 GLint linkStatus = 0; |
| 199 context->getProgramiv(m_object, GL_LINK_STATUS, &linkStatus); | 199 context->getProgramiv(m_object, GL_LINK_STATUS, &linkStatus); |
| 200 m_linkStatus = linkStatus; | 200 m_linkStatus = linkStatus; |
| 201 if (m_linkStatus) | 201 if (m_linkStatus) |
| 202 cacheActiveAttribLocations(context); | 202 cacheActiveAttribLocations(context); |
| 203 m_infoValid = true; | 203 m_infoValid = true; |
| 204 } | 204 } |
| 205 | 205 |
| 206 DEFINE_TRACE(WebGLProgram) | 206 DEFINE_TRACE(WebGLProgram) |
| 207 { | 207 { |
| 208 visitor->trace(m_vertexShader); | 208 visitor->trace(m_vertexShader); |
| 209 visitor->trace(m_fragmentShader); | 209 visitor->trace(m_fragmentShader); |
| 210 WebGLSharedPlatform3DObject::trace(visitor); | 210 WebGLSharedPlatform3DObject::trace(visitor); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } | 213 } // namespace blink |
| OLD | NEW |