xref: /aosp_15_r20/external/skia/src/gpu/ganesh/gl/epoxy/GrGLMakeEpoxyEGLInterface.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2024 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 
8 #include "include/gpu/ganesh/gl/epoxy/GrGLMakeEpoxyEGLInterface.h"
9 
10 #include "include/gpu/ganesh/gl/GrGLAssembleInterface.h"
11 #include "include/gpu/ganesh/gl/GrGLInterface.h"
12 #include "src/gpu/ganesh/gl/GrGLCoreFunctions.h"
13 #include "src/gpu/ganesh/gl/GrGLUtil.h"
14 
15 #include <epoxy/egl.h>
16 #include <epoxy/gl.h>
17 
epoxy_get_gl_proc(void * ctx,const char name[])18 static GrGLFuncPtr epoxy_get_gl_proc(void* ctx, const char name[])
19 {
20     SkASSERT(nullptr == ctx);
21     #define M(X) if (0 == strcmp(#X, name)) { return (GrGLFuncPtr) epoxy_ ## X; }
22     GR_GL_CORE_FUNCTIONS_EACH(M)
23     #undef M
24     return epoxy_eglGetProcAddress(name);
25 }
26 
27 namespace GrGLInterfaces {
MakeEpoxyEGL()28 sk_sp<const GrGLInterface> MakeEpoxyEGL() {
29     return GrGLMakeAssembledInterface(nullptr, epoxy_get_gl_proc);
30 }
31 }  // namespace GrGLInterfaces
32