OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "GrGLAssembleInterface.h" | 10 #include "GrGLAssembleInterface.h" |
11 #include "GrGLUtil.h" | 11 #include "GrGLUtil.h" |
12 | 12 |
13 #define GET_PROC(F) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F) | 13 #define GET_PROC(F) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F) |
14 #define GET_PROC_SUFFIX(F, S) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "
gl" #F #S) | 14 #define GET_PROC_SUFFIX(F, S) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "
gl" #F #S) |
15 #define GET_PROC_LOCAL(F) GrGL ## F ## Proc F = (GrGL ## F ## Proc) get(ctx, "gl
" #F) | 15 #define GET_PROC_LOCAL(F) GrGL ## F ## Proc F = (GrGL ## F ## Proc) get(ctx, "gl
" #F) |
16 | 16 |
17 const GrGLInterface* GrGLAssembleInterface(void* ctx, GrGLGetProc get) { | 17 const GrGLInterface* GrGLAssembleInterface(void* ctx, GrGLGetProc get) { |
18 GET_PROC_LOCAL(GetString); | 18 GET_PROC_LOCAL(GetString); |
19 if (NULL == GetString) { | 19 if (nullptr == GetString) { |
20 return NULL; | 20 return nullptr; |
21 } | 21 } |
22 | 22 |
23 const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION))
; | 23 const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION))
; |
24 if (NULL == verStr) { | 24 if (nullptr == verStr) { |
25 return NULL; | 25 return nullptr; |
26 } | 26 } |
27 | 27 |
28 GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); | 28 GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); |
29 | 29 |
30 if (kGLES_GrGLStandard == standard) { | 30 if (kGLES_GrGLStandard == standard) { |
31 return GrGLAssembleGLESInterface(ctx, get); | 31 return GrGLAssembleGLESInterface(ctx, get); |
32 } else if (kGL_GrGLStandard == standard) { | 32 } else if (kGL_GrGLStandard == standard) { |
33 return GrGLAssembleGLInterface(ctx, get); | 33 return GrGLAssembleGLInterface(ctx, get); |
34 } | 34 } |
35 return NULL; | 35 return nullptr; |
36 } | 36 } |
37 | 37 |
38 const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) { | 38 const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) { |
39 GET_PROC_LOCAL(GetString); | 39 GET_PROC_LOCAL(GetString); |
40 GET_PROC_LOCAL(GetStringi); | 40 GET_PROC_LOCAL(GetStringi); |
41 GET_PROC_LOCAL(GetIntegerv); | 41 GET_PROC_LOCAL(GetIntegerv); |
42 | 42 |
43 // GetStringi may be NULL depending on the GL version. | 43 // GetStringi may be nullptr depending on the GL version. |
44 if (NULL == GetString || NULL == GetIntegerv) { | 44 if (nullptr == GetString || nullptr == GetIntegerv) { |
45 return NULL; | 45 return nullptr; |
46 } | 46 } |
47 | 47 |
48 const char* versionString = (const char*) GetString(GR_GL_VERSION); | 48 const char* versionString = (const char*) GetString(GR_GL_VERSION); |
49 GrGLVersion glVer = GrGLGetVersionFromString(versionString); | 49 GrGLVersion glVer = GrGLGetVersionFromString(versionString); |
50 | 50 |
51 if (glVer < GR_GL_VER(1,5) || GR_GL_INVALID_VER == glVer) { | 51 if (glVer < GR_GL_VER(1,5) || GR_GL_INVALID_VER == glVer) { |
52 // We must have array and element_array buffer objects. | 52 // We must have array and element_array buffer objects. |
53 return NULL; | 53 return nullptr; |
54 } | 54 } |
55 | 55 |
56 GrGLExtensions extensions; | 56 GrGLExtensions extensions; |
57 if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv))
{ | 57 if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv))
{ |
58 return NULL; | 58 return nullptr; |
59 } | 59 } |
60 | 60 |
61 GrGLInterface* interface = new GrGLInterface(); | 61 GrGLInterface* interface = new GrGLInterface(); |
62 GrGLInterface::Functions* functions = &interface->fFunctions; | 62 GrGLInterface::Functions* functions = &interface->fFunctions; |
63 | 63 |
64 GET_PROC(ActiveTexture); | 64 GET_PROC(ActiveTexture); |
65 GET_PROC(AttachShader); | 65 GET_PROC(AttachShader); |
66 GET_PROC(BindAttribLocation); | 66 GET_PROC(BindAttribLocation); |
67 GET_PROC(BindBuffer); | 67 GET_PROC(BindBuffer); |
68 if (glVer >= GR_GL_VER(3,0)) { | 68 if (glVer >= GR_GL_VER(3,0)) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 GET_PROC_SUFFIX(BindRenderbuffer, EXT); | 259 GET_PROC_SUFFIX(BindRenderbuffer, EXT); |
260 if (extensions.has("GL_EXT_framebuffer_multisample")) { | 260 if (extensions.has("GL_EXT_framebuffer_multisample")) { |
261 GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); | 261 GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); |
262 } | 262 } |
263 if (extensions.has("GL_EXT_framebuffer_blit")) { | 263 if (extensions.has("GL_EXT_framebuffer_blit")) { |
264 GET_PROC_SUFFIX(BlitFramebuffer, EXT); | 264 GET_PROC_SUFFIX(BlitFramebuffer, EXT); |
265 } | 265 } |
266 } else { | 266 } else { |
267 // we must have FBOs | 267 // we must have FBOs |
268 delete interface; | 268 delete interface; |
269 return NULL; | 269 return nullptr; |
270 } | 270 } |
271 | 271 |
272 if (extensions.has("GL_NV_path_rendering")) { | 272 if (extensions.has("GL_NV_path_rendering")) { |
273 GET_PROC_SUFFIX(MatrixLoadf, EXT); | 273 GET_PROC_SUFFIX(MatrixLoadf, EXT); |
274 GET_PROC_SUFFIX(MatrixLoadIdentity, EXT); | 274 GET_PROC_SUFFIX(MatrixLoadIdentity, EXT); |
275 GET_PROC_SUFFIX(PathCommands, NV); | 275 GET_PROC_SUFFIX(PathCommands, NV); |
276 GET_PROC_SUFFIX(PathParameteri, NV); | 276 GET_PROC_SUFFIX(PathParameteri, NV); |
277 GET_PROC_SUFFIX(PathParameterf, NV); | 277 GET_PROC_SUFFIX(PathParameterf, NV); |
278 GET_PROC_SUFFIX(GenPaths, NV); | 278 GET_PROC_SUFFIX(GenPaths, NV); |
279 GET_PROC_SUFFIX(DeletePaths, NV); | 279 GET_PROC_SUFFIX(DeletePaths, NV); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 } | 462 } |
463 | 463 |
464 interface->fStandard = kGL_GrGLStandard; | 464 interface->fStandard = kGL_GrGLStandard; |
465 interface->fExtensions.swap(&extensions); | 465 interface->fExtensions.swap(&extensions); |
466 | 466 |
467 return interface; | 467 return interface; |
468 } | 468 } |
469 | 469 |
470 const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) { | 470 const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) { |
471 GET_PROC_LOCAL(GetString); | 471 GET_PROC_LOCAL(GetString); |
472 if (NULL == GetString) { | 472 if (nullptr == GetString) { |
473 return NULL; | 473 return nullptr; |
474 } | 474 } |
475 | 475 |
476 const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION))
; | 476 const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION))
; |
477 GrGLVersion version = GrGLGetVersionFromString(verStr); | 477 GrGLVersion version = GrGLGetVersionFromString(verStr); |
478 | 478 |
479 if (version < GR_GL_VER(2,0)) { | 479 if (version < GR_GL_VER(2,0)) { |
480 return NULL; | 480 return nullptr; |
481 } | 481 } |
482 | 482 |
483 GET_PROC_LOCAL(GetIntegerv); | 483 GET_PROC_LOCAL(GetIntegerv); |
484 GET_PROC_LOCAL(GetStringi); | 484 GET_PROC_LOCAL(GetStringi); |
485 GrGLExtensions extensions; | 485 GrGLExtensions extensions; |
486 if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv)
) { | 486 if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv)
) { |
487 return NULL; | 487 return nullptr; |
488 } | 488 } |
489 | 489 |
490 GrGLInterface* interface = new GrGLInterface; | 490 GrGLInterface* interface = new GrGLInterface; |
491 GrGLInterface::Functions* functions = &interface->fFunctions; | 491 GrGLInterface::Functions* functions = &interface->fFunctions; |
492 | 492 |
493 GET_PROC(ActiveTexture); | 493 GET_PROC(ActiveTexture); |
494 GET_PROC(AttachShader); | 494 GET_PROC(AttachShader); |
495 GET_PROC(BindAttribLocation); | 495 GET_PROC(BindAttribLocation); |
496 GET_PROC(BindBuffer); | 496 GET_PROC(BindBuffer); |
497 GET_PROC(BindTexture); | 497 GET_PROC(BindTexture); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 } else if (extensions.has("GL_EXT_map_buffer_range")) { | 663 } else if (extensions.has("GL_EXT_map_buffer_range")) { |
664 GET_PROC_SUFFIX(MapBufferRange, EXT); | 664 GET_PROC_SUFFIX(MapBufferRange, EXT); |
665 GET_PROC_SUFFIX(FlushMappedBufferRange, EXT); | 665 GET_PROC_SUFFIX(FlushMappedBufferRange, EXT); |
666 } | 666 } |
667 | 667 |
668 if (extensions.has("GL_EXT_debug_marker")) { | 668 if (extensions.has("GL_EXT_debug_marker")) { |
669 GET_PROC(InsertEventMarker); | 669 GET_PROC(InsertEventMarker); |
670 GET_PROC(PushGroupMarker); | 670 GET_PROC(PushGroupMarker); |
671 GET_PROC(PopGroupMarker); | 671 GET_PROC(PopGroupMarker); |
672 // The below check is here because a device has been found that has the
extension string but | 672 // The below check is here because a device has been found that has the
extension string but |
673 // returns NULL from the eglGetProcAddress for the functions | 673 // returns nullptr from the eglGetProcAddress for the functions |
674 if (NULL == functions->fInsertEventMarker || | 674 if (nullptr == functions->fInsertEventMarker || |
675 NULL == functions->fPushGroupMarker || | 675 nullptr == functions->fPushGroupMarker || |
676 NULL == functions->fPopGroupMarker) { | 676 nullptr == functions->fPopGroupMarker) { |
677 extensions.remove("GL_EXT_debug_marker"); | 677 extensions.remove("GL_EXT_debug_marker"); |
678 } | 678 } |
679 } | 679 } |
680 | 680 |
681 GET_PROC(InvalidateFramebuffer); | 681 GET_PROC(InvalidateFramebuffer); |
682 GET_PROC(InvalidateSubFramebuffer); | 682 GET_PROC(InvalidateSubFramebuffer); |
683 GET_PROC(InvalidateBufferData); | 683 GET_PROC(InvalidateBufferData); |
684 GET_PROC(InvalidateBufferSubData); | 684 GET_PROC(InvalidateBufferSubData); |
685 GET_PROC(InvalidateTexImage); | 685 GET_PROC(InvalidateTexImage); |
686 GET_PROC(InvalidateTexSubImage); | 686 GET_PROC(InvalidateTexSubImage); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 GET_PROC_SUFFIX(PushDebugGroup, KHR); | 751 GET_PROC_SUFFIX(PushDebugGroup, KHR); |
752 GET_PROC_SUFFIX(PopDebugGroup, KHR); | 752 GET_PROC_SUFFIX(PopDebugGroup, KHR); |
753 GET_PROC_SUFFIX(ObjectLabel, KHR); | 753 GET_PROC_SUFFIX(ObjectLabel, KHR); |
754 } | 754 } |
755 | 755 |
756 interface->fStandard = kGLES_GrGLStandard; | 756 interface->fStandard = kGLES_GrGLStandard; |
757 interface->fExtensions.swap(&extensions); | 757 interface->fExtensions.swap(&extensions); |
758 | 758 |
759 return interface; | 759 return interface; |
760 } | 760 } |
OLD | NEW |