1/*
2 * Copyright 2014 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
8
9#include "gl/GrGLInterface.h"
10#include "gl/GrGLAssembleInterface.h"
11#include "gl/GrGLUtil.h"
12
13#include <GL/glx.h>
14
15static GrGLFuncPtr glx_get(void* ctx, const char name[]) {
16    // Avoid calling glXGetProcAddress() for EGL procs.
17    // We don't expect it to ever succeed, but somtimes it returns non-null anyway.
18    if (0 == strncmp(name, "egl", 3)) {
19        return nullptr;
20    }
21
22    SkASSERT(nullptr == ctx);
23    SkASSERT(glXGetCurrentContext());
24    return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name));
25}
26
27const GrGLInterface* GrGLCreateNativeInterface() {
28    if (nullptr == glXGetCurrentContext()) {
29        return nullptr;
30    }
31
32    return GrGLAssembleInterface(nullptr, glx_get);
33}
34