[Scummvm-cvs-logs] CVS: scummvm x11.cpp,1.18,1.19

Lionel Ulmer bbrox at users.sourceforge.net
Wed Apr 24 14:20:03 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv22198

Modified Files:
	x11.cpp 
Log Message:
Added beginning of (hacky) hardware scaling for the X11 port of
ScummVM. This is NOT finalized at all (for example mouse 'descaling'
is not implemented yet) but is here for the not-faint of heart :-)

If you want to try to play with it, replace '65' by the video port
supporting a RGB image format (search it with 'xvinfo').

This works with the latest NVIDIA drivers. I have no idea if any other
graphic driver exports this feature.



Index: x11.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/x11.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** x11.cpp	24 Apr 2002 19:35:49 -0000	1.18
--- x11.cpp	24 Apr 2002 21:19:19 -0000	1.19
***************
*** 36,39 ****
--- 36,43 ----
  #include <X11/Xutil.h>
  #include <X11/extensions/XShm.h>
+ #ifdef USE_XV_SCALING
+ #include <X11/extensions/Xv.h>
+ #include <X11/extensions/Xvlib.h>
+ #endif
  #include <linux/soundcard.h>
  
***************
*** 128,132 ****
--- 132,140 ----
  	int scumm_x, scumm_y;
  
+ #ifdef USE_XV_SCALING
+ 	unsigned int palette[256];
+ #else
  	unsigned short palette[256];
+ #endif
  	bool _palette_changed;
  	Display *display;
***************
*** 134,138 ****
--- 142,150 ----
  	Window window;
  	GC black_gc;
+ #ifdef USE_XV_SCALING
+ 	XvImage *image;
+ #else
  	XImage *image;
+ #endif
  	pthread_t sound_thread;
  
***************
*** 305,310 ****
  	scumm_x = 0;
  	scumm_y = 0;
! 	window = XCreateSimpleWindow(display, XRootWindow(display, screen), 0, 0,
! 															 320, 200, 0, 0, 0);
  	wm_hints = XAllocWMHints();
  	if (wm_hints == NULL) {
--- 317,321 ----
  	scumm_x = 0;
  	scumm_y = 0;
! 	window = XCreateSimpleWindow(display, XRootWindow(display, screen), 0, 0, 320, 200, 0, 0, 0);
  	wm_hints = XAllocWMHints();
  	if (wm_hints == NULL) {
***************
*** 317,331 ****
  	XStringListToTextProperty(&name, 1, &window_name);
  	XSetWMProperties(display, window, &window_name, &window_name,
! 									 NULL /* argv */ , 0 /* argc */ , NULL /* size hints */ ,
! 									 wm_hints, NULL /* class hints */ );
  
  	XSelectInput(display, window,
! 							 ExposureMask | KeyPressMask | KeyReleaseMask |
! 							 PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
! 							 StructureNotifyMask);
! 	image =
! 		XShmCreateImage(display, DefaultVisual(display, screen), 16, ZPixmap,
! 										NULL, &shminfo, 320, 200);
  	shminfo.shmid = shmget(IPC_PRIVATE, 320 * 200 * 2, IPC_CREAT | 0700);
  	shminfo.shmaddr = (char *)shmat(shminfo.shmid, 0, 0);
  	image->data = shminfo.shmaddr;
--- 328,345 ----
  	XStringListToTextProperty(&name, 1, &window_name);
  	XSetWMProperties(display, window, &window_name, &window_name,
! 	                 NULL /* argv */ , 0 /* argc */ , NULL /* size hints */ ,
! 	                 wm_hints, NULL /* class hints */ );
  
  	XSelectInput(display, window,
! 	             ExposureMask | KeyPressMask | KeyReleaseMask |
! 	             PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
! 	             StructureNotifyMask);
! #ifdef USE_XV_SCALING
! 	image = XvShmCreateImage(display, 65, 0x03, 0, 320, 200, &shminfo);
! 	shminfo.shmid = shmget(IPC_PRIVATE, image->data_size, IPC_CREAT | 0700);
! #else
! 	image =	XShmCreateImage(display, DefaultVisual(display, screen), 16, ZPixmap, NULL, &shminfo, 320, 200);
  	shminfo.shmid = shmget(IPC_PRIVATE, 320 * 200 * 2, IPC_CREAT | 0700);
+ #endif
  	shminfo.shmaddr = (char *)shmat(shminfo.shmid, 0, 0);
  	image->data = shminfo.shmaddr;
***************
*** 393,400 ****
--- 407,422 ----
  void OSystem_X11::set_palette(const byte *colors, uint start, uint num) {
  	const byte *data = colors;
+ #ifdef USE_XV_SCALING
+ 	unsigned int *pal = &(palette[start]);
+ #else
  	unsigned short *pal = &(palette[start]);
+ #endif
  	
  	do {
+ #ifdef USE_XV_SCALING
+ 		*pal++ = (data[0] << 16) | (data[1] << 8) | data[2];
+ #else
  		*pal++ = ((data[0] & 0xF8) << 8) | ((data[1] & 0xFC) << 3) | (data[2] >> 3);
+ #endif
  		data += 4;
  		num--;
***************
*** 444,448 ****
--- 466,474 ----
  	int x, y;
  	unsigned char *ptr_src = local_fb + (320 * d->y) + d->x;
+ #ifdef USE_XV_SCALING
+ 	unsigned int *ptr_dst = ((unsigned int *)image->data) + (320 * d->y) + d->x;
+ #else
  	unsigned short *ptr_dst = ((unsigned short *)image->data) + (320 * d->y) + d->x;
+ #endif
  	for (y = 0; y < d->h; y++) {
  		for (x = 0; x < d->w; x++) {
***************
*** 491,497 ****
--- 517,528 ----
  	}
  	if (need_redraw == true) {
+ #ifdef USE_XV_SCALING
+ 		XvShmPutImage(display, 65, window, DefaultGC(display, screen), image,
+ 			      0, 0, 320, 200, 0, 0, window_width, window_height, 0);
+ #else
  		XShmPutImage(display, window, DefaultGC(display, screen), image,
  		             dout.x, dout.y, scumm_x + dout.x, scumm_y + dout.y,
  		             dout.w - dout.x, dout.h - dout.y, 0);
+ #endif
  		XFlush(display);
  	}





More information about the Scummvm-git-logs mailing list