Commit 998ddcb1 authored by Jonah Ryan-Davis's avatar Jonah Ryan-Davis Committed by Commit Bot

Clean up GLX extension string getters

There was a mismatch between methods of retrieving GLX extensions in
Chrome, causing certain available/used extensions to not appear on
about::gpu. Additionally, there is an opportunity to cache the extension
string and save calls.

Bug: 1043761
Change-Id: I39bde9702daf9b5cf80a5cc1c9a030ef56623913
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015644
Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735924}
parent 939390e5
......@@ -77,7 +77,9 @@ std::string DriverEGL::GetClientExtensions() {
#if defined(USE_GLX)
std::string DriverGLX::GetPlatformExtensions() {
const char* str = glXQueryExtensionsString(gfx::GetXDisplay(), 0);
Display* display = gfx::GetXDisplay();
const int screen = (display == EGL_NO_DISPLAY ? 0 : DefaultScreen(display));
const char* str = glXQueryExtensionsString(display, screen);
return str ? std::string(str) : "";
}
#endif
......
......@@ -79,7 +79,6 @@ const char* RealGLXApi::glXQueryExtensionsStringFn(Display* dpy,
if (!driver_->fn.glXQueryExtensionsStringFn)
return nullptr;
const char* str = GLXApiBase::glXQueryExtensionsStringFn(dpy, screen);
if (!str)
return nullptr;
......@@ -111,13 +110,10 @@ void TraceGLXApi::SetDisabledExtensions(
bool GetGLWindowSystemBindingInfoGLX(const GLVersionInfo& gl_info,
GLWindowSystemBindingInfo* info) {
Display* display = glXGetCurrentDisplay();
const int kDefaultScreen = 0;
const char* vendor =
glXQueryServerString(display, kDefaultScreen, GLX_VENDOR);
const char* version =
glXQueryServerString(display, kDefaultScreen, GLX_VERSION);
const char* extensions =
glXQueryServerString(display, kDefaultScreen, GLX_EXTENSIONS);
const int screen = (display ? DefaultScreen(display) : 0);
const char* vendor = glXQueryServerString(display, screen, GLX_VENDOR);
const char* version = glXQueryServerString(display, screen, GLX_VERSION);
const char* extensions = glXQueryExtensionsString(display, screen);
*info = GLWindowSystemBindingInfo();
if (vendor)
info->vendor = vendor;
......
......@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/no_destructor.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/atomic_flag.h"
#include "base/synchronization/lock.h"
......@@ -532,9 +533,24 @@ void GLSurfaceGLX::ShutdownOneOff() {
g_colormap = CopyFromParent;
}
// static
std::string GLSurfaceGLX::QueryGLXExtensions() {
Display* display = gfx::GetXDisplay();
const int screen = (display ? DefaultScreen(display) : 0);
const char* extensions = glXQueryExtensionsString(display, screen);
if (extensions) {
return std::string(extensions);
}
return "";
}
// static
const char* GLSurfaceGLX::GetGLXExtensions() {
return glXQueryExtensionsString(gfx::GetXDisplay(), 0);
static base::NoDestructor<std::string> glx_extensions("");
if (glx_extensions->empty()) {
*glx_extensions = QueryGLXExtensions();
}
return glx_extensions->c_str();
}
// static
......
......@@ -38,6 +38,7 @@ class GL_EXPORT GLSurfaceGLX : public GLSurface {
// These aren't particularly tied to surfaces, but since we already
// have the static InitializeOneOff here, it's easiest to reuse its
// initialization guards.
static std::string QueryGLXExtensions();
static const char* GetGLXExtensions();
static bool HasGLXExtension(const char* name);
static bool IsCreateContextSupported();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment