• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "include/gpu/gl/GrGLAssembleInterface.h"
9 #include "include/gpu/gl/GrGLInterface.h"
10 #include "include/gpu/ganesh/gl/glx/GrGLMakeGLXInterface.h"
11 #include "src/gpu/ganesh/gl/GrGLUtil.h"
12 
13 // Define this to get a prototype for glXGetProcAddress on some systems
14 #define GLX_GLXEXT_PROTOTYPES 1
15 #include <GL/glx.h>
16 
glx_get(void * ctx,const char name[])17 static GrGLFuncPtr glx_get(void* ctx, const char name[]) {
18     // Avoid calling glXGetProcAddress() for EGL procs.
19     // We don't expect it to ever succeed, but somtimes it returns non-null anyway.
20     if (0 == strncmp(name, "egl", 3)) {
21         return nullptr;
22     }
23 
24     SkASSERT(nullptr == ctx);
25     SkASSERT(glXGetCurrentContext());
26     return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name));
27 }
28 
29 namespace GrGLInterfaces {
MakeGLX()30 sk_sp<const GrGLInterface> MakeGLX() {
31     if (nullptr == glXGetCurrentContext()) {
32         return nullptr;
33     }
34 
35     return GrGLMakeAssembledInterface(nullptr, glx_get);
36 }
37 }  // namespace GrGLInterfaces
38 
39 #if !defined(SK_DISABLE_LEGACY_GLXINTERFACE_FACTORY)
GrGLMakeGLXInterface()40 sk_sp<const GrGLInterface> GrGLMakeGLXInterface() { return GrGLInterfaces::MakeGLX(); }
41 #endif
42