OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 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 "SkMutex.h" | 9 #include "SkMutex.h" |
10 #include "SkOnce.h" | 10 #include "SkOnce.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 static MakeCurrentProc gfMakeCurrent = nullptr; | 81 static MakeCurrentProc gfMakeCurrent = nullptr; |
82 static SwapBuffersProc gfSwapBuffers = nullptr; | 82 static SwapBuffersProc gfSwapBuffers = nullptr; |
83 static GetProcAddressProc gfGetProcAddress = nullptr; | 83 static GetProcAddressProc gfGetProcAddress = nullptr; |
84 | 84 |
85 static void* gLibrary = nullptr; | 85 static void* gLibrary = nullptr; |
86 static bool gfFunctionsLoadedSuccessfully = false; | 86 static bool gfFunctionsLoadedSuccessfully = false; |
87 | 87 |
88 namespace { | 88 namespace { |
89 static void load_command_buffer_functions() { | 89 static void load_command_buffer_functions() { |
90 if (!gLibrary) { | 90 if (!gLibrary) { |
| 91 static constexpr const char* libName = |
91 #if defined _WIN32 | 92 #if defined _WIN32 |
92 gLibrary = DynamicLoadLibrary("command_buffer_gles2.dll"); | 93 "command_buffer_gles2.dll"; |
93 #elif defined SK_BUILD_FOR_MAC | 94 #elif defined SK_BUILD_FOR_MAC |
94 gLibrary = DynamicLoadLibrary("libcommand_buffer_gles2.dylib"); | 95 "libcommand_buffer_gles2.dylib"; |
95 #else | 96 #else |
96 gLibrary = DynamicLoadLibrary("libcommand_buffer_gles2.so"); | 97 "libcommand_buffer_gles2.so"; |
97 #endif // defined _WIN32 | 98 #endif // defined _WIN32 |
| 99 gLibrary = DynamicLoadLibrary(libName); |
98 if (gLibrary) { | 100 if (gLibrary) { |
99 gfGetDisplay = (GetDisplayProc)GetProcedureAddress(gLibrary, "eglGet
Display"); | 101 gfGetDisplay = (GetDisplayProc)GetProcedureAddress(gLibrary, "eglGet
Display"); |
100 gfInitialize = (InitializeProc)GetProcedureAddress(gLibrary, "eglIni
tialize"); | 102 gfInitialize = (InitializeProc)GetProcedureAddress(gLibrary, "eglIni
tialize"); |
101 gfTerminate = (TerminateProc)GetProcedureAddress(gLibrary, "eglTermi
nate"); | 103 gfTerminate = (TerminateProc)GetProcedureAddress(gLibrary, "eglTermi
nate"); |
102 gfChooseConfig = (ChooseConfigProc)GetProcedureAddress(gLibrary, "eg
lChooseConfig"); | 104 gfChooseConfig = (ChooseConfigProc)GetProcedureAddress(gLibrary, "eg
lChooseConfig"); |
103 gfGetConfigAttrib = (GetConfigAttrib)GetProcedureAddress(gLibrary, "
eglGetConfigAttrib"); | 105 gfGetConfigAttrib = (GetConfigAttrib)GetProcedureAddress(gLibrary, "
eglGetConfigAttrib"); |
104 gfCreateWindowSurface = (CreateWindowSurfaceProc)GetProcedureAddress
(gLibrary, "eglCreateWindowSurface"); | 106 gfCreateWindowSurface = (CreateWindowSurfaceProc)GetProcedureAddress
(gLibrary, "eglCreateWindowSurface"); |
105 gfCreatePbufferSurface = (CreatePbufferSurfaceProc)GetProcedureAddre
ss(gLibrary, "eglCreatePbufferSurface"); | 107 gfCreatePbufferSurface = (CreatePbufferSurfaceProc)GetProcedureAddre
ss(gLibrary, "eglCreatePbufferSurface"); |
106 gfDestroySurface = (DestroySurfaceProc)GetProcedureAddress(gLibrary,
"eglDestroySurface"); | 108 gfDestroySurface = (DestroySurfaceProc)GetProcedureAddress(gLibrary,
"eglDestroySurface"); |
107 gfCreateContext = (CreateContextProc)GetProcedureAddress(gLibrary, "
eglCreateContext"); | 109 gfCreateContext = (CreateContextProc)GetProcedureAddress(gLibrary, "
eglCreateContext"); |
108 gfDestroyContext = (DestroyContextProc)GetProcedureAddress(gLibrary,
"eglDestroyContext"); | 110 gfDestroyContext = (DestroyContextProc)GetProcedureAddress(gLibrary,
"eglDestroyContext"); |
109 gfMakeCurrent = (MakeCurrentProc)GetProcedureAddress(gLibrary, "eglM
akeCurrent"); | 111 gfMakeCurrent = (MakeCurrentProc)GetProcedureAddress(gLibrary, "eglM
akeCurrent"); |
110 gfSwapBuffers = (SwapBuffersProc)GetProcedureAddress(gLibrary, "eglS
wapBuffers"); | 112 gfSwapBuffers = (SwapBuffersProc)GetProcedureAddress(gLibrary, "eglS
wapBuffers"); |
111 gfGetProcAddress = (GetProcAddressProc)GetProcedureAddress(gLibrary,
"eglGetProcAddress"); | 113 gfGetProcAddress = (GetProcAddressProc)GetProcedureAddress(gLibrary,
"eglGetProcAddress"); |
112 | 114 |
113 gfFunctionsLoadedSuccessfully = gfGetDisplay && gfInitialize && gfTe
rminate && | 115 gfFunctionsLoadedSuccessfully = gfGetDisplay && gfInitialize && gfTe
rminate && |
114 gfChooseConfig && gfCreateWindowSurf
ace && | 116 gfChooseConfig && gfCreateWindowSurf
ace && |
115 gfCreatePbufferSurface && gfDestroyS
urface && | 117 gfCreatePbufferSurface && gfDestroyS
urface && |
116 gfCreateContext && gfDestroyContext
&& gfMakeCurrent && | 118 gfCreateContext && gfDestroyContext
&& gfMakeCurrent && |
117 gfSwapBuffers && gfGetProcAddress; | 119 gfSwapBuffers && gfGetProcAddress; |
118 | 120 |
| 121 } else { |
| 122 SkDebugf("Could not load %s.\n", libName); |
119 } | 123 } |
120 } | 124 } |
121 } | 125 } |
122 | 126 |
123 static GrGLFuncPtr command_buffer_get_gl_proc(void* ctx, const char name[]) { | 127 static GrGLFuncPtr command_buffer_get_gl_proc(void* ctx, const char name[]) { |
124 if (!gfFunctionsLoadedSuccessfully) { | 128 if (!gfFunctionsLoadedSuccessfully) { |
125 return nullptr; | 129 return nullptr; |
126 } | 130 } |
127 return gfGetProcAddress(name); | 131 return gfGetProcAddress(name); |
128 } | 132 } |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 return result; | 337 return result; |
334 } | 338 } |
335 | 339 |
336 int CommandBufferGLTestContext::getSampleCount() { | 340 int CommandBufferGLTestContext::getSampleCount() { |
337 EGLint result = 0; | 341 EGLint result = 0; |
338 gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_SAMPLES, &r
esult); | 342 gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_SAMPLES, &r
esult); |
339 return result; | 343 return result; |
340 } | 344 } |
341 | 345 |
342 } // namespace sk_gpu_test | 346 } // namespace sk_gpu_test |
OLD | NEW |