Debian Codegraph @

src/gpu/ganesh/gl/mac/GrGLMakeNativeInterface_mac.cpp

raw
1 /*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #include "include/core/SkTypes.h"
8 #ifdef SK_BUILD_FOR_MAC
9
10 #include "include/gpu/ganesh/gl/GrGLAssembleInterface.h"
11 #include "include/gpu/ganesh/gl/GrGLInterface.h"
12 #include "include/gpu/ganesh/gl/mac/GrGLMakeMacInterface.h"
13 #include "include/private/base/SkTemplates.h"
14
15 #include <dlfcn.h>
16 #include <memory>
17
18 namespace GrGLInterfaces {
19 sk_sp<const GrGLInterface> MakeMac() {
20 static const char kPath[] =
21 "/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib";
22 std::unique_ptr<void, SkFunctionObject<dlclose>> lib(dlopen(kPath, RTLD_LAZY));
23 return GrGLMakeAssembledGLInterface(lib.get(), [](void* ctx, const char* name) {
24 return (GrGLFuncPtr)dlsym(ctx ? ctx : RTLD_DEFAULT, name); });
25 }
26
27 } // namespace GrGLInterfaces
28
29 #if !defined(SK_DISABLE_LEGACY_GL_MAKE_NATIVE_INTERFACE)
30 sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
31 return GrGLInterfaces::MakeMac();
32 }
33 #endif
34
35 #endif // SK_BUILD_FOR_MAC