| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "gl/GrGLInterface.h" | 9 #include "gl/GrGLInterface.h" |
| 10 #include "gl/GrGLAssembleInterface.h" | 10 #include "gl/GrGLAssembleInterface.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 bool isInitialized() const { return SkToBool(fGLLib.get()); } | 35 bool isInitialized() const { return SkToBool(fGLLib.get()); } |
| 36 | 36 |
| 37 GrGLFuncPtr getProc(const char name[]) const { | 37 GrGLFuncPtr getProc(const char name[]) const { |
| 38 GrGLFuncPtr proc; | 38 GrGLFuncPtr proc; |
| 39 if ((proc = (GrGLFuncPtr) GetProcAddress(fGLLib.get(), name))) { | 39 if ((proc = (GrGLFuncPtr) GetProcAddress(fGLLib.get(), name))) { |
| 40 return proc; | 40 return proc; |
| 41 } | 41 } |
| 42 if ((proc = (GrGLFuncPtr) wglGetProcAddress(name))) { | 42 if ((proc = (GrGLFuncPtr) wglGetProcAddress(name))) { |
| 43 return proc; | 43 return proc; |
| 44 } | 44 } |
| 45 return NULL; | 45 return nullptr; |
| 46 } | 46 } |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 AutoLibraryUnload fGLLib; | 49 AutoLibraryUnload fGLLib; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 static GrGLFuncPtr win_get_gl_proc(void* ctx, const char name[]) { | 52 static GrGLFuncPtr win_get_gl_proc(void* ctx, const char name[]) { |
| 53 SkASSERT(ctx); | 53 SkASSERT(ctx); |
| 54 SkASSERT(wglGetCurrentContext()); | 54 SkASSERT(wglGetCurrentContext()); |
| 55 const GLProcGetter* getter = (const GLProcGetter*) ctx; | 55 const GLProcGetter* getter = (const GLProcGetter*) ctx; |
| 56 return getter->getProc(name); | 56 return getter->getProc(name); |
| 57 } | 57 } |
| 58 | 58 |
| 59 /* | 59 /* |
| 60 * Windows makes the GL funcs all be __stdcall instead of __cdecl :( | 60 * Windows makes the GL funcs all be __stdcall instead of __cdecl :( |
| 61 * This implementation will only work if GR_GL_FUNCTION_TYPE is __stdcall. | 61 * This implementation will only work if GR_GL_FUNCTION_TYPE is __stdcall. |
| 62 * Otherwise, a springboard would be needed that hides the calling convention. | 62 * Otherwise, a springboard would be needed that hides the calling convention. |
| 63 */ | 63 */ |
| 64 const GrGLInterface* GrGLCreateNativeInterface() { | 64 const GrGLInterface* GrGLCreateNativeInterface() { |
| 65 if (NULL == wglGetCurrentContext()) { | 65 if (nullptr == wglGetCurrentContext()) { |
| 66 return NULL; | 66 return nullptr; |
| 67 } | 67 } |
| 68 | 68 |
| 69 GLProcGetter getter; | 69 GLProcGetter getter; |
| 70 if (!getter.isInitialized()) { | 70 if (!getter.isInitialized()) { |
| 71 return NULL; | 71 return nullptr; |
| 72 } | 72 } |
| 73 | 73 |
| 74 GrGLGetStringProc getString = (GrGLGetStringProc)getter.getProc("glGetString
"); | 74 GrGLGetStringProc getString = (GrGLGetStringProc)getter.getProc("glGetString
"); |
| 75 if (NULL == getString) { | 75 if (nullptr == getString) { |
| 76 return NULL; | 76 return nullptr; |
| 77 } | 77 } |
| 78 const char* verStr = reinterpret_cast<const char*>(getString(GR_GL_VERSION))
; | 78 const char* verStr = reinterpret_cast<const char*>(getString(GR_GL_VERSION))
; |
| 79 GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); | 79 GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); |
| 80 | 80 |
| 81 if (kGLES_GrGLStandard == standard) { | 81 if (kGLES_GrGLStandard == standard) { |
| 82 return GrGLAssembleGLESInterface(&getter, win_get_gl_proc); | 82 return GrGLAssembleGLESInterface(&getter, win_get_gl_proc); |
| 83 } else if (kGL_GrGLStandard == standard) { | 83 } else if (kGL_GrGLStandard == standard) { |
| 84 return GrGLAssembleGLInterface(&getter, win_get_gl_proc); | 84 return GrGLAssembleGLInterface(&getter, win_get_gl_proc); |
| 85 } | 85 } |
| 86 return NULL; | 86 return nullptr; |
| 87 } | 87 } |
| OLD | NEW |