Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLProgram.cpp

Issue 1824433002: Remove getError() and synthesizeGLError() from WebGraphicsContext3D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simples-tplus
Patch Set: errors: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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() 76 bool WebGLProgram::linkStatus(WebGLRenderingContextBase* context)
77 { 77 {
78 cacheInfoIfNeeded(); 78 cacheInfoIfNeeded(context);
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()
101 {
102 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;
110 } 86 }
111 87
112 void WebGLProgram::increaseActiveTransformFeedbackCount() 88 void WebGLProgram::increaseActiveTransformFeedbackCount()
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) 150 void WebGLProgram::cacheInfoIfNeeded(WebGLRenderingContextBase* context)
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()
189 { 151 {
190 if (m_infoValid) 152 if (m_infoValid)
191 return; 153 return;
192
193 if (!m_object) 154 if (!m_object)
194 return; 155 return;
195 156 gpu::gles2::GLES2Interface* gl = context->contextGL();
196 if (!contextGroup()) 157 m_linkStatus = 0;
197 return; 158 gl->GetProgramiv(m_object, GL_LINK_STATUS, &m_linkStatus);
198 WebGraphicsContext3D* context = contextGroup()->getAWebGraphicsContext3D();
199 if (!context)
200 return;
201 gpu::gles2::GLES2Interface* gl = context->getGLES2Interface();
202 GLint linkStatus = 0;
203 gl->GetProgramiv(m_object, GL_LINK_STATUS, &linkStatus);
204 m_linkStatus = linkStatus;
205 if (m_linkStatus)
206 cacheActiveAttribLocations(context, gl);
207 m_infoValid = true; 159 m_infoValid = true;
208 } 160 }
209 161
210 DEFINE_TRACE(WebGLProgram) 162 DEFINE_TRACE(WebGLProgram)
211 { 163 {
212 visitor->trace(m_vertexShader); 164 visitor->trace(m_vertexShader);
213 visitor->trace(m_fragmentShader); 165 visitor->trace(m_fragmentShader);
214 WebGLSharedPlatform3DObject::trace(visitor); 166 WebGLSharedPlatform3DObject::trace(visitor);
215 } 167 }
216 168
217 } // namespace blink 169 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698