GrGLInterface.cpp revision 08b4d29a0a29badc15129c9bc7ee8352bc75278d
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;
488dd90cb1fd541b9a2a264725e3dfeae736c91e22cdalton    newInterface->fFunctions.fIsPath = NULL;
49f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathStencilFunc = NULL;
50f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilFillPath = NULL;
51f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilStrokePath = NULL;
52f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilFillPathInstanced = NULL;
53f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilStrokePathInstanced = NULL;
54f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathTexGen = NULL;
55f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverFillPath = NULL;
56f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverStrokePath = NULL;
57f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverFillPathInstanced = NULL;
58f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverStrokePathInstanced = NULL;
59c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton    newInterface->fFunctions.fStencilThenCoverFillPath = NULL;
60c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton    newInterface->fFunctions.fStencilThenCoverStrokePath = NULL;
61c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton    newInterface->fFunctions.fStencilThenCoverFillPathInstanced = NULL;
62c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton    newInterface->fFunctions.fStencilThenCoverStrokePathInstanced = NULL;
6332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    newInterface->fFunctions.fProgramPathFragmentInputGen = NULL;
64149b3ec2b1ccaf00e40bf296d2a3394852d73fe9cdalton    newInterface->fFunctions.fPathMemoryGlyphIndexArray = NULL;
65d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    return newInterface;
66d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org}
67d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
68f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.orgGrGLInterface::GrGLInterface() {
699e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    fStandard = kNone_GrGLStandard;
700b77d6892b067ad402c9678b0226bff70599fbe2bsalomon@google.com
7156bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com#if GR_GL_PER_GL_FUNC_CALLBACK
7256bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com    fCallback = GrGLDefaultInterfaceCallback;
7356bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com    fCallbackData = 0;
7456bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com#endif
750b77d6892b067ad402c9678b0226bff70599fbe2bsalomon@google.com}
760b77d6892b067ad402c9678b0226bff70599fbe2bsalomon@google.com
77d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.orgGrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
7849f085dddff10473b6ebf832a974288300224e60bsalomon    SkASSERT(interface);
79d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
80d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    GrGLInterface* clone = SkNEW(GrGLInterface);
81d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fStandard = interface->fStandard;
82d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fExtensions = interface->fExtensions;
83d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fFunctions = interface->fFunctions;
84d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org#if GR_GL_PER_GL_FUNC_CALLBACK
85d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fCallback = interface->fCallback;
86d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fCallbackData = interface->fCallbackData;
87d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org#endif
88d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    return clone;
89d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org}
90d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
91e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#ifdef SK_DEBUG
92e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    static int kIsDebug = 1;
93e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#else
94e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    static int kIsDebug = 0;
95e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#endif
96e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org
97e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#define RETURN_FALSE_INTERFACE                                                                   \
98e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \
99e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    return false;
100adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org
1019e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.orgbool GrGLInterface::validate() const {
102bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
1039e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kNone_GrGLStandard == fStandard) {
104adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
105bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
10612eea2b10d6caaafe0a207d10b1e9322510983a2skia.committer@gmail.com
10790313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    if (!fExtensions.isInitialized()) {
108adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
1091744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com    }
110bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
111bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // functions that are always required
112c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    if (NULL == fFunctions.fActiveTexture ||
113c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fAttachShader ||
114c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindAttribLocation ||
115c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindBuffer ||
116c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindTexture ||
117c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBlendFunc ||
118c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBlendColor ||      // -> GL >= 1.4, ES >= 2.0 or extension
119c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBufferData ||
120c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBufferSubData ||
121c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fClear ||
122c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fClearColor ||
123c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fClearStencil ||
124c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fColorMask ||
125c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCompileShader ||
126c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCopyTexSubImage2D ||
127c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCreateProgram ||
128c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCreateShader ||
129c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCullFace ||
130c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteBuffers ||
131c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteProgram ||
132c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteShader ||
133c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteTextures ||
134c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDepthMask ||
135c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDisable ||
136c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDisableVertexAttribArray ||
137c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDrawArrays ||
138c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDrawElements ||
139c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fEnable ||
140c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fEnableVertexAttribArray ||
141c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFrontFace ||
142c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenBuffers ||
143c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenTextures ||
144c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetBufferParameteriv ||
145c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenerateMipmap ||
146c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetError ||
147c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetIntegerv ||
148c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetProgramInfoLog ||
149c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetProgramiv ||
150c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetShaderInfoLog ||
151c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetShaderiv ||
152c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetString ||
153c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetUniformLocation ||
154c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fLinkProgram ||
155c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fLineWidth ||
156c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fPixelStorei ||
157c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fReadPixels ||
158c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fScissor ||
159c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fShaderSource ||
160c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fStencilFunc ||
161c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fStencilMask ||
162c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fStencilOp ||
163c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexImage2D ||
164c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexParameteri ||
165c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexParameteriv ||
166c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexSubImage2D ||
167c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1f ||
168c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1i ||
169c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1fv ||
170c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1iv ||
171c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2f ||
172c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2i ||
173c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2fv ||
174c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2iv ||
175c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3f ||
176c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3i ||
177c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3fv ||
178c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3iv ||
179c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4f ||
180c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4i ||
181c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4fv ||
182c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4iv ||
183c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniformMatrix2fv ||
184c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniformMatrix3fv ||
185c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniformMatrix4fv ||
186c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUseProgram ||
18727c1521ccf0f833affa1182d6d9bc5e31b3af351egdaniel        NULL == fFunctions.fVertexAttrib1f ||
18827c1521ccf0f833affa1182d6d9bc5e31b3af351egdaniel        NULL == fFunctions.fVertexAttrib2fv ||
18927c1521ccf0f833affa1182d6d9bc5e31b3af351egdaniel        NULL == fFunctions.fVertexAttrib3fv ||
190c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fVertexAttrib4fv ||
191c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fVertexAttribPointer ||
192c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fViewport ||
193c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindFramebuffer ||
194c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindRenderbuffer ||
195c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCheckFramebufferStatus ||
196c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteFramebuffers ||
197c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteRenderbuffers ||
198c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFinish ||
199c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFlush ||
200c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFramebufferRenderbuffer ||
201c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFramebufferTexture2D ||
202c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetFramebufferAttachmentParameteriv ||
203c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetRenderbufferParameteriv ||
204c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenFramebuffers ||
205c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenRenderbuffers ||
206c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fRenderbufferStorage) {
207adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
208bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
209bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
210c82b8899d97c2a26f5991bc771ad3beb8257edaebsalomon@google.com    GrGLVersion glVer = GrGLGetVersion(this);
211f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org    if (GR_GL_INVALID_VER == glVer) {
212f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org        RETURN_FALSE_INTERFACE
213f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org    }
214bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
215bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // Now check that baseline ES/Desktop fns not covered above are present
21690313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    // and that we have fn pointers for any advertised fExtensions that we will
217bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // try to use.
218bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
219bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // these functions are part of ES2, we assume they are available
220bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // On the desktop we assume they are available if the extension
221bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // is present or GL version is high enough.
2229e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGLES_GrGLStandard == fStandard) {
223c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fStencilFuncSeparate ||
224c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fStencilMaskSeparate ||
225c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fStencilOpSeparate) {
226adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
227bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
2289e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    } else if (kGL_GrGLStandard == fStandard) {
229e788430144d1474329878abd1ddb39cc0ca52a0arobertphillips@google.com
230c82b8899d97c2a26f5991bc771ad3beb8257edaebsalomon@google.com        if (glVer >= GR_GL_VER(2,0)) {
231c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fStencilFuncSeparate ||
232c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilMaskSeparate ||
233c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilOpSeparate) {
234adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
235bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
236bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
237c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) && NULL == fFunctions.fBindFragDataLocation) {
238adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
239bc5cf51627505f763586100675aa60b66d743c7ebsalomon@google.com        }
24090313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) {
241c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fDrawBuffers) {
242adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
243d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com            }
244d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com        }
245e788430144d1474329878abd1ddb39cc0ca52a0arobertphillips@google.com
24690313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")) {
247c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fGenQueries ||
248c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteQueries ||
249c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBeginQuery ||
250c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fEndQuery ||
251c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryiv ||
252c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectiv ||
253c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectuiv) {
254adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
255373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
256373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
257373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        if (glVer >= GR_GL_VER(3,3) ||
25890313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_ARB_timer_query") ||
25990313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_timer_query")) {
260c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fGetQueryObjecti64v ||
261c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectui64v) {
262adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
263373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
264373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
26590313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
266c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fQueryCounter) {
267adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
268373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
269373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
270bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
271bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
272bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // optional function on desktop before 1.3
2739e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard != fStandard ||
2741744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com        (glVer >= GR_GL_VER(1,3)) ||
27590313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        fExtensions.has("GL_ARB_texture_compression")) {
276e1f5a23812cab849174a47fae02397e7291f850ekrajcevski        if (NULL == fFunctions.fCompressedTexImage2D
277e1f5a23812cab849174a47fae02397e7291f850ekrajcevski#if 0
278e1f5a23812cab849174a47fae02397e7291f850ekrajcevski            || NULL == fFunctions.fCompressedTexSubImage2D
279e1f5a23812cab849174a47fae02397e7291f850ekrajcevski#endif
280e1f5a23812cab849174a47fae02397e7291f850ekrajcevski            ) {
281adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
282bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
283bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
284bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
285d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com    // part of desktop GL, but not ES
2869e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard &&
287c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        (NULL == fFunctions.fGetTexLevelParameteriv ||
288c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org         NULL == fFunctions.fDrawBuffer ||
289c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org         NULL == fFunctions.fReadBuffer)) {
290adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
291bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
292cee661af926cc977addc6e039b7022975a448acebsalomon@google.com
293280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    // GL_EXT_texture_storage is part of desktop 4.2
294280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    // There is a desktop ARB extension and an ES+desktop EXT extension
2959e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
296baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        if (glVer >= GR_GL_VER(4,2) ||
29790313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_ARB_texture_storage") ||
29890313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_texture_storage")) {
299c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fTexStorage2D) {
300adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
301baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com            }
302baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        }
30390313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
304c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fTexStorage2D) {
305adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
306baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        }
307280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    }
308280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com
30990313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    if (fExtensions.has("GL_EXT_discard_framebuffer")) {
310a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com// FIXME: Remove this once Chromium is updated to provide this function
311a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com#if 0
312c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fDiscardFramebuffer) {
313adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
314a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com        }
315a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com#endif
316a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com    }
317a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com
318bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // FBO MSAA
3199e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
320bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        // GL 3.0 and the ARB extension have multisample + blit
32190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) {
322c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisample ||
323c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
324adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
325bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
326bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        } else {
32790313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            if (fExtensions.has("GL_EXT_framebuffer_blit") &&
328c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
329adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
330bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
33190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
332c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fRenderbufferStorageMultisample) {
333adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
334bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
335bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
336bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    } else {
33790313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) {
338c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisample ||
339c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
340adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
341a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org            }
342a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org        }
34390313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
344c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
345c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fResolveMultisampleFramebuffer) {
346adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
347bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
348bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
34990313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
35090313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
351c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisampleES2EXT ||
352c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fFramebufferTexture2DMultisample) {
353adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
354f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com            }
355f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com        }
356bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
357bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
358bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // On ES buffer mapping is an extension. On Desktop
359bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // buffer mapping was part of original VBO extension
360bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // which we require.
36190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
362c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fMapBuffer ||
363c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fUnmapBuffer) {
364adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
365bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
366bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
367bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
368271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com    // Dual source blending
3699e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard &&
37090313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended"))) {
371c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fBindFragDataLocationIndexed) {
372adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
373271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com        }
374271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com    }
37512eea2b10d6caaafe0a207d10b1e9322510983a2skia.committer@gmail.com
376726e621000582e4de7c9ce0f7e9950c3af4e5d9bcommit-bot@chromium.org    // glGetStringi was added in version 3.0 of both desktop and ES.
377726e621000582e4de7c9ce0f7e9950c3af4e5d9bcommit-bot@chromium.org    if (glVer >= GR_GL_VER(3, 0)) {
378c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fGetStringi) {
379adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
3801744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com        }
3811744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com    }
382271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com
3839e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
38490313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
385c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fBindVertexArray ||
386c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteVertexArrays ||
387c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGenVertexArrays) {
388adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
389ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            }
390ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        }
391ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    } else {
39290313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) {
393c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fBindVertexArray ||
394c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteVertexArrays ||
395c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGenVertexArrays) {
396adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
397ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            }
398ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        }
399ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    }
400a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org
401a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    if (fExtensions.has("GL_EXT_debug_marker")) {
402a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org        if (NULL == fFunctions.fInsertEventMarker ||
403a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org            NULL == fFunctions.fPushGroupMarker ||
404a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org            NULL == fFunctions.fPopGroupMarker) {
405adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
406a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org        }
407a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    }
408a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com
409160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
410160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        fExtensions.has("GL_ARB_invalidate_subdata")) {
411a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        if (NULL == fFunctions.fInvalidateBufferData ||
412a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateBufferSubData ||
413a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateFramebuffer ||
414a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateSubFramebuffer ||
415a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateTexImage ||
416a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateTexSubImage) {
417a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            RETURN_FALSE_INTERFACE;
418a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        }
419160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
420a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        // ES 3.0 adds the framebuffer functions but not the others.
421a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        if (NULL == fFunctions.fInvalidateFramebuffer ||
422a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateSubFramebuffer) {
423a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            RETURN_FALSE_INTERFACE;
424a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        }
425a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com    }
426beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org
427beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org    if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
428beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org        if (NULL == fFunctions.fMapBufferSubData ||
429beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fMapTexSubImage2D ||
430beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fUnmapBufferSubData ||
431beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fUnmapTexSubImage2D) {
432beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            RETURN_FALSE_INTERFACE;
433beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org        }
434beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org    }
435a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com
436160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    // These functions are added to the 3.0 version of both GLES and GL.
437160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    if (glVer >= GR_GL_VER(3,0) ||
438160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
439160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
440160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        if (NULL == fFunctions.fMapBufferRange ||
441160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            NULL == fFunctions.fFlushMappedBufferRange) {
442160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            RETURN_FALSE_INTERFACE;
443160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        }
444160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    }
44532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
44632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    if ((kGL_GrGLStandard == fStandard && fExtensions.has("GL_EXT_direct_state_access")) ||
44732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_NV_path_rendering"))) {
44832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        if (NULL == fFunctions.fMatrixLoadf ||
44932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fMatrixLoadIdentity) {
45032b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            RETURN_FALSE_INTERFACE
45132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
45232b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    }
45332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
45432b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    if ((kGL_GrGLStandard == fStandard &&
45532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen         (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_program_interface_query"))) ||
45632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
45732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        if (NULL == fFunctions.fGetProgramResourceLocation) {
45832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            RETURN_FALSE_INTERFACE
45932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
46032b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    }
46132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
462ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon    if (kGLES_GrGLStandard == fStandard || glVer >= GR_GL_VER(4,1) ||
463ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon        fExtensions.has("GL_ARB_ES2_compatibility")) {
464ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon#if 0 // Enable this once Chrome gives us the function ptr
465ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon        if (NULL == fFunctions.fGetShaderPrecisionFormat) {
466ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon            RETURN_FALSE_INTERFACE
467ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon        }
468ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon#endif
469ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon    }
470ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon
47132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    if (fExtensions.has("GL_NV_path_rendering")) {
47232b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        if (NULL == fFunctions.fPathCommands ||
47332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathCoords ||
47432b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathParameteri ||
47532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathParameterf ||
47632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fGenPaths ||
47732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fDeletePaths ||
4788dd90cb1fd541b9a2a264725e3dfeae736c91e22cdalton            NULL == fFunctions.fIsPath ||
47932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathStencilFunc ||
48032b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilFillPath ||
48132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilStrokePath ||
48232b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilFillPathInstanced ||
48332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilStrokePathInstanced ||
48432b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fCoverFillPath ||
48532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fCoverStrokePath ||
48632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fCoverFillPathInstanced ||
487c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            NULL == fFunctions.fCoverStrokePathInstanced) {
48832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            RETURN_FALSE_INTERFACE
48932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
490c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton        if (kGL_GrGLStandard == fStandard) {
491c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            // Some methods only exist on desktop
492c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            if (NULL == fFunctions.fPathTexGen) {
493c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton                RETURN_FALSE_INTERFACE
494c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            }
495c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton        } else {
496c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            // All additions through v1.3 exist on GLES
497c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            if (NULL == fFunctions.fStencilThenCoverFillPath ||
498c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton                NULL == fFunctions.fStencilThenCoverStrokePath ||
499c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton                NULL == fFunctions.fStencilThenCoverFillPathInstanced ||
500c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton                NULL == fFunctions.fStencilThenCoverStrokePathInstanced ||
501149b3ec2b1ccaf00e40bf296d2a3394852d73fe9cdalton                NULL == fFunctions.fProgramPathFragmentInputGen ||
502149b3ec2b1ccaf00e40bf296d2a3394852d73fe9cdalton                NULL == fFunctions.fPathMemoryGlyphIndexArray) {
503c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton                RETURN_FALSE_INTERFACE
504c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            }
50532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
50632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    }
50732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
50808b4d29a0a29badc15129c9bc7ee8352bc75278dvbuzinov    if (fExtensions.has("GL_NV_framebuffer_mixed_samples")) {
50908b4d29a0a29badc15129c9bc7ee8352bc75278dvbuzinov        if (NULL == fFunctions.fCoverageModulation) {
51008b4d29a0a29badc15129c9bc7ee8352bc75278dvbuzinov            RETURN_FALSE_INTERFACE
51108b4d29a0a29badc15129c9bc7ee8352bc75278dvbuzinov        }
51208b4d29a0a29badc15129c9bc7ee8352bc75278dvbuzinov    }
51308b4d29a0a29badc15129c9bc7ee8352bc75278dvbuzinov
514bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    return true;
515bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com}
516