twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * 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.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | |
tomhudson@google.com | 6bf38b5 | 2012-02-14 15:11:59 +0000 | [diff] [blame] | 9 | #include "gl/GrGLInterface.h" |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 10 | #include "gl/GrGLExtensions.h" |
| 11 | #include "gl/GrGLUtil.h" |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 12 | |
| 13 | #include <stdio.h> |
| 14 | |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 15 | #if GR_GL_PER_GL_FUNC_CALLBACK |
| 16 | namespace { |
| 17 | void GrGLDefaultInterfaceCallback(const GrGLInterface*) {} |
| 18 | } |
| 19 | #endif |
| 20 | |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 21 | const 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.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 31 | newInterface->fFunctions.fInsertEventMarker = insertEventMarkerFn; |
| 32 | newInterface->fFunctions.fPushGroupMarker = pushGroupMarkerFn; |
| 33 | newInterface->fFunctions.fPopGroupMarker = popGroupMarkerFn; |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 34 | |
| 35 | return newInterface; |
| 36 | } |
| 37 | |
commit-bot@chromium.org | d8ed851 | 2014-01-24 20:49:44 +0000 | [diff] [blame] | 38 | const GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface* interface) { |
| 39 | GrGLInterface* newInterface = GrGLInterface::NewClone(interface); |
| 40 | |
| 41 | newInterface->fExtensions.remove("GL_NV_path_rendering"); |
| 42 | |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 43 | 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.org | d8ed851 | 2014-01-24 20:49:44 +0000 | [diff] [blame] | 92 | |
| 93 | return newInterface; |
| 94 | } |
| 95 | |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 96 | GrGLInterface::GrGLInterface() { |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 97 | fStandard = kNone_GrGLStandard; |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 98 | |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 99 | #if GR_GL_PER_GL_FUNC_CALLBACK |
| 100 | fCallback = GrGLDefaultInterfaceCallback; |
| 101 | fCallbackData = 0; |
| 102 | #endif |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 103 | } |
| 104 | |
commit-bot@chromium.org | d8ed851 | 2014-01-24 20:49:44 +0000 | [diff] [blame] | 105 | GrGLInterface* 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.org | e83b9b7 | 2014-05-01 19:21:41 +0000 | [diff] [blame] | 119 | #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.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 128 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 129 | bool GrGLInterface::validate() const { |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 130 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 131 | if (kNone_GrGLStandard == fStandard) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 132 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 133 | } |
skia.committer@gmail.com | 12eea2b | 2013-02-27 07:10:10 +0000 | [diff] [blame] | 134 | |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 135 | if (!fExtensions.isInitialized()) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 136 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 137 | } |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 138 | |
| 139 | // functions that are always required |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 140 | 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.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 232 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 233 | } |
| 234 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 235 | GrGLVersion glVer = GrGLGetVersion(this); |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 236 | if (GR_GL_INVALID_VER == glVer) { |
| 237 | RETURN_FALSE_INTERFACE |
| 238 | } |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 239 | |
| 240 | // Now check that baseline ES/Desktop fns not covered above are present |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 241 | // and that we have fn pointers for any advertised fExtensions that we will |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 242 | // 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.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 247 | if (kGLES_GrGLStandard == fStandard) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 248 | if (NULL == fFunctions.fStencilFuncSeparate || |
| 249 | NULL == fFunctions.fStencilMaskSeparate || |
| 250 | NULL == fFunctions.fStencilOpSeparate) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 251 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 252 | } |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 253 | } else if (kGL_GrGLStandard == fStandard) { |
robertphillips@google.com | e788430 | 2012-04-18 14:39:58 +0000 | [diff] [blame] | 254 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 255 | if (glVer >= GR_GL_VER(2,0)) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 256 | if (NULL == fFunctions.fStencilFuncSeparate || |
| 257 | NULL == fFunctions.fStencilMaskSeparate || |
| 258 | NULL == fFunctions.fStencilOpSeparate) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 259 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 260 | } |
| 261 | } |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 262 | if (glVer >= GR_GL_VER(3,0) && NULL == fFunctions.fBindFragDataLocation) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 263 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bc5cf51 | 2011-09-21 16:21:07 +0000 | [diff] [blame] | 264 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 265 | if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 266 | if (NULL == fFunctions.fDrawBuffers) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 267 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | d32c5f5 | 2011-08-02 19:29:03 +0000 | [diff] [blame] | 268 | } |
| 269 | } |
robertphillips@google.com | e788430 | 2012-04-18 14:39:58 +0000 | [diff] [blame] | 270 | |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 271 | if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 272 | 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.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 279 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | if (glVer >= GR_GL_VER(3,3) || |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 283 | fExtensions.has("GL_ARB_timer_query") || |
| 284 | fExtensions.has("GL_EXT_timer_query")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 285 | if (NULL == fFunctions.fGetQueryObjecti64v || |
| 286 | NULL == fFunctions.fGetQueryObjectui64v) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 287 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 288 | } |
| 289 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 290 | if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 291 | if (NULL == fFunctions.fQueryCounter) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 292 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 293 | } |
| 294 | } |
commit-bot@chromium.org | f669672 | 2014-04-25 06:21:30 +0000 | [diff] [blame] | 295 | if (fExtensions.has("GL_EXT_direct_state_access")) { |
| 296 | if (NULL == fFunctions.fMatrixLoadf || |
| 297 | NULL == fFunctions.fMatrixLoadIdentity) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 298 | RETURN_FALSE_INTERFACE |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame] | 299 | } |
bsalomon@google.com | fe11cb6 | 2012-06-06 15:17:54 +0000 | [diff] [blame] | 300 | } |
commit-bot@chromium.org | d8ed851 | 2014-01-24 20:49:44 +0000 | [diff] [blame] | 301 | if (fExtensions.has("GL_NV_path_rendering")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 302 | 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.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 351 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | fe11cb6 | 2012-06-06 15:17:54 +0000 | [diff] [blame] | 352 | } |
| 353 | } |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | // optional function on desktop before 1.3 |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 357 | if (kGL_GrGLStandard != fStandard || |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 358 | (glVer >= GR_GL_VER(1,3)) || |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 359 | fExtensions.has("GL_ARB_texture_compression")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 360 | if (NULL == fFunctions.fCompressedTexImage2D) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 361 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 362 | } |
| 363 | } |
| 364 | |
bsalomon@google.com | d32c5f5 | 2011-08-02 19:29:03 +0000 | [diff] [blame] | 365 | // part of desktop GL, but not ES |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 366 | if (kGL_GrGLStandard == fStandard && |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 367 | (NULL == fFunctions.fGetTexLevelParameteriv || |
| 368 | NULL == fFunctions.fDrawBuffer || |
| 369 | NULL == fFunctions.fReadBuffer)) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 370 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 371 | } |
bsalomon@google.com | cee661a | 2011-07-26 12:32:36 +0000 | [diff] [blame] | 372 | |
bsalomon@google.com | 280e99f | 2012-01-05 16:17:38 +0000 | [diff] [blame] | 373 | // GL_EXT_texture_storage is part of desktop 4.2 |
| 374 | // There is a desktop ARB extension and an ES+desktop EXT extension |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 375 | if (kGL_GrGLStandard == fStandard) { |
bsalomon@google.com | baa9ea1 | 2012-01-06 19:05:43 +0000 | [diff] [blame] | 376 | if (glVer >= GR_GL_VER(4,2) || |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 377 | fExtensions.has("GL_ARB_texture_storage") || |
| 378 | fExtensions.has("GL_EXT_texture_storage")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 379 | if (NULL == fFunctions.fTexStorage2D) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 380 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | baa9ea1 | 2012-01-06 19:05:43 +0000 | [diff] [blame] | 381 | } |
| 382 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 383 | } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 384 | if (NULL == fFunctions.fTexStorage2D) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 385 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | baa9ea1 | 2012-01-06 19:05:43 +0000 | [diff] [blame] | 386 | } |
bsalomon@google.com | 280e99f | 2012-01-05 16:17:38 +0000 | [diff] [blame] | 387 | } |
| 388 | |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 389 | if (fExtensions.has("GL_EXT_discard_framebuffer")) { |
robertphillips@google.com | a6ffb58 | 2013-04-29 16:50:17 +0000 | [diff] [blame] | 390 | // FIXME: Remove this once Chromium is updated to provide this function |
| 391 | #if 0 |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 392 | if (NULL == fFunctions.fDiscardFramebuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 393 | RETURN_FALSE_INTERFACE |
robertphillips@google.com | a6ffb58 | 2013-04-29 16:50:17 +0000 | [diff] [blame] | 394 | } |
| 395 | #endif |
| 396 | } |
| 397 | |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 398 | // FBO MSAA |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 399 | if (kGL_GrGLStandard == fStandard) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 400 | // GL 3.0 and the ARB extension have multisample + blit |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 401 | if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 402 | if (NULL == fFunctions.fRenderbufferStorageMultisample || |
| 403 | NULL == fFunctions.fBlitFramebuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 404 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 405 | } |
| 406 | } else { |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 407 | if (fExtensions.has("GL_EXT_framebuffer_blit") && |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 408 | NULL == fFunctions.fBlitFramebuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 409 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 410 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 411 | if (fExtensions.has("GL_EXT_framebuffer_multisample") && |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 412 | NULL == fFunctions.fRenderbufferStorageMultisample) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 413 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 414 | } |
| 415 | } |
| 416 | } else { |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 417 | if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 418 | if (NULL == fFunctions.fRenderbufferStorageMultisample || |
| 419 | NULL == fFunctions.fBlitFramebuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 420 | RETURN_FALSE_INTERFACE |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 421 | } |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 422 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 423 | if (fExtensions.has("GL_APPLE_framebuffer_multisample")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 424 | if (NULL == fFunctions.fRenderbufferStorageMultisampleES2APPLE || |
| 425 | NULL == fFunctions.fResolveMultisampleFramebuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 426 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 427 | } |
| 428 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 429 | if (fExtensions.has("GL_IMG_multisampled_render_to_texture") || |
| 430 | fExtensions.has("GL_EXT_multisampled_render_to_texture")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 431 | if (NULL == fFunctions.fRenderbufferStorageMultisampleES2EXT || |
| 432 | NULL == fFunctions.fFramebufferTexture2DMultisample) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 433 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | f3a60c0 | 2013-03-19 19:06:09 +0000 | [diff] [blame] | 434 | } |
| 435 | } |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | // On ES buffer mapping is an extension. On Desktop |
| 439 | // buffer mapping was part of original VBO extension |
| 440 | // which we require. |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 441 | if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 442 | if (NULL == fFunctions.fMapBuffer || |
| 443 | NULL == fFunctions.fUnmapBuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 444 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 445 | } |
| 446 | } |
| 447 | |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 448 | // Dual source blending |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 449 | if (kGL_GrGLStandard == fStandard && |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 450 | (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended"))) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 451 | if (NULL == fFunctions.fBindFragDataLocationIndexed) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 452 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 453 | } |
| 454 | } |
skia.committer@gmail.com | 12eea2b | 2013-02-27 07:10:10 +0000 | [diff] [blame] | 455 | |
commit-bot@chromium.org | 726e621 | 2013-08-23 20:55:46 +0000 | [diff] [blame] | 456 | // glGetStringi was added in version 3.0 of both desktop and ES. |
| 457 | if (glVer >= GR_GL_VER(3, 0)) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 458 | if (NULL == fFunctions.fGetStringi) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 459 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 460 | } |
| 461 | } |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 462 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 463 | if (kGL_GrGLStandard == fStandard) { |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 464 | if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 465 | if (NULL == fFunctions.fBindVertexArray || |
| 466 | NULL == fFunctions.fDeleteVertexArrays || |
| 467 | NULL == fFunctions.fGenVertexArrays) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 468 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | ecd8484 | 2013-03-01 15:36:02 +0000 | [diff] [blame] | 469 | } |
| 470 | } |
| 471 | } else { |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 472 | if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 473 | if (NULL == fFunctions.fBindVertexArray || |
| 474 | NULL == fFunctions.fDeleteVertexArrays || |
| 475 | NULL == fFunctions.fGenVertexArrays) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 476 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | ecd8484 | 2013-03-01 15:36:02 +0000 | [diff] [blame] | 477 | } |
| 478 | } |
bsalomon@google.com | ecd8484 | 2013-03-01 15:36:02 +0000 | [diff] [blame] | 479 | } |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 480 | |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 481 | if (fExtensions.has("GL_EXT_debug_marker")) { |
| 482 | if (NULL == fFunctions.fInsertEventMarker || |
| 483 | NULL == fFunctions.fPushGroupMarker || |
| 484 | NULL == fFunctions.fPopGroupMarker) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 485 | RETURN_FALSE_INTERFACE |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 486 | } |
| 487 | } |
bsalomon@google.com | a34bb60 | 2014-04-01 13:07:29 +0000 | [diff] [blame] | 488 | |
djsollen@google.com | 53b614b | 2014-05-02 17:44:34 +0000 | [diff] [blame] | 489 | #if 0 // This can be enabled once Chromium is updated to set these functions pointers. |
| 490 | if ((kGL_GrGLStandard == fStandard) || fExtensions.has("GL_ARB_invalidate_subdata")) { |
bsalomon@google.com | a34bb60 | 2014-04-01 13:07:29 +0000 | [diff] [blame] | 491 | if (NULL == fFunctions.fInvalidateBufferData || |
| 492 | NULL == fFunctions.fInvalidateBufferSubData || |
| 493 | NULL == fFunctions.fInvalidateFramebuffer || |
| 494 | NULL == fFunctions.fInvalidateSubFramebuffer || |
| 495 | NULL == fFunctions.fInvalidateTexImage || |
| 496 | NULL == fFunctions.fInvalidateTexSubImage) { |
| 497 | RETURN_FALSE_INTERFACE; |
| 498 | } |
djsollen@google.com | 53b614b | 2014-05-02 17:44:34 +0000 | [diff] [blame] | 499 | } else if (glVer >= GR_GL_VER(3,0)) { |
bsalomon@google.com | a34bb60 | 2014-04-01 13:07:29 +0000 | [diff] [blame] | 500 | // ES 3.0 adds the framebuffer functions but not the others. |
| 501 | if (NULL == fFunctions.fInvalidateFramebuffer || |
| 502 | NULL == fFunctions.fInvalidateSubFramebuffer) { |
| 503 | RETURN_FALSE_INTERFACE; |
| 504 | } |
| 505 | } |
commit-bot@chromium.org | beb8b3a | 2014-04-15 15:37:51 +0000 | [diff] [blame] | 506 | |
| 507 | if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) { |
| 508 | if (NULL == fFunctions.fMapBufferSubData || |
| 509 | NULL == fFunctions.fMapTexSubImage2D || |
| 510 | NULL == fFunctions.fUnmapBufferSubData || |
| 511 | NULL == fFunctions.fUnmapTexSubImage2D) { |
| 512 | RETURN_FALSE_INTERFACE; |
| 513 | } |
| 514 | } |
djsollen@google.com | 53b614b | 2014-05-02 17:44:34 +0000 | [diff] [blame] | 515 | #endif |
bsalomon@google.com | a34bb60 | 2014-04-01 13:07:29 +0000 | [diff] [blame] | 516 | |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 517 | return true; |
| 518 | } |