GrGLInterface.cpp revision ee64d6ef49fbb63e0fc7934334c5ae5e900f5336
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#if 0
18827c1521ccf0f833affa1182d6d9bc5e31b3af351egdaniel        NULL == fFunctions.fVertexAttrib1f ||
18927c1521ccf0f833affa1182d6d9bc5e31b3af351egdaniel        NULL == fFunctions.fVertexAttrib2fv ||
19027c1521ccf0f833affa1182d6d9bc5e31b3af351egdaniel        NULL == fFunctions.fVertexAttrib3fv ||
19127c1521ccf0f833affa1182d6d9bc5e31b3af351egdaniel#endif
192c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fVertexAttrib4fv ||
193c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fVertexAttribPointer ||
194c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fViewport ||
195c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindFramebuffer ||
196c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindRenderbuffer ||
197c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCheckFramebufferStatus ||
198c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteFramebuffers ||
199c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteRenderbuffers ||
200c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFinish ||
201c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFlush ||
202c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFramebufferRenderbuffer ||
203c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFramebufferTexture2D ||
204c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetFramebufferAttachmentParameteriv ||
205c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetRenderbufferParameteriv ||
206c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenFramebuffers ||
207c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenRenderbuffers ||
208c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fRenderbufferStorage) {
209adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
210bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
211bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
212c82b8899d97c2a26f5991bc771ad3beb8257edaebsalomon@google.com    GrGLVersion glVer = GrGLGetVersion(this);
213f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org    if (GR_GL_INVALID_VER == glVer) {
214f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org        RETURN_FALSE_INTERFACE
215f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org    }
216bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
217bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // Now check that baseline ES/Desktop fns not covered above are present
21890313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    // and that we have fn pointers for any advertised fExtensions that we will
219bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // try to use.
220bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
221bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // these functions are part of ES2, we assume they are available
222bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // On the desktop we assume they are available if the extension
223bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // is present or GL version is high enough.
2249e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGLES_GrGLStandard == fStandard) {
225c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fStencilFuncSeparate ||
226c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fStencilMaskSeparate ||
227c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fStencilOpSeparate) {
228adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
229bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
2309e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    } else if (kGL_GrGLStandard == fStandard) {
231e788430144d1474329878abd1ddb39cc0ca52a0arobertphillips@google.com
232c82b8899d97c2a26f5991bc771ad3beb8257edaebsalomon@google.com        if (glVer >= GR_GL_VER(2,0)) {
233c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fStencilFuncSeparate ||
234c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilMaskSeparate ||
235c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilOpSeparate) {
236adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
237bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
238bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
239c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) && NULL == fFunctions.fBindFragDataLocation) {
240adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
241bc5cf51627505f763586100675aa60b66d743c7ebsalomon@google.com        }
24290313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) {
243c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fDrawBuffers) {
244adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
245d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com            }
246d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com        }
247e788430144d1474329878abd1ddb39cc0ca52a0arobertphillips@google.com
24890313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")) {
249c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fGenQueries ||
250c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteQueries ||
251c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBeginQuery ||
252c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fEndQuery ||
253c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryiv ||
254c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectiv ||
255c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectuiv) {
256adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
257373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
258373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
259373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        if (glVer >= GR_GL_VER(3,3) ||
26090313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_ARB_timer_query") ||
26190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_timer_query")) {
262c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fGetQueryObjecti64v ||
263c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectui64v) {
264adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
265373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
266373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
26790313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
268c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fQueryCounter) {
269adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
270373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
271373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
272bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
273bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
274bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // optional function on desktop before 1.3
2759e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard != fStandard ||
2761744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com        (glVer >= GR_GL_VER(1,3)) ||
27790313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        fExtensions.has("GL_ARB_texture_compression")) {
278e1f5a23812cab849174a47fae02397e7291f850ekrajcevski        if (NULL == fFunctions.fCompressedTexImage2D
279e1f5a23812cab849174a47fae02397e7291f850ekrajcevski#if 0
280e1f5a23812cab849174a47fae02397e7291f850ekrajcevski            || NULL == fFunctions.fCompressedTexSubImage2D
281e1f5a23812cab849174a47fae02397e7291f850ekrajcevski#endif
282e1f5a23812cab849174a47fae02397e7291f850ekrajcevski            ) {
283adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
284bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
285bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
286bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
287d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com    // part of desktop GL, but not ES
2889e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard &&
289c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        (NULL == fFunctions.fGetTexLevelParameteriv ||
290c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org         NULL == fFunctions.fDrawBuffer ||
291c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org         NULL == fFunctions.fReadBuffer)) {
292adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
293bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
294cee661af926cc977addc6e039b7022975a448acebsalomon@google.com
295280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    // GL_EXT_texture_storage is part of desktop 4.2
296280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    // There is a desktop ARB extension and an ES+desktop EXT extension
2979e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
298baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        if (glVer >= GR_GL_VER(4,2) ||
29990313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_ARB_texture_storage") ||
30090313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_texture_storage")) {
301c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fTexStorage2D) {
302adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
303baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com            }
304baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        }
30590313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
306c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fTexStorage2D) {
307adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
308baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        }
309280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    }
310280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com
31190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    if (fExtensions.has("GL_EXT_discard_framebuffer")) {
312a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com// FIXME: Remove this once Chromium is updated to provide this function
313a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com#if 0
314c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fDiscardFramebuffer) {
315adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
316a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com        }
317a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com#endif
318a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com    }
319a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com
320bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // FBO MSAA
3219e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
322bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        // GL 3.0 and the ARB extension have multisample + blit
32390313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) {
324c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisample ||
325c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
326adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
327bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
328bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        } else {
32990313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            if (fExtensions.has("GL_EXT_framebuffer_blit") &&
330c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
331adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
332bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
33390313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
334c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fRenderbufferStorageMultisample) {
335adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
336bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
337bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
338bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    } else {
33990313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) {
340c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisample ||
341c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
342adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
343a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org            }
344a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org        }
34590313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
346c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
347c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fResolveMultisampleFramebuffer) {
348adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
349bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
350bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
35190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
35290313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
353c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisampleES2EXT ||
354c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fFramebufferTexture2DMultisample) {
355adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
356f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com            }
357f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com        }
358bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
359bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
360bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // On ES buffer mapping is an extension. On Desktop
361bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // buffer mapping was part of original VBO extension
362bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // which we require.
36390313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
364c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fMapBuffer ||
365c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fUnmapBuffer) {
366adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
367bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
368bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
369bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
370271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com    // Dual source blending
3719e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard &&
37290313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended"))) {
373c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fBindFragDataLocationIndexed) {
374adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
375271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com        }
376271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com    }
37712eea2b10d6caaafe0a207d10b1e9322510983a2skia.committer@gmail.com
378726e621000582e4de7c9ce0f7e9950c3af4e5d9bcommit-bot@chromium.org    // glGetStringi was added in version 3.0 of both desktop and ES.
379726e621000582e4de7c9ce0f7e9950c3af4e5d9bcommit-bot@chromium.org    if (glVer >= GR_GL_VER(3, 0)) {
380c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fGetStringi) {
381adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
3821744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com        }
3831744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com    }
384271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com
3859e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
38690313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
387c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fBindVertexArray ||
388c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteVertexArrays ||
389c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGenVertexArrays) {
390adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
391ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            }
392ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        }
393ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    } else {
39490313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) {
395c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fBindVertexArray ||
396c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteVertexArrays ||
397c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGenVertexArrays) {
398adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
399ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            }
400ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        }
401ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    }
402a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org
403a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    if (fExtensions.has("GL_EXT_debug_marker")) {
404a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org        if (NULL == fFunctions.fInsertEventMarker ||
405a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org            NULL == fFunctions.fPushGroupMarker ||
406a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org            NULL == fFunctions.fPopGroupMarker) {
407adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
408a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org        }
409a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    }
410a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com
411160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
412160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        fExtensions.has("GL_ARB_invalidate_subdata")) {
413a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        if (NULL == fFunctions.fInvalidateBufferData ||
414a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateBufferSubData ||
415a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateFramebuffer ||
416a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateSubFramebuffer ||
417a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateTexImage ||
418a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateTexSubImage) {
419a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            RETURN_FALSE_INTERFACE;
420a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        }
421160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
422a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        // ES 3.0 adds the framebuffer functions but not the others.
423a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        if (NULL == fFunctions.fInvalidateFramebuffer ||
424a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateSubFramebuffer) {
425a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            RETURN_FALSE_INTERFACE;
426a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        }
427a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com    }
428beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org
429beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org    if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
430beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org        if (NULL == fFunctions.fMapBufferSubData ||
431beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fMapTexSubImage2D ||
432beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fUnmapBufferSubData ||
433beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fUnmapTexSubImage2D) {
434beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            RETURN_FALSE_INTERFACE;
435beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org        }
436beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org    }
437a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com
438160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    // These functions are added to the 3.0 version of both GLES and GL.
439160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    if (glVer >= GR_GL_VER(3,0) ||
440160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
441160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
442160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        if (NULL == fFunctions.fMapBufferRange ||
443160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            NULL == fFunctions.fFlushMappedBufferRange) {
444160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            RETURN_FALSE_INTERFACE;
445160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        }
446160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    }
44732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
44832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    if ((kGL_GrGLStandard == fStandard && fExtensions.has("GL_EXT_direct_state_access")) ||
44932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_NV_path_rendering"))) {
45032b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        if (NULL == fFunctions.fMatrixLoadf ||
45132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fMatrixLoadIdentity) {
45232b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            RETURN_FALSE_INTERFACE
45332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
45432b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    }
45532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
45632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    if ((kGL_GrGLStandard == fStandard &&
45732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen         (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_program_interface_query"))) ||
45832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
45932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        if (NULL == fFunctions.fGetProgramResourceLocation) {
46032b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            RETURN_FALSE_INTERFACE
46132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
46232b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    }
46332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
464ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon    if (kGLES_GrGLStandard == fStandard || glVer >= GR_GL_VER(4,1) ||
465ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon        fExtensions.has("GL_ARB_ES2_compatibility")) {
466ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon#if 0 // Enable this once Chrome gives us the function ptr
467ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon        if (NULL == fFunctions.fGetShaderPrecisionFormat) {
468ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon            RETURN_FALSE_INTERFACE
469ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon        }
470ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon#endif
471ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon    }
472ee64d6ef49fbb63e0fc7934334c5ae5e900f5336bsalomon
47332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    if (fExtensions.has("GL_NV_path_rendering")) {
47432b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        if (NULL == fFunctions.fPathCommands ||
47532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathCoords ||
47632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathParameteri ||
47732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathParameterf ||
47832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fGenPaths ||
47932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fDeletePaths ||
4808dd90cb1fd541b9a2a264725e3dfeae736c91e22cdalton            NULL == fFunctions.fIsPath ||
48132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fPathStencilFunc ||
48232b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilFillPath ||
48332b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilStrokePath ||
48432b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilFillPathInstanced ||
48532b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fStencilStrokePathInstanced ||
48632b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fCoverFillPath ||
48732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fCoverStrokePath ||
48832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            NULL == fFunctions.fCoverFillPathInstanced ||
489c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            NULL == fFunctions.fCoverStrokePathInstanced) {
49032b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen            RETURN_FALSE_INTERFACE
49132b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
492c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton        if (kGL_GrGLStandard == fStandard) {
493c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            // Some methods only exist on desktop
494c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            if (NULL == fFunctions.fPathTexGen) {
495c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton                RETURN_FALSE_INTERFACE
496c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            }
497c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton        } else {
498c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            // All additions through v1.3 exist on GLES
499c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            if (NULL == fFunctions.fStencilThenCoverFillPath ||
500c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton                NULL == fFunctions.fStencilThenCoverStrokePath ||
501c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton                NULL == fFunctions.fStencilThenCoverFillPathInstanced ||
502c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton                NULL == fFunctions.fStencilThenCoverStrokePathInstanced ||
503149b3ec2b1ccaf00e40bf296d2a3394852d73fe9cdalton                NULL == fFunctions.fProgramPathFragmentInputGen ||
504149b3ec2b1ccaf00e40bf296d2a3394852d73fe9cdalton                NULL == fFunctions.fPathMemoryGlyphIndexArray) {
505c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton                RETURN_FALSE_INTERFACE
506c7103a104fdc7150b4e3c0d3efc42735ad359616cdalton            }
50732b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen        }
50832b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen    }
50932b9a3b02ed6b8bab4a25b6cb8853f5bea4b87bakkinnunen
510bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    return true;
511bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com}
512