Skip to content
Permalink
Browse files

Date: Tue, 24 Aug 2004 06:16:32 +0200

From: Christian Biere
Subject: [SDL] YUV Overlay vs. XV_AUTOPAINT_COLORKEY

I have a problem with SDL's YUV Overlay support using X11 Xv. Some people
reported that they get nothing but a black screen. I've compared the
output of xvattr they've sent me with the values I get here. It turned
out that XV_AUTOPAINT_COLORKEY was disabled. By enabling this feature
everything works fine.
  • Loading branch information
slouken committed Aug 25, 2004
1 parent 2f46e5a commit 1c5c280be613c60fca6df21d502fb770651e53b4
Showing with 35 additions and 1 deletion.
  1. +35 −1 src/video/x11/SDL_x11yuv.c
@@ -73,10 +73,11 @@ struct private_yuvhwdata {
};


static int (*X_handler)(Display *, XErrorEvent *) = NULL;

#ifndef NO_SHARED_MEMORY
/* Shared memory error handler routine */
static int shm_error;
static int (*X_handler)(Display *, XErrorEvent *) = NULL;
static int shm_errhandler(Display *d, XErrorEvent *e)
{
if ( e->error_code == BadAccess ) {
@@ -87,6 +88,15 @@ static int shm_errhandler(Display *d, XErrorEvent *e)
}
#endif /* !NO_SHARED_MEMORY */

static int xv_error;
static int xv_errhandler(Display *d, XErrorEvent *e)
{
if ( e->error_code == BadMatch ) {
xv_error = True;
return(0);
} else
return(X_handler(d,e));
}

SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
{
@@ -192,6 +202,30 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
return(NULL);
}

/* Enable auto-painting of the overlay colorkey */
{
static const char *attr[] = { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" };
unsigned int i;

SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True);
X_handler = XSetErrorHandler(xv_errhandler);
for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) {
Atom a;

xv_error = False;
a = XInternAtom(GFX_Display, attr[i], True);
if ( a != None ) {
SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1);
XSync(GFX_Display, True);
if ( ! xv_error ) {
break;
}
}
}
XSetErrorHandler(X_handler);
SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False);
}

/* Create the overlay structure */
overlay = (SDL_Overlay *)malloc(sizeof *overlay);
if ( overlay == NULL ) {

0 comments on commit 1c5c280

Please sign in to comment.