1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2014 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#include "include/gpu/gl/GrGLAssembleInterface.h" 9cb93a386Sopenharmony_ci#include "include/gpu/gl/GrGLInterface.h" 10cb93a386Sopenharmony_ci#include "src/gpu/gl/GrGLUtil.h" 11cb93a386Sopenharmony_ci 12cb93a386Sopenharmony_ci// Define this to get a prototype for glXGetProcAddress on some systems 13cb93a386Sopenharmony_ci#define GLX_GLXEXT_PROTOTYPES 1 14cb93a386Sopenharmony_ci#include <GL/glx.h> 15cb93a386Sopenharmony_ci 16cb93a386Sopenharmony_cistatic GrGLFuncPtr glx_get(void* ctx, const char name[]) { 17cb93a386Sopenharmony_ci // Avoid calling glXGetProcAddress() for EGL procs. 18cb93a386Sopenharmony_ci // We don't expect it to ever succeed, but somtimes it returns non-null anyway. 19cb93a386Sopenharmony_ci if (0 == strncmp(name, "egl", 3)) { 20cb93a386Sopenharmony_ci return nullptr; 21cb93a386Sopenharmony_ci } 22cb93a386Sopenharmony_ci 23cb93a386Sopenharmony_ci SkASSERT(nullptr == ctx); 24cb93a386Sopenharmony_ci SkASSERT(glXGetCurrentContext()); 25cb93a386Sopenharmony_ci return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name)); 26cb93a386Sopenharmony_ci} 27cb93a386Sopenharmony_ci 28cb93a386Sopenharmony_cisk_sp<const GrGLInterface> GrGLMakeGLXInterface() { 29cb93a386Sopenharmony_ci if (nullptr == glXGetCurrentContext()) { 30cb93a386Sopenharmony_ci return nullptr; 31cb93a386Sopenharmony_ci } 32cb93a386Sopenharmony_ci 33cb93a386Sopenharmony_ci return GrGLMakeAssembledInterface(nullptr, glx_get); 34cb93a386Sopenharmony_ci} 35