OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "GrGLNoOpInterface.h" | 8 #include "GrGLNoOpInterface.h" |
| 9 #include "SkString.h" |
| 10 #include "SkThread.h" |
9 | 11 |
10 // the OpenGLES 2.0 spec says this must be >= 128 | 12 // the OpenGLES 2.0 spec says this must be >= 128 |
11 static const GrGLint kDefaultMaxVertexUniformVectors = 128; | 13 static const GrGLint kDefaultMaxVertexUniformVectors = 128; |
12 | 14 |
13 // the OpenGLES 2.0 spec says this must be >=16 | 15 // the OpenGLES 2.0 spec says this must be >=16 |
14 static const GrGLint kDefaultMaxFragmentUniformVectors = 16; | 16 static const GrGLint kDefaultMaxFragmentUniformVectors = 16; |
15 | 17 |
16 // the OpenGLES 2.0 spec says this must be >= 8 | 18 // the OpenGLES 2.0 spec says this must be >= 8 |
17 static const GrGLint kDefaultMaxVertexAttribs = 8; | 19 static const GrGLint kDefaultMaxVertexAttribs = 8; |
18 | 20 |
19 // the OpenGLES 2.0 spec says this must be >= 8 | 21 // the OpenGLES 2.0 spec says this must be >= 8 |
20 static const GrGLint kDefaultMaxVaryingVectors = 8; | 22 static const GrGLint kDefaultMaxVaryingVectors = 8; |
21 | 23 |
| 24 static const char* kExtensions[] = { |
| 25 "GL_ARB_framebuffer_object", |
| 26 "GL_ARB_blend_func_extended", |
| 27 "GL_ARB_timer_query", |
| 28 "GL_ARB_draw_buffers", |
| 29 "GL_ARB_occlusion_query", |
| 30 "GL_EXT_blend_color", |
| 31 "GL_EXT_stencil_wrap" |
| 32 }; |
| 33 |
| 34 namespace { |
| 35 const GrGLubyte* combined_extensions_string() { |
| 36 static SkString gExtString; |
| 37 static SkMutex gMutex; |
| 38 gMutex.acquire(); |
| 39 if (0 == gExtString.size()) { |
| 40 for (size_t i = 0; i < GR_ARRAY_COUNT(kExtensions) - 1; ++i) { |
| 41 gExtString.append(kExtensions[i]); |
| 42 gExtString.append(" "); |
| 43 } |
| 44 gExtString.append(kExtensions[GR_ARRAY_COUNT(kExtensions) - 1]); |
| 45 } |
| 46 gMutex.release(); |
| 47 return (const GrGLubyte*) gExtString.c_str(); |
| 48 } |
| 49 } |
| 50 |
22 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendColor(GrGLclampf red, | 51 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendColor(GrGLclampf red, |
23 GrGLclampf green, | 52 GrGLclampf green, |
24 GrGLclampf blue, | 53 GrGLclampf blue, |
25 GrGLclampf alpha) { | 54 GrGLclampf alpha) { |
26 } | 55 } |
27 | 56 |
28 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBindFragDataLocation(GrGLuint program, | 57 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBindFragDataLocation(GrGLuint program, |
29 GrGLuint colorNumber, | 58 GrGLuint colorNumber, |
30 const GrGLchar* name) { | 59 const GrGLchar* name) { |
31 } | 60 } |
(...skipping 14 matching lines...) Expand all Loading... |
46 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLClearColor(GrGLclampf red, | 75 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLClearColor(GrGLclampf red, |
47 GrGLclampf green, | 76 GrGLclampf green, |
48 GrGLclampf blue, | 77 GrGLclampf blue, |
49 GrGLclampf alpha) { | 78 GrGLclampf alpha) { |
50 } | 79 } |
51 | 80 |
52 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLClearStencil(GrGLint s) { | 81 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLClearStencil(GrGLint s) { |
53 } | 82 } |
54 | 83 |
55 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLColorMask(GrGLboolean red, | 84 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLColorMask(GrGLboolean red, |
56 GrGLboolean green, | 85 GrGLboolean green, |
57 GrGLboolean blue, | 86 GrGLboolean blue, |
58 GrGLboolean alpha) { | 87 GrGLboolean alpha) { |
59 } | 88 } |
60 | 89 |
61 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCompileShader(GrGLuint shader) { | 90 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCompileShader(GrGLuint shader) { |
62 } | 91 } |
63 | 92 |
64 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCompressedTexImage2D(GrGLenum target, | 93 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCompressedTexImage2D(GrGLenum target, |
65 GrGLint level, | 94 GrGLint level, |
66 GrGLenum internalformat, | 95 GrGLenum internalformat, |
67 GrGLsizei width, | 96 GrGLsizei width, |
68 GrGLsizei height, | 97 GrGLsizei height, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLinkProgram(GrGLuint program) { | 154 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLinkProgram(GrGLuint program) { |
126 } | 155 } |
127 | 156 |
128 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLQueryCounter(GrGLuint id, GrGLenum target) { | 157 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLQueryCounter(GrGLuint id, GrGLenum target) { |
129 } | 158 } |
130 | 159 |
131 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLReadBuffer(GrGLenum src) { | 160 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLReadBuffer(GrGLenum src) { |
132 } | 161 } |
133 | 162 |
134 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLScissor(GrGLint x, | 163 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLScissor(GrGLint x, |
135 GrGLint y, | 164 GrGLint y, |
136 GrGLsizei width, | 165 GrGLsizei width, |
137 GrGLsizei height) { | 166 GrGLsizei height) { |
138 } | 167 } |
139 | 168 |
140 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLShaderSource(GrGLuint shader, | 169 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLShaderSource(GrGLuint shader, |
141 GrGLsizei count, | 170 GrGLsizei count, |
142 #if GR_USE_NEW_GL_SHADER_SOURCE_SIGNATURE | 171 #if GR_USE_NEW_GL_SHADER_SOURCE_SIGNATURE |
143 const char* const * str, | 172 const char* const * str, |
144 #else | 173 #else |
145 const char** str, | 174 const char** str, |
146 #endif | 175 #endif |
147 const GrGLint* length) { | 176 const GrGLint* length) { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 340 |
312 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttribPointer(GrGLuint indx, | 341 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttribPointer(GrGLuint indx, |
313 GrGLint size, | 342 GrGLint size, |
314 GrGLenum type, | 343 GrGLenum type, |
315 GrGLboolean normalized, | 344 GrGLboolean normalized, |
316 GrGLsizei stride, | 345 GrGLsizei stride, |
317 const GrGLvoid* ptr) { | 346 const GrGLvoid* ptr) { |
318 } | 347 } |
319 | 348 |
320 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLViewport(GrGLint x, | 349 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLViewport(GrGLint x, |
321 GrGLint y, | 350 GrGLint y, |
322 GrGLsizei width, | 351 GrGLsizei width, |
323 GrGLsizei height) { | 352 GrGLsizei height) { |
324 } | 353 } |
325 | 354 |
326 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetFramebufferAttachmentParameteriv(GrGLenu
m target, | 355 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetFramebufferAttachmentParameteriv(GrGLenu
m target, |
327 GrGLenum
attachment, | 356 GrGLenu
m attachment, |
328 GrGLenum
pname, | 357 GrGLenu
m pname, |
329 GrGLint*
params) { | 358 GrGLint
* params) { |
330 } | 359 } |
331 | 360 |
332 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetRenderbufferParameteriv(GrGLenum target, | 361 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetRenderbufferParameteriv(GrGLenum target, |
333 GrGLenum pname, | 362 GrGLenum pname, |
334 GrGLint* params) { | 363 GrGLint* params) { |
335 } | 364 } |
336 | 365 |
337 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLRenderbufferStorage(GrGLenum target, | 366 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLRenderbufferStorage(GrGLenum target, |
338 GrGLenum internalformat, | 367 GrGLenum internalformat, |
339 GrGLsizei width, | 368 GrGLsizei width, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 } | 415 } |
387 | 416 |
388 GrGLenum GR_GL_FUNCTION_TYPE noOpGLGetError() { | 417 GrGLenum GR_GL_FUNCTION_TYPE noOpGLGetError() { |
389 return GR_GL_NO_ERROR; | 418 return GR_GL_NO_ERROR; |
390 } | 419 } |
391 | 420 |
392 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetIntegerv(GrGLenum pname, GrGLint* params)
{ | 421 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetIntegerv(GrGLenum pname, GrGLint* params)
{ |
393 // TODO: remove from Ganesh the #defines for gets we don't use. | 422 // TODO: remove from Ganesh the #defines for gets we don't use. |
394 // We would like to minimize gets overall due to performance issues | 423 // We would like to minimize gets overall due to performance issues |
395 switch (pname) { | 424 switch (pname) { |
| 425 case GR_GL_CONTEXT_PROFILE_MASK: |
| 426 *params = GR_GL_CONTEXT_COMPATIBILITY_PROFILE_BIT; |
| 427 break; |
396 case GR_GL_STENCIL_BITS: | 428 case GR_GL_STENCIL_BITS: |
397 *params = 8; | 429 *params = 8; |
398 break; | 430 break; |
399 case GR_GL_SAMPLES: | 431 case GR_GL_SAMPLES: |
400 *params = 1; | 432 *params = 1; |
401 break; | 433 break; |
402 case GR_GL_FRAMEBUFFER_BINDING: | 434 case GR_GL_FRAMEBUFFER_BINDING: |
403 *params = 0; | 435 *params = 0; |
404 break; | 436 break; |
405 case GR_GL_VIEWPORT: | 437 case GR_GL_VIEWPORT: |
(...skipping 27 matching lines...) Expand all Loading... |
433 break; | 465 break; |
434 case GR_GL_MAX_SAMPLES: | 466 case GR_GL_MAX_SAMPLES: |
435 *params = 32; | 467 *params = 32; |
436 break; | 468 break; |
437 case GR_GL_MAX_VERTEX_ATTRIBS: | 469 case GR_GL_MAX_VERTEX_ATTRIBS: |
438 *params = kDefaultMaxVertexAttribs; | 470 *params = kDefaultMaxVertexAttribs; |
439 break; | 471 break; |
440 case GR_GL_MAX_VARYING_VECTORS: | 472 case GR_GL_MAX_VARYING_VECTORS: |
441 *params = kDefaultMaxVaryingVectors; | 473 *params = kDefaultMaxVaryingVectors; |
442 break; | 474 break; |
| 475 case GR_GL_NUM_EXTENSIONS: |
| 476 *params = GR_ARRAY_COUNT(kExtensions); |
| 477 break; |
443 default: | 478 default: |
444 GrCrash("Unexpected pname to GetIntegerv"); | 479 GrCrash("Unexpected pname to GetIntegerv"); |
445 } | 480 } |
446 } | 481 } |
447 | 482 |
448 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetInfoLog(GrGLuint program, | 483 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetInfoLog(GrGLuint program, |
449 GrGLsizei bufsize, | 484 GrGLsizei bufsize, |
450 GrGLsizei* length, | 485 GrGLsizei* length, |
451 char* infolog) { | 486 char* infolog) { |
452 if (length) { | 487 if (length) { |
453 *length = 0; | 488 *length = 0; |
454 } | 489 } |
455 if (bufsize > 0) { | 490 if (bufsize > 0) { |
456 *infolog = 0; | 491 *infolog = 0; |
457 } | 492 } |
458 } | 493 } |
459 | 494 |
460 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetShaderOrProgramiv(GrGLuint program, | 495 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetShaderOrProgramiv(GrGLuint program, |
461 GrGLenum pname, | 496 GrGLenum pname, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 | 562 |
528 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryObjectuiv(GrGLuint id, | 563 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryObjectuiv(GrGLuint id, |
529 GrGLenum pname, | 564 GrGLenum pname, |
530 GrGLuint *params) { | 565 GrGLuint *params) { |
531 query_result(id, pname, params); | 566 query_result(id, pname, params); |
532 } | 567 } |
533 | 568 |
534 const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetString(GrGLenum name) { | 569 const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetString(GrGLenum name) { |
535 switch (name) { | 570 switch (name) { |
536 case GR_GL_EXTENSIONS: | 571 case GR_GL_EXTENSIONS: |
537 return (const GrGLubyte*)"GL_ARB_framebuffer_object GL_ARB_blend_fun
c_extended GL_ARB_timer_query GL_ARB_draw_buffers GL_ARB_occlusion_query GL_EXT_
blend_color GL_EXT_stencil_wrap"; | 572 return combined_extensions_string(); |
538 case GR_GL_VERSION: | 573 case GR_GL_VERSION: |
539 return (const GrGLubyte*)"4.0 Debug GL"; | 574 return (const GrGLubyte*)"4.0 Debug GL"; |
540 case GR_GL_SHADING_LANGUAGE_VERSION: | 575 case GR_GL_SHADING_LANGUAGE_VERSION: |
541 return (const GrGLubyte*)"4.20.8 Debug GLSL"; | 576 return (const GrGLubyte*)"4.20.8 Debug GLSL"; |
542 case GR_GL_VENDOR: | 577 case GR_GL_VENDOR: |
543 return (const GrGLubyte*)"Debug Vendor"; | 578 return (const GrGLubyte*)"Debug Vendor"; |
544 case GR_GL_RENDERER: | 579 case GR_GL_RENDERER: |
545 return (const GrGLubyte*)"The Debug (Non-)Renderer"; | 580 return (const GrGLubyte*)"The Debug (Non-)Renderer"; |
546 default: | 581 default: |
547 GrCrash("Unexpected name to GetString"); | 582 GrCrash("Unexpected name passed to GetString"); |
548 return NULL; | 583 return NULL; |
549 } | 584 } |
550 } | 585 } |
551 | 586 |
| 587 const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetStringi(GrGLenum name, GrGLuint i)
{ |
| 588 switch (name) { |
| 589 case GR_GL_EXTENSIONS: |
| 590 if (static_cast<size_t>(i) <= GR_ARRAY_COUNT(kExtensions)) { |
| 591 return (const GrGLubyte*) kExtensions[i]; |
| 592 } else { |
| 593 return NULL; |
| 594 } |
| 595 default: |
| 596 GrCrash("Unexpected name passed to GetStringi"); |
| 597 return NULL; |
| 598 } |
| 599 } |
| 600 |
552 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetTexLevelParameteriv(GrGLenum target, | 601 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetTexLevelParameteriv(GrGLenum target, |
553 GrGLint level, | 602 GrGLint level, |
554 GrGLenum pname, | 603 GrGLenum pname, |
555 GrGLint* params) { | 604 GrGLint* params) { |
556 // we used to use this to query stuff about externally created textures, | 605 // we used to use this to query stuff about externally created textures, |
557 // now we just require clients to tell us everything about the texture. | 606 // now we just require clients to tell us everything about the texture. |
558 GrCrash("Should never query texture parameters."); | 607 GrCrash("Should never query texture parameters."); |
559 } | 608 } |
560 | 609 |
561 GrGLint GR_GL_FUNCTION_TYPE noOpGLGetUniformLocation(GrGLuint program, | 610 GrGLint GR_GL_FUNCTION_TYPE noOpGLGetUniformLocation(GrGLuint program, const cha
r* name) { |
562 const char* name) { | |
563 static int gUniLocation = 0; | 611 static int gUniLocation = 0; |
564 return ++gUniLocation; | 612 return ++gUniLocation; |
565 } | 613 } |
OLD | NEW |