aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
blob: 1ebd376288be575b9b633c2af3b47f9f2bae8da6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "gl/GrGLInterface.h"
#include "gl/GrGLAssembleInterface.h"
#include "../ports/SkOSLibrary.h"

#include <EGL/egl.h>

static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) {
    GrGLFuncPtr proc = (GrGLFuncPtr) GetProcedureAddress(ctx, name);
    if (proc) {
        return proc;
    }
    return eglGetProcAddress(name);
}

const GrGLInterface* GrGLCreateANGLEInterface() {
    static void* gANGLELib = nullptr;

    if (nullptr == gANGLELib) {
        // We load the ANGLE library and never let it go
#if defined _WIN32
        gANGLELib = DynamicLoadLibrary("libGLESv2.dll");
#else
        gANGLELib = DynamicLoadLibrary("libGLESv2.so");
#endif // defined _WIN32
    }

    if (nullptr == gANGLELib) {
        // We can't setup the interface correctly w/o the so
        return nullptr;
    }

    return GrGLAssembleGLESInterface(gANGLELib, angle_get_gl_proc);
}