1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2014 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci#include "include/core/SkTypes.h" 8cb93a386Sopenharmony_ci#ifdef SK_BUILD_FOR_IOS 9cb93a386Sopenharmony_ci 10cb93a386Sopenharmony_ci#include "include/gpu/gl/GrGLInterface.h" 11cb93a386Sopenharmony_ci 12cb93a386Sopenharmony_ci#include "include/gpu/gl/GrGLAssembleInterface.h" 13cb93a386Sopenharmony_ci#include "include/private/SkTemplates.h" 14cb93a386Sopenharmony_ci 15cb93a386Sopenharmony_ci#include <dlfcn.h> 16cb93a386Sopenharmony_ci#include <memory> 17cb93a386Sopenharmony_ci 18cb93a386Sopenharmony_cisk_sp<const GrGLInterface> GrGLMakeNativeInterface() { 19cb93a386Sopenharmony_ci static const char kPath[] = 20cb93a386Sopenharmony_ci "/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"; 21cb93a386Sopenharmony_ci std::unique_ptr<void, SkFunctionWrapper<int(void*), dlclose>> lib(dlopen(kPath, RTLD_LAZY)); 22cb93a386Sopenharmony_ci return GrGLMakeAssembledGLESInterface(lib.get(), [](void* ctx, const char* name) { 23cb93a386Sopenharmony_ci return (GrGLFuncPtr)dlsym(ctx ? ctx : RTLD_DEFAULT, name); }); 24cb93a386Sopenharmony_ci} 25cb93a386Sopenharmony_ci 26cb93a386Sopenharmony_ciconst GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); } 27cb93a386Sopenharmony_ci 28cb93a386Sopenharmony_ci#endif // SK_BUILD_FOR_IOS 29