Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(876)

Side by Side Diff: src/gpu/gl/GrGLInterface.cpp

Issue 133073009: Move GrGLInterface function pointers into a nested struct (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: tip of tree Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "gl/GrGLInterface.h" 9 #include "gl/GrGLInterface.h"
10 #include "gl/GrGLExtensions.h" 10 #include "gl/GrGLExtensions.h"
11 #include "gl/GrGLUtil.h" 11 #include "gl/GrGLUtil.h"
12 12
13 #include <stdio.h> 13 #include <stdio.h>
14 14
15 #if GR_GL_PER_GL_FUNC_CALLBACK 15 #if GR_GL_PER_GL_FUNC_CALLBACK
16 namespace { 16 namespace {
17 void GrGLDefaultInterfaceCallback(const GrGLInterface*) {} 17 void GrGLDefaultInterfaceCallback(const GrGLInterface*) {}
18 } 18 }
19 #endif 19 #endif
20 20
21 GrGLInterface::GrGLInterface() { 21 GrGLInterface::GrGLInterface()
22 // TODO: Remove this madness ASAP.
23 : fActiveTexture(&fFunctions.fActiveTexture)
24 , fAttachShader(&fFunctions.fAttachShader)
25 , fBeginQuery(&fFunctions.fBeginQuery)
26 , fBindAttribLocation(&fFunctions.fBindAttribLocation)
27 , fBindBuffer(&fFunctions.fBindBuffer)
28 , fBindFragDataLocation(&fFunctions.fBindFragDataLocation)
29 , fBindFragDataLocationIndexed(&fFunctions.fBindFragDataLocationIndexed)
30 , fBindFramebuffer(&fFunctions.fBindFramebuffer)
31 , fBindRenderbuffer(&fFunctions.fBindRenderbuffer)
32 , fBindTexture(&fFunctions.fBindTexture)
33 , fBindVertexArray(&fFunctions.fBindVertexArray)
34 , fBlendColor(&fFunctions.fBlendColor)
35 , fBlendFunc(&fFunctions.fBlendFunc)
36 , fBlitFramebuffer(&fFunctions.fBlitFramebuffer)
37 , fBufferData(&fFunctions.fBufferData)
38 , fBufferSubData(&fFunctions.fBufferSubData)
39 , fCheckFramebufferStatus(&fFunctions.fCheckFramebufferStatus)
40 , fClear(&fFunctions.fClear)
41 , fClearColor(&fFunctions.fClearColor)
42 , fClearStencil(&fFunctions.fClearStencil)
43 , fClientActiveTexture(&fFunctions.fClientActiveTexture)
44 , fColorMask(&fFunctions.fColorMask)
45 , fCompileShader(&fFunctions.fCompileShader)
46 , fCompressedTexImage2D(&fFunctions.fCompressedTexImage2D)
47 , fCopyTexSubImage2D(&fFunctions.fCopyTexSubImage2D)
48 , fCreateProgram(&fFunctions.fCreateProgram)
49 , fCreateShader(&fFunctions.fCreateShader)
50 , fCullFace(&fFunctions.fCullFace)
51 , fDeleteBuffers(&fFunctions.fDeleteBuffers)
52 , fDeleteFramebuffers(&fFunctions.fDeleteFramebuffers)
53 , fDeleteProgram(&fFunctions.fDeleteProgram)
54 , fDeleteQueries(&fFunctions.fDeleteQueries)
55 , fDeleteRenderbuffers(&fFunctions.fDeleteRenderbuffers)
56 , fDeleteShader(&fFunctions.fDeleteShader)
57 , fDeleteTextures(&fFunctions.fDeleteTextures)
58 , fDeleteVertexArrays(&fFunctions.fDeleteVertexArrays)
59 , fDepthMask(&fFunctions.fDepthMask)
60 , fDisable(&fFunctions.fDisable)
61 , fDisableClientState(&fFunctions.fDisableClientState)
62 , fDisableVertexAttribArray(&fFunctions.fDisableVertexAttribArray)
63 , fDrawArrays(&fFunctions.fDrawArrays)
64 , fDrawBuffer(&fFunctions.fDrawBuffer)
65 , fDrawBuffers(&fFunctions.fDrawBuffers)
66 , fDrawElements(&fFunctions.fDrawElements)
67 , fEnable(&fFunctions.fEnable)
68 , fEnableClientState(&fFunctions.fEnableClientState)
69 , fEnableVertexAttribArray(&fFunctions.fEnableVertexAttribArray)
70 , fEndQuery(&fFunctions.fEndQuery)
71 , fFinish(&fFunctions.fFinish)
72 , fFlush(&fFunctions.fFlush)
73 , fFramebufferRenderbuffer(&fFunctions.fFramebufferRenderbuffer)
74 , fFramebufferTexture2D(&fFunctions.fFramebufferTexture2D)
75 , fFramebufferTexture2DMultisample(&fFunctions.fFramebufferTexture2DMultisam ple)
76 , fFrontFace(&fFunctions.fFrontFace)
77 , fGenBuffers(&fFunctions.fGenBuffers)
78 , fGenFramebuffers(&fFunctions.fGenFramebuffers)
79 , fGenerateMipmap(&fFunctions.fGenerateMipmap)
80 , fGenQueries(&fFunctions.fGenQueries)
81 , fGenRenderbuffers(&fFunctions.fGenRenderbuffers)
82 , fGenTextures(&fFunctions.fGenTextures)
83 , fGenVertexArrays(&fFunctions.fGenVertexArrays)
84 , fGetBufferParameteriv(&fFunctions.fGetBufferParameteriv)
85 , fGetError(&fFunctions.fGetError)
86 , fGetFramebufferAttachmentParameteriv(&fFunctions.fGetFramebufferAttachment Parameteriv)
87 , fGetIntegerv(&fFunctions.fGetIntegerv)
88 , fGetQueryObjecti64v(&fFunctions.fGetQueryObjecti64v)
89 , fGetQueryObjectiv(&fFunctions.fGetQueryObjectiv)
90 , fGetQueryObjectui64v(&fFunctions.fGetQueryObjectui64v)
91 , fGetQueryObjectuiv(&fFunctions.fGetQueryObjectuiv)
92 , fGetQueryiv(&fFunctions.fGetQueryiv)
93 , fGetProgramInfoLog(&fFunctions.fGetProgramInfoLog)
94 , fGetProgramiv(&fFunctions.fGetProgramiv)
95 , fGetRenderbufferParameteriv(&fFunctions.fGetRenderbufferParameteriv)
96 , fGetShaderInfoLog(&fFunctions.fGetShaderInfoLog)
97 , fGetShaderiv(&fFunctions.fGetShaderiv)
98 , fGetString(&fFunctions.fGetString)
99 , fGetStringi(&fFunctions.fGetStringi)
100 , fGetTexLevelParameteriv(&fFunctions.fGetTexLevelParameteriv)
101 , fGetUniformLocation(&fFunctions.fGetUniformLocation)
102 , fLineWidth(&fFunctions.fLineWidth)
103 , fLinkProgram(&fFunctions.fLinkProgram)
104 , fLoadIdentity(&fFunctions.fLoadIdentity)
105 , fLoadMatrixf(&fFunctions.fLoadMatrixf)
106 , fMapBuffer(&fFunctions.fMapBuffer)
107 , fMatrixMode(&fFunctions.fMatrixMode)
108 , fPixelStorei(&fFunctions.fPixelStorei)
109 , fQueryCounter(&fFunctions.fQueryCounter)
110 , fReadBuffer(&fFunctions.fReadBuffer)
111 , fReadPixels(&fFunctions.fReadPixels)
112 , fRenderbufferStorage(&fFunctions.fRenderbufferStorage)
113 , fRenderbufferStorageMultisampleES2EXT(&fFunctions.fRenderbufferStorageMult isampleES2EXT)
114 , fRenderbufferStorageMultisampleES2APPLE(&fFunctions.fRenderbufferStorageMu ltisampleES2APPLE)
115 , fRenderbufferStorageMultisample(&fFunctions.fRenderbufferStorageMultisampl e)
116 , fBindUniformLocation(&fFunctions.fBindUniformLocation)
117 , fResolveMultisampleFramebuffer(&fFunctions.fResolveMultisampleFramebuffer)
118 , fScissor(&fFunctions.fScissor)
119 , fShaderSource(&fFunctions.fShaderSource)
120 , fStencilFunc(&fFunctions.fStencilFunc)
121 , fStencilFuncSeparate(&fFunctions.fStencilFuncSeparate)
122 , fStencilMask(&fFunctions.fStencilMask)
123 , fStencilMaskSeparate(&fFunctions.fStencilMaskSeparate)
124 , fStencilOp(&fFunctions.fStencilOp)
125 , fStencilOpSeparate(&fFunctions.fStencilOpSeparate)
126 , fTexGenf(&fFunctions.fTexGenf)
127 , fTexGenfv(&fFunctions.fTexGenfv)
128 , fTexGeni(&fFunctions.fTexGeni)
129 , fTexImage2D(&fFunctions.fTexImage2D)
130 , fTexParameteri(&fFunctions.fTexParameteri)
131 , fTexParameteriv(&fFunctions.fTexParameteriv)
132 , fTexSubImage2D(&fFunctions.fTexSubImage2D)
133 , fTexStorage2D(&fFunctions.fTexStorage2D)
134 , fDiscardFramebuffer(&fFunctions.fDiscardFramebuffer)
135 , fUniform1f(&fFunctions.fUniform1f)
136 , fUniform1i(&fFunctions.fUniform1i)
137 , fUniform1fv(&fFunctions.fUniform1fv)
138 , fUniform1iv(&fFunctions.fUniform1iv)
139 , fUniform2f(&fFunctions.fUniform2f)
140 , fUniform2i(&fFunctions.fUniform2i)
141 , fUniform2fv(&fFunctions.fUniform2fv)
142 , fUniform2iv(&fFunctions.fUniform2iv)
143 , fUniform3f(&fFunctions.fUniform3f)
144 , fUniform3i(&fFunctions.fUniform3i)
145 , fUniform3fv(&fFunctions.fUniform3fv)
146 , fUniform3iv(&fFunctions.fUniform3iv)
147 , fUniform4f(&fFunctions.fUniform4f)
148 , fUniform4i(&fFunctions.fUniform4i)
149 , fUniform4fv(&fFunctions.fUniform4fv)
150 , fUniform4iv(&fFunctions.fUniform4iv)
151 , fUniformMatrix2fv(&fFunctions.fUniformMatrix2fv)
152 , fUniformMatrix3fv(&fFunctions.fUniformMatrix3fv)
153 , fUniformMatrix4fv(&fFunctions.fUniformMatrix4fv)
154 , fUnmapBuffer(&fFunctions.fUnmapBuffer)
155 , fUseProgram(&fFunctions.fUseProgram)
156 , fVertexAttrib4fv(&fFunctions.fVertexAttrib4fv)
157 , fVertexAttribPointer(&fFunctions.fVertexAttribPointer)
158 , fVertexPointer(&fFunctions.fVertexPointer)
159 , fViewport(&fFunctions.fViewport)
160 , fPathCommands(&fFunctions.fPathCommands)
161 , fPathCoords(&fFunctions.fPathCoords)
162 , fPathSubCommands(&fFunctions.fPathSubCommands)
163 , fPathSubCoords(&fFunctions.fPathSubCoords)
164 , fPathString(&fFunctions.fPathString)
165 , fPathGlyphs(&fFunctions.fPathGlyphs)
166 , fPathGlyphRange(&fFunctions.fPathGlyphRange)
167 , fWeightPaths(&fFunctions.fWeightPaths)
168 , fCopyPath(&fFunctions.fCopyPath)
169 , fInterpolatePaths(&fFunctions.fInterpolatePaths)
170 , fTransformPath(&fFunctions.fTransformPath)
171 , fPathParameteriv(&fFunctions.fPathParameteriv)
172 , fPathParameteri(&fFunctions.fPathParameteri)
173 , fPathParameterfv(&fFunctions.fPathParameterfv)
174 , fPathParameterf(&fFunctions.fPathParameterf)
175 , fPathDashArray(&fFunctions.fPathDashArray)
176 , fGenPaths(&fFunctions.fGenPaths)
177 , fDeletePaths(&fFunctions.fDeletePaths)
178 , fIsPath(&fFunctions.fIsPath)
179 , fPathStencilFunc(&fFunctions.fPathStencilFunc)
180 , fPathStencilDepthOffset(&fFunctions.fPathStencilDepthOffset)
181 , fStencilFillPath(&fFunctions.fStencilFillPath)
182 , fStencilStrokePath(&fFunctions.fStencilStrokePath)
183 , fStencilFillPathInstanced(&fFunctions.fStencilFillPathInstanced)
184 , fStencilStrokePathInstanced(&fFunctions.fStencilStrokePathInstanced)
185 , fPathCoverDepthFunc(&fFunctions.fPathCoverDepthFunc)
186 , fPathColorGen(&fFunctions.fPathColorGen)
187 , fPathTexGen(&fFunctions.fPathTexGen)
188 , fPathFogGen(&fFunctions.fPathFogGen)
189 , fCoverFillPath(&fFunctions.fCoverFillPath)
190 , fCoverStrokePath(&fFunctions.fCoverStrokePath)
191 , fCoverFillPathInstanced(&fFunctions.fCoverFillPathInstanced)
192 , fCoverStrokePathInstanced(&fFunctions.fCoverStrokePathInstanced)
193 , fGetPathParameteriv(&fFunctions.fGetPathParameteriv)
194 , fGetPathParameterfv(&fFunctions.fGetPathParameterfv)
195 , fGetPathCommands(&fFunctions.fGetPathCommands)
196 , fGetPathCoords(&fFunctions.fGetPathCoords)
197 , fGetPathDashArray(&fFunctions.fGetPathDashArray)
198 , fGetPathMetrics(&fFunctions.fGetPathMetrics)
199 , fGetPathMetricRange(&fFunctions.fGetPathMetricRange)
200 , fGetPathSpacing(&fFunctions.fGetPathSpacing)
201 , fGetPathColorGeniv(&fFunctions.fGetPathColorGeniv)
202 , fGetPathColorGenfv(&fFunctions.fGetPathColorGenfv)
203 , fGetPathTexGeniv(&fFunctions.fGetPathTexGeniv)
204 , fGetPathTexGenfv(&fFunctions.fGetPathTexGenfv)
205 , fIsPointInFillPath(&fFunctions.fIsPointInFillPath)
206 , fIsPointInStrokePath(&fFunctions.fIsPointInStrokePath)
207 , fGetPathLength(&fFunctions.fGetPathLength)
208 , fPointAlongPath(&fFunctions.fPointAlongPath)
209 {
22 fStandard = kNone_GrGLStandard; 210 fStandard = kNone_GrGLStandard;
23 211
24 #if GR_GL_PER_GL_FUNC_CALLBACK 212 #if GR_GL_PER_GL_FUNC_CALLBACK
25 fCallback = GrGLDefaultInterfaceCallback; 213 fCallback = GrGLDefaultInterfaceCallback;
26 fCallbackData = 0; 214 fCallbackData = 0;
27 #endif 215 #endif
28 } 216 }
29 217
30 bool GrGLInterface::validate() const { 218 bool GrGLInterface::validate() const {
31 219
32 if (kNone_GrGLStandard == fStandard) { 220 if (kNone_GrGLStandard == fStandard) {
33 return false; 221 return false;
34 } 222 }
35 223
36 // This const hackery is necessary because the factories in Chromium do not yet initialize 224 // This const hackery is necessary because the factories in Chromium do not yet initialize
37 // fExtensions. 225 // fExtensions.
38 if (!fExtensions.isInitialized()) { 226 if (!fExtensions.isInitialized()) {
39 GrGLExtensions* extensions = const_cast<GrGLExtensions*>(&fExtensions); 227 GrGLExtensions* extensions = const_cast<GrGLExtensions*>(&fExtensions);
40 if (!extensions->init(fStandard, fGetString, fGetStringi, fGetIntegerv)) { 228 if (!extensions->init(fStandard, fFunctions.fGetString, fFunctions.fGetS tringi,
229 fFunctions.fGetIntegerv)) {
41 return false; 230 return false;
42 } 231 }
43 } 232 }
44 233
45 // functions that are always required 234 // functions that are always required
46 if (NULL == fActiveTexture || 235 if (NULL == fFunctions.fActiveTexture ||
47 NULL == fAttachShader || 236 NULL == fFunctions.fAttachShader ||
48 NULL == fBindAttribLocation || 237 NULL == fFunctions.fBindAttribLocation ||
49 NULL == fBindBuffer || 238 NULL == fFunctions.fBindBuffer ||
50 NULL == fBindTexture || 239 NULL == fFunctions.fBindTexture ||
51 NULL == fBlendFunc || 240 NULL == fFunctions.fBlendFunc ||
52 NULL == fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension 241 NULL == fFunctions.fBlendColor || // -> GL >= 1.4, ES >= 2.0 or ext ension
53 NULL == fBufferData || 242 NULL == fFunctions.fBufferData ||
54 NULL == fBufferSubData || 243 NULL == fFunctions.fBufferSubData ||
55 NULL == fClear || 244 NULL == fFunctions.fClear ||
56 NULL == fClearColor || 245 NULL == fFunctions.fClearColor ||
57 NULL == fClearStencil || 246 NULL == fFunctions.fClearStencil ||
58 NULL == fColorMask || 247 NULL == fFunctions.fColorMask ||
59 NULL == fCompileShader || 248 NULL == fFunctions.fCompileShader ||
60 NULL == fCopyTexSubImage2D || 249 NULL == fFunctions.fCopyTexSubImage2D ||
61 NULL == fCreateProgram || 250 NULL == fFunctions.fCreateProgram ||
62 NULL == fCreateShader || 251 NULL == fFunctions.fCreateShader ||
63 NULL == fCullFace || 252 NULL == fFunctions.fCullFace ||
64 NULL == fDeleteBuffers || 253 NULL == fFunctions.fDeleteBuffers ||
65 NULL == fDeleteProgram || 254 NULL == fFunctions.fDeleteProgram ||
66 NULL == fDeleteShader || 255 NULL == fFunctions.fDeleteShader ||
67 NULL == fDeleteTextures || 256 NULL == fFunctions.fDeleteTextures ||
68 NULL == fDepthMask || 257 NULL == fFunctions.fDepthMask ||
69 NULL == fDisable || 258 NULL == fFunctions.fDisable ||
70 NULL == fDisableVertexAttribArray || 259 NULL == fFunctions.fDisableVertexAttribArray ||
71 NULL == fDrawArrays || 260 NULL == fFunctions.fDrawArrays ||
72 NULL == fDrawElements || 261 NULL == fFunctions.fDrawElements ||
73 NULL == fEnable || 262 NULL == fFunctions.fEnable ||
74 NULL == fEnableVertexAttribArray || 263 NULL == fFunctions.fEnableVertexAttribArray ||
75 NULL == fFrontFace || 264 NULL == fFunctions.fFrontFace ||
76 NULL == fGenBuffers || 265 NULL == fFunctions.fGenBuffers ||
77 NULL == fGenTextures || 266 NULL == fFunctions.fGenTextures ||
78 NULL == fGetBufferParameteriv || 267 NULL == fFunctions.fGetBufferParameteriv ||
79 NULL == fGenerateMipmap || 268 NULL == fFunctions.fGenerateMipmap ||
80 NULL == fGetError || 269 NULL == fFunctions.fGetError ||
81 NULL == fGetIntegerv || 270 NULL == fFunctions.fGetIntegerv ||
82 NULL == fGetProgramInfoLog || 271 NULL == fFunctions.fGetProgramInfoLog ||
83 NULL == fGetProgramiv || 272 NULL == fFunctions.fGetProgramiv ||
84 NULL == fGetShaderInfoLog || 273 NULL == fFunctions.fGetShaderInfoLog ||
85 NULL == fGetShaderiv || 274 NULL == fFunctions.fGetShaderiv ||
86 NULL == fGetString || 275 NULL == fFunctions.fGetString ||
87 NULL == fGetUniformLocation || 276 NULL == fFunctions.fGetUniformLocation ||
88 NULL == fLinkProgram || 277 NULL == fFunctions.fLinkProgram ||
89 NULL == fLineWidth || 278 NULL == fFunctions.fLineWidth ||
90 NULL == fPixelStorei || 279 NULL == fFunctions.fPixelStorei ||
91 NULL == fReadPixels || 280 NULL == fFunctions.fReadPixels ||
92 NULL == fScissor || 281 NULL == fFunctions.fScissor ||
93 NULL == fShaderSource || 282 NULL == fFunctions.fShaderSource ||
94 NULL == fStencilFunc || 283 NULL == fFunctions.fStencilFunc ||
95 NULL == fStencilMask || 284 NULL == fFunctions.fStencilMask ||
96 NULL == fStencilOp || 285 NULL == fFunctions.fStencilOp ||
97 NULL == fTexImage2D || 286 NULL == fFunctions.fTexImage2D ||
98 NULL == fTexParameteri || 287 NULL == fFunctions.fTexParameteri ||
99 NULL == fTexParameteriv || 288 NULL == fFunctions.fTexParameteriv ||
100 NULL == fTexSubImage2D || 289 NULL == fFunctions.fTexSubImage2D ||
101 NULL == fUniform1f || 290 NULL == fFunctions.fUniform1f ||
102 NULL == fUniform1i || 291 NULL == fFunctions.fUniform1i ||
103 NULL == fUniform1fv || 292 NULL == fFunctions.fUniform1fv ||
104 NULL == fUniform1iv || 293 NULL == fFunctions.fUniform1iv ||
105 NULL == fUniform2f || 294 NULL == fFunctions.fUniform2f ||
106 NULL == fUniform2i || 295 NULL == fFunctions.fUniform2i ||
107 NULL == fUniform2fv || 296 NULL == fFunctions.fUniform2fv ||
108 NULL == fUniform2iv || 297 NULL == fFunctions.fUniform2iv ||
109 NULL == fUniform3f || 298 NULL == fFunctions.fUniform3f ||
110 NULL == fUniform3i || 299 NULL == fFunctions.fUniform3i ||
111 NULL == fUniform3fv || 300 NULL == fFunctions.fUniform3fv ||
112 NULL == fUniform3iv || 301 NULL == fFunctions.fUniform3iv ||
113 NULL == fUniform4f || 302 NULL == fFunctions.fUniform4f ||
114 NULL == fUniform4i || 303 NULL == fFunctions.fUniform4i ||
115 NULL == fUniform4fv || 304 NULL == fFunctions.fUniform4fv ||
116 NULL == fUniform4iv || 305 NULL == fFunctions.fUniform4iv ||
117 NULL == fUniformMatrix2fv || 306 NULL == fFunctions.fUniformMatrix2fv ||
118 NULL == fUniformMatrix3fv || 307 NULL == fFunctions.fUniformMatrix3fv ||
119 NULL == fUniformMatrix4fv || 308 NULL == fFunctions.fUniformMatrix4fv ||
120 NULL == fUseProgram || 309 NULL == fFunctions.fUseProgram ||
121 NULL == fVertexAttrib4fv || 310 NULL == fFunctions.fVertexAttrib4fv ||
122 NULL == fVertexAttribPointer || 311 NULL == fFunctions.fVertexAttribPointer ||
123 NULL == fViewport || 312 NULL == fFunctions.fViewport ||
124 NULL == fBindFramebuffer || 313 NULL == fFunctions.fBindFramebuffer ||
125 NULL == fBindRenderbuffer || 314 NULL == fFunctions.fBindRenderbuffer ||
126 NULL == fCheckFramebufferStatus || 315 NULL == fFunctions.fCheckFramebufferStatus ||
127 NULL == fDeleteFramebuffers || 316 NULL == fFunctions.fDeleteFramebuffers ||
128 NULL == fDeleteRenderbuffers || 317 NULL == fFunctions.fDeleteRenderbuffers ||
129 NULL == fFinish || 318 NULL == fFunctions.fFinish ||
130 NULL == fFlush || 319 NULL == fFunctions.fFlush ||
131 NULL == fFramebufferRenderbuffer || 320 NULL == fFunctions.fFramebufferRenderbuffer ||
132 NULL == fFramebufferTexture2D || 321 NULL == fFunctions.fFramebufferTexture2D ||
133 NULL == fGetFramebufferAttachmentParameteriv || 322 NULL == fFunctions.fGetFramebufferAttachmentParameteriv ||
134 NULL == fGetRenderbufferParameteriv || 323 NULL == fFunctions.fGetRenderbufferParameteriv ||
135 NULL == fGenFramebuffers || 324 NULL == fFunctions.fGenFramebuffers ||
136 NULL == fGenRenderbuffers || 325 NULL == fFunctions.fGenRenderbuffers ||
137 NULL == fRenderbufferStorage) { 326 NULL == fFunctions.fRenderbufferStorage) {
138 return false; 327 return false;
139 } 328 }
140 329
141 GrGLVersion glVer = GrGLGetVersion(this); 330 GrGLVersion glVer = GrGLGetVersion(this);
142 331
143 bool isCoreProfile = false; 332 bool isCoreProfile = false;
144 if (kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,2)) { 333 if (kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,2)) {
145 GrGLint profileMask; 334 GrGLint profileMask;
146 GR_GL_GetIntegerv(this, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); 335 GR_GL_GetIntegerv(this, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
147 isCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); 336 isCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
148 } 337 }
149 338
150 // Now check that baseline ES/Desktop fns not covered above are present 339 // Now check that baseline ES/Desktop fns not covered above are present
151 // and that we have fn pointers for any advertised fExtensions that we will 340 // and that we have fn pointers for any advertised fExtensions that we will
152 // try to use. 341 // try to use.
153 342
154 // these functions are part of ES2, we assume they are available 343 // these functions are part of ES2, we assume they are available
155 // On the desktop we assume they are available if the extension 344 // On the desktop we assume they are available if the extension
156 // is present or GL version is high enough. 345 // is present or GL version is high enough.
157 if (kGLES_GrGLStandard == fStandard) { 346 if (kGLES_GrGLStandard == fStandard) {
158 if (NULL == fStencilFuncSeparate || 347 if (NULL == fFunctions.fStencilFuncSeparate ||
159 NULL == fStencilMaskSeparate || 348 NULL == fFunctions.fStencilMaskSeparate ||
160 NULL == fStencilOpSeparate) { 349 NULL == fFunctions.fStencilOpSeparate) {
161 return false; 350 return false;
162 } 351 }
163 } else if (kGL_GrGLStandard == fStandard) { 352 } else if (kGL_GrGLStandard == fStandard) {
164 353
165 if (glVer >= GR_GL_VER(2,0)) { 354 if (glVer >= GR_GL_VER(2,0)) {
166 if (NULL == fStencilFuncSeparate || 355 if (NULL == fFunctions.fStencilFuncSeparate ||
167 NULL == fStencilMaskSeparate || 356 NULL == fFunctions.fStencilMaskSeparate ||
168 NULL == fStencilOpSeparate) { 357 NULL == fFunctions.fStencilOpSeparate) {
169 return false; 358 return false;
170 } 359 }
171 } 360 }
172 if (glVer >= GR_GL_VER(3,0) && NULL == fBindFragDataLocation) { 361 if (glVer >= GR_GL_VER(3,0) && NULL == fFunctions.fBindFragDataLocation) {
173 return false; 362 return false;
174 } 363 }
175 if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) { 364 if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) {
176 if (NULL == fDrawBuffers) { 365 if (NULL == fFunctions.fDrawBuffers) {
177 return false; 366 return false;
178 } 367 }
179 } 368 }
180 369
181 if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query") ) { 370 if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query") ) {
182 if (NULL == fGenQueries || 371 if (NULL == fFunctions.fGenQueries ||
183 NULL == fDeleteQueries || 372 NULL == fFunctions.fDeleteQueries ||
184 NULL == fBeginQuery || 373 NULL == fFunctions.fBeginQuery ||
185 NULL == fEndQuery || 374 NULL == fFunctions.fEndQuery ||
186 NULL == fGetQueryiv || 375 NULL == fFunctions.fGetQueryiv ||
187 NULL == fGetQueryObjectiv || 376 NULL == fFunctions.fGetQueryObjectiv ||
188 NULL == fGetQueryObjectuiv) { 377 NULL == fFunctions.fGetQueryObjectuiv) {
189 return false; 378 return false;
190 } 379 }
191 } 380 }
192 if (glVer >= GR_GL_VER(3,3) || 381 if (glVer >= GR_GL_VER(3,3) ||
193 fExtensions.has("GL_ARB_timer_query") || 382 fExtensions.has("GL_ARB_timer_query") ||
194 fExtensions.has("GL_EXT_timer_query")) { 383 fExtensions.has("GL_EXT_timer_query")) {
195 if (NULL == fGetQueryObjecti64v || 384 if (NULL == fFunctions.fGetQueryObjecti64v ||
196 NULL == fGetQueryObjectui64v) { 385 NULL == fFunctions.fGetQueryObjectui64v) {
197 return false; 386 return false;
198 } 387 }
199 } 388 }
200 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) { 389 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
201 if (NULL == fQueryCounter) { 390 if (NULL == fFunctions.fQueryCounter) {
202 return false; 391 return false;
203 } 392 }
204 } 393 }
205 if (!isCoreProfile) { 394 if (!isCoreProfile) {
206 if (NULL == fClientActiveTexture || 395 if (NULL == fFunctions.fClientActiveTexture ||
207 NULL == fDisableClientState || 396 NULL == fFunctions.fDisableClientState ||
208 NULL == fEnableClientState || 397 NULL == fFunctions.fEnableClientState ||
209 NULL == fLoadIdentity || 398 NULL == fFunctions.fLoadIdentity ||
210 NULL == fLoadMatrixf || 399 NULL == fFunctions.fLoadMatrixf ||
211 NULL == fMatrixMode || 400 NULL == fFunctions.fMatrixMode ||
212 NULL == fTexGenf || 401 NULL == fFunctions.fTexGenf ||
213 NULL == fTexGenfv || 402 NULL == fFunctions.fTexGenfv ||
214 NULL == fTexGeni || 403 NULL == fFunctions.fTexGeni ||
215 NULL == fVertexPointer) { 404 NULL == fFunctions.fVertexPointer) {
216 return false; 405 return false;
217 } 406 }
218 } 407 }
219 if (false && fExtensions.has("GL_NV_path_rendering")) { 408 if (false && fExtensions.has("GL_NV_path_rendering")) {
220 if (NULL == fPathCommands || 409 if (NULL == fFunctions.fPathCommands ||
221 NULL == fPathCoords || 410 NULL == fFunctions.fPathCoords ||
222 NULL == fPathSubCommands || 411 NULL == fFunctions.fPathSubCommands ||
223 NULL == fPathSubCoords || 412 NULL == fFunctions.fPathSubCoords ||
224 NULL == fPathString || 413 NULL == fFunctions.fPathString ||
225 NULL == fPathGlyphs || 414 NULL == fFunctions.fPathGlyphs ||
226 NULL == fPathGlyphRange || 415 NULL == fFunctions.fPathGlyphRange ||
227 NULL == fWeightPaths || 416 NULL == fFunctions.fWeightPaths ||
228 NULL == fCopyPath || 417 NULL == fFunctions.fCopyPath ||
229 NULL == fInterpolatePaths || 418 NULL == fFunctions.fInterpolatePaths ||
230 NULL == fTransformPath || 419 NULL == fFunctions.fTransformPath ||
231 NULL == fPathParameteriv || 420 NULL == fFunctions.fPathParameteriv ||
232 NULL == fPathParameteri || 421 NULL == fFunctions.fPathParameteri ||
233 NULL == fPathParameterfv || 422 NULL == fFunctions.fPathParameterfv ||
234 NULL == fPathParameterf || 423 NULL == fFunctions.fPathParameterf ||
235 NULL == fPathDashArray || 424 NULL == fFunctions.fPathDashArray ||
236 NULL == fGenPaths || 425 NULL == fFunctions.fGenPaths ||
237 NULL == fDeletePaths || 426 NULL == fFunctions.fDeletePaths ||
238 NULL == fIsPath || 427 NULL == fFunctions.fIsPath ||
239 NULL == fPathStencilFunc || 428 NULL == fFunctions.fPathStencilFunc ||
240 NULL == fPathStencilDepthOffset || 429 NULL == fFunctions.fPathStencilDepthOffset ||
241 NULL == fStencilFillPath || 430 NULL == fFunctions.fStencilFillPath ||
242 NULL == fStencilStrokePath || 431 NULL == fFunctions.fStencilStrokePath ||
243 NULL == fStencilFillPathInstanced || 432 NULL == fFunctions.fStencilFillPathInstanced ||
244 NULL == fStencilStrokePathInstanced || 433 NULL == fFunctions.fStencilStrokePathInstanced ||
245 NULL == fPathCoverDepthFunc || 434 NULL == fFunctions.fPathCoverDepthFunc ||
246 NULL == fPathColorGen || 435 NULL == fFunctions.fPathColorGen ||
247 NULL == fPathTexGen || 436 NULL == fFunctions.fPathTexGen ||
248 NULL == fPathFogGen || 437 NULL == fFunctions.fPathFogGen ||
249 NULL == fCoverFillPath || 438 NULL == fFunctions.fCoverFillPath ||
250 NULL == fCoverStrokePath || 439 NULL == fFunctions.fCoverStrokePath ||
251 NULL == fCoverFillPathInstanced || 440 NULL == fFunctions.fCoverFillPathInstanced ||
252 NULL == fCoverStrokePathInstanced || 441 NULL == fFunctions.fCoverStrokePathInstanced ||
253 NULL == fGetPathParameteriv || 442 NULL == fFunctions.fGetPathParameteriv ||
254 NULL == fGetPathParameterfv || 443 NULL == fFunctions.fGetPathParameterfv ||
255 NULL == fGetPathCommands || 444 NULL == fFunctions.fGetPathCommands ||
256 NULL == fGetPathCoords || 445 NULL == fFunctions.fGetPathCoords ||
257 NULL == fGetPathDashArray || 446 NULL == fFunctions.fGetPathDashArray ||
258 NULL == fGetPathMetrics || 447 NULL == fFunctions.fGetPathMetrics ||
259 NULL == fGetPathMetricRange || 448 NULL == fFunctions.fGetPathMetricRange ||
260 NULL == fGetPathSpacing || 449 NULL == fFunctions.fGetPathSpacing ||
261 NULL == fGetPathColorGeniv || 450 NULL == fFunctions.fGetPathColorGeniv ||
262 NULL == fGetPathColorGenfv || 451 NULL == fFunctions.fGetPathColorGenfv ||
263 NULL == fGetPathTexGeniv || 452 NULL == fFunctions.fGetPathTexGeniv ||
264 NULL == fGetPathTexGenfv || 453 NULL == fFunctions.fGetPathTexGenfv ||
265 NULL == fIsPointInFillPath || 454 NULL == fFunctions.fIsPointInFillPath ||
266 NULL == fIsPointInStrokePath || 455 NULL == fFunctions.fIsPointInStrokePath ||
267 NULL == fGetPathLength || 456 NULL == fFunctions.fGetPathLength ||
268 NULL == fPointAlongPath) { 457 NULL == fFunctions.fPointAlongPath) {
269 return false; 458 return false;
270 } 459 }
271 } 460 }
272 } 461 }
273 462
274 // optional function on desktop before 1.3 463 // optional function on desktop before 1.3
275 if (kGL_GrGLStandard != fStandard || 464 if (kGL_GrGLStandard != fStandard ||
276 (glVer >= GR_GL_VER(1,3)) || 465 (glVer >= GR_GL_VER(1,3)) ||
277 fExtensions.has("GL_ARB_texture_compression")) { 466 fExtensions.has("GL_ARB_texture_compression")) {
278 if (NULL == fCompressedTexImage2D) { 467 if (NULL == fFunctions.fCompressedTexImage2D) {
279 return false; 468 return false;
280 } 469 }
281 } 470 }
282 471
283 // part of desktop GL, but not ES 472 // part of desktop GL, but not ES
284 if (kGL_GrGLStandard == fStandard && 473 if (kGL_GrGLStandard == fStandard &&
285 (NULL == fGetTexLevelParameteriv || 474 (NULL == fFunctions.fGetTexLevelParameteriv ||
286 NULL == fDrawBuffer || 475 NULL == fFunctions.fDrawBuffer ||
287 NULL == fReadBuffer)) { 476 NULL == fFunctions.fReadBuffer)) {
288 return false; 477 return false;
289 } 478 }
290 479
291 // GL_EXT_texture_storage is part of desktop 4.2 480 // GL_EXT_texture_storage is part of desktop 4.2
292 // There is a desktop ARB extension and an ES+desktop EXT extension 481 // There is a desktop ARB extension and an ES+desktop EXT extension
293 if (kGL_GrGLStandard == fStandard) { 482 if (kGL_GrGLStandard == fStandard) {
294 if (glVer >= GR_GL_VER(4,2) || 483 if (glVer >= GR_GL_VER(4,2) ||
295 fExtensions.has("GL_ARB_texture_storage") || 484 fExtensions.has("GL_ARB_texture_storage") ||
296 fExtensions.has("GL_EXT_texture_storage")) { 485 fExtensions.has("GL_EXT_texture_storage")) {
297 if (NULL == fTexStorage2D) { 486 if (NULL == fFunctions.fTexStorage2D) {
298 return false; 487 return false;
299 } 488 }
300 } 489 }
301 } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storag e")) { 490 } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storag e")) {
302 if (NULL == fTexStorage2D) { 491 if (NULL == fFunctions.fTexStorage2D) {
303 return false; 492 return false;
304 } 493 }
305 } 494 }
306 495
307 if (fExtensions.has("GL_EXT_discard_framebuffer")) { 496 if (fExtensions.has("GL_EXT_discard_framebuffer")) {
308 // FIXME: Remove this once Chromium is updated to provide this function 497 // FIXME: Remove this once Chromium is updated to provide this function
309 #if 0 498 #if 0
310 if (NULL == fDiscardFramebuffer) { 499 if (NULL == fFunctions.fDiscardFramebuffer) {
311 return false; 500 return false;
312 } 501 }
313 #endif 502 #endif
314 } 503 }
315 504
316 // FBO MSAA 505 // FBO MSAA
317 if (kGL_GrGLStandard == fStandard) { 506 if (kGL_GrGLStandard == fStandard) {
318 // GL 3.0 and the ARB extension have multisample + blit 507 // GL 3.0 and the ARB extension have multisample + blit
319 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_objec t")) { 508 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_objec t")) {
320 if (NULL == fRenderbufferStorageMultisample || 509 if (NULL == fFunctions.fRenderbufferStorageMultisample ||
321 NULL == fBlitFramebuffer) { 510 NULL == fFunctions.fBlitFramebuffer) {
322 return false; 511 return false;
323 } 512 }
324 } else { 513 } else {
325 if (fExtensions.has("GL_EXT_framebuffer_blit") && 514 if (fExtensions.has("GL_EXT_framebuffer_blit") &&
326 NULL == fBlitFramebuffer) { 515 NULL == fFunctions.fBlitFramebuffer) {
327 return false; 516 return false;
328 } 517 }
329 if (fExtensions.has("GL_EXT_framebuffer_multisample") && 518 if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
330 NULL == fRenderbufferStorageMultisample) { 519 NULL == fFunctions.fRenderbufferStorageMultisample) {
331 return false; 520 return false;
332 } 521 }
333 } 522 }
334 } else { 523 } else {
335 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_ multisample")) { 524 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_ multisample")) {
336 if (NULL == fRenderbufferStorageMultisample || 525 if (NULL == fFunctions.fRenderbufferStorageMultisample ||
337 NULL == fBlitFramebuffer) { 526 NULL == fFunctions.fBlitFramebuffer) {
338 return false; 527 return false;
339 } 528 }
340 } 529 }
341 if (fExtensions.has("GL_APPLE_framebuffer_multisample")) { 530 if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
342 if (NULL == fRenderbufferStorageMultisampleES2APPLE || 531 if (NULL == fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
343 NULL == fResolveMultisampleFramebuffer) { 532 NULL == fFunctions.fResolveMultisampleFramebuffer) {
344 return false; 533 return false;
345 } 534 }
346 } 535 }
347 if (fExtensions.has("GL_IMG_multisampled_render_to_texture") || 536 if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
348 fExtensions.has("GL_EXT_multisampled_render_to_texture")) { 537 fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
349 if (NULL == fRenderbufferStorageMultisampleES2EXT || 538 if (NULL == fFunctions.fRenderbufferStorageMultisampleES2EXT ||
350 NULL == fFramebufferTexture2DMultisample) { 539 NULL == fFunctions.fFramebufferTexture2DMultisample) {
351 return false; 540 return false;
352 } 541 }
353 } 542 }
354 } 543 }
355 544
356 // On ES buffer mapping is an extension. On Desktop 545 // On ES buffer mapping is an extension. On Desktop
357 // buffer mapping was part of original VBO extension 546 // buffer mapping was part of original VBO extension
358 // which we require. 547 // which we require.
359 if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) { 548 if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
360 if (NULL == fMapBuffer || 549 if (NULL == fFunctions.fMapBuffer ||
361 NULL == fUnmapBuffer) { 550 NULL == fFunctions.fUnmapBuffer) {
362 return false; 551 return false;
363 } 552 }
364 } 553 }
365 554
366 // Dual source blending 555 // Dual source blending
367 if (kGL_GrGLStandard == fStandard && 556 if (kGL_GrGLStandard == fStandard &&
368 (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended" ))) { 557 (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended" ))) {
369 if (NULL == fBindFragDataLocationIndexed) { 558 if (NULL == fFunctions.fBindFragDataLocationIndexed) {
370 return false; 559 return false;
371 } 560 }
372 } 561 }
373 562
374 // glGetStringi was added in version 3.0 of both desktop and ES. 563 // glGetStringi was added in version 3.0 of both desktop and ES.
375 if (glVer >= GR_GL_VER(3, 0)) { 564 if (glVer >= GR_GL_VER(3, 0)) {
376 if (NULL == fGetStringi) { 565 if (NULL == fFunctions.fGetStringi) {
377 return false; 566 return false;
378 } 567 }
379 } 568 }
380 569
381 if (kGL_GrGLStandard == fStandard) { 570 if (kGL_GrGLStandard == fStandard) {
382 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_obj ect")) { 571 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_obj ect")) {
383 if (NULL == fBindVertexArray || 572 if (NULL == fFunctions.fBindVertexArray ||
384 NULL == fDeleteVertexArrays || 573 NULL == fFunctions.fDeleteVertexArrays ||
385 NULL == fGenVertexArrays) { 574 NULL == fFunctions.fGenVertexArrays) {
386 return false; 575 return false;
387 } 576 }
388 } 577 }
389 } else { 578 } else {
390 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_obje ct")) { 579 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_obje ct")) {
391 if (NULL == fBindVertexArray || 580 if (NULL == fFunctions.fBindVertexArray ||
392 NULL == fDeleteVertexArrays || 581 NULL == fFunctions.fDeleteVertexArrays ||
393 NULL == fGenVertexArrays) { 582 NULL == fFunctions.fGenVertexArrays) {
394 return false; 583 return false;
395 } 584 }
396 } 585 }
397 } 586 }
398
399 return true; 587 return true;
400 } 588 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698