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");
42d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
43f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathCommands = NULL;
44f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathCoords = NULL;
45f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathSubCommands = NULL;
46f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathSubCoords = NULL;
47f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathString = NULL;
48f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathGlyphs = NULL;
49f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathGlyphRange = NULL;
50f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fWeightPaths = NULL;
51f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCopyPath = NULL;
52f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fInterpolatePaths = NULL;
53f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fTransformPath = NULL;
54f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathParameteriv = NULL;
55f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathParameteri = NULL;
56f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathParameterfv = NULL;
57f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathParameterf = NULL;
58f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathDashArray = NULL;
59f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGenPaths = NULL;
60f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fDeletePaths = NULL;
61f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fIsPath = NULL;
62f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathStencilFunc = NULL;
63f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathStencilDepthOffset = NULL;
64f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilFillPath = NULL;
65f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilStrokePath = NULL;
66f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilFillPathInstanced = NULL;
67f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fStencilStrokePathInstanced = NULL;
68f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathCoverDepthFunc = NULL;
69f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathColorGen = NULL;
70f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathTexGen = NULL;
71f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPathFogGen = NULL;
72f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverFillPath = NULL;
73f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverStrokePath = NULL;
74f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverFillPathInstanced = NULL;
75f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fCoverStrokePathInstanced = NULL;
76f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathParameteriv = NULL;
77f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathParameterfv = NULL;
78f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathCommands = NULL;
79f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathCoords = NULL;
80f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathDashArray = NULL;
81f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathMetrics = NULL;
82f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathMetricRange = NULL;
83f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathSpacing = NULL;
84f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathColorGeniv = NULL;
85f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathColorGenfv = NULL;
86f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathTexGeniv = NULL;
87f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathTexGenfv = NULL;
88f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fIsPointInFillPath = NULL;
89f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fIsPointInStrokePath = NULL;
90f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fGetPathLength = NULL;
91f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    newInterface->fFunctions.fPointAlongPath = NULL;
92d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
93d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    return newInterface;
94d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org}
95d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
96f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.orgGrGLInterface::GrGLInterface() {
979e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    fStandard = kNone_GrGLStandard;
980b77d6892b067ad402c9678b0226bff70599fbe2bsalomon@google.com
9956bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com#if GR_GL_PER_GL_FUNC_CALLBACK
10056bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com    fCallback = GrGLDefaultInterfaceCallback;
10156bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com    fCallbackData = 0;
10256bfc5acc210987838744eece7383bc2f6b34915bsalomon@google.com#endif
1030b77d6892b067ad402c9678b0226bff70599fbe2bsalomon@google.com}
1040b77d6892b067ad402c9678b0226bff70599fbe2bsalomon@google.com
105d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.orgGrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
106d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    SkASSERT(NULL != interface);
107d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
108d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    GrGLInterface* clone = SkNEW(GrGLInterface);
109d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fStandard = interface->fStandard;
110d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fExtensions = interface->fExtensions;
111d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fFunctions = interface->fFunctions;
112d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org#if GR_GL_PER_GL_FUNC_CALLBACK
113d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fCallback = interface->fCallback;
114d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    clone->fCallbackData = interface->fCallbackData;
115d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org#endif
116d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org    return clone;
117d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org}
118d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org
119e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#ifdef SK_DEBUG
120e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    static int kIsDebug = 1;
121e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#else
122e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    static int kIsDebug = 0;
123e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#endif
124e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org
125e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org#define RETURN_FALSE_INTERFACE                                                                   \
126e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \
127e83b9b7c20c0b5cf6b15129d60576100199fd051commit-bot@chromium.org    return false;
128adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org
1299e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.orgbool GrGLInterface::validate() const {
130bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
1319e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kNone_GrGLStandard == fStandard) {
132adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
133bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
13412eea2b10d6caaafe0a207d10b1e9322510983a2skia.committer@gmail.com
13590313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    if (!fExtensions.isInitialized()) {
136adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
1371744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com    }
138bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
139bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // functions that are always required
140c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    if (NULL == fFunctions.fActiveTexture ||
141c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fAttachShader ||
142c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindAttribLocation ||
143c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindBuffer ||
144c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindTexture ||
145c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBlendFunc ||
146c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBlendColor ||      // -> GL >= 1.4, ES >= 2.0 or extension
147c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBufferData ||
148c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBufferSubData ||
149c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fClear ||
150c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fClearColor ||
151c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fClearStencil ||
152c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fColorMask ||
153c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCompileShader ||
154c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCopyTexSubImage2D ||
155c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCreateProgram ||
156c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCreateShader ||
157c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCullFace ||
158c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteBuffers ||
159c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteProgram ||
160c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteShader ||
161c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteTextures ||
162c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDepthMask ||
163c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDisable ||
164c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDisableVertexAttribArray ||
165c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDrawArrays ||
166c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDrawElements ||
167c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fEnable ||
168c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fEnableVertexAttribArray ||
169c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFrontFace ||
170c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenBuffers ||
171c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenTextures ||
172c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetBufferParameteriv ||
173c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenerateMipmap ||
174c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetError ||
175c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetIntegerv ||
176c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetProgramInfoLog ||
177c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetProgramiv ||
178c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetShaderInfoLog ||
179c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetShaderiv ||
180c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetString ||
181c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetUniformLocation ||
182c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fLinkProgram ||
183c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fLineWidth ||
184c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fPixelStorei ||
185c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fReadPixels ||
186c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fScissor ||
187c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fShaderSource ||
188c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fStencilFunc ||
189c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fStencilMask ||
190c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fStencilOp ||
191c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexImage2D ||
192c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexParameteri ||
193c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexParameteriv ||
194c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fTexSubImage2D ||
195c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1f ||
196c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1i ||
197c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1fv ||
198c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform1iv ||
199c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2f ||
200c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2i ||
201c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2fv ||
202c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform2iv ||
203c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3f ||
204c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3i ||
205c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3fv ||
206c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform3iv ||
207c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4f ||
208c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4i ||
209c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4fv ||
210c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniform4iv ||
211c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniformMatrix2fv ||
212c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniformMatrix3fv ||
213c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUniformMatrix4fv ||
214c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fUseProgram ||
215c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fVertexAttrib4fv ||
216c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fVertexAttribPointer ||
217c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fViewport ||
218c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindFramebuffer ||
219c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fBindRenderbuffer ||
220c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fCheckFramebufferStatus ||
221c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteFramebuffers ||
222c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fDeleteRenderbuffers ||
223c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFinish ||
224c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFlush ||
225c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFramebufferRenderbuffer ||
226c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fFramebufferTexture2D ||
227c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetFramebufferAttachmentParameteriv ||
228c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGetRenderbufferParameteriv ||
229c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenFramebuffers ||
230c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fGenRenderbuffers ||
231c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        NULL == fFunctions.fRenderbufferStorage) {
232adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
233bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
234bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
235c82b8899d97c2a26f5991bc771ad3beb8257edaebsalomon@google.com    GrGLVersion glVer = GrGLGetVersion(this);
236f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org    if (GR_GL_INVALID_VER == glVer) {
237f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org        RETURN_FALSE_INTERFACE
238f4e67e3e5e5017284300a61e7bb046723a44b0cfcommit-bot@chromium.org    }
239bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
240bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // Now check that baseline ES/Desktop fns not covered above are present
24190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    // and that we have fn pointers for any advertised fExtensions that we will
242bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // try to use.
243bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
244bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // these functions are part of ES2, we assume they are available
245bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // On the desktop we assume they are available if the extension
246bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // is present or GL version is high enough.
2479e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGLES_GrGLStandard == fStandard) {
248c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fStencilFuncSeparate ||
249c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fStencilMaskSeparate ||
250c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fStencilOpSeparate) {
251adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
252bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
2539e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    } else if (kGL_GrGLStandard == fStandard) {
254e788430144d1474329878abd1ddb39cc0ca52a0arobertphillips@google.com
255c82b8899d97c2a26f5991bc771ad3beb8257edaebsalomon@google.com        if (glVer >= GR_GL_VER(2,0)) {
256c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fStencilFuncSeparate ||
257c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilMaskSeparate ||
258c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilOpSeparate) {
259adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
260bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
261bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
262c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) && NULL == fFunctions.fBindFragDataLocation) {
263adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
264bc5cf51627505f763586100675aa60b66d743c7ebsalomon@google.com        }
26590313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) {
266c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fDrawBuffers) {
267adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
268d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com            }
269d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com        }
270e788430144d1474329878abd1ddb39cc0ca52a0arobertphillips@google.com
27190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")) {
272c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fGenQueries ||
273c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteQueries ||
274c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBeginQuery ||
275c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fEndQuery ||
276c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryiv ||
277c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectiv ||
278c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectuiv) {
279adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
280373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
281373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
282373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        if (glVer >= GR_GL_VER(3,3) ||
28390313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_ARB_timer_query") ||
28490313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_timer_query")) {
285c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fGetQueryObjecti64v ||
286c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetQueryObjectui64v) {
287adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
288373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
289373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
29090313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
291c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fQueryCounter) {
292adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
293373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com            }
294373a6635b7190b4af4d265fdd4b70f102ec3a6fdbsalomon@google.com        }
295f66967243c3732523c2035f7d6dbf65c2d20b264commit-bot@chromium.org        if (fExtensions.has("GL_EXT_direct_state_access")) {
296f66967243c3732523c2035f7d6dbf65c2d20b264commit-bot@chromium.org            if (NULL == fFunctions.fMatrixLoadf ||
297f66967243c3732523c2035f7d6dbf65c2d20b264commit-bot@chromium.org                NULL == fFunctions.fMatrixLoadIdentity) {
298adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
29946fbfe0cd1bbe60fd15ce52e784f5d51450ff5fdcommit-bot@chromium.org            }
300fe11cb6486adfccc1a9ca9658ae25907192a8642bsalomon@google.com        }
301d8ed85101ee77ad2cb0c186a79d197698a75d246commit-bot@chromium.org        if (fExtensions.has("GL_NV_path_rendering")) {
302c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fPathCommands ||
303c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathCoords ||
304c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathSubCommands ||
305c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathSubCoords ||
306c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathString ||
307c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathGlyphs ||
308c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathGlyphRange ||
309c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fWeightPaths ||
310c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fCopyPath ||
311c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fInterpolatePaths ||
312c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fTransformPath ||
313c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathParameteriv ||
314c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathParameteri ||
315c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathParameterfv ||
316c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathParameterf ||
317c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathDashArray ||
318c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGenPaths ||
319c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeletePaths ||
320c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fIsPath ||
321c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathStencilFunc ||
322c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathStencilDepthOffset ||
323c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilFillPath ||
324c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilStrokePath ||
325c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilFillPathInstanced ||
326c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fStencilStrokePathInstanced ||
327c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathCoverDepthFunc ||
328c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathColorGen ||
329c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathTexGen ||
330c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPathFogGen ||
331c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fCoverFillPath ||
332c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fCoverStrokePath ||
333c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fCoverFillPathInstanced ||
334c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fCoverStrokePathInstanced ||
335c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathParameteriv ||
336c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathParameterfv ||
337c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathCommands ||
338c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathCoords ||
339c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathDashArray ||
340c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathMetrics ||
341c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathMetricRange ||
342c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathSpacing ||
343c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathColorGeniv ||
344c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathColorGenfv ||
345c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathTexGeniv ||
346c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathTexGenfv ||
347c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fIsPointInFillPath ||
348c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fIsPointInStrokePath ||
349c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGetPathLength ||
350c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fPointAlongPath) {
351adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
352fe11cb6486adfccc1a9ca9658ae25907192a8642bsalomon@google.com            }
353fe11cb6486adfccc1a9ca9658ae25907192a8642bsalomon@google.com        }
354bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
355bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
356bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // optional function on desktop before 1.3
3579e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard != fStandard ||
3581744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com        (glVer >= GR_GL_VER(1,3)) ||
35990313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        fExtensions.has("GL_ARB_texture_compression")) {
360e1f5a23812cab849174a47fae02397e7291f850ekrajcevski        if (NULL == fFunctions.fCompressedTexImage2D
361e1f5a23812cab849174a47fae02397e7291f850ekrajcevski#if 0
362e1f5a23812cab849174a47fae02397e7291f850ekrajcevski            || NULL == fFunctions.fCompressedTexSubImage2D
363e1f5a23812cab849174a47fae02397e7291f850ekrajcevski#endif
364e1f5a23812cab849174a47fae02397e7291f850ekrajcevski            ) {
365adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
366bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
367bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
368bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
369d32c5f564e4aa9ada2650e07d3856d5b21cd2138bsalomon@google.com    // part of desktop GL, but not ES
3709e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard &&
371c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        (NULL == fFunctions.fGetTexLevelParameteriv ||
372c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org         NULL == fFunctions.fDrawBuffer ||
373c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org         NULL == fFunctions.fReadBuffer)) {
374adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org        RETURN_FALSE_INTERFACE
375bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
376cee661af926cc977addc6e039b7022975a448acebsalomon@google.com
377280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    // GL_EXT_texture_storage is part of desktop 4.2
378280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    // There is a desktop ARB extension and an ES+desktop EXT extension
3799e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
380baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        if (glVer >= GR_GL_VER(4,2) ||
38190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_ARB_texture_storage") ||
38290313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_texture_storage")) {
383c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fTexStorage2D) {
384adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
385baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com            }
386baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        }
38790313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
388c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fTexStorage2D) {
389adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
390baa9ea10f9b704f42efc804e7401e0aa519b3e29bsalomon@google.com        }
391280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com    }
392280e99f1a61f2cf66a8ee9b9e6c517f3d2290de7bsalomon@google.com
39390313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    if (fExtensions.has("GL_EXT_discard_framebuffer")) {
394a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com// FIXME: Remove this once Chromium is updated to provide this function
395a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com#if 0
396c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fDiscardFramebuffer) {
397adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
398a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com        }
399a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com#endif
400a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com    }
401a6ffb58b109f71512bde4e14d06a655914578c8drobertphillips@google.com
402bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // FBO MSAA
4039e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
404bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        // GL 3.0 and the ARB extension have multisample + blit
40590313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) {
406c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisample ||
407c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
408adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
409bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
410bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        } else {
41190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            if (fExtensions.has("GL_EXT_framebuffer_blit") &&
412c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
413adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
414bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
41590313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
416c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fRenderbufferStorageMultisample) {
417adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
418bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
419bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
420bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    } else {
42190313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) {
422c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisample ||
423c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fBlitFramebuffer) {
424adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
425a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org            }
426a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org        }
42790313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
428c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
429c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fResolveMultisampleFramebuffer) {
430adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
431bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com            }
432bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
43390313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
43490313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org            fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
435c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fRenderbufferStorageMultisampleES2EXT ||
436c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fFramebufferTexture2DMultisample) {
437adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
438f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com            }
439f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com        }
440bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
441bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
442bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // On ES buffer mapping is an extension. On Desktop
443bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // buffer mapping was part of original VBO extension
444bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    // which we require.
44590313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
446c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fMapBuffer ||
447c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            NULL == fFunctions.fUnmapBuffer) {
448adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
449bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com        }
450bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    }
451bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com
452271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com    // Dual source blending
4539e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard &&
45490313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended"))) {
455c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fBindFragDataLocationIndexed) {
456adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
457271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com        }
458271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com    }
45912eea2b10d6caaafe0a207d10b1e9322510983a2skia.committer@gmail.com
460726e621000582e4de7c9ce0f7e9950c3af4e5d9bcommit-bot@chromium.org    // glGetStringi was added in version 3.0 of both desktop and ES.
461726e621000582e4de7c9ce0f7e9950c3af4e5d9bcommit-bot@chromium.org    if (glVer >= GR_GL_VER(3, 0)) {
462c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org        if (NULL == fFunctions.fGetStringi) {
463adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
4641744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com        }
4651744f97ea73384b9f75b0ccee0a36a213c681d3absalomon@google.com    }
466271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com
4679e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    if (kGL_GrGLStandard == fStandard) {
46890313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
469c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fBindVertexArray ||
470c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteVertexArrays ||
471c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGenVertexArrays) {
472adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
473ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            }
474ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        }
475ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    } else {
47690313cc36a6f43a3e9d3818aca536cd6631c222bcommit-bot@chromium.org        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) {
477c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org            if (NULL == fFunctions.fBindVertexArray ||
478c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fDeleteVertexArrays ||
479c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org                NULL == fFunctions.fGenVertexArrays) {
480adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org                RETURN_FALSE_INTERFACE
481ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            }
482ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        }
483ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    }
484a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org
485a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    if (fExtensions.has("GL_EXT_debug_marker")) {
486a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org        if (NULL == fFunctions.fInsertEventMarker ||
487a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org            NULL == fFunctions.fPushGroupMarker ||
488a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org            NULL == fFunctions.fPopGroupMarker) {
489adadf7c31f964fb98a64d1f59c18fa099888cae5commit-bot@chromium.org            RETURN_FALSE_INTERFACE
490a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org        }
491a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org    }
492a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com
493160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
494160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        fExtensions.has("GL_ARB_invalidate_subdata")) {
495a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        if (NULL == fFunctions.fInvalidateBufferData ||
496a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateBufferSubData ||
497a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateFramebuffer ||
498a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateSubFramebuffer ||
499a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateTexImage ||
500a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateTexSubImage) {
501a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            RETURN_FALSE_INTERFACE;
502a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        }
503160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
504a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        // ES 3.0 adds the framebuffer functions but not the others.
505a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        if (NULL == fFunctions.fInvalidateFramebuffer ||
506a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            NULL == fFunctions.fInvalidateSubFramebuffer) {
507a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com            RETURN_FALSE_INTERFACE;
508a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com        }
509a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com    }
510beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org
511beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org    if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
512beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org        if (NULL == fFunctions.fMapBufferSubData ||
513beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fMapTexSubImage2D ||
514beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fUnmapBufferSubData ||
515beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            NULL == fFunctions.fUnmapTexSubImage2D) {
516beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org            RETURN_FALSE_INTERFACE;
517beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org        }
518beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org    }
519a34bb60c4e319f2289106d519544fe09d43eabd5bsalomon@google.com
520160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    // These functions are added to the 3.0 version of both GLES and GL.
521160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    if (glVer >= GR_GL_VER(3,0) ||
522160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
523160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
524160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        if (NULL == fFunctions.fMapBufferRange ||
525160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            NULL == fFunctions.fFlushMappedBufferRange) {
526160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            RETURN_FALSE_INTERFACE;
527160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        }
528160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    }
529bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com    return true;
530bf2a46941e8fdebfcd24ea8f7184779021898225bsalomon@google.com}
531