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

Side by Side Diff: src/gpu/gl/GrGLInterface.cpp

Issue 140823003: Move GrGLExtensions from GrGLContextInfo to GrGLInterface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix Android Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLExtensions.cpp ('k') | src/gpu/gl/GrGpuGL.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "gl/GrGLInterface.h" 9 #include "gl/GrGLInterface.h"
10 #include "gl/GrGLExtensions.h" 10 #include "gl/GrGLExtensions.h"
(...skipping 15 matching lines...) Expand all
26 fCallbackData = 0; 26 fCallbackData = 0;
27 #endif 27 #endif
28 } 28 }
29 29
30 bool GrGLInterface::validate() const { 30 bool GrGLInterface::validate() const {
31 31
32 if (kNone_GrGLStandard == fStandard) { 32 if (kNone_GrGLStandard == fStandard) {
33 return false; 33 return false;
34 } 34 }
35 35
36 GrGLExtensions extensions; 36 // This const hackery is necessary because the factories in Chromium do not yet initialize
37 if (!extensions.init(this)) { 37 // fExtensions.
38 return false; 38 if (!fExtensions.isInitialized()) {
39 GrGLExtensions* extensions = const_cast<GrGLExtensions*>(&fExtensions);
40 if (!extensions->init(fStandard, fGetString, fGetStringi, fGetIntegerv)) {
41 return false;
42 }
39 } 43 }
40 44
41 // functions that are always required 45 // functions that are always required
42 if (NULL == fActiveTexture || 46 if (NULL == fActiveTexture ||
43 NULL == fAttachShader || 47 NULL == fAttachShader ||
44 NULL == fBindAttribLocation || 48 NULL == fBindAttribLocation ||
45 NULL == fBindBuffer || 49 NULL == fBindBuffer ||
46 NULL == fBindTexture || 50 NULL == fBindTexture ||
47 NULL == fBlendFunc || 51 NULL == fBlendFunc ||
48 NULL == fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension 52 NULL == fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 GrGLVersion glVer = GrGLGetVersion(this); 141 GrGLVersion glVer = GrGLGetVersion(this);
138 142
139 bool isCoreProfile = false; 143 bool isCoreProfile = false;
140 if (kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,2)) { 144 if (kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,2)) {
141 GrGLint profileMask; 145 GrGLint profileMask;
142 GR_GL_GetIntegerv(this, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); 146 GR_GL_GetIntegerv(this, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
143 isCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); 147 isCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
144 } 148 }
145 149
146 // Now check that baseline ES/Desktop fns not covered above are present 150 // Now check that baseline ES/Desktop fns not covered above are present
147 // and that we have fn pointers for any advertised extensions that we will 151 // and that we have fn pointers for any advertised fExtensions that we will
148 // try to use. 152 // try to use.
149 153
150 // these functions are part of ES2, we assume they are available 154 // these functions are part of ES2, we assume they are available
151 // On the desktop we assume they are available if the extension 155 // On the desktop we assume they are available if the extension
152 // is present or GL version is high enough. 156 // is present or GL version is high enough.
153 if (kGLES_GrGLStandard == fStandard) { 157 if (kGLES_GrGLStandard == fStandard) {
154 if (NULL == fStencilFuncSeparate || 158 if (NULL == fStencilFuncSeparate ||
155 NULL == fStencilMaskSeparate || 159 NULL == fStencilMaskSeparate ||
156 NULL == fStencilOpSeparate) { 160 NULL == fStencilOpSeparate) {
157 return false; 161 return false;
158 } 162 }
159 } else if (kGL_GrGLStandard == fStandard) { 163 } else if (kGL_GrGLStandard == fStandard) {
160 164
161 if (glVer >= GR_GL_VER(2,0)) { 165 if (glVer >= GR_GL_VER(2,0)) {
162 if (NULL == fStencilFuncSeparate || 166 if (NULL == fStencilFuncSeparate ||
163 NULL == fStencilMaskSeparate || 167 NULL == fStencilMaskSeparate ||
164 NULL == fStencilOpSeparate) { 168 NULL == fStencilOpSeparate) {
165 return false; 169 return false;
166 } 170 }
167 } 171 }
168 if (glVer >= GR_GL_VER(3,0) && NULL == fBindFragDataLocation) { 172 if (glVer >= GR_GL_VER(3,0) && NULL == fBindFragDataLocation) {
169 return false; 173 return false;
170 } 174 }
171 if (glVer >= GR_GL_VER(2,0) || extensions.has("GL_ARB_draw_buffers")) { 175 if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) {
172 if (NULL == fDrawBuffers) { 176 if (NULL == fDrawBuffers) {
173 return false; 177 return false;
174 } 178 }
175 } 179 }
176 180
177 if (glVer >= GR_GL_VER(1,5) || extensions.has("GL_ARB_occlusion_query")) { 181 if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query") ) {
178 if (NULL == fGenQueries || 182 if (NULL == fGenQueries ||
179 NULL == fDeleteQueries || 183 NULL == fDeleteQueries ||
180 NULL == fBeginQuery || 184 NULL == fBeginQuery ||
181 NULL == fEndQuery || 185 NULL == fEndQuery ||
182 NULL == fGetQueryiv || 186 NULL == fGetQueryiv ||
183 NULL == fGetQueryObjectiv || 187 NULL == fGetQueryObjectiv ||
184 NULL == fGetQueryObjectuiv) { 188 NULL == fGetQueryObjectuiv) {
185 return false; 189 return false;
186 } 190 }
187 } 191 }
188 if (glVer >= GR_GL_VER(3,3) || 192 if (glVer >= GR_GL_VER(3,3) ||
189 extensions.has("GL_ARB_timer_query") || 193 fExtensions.has("GL_ARB_timer_query") ||
190 extensions.has("GL_EXT_timer_query")) { 194 fExtensions.has("GL_EXT_timer_query")) {
191 if (NULL == fGetQueryObjecti64v || 195 if (NULL == fGetQueryObjecti64v ||
192 NULL == fGetQueryObjectui64v) { 196 NULL == fGetQueryObjectui64v) {
193 return false; 197 return false;
194 } 198 }
195 } 199 }
196 if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { 200 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
197 if (NULL == fQueryCounter) { 201 if (NULL == fQueryCounter) {
198 return false; 202 return false;
199 } 203 }
200 } 204 }
201 if (!isCoreProfile) { 205 if (!isCoreProfile) {
202 if (NULL == fClientActiveTexture || 206 if (NULL == fClientActiveTexture ||
203 NULL == fDisableClientState || 207 NULL == fDisableClientState ||
204 NULL == fEnableClientState || 208 NULL == fEnableClientState ||
205 NULL == fLoadIdentity || 209 NULL == fLoadIdentity ||
206 NULL == fLoadMatrixf || 210 NULL == fLoadMatrixf ||
207 NULL == fMatrixMode || 211 NULL == fMatrixMode ||
208 NULL == fTexGenf || 212 NULL == fTexGenf ||
209 NULL == fTexGenfv || 213 NULL == fTexGenfv ||
210 NULL == fTexGeni || 214 NULL == fTexGeni ||
211 NULL == fVertexPointer) { 215 NULL == fVertexPointer) {
212 return false; 216 return false;
213 } 217 }
214 } 218 }
215 if (false && extensions.has("GL_NV_path_rendering")) { 219 if (false && fExtensions.has("GL_NV_path_rendering")) {
216 if (NULL == fPathCommands || 220 if (NULL == fPathCommands ||
217 NULL == fPathCoords || 221 NULL == fPathCoords ||
218 NULL == fPathSubCommands || 222 NULL == fPathSubCommands ||
219 NULL == fPathSubCoords || 223 NULL == fPathSubCoords ||
220 NULL == fPathString || 224 NULL == fPathString ||
221 NULL == fPathGlyphs || 225 NULL == fPathGlyphs ||
222 NULL == fPathGlyphRange || 226 NULL == fPathGlyphRange ||
223 NULL == fWeightPaths || 227 NULL == fWeightPaths ||
224 NULL == fCopyPath || 228 NULL == fCopyPath ||
225 NULL == fInterpolatePaths || 229 NULL == fInterpolatePaths ||
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 NULL == fGetPathLength || 267 NULL == fGetPathLength ||
264 NULL == fPointAlongPath) { 268 NULL == fPointAlongPath) {
265 return false; 269 return false;
266 } 270 }
267 } 271 }
268 } 272 }
269 273
270 // optional function on desktop before 1.3 274 // optional function on desktop before 1.3
271 if (kGL_GrGLStandard != fStandard || 275 if (kGL_GrGLStandard != fStandard ||
272 (glVer >= GR_GL_VER(1,3)) || 276 (glVer >= GR_GL_VER(1,3)) ||
273 extensions.has("GL_ARB_texture_compression")) { 277 fExtensions.has("GL_ARB_texture_compression")) {
274 if (NULL == fCompressedTexImage2D) { 278 if (NULL == fCompressedTexImage2D) {
275 return false; 279 return false;
276 } 280 }
277 } 281 }
278 282
279 // part of desktop GL, but not ES 283 // part of desktop GL, but not ES
280 if (kGL_GrGLStandard == fStandard && 284 if (kGL_GrGLStandard == fStandard &&
281 (NULL == fGetTexLevelParameteriv || 285 (NULL == fGetTexLevelParameteriv ||
282 NULL == fDrawBuffer || 286 NULL == fDrawBuffer ||
283 NULL == fReadBuffer)) { 287 NULL == fReadBuffer)) {
284 return false; 288 return false;
285 } 289 }
286 290
287 // GL_EXT_texture_storage is part of desktop 4.2 291 // GL_EXT_texture_storage is part of desktop 4.2
288 // There is a desktop ARB extension and an ES+desktop EXT extension 292 // There is a desktop ARB extension and an ES+desktop EXT extension
289 if (kGL_GrGLStandard == fStandard) { 293 if (kGL_GrGLStandard == fStandard) {
290 if (glVer >= GR_GL_VER(4,2) || 294 if (glVer >= GR_GL_VER(4,2) ||
291 extensions.has("GL_ARB_texture_storage") || 295 fExtensions.has("GL_ARB_texture_storage") ||
292 extensions.has("GL_EXT_texture_storage")) { 296 fExtensions.has("GL_EXT_texture_storage")) {
293 if (NULL == fTexStorage2D) { 297 if (NULL == fTexStorage2D) {
294 return false; 298 return false;
295 } 299 }
296 } 300 }
297 } else if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_EXT_texture_storage ")) { 301 } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storag e")) {
298 if (NULL == fTexStorage2D) { 302 if (NULL == fTexStorage2D) {
299 return false; 303 return false;
300 } 304 }
301 } 305 }
302 306
303 if (extensions.has("GL_EXT_discard_framebuffer")) { 307 if (fExtensions.has("GL_EXT_discard_framebuffer")) {
304 // FIXME: Remove this once Chromium is updated to provide this function 308 // FIXME: Remove this once Chromium is updated to provide this function
305 #if 0 309 #if 0
306 if (NULL == fDiscardFramebuffer) { 310 if (NULL == fDiscardFramebuffer) {
307 return false; 311 return false;
308 } 312 }
309 #endif 313 #endif
310 } 314 }
311 315
312 // FBO MSAA 316 // FBO MSAA
313 if (kGL_GrGLStandard == fStandard) { 317 if (kGL_GrGLStandard == fStandard) {
314 // GL 3.0 and the ARB extension have multisample + blit 318 // GL 3.0 and the ARB extension have multisample + blit
315 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object ")) { 319 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_objec t")) {
316 if (NULL == fRenderbufferStorageMultisample || 320 if (NULL == fRenderbufferStorageMultisample ||
317 NULL == fBlitFramebuffer) { 321 NULL == fBlitFramebuffer) {
318 return false; 322 return false;
319 } 323 }
320 } else { 324 } else {
321 if (extensions.has("GL_EXT_framebuffer_blit") && 325 if (fExtensions.has("GL_EXT_framebuffer_blit") &&
322 NULL == fBlitFramebuffer) { 326 NULL == fBlitFramebuffer) {
323 return false; 327 return false;
324 } 328 }
325 if (extensions.has("GL_EXT_framebuffer_multisample") && 329 if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
326 NULL == fRenderbufferStorageMultisample) { 330 NULL == fRenderbufferStorageMultisample) {
327 return false; 331 return false;
328 } 332 }
329 } 333 }
330 } else { 334 } else {
331 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_CHROMIUM_framebuffer_m ultisample")) { 335 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_ multisample")) {
332 if (NULL == fRenderbufferStorageMultisample || 336 if (NULL == fRenderbufferStorageMultisample ||
333 NULL == fBlitFramebuffer) { 337 NULL == fBlitFramebuffer) {
334 return false; 338 return false;
335 } 339 }
336 } 340 }
337 if (extensions.has("GL_APPLE_framebuffer_multisample")) { 341 if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
338 if (NULL == fRenderbufferStorageMultisampleES2APPLE || 342 if (NULL == fRenderbufferStorageMultisampleES2APPLE ||
339 NULL == fResolveMultisampleFramebuffer) { 343 NULL == fResolveMultisampleFramebuffer) {
340 return false; 344 return false;
341 } 345 }
342 } 346 }
343 if (extensions.has("GL_IMG_multisampled_render_to_texture") || 347 if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
344 extensions.has("GL_EXT_multisampled_render_to_texture")) { 348 fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
345 if (NULL == fRenderbufferStorageMultisampleES2EXT || 349 if (NULL == fRenderbufferStorageMultisampleES2EXT ||
346 NULL == fFramebufferTexture2DMultisample) { 350 NULL == fFramebufferTexture2DMultisample) {
347 return false; 351 return false;
348 } 352 }
349 } 353 }
350 } 354 }
351 355
352 // On ES buffer mapping is an extension. On Desktop 356 // On ES buffer mapping is an extension. On Desktop
353 // buffer mapping was part of original VBO extension 357 // buffer mapping was part of original VBO extension
354 // which we require. 358 // which we require.
355 if (kGL_GrGLStandard == fStandard || extensions.has("GL_OES_mapbuffer")) { 359 if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
356 if (NULL == fMapBuffer || 360 if (NULL == fMapBuffer ||
357 NULL == fUnmapBuffer) { 361 NULL == fUnmapBuffer) {
358 return false; 362 return false;
359 } 363 }
360 } 364 }
361 365
362 // Dual source blending 366 // Dual source blending
363 if (kGL_GrGLStandard == fStandard && 367 if (kGL_GrGLStandard == fStandard &&
364 (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_blend_func_extended") )) { 368 (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended" ))) {
365 if (NULL == fBindFragDataLocationIndexed) { 369 if (NULL == fBindFragDataLocationIndexed) {
366 return false; 370 return false;
367 } 371 }
368 } 372 }
369 373
370 // glGetStringi was added in version 3.0 of both desktop and ES. 374 // glGetStringi was added in version 3.0 of both desktop and ES.
371 if (glVer >= GR_GL_VER(3, 0)) { 375 if (glVer >= GR_GL_VER(3, 0)) {
372 if (NULL == fGetStringi) { 376 if (NULL == fGetStringi) {
373 return false; 377 return false;
374 } 378 }
375 } 379 }
376 380
377 if (kGL_GrGLStandard == fStandard) { 381 if (kGL_GrGLStandard == fStandard) {
378 if (glVer >= GR_GL_VER(3, 0) || extensions.has("GL_ARB_vertex_array_obje ct")) { 382 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_obj ect")) {
379 if (NULL == fBindVertexArray || 383 if (NULL == fBindVertexArray ||
380 NULL == fDeleteVertexArrays || 384 NULL == fDeleteVertexArrays ||
381 NULL == fGenVertexArrays) { 385 NULL == fGenVertexArrays) {
382 return false; 386 return false;
383 } 387 }
384 } 388 }
385 } else { 389 } else {
386 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_OES_vertex_array_objec t")) { 390 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_obje ct")) {
387 if (NULL == fBindVertexArray || 391 if (NULL == fBindVertexArray ||
388 NULL == fDeleteVertexArrays || 392 NULL == fDeleteVertexArrays ||
389 NULL == fGenVertexArrays) { 393 NULL == fGenVertexArrays) {
390 return false; 394 return false;
391 } 395 }
392 } 396 }
393 } 397 }
394 398
395 return true; 399 return true;
396 } 400 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLExtensions.cpp ('k') | src/gpu/gl/GrGpuGL.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698