1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2016 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
8cb93a386Sopenharmony_ci
9cb93a386Sopenharmony_ci#include "include/gpu/gl/GrGLAssembleInterface.h"
10cb93a386Sopenharmony_ci#include "include/gpu/gl/GrGLInterface.h"
11cb93a386Sopenharmony_ci#include "src/gpu/gl/GrGLUtil.h"
12cb93a386Sopenharmony_ci
13cb93a386Sopenharmony_ci#include <GLFW/glfw3.h>
14cb93a386Sopenharmony_ci
15cb93a386Sopenharmony_cistatic GrGLFuncPtr glfw_get(void* ctx, const char name[]) {
16cb93a386Sopenharmony_ci    SkASSERT(nullptr == ctx);
17cb93a386Sopenharmony_ci    SkASSERT(glfwGetCurrentContext());
18cb93a386Sopenharmony_ci    return glfwGetProcAddress(name);
19cb93a386Sopenharmony_ci}
20cb93a386Sopenharmony_ci
21cb93a386Sopenharmony_cisk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
22cb93a386Sopenharmony_ci    if (nullptr == glfwGetCurrentContext()) {
23cb93a386Sopenharmony_ci        return nullptr;
24cb93a386Sopenharmony_ci    }
25cb93a386Sopenharmony_ci
26cb93a386Sopenharmony_ci    return GrGLMakeAssembledInterface(nullptr, glfw_get);
27cb93a386Sopenharmony_ci}
28cb93a386Sopenharmony_ci
29cb93a386Sopenharmony_ciconst GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }
30