diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-12-14 10:30:00 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-12-14 10:30:00 +0100 |
commit | 876de03290ce0e9393134d722e5b15025e32a341 (patch) | |
tree | c387ef7c6088e88545b837ae457e1699a88acaf9 /vcl | |
parent | 65e17112824967d990536d6a904f0b35a01b5340 (diff) |
Simplify GLX11Window::HasGLXExtension, avoiding strtok
Change-Id: If737cf4aaec1e6297db2bc8a80b19720ca9ca189
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/unx/saldisp.hxx | 3 | ||||
-rw-r--r-- | vcl/opengl/x11/gdiimpl.cxx | 45 |
2 files changed, 8 insertions, 40 deletions
diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx index 339ba806d6e8..d64b67ec6ca8 100644 --- a/vcl/inc/unx/saldisp.hxx +++ b/vcl/inc/unx/saldisp.hxx @@ -30,6 +30,7 @@ class SalXLib; #include <X11/extensions/Xrender.h> #include <epoxy/glx.h> +#include <rtl/string.hxx> #include <unx/salunx.h> #include <unx/saltype.h> #include <vcl/opengl/OpenGLContext.hxx> @@ -200,7 +201,7 @@ public: Window win; XVisualInfo* vi; GLXContext ctx; - const char* GLXExtensions; + OString GLXExtensions; bool HasGLXExtension(const char* name) const; diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx index 292dd14e7318..d46b002caf75 100644 --- a/vcl/opengl/x11/gdiimpl.cxx +++ b/vcl/opengl/x11/gdiimpl.cxx @@ -525,56 +525,23 @@ bool X11OpenGLContext::initWindow() return true; } -// Copy of gluCheckExtension(), from the Apache-licensed -// https://code.google.com/p/glues/source/browse/trunk/glues/source/glues_registry.c -static GLboolean checkExtension(const GLubyte* extName, const GLubyte* extString) -{ - GLboolean flag=GL_FALSE; - char* word; - char* lookHere; - char* deleteThis; - - if (extString==nullptr) - { - return GL_FALSE; - } - - deleteThis=lookHere=static_cast<char*>(malloc(strlen(reinterpret_cast<const char*>(extString))+1)); - if (lookHere==nullptr) - { - return GL_FALSE; - } - - /* strtok() will modify string, so copy it somewhere */ - strcpy(lookHere, reinterpret_cast<const char*>(extString)); - - while ((word=strtok(lookHere, " "))!=nullptr) - { - if (strcmp(word, reinterpret_cast<const char*>(extName))==0) - { - flag=GL_TRUE; - break; - } - lookHere=nullptr; /* get next token */ - } - free(static_cast<void*>(deleteThis)); - - return flag; -} - GLX11Window::GLX11Window() : dpy(nullptr) , screen(0) , win(0) , vi(nullptr) , ctx(nullptr) - , GLXExtensions(nullptr) { } bool GLX11Window::HasGLXExtension( const char* name ) const { - return checkExtension( reinterpret_cast<const GLubyte*>(name), reinterpret_cast<const GLubyte*>(GLXExtensions) ); + for (sal_Int32 i = 0; i != -1;) { + if (GLXExtensions.getToken(0, ' ', i) == name) { + return true; + } + } + return false; } GLX11Window::~GLX11Window() |