Debian Codegraph @

src/gpu/ganesh/gl/webgl/GrGLMakeNativeInterface_webgl.cpp

raw
1 /*
2 * Copyright 2020 Google LLC
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/gpu/ganesh/gl/GrGLAssembleInterface.h"
8 #include "include/gpu/ganesh/gl/GrGLInterface.h"
9 #include "include/gpu/ganesh/gl/GrGLMakeWebGLInterface.h"
10
11 #include <GLES3/gl32.h>
12
13 static GrGLFuncPtr webgl_get_gl_proc(void* ctx, const char name[]) {
14
15 #define M(X) if (0 == strcmp(#X, name)) { return (GrGLFuncPtr) X; }
16 M(glGetString)
17 #undef M
18
19 // We explicitly do not use GetProcAddress or something similar because
20 // its code size is quite large. We shouldn't need GetProcAddress
21 // because emscripten provides us all the valid function pointers
22 // for WebGL via the included headers.
23 // https://github.com/emscripten-core/emscripten/blob/7ba7700902c46734987585409502f3c63beb650f/system/include/emscripten/html5_webgl.h#L93
24 SkASSERTF(false, "Can't lookup fn %s\n", name);
25 return nullptr;
26 }
27
28 namespace GrGLInterfaces {
29 sk_sp<const GrGLInterface> MakeWebGL() {
30 return GrGLMakeAssembledWebGLInterface(nullptr, webgl_get_gl_proc);
31 }
32 } // namespace GrGLInterfaces
33
34 #if !defined(SK_DISABLE_LEGACY_GL_MAKE_NATIVE_INTERFACE)
35 sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
36 return GrGLInterfaces::MakeWebGL();
37 }
38 #endif