Commit 4f691690 by Corentin Wallez

FunctionsGLX: Remove all but one of the ANGLE dependencies

A follow-up CL will make it so the dependencies on TokenizeExtensionString doesn't pull the GL headers, this will then allow use to remove the hack for the inclusion of glx.h BUG=angleproject:892 Change-Id: I51c5466617057e2c580bd5e8056307515bcecc4b Reviewed-on: https://chromium-review.googlesource.com/272206Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 3cd0ca3c
......@@ -72,10 +72,10 @@ egl::Error DisplayGLX::initialize(egl::Display *display)
}
}
egl::Error glxInitResult = mGLX.initialize(xDisplay, DefaultScreen(xDisplay));
if (glxInitResult.isError())
std::string glxInitError;
if (!mGLX.initialize(xDisplay, DefaultScreen(xDisplay), &glxInitError))
{
return glxInitResult;
return egl::Error(EGL_NOT_INITIALIZED, glxInitError.c_str());
}
// Check we have the needed extensions
......
......@@ -95,11 +95,11 @@ FunctionsGLX::FunctionsGLX()
FunctionsGLX::~FunctionsGLX()
{
SafeDelete(mFnPtrs);
delete mFnPtrs;
terminate();
}
egl::Error FunctionsGLX::initialize(Display *xDisplay, int screen)
bool FunctionsGLX::initialize(Display *xDisplay, int screen, std::string *errorString)
{
terminate();
mXDisplay = xDisplay;
......@@ -108,7 +108,8 @@ egl::Error FunctionsGLX::initialize(Display *xDisplay, int screen)
mLibHandle = dlopen("libGL.so.1", RTLD_NOW);
if (!mLibHandle)
{
return egl::Error(EGL_NOT_INITIALIZED, "Could not dlopen libGL.so.1: %s", dlerror());
*errorString = std::string("Could not dlopen libGL.so.1: ") + dlerror();
return false;
}
getProc = reinterpret_cast<PFNGETPROCPROC>(dlsym(mLibHandle, "glXGetProcAddress"));
......@@ -118,13 +119,15 @@ egl::Error FunctionsGLX::initialize(Display *xDisplay, int screen)
}
if (!getProc)
{
return egl::Error(EGL_NOT_INITIALIZED, "Could not retrieve glXGetProcAddress");
*errorString = "Could not retrieve glXGetProcAddress";
return false;
}
#define GET_PROC_OR_ERROR(MEMBER, NAME) \
if (!GetProc(getProc, MEMBER, NAME)) \
{ \
return egl::Error(EGL_NOT_INITIALIZED, "Could not load GLX entry point " NAME); \
*errorString = "Could not load GLX entry point " NAME; \
return false; \
}
// GLX 1.0
......@@ -145,24 +148,28 @@ egl::Error FunctionsGLX::initialize(Display *xDisplay, int screen)
int eventBase;
if (!queryExtension(&errorBase, &eventBase))
{
return egl::Error(EGL_NOT_INITIALIZED, "GLX is not present.");
*errorString = "GLX is not present.";
return false;
}
}
// Check we have a supported version of GLX
if (!queryVersion(&majorVersion, &minorVersion))
{
return egl::Error(EGL_NOT_INITIALIZED, "Could not query the GLX version.");
*errorString = "Could not query the GLX version.";
return false;
}
if (majorVersion != 1 || minorVersion < 3)
{
return egl::Error(EGL_NOT_INITIALIZED, "Unsupported GLX version (requires at least 1.3).");
*errorString = "Unsupported GLX version (requires at least 1.3).";
return false;
}
const char *extensions = queryExtensionsString();
if (!extensions)
{
return egl::Error(EGL_NOT_INITIALIZED, "glXQueryExtensionsString returned NULL");
*errorString = "glXQueryExtensionsString returned NULL";
return false;
}
mExtensions = TokenizeExtensionsString(extensions);
......@@ -189,7 +196,8 @@ egl::Error FunctionsGLX::initialize(Display *xDisplay, int screen)
#undef GET_PROC_OR_ERROR
return egl::Error(EGL_SUCCESS);
*errorString = "";
return true;
}
void FunctionsGLX::terminate()
......
......@@ -12,21 +12,19 @@
#include <string>
#include <vector>
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/renderer/gl/glx/platform_glx.h"
namespace rx
{
class FunctionsGLX : angle::NonCopyable
class FunctionsGLX
{
public:
FunctionsGLX();
~FunctionsGLX();
// Load data from GLX, can be called multiple times
egl::Error initialize(Display *xDisplay, int screen);
bool initialize(Display *xDisplay, int screen, std::string *errorString);
void terminate();
bool hasExtension(const char *extension) const;
......@@ -66,6 +64,11 @@ class FunctionsGLX : angle::NonCopyable
glx::Context createContextAttribsARB(glx::FBConfig config, glx::Context shareContext, Bool direct, const int *attribList) const;
private:
// So as to isolate GLX from angle we do not include angleutils.h and cannot
// use angle::NonCopyable so we replicated it here instead.
FunctionsGLX(const FunctionsGLX&) = delete;
void operator=(const FunctionsGLX&) = delete;
struct GLXFunctionTable;
void *mLibHandle;
......
......@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
// renderer11_utils.cpp: Conversion functions and other utility routines
// renderergl_utils.cpp: Conversion functions and other utility routines
// specific to the OpenGL renderer.
#include "libANGLE/renderer/gl/renderergl_utils.h"
......
......@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
// renderer11_utils.h: Conversion functions and other utility routines
// renderergl_utils.h: Conversion functions and other utility routines
// specific to the OpenGL renderer.
#ifndef LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_
......
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