1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  *
7  * THIS FILE IS AUTOGENERATED
8  * Make edits to tools/gpu/gl/interface/templates.go or they will
9  * be overwritten.
10  */
11 
12 #include "include/gpu/gl/GrGLExtensions.h"
13 #include "include/gpu/gl/GrGLInterface.h"
14 #include "src/gpu/gl/GrGLUtil.h"
15 
16 #include <stdio.h>
17 
GrGLInterface()18 GrGLInterface::GrGLInterface() {
19     fStandard = kNone_GrGLStandard;
20 }
21 
22 #if GR_GL_CHECK_ERROR
get_error_string(GrGLenum err)23 static const char* get_error_string(GrGLenum err) {
24     switch (err) {
25         case GR_GL_NO_ERROR:
26             return "";
27         case GR_GL_INVALID_ENUM:
28             return "Invalid Enum";
29         case GR_GL_INVALID_VALUE:
30             return "Invalid Value";
31         case GR_GL_INVALID_OPERATION:
32             return "Invalid Operation";
33         case GR_GL_OUT_OF_MEMORY:
34             return "Out of Memory";
35         case GR_GL_CONTEXT_LOST:
36             return "Context Lost";
37     }
38     return "Unknown";
39 }
40 
checkError(const char * location,const char * call) const41 GrGLenum GrGLInterface::checkError(const char* location, const char* call) const {
42     GrGLenum error = fFunctions.fGetError();
43     if (error != GR_GL_NO_ERROR && !fSuppressErrorLogging) {
44         SkDebugf("---- glGetError 0x%x(%s)", error, get_error_string(error));
45         if (location) {
46             SkDebugf(" at\n\t%s", location);
47         }
48         if (call) {
49             SkDebugf("\n\t\t%s", call);
50         }
51         SkDebugf("\n");
52         if (error == GR_GL_OUT_OF_MEMORY) {
53             fOOMed = true;
54         }
55     }
56     return error;
57 }
58 
checkAndResetOOMed() const59 bool GrGLInterface::checkAndResetOOMed() const {
60     if (fOOMed) {
61         fOOMed = false;
62         return true;
63     }
64     return false;
65 }
66 
suppressErrorLogging()67 void GrGLInterface::suppressErrorLogging() { fSuppressErrorLogging = true; }
68 #endif
69 
70 #define RETURN_FALSE_INTERFACE                                                 \
71     SkDEBUGF("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); \
72     return false
73 
validate() const74 bool GrGLInterface::validate() const {
75 
76     if (kNone_GrGLStandard == fStandard) {
77         RETURN_FALSE_INTERFACE;
78     }
79 
80     if (!fExtensions.isInitialized()) {
81         RETURN_FALSE_INTERFACE;
82     }
83 
84     GrGLVersion glVer = GrGLGetVersion(this);
85     if (GR_GL_INVALID_VER == glVer) {
86         RETURN_FALSE_INTERFACE;
87     }
88     // Autogenerated content follows
89     if (!fFunctions.fActiveTexture ||
90         !fFunctions.fAttachShader ||
91         !fFunctions.fBindAttribLocation ||
92         !fFunctions.fBindBuffer ||
93         !fFunctions.fBindTexture ||
94         !fFunctions.fBlendColor ||
95         !fFunctions.fBlendEquation ||
96         !fFunctions.fBlendFunc ||
97         !fFunctions.fBufferData ||
98         !fFunctions.fBufferSubData ||
99         !fFunctions.fClear ||
100         !fFunctions.fClearColor ||
101         !fFunctions.fClearStencil ||
102         !fFunctions.fColorMask ||
103         !fFunctions.fCompileShader ||
104         !fFunctions.fCompressedTexImage2D ||
105         !fFunctions.fCompressedTexSubImage2D ||
106         !fFunctions.fCopyTexSubImage2D ||
107         !fFunctions.fCreateProgram ||
108         !fFunctions.fCreateShader ||
109         !fFunctions.fCullFace ||
110         !fFunctions.fDeleteBuffers ||
111         !fFunctions.fDeleteProgram ||
112         !fFunctions.fDeleteShader ||
113         !fFunctions.fDeleteTextures ||
114         !fFunctions.fDepthMask ||
115         !fFunctions.fDisable ||
116         !fFunctions.fDisableVertexAttribArray ||
117         !fFunctions.fDrawArrays ||
118         !fFunctions.fDrawElements ||
119         !fFunctions.fEnable ||
120         !fFunctions.fEnableVertexAttribArray ||
121         !fFunctions.fFinish ||
122         !fFunctions.fFlush ||
123         !fFunctions.fFrontFace ||
124         !fFunctions.fGenBuffers ||
125         !fFunctions.fGenTextures ||
126         !fFunctions.fGetBufferParameteriv ||
127         !fFunctions.fGetError ||
128         !fFunctions.fGetIntegerv ||
129         !fFunctions.fGetProgramInfoLog ||
130         !fFunctions.fGetProgramiv ||
131         !fFunctions.fGetShaderInfoLog ||
132         !fFunctions.fGetShaderiv ||
133         !fFunctions.fGetString ||
134         !fFunctions.fGetUniformLocation ||
135         !fFunctions.fIsTexture ||
136         !fFunctions.fLineWidth ||
137         !fFunctions.fLinkProgram ||
138         !fFunctions.fPixelStorei ||
139         !fFunctions.fReadPixels ||
140         !fFunctions.fScissor ||
141         !fFunctions.fShaderSource ||
142         !fFunctions.fStencilFunc ||
143         !fFunctions.fStencilFuncSeparate ||
144         !fFunctions.fStencilMask ||
145         !fFunctions.fStencilMaskSeparate ||
146         !fFunctions.fStencilOp ||
147         !fFunctions.fStencilOpSeparate ||
148         !fFunctions.fTexImage2D ||
149         !fFunctions.fTexParameterf ||
150         !fFunctions.fTexParameterfv ||
151         !fFunctions.fTexParameteri ||
152         !fFunctions.fTexParameteriv ||
153         !fFunctions.fTexSubImage2D ||
154         !fFunctions.fUniform1f ||
155         !fFunctions.fUniform1fv ||
156         !fFunctions.fUniform1i ||
157         !fFunctions.fUniform1iv ||
158         !fFunctions.fUniform2f ||
159         !fFunctions.fUniform2fv ||
160         !fFunctions.fUniform2i ||
161         !fFunctions.fUniform2iv ||
162         !fFunctions.fUniform3f ||
163         !fFunctions.fUniform3fv ||
164         !fFunctions.fUniform3i ||
165         !fFunctions.fUniform3iv ||
166         !fFunctions.fUniform4f ||
167         !fFunctions.fUniform4fv ||
168         !fFunctions.fUniform4i ||
169         !fFunctions.fUniform4iv ||
170         !fFunctions.fUniformMatrix2fv ||
171         !fFunctions.fUniformMatrix3fv ||
172         !fFunctions.fUniformMatrix4fv ||
173         !fFunctions.fUseProgram ||
174         !fFunctions.fVertexAttrib1f ||
175         !fFunctions.fVertexAttrib2fv ||
176         !fFunctions.fVertexAttrib3fv ||
177         !fFunctions.fVertexAttrib4fv ||
178         !fFunctions.fVertexAttribPointer ||
179         !fFunctions.fViewport) {
180         RETURN_FALSE_INTERFACE;
181     }
182 
183     if (GR_IS_GR_GL(fStandard)) {
184         if (!fFunctions.fDrawBuffer ||
185             !fFunctions.fPolygonMode) {
186             RETURN_FALSE_INTERFACE;
187         }
188     }
189 
190     if ((GR_IS_GR_GL(fStandard) && (
191           (glVer >= GR_GL_VER(3,0)))) ||
192        (GR_IS_GR_GL_ES(fStandard) && (
193           (glVer >= GR_GL_VER(3,0)))) ||
194        (GR_IS_GR_WEBGL(fStandard) && (
195           (glVer >= GR_GL_VER(2,0))))) {
196         if (!fFunctions.fGetStringi) {
197             RETURN_FALSE_INTERFACE;
198         }
199     }
200 
201     if ((GR_IS_GR_GL(fStandard) && (
202           (glVer >= GR_GL_VER(4,2)))) ||
203        (GR_IS_GR_GL_ES(fStandard) && (
204           (glVer >= GR_GL_VER(3,1))))) {
205         // all functions were marked optional or test_only
206     }
207 
208     if ((GR_IS_GR_GL(fStandard) && (
209           (glVer >= GR_GL_VER(3,0)) ||
210           fExtensions.has("GL_ARB_vertex_array_object") ||
211           fExtensions.has("GL_APPLE_vertex_array_object"))) ||
212        (GR_IS_GR_GL_ES(fStandard) && (
213           (glVer >= GR_GL_VER(3,0)) ||
214           fExtensions.has("GL_OES_vertex_array_object"))) ||
215        (GR_IS_GR_WEBGL(fStandard) && (
216           (glVer >= GR_GL_VER(2,0)) ||
217           fExtensions.has("GL_OES_vertex_array_object") ||
218           fExtensions.has("OES_vertex_array_object")))) {
219         if (!fFunctions.fBindVertexArray ||
220             !fFunctions.fDeleteVertexArrays ||
221             !fFunctions.fGenVertexArrays) {
222             RETURN_FALSE_INTERFACE;
223         }
224     }
225 
226     if ((GR_IS_GR_GL(fStandard) && (
227           (glVer >= GR_GL_VER(4,0)) ||
228           fExtensions.has("GL_ARB_tessellation_shader"))) ||
229        (GR_IS_GR_GL_ES(fStandard) && (
230           (glVer >= GR_GL_VER(3,2)) ||
231           fExtensions.has("GL_OES_tessellation_shader")))) {
232         if (!fFunctions.fPatchParameteri) {
233             RETURN_FALSE_INTERFACE;
234         }
235     }
236 
237     if ((GR_IS_GR_GL(fStandard) && (
238           (glVer >= GR_GL_VER(3,0)))) ||
239        (GR_IS_GR_GL_ES(fStandard) && (
240           (glVer >= GR_GL_VER(3,0) && fExtensions.has("GL_EXT_blend_func_extended"))))) {
241         if (!fFunctions.fBindFragDataLocation) {
242             RETURN_FALSE_INTERFACE;
243         }
244     }
245 
246     if ((GR_IS_GR_GL(fStandard) && (
247           (glVer >= GR_GL_VER(3,3)) ||
248           fExtensions.has("GL_ARB_blend_func_extended"))) ||
249        (GR_IS_GR_GL_ES(fStandard) && (
250           (glVer >= GR_GL_VER(3,0) && fExtensions.has("GL_EXT_blend_func_extended"))))) {
251         if (!fFunctions.fBindFragDataLocationIndexed) {
252             RETURN_FALSE_INTERFACE;
253         }
254     }
255 
256     if ((GR_IS_GR_GL(fStandard) && (
257           fExtensions.has("GL_KHR_blend_equation_advanced") ||
258           fExtensions.has("GL_NV_blend_equation_advanced"))) ||
259        (GR_IS_GR_GL_ES(fStandard) && (
260           fExtensions.has("GL_KHR_blend_equation_advanced") ||
261           fExtensions.has("GL_NV_blend_equation_advanced")))) {
262         if (!fFunctions.fBlendBarrier) {
263             RETURN_FALSE_INTERFACE;
264         }
265     }
266 
267     if ((GR_IS_GR_GL(fStandard) && (
268           (glVer >= GR_GL_VER(4,4)) ||
269           fExtensions.has("GL_ARB_clear_texture"))) ||
270        (GR_IS_GR_GL_ES(fStandard) && (
271           fExtensions.has("GL_EXT_clear_texture")))) {
272         // all functions were marked optional or test_only
273     }
274 
275     if ((GR_IS_GR_GL(fStandard) && (
276           (glVer >= GR_GL_VER(3,1)) ||
277           fExtensions.has("GL_ARB_draw_instanced") ||
278           fExtensions.has("GL_EXT_draw_instanced"))) ||
279        (GR_IS_GR_GL_ES(fStandard) && (
280           (glVer >= GR_GL_VER(3,0)) ||
281           fExtensions.has("GL_EXT_draw_instanced"))) ||
282        (GR_IS_GR_WEBGL(fStandard) && (
283           (glVer >= GR_GL_VER(2,0))))) {
284         if (!fFunctions.fDrawArraysInstanced ||
285             !fFunctions.fDrawElementsInstanced) {
286             RETURN_FALSE_INTERFACE;
287         }
288     }
289 
290     if ((GR_IS_GR_GL(fStandard) && (
291           (glVer >= GR_GL_VER(4,2)) ||
292           fExtensions.has("GL_ARB_base_instance"))) ||
293        (GR_IS_GR_GL_ES(fStandard) && (
294           fExtensions.has("GL_EXT_base_instance") ||
295           fExtensions.has("GL_ANGLE_base_vertex_base_instance"))) ||
296        (GR_IS_GR_WEBGL(fStandard) && (
297           fExtensions.has("GL_WEBGL_draw_instanced_base_vertex_base_instance")))) {
298         if (!fFunctions.fDrawArraysInstancedBaseInstance ||
299             !fFunctions.fDrawElementsInstancedBaseVertexBaseInstance) {
300             RETURN_FALSE_INTERFACE;
301         }
302     }
303 
304     if (GR_IS_GR_GL(fStandard) ||
305        (GR_IS_GR_GL_ES(fStandard) && (
306           (glVer >= GR_GL_VER(3,0)))) ||
307        (GR_IS_GR_WEBGL(fStandard) && (
308           (glVer >= GR_GL_VER(2,0))))) {
309         if (!fFunctions.fDrawBuffers ||
310             !fFunctions.fReadBuffer) {
311             RETURN_FALSE_INTERFACE;
312         }
313     }
314 
315     if ((GR_IS_GR_GL(fStandard) && (
316           (glVer >= GR_GL_VER(4,0)) ||
317           fExtensions.has("GL_ARB_draw_indirect"))) ||
318        (GR_IS_GR_GL_ES(fStandard) && (
319           (glVer >= GR_GL_VER(3,1))))) {
320         if (!fFunctions.fDrawArraysIndirect ||
321             !fFunctions.fDrawElementsIndirect) {
322             RETURN_FALSE_INTERFACE;
323         }
324     }
325 
326     if ((GR_IS_GR_GL_ES(fStandard) && (
327           fExtensions.has("GL_ANGLE_base_vertex_base_instance"))) ||
328        (GR_IS_GR_WEBGL(fStandard) && (
329           fExtensions.has("GL_WEBGL_multi_draw_instanced_base_vertex_base_instance")))) {
330         if (!fFunctions.fMultiDrawArraysInstancedBaseInstance ||
331             !fFunctions.fMultiDrawElementsInstancedBaseVertexBaseInstance) {
332             RETURN_FALSE_INTERFACE;
333         }
334     }
335 
336     if (GR_IS_GR_GL(fStandard) ||
337        (GR_IS_GR_GL_ES(fStandard) && (
338           (glVer >= GR_GL_VER(3,0)))) ||
339        (GR_IS_GR_WEBGL(fStandard) && (
340           (glVer >= GR_GL_VER(2,0))))) {
341         if (!fFunctions.fDrawRangeElements) {
342             RETURN_FALSE_INTERFACE;
343         }
344     }
345 
346     if ((GR_IS_GR_GL(fStandard) && (
347           (glVer >= GR_GL_VER(3,2)) ||
348           fExtensions.has("GL_ARB_texture_multisample"))) ||
349        (GR_IS_GR_GL_ES(fStandard) && (
350           (glVer >= GR_GL_VER(3,1))))) {
351         if (!fFunctions.fGetMultisamplefv) {
352             RETURN_FALSE_INTERFACE;
353         }
354     }
355 
356     if (GR_IS_GR_GL(fStandard) ||
357        (GR_IS_GR_GL_ES(fStandard) && (
358           (glVer >= GR_GL_VER(3,1))))) {
359         if (!fFunctions.fGetTexLevelParameteriv) {
360             RETURN_FALSE_INTERFACE;
361         }
362     }
363 
364     if ((GR_IS_GR_GL(fStandard) && (
365           (glVer >= GR_GL_VER(4,3)) ||
366           fExtensions.has("GL_ARB_multi_draw_indirect"))) ||
367        (GR_IS_GR_GL_ES(fStandard) && (
368           fExtensions.has("GL_EXT_multi_draw_indirect")))) {
369         if (!fFunctions.fMultiDrawArraysIndirect ||
370             !fFunctions.fMultiDrawElementsIndirect) {
371             RETURN_FALSE_INTERFACE;
372         }
373     }
374 
375     if ((GR_IS_GR_GL(fStandard) && (
376           (glVer >= GR_GL_VER(3,1)))) ||
377        (GR_IS_GR_GL_ES(fStandard) && (
378           (glVer >= GR_GL_VER(3,2)) ||
379           fExtensions.has("GL_OES_texture_buffer") ||
380           fExtensions.has("GL_EXT_texture_buffer")))) {
381         if (!fFunctions.fTexBuffer) {
382             RETURN_FALSE_INTERFACE;
383         }
384     }
385 
386     if ((GR_IS_GR_GL(fStandard) && (
387           (glVer >= GR_GL_VER(4,3)))) ||
388        (GR_IS_GR_GL_ES(fStandard) && (
389           (glVer >= GR_GL_VER(3,2)) ||
390           fExtensions.has("GL_OES_texture_buffer") ||
391           fExtensions.has("GL_EXT_texture_buffer")))) {
392         if (!fFunctions.fTexBufferRange) {
393             RETURN_FALSE_INTERFACE;
394         }
395     }
396 
397     if ((GR_IS_GR_GL(fStandard) && (
398           (glVer >= GR_GL_VER(4,2)) ||
399           fExtensions.has("GL_ARB_texture_storage") ||
400           fExtensions.has("GL_EXT_texture_storage"))) ||
401        (GR_IS_GR_GL_ES(fStandard) && (
402           (glVer >= GR_GL_VER(3,0)) ||
403           fExtensions.has("GL_EXT_texture_storage"))) ||
404        (GR_IS_GR_WEBGL(fStandard) && (
405           (glVer >= GR_GL_VER(2,0))))) {
406         if (!fFunctions.fTexStorage2D) {
407             RETURN_FALSE_INTERFACE;
408         }
409     }
410 
411     if ((GR_IS_GR_GL(fStandard) && (
412           (glVer >= GR_GL_VER(4,5)) ||
413           fExtensions.has("GL_ARB_texture_barrier") ||
414           fExtensions.has("GL_NV_texture_barrier"))) ||
415        (GR_IS_GR_GL_ES(fStandard) && (
416           fExtensions.has("GL_NV_texture_barrier")))) {
417         if (!fFunctions.fTextureBarrier) {
418             RETURN_FALSE_INTERFACE;
419         }
420     }
421 
422     if ((GR_IS_GR_GL_ES(fStandard) && (
423           fExtensions.has("GL_EXT_discard_framebuffer")))) {
424         if (!fFunctions.fDiscardFramebuffer) {
425             RETURN_FALSE_INTERFACE;
426         }
427     }
428 
429     if ((GR_IS_GR_GL_ES(fStandard) && (
430           fExtensions.has("GL_QCOM_tiled_rendering")))) {
431         // all functions were marked optional or test_only
432     }
433 
434     if ((GR_IS_GR_GL(fStandard) && (
435           (glVer >= GR_GL_VER(3,2)) ||
436           fExtensions.has("GL_ARB_instanced_arrays"))) ||
437        (GR_IS_GR_GL_ES(fStandard) && (
438           (glVer >= GR_GL_VER(3,0)) ||
439           fExtensions.has("GL_EXT_instanced_arrays"))) ||
440        (GR_IS_GR_WEBGL(fStandard) && (
441           (glVer >= GR_GL_VER(2,0))))) {
442         if (!fFunctions.fVertexAttribDivisor) {
443             RETURN_FALSE_INTERFACE;
444         }
445     }
446 
447     if ((GR_IS_GR_GL(fStandard) && (
448           (glVer >= GR_GL_VER(3,0)))) ||
449        (GR_IS_GR_GL_ES(fStandard) && (
450           (glVer >= GR_GL_VER(3,0)))) ||
451        (GR_IS_GR_WEBGL(fStandard) && (
452           (glVer >= GR_GL_VER(2,0))))) {
453         if (!fFunctions.fVertexAttribIPointer) {
454             RETURN_FALSE_INTERFACE;
455         }
456     }
457 
458     if ((GR_IS_GR_GL(fStandard) && (
459           (glVer >= GR_GL_VER(3,0)) ||
460           fExtensions.has("GL_ARB_framebuffer_object") ||
461           fExtensions.has("GL_EXT_framebuffer_object"))) ||
462        GR_IS_GR_GL_ES(fStandard) ||
463        GR_IS_GR_WEBGL(fStandard)) {
464         if (!fFunctions.fBindFramebuffer ||
465             !fFunctions.fBindRenderbuffer ||
466             !fFunctions.fCheckFramebufferStatus ||
467             !fFunctions.fDeleteFramebuffers ||
468             !fFunctions.fDeleteRenderbuffers ||
469             !fFunctions.fFramebufferRenderbuffer ||
470             !fFunctions.fFramebufferTexture2D ||
471             !fFunctions.fGenFramebuffers ||
472             !fFunctions.fGenRenderbuffers ||
473             !fFunctions.fGenerateMipmap ||
474             !fFunctions.fGetFramebufferAttachmentParameteriv ||
475             !fFunctions.fGetRenderbufferParameteriv ||
476             !fFunctions.fRenderbufferStorage) {
477             RETURN_FALSE_INTERFACE;
478         }
479     }
480 
481     if ((GR_IS_GR_GL(fStandard) && (
482           (glVer >= GR_GL_VER(3,0)) ||
483           fExtensions.has("GL_ARB_framebuffer_object") ||
484           fExtensions.has("GL_EXT_framebuffer_blit"))) ||
485        (GR_IS_GR_GL_ES(fStandard) && (
486           (glVer >= GR_GL_VER(3,0)) ||
487           fExtensions.has("GL_CHROMIUM_framebuffer_multisample") ||
488           fExtensions.has("GL_ANGLE_framebuffer_blit"))) ||
489        (GR_IS_GR_WEBGL(fStandard) && (
490           (glVer >= GR_GL_VER(2,0))))) {
491         if (!fFunctions.fBlitFramebuffer) {
492             RETURN_FALSE_INTERFACE;
493         }
494     }
495 
496     if ((GR_IS_GR_GL(fStandard) && (
497           (glVer >= GR_GL_VER(3,0)) ||
498           fExtensions.has("GL_ARB_framebuffer_object") ||
499           fExtensions.has("GL_EXT_framebuffer_multisample"))) ||
500        (GR_IS_GR_GL_ES(fStandard) && (
501           (glVer >= GR_GL_VER(3,0)) ||
502           fExtensions.has("GL_CHROMIUM_framebuffer_multisample") ||
503           fExtensions.has("GL_ANGLE_framebuffer_multisample"))) ||
504        (GR_IS_GR_WEBGL(fStandard) && (
505           (glVer >= GR_GL_VER(2,0))))) {
506         if (!fFunctions.fRenderbufferStorageMultisample) {
507             RETURN_FALSE_INTERFACE;
508         }
509     }
510 
511     if ((GR_IS_GR_GL_ES(fStandard) && (
512           fExtensions.has("GL_CHROMIUM_map_sub")))) {
513         if (!fFunctions.fMapBufferSubData ||
514             !fFunctions.fMapTexSubImage2D ||
515             !fFunctions.fUnmapBufferSubData ||
516             !fFunctions.fUnmapTexSubImage2D) {
517             RETURN_FALSE_INTERFACE;
518         }
519     }
520 
521     if ((GR_IS_GR_GL_ES(fStandard) && (
522           fExtensions.has("GL_EXT_multisampled_render_to_texture") ||
523           fExtensions.has("GL_IMG_multisampled_render_to_texture")))) {
524         if (!fFunctions.fFramebufferTexture2DMultisample) {
525             RETURN_FALSE_INTERFACE;
526         }
527     }
528 
529     if ((GR_IS_GR_GL_ES(fStandard) && (
530           fExtensions.has("GL_EXT_multisampled_render_to_texture")))) {
531         if (!fFunctions.fRenderbufferStorageMultisampleES2EXT) {
532             RETURN_FALSE_INTERFACE;
533         }
534     }
535 
536     if ((GR_IS_GR_GL_ES(fStandard) && (
537           fExtensions.has("GL_IMG_multisampled_render_to_texture")))) {
538         if (!fFunctions.fRenderbufferStorageMultisampleES2EXT) {
539             RETURN_FALSE_INTERFACE;
540         }
541     }
542 
543     if ((GR_IS_GR_GL_ES(fStandard) && (
544           fExtensions.has("GL_APPLE_framebuffer_multisample")))) {
545         if (!fFunctions.fResolveMultisampleFramebuffer ||
546             !fFunctions.fRenderbufferStorageMultisampleES2APPLE) {
547             RETURN_FALSE_INTERFACE;
548         }
549     }
550 
551     if (GR_IS_GR_GL(fStandard) ||
552        (GR_IS_GR_GL_ES(fStandard) && (
553           fExtensions.has("GL_OES_mapbuffer")))) {
554         if (!fFunctions.fMapBuffer) {
555             RETURN_FALSE_INTERFACE;
556         }
557     }
558 
559     if (GR_IS_GR_GL(fStandard) ||
560        (GR_IS_GR_GL_ES(fStandard) && (
561           (glVer >= GR_GL_VER(3,0)) ||
562           fExtensions.has("GL_OES_mapbuffer")))) {
563         if (!fFunctions.fUnmapBuffer) {
564             RETURN_FALSE_INTERFACE;
565         }
566     }
567 
568     if ((GR_IS_GR_GL(fStandard) && (
569           (glVer >= GR_GL_VER(3,0)) ||
570           fExtensions.has("GL_ARB_map_buffer_range"))) ||
571        (GR_IS_GR_GL_ES(fStandard) && (
572           (glVer >= GR_GL_VER(3,0)) ||
573           fExtensions.has("GL_EXT_map_buffer_range")))) {
574         if (!fFunctions.fFlushMappedBufferRange ||
575             !fFunctions.fMapBufferRange) {
576             RETURN_FALSE_INTERFACE;
577         }
578     }
579 
580     if ((GR_IS_GR_GL(fStandard) && (
581           fExtensions.has("GL_EXT_debug_marker"))) ||
582        (GR_IS_GR_GL_ES(fStandard) && (
583           fExtensions.has("GL_EXT_debug_marker")))) {
584         if (!fFunctions.fInsertEventMarker ||
585             !fFunctions.fPopGroupMarker ||
586             !fFunctions.fPushGroupMarker) {
587             RETURN_FALSE_INTERFACE;
588         }
589     }
590 
591     if ((GR_IS_GR_GL(fStandard) && (
592           fExtensions.has("GL_NV_framebuffer_mixed_samples"))) ||
593        (GR_IS_GR_GL_ES(fStandard) && (
594           fExtensions.has("GL_CHROMIUM_framebuffer_mixed_samples") ||
595           fExtensions.has("GL_NV_framebuffer_mixed_samples")))) {
596         if (!fFunctions.fCoverageModulation) {
597             RETURN_FALSE_INTERFACE;
598         }
599     }
600 
601     if ((GR_IS_GR_GL(fStandard) && (
602           (glVer >= GR_GL_VER(4,3)) ||
603           fExtensions.has("GL_KHR_debug"))) ||
604        (GR_IS_GR_GL_ES(fStandard) && (
605           fExtensions.has("GL_KHR_debug")))) {
606         if (!fFunctions.fDebugMessageCallback ||
607             !fFunctions.fDebugMessageControl ||
608             !fFunctions.fDebugMessageInsert ||
609             !fFunctions.fGetDebugMessageLog ||
610             !fFunctions.fObjectLabel ||
611             !fFunctions.fPopDebugGroup ||
612             !fFunctions.fPushDebugGroup) {
613             RETURN_FALSE_INTERFACE;
614         }
615     }
616 
617     if ((GR_IS_GR_GL_ES(fStandard) && (
618           fExtensions.has("GL_CHROMIUM_bind_uniform_location")))) {
619         if (!fFunctions.fBindUniformLocation) {
620             RETURN_FALSE_INTERFACE;
621         }
622     }
623 
624     if ((GR_IS_GR_GL(fStandard) && (
625           fExtensions.has("GL_EXT_window_rectangles"))) ||
626        (GR_IS_GR_GL_ES(fStandard) && (
627           fExtensions.has("GL_EXT_window_rectangles")))) {
628         if (!fFunctions.fWindowRectangles) {
629             RETURN_FALSE_INTERFACE;
630         }
631     }
632 
633     if ((GR_IS_GR_GL(fStandard) && (
634           (glVer >= GR_GL_VER(3,2)) ||
635           fExtensions.has("GL_ARB_sync"))) ||
636        (GR_IS_GR_GL_ES(fStandard) && (
637           (glVer >= GR_GL_VER(3,0)) ||
638           fExtensions.has("GL_APPLE_sync"))) ||
639        (GR_IS_GR_WEBGL(fStandard) && (
640           (glVer >= GR_GL_VER(2,0))))) {
641         if (!fFunctions.fClientWaitSync ||
642             !fFunctions.fDeleteSync ||
643             !fFunctions.fFenceSync ||
644             !fFunctions.fIsSync ||
645             !fFunctions.fWaitSync) {
646             RETURN_FALSE_INTERFACE;
647         }
648     }
649 
650     if ((GR_IS_GR_GL(fStandard) && (
651           (glVer >= GR_GL_VER(4,2)) ||
652           fExtensions.has("GL_ARB_internalformat_query"))) ||
653        (GR_IS_GR_GL_ES(fStandard) && (
654           (glVer >= GR_GL_VER(3,0))))) {
655         if (!fFunctions.fGetInternalformativ) {
656             RETURN_FALSE_INTERFACE;
657         }
658     }
659 
660     if ((GR_IS_GR_GL(fStandard) && (
661           (glVer >= GR_GL_VER(4,1)))) ||
662        (GR_IS_GR_GL_ES(fStandard) && (
663           (glVer >= GR_GL_VER(3,0)) ||
664           fExtensions.has("GL_OES_get_program_binary")))) {
665         if (!fFunctions.fGetProgramBinary ||
666             !fFunctions.fProgramBinary) {
667             RETURN_FALSE_INTERFACE;
668         }
669     }
670 
671     if ((GR_IS_GR_GL(fStandard) && (
672           (glVer >= GR_GL_VER(4,1)))) ||
673        (GR_IS_GR_GL_ES(fStandard) && (
674           (glVer >= GR_GL_VER(3,0))))) {
675         if (!fFunctions.fProgramParameteri) {
676             RETURN_FALSE_INTERFACE;
677         }
678     }
679 
680     if ((GR_IS_GR_GL(fStandard) && (
681           (glVer >= GR_GL_VER(3,2)) ||
682           fExtensions.has("GL_ARB_sampler_objects"))) ||
683        (GR_IS_GR_GL_ES(fStandard) && (
684           (glVer >= GR_GL_VER(3,0)))) ||
685        (GR_IS_GR_WEBGL(fStandard) && (
686           (glVer >= GR_GL_VER(2,0))))) {
687         if (!fFunctions.fBindSampler ||
688             !fFunctions.fDeleteSamplers ||
689             !fFunctions.fGenSamplers ||
690             !fFunctions.fSamplerParameteri ||
691             !fFunctions.fSamplerParameteriv) {
692             RETURN_FALSE_INTERFACE;
693         }
694     }
695 
696     if (GR_IS_GR_GL(fStandard)) {
697         if (!fFunctions.fGetQueryObjectiv) {
698             RETURN_FALSE_INTERFACE;
699         }
700     }
701 
702     if (GR_IS_GR_GL(fStandard) ||
703        (GR_IS_GR_GL_ES(fStandard) && (
704           (glVer >= GR_GL_VER(3,0)) ||
705           fExtensions.has("GL_EXT_occlusion_query_boolean")))) {
706 #if GR_TEST_UTILS
707         if (!fFunctions.fBeginQuery ||
708             !fFunctions.fDeleteQueries ||
709             !fFunctions.fEndQuery ||
710             !fFunctions.fGenQueries ||
711             !fFunctions.fGetQueryObjectuiv ||
712             !fFunctions.fGetQueryiv) {
713             RETURN_FALSE_INTERFACE;
714         }
715 #endif
716         // all functions were marked optional or test_only
717     }
718 
719     if ((GR_IS_GR_GL(fStandard) && (
720           (glVer >= GR_GL_VER(3,3)) ||
721           fExtensions.has("GL_ARB_timer_query") ||
722           fExtensions.has("GL_EXT_timer_query")))) {
723         if (!fFunctions.fGetQueryObjecti64v ||
724             !fFunctions.fGetQueryObjectui64v) {
725             RETURN_FALSE_INTERFACE;
726         }
727     }
728 
729     if ((GR_IS_GR_GL(fStandard) && (
730           (glVer >= GR_GL_VER(3,3)) ||
731           fExtensions.has("GL_ARB_timer_query")))) {
732         if (!fFunctions.fQueryCounter) {
733             RETURN_FALSE_INTERFACE;
734         }
735     }
736 
737     if ((GR_IS_GR_GL(fStandard) && (
738           (glVer >= GR_GL_VER(4,3)) ||
739           fExtensions.has("GL_ARB_invalidate_subdata")))) {
740         if (!fFunctions.fInvalidateBufferData ||
741             !fFunctions.fInvalidateBufferSubData ||
742             !fFunctions.fInvalidateTexImage ||
743             !fFunctions.fInvalidateTexSubImage) {
744             RETURN_FALSE_INTERFACE;
745         }
746     }
747 
748     if ((GR_IS_GR_GL(fStandard) && (
749           (glVer >= GR_GL_VER(4,3)) ||
750           fExtensions.has("GL_ARB_invalidate_subdata"))) ||
751        (GR_IS_GR_GL_ES(fStandard) && (
752           (glVer >= GR_GL_VER(3,0)))) ||
753        (GR_IS_GR_WEBGL(fStandard) && (
754           (glVer >= GR_GL_VER(2,0))))) {
755         if (!fFunctions.fInvalidateFramebuffer ||
756             !fFunctions.fInvalidateSubFramebuffer) {
757             RETURN_FALSE_INTERFACE;
758         }
759     }
760 
761     if ((GR_IS_GR_GL(fStandard) && (
762           (glVer >= GR_GL_VER(4,3)) ||
763           fExtensions.has("GL_ARB_ES2_compatibility"))) ||
764        GR_IS_GR_GL_ES(fStandard) ||
765        GR_IS_GR_WEBGL(fStandard)) {
766         if (!fFunctions.fGetShaderPrecisionFormat) {
767             RETURN_FALSE_INTERFACE;
768         }
769     }
770 
771     if ((GR_IS_GR_GL(fStandard) && (
772           fExtensions.has("GL_NV_fence"))) ||
773        (GR_IS_GR_GL_ES(fStandard) && (
774           fExtensions.has("GL_NV_fence")))) {
775         if (!fFunctions.fDeleteFences ||
776             !fFunctions.fFinishFence ||
777             !fFunctions.fGenFences ||
778             !fFunctions.fSetFence ||
779             !fFunctions.fTestFence) {
780             RETURN_FALSE_INTERFACE;
781         }
782     }
783 
784 
785     // End autogenerated content
786     return true;
787 }
788 
789 #if GR_TEST_UTILS
790 
abandon() const791 void GrGLInterface::abandon() const {
792     const_cast<GrGLInterface*>(this)->fFunctions = GrGLInterface::Functions();
793 }
794 
795 #endif // GR_TEST_UTILS
796