Commit 2f24de32 by Nicolas Capens

Only open an X11 display when not provided by the application through eglGetDisplay().

parent 49e3cb5f
#define MAJOR_VERSION 3
#define MINOR_VERSION 2
#define BUILD_VERSION 6
#define BUILD_REVISION 47125
#define BUILD_REVISION 47297
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -144,7 +144,7 @@ bool Surface::reset(int backBufferWidth, int backBufferHeight)
if(mWindow)
{
frameBuffer = gl::createFrameBuffer(mWindow, backBufferWidth, backBufferHeight);
frameBuffer = gl::createFrameBuffer(mDisplay->getNativeDisplay(), mWindow, backBufferWidth, backBufferHeight);
if(!frameBuffer)
{
......
......@@ -95,7 +95,7 @@ CONSTRUCTOR static bool eglAttachProcess()
gl::getCurrentContext = (gl::Context *(*)())getProcAddress(libGLESv2, "glGetCurrentContext");
gl::getProcAddress = (__eglMustCastToProperFunctionPointerType (*)(const char*))getProcAddress(libGLESv2, "glGetProcAddress");
gl::createBackBuffer = (gl::Image *(*)(int, int, const egl::Config*))getProcAddress(libGLESv2, "createBackBuffer");
gl::createFrameBuffer = (sw::FrameBuffer *(*)(EGLNativeWindowType, int, int))getProcAddress(libGLESv2, "createFrameBuffer");
gl::createFrameBuffer = (sw::FrameBuffer *(*)(EGLNativeDisplayType, EGLNativeWindowType, int, int))getProcAddress(libGLESv2, "createFrameBuffer");
return libGLESv2 != 0;
}
......@@ -255,7 +255,7 @@ namespace gl
Context *(*getCurrentContext)() = 0;
__eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname) = 0;
Image *(*createBackBuffer)(int width, int height, const egl::Config *config) = 0;
sw::FrameBuffer *(*createFrameBuffer)(EGLNativeWindowType window, int width, int height) = 0;
sw::FrameBuffer *(*createFrameBuffer)(EGLNativeDisplayType display, EGLNativeWindowType window, int width, int height) = 0;
}
void *libGLESv2 = 0; // Handle to the libGLESv2 module
......@@ -90,7 +90,7 @@ namespace gl
extern Context *(*getCurrentContext)();
extern __eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname);
extern Image *(*createBackBuffer)(int width, int height, const egl::Config *config);
extern sw::FrameBuffer *(*createFrameBuffer)(EGLNativeWindowType window, int width, int height);
extern sw::FrameBuffer *(*createFrameBuffer)(EGLNativeDisplayType display, EGLNativeWindowType window, int width, int height);
}
extern void *libGLESv2; // Handle to the libGLESv2 module
......
......@@ -17,7 +17,6 @@
#include "Register.hpp"
#include "Renderer/Surface.hpp"
#include "Reactor/Reactor.hpp"
#include "Common/Configurator.hpp"
#include "Common/Debug.hpp"
#include <stdio.h>
......@@ -515,43 +514,4 @@ namespace sw
}
#endif
}
}
#if defined(_WIN32)
#include "FrameBufferDD.hpp"
#include "FrameBufferGDI.hpp"
#else
#include "FrameBufferX11.hpp"
#endif
extern "C"
{
#if defined(_WIN32)
sw::FrameBuffer *createFrameBuffer(HWND window, int width, int height)
{
return createFrameBufferWin(window, width, height, false, false);
}
sw::FrameBufferWin *createFrameBufferWin(HWND windowHandle, int width, int height, bool fullscreen, bool topLeftOrigin)
{
sw::Configurator ini("SwiftShader.ini");
int api = ini.getInteger("Testing", "FrameBufferAPI", 0);
if(api == 0 && topLeftOrigin)
{
return new sw::FrameBufferDD(windowHandle, width, height, fullscreen, topLeftOrigin);
}
else
{
return new sw::FrameBufferGDI(windowHandle, width, height, fullscreen, topLeftOrigin);
}
return 0;
}
#else
sw::FrameBuffer *createFrameBuffer(Window window, int width, int height)
{
return new sw::FrameBufferX11(window, width, height);
}
#endif
}
}
\ No newline at end of file
......@@ -100,18 +100,6 @@ namespace sw
static bool topLeftOrigin;
};
class FrameBufferWin;
}
extern "C"
{
#if defined(_WIN32)
sw::FrameBuffer *createFrameBuffer(HWND windowHandle, int width, int height);
sw::FrameBufferWin *createFrameBufferWin(HWND windowHandle, int width, int height, bool fullscreen, bool topLeftOrigin);
#else
sw::FrameBuffer *createFrameBuffer(unsigned long window, int width, int height);
#endif
}
#endif // sw_FrameBuffer_hpp
......@@ -47,3 +47,32 @@ namespace sw
}
}
}
#include "FrameBufferDD.hpp"
#include "FrameBufferGDI.hpp"
#include "Common/Configurator.hpp"
extern "C"
{
sw::FrameBufferWin *createFrameBufferWin(HWND windowHandle, int width, int height, bool fullscreen, bool topLeftOrigin)
{
sw::Configurator ini("SwiftShader.ini");
int api = ini.getInteger("Testing", "FrameBufferAPI", 0);
if(api == 0 && topLeftOrigin)
{
return new sw::FrameBufferDD(windowHandle, width, height, fullscreen, topLeftOrigin);
}
else
{
return new sw::FrameBufferGDI(windowHandle, width, height, fullscreen, topLeftOrigin);
}
return 0;
}
sw::FrameBuffer *createFrameBuffer(HDC display, HWND window, int width, int height)
{
return createFrameBufferWin(window, width, height, false, false);
}
}
......@@ -54,4 +54,9 @@ namespace sw
};
}
extern "C"
{
sw::FrameBufferWin *createFrameBufferWin(HWND windowHandle, int width, int height, bool fullscreen, bool topLeftOrigin);
}
#endif // sw_FrameBufferWin_hpp
......@@ -38,9 +38,13 @@ namespace sw
}
}
FrameBufferX11::FrameBufferX11(Window window, int width, int height) : FrameBuffer(width, height, false, false), x_window(window)
FrameBufferX11::FrameBufferX11(Display *display, Window window, int width, int height) : FrameBuffer(width, height, false, false), x_window(window), x_display(display), ownX11(!display)
{
x_display = XOpenDisplay(0);
if(!x_display)
{
x_display = XOpenDisplay(0);
}
int screen = DefaultScreen(x_display);
x_gc = XDefaultGC(x_display, screen);
Visual *x_visual = XDefaultVisual(x_display, screen);
......@@ -98,7 +102,10 @@ namespace sw
shmctl(shminfo.shmid, IPC_RMID, 0);
}
XCloseDisplay(x_display);
if(ownX11)
{
XCloseDisplay(x_display);
}
}
void *FrameBufferX11::lock()
......@@ -130,3 +137,11 @@ namespace sw
XSync(x_display, False);
}
}
extern "C"
{
sw::FrameBuffer *createFrameBuffer(void *display, Window window, int width, int height)
{
return new sw::FrameBufferX11((Display*)display, window, width, height);
}
}
......@@ -28,7 +28,7 @@ namespace sw
class FrameBufferX11 : public FrameBuffer
{
public:
FrameBufferX11(Window window, int width, int height);
FrameBufferX11(Display *display, Window window, int width, int height);
~FrameBufferX11();
......@@ -38,7 +38,8 @@ namespace sw
virtual void *lock();
virtual void unlock();
private:
private:
bool ownX11;
Display *x_display;
Window x_window;
XImage *x_image;
......
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