| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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/GrGLAssembleInterface.h" | 10 #include "gl/GrGLAssembleInterface.h" |
| 11 #include "gl/GrGLUtil.h" | 11 #include "gl/GrGLUtil.h" |
| 12 | 12 |
| 13 #include <GL/glx.h> | 13 #include <GL/glx.h> |
| 14 | 14 |
| 15 #define GET_PROC(F) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F) | |
| 16 #define GET_PROC_SUFFIX(F, S) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "
gl" #F #S) | |
| 17 #define GET_PROC_LOCAL(F) GrGL ## F ## Proc F = (GrGL ## F ## Proc) get(ctx, "gl
" #F) | |
| 18 | |
| 19 #define GET_LINKED GET_PROC | |
| 20 #define GET_LINKED_SUFFIX GET_PROC_SUFFIX | |
| 21 | |
| 22 #include "gl/GrGLAssembleGLESInterface.h" | |
| 23 | |
| 24 static GrGLFuncPtr glx_get(void* ctx, const char name[]) { | 15 static GrGLFuncPtr glx_get(void* ctx, const char name[]) { |
| 25 SkASSERT(NULL == ctx); | 16 SkASSERT(NULL == ctx); |
| 26 SkASSERT(NULL != glXGetCurrentContext()); | 17 SkASSERT(NULL != glXGetCurrentContext()); |
| 27 return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name)); | 18 return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name)); |
| 28 } | 19 } |
| 29 | 20 |
| 30 const GrGLInterface* GrGLCreateNativeInterface() { | 21 const GrGLInterface* GrGLCreateNativeInterface() { |
| 31 if (NULL == glXGetCurrentContext()) { | 22 if (NULL == glXGetCurrentContext()) { |
| 32 return NULL; | 23 return NULL; |
| 33 } | 24 } |
| 34 | 25 |
| 35 const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION
)); | 26 return GrGLAssembleInterface(NULL, glx_get); |
| 36 GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); | |
| 37 | |
| 38 if (kGLES_GrGLStandard == standard) { | |
| 39 return GrGLAssembleGLESInterface(NULL, glx_get); | |
| 40 } else if (kGL_GrGLStandard == standard) { | |
| 41 return GrGLAssembleGLInterface(NULL, glx_get); | |
| 42 } | |
| 43 return NULL; | |
| 44 } | 27 } |
| OLD | NEW |