aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp')
-rw-r--r--src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp b/src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp
new file mode 100644
index 0000000000..4bbbe087a2
--- /dev/null
+++ b/src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2014 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 "gl/GrGLUtil.h"
+
+// Define this to get a prototype for glXGetProcAddress on some systems
+#define GLX_GLXEXT_PROTOTYPES 1
+#include <GL/glx.h>
+
+static GrGLFuncPtr glx_get(void* ctx, const char name[]) {
+ // Avoid calling glXGetProcAddress() for EGL procs.
+ // We don't expect it to ever succeed, but somtimes it returns non-null anyway.
+ if (0 == strncmp(name, "egl", 3)) {
+ return nullptr;
+ }
+
+ SkASSERT(nullptr == ctx);
+ SkASSERT(glXGetCurrentContext());
+ return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name));
+}
+
+sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
+ if (nullptr == glXGetCurrentContext()) {
+ return nullptr;
+ }
+
+ return GrGLAssembleInterface(nullptr, glx_get);
+}
+
+const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }