blob: b81d9ceeb84b378366a3e119a04e6812496327e9 [file] [log] [blame]
twiz@google.com59a190b2011-03-14 21:23:01 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
twiz@google.com59a190b2011-03-14 21:23:01 +00006 */
7
8
tomhudson@google.com6bf38b52012-02-14 15:11:59 +00009#include "gl/GrGLInterface.h"
bsalomon@google.com1744f972013-02-26 21:46:32 +000010#include "gl/GrGLExtensions.h"
11#include "gl/GrGLUtil.h"
twiz@google.com59a190b2011-03-14 21:23:01 +000012
13#include <stdio.h>
14
bsalomon@google.com56bfc5a2011-09-01 13:28:16 +000015#if GR_GL_PER_GL_FUNC_CALLBACK
16namespace {
17void GrGLDefaultInterfaceCallback(const GrGLInterface*) {}
18}
19#endif
20
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +000021const GrGLInterface* GrGLInterfaceAddTestDebugMarker(const GrGLInterface* interface,
22 GrGLInsertEventMarkerProc insertEventMarkerFn,
23 GrGLPushGroupMarkerProc pushGroupMarkerFn,
24 GrGLPopGroupMarkerProc popGroupMarkerFn) {
25 GrGLInterface* newInterface = GrGLInterface::NewClone(interface);
26
27 if (!newInterface->fExtensions.has("GL_EXT_debug_marker")) {
28 newInterface->fExtensions.add("GL_EXT_debug_marker");
29 }
30
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000031 newInterface->fFunctions.fInsertEventMarker = insertEventMarkerFn;
32 newInterface->fFunctions.fPushGroupMarker = pushGroupMarkerFn;
33 newInterface->fFunctions.fPopGroupMarker = popGroupMarkerFn;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +000034
35 return newInterface;
36}
37
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000038const GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface* interface) {
39 GrGLInterface* newInterface = GrGLInterface::NewClone(interface);
40
41 newInterface->fExtensions.remove("GL_NV_path_rendering");
42
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000043 newInterface->fFunctions.fPathCommands = NULL;
44 newInterface->fFunctions.fPathCoords = NULL;
45 newInterface->fFunctions.fPathSubCommands = NULL;
46 newInterface->fFunctions.fPathSubCoords = NULL;
47 newInterface->fFunctions.fPathString = NULL;
48 newInterface->fFunctions.fPathGlyphs = NULL;
49 newInterface->fFunctions.fPathGlyphRange = NULL;
50 newInterface->fFunctions.fWeightPaths = NULL;
51 newInterface->fFunctions.fCopyPath = NULL;
52 newInterface->fFunctions.fInterpolatePaths = NULL;
53 newInterface->fFunctions.fTransformPath = NULL;
54 newInterface->fFunctions.fPathParameteriv = NULL;
55 newInterface->fFunctions.fPathParameteri = NULL;
56 newInterface->fFunctions.fPathParameterfv = NULL;
57 newInterface->fFunctions.fPathParameterf = NULL;
58 newInterface->fFunctions.fPathDashArray = NULL;
59 newInterface->fFunctions.fGenPaths = NULL;
60 newInterface->fFunctions.fDeletePaths = NULL;
61 newInterface->fFunctions.fIsPath = NULL;
62 newInterface->fFunctions.fPathStencilFunc = NULL;
63 newInterface->fFunctions.fPathStencilDepthOffset = NULL;
64 newInterface->fFunctions.fStencilFillPath = NULL;
65 newInterface->fFunctions.fStencilStrokePath = NULL;
66 newInterface->fFunctions.fStencilFillPathInstanced = NULL;
67 newInterface->fFunctions.fStencilStrokePathInstanced = NULL;
68 newInterface->fFunctions.fPathCoverDepthFunc = NULL;
69 newInterface->fFunctions.fPathColorGen = NULL;
70 newInterface->fFunctions.fPathTexGen = NULL;
71 newInterface->fFunctions.fPathFogGen = NULL;
72 newInterface->fFunctions.fCoverFillPath = NULL;
73 newInterface->fFunctions.fCoverStrokePath = NULL;
74 newInterface->fFunctions.fCoverFillPathInstanced = NULL;
75 newInterface->fFunctions.fCoverStrokePathInstanced = NULL;
76 newInterface->fFunctions.fGetPathParameteriv = NULL;
77 newInterface->fFunctions.fGetPathParameterfv = NULL;
78 newInterface->fFunctions.fGetPathCommands = NULL;
79 newInterface->fFunctions.fGetPathCoords = NULL;
80 newInterface->fFunctions.fGetPathDashArray = NULL;
81 newInterface->fFunctions.fGetPathMetrics = NULL;
82 newInterface->fFunctions.fGetPathMetricRange = NULL;
83 newInterface->fFunctions.fGetPathSpacing = NULL;
84 newInterface->fFunctions.fGetPathColorGeniv = NULL;
85 newInterface->fFunctions.fGetPathColorGenfv = NULL;
86 newInterface->fFunctions.fGetPathTexGeniv = NULL;
87 newInterface->fFunctions.fGetPathTexGenfv = NULL;
88 newInterface->fFunctions.fIsPointInFillPath = NULL;
89 newInterface->fFunctions.fIsPointInStrokePath = NULL;
90 newInterface->fFunctions.fGetPathLength = NULL;
91 newInterface->fFunctions.fPointAlongPath = NULL;
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000092
93 return newInterface;
94}
95
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000096GrGLInterface::GrGLInterface() {
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000097 fStandard = kNone_GrGLStandard;
bsalomon@google.com0b77d682011-08-19 13:28:54 +000098
bsalomon@google.com56bfc5a2011-09-01 13:28:16 +000099#if GR_GL_PER_GL_FUNC_CALLBACK
100 fCallback = GrGLDefaultInterfaceCallback;
101 fCallbackData = 0;
102#endif
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000103}
104
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +0000105GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
106 SkASSERT(NULL != interface);
107
108 GrGLInterface* clone = SkNEW(GrGLInterface);
109 clone->fStandard = interface->fStandard;
110 clone->fExtensions = interface->fExtensions;
111 clone->fFunctions = interface->fFunctions;
112#if GR_GL_PER_GL_FUNC_CALLBACK
113 clone->fCallback = interface->fCallback;
114 clone->fCallbackData = interface->fCallbackData;
115#endif
116 return clone;
117}
118
commit-bot@chromium.orge83b9b72014-05-01 19:21:41 +0000119#ifdef SK_DEBUG
120 static int kIsDebug = 1;
121#else
122 static int kIsDebug = 0;
123#endif
124
125#define RETURN_FALSE_INTERFACE \
126 if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \
127 return false;
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000128
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000129bool GrGLInterface::validate() const {
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000130
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000131 if (kNone_GrGLStandard == fStandard) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000132 RETURN_FALSE_INTERFACE
bsalomon@google.com1dcf5062011-11-14 19:29:53 +0000133 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +0000134
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000135 if (!fExtensions.isInitialized()) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000136 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +0000137 }
bsalomon@google.com1dcf5062011-11-14 19:29:53 +0000138
139 // functions that are always required
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000140 if (NULL == fFunctions.fActiveTexture ||
141 NULL == fFunctions.fAttachShader ||
142 NULL == fFunctions.fBindAttribLocation ||
143 NULL == fFunctions.fBindBuffer ||
144 NULL == fFunctions.fBindTexture ||
145 NULL == fFunctions.fBlendFunc ||
146 NULL == fFunctions.fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension
147 NULL == fFunctions.fBufferData ||
148 NULL == fFunctions.fBufferSubData ||
149 NULL == fFunctions.fClear ||
150 NULL == fFunctions.fClearColor ||
151 NULL == fFunctions.fClearStencil ||
152 NULL == fFunctions.fColorMask ||
153 NULL == fFunctions.fCompileShader ||
154 NULL == fFunctions.fCopyTexSubImage2D ||
155 NULL == fFunctions.fCreateProgram ||
156 NULL == fFunctions.fCreateShader ||
157 NULL == fFunctions.fCullFace ||
158 NULL == fFunctions.fDeleteBuffers ||
159 NULL == fFunctions.fDeleteProgram ||
160 NULL == fFunctions.fDeleteShader ||
161 NULL == fFunctions.fDeleteTextures ||
162 NULL == fFunctions.fDepthMask ||
163 NULL == fFunctions.fDisable ||
164 NULL == fFunctions.fDisableVertexAttribArray ||
165 NULL == fFunctions.fDrawArrays ||
166 NULL == fFunctions.fDrawElements ||
167 NULL == fFunctions.fEnable ||
168 NULL == fFunctions.fEnableVertexAttribArray ||
169 NULL == fFunctions.fFrontFace ||
170 NULL == fFunctions.fGenBuffers ||
171 NULL == fFunctions.fGenTextures ||
172 NULL == fFunctions.fGetBufferParameteriv ||
173 NULL == fFunctions.fGenerateMipmap ||
174 NULL == fFunctions.fGetError ||
175 NULL == fFunctions.fGetIntegerv ||
176 NULL == fFunctions.fGetProgramInfoLog ||
177 NULL == fFunctions.fGetProgramiv ||
178 NULL == fFunctions.fGetShaderInfoLog ||
179 NULL == fFunctions.fGetShaderiv ||
180 NULL == fFunctions.fGetString ||
181 NULL == fFunctions.fGetUniformLocation ||
182 NULL == fFunctions.fLinkProgram ||
183 NULL == fFunctions.fLineWidth ||
184 NULL == fFunctions.fPixelStorei ||
185 NULL == fFunctions.fReadPixels ||
186 NULL == fFunctions.fScissor ||
187 NULL == fFunctions.fShaderSource ||
188 NULL == fFunctions.fStencilFunc ||
189 NULL == fFunctions.fStencilMask ||
190 NULL == fFunctions.fStencilOp ||
191 NULL == fFunctions.fTexImage2D ||
192 NULL == fFunctions.fTexParameteri ||
193 NULL == fFunctions.fTexParameteriv ||
194 NULL == fFunctions.fTexSubImage2D ||
195 NULL == fFunctions.fUniform1f ||
196 NULL == fFunctions.fUniform1i ||
197 NULL == fFunctions.fUniform1fv ||
198 NULL == fFunctions.fUniform1iv ||
199 NULL == fFunctions.fUniform2f ||
200 NULL == fFunctions.fUniform2i ||
201 NULL == fFunctions.fUniform2fv ||
202 NULL == fFunctions.fUniform2iv ||
203 NULL == fFunctions.fUniform3f ||
204 NULL == fFunctions.fUniform3i ||
205 NULL == fFunctions.fUniform3fv ||
206 NULL == fFunctions.fUniform3iv ||
207 NULL == fFunctions.fUniform4f ||
208 NULL == fFunctions.fUniform4i ||
209 NULL == fFunctions.fUniform4fv ||
210 NULL == fFunctions.fUniform4iv ||
211 NULL == fFunctions.fUniformMatrix2fv ||
212 NULL == fFunctions.fUniformMatrix3fv ||
213 NULL == fFunctions.fUniformMatrix4fv ||
214 NULL == fFunctions.fUseProgram ||
215 NULL == fFunctions.fVertexAttrib4fv ||
216 NULL == fFunctions.fVertexAttribPointer ||
217 NULL == fFunctions.fViewport ||
218 NULL == fFunctions.fBindFramebuffer ||
219 NULL == fFunctions.fBindRenderbuffer ||
220 NULL == fFunctions.fCheckFramebufferStatus ||
221 NULL == fFunctions.fDeleteFramebuffers ||
222 NULL == fFunctions.fDeleteRenderbuffers ||
223 NULL == fFunctions.fFinish ||
224 NULL == fFunctions.fFlush ||
225 NULL == fFunctions.fFramebufferRenderbuffer ||
226 NULL == fFunctions.fFramebufferTexture2D ||
227 NULL == fFunctions.fGetFramebufferAttachmentParameteriv ||
228 NULL == fFunctions.fGetRenderbufferParameteriv ||
229 NULL == fFunctions.fGenFramebuffers ||
230 NULL == fFunctions.fGenRenderbuffers ||
231 NULL == fFunctions.fRenderbufferStorage) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000232 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000233 }
234
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000235 GrGLVersion glVer = GrGLGetVersion(this);
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000236 if (GR_GL_INVALID_VER == glVer) {
237 RETURN_FALSE_INTERFACE
238 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000239
240 // Now check that baseline ES/Desktop fns not covered above are present
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000241 // and that we have fn pointers for any advertised fExtensions that we will
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000242 // try to use.
243
244 // these functions are part of ES2, we assume they are available
245 // On the desktop we assume they are available if the extension
246 // is present or GL version is high enough.
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000247 if (kGLES_GrGLStandard == fStandard) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000248 if (NULL == fFunctions.fStencilFuncSeparate ||
249 NULL == fFunctions.fStencilMaskSeparate ||
250 NULL == fFunctions.fStencilOpSeparate) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000251 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000252 }
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000253 } else if (kGL_GrGLStandard == fStandard) {
robertphillips@google.come7884302012-04-18 14:39:58 +0000254
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000255 if (glVer >= GR_GL_VER(2,0)) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000256 if (NULL == fFunctions.fStencilFuncSeparate ||
257 NULL == fFunctions.fStencilMaskSeparate ||
258 NULL == fFunctions.fStencilOpSeparate) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000259 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000260 }
261 }
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000262 if (glVer >= GR_GL_VER(3,0) && NULL == fFunctions.fBindFragDataLocation) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000263 RETURN_FALSE_INTERFACE
bsalomon@google.combc5cf512011-09-21 16:21:07 +0000264 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000265 if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000266 if (NULL == fFunctions.fDrawBuffers) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000267 RETURN_FALSE_INTERFACE
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000268 }
269 }
robertphillips@google.come7884302012-04-18 14:39:58 +0000270
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000271 if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000272 if (NULL == fFunctions.fGenQueries ||
273 NULL == fFunctions.fDeleteQueries ||
274 NULL == fFunctions.fBeginQuery ||
275 NULL == fFunctions.fEndQuery ||
276 NULL == fFunctions.fGetQueryiv ||
277 NULL == fFunctions.fGetQueryObjectiv ||
278 NULL == fFunctions.fGetQueryObjectuiv) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000279 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000280 }
281 }
282 if (glVer >= GR_GL_VER(3,3) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000283 fExtensions.has("GL_ARB_timer_query") ||
284 fExtensions.has("GL_EXT_timer_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000285 if (NULL == fFunctions.fGetQueryObjecti64v ||
286 NULL == fFunctions.fGetQueryObjectui64v) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000287 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000288 }
289 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000290 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000291 if (NULL == fFunctions.fQueryCounter) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000292 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000293 }
294 }
commit-bot@chromium.orgf6696722014-04-25 06:21:30 +0000295 if (fExtensions.has("GL_EXT_direct_state_access")) {
296 if (NULL == fFunctions.fMatrixLoadf ||
297 NULL == fFunctions.fMatrixLoadIdentity) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000298 RETURN_FALSE_INTERFACE
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000299 }
bsalomon@google.comfe11cb62012-06-06 15:17:54 +0000300 }
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +0000301 if (fExtensions.has("GL_NV_path_rendering")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000302 if (NULL == fFunctions.fPathCommands ||
303 NULL == fFunctions.fPathCoords ||
304 NULL == fFunctions.fPathSubCommands ||
305 NULL == fFunctions.fPathSubCoords ||
306 NULL == fFunctions.fPathString ||
307 NULL == fFunctions.fPathGlyphs ||
308 NULL == fFunctions.fPathGlyphRange ||
309 NULL == fFunctions.fWeightPaths ||
310 NULL == fFunctions.fCopyPath ||
311 NULL == fFunctions.fInterpolatePaths ||
312 NULL == fFunctions.fTransformPath ||
313 NULL == fFunctions.fPathParameteriv ||
314 NULL == fFunctions.fPathParameteri ||
315 NULL == fFunctions.fPathParameterfv ||
316 NULL == fFunctions.fPathParameterf ||
317 NULL == fFunctions.fPathDashArray ||
318 NULL == fFunctions.fGenPaths ||
319 NULL == fFunctions.fDeletePaths ||
320 NULL == fFunctions.fIsPath ||
321 NULL == fFunctions.fPathStencilFunc ||
322 NULL == fFunctions.fPathStencilDepthOffset ||
323 NULL == fFunctions.fStencilFillPath ||
324 NULL == fFunctions.fStencilStrokePath ||
325 NULL == fFunctions.fStencilFillPathInstanced ||
326 NULL == fFunctions.fStencilStrokePathInstanced ||
327 NULL == fFunctions.fPathCoverDepthFunc ||
328 NULL == fFunctions.fPathColorGen ||
329 NULL == fFunctions.fPathTexGen ||
330 NULL == fFunctions.fPathFogGen ||
331 NULL == fFunctions.fCoverFillPath ||
332 NULL == fFunctions.fCoverStrokePath ||
333 NULL == fFunctions.fCoverFillPathInstanced ||
334 NULL == fFunctions.fCoverStrokePathInstanced ||
335 NULL == fFunctions.fGetPathParameteriv ||
336 NULL == fFunctions.fGetPathParameterfv ||
337 NULL == fFunctions.fGetPathCommands ||
338 NULL == fFunctions.fGetPathCoords ||
339 NULL == fFunctions.fGetPathDashArray ||
340 NULL == fFunctions.fGetPathMetrics ||
341 NULL == fFunctions.fGetPathMetricRange ||
342 NULL == fFunctions.fGetPathSpacing ||
343 NULL == fFunctions.fGetPathColorGeniv ||
344 NULL == fFunctions.fGetPathColorGenfv ||
345 NULL == fFunctions.fGetPathTexGeniv ||
346 NULL == fFunctions.fGetPathTexGenfv ||
347 NULL == fFunctions.fIsPointInFillPath ||
348 NULL == fFunctions.fIsPointInStrokePath ||
349 NULL == fFunctions.fGetPathLength ||
350 NULL == fFunctions.fPointAlongPath) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000351 RETURN_FALSE_INTERFACE
bsalomon@google.comfe11cb62012-06-06 15:17:54 +0000352 }
353 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000354 }
355
356 // optional function on desktop before 1.3
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000357 if (kGL_GrGLStandard != fStandard ||
bsalomon@google.com1744f972013-02-26 21:46:32 +0000358 (glVer >= GR_GL_VER(1,3)) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000359 fExtensions.has("GL_ARB_texture_compression")) {
krajcevskie1f5a232014-06-11 16:08:50 -0700360 if (NULL == fFunctions.fCompressedTexImage2D
361#if 0
362 || NULL == fFunctions.fCompressedTexSubImage2D
363#endif
364 ) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000365 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000366 }
367 }
368
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000369 // part of desktop GL, but not ES
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000370 if (kGL_GrGLStandard == fStandard &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000371 (NULL == fFunctions.fGetTexLevelParameteriv ||
372 NULL == fFunctions.fDrawBuffer ||
373 NULL == fFunctions.fReadBuffer)) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000374 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000375 }
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000376
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000377 // GL_EXT_texture_storage is part of desktop 4.2
378 // There is a desktop ARB extension and an ES+desktop EXT extension
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000379 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000380 if (glVer >= GR_GL_VER(4,2) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000381 fExtensions.has("GL_ARB_texture_storage") ||
382 fExtensions.has("GL_EXT_texture_storage")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000383 if (NULL == fFunctions.fTexStorage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000384 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000385 }
386 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000387 } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000388 if (NULL == fFunctions.fTexStorage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000389 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000390 }
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000391 }
392
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000393 if (fExtensions.has("GL_EXT_discard_framebuffer")) {
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000394// FIXME: Remove this once Chromium is updated to provide this function
395#if 0
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000396 if (NULL == fFunctions.fDiscardFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000397 RETURN_FALSE_INTERFACE
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000398 }
399#endif
400 }
401
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000402 // FBO MSAA
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000403 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000404 // GL 3.0 and the ARB extension have multisample + blit
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000405 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000406 if (NULL == fFunctions.fRenderbufferStorageMultisample ||
407 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000408 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000409 }
410 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000411 if (fExtensions.has("GL_EXT_framebuffer_blit") &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000412 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000413 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000414 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000415 if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000416 NULL == fFunctions.fRenderbufferStorageMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000417 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000418 }
419 }
420 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000421 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000422 if (NULL == fFunctions.fRenderbufferStorageMultisample ||
423 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000424 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000425 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000426 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000427 if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000428 if (NULL == fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
429 NULL == fFunctions.fResolveMultisampleFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000430 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000431 }
432 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000433 if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
434 fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000435 if (NULL == fFunctions.fRenderbufferStorageMultisampleES2EXT ||
436 NULL == fFunctions.fFramebufferTexture2DMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000437 RETURN_FALSE_INTERFACE
bsalomon@google.comf3a60c02013-03-19 19:06:09 +0000438 }
439 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000440 }
441
442 // On ES buffer mapping is an extension. On Desktop
443 // buffer mapping was part of original VBO extension
444 // which we require.
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000445 if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000446 if (NULL == fFunctions.fMapBuffer ||
447 NULL == fFunctions.fUnmapBuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000448 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000449 }
450 }
451
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000452 // Dual source blending
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000453 if (kGL_GrGLStandard == fStandard &&
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000454 (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended"))) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000455 if (NULL == fFunctions.fBindFragDataLocationIndexed) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000456 RETURN_FALSE_INTERFACE
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000457 }
458 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +0000459
commit-bot@chromium.org726e6212013-08-23 20:55:46 +0000460 // glGetStringi was added in version 3.0 of both desktop and ES.
461 if (glVer >= GR_GL_VER(3, 0)) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000462 if (NULL == fFunctions.fGetStringi) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000463 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +0000464 }
465 }
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000466
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000467 if (kGL_GrGLStandard == fStandard) {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000468 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000469 if (NULL == fFunctions.fBindVertexArray ||
470 NULL == fFunctions.fDeleteVertexArrays ||
471 NULL == fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000472 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000473 }
474 }
475 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000476 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000477 if (NULL == fFunctions.fBindVertexArray ||
478 NULL == fFunctions.fDeleteVertexArrays ||
479 NULL == fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000480 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000481 }
482 }
bsalomon@google.comecd84842013-03-01 15:36:02 +0000483 }
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000484
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000485 if (fExtensions.has("GL_EXT_debug_marker")) {
486 if (NULL == fFunctions.fInsertEventMarker ||
487 NULL == fFunctions.fPushGroupMarker ||
488 NULL == fFunctions.fPopGroupMarker) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000489 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000490 }
491 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000492
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000493 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
494 fExtensions.has("GL_ARB_invalidate_subdata")) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000495 if (NULL == fFunctions.fInvalidateBufferData ||
496 NULL == fFunctions.fInvalidateBufferSubData ||
497 NULL == fFunctions.fInvalidateFramebuffer ||
498 NULL == fFunctions.fInvalidateSubFramebuffer ||
499 NULL == fFunctions.fInvalidateTexImage ||
500 NULL == fFunctions.fInvalidateTexSubImage) {
501 RETURN_FALSE_INTERFACE;
502 }
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000503 } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000504 // ES 3.0 adds the framebuffer functions but not the others.
505 if (NULL == fFunctions.fInvalidateFramebuffer ||
506 NULL == fFunctions.fInvalidateSubFramebuffer) {
507 RETURN_FALSE_INTERFACE;
508 }
509 }
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000510
511 if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
512 if (NULL == fFunctions.fMapBufferSubData ||
513 NULL == fFunctions.fMapTexSubImage2D ||
514 NULL == fFunctions.fUnmapBufferSubData ||
515 NULL == fFunctions.fUnmapTexSubImage2D) {
516 RETURN_FALSE_INTERFACE;
517 }
518 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000519
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000520 // These functions are added to the 3.0 version of both GLES and GL.
521 if (glVer >= GR_GL_VER(3,0) ||
522 (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
523 (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
524 if (NULL == fFunctions.fMapBufferRange ||
525 NULL == fFunctions.fFlushMappedBufferRange) {
526 RETURN_FALSE_INTERFACE;
527 }
528 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000529 return true;
530}