OLD | NEW |
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 "GrGLDefines.h" | 10 #include "GrGLDefines.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 break; } | 252 break; } |
253 default: | 253 default: |
254 GrCrash("Unexpected pname to GetBufferParamateriv"); | 254 GrCrash("Unexpected pname to GetBufferParamateriv"); |
255 break; | 255 break; |
256 } | 256 } |
257 }; | 257 }; |
258 | 258 |
259 } // end anonymous namespace | 259 } // end anonymous namespace |
260 | 260 |
261 const GrGLInterface* GrGLCreateNullInterface() { | 261 const GrGLInterface* GrGLCreateNullInterface() { |
262 // The gl functions are not context-specific so we create one global | 262 GrGLInterface* interface = SkNEW(GrGLInterface); |
263 // interface | |
264 static SkAutoTUnref<GrGLInterface> glInterface; | |
265 if (!glInterface.get()) { | |
266 GrGLInterface* interface = SkNEW(GrGLInterface); | |
267 glInterface.reset(interface); | |
268 | 263 |
269 interface->fStandard = kGL_GrGLStandard; | 264 interface->fStandard = kGL_GrGLStandard; |
270 | 265 |
271 GrGLInterface::Functions* functions = &interface->fFunctions; | 266 GrGLInterface::Functions* functions = &interface->fFunctions; |
272 functions->fActiveTexture = nullGLActiveTexture; | 267 functions->fActiveTexture = nullGLActiveTexture; |
273 functions->fAttachShader = nullGLAttachShader; | 268 functions->fAttachShader = nullGLAttachShader; |
274 functions->fBeginQuery = nullGLBeginQuery; | 269 functions->fBeginQuery = nullGLBeginQuery; |
275 functions->fBindAttribLocation = nullGLBindAttribLocation; | 270 functions->fBindAttribLocation = nullGLBindAttribLocation; |
276 functions->fBindBuffer = nullGLBindBuffer; | 271 functions->fBindBuffer = nullGLBindBuffer; |
277 functions->fBindFragDataLocation = noOpGLBindFragDataLocation; | 272 functions->fBindFragDataLocation = noOpGLBindFragDataLocation; |
278 functions->fBindTexture = nullGLBindTexture; | 273 functions->fBindTexture = nullGLBindTexture; |
279 functions->fBindVertexArray = nullGLBindVertexArray; | 274 functions->fBindVertexArray = nullGLBindVertexArray; |
280 functions->fBlendColor = noOpGLBlendColor; | 275 functions->fBlendColor = noOpGLBlendColor; |
281 functions->fBlendFunc = noOpGLBlendFunc; | 276 functions->fBlendFunc = noOpGLBlendFunc; |
282 functions->fBufferData = nullGLBufferData; | 277 functions->fBufferData = nullGLBufferData; |
283 functions->fBufferSubData = noOpGLBufferSubData; | 278 functions->fBufferSubData = noOpGLBufferSubData; |
284 functions->fClear = noOpGLClear; | 279 functions->fClear = noOpGLClear; |
285 functions->fClearColor = noOpGLClearColor; | 280 functions->fClearColor = noOpGLClearColor; |
286 functions->fClearStencil = noOpGLClearStencil; | 281 functions->fClearStencil = noOpGLClearStencil; |
287 functions->fColorMask = noOpGLColorMask; | 282 functions->fColorMask = noOpGLColorMask; |
288 functions->fCompileShader = noOpGLCompileShader; | 283 functions->fCompileShader = noOpGLCompileShader; |
289 functions->fCompressedTexImage2D = noOpGLCompressedTexImage2D; | 284 functions->fCompressedTexImage2D = noOpGLCompressedTexImage2D; |
290 functions->fCopyTexSubImage2D = noOpGLCopyTexSubImage2D; | 285 functions->fCopyTexSubImage2D = noOpGLCopyTexSubImage2D; |
291 functions->fCreateProgram = nullGLCreateProgram; | 286 functions->fCreateProgram = nullGLCreateProgram; |
292 functions->fCreateShader = nullGLCreateShader; | 287 functions->fCreateShader = nullGLCreateShader; |
293 functions->fCullFace = noOpGLCullFace; | 288 functions->fCullFace = noOpGLCullFace; |
294 functions->fDeleteBuffers = nullGLDeleteBuffers; | 289 functions->fDeleteBuffers = nullGLDeleteBuffers; |
295 functions->fDeleteProgram = nullGLDelete; | 290 functions->fDeleteProgram = nullGLDelete; |
296 functions->fDeleteQueries = noOpGLDeleteIds; | 291 functions->fDeleteQueries = noOpGLDeleteIds; |
297 functions->fDeleteShader = nullGLDelete; | 292 functions->fDeleteShader = nullGLDelete; |
298 functions->fDeleteTextures = noOpGLDeleteIds; | 293 functions->fDeleteTextures = noOpGLDeleteIds; |
299 functions->fDeleteVertexArrays = noOpGLDeleteIds; | 294 functions->fDeleteVertexArrays = noOpGLDeleteIds; |
300 functions->fDepthMask = noOpGLDepthMask; | 295 functions->fDepthMask = noOpGLDepthMask; |
301 functions->fDisable = noOpGLDisable; | 296 functions->fDisable = noOpGLDisable; |
302 functions->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray; | 297 functions->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray; |
303 functions->fDrawArrays = noOpGLDrawArrays; | 298 functions->fDrawArrays = noOpGLDrawArrays; |
304 functions->fDrawBuffer = noOpGLDrawBuffer; | 299 functions->fDrawBuffer = noOpGLDrawBuffer; |
305 functions->fDrawBuffers = noOpGLDrawBuffers; | 300 functions->fDrawBuffers = noOpGLDrawBuffers; |
306 functions->fDrawElements = noOpGLDrawElements; | 301 functions->fDrawElements = noOpGLDrawElements; |
307 functions->fEnable = noOpGLEnable; | 302 functions->fEnable = noOpGLEnable; |
308 functions->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray; | 303 functions->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray; |
309 functions->fEndQuery = noOpGLEndQuery; | 304 functions->fEndQuery = noOpGLEndQuery; |
310 functions->fFinish = noOpGLFinish; | 305 functions->fFinish = noOpGLFinish; |
311 functions->fFlush = noOpGLFlush; | 306 functions->fFlush = noOpGLFlush; |
312 functions->fFrontFace = noOpGLFrontFace; | 307 functions->fFrontFace = noOpGLFrontFace; |
313 functions->fGenBuffers = nullGLGenBuffers; | 308 functions->fGenBuffers = nullGLGenBuffers; |
314 functions->fGenerateMipmap = nullGLGenerateMipmap; | 309 functions->fGenerateMipmap = nullGLGenerateMipmap; |
315 functions->fGenQueries = noOpGLGenIds; | 310 functions->fGenQueries = noOpGLGenIds; |
316 functions->fGenTextures = noOpGLGenIds; | 311 functions->fGenTextures = noOpGLGenIds; |
317 functions->fGenVertexArrays = noOpGLGenIds; | 312 functions->fGenVertexArrays = noOpGLGenIds; |
318 functions->fGetBufferParameteriv = nullGLGetBufferParameteriv; | 313 functions->fGetBufferParameteriv = nullGLGetBufferParameteriv; |
319 functions->fGetError = noOpGLGetError; | 314 functions->fGetError = noOpGLGetError; |
320 functions->fGetIntegerv = noOpGLGetIntegerv; | 315 functions->fGetIntegerv = noOpGLGetIntegerv; |
321 functions->fGetQueryObjecti64v = noOpGLGetQueryObjecti64v; | 316 functions->fGetQueryObjecti64v = noOpGLGetQueryObjecti64v; |
322 functions->fGetQueryObjectiv = noOpGLGetQueryObjectiv; | 317 functions->fGetQueryObjectiv = noOpGLGetQueryObjectiv; |
323 functions->fGetQueryObjectui64v = noOpGLGetQueryObjectui64v; | 318 functions->fGetQueryObjectui64v = noOpGLGetQueryObjectui64v; |
324 functions->fGetQueryObjectuiv = noOpGLGetQueryObjectuiv; | 319 functions->fGetQueryObjectuiv = noOpGLGetQueryObjectuiv; |
325 functions->fGetQueryiv = noOpGLGetQueryiv; | 320 functions->fGetQueryiv = noOpGLGetQueryiv; |
326 functions->fGetProgramInfoLog = noOpGLGetInfoLog; | 321 functions->fGetProgramInfoLog = noOpGLGetInfoLog; |
327 functions->fGetProgramiv = noOpGLGetShaderOrProgramiv; | 322 functions->fGetProgramiv = noOpGLGetShaderOrProgramiv; |
328 functions->fGetShaderInfoLog = noOpGLGetInfoLog; | 323 functions->fGetShaderInfoLog = noOpGLGetInfoLog; |
329 functions->fGetShaderiv = noOpGLGetShaderOrProgramiv; | 324 functions->fGetShaderiv = noOpGLGetShaderOrProgramiv; |
330 functions->fGetString = noOpGLGetString; | 325 functions->fGetString = noOpGLGetString; |
331 functions->fGetStringi = noOpGLGetStringi; | 326 functions->fGetStringi = noOpGLGetStringi; |
332 functions->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv; | 327 functions->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv; |
333 functions->fGetUniformLocation = noOpGLGetUniformLocation; | 328 functions->fGetUniformLocation = noOpGLGetUniformLocation; |
334 functions->fInsertEventMarker = noOpGLInsertEventMarker; | 329 functions->fInsertEventMarker = noOpGLInsertEventMarker; |
335 functions->fLoadIdentity = noOpGLLoadIdentity; | 330 functions->fLoadIdentity = noOpGLLoadIdentity; |
336 functions->fLoadMatrixf = noOpGLLoadMatrixf; | 331 functions->fLoadMatrixf = noOpGLLoadMatrixf; |
337 functions->fLineWidth = noOpGLLineWidth; | 332 functions->fLineWidth = noOpGLLineWidth; |
338 functions->fLinkProgram = noOpGLLinkProgram; | 333 functions->fLinkProgram = noOpGLLinkProgram; |
339 functions->fMatrixMode = noOpGLMatrixMode; | 334 functions->fMatrixMode = noOpGLMatrixMode; |
340 functions->fPixelStorei = nullGLPixelStorei; | 335 functions->fPixelStorei = nullGLPixelStorei; |
341 functions->fPopGroupMarker = noOpGLPopGroupMarker; | 336 functions->fPopGroupMarker = noOpGLPopGroupMarker; |
342 functions->fPushGroupMarker = noOpGLPushGroupMarker; | 337 functions->fPushGroupMarker = noOpGLPushGroupMarker; |
343 functions->fQueryCounter = noOpGLQueryCounter; | 338 functions->fQueryCounter = noOpGLQueryCounter; |
344 functions->fReadBuffer = noOpGLReadBuffer; | 339 functions->fReadBuffer = noOpGLReadBuffer; |
345 functions->fReadPixels = nullGLReadPixels; | 340 functions->fReadPixels = nullGLReadPixels; |
346 functions->fScissor = noOpGLScissor; | 341 functions->fScissor = noOpGLScissor; |
347 functions->fShaderSource = noOpGLShaderSource; | 342 functions->fShaderSource = noOpGLShaderSource; |
348 functions->fStencilFunc = noOpGLStencilFunc; | 343 functions->fStencilFunc = noOpGLStencilFunc; |
349 functions->fStencilFuncSeparate = noOpGLStencilFuncSeparate; | 344 functions->fStencilFuncSeparate = noOpGLStencilFuncSeparate; |
350 functions->fStencilMask = noOpGLStencilMask; | 345 functions->fStencilMask = noOpGLStencilMask; |
351 functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate; | 346 functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate; |
352 functions->fStencilOp = noOpGLStencilOp; | 347 functions->fStencilOp = noOpGLStencilOp; |
353 functions->fStencilOpSeparate = noOpGLStencilOpSeparate; | 348 functions->fStencilOpSeparate = noOpGLStencilOpSeparate; |
354 functions->fTexGenfv = noOpGLTexGenfv; | 349 functions->fTexGenfv = noOpGLTexGenfv; |
355 functions->fTexGeni = noOpGLTexGeni; | 350 functions->fTexGeni = noOpGLTexGeni; |
356 functions->fTexImage2D = noOpGLTexImage2D; | 351 functions->fTexImage2D = noOpGLTexImage2D; |
357 functions->fTexParameteri = noOpGLTexParameteri; | 352 functions->fTexParameteri = noOpGLTexParameteri; |
358 functions->fTexParameteriv = noOpGLTexParameteriv; | 353 functions->fTexParameteriv = noOpGLTexParameteriv; |
359 functions->fTexSubImage2D = noOpGLTexSubImage2D; | 354 functions->fTexSubImage2D = noOpGLTexSubImage2D; |
360 functions->fTexStorage2D = noOpGLTexStorage2D; | 355 functions->fTexStorage2D = noOpGLTexStorage2D; |
361 functions->fDiscardFramebuffer = noOpGLDiscardFramebuffer; | 356 functions->fDiscardFramebuffer = noOpGLDiscardFramebuffer; |
362 functions->fUniform1f = noOpGLUniform1f; | 357 functions->fUniform1f = noOpGLUniform1f; |
363 functions->fUniform1i = noOpGLUniform1i; | 358 functions->fUniform1i = noOpGLUniform1i; |
364 functions->fUniform1fv = noOpGLUniform1fv; | 359 functions->fUniform1fv = noOpGLUniform1fv; |
365 functions->fUniform1iv = noOpGLUniform1iv; | 360 functions->fUniform1iv = noOpGLUniform1iv; |
366 functions->fUniform2f = noOpGLUniform2f; | 361 functions->fUniform2f = noOpGLUniform2f; |
367 functions->fUniform2i = noOpGLUniform2i; | 362 functions->fUniform2i = noOpGLUniform2i; |
368 functions->fUniform2fv = noOpGLUniform2fv; | 363 functions->fUniform2fv = noOpGLUniform2fv; |
369 functions->fUniform2iv = noOpGLUniform2iv; | 364 functions->fUniform2iv = noOpGLUniform2iv; |
370 functions->fUniform3f = noOpGLUniform3f; | 365 functions->fUniform3f = noOpGLUniform3f; |
371 functions->fUniform3i = noOpGLUniform3i; | 366 functions->fUniform3i = noOpGLUniform3i; |
372 functions->fUniform3fv = noOpGLUniform3fv; | 367 functions->fUniform3fv = noOpGLUniform3fv; |
373 functions->fUniform3iv = noOpGLUniform3iv; | 368 functions->fUniform3iv = noOpGLUniform3iv; |
374 functions->fUniform4f = noOpGLUniform4f; | 369 functions->fUniform4f = noOpGLUniform4f; |
375 functions->fUniform4i = noOpGLUniform4i; | 370 functions->fUniform4i = noOpGLUniform4i; |
376 functions->fUniform4fv = noOpGLUniform4fv; | 371 functions->fUniform4fv = noOpGLUniform4fv; |
377 functions->fUniform4iv = noOpGLUniform4iv; | 372 functions->fUniform4iv = noOpGLUniform4iv; |
378 functions->fUniformMatrix2fv = noOpGLUniformMatrix2fv; | 373 functions->fUniformMatrix2fv = noOpGLUniformMatrix2fv; |
379 functions->fUniformMatrix3fv = noOpGLUniformMatrix3fv; | 374 functions->fUniformMatrix3fv = noOpGLUniformMatrix3fv; |
380 functions->fUniformMatrix4fv = noOpGLUniformMatrix4fv; | 375 functions->fUniformMatrix4fv = noOpGLUniformMatrix4fv; |
381 functions->fUseProgram = nullGLUseProgram; | 376 functions->fUseProgram = nullGLUseProgram; |
382 functions->fVertexAttrib4fv = noOpGLVertexAttrib4fv; | 377 functions->fVertexAttrib4fv = noOpGLVertexAttrib4fv; |
383 functions->fVertexAttribPointer = noOpGLVertexAttribPointer; | 378 functions->fVertexAttribPointer = noOpGLVertexAttribPointer; |
384 functions->fViewport = nullGLViewport; | 379 functions->fViewport = nullGLViewport; |
385 functions->fBindFramebuffer = nullGLBindFramebuffer; | 380 functions->fBindFramebuffer = nullGLBindFramebuffer; |
386 functions->fBindRenderbuffer = nullGLBindRenderbuffer; | 381 functions->fBindRenderbuffer = nullGLBindRenderbuffer; |
387 functions->fCheckFramebufferStatus = noOpGLCheckFramebufferStatus; | 382 functions->fCheckFramebufferStatus = noOpGLCheckFramebufferStatus; |
388 functions->fDeleteFramebuffers = nullGLDeleteFramebuffers; | 383 functions->fDeleteFramebuffers = nullGLDeleteFramebuffers; |
389 functions->fDeleteRenderbuffers = nullGLDeleteRenderbuffers; | 384 functions->fDeleteRenderbuffers = nullGLDeleteRenderbuffers; |
390 functions->fFramebufferRenderbuffer = nullGLFramebufferRenderbuffer; | 385 functions->fFramebufferRenderbuffer = nullGLFramebufferRenderbuffer; |
391 functions->fFramebufferTexture2D = nullGLFramebufferTexture2D; | 386 functions->fFramebufferTexture2D = nullGLFramebufferTexture2D; |
392 functions->fGenFramebuffers = noOpGLGenIds; | 387 functions->fGenFramebuffers = noOpGLGenIds; |
393 functions->fGenRenderbuffers = noOpGLGenIds; | 388 functions->fGenRenderbuffers = noOpGLGenIds; |
394 functions->fGetFramebufferAttachmentParameteriv = noOpGLGetFramebufferAt
tachmentParameteriv; | 389 functions->fGetFramebufferAttachmentParameteriv = noOpGLGetFramebufferAttach
mentParameteriv; |
395 functions->fGetRenderbufferParameteriv = noOpGLGetRenderbufferParameteri
v; | 390 functions->fGetRenderbufferParameteriv = noOpGLGetRenderbufferParameteriv; |
396 functions->fRenderbufferStorage = noOpGLRenderbufferStorage; | 391 functions->fRenderbufferStorage = noOpGLRenderbufferStorage; |
397 functions->fRenderbufferStorageMultisample = noOpGLRenderbufferStorageMu
ltisample; | 392 functions->fRenderbufferStorageMultisample = noOpGLRenderbufferStorageMultis
ample; |
398 functions->fBlitFramebuffer = noOpGLBlitFramebuffer; | 393 functions->fBlitFramebuffer = noOpGLBlitFramebuffer; |
399 functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFram
ebuffer; | 394 functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFramebuf
fer; |
400 functions->fMapBuffer = nullGLMapBuffer; | 395 functions->fMapBuffer = nullGLMapBuffer; |
401 functions->fUnmapBuffer = nullGLUnmapBuffer; | 396 functions->fUnmapBuffer = nullGLUnmapBuffer; |
402 functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationInde
xed; | 397 functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationIndexed; |
403 } | 398 |
404 glInterface.get()->ref(); | 399 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functio
ns->fGetStringi, |
405 return glInterface.get(); | 400 functions->fGetIntegerv); |
| 401 return interface; |
406 } | 402 } |
OLD | NEW |