GrGLInterface.cpp revision 32b9a3b02ed6b8bab4a25b6cb8853f5bea4b87ba
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/*
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2011 Google Inc.
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com *
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
659a190bcab5d4b2bf03f8f10cb6a581d19fed403twiz@google.com */
759a190bcab5d4b2bf03f8f10cb6a581d19fed403twiz@google.com
859a190bcab5d4b2bf03f8f10cb6a581d19fed403twiz@google.com
96bf38b59c9de1cd35cd091cf8766117f4e1f66a0tomhudson@google.com#include "gl/GrGLInterface.h"
101744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com#include "gl/GrGLExtensions.h"
111744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com#include "gl/GrGLUtil.h"
1259a190bcab5d4b2bf03f8f10cb6a581d19fed403twiz@google.com
1359a190bcab5d4b2bf03f8f10cb6a581d19fed403twiz@google.com#include <stdio.h>
1459a190bcab5d4b2bf03f8f10cb6a581d19fed403twiz@google.com
1556bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com#if GR_GL_PER_GL_FUNC_CALLBACK
1656bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.comnamespace {
1756bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.comvoid GrGLDefaultInterfaceCallback(const GrGLInterface*) {}
1856bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com}
1956bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com#endif
2056bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com
21a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.orgconst GrGLInterface* GrGLInterfaceAddTestDebugMarker(const GrGLInterface* interface,
22a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org                                                     GrGLInsertEventMarkerProc insertEventMarkerFn,
23a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org                                                     GrGLPushGroupMarkerProc pushGroupMarkerFn,
24a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org                                                     GrGLPopGroupMarkerProc popGroupMarkerFn) {
25a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    GrGLInterface* newInterface = GrGLInterface::NewClone(interface);
26a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org
27a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    if (!newInterface->fExtensions.has("GL_EXT_debug_marker")) {
28a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org        newInterface->fExtensions.add("GL_EXT_debug_marker");
29a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    }
30a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org
31f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fInsertEventMarker = insertEventMarkerFn;
32f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPushGroupMarker = pushGroupMarkerFn;
33f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPopGroupMarker = popGroupMarkerFn;
34a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org
35a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    return newInterface;
36a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org}
37a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org
38d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.orgconst GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface* interface) {
39d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    GrGLInterface* newInterface = GrGLInterface::NewClone(interface);
40d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
41d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    newInterface->fExtensions.remove("GL_NV_path_rendering");
42f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathCommands = NULL;
43f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathCoords = NULL;
44f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathParameteri = NULL;
45f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathParameterf = NULL;
46f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGenPaths = NULL;
47f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fDeletePaths = NULL;
48f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathStencilFunc = NULL;
49f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilFillPath = NULL;
50f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilStrokePath = NULL;
51f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilFillPathInstanced = NULL;
52f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilStrokePathInstanced = NULL;
53f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathTexGen = NULL;
54f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverFillPath = NULL;
55f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverStrokePath = NULL;
56f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverFillPathInstanced = NULL;
57f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverStrokePathInstanced = NULL;
5832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    newInterface->fFunctions.fProgramPathFragmentInputGen = NULL;
59d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    return newInterface;
60d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org}
61d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
62f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.orgGrGLInterface::GrGLInterface() {
639e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    fStandard = kNone_GrGLStandard;
640b77d6892b067ad402c9678b0226bff70599fbe2bsalomon@google.com
6556bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com#if GR_GL_PER_GL_FUNC_CALLBACK
6656bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com    fCallback = GrGLDefaultInterfaceCallback;
6756bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com    fCallbackData = 0;
6856bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com#endif
690b77d6892b067ad402c9678b0226bff70599fbe2bsalomon@google.com}
700b77d6892b067ad402c9678b0226bff70599fbe2bsalomon@google.com
71d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.orgGrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
72d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    SkASSERT(NULL != interface);
73d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
74d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    GrGLInterface* clone = SkNEW(GrGLInterface);
75d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fStandard = interface->fStandard;
76d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fExtensions = interface->fExtensions;
77d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fFunctions = interface->fFunctions;
78d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org#if GR_GL_PER_GL_FUNC_CALLBACK
79d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fCallback = interface->fCallback;
80d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fCallbackData = interface->fCallbackData;
81d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org#endif
82d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    return clone;
83d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org}
84d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
85e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#ifdef SK_DEBUG
86e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    static int kIsDebug = 1;
87e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#else
88e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    static int kIsDebug = 0;
89e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#endif
90e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org
91e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#define RETURN_FALSE_INTERFACE                                                                   \
92e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \
93e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    return false;
94adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org
959e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.orgbool GrGLInterface::validate() const {
96bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
979e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kNone_GrGLStandard == fStandard) {
98adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
99bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
10012eea2b10d6caaafe0a207d10b1e9322510983a2skia.committer@gmail.com
10190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    if (!fExtensions.isInitialized()) {
102adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
1031744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com    }
104bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
105bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // functions that are always required
106c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    if (NULL == fFunctions.fActiveTexture ||
107c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fAttachShader ||
108c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindAttribLocation ||
109c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindBuffer ||
110c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindTexture ||
111c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBlendFunc ||
112c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBlendColor ||      // -> GL >= 1.4, ES >= 2.0 or extension
113c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBufferData ||
114c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBufferSubData ||
115c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fClear ||
116c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fClearColor ||
117c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fClearStencil ||
118c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fColorMask ||
119c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCompileShader ||
120c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCopyTexSubImage2D ||
121c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCreateProgram ||
122c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCreateShader ||
123c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCullFace ||
124c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteBuffers ||
125c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteProgram ||
126c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteShader ||
127c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteTextures ||
128c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDepthMask ||
129c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDisable ||
130c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDisableVertexAttribArray ||
131c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDrawArrays ||
132c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDrawElements ||
133c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fEnable ||
134c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fEnableVertexAttribArray ||
135c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFrontFace ||
136c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenBuffers ||
137c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenTextures ||
138c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetBufferParameteriv ||
139c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenerateMipmap ||
140c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetError ||
141c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetIntegerv ||
142c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetProgramInfoLog ||
143c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetProgramiv ||
144c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetShaderInfoLog ||
145c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetShaderiv ||
146c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetString ||
147c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetUniformLocation ||
148c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fLinkProgram ||
149c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fLineWidth ||
150c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fPixelStorei ||
151c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fReadPixels ||
152c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fScissor ||
153c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fShaderSource ||
154c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fStencilFunc ||
155c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fStencilMask ||
156c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fStencilOp ||
157c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexImage2D ||
158c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexParameteri ||
159c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexParameteriv ||
160c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexSubImage2D ||
161c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1f ||
162c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1i ||
163c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1fv ||
164c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1iv ||
165c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2f ||
166c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2i ||
167c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2fv ||
168c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2iv ||
169c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3f ||
170c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3i ||
171c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3fv ||
172c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3iv ||
173c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4f ||
174c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4i ||
175c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4fv ||
176c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4iv ||
177c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniformMatrix2fv ||
178c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniformMatrix3fv ||
179c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniformMatrix4fv ||
180c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUseProgram ||
181c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fVertexAttrib4fv ||
182c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fVertexAttribPointer ||
183c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fViewport ||
184c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindFramebuffer ||
185c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindRenderbuffer ||
186c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCheckFramebufferStatus ||
187c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteFramebuffers ||
188c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteRenderbuffers ||
189c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFinish ||
190c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFlush ||
191c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFramebufferRenderbuffer ||
192c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFramebufferTexture2D ||
193c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetFramebufferAttachmentParameteriv ||
194c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetRenderbufferParameteriv ||
195c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenFramebuffers ||
196c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenRenderbuffers ||
197c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fRenderbufferStorage) {
198adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
199bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
200bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
201c82b8899d97c2a26f5991bc771ad3beb8257edaebsalomon@google.com    GrGLVersion glVer = GrGLGetVersion(this);
202f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org    if (GR_GL_INVALID_VER == glVer) {
203f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org        RETURN_FALSE_INTERFACE
204f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org    }
205bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
206bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // Now check that baseline ES/Desktop fns not covered above are present
20790313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    // and that we have fn pointers for any advertised fExtensions that we will
208bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // try to use.
209bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
210bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // these functions are part of ES2, we assume they are available
211bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // On the desktop we assume they are available if the extension
212bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // is present or GL version is high enough.
2139e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGLES_GrGLStandard == fStandard) {
214c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fStencilFuncSeparate ||
215c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fStencilMaskSeparate ||
216c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fStencilOpSeparate) {
217adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
218bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
2199e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    } else if (kGL_GrGLStandard == fStandard) {
220e788430144d1474329878abd1ddb39cc0ca52a0arobertphillips@google.com
221c82b8899d97c2a26f5991bc771ad3beb8257edaebsalomon@google.com        if (glVer >= GR_GL_VER(2,0)) {
222c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fStencilFuncSeparate ||
223c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilMaskSeparate ||
224c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilOpSeparate) {
225adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
226bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
227bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
228c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) && NULL == fFunctions.fBindFragDataLocation) {
229adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
230bc5cf51627505f763586100675aa60b66d743c7ebsalomon@google.com        }
23190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) {
232c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fDrawBuffers) {
233adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
234d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com            }
235d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com        }
236e788430144d1474329878abd1ddb39cc0ca52a0arobertphillips@google.com
23790313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")) {
238c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fGenQueries ||
239c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteQueries ||
240c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBeginQuery ||
241c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fEndQuery ||
242c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryiv ||
243c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectiv ||
244c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectuiv) {
245adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
246373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
247373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
248373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        if (glVer >= GR_GL_VER(3,3) ||
24990313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_ARB_timer_query") ||
25090313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_timer_query")) {
251c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fGetQueryObjecti64v ||
252c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectui64v) {
253adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
254373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
255373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
25690313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
257c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fQueryCounter) {
258adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
259373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
260373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
261bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
262bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
263bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // optional function on desktop before 1.3
2649e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard != fStandard ||
2651744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com        (glVer >= GR_GL_VER(1,3)) ||
26690313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        fExtensions.has("GL_ARB_texture_compression")) {
267e1f5a23812cab849174a47fae02397e7291f850ekrajcevski        if (NULL == fFunctions.fCompressedTexImage2D
268e1f5a23812cab849174a47fae02397e7291f850ekrajcevski#if 0
269e1f5a23812cab849174a47fae02397e7291f850ekrajcevski            || NULL == fFunctions.fCompressedTexSubImage2D
270e1f5a23812cab849174a47fae02397e7291f850ekrajcevski#endif
271e1f5a23812cab849174a47fae02397e7291f850ekrajcevski            ) {
272adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
273bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
274bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
275bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
276d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com    // part of desktop GL, but not ES
2779e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard &&
278c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        (NULL == fFunctions.fGetTexLevelParameteriv ||
279c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org         NULL == fFunctions.fDrawBuffer ||
280c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org         NULL == fFunctions.fReadBuffer)) {
281adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
282bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
283cee661af926cc977addc6e039b7022975a448acebsalomon@google.com
284280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    // GL_EXT_texture_storage is part of desktop 4.2
285280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    // There is a desktop ARB extension and an ES+desktop EXT extension
2869e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
287baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        if (glVer >= GR_GL_VER(4,2) ||
28890313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_ARB_texture_storage") ||
28990313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_texture_storage")) {
290c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fTexStorage2D) {
291adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
292baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com            }
293baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        }
29490313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
295c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fTexStorage2D) {
296adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
297baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        }
298280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    }
299280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com
30090313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    if (fExtensions.has("GL_EXT_discard_framebuffer")) {
301a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com// FIXME: Remove this once Chromium is updated to provide this function
302a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com#if 0
303c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fDiscardFramebuffer) {
304adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
305a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com        }
306a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com#endif
307a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com    }
308a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com
309bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // FBO MSAA
3109e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
311bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        // GL 3.0 and the ARB extension have multisample + blit
31290313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) {
313c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisample ||
314c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
315adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
316bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
317bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        } else {
31890313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            if (fExtensions.has("GL_EXT_framebuffer_blit") &&
319c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
320adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
321bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
32290313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
323c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fRenderbufferStorageMultisample) {
324adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
325bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
326bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
327bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    } else {
32890313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) {
329c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisample ||
330c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
331adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
332a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org            }
333a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org        }
33490313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
335c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
336c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fResolveMultisampleFramebuffer) {
337adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
338bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
339bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
34090313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
34190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
342c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisampleES2EXT ||
343c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fFramebufferTexture2DMultisample) {
344adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
345f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com            }
346f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com        }
347bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
348bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
349bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // On ES buffer mapping is an extension. On Desktop
350bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // buffer mapping was part of original VBO extension
351bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // which we require.
35290313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
353c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fMapBuffer ||
354c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fUnmapBuffer) {
355adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
356bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
357bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
358bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
359271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com    // Dual source blending
3609e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard &&
36190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended"))) {
362c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fBindFragDataLocationIndexed) {
363adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
364271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com        }
365271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com    }
36612eea2b10d6caaafe0a207d10b1e9322510983a2skia.committer@gmail.com
367726e621000582e4de7c9ce0f7e9950c3af4e5d9bcommit-bot@chromium.org    // glGetStringi was added in version 3.0 of both desktop and ES.
368726e621000582e4de7c9ce0f7e9950c3af4e5d9bcommit-bot@chromium.org    if (glVer >= GR_GL_VER(3, 0)) {
369c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fGetStringi) {
370adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
3711744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com        }
3721744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com    }
373271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com
3749e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
37590313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
376c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fBindVertexArray ||
377c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteVertexArrays ||
378c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGenVertexArrays) {
379adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
380ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            }
381ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        }
382ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    } else {
38390313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) {
384c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fBindVertexArray ||
385c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteVertexArrays ||
386c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGenVertexArrays) {
387adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
388ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            }
389ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        }
390ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    }
391a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org
392a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    if (fExtensions.has("GL_EXT_debug_marker")) {
393a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org        if (NULL == fFunctions.fInsertEventMarker ||
394a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org            NULL == fFunctions.fPushGroupMarker ||
395a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org            NULL == fFunctions.fPopGroupMarker) {
396adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
397a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org        }
398a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    }
399a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com
400160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
401160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        fExtensions.has("GL_ARB_invalidate_subdata")) {
402a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        if (NULL == fFunctions.fInvalidateBufferData ||
403a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateBufferSubData ||
404a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateFramebuffer ||
405a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateSubFramebuffer ||
406a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateTexImage ||
407a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateTexSubImage) {
408a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            RETURN_FALSE_INTERFACE;
409a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        }
410160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
411a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        // ES 3.0 adds the framebuffer functions but not the others.
412a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        if (NULL == fFunctions.fInvalidateFramebuffer ||
413a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateSubFramebuffer) {
414a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            RETURN_FALSE_INTERFACE;
415a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        }
416a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com    }
417beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org
418beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org    if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
419beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org        if (NULL == fFunctions.fMapBufferSubData ||
420beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fMapTexSubImage2D ||
421beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fUnmapBufferSubData ||
422beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fUnmapTexSubImage2D) {
423beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            RETURN_FALSE_INTERFACE;
424beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org        }
425beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org    }
426a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com
427160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    // These functions are added to the 3.0 version of both GLES and GL.
428160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    if (glVer >= GR_GL_VER(3,0) ||
429160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
430160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
431160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        if (NULL == fFunctions.fMapBufferRange ||
432160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            NULL == fFunctions.fFlushMappedBufferRange) {
433160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            RETURN_FALSE_INTERFACE;
434160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        }
435160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    }
43632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
43732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    if ((kGL_GrGLStandard == fStandard && fExtensions.has("GL_EXT_direct_state_access")) ||
43832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_NV_path_rendering"))) {
43932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        if (NULL == fFunctions.fMatrixLoadf ||
44032b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fMatrixLoadIdentity) {
44132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            RETURN_FALSE_INTERFACE
44232b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
44332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    }
44432b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
44532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    if ((kGL_GrGLStandard == fStandard &&
44632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen         (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_program_interface_query"))) ||
44732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
44832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        if (NULL == fFunctions.fGetProgramResourceLocation) {
44932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            RETURN_FALSE_INTERFACE
45032b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
45132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    }
45232b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
45332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    if (fExtensions.has("GL_NV_path_rendering")) {
45432b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        if (NULL == fFunctions.fPathCommands ||
45532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathCoords ||
45632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathParameteri ||
45732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathParameterf ||
45832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fGenPaths ||
45932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fDeletePaths ||
46032b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathStencilFunc ||
46132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilFillPath ||
46232b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilStrokePath ||
46332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilFillPathInstanced ||
46432b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilStrokePathInstanced ||
46532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fCoverFillPath ||
46632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fCoverStrokePath ||
46732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fCoverFillPathInstanced ||
46832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fCoverStrokePathInstanced) {
46932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            RETURN_FALSE_INTERFACE
47032b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
47132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        // Currently ProgramPathFragmentInputGen is not used on
47232b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        // OpenGL, rather PathTexGen is.
47332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        if ((kGL_GrGLStandard == fStandard && NULL == fFunctions.fPathTexGen) ||
47432b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            (kGLES_GrGLStandard == fStandard && NULL == fFunctions.fProgramPathFragmentInputGen)) {
47532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            RETURN_FALSE_INTERFACE
47632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
47732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    }
47832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
479bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    return true;
480bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com}
481