Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Respect environment variables.
  • Loading branch information
sunnyps committed Jul 19, 2010
1 parent ebd50fe commit 8c9ab14570ea0f645bf3a5ae63bd0ccdea1a6abb
Showing with 100 additions and 29 deletions.
  1. +1 −1 src/SDL_error.c
  2. +91 −28 src/video/x11/SDL_x11render.c
  3. +2 −0 src/video/x11/SDL_x11sym.h
  4. +6 −0 src/video/x11/SDL_x11video.h
@@ -38,7 +38,7 @@ extern SDL_error *SDL_GetErrBuf(void);

#define SDL_ERRBUFIZE 1024

#define DEBUG_ERROR
//#define DEBUG_ERROR

/* Private functions */

@@ -176,11 +176,87 @@ UpdateYUVTextureData(SDL_Texture * texture)
texture->h, data->pixels, data->pitch);
}

#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
static SDL_bool
CheckXRender(Display *display, int *major, int *minor) {
const char *env;

*major = *minor = 0;

env = SDL_getenv("SDL_VIDEO_X11_XRENDER");

if (env && !SDL_atoi(env)) {
return SDL_FALSE;
}

if (!SDL_X11_HAVE_XRENDER) {
return SDL_FALSE;
}

if (!XRenderQueryVersion(display, major, minor)) {
return SDL_FALSE;
}

return SDL_TRUE;
}
#endif

#ifdef SDL_VIDEO_DRIVER_X11_XFIXES
static SDL_bool
CheckXFixes(Display *display, int *major, int *minor) {
const char *env;

*major = *minor = 0;

env = SDL_getenv("SDL_VIDEO_X11_XFIXES");

if (env && !SDL_atoi(env)) {
return SDL_FALSE;
}

if (!SDL_X11_HAVE_XFIXES) {
return SDL_FALSE;
}

if (!XFixesQueryVersion(display, major, minor)) {
return SDL_FALSE;
}

return SDL_TRUE;
}
#endif

#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
static SDL_bool
CheckXDamage(Display *display, int *major, int *minor) {
const char *env;

*major = *minor = 0;

env = SDL_getenv("SDL_VIDEO_X11_XDAMAGE");

if (env && !SDL_atoi(env)) {
return SDL_FALSE;
}

if (!SDL_X11_HAVE_XDAMAGE) {
return SDL_FALSE;
}

if (!XDamageQueryVersion(display, major, minor)) {
return SDL_FALSE;
}

return SDL_TRUE;
}
#endif

void
X11_AddRenderDriver(_THIS)
{
SDL_RendererInfo *info = &X11_RenderDriver.info;
SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode;
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
int i;

info->texture_formats[info->num_texture_formats++] = mode->format;
@@ -189,7 +265,13 @@ X11_AddRenderDriver(_THIS)
info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2;
info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY;
info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU;
info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_ARGB8888;

#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
int major, minor;
if (CheckXRender(data->display, &major, &minor)) {
info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_ARGB8888;
}
#endif

for (i = 0; i < _this->num_displays; ++i) {
SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver);
@@ -255,36 +337,17 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->info.flags = SDL_RENDERER_ACCELERATED;

#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
data->use_xrender = SDL_FALSE;
data->use_xdamage = SDL_FALSE;
int event_basep, error_basep;
if (SDL_X11_HAVE_XRENDER) {
/* Query the extension. This is the server runtime check. */
if(XRenderQueryExtension(data->display,
&event_basep, &error_basep) == True)
data->use_xrender = SDL_TRUE;
}
int major, minor;
data->use_xrender = CheckXRender(data->display, &major, &minor);
#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
if (data->use_xrender) {
if(SDL_X11_HAVE_XDAMAGE && SDL_X11_HAVE_XFIXES) {
/* Query XDamage and XFixes */
if(XDamageQueryExtension(data->display,
&event_basep,
&error_basep) == True &&
(XFixesQueryExtension(data->display,
&event_basep,
&error_basep) == True)) {
int major_version, minor_version;
XFixesQueryVersion(data->display,
&major_version,
&minor_version);
/* Only XFixes v 2 or greater
* Required for XFixesSetPictureClipRegion() */
if(major_version >= 2)
data->use_xdamage = SDL_TRUE;
}
if (CheckXDamage(data->display, &major, &minor)) {
if (CheckXFixes(data->display, &major, &minor)) {
if (major >= 2)
data->use_xdamage = SDL_TRUE;
}
}
#endif
if (data->use_xrender) {
/* Find the PictFormat from the visual.
* Should be an RGB PictFormat most of the time. */
data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display,
@@ -240,6 +240,7 @@ SDL_X11_SYM(void,XScreenSaverSuspend,(Display *dpy,Bool suspend),(dpy,suspend),r
#if SDL_VIDEO_DRIVER_X11_XRENDER
SDL_X11_MODULE(XRENDER)
SDL_X11_SYM(Bool,XRenderQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return)
SDL_X11_SYM(Bool,XRenderQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
SDL_X11_SYM(XRenderPictFormat*,XRenderFindVisualFormat,(Display *dpy,_Xconst Visual *visual),(dpy,visual),return)
SDL_X11_SYM(XRenderPictFormat*,XRenderFindStandardFormat,(Display *dpy,int format),(dpy,format),return)
SDL_X11_SYM(XRenderPictFormat*,XRenderFindFormat,(Display *dpy,unsigned long mask,_Xconst XRenderPictFormat* templ,int count),(dpy,mask,templ,count),return)
@@ -256,6 +257,7 @@ SDL_X11_SYM(void,XRenderFillRectangles,(Display *dpy,int op,Picture dst,_Xconst
#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
SDL_X11_MODULE(XDAMAGE)
SDL_X11_SYM(Bool,XDamageQueryExtension,(Display *dpy,int *event_base_return,int *error_base_return),(dpy,event_base_return,error_base_return),return)
SDL_X11_SYM(Status,XDamageQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
SDL_X11_SYM(Damage,XDamageCreate,(Display *dpy,Drawable d,int level),(dpy,d,level),return)
SDL_X11_SYM(void,XDamageSubtract,(Display *dpy,Damage damage,XserverRegion repair,XserverRegion parts),(dpy,damage,repair,parts),return)
SDL_X11_SYM(void,XDamageDestroy,(Display *dpy,Damage damage),(dpy,damage),return)
@@ -48,6 +48,12 @@
#if SDL_VIDEO_DRIVER_X11_XRENDER
#include <X11/extensions/Xrender.h>
#endif
#if SDL_VIDEO_DRIVER_X11_XDAMAGE
#include <X11/extensions/Xdamage.h>
#endif
#if SDL_VIDEO_DRIVER_X11_XFIXES
#include <X11/extensions/Xfixes.h>
#endif
#include "SDL_x11dyn.h"

#include "SDL_x11events.h"

0 comments on commit 8c9ab14

Please sign in to comment.