# HG changeset patch # User Sam Lantinga # Date 1083858906 0 # Node ID 05c551e5bc64ca247a80de79f10320437f119789 # Parent 9f6ad2286011dedbf95e3d41046de3ba8ba56468 Date: Sat, 24 Apr 2004 15:13:32 +0300 From: "Mike Gorchak" Subject: SDL updates for the QNX6 1. Updated the README.QNX 2. Updated libtool scripts, which are shipped with SDL for QNX6 support. 3. Added some code to support the new QNX 6.3.0, which is in beta now. 4. Added code to detect the hw features, which driver supports. 5. Added hw alpha blits code. 6. Fixed bug when application switches to fullscreen more the 2 times. (afte\ r that window becames always stay on top). 7. Updated a bit README for the tests. 8. Added information about acceleration show in the testalpha.c test. 9. Added small fixes to the testoverlay2.c test. 10. Added alpha and cc+alpha blits benchmarks to the testvidinfo.c test. diff -r 9f6ad2286011 -r 05c551e5bc64 README.QNX --- a/README.QNX Fri Apr 30 18:33:30 2004 +0000 +++ b/README.QNX Thu May 06 15:55:06 2004 +0000 @@ -1,5 +1,5 @@ -README by Mike Gorchak , -Last changed at 14 Feb 2004. +README.QNX by Mike Gorchak , +Last changed at 24 Apr 2004. ====================================================================== Table of Contents: @@ -19,8 +19,8 @@ heavily tested yet. If you have QNX RtP version 6.1.0 or above you must download the Photon3D runtime from http://developers.qnx.com or install it from the -public repository or the public CD, available with QNX. OS versions -below 6.1.0 are not supported. +public repository or from the public CD, available with QNX. OS versi- +ons below 6.1.0 are not supported. When creating an OpenGL context, software renderer mode is artifi- cially selected (QSSL made acceleration only for Voodoo boards in fullscreen mode, sorry but I don't have this board to test OpenGL - @@ -36,22 +36,23 @@ ====================================================================== 2. Wheel and multi-button mouses: - Photon emits keyboard events (key up and down) when the mouse + Photon emits keyboard events (key up and down) when the mouse wheel is moved. The key_scan field appears valid, and it contains zero. That is a basic method of detecting mouse wheel events under Photon. -It looks like a hack, but it works for me :) on various PC configura- +It looks like a hack, but it works for me :) on various PC configura- tions. I've tested it on: -1. Genius Optical NetScroll/+ (1 wheel) -2. A4Tech Optical GreatEye WheelMouse, model: WOP-35. (2 wheels + 2 - additional buttons). The wheel for vertical scrolling works as usu- - al, but the second wheel for horizontal scrolling emits two sequen- - tial events up or down, so it can provide faster scrolling than the - first wheel. Additional buttons don't emit any events, but it looks - like they're handled by photon in an unusual way - like click to - front, but works not with any window, looks like bug-o-feature :). +1. Genius Optical NetScroll/+ PS/2 (1 wheel) +2. A4Tech Optical GreatEye WheelMouse PS/2, model: WOP-35. (2 wheels + + 2 additional buttons). The wheel for vertical scrolling works as + usual, but the second wheel for horizontal scrolling emits two se- + quential events up or down, so it can provide faster scrolling than + the first wheel. Additional buttons don't emit any events, but it + looks like they're handled by photon in an unusual way - like click + to front, but works not with any window, looks like a fun bug-o-fe- + ature :). ====================================================================== 3. CDROM handling issues: @@ -89,10 +90,12 @@ de.m4 file (it comes after the ESD detection code up to the end of the file), because the libtool stuff in the acinclude.m4 file was very old in SDL distribution before the version 1.2.7 and doesn't knew anything -about QNX. SDL 1.2.7 distribution contain the new libtool.m4 script, +about QNX. SDL 1.2.7 distribution contains the new libtool.m4 script, but anyway it is broken :), Just remove it, then run "libtoolize ---force --copy", delete the file aclocal.m4 and after that run the -autogen.sh script. +--force --copy", delete the file aclocal.m4 if it is exists and after +that run the autogen.sh script. SDL 1.2.8 contains fixed libtool.m4, +ltmain.sh and config.sub files, so you can just run the autogen.sh +script. ====================================================================== 6. Some building issues: @@ -105,16 +108,19 @@ Run the configure script without x11 support, e.g.: a) for OpenGL support: - ./configure --prefix=/usr \ - --disable-video-x11 \ + ./configure --prefix=/usr \ + --disable-video-x11 \ --disable-shared b) without OpenGL support: - ./configure --prefix=/usr \ - --disable-video-x11 \ - --disable-shared \ + ./configure --prefix=/usr \ + --disable-video-x11 \ + --disable-shared \ --disable-video-opengl + And of course dont forget to specify --disable-debug, which is on +by default, to disable debug and enable the expensive optimizations. + In the test directory also run the ./configure script without x11 support, e.g.: @@ -128,10 +134,10 @@ Please note that the photon driver is sensible to the following environmental variables: - * SDL_PHOTON_FULLSCREEN_REFRESH - this environment variable controls -the refresh rate in all fullscreen modes. Be carefull !!! Photon drivers -usually do not checking the maximum refresh rate, which video adapter or -monitor supports. + * SDL_PHOTON_FULLSCREEN_REFRESH - this environment variable controls +the refresh rate in all fullscreen modes. Be carefull !!! Photon +drivers usually do not checking the maximum refresh rate, which video +adapter or monitor supports. * SDL_VIDEO_WINDOW_POS - can be set in the "X,Y" format. If X and Y coordinates are bigger than the current desktop resolution, then win- @@ -144,6 +150,6 @@ * SDL_VIDEO_CENTERED - if this environmental variable exists then the window centering is perfomed in the current virtual console. - The SDL_VIDEO_CENTERED enviromental variable has greater priority -than the SDL_VIDEO_WINDOW_POS in case if both variables are supplied -to the application. +Notes: The SDL_VIDEO_CENTERED enviromental variable has greater pri- +ority than the SDL_VIDEO_WINDOW_POS in case if both variables are sup- +plied to the application. diff -r 9f6ad2286011 -r 05c551e5bc64 acinclude.m4 --- a/acinclude.m4 Fri Apr 30 18:33:30 2004 +0000 +++ b/acinclude.m4 Thu May 06 15:55:06 2004 +0000 @@ -1652,14 +1652,16 @@ shlibpath_overrides_runpath=yes ;; -nto-qnx) - version_type=linux +*qnx* | *nto*) + version_type=qnx need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' ;; openbsd*) @@ -2356,6 +2358,10 @@ lt_cv_deplibs_check_method=pass_all ;; +*qnx* | *nto*) + lt_cv_deplibs_check_method=pass_all + ;; + # This must be Linux ELF. linux*) case $host_cpu in @@ -2382,10 +2388,6 @@ lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; -nto-qnx) - lt_cv_deplibs_check_method=unknown - ;; - openbsd*) lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` @@ -3614,6 +3616,8 @@ # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; + *qnx* | *nto*) + ;; *) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no @@ -4729,6 +4733,10 @@ ;; esac ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise it will coredumped. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; @@ -4768,6 +4776,10 @@ freebsd*) # FreeBSD uses GNU C++ ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise it will coredumped. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC) @@ -4988,6 +5000,10 @@ ;; esac ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise it will coredumped. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' @@ -5028,6 +5044,11 @@ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise it will coredumped. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + irix5* | irix6* | nonstopux*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. diff -r 9f6ad2286011 -r 05c551e5bc64 config.sub --- a/config.sub Fri Apr 30 18:33:30 2004 +0000 +++ b/config.sub Thu May 06 15:55:06 2004 +0000 @@ -1140,10 +1140,8 @@ ;; esac ;; - -nto-qnx*) - ;; -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` + os=-nto-qnx ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ diff -r 9f6ad2286011 -r 05c551e5bc64 configure.in --- a/configure.in Fri Apr 30 18:33:30 2004 +0000 +++ b/configure.in Thu May 06 15:55:06 2004 +0000 @@ -528,6 +528,14 @@ SDL_EXTRADIRS="$SDL_EXTRADIRS hermes" SDL_EXTRALIBS="$SDL_EXTRALIBS hermes/libhermes.la" use_nasm=yes + + case "$target" in + # this line is needed for QNX, because it's not defined the __ELF__ + *-*-qnx*) CFLAGS="$CFLAGS -D__ELF__" + ;; + + esac + fi fi } @@ -2309,6 +2317,7 @@ ARCH=qnx CheckDummyVideo CheckDiskAudio + # CheckNASM CheckDLOPEN CheckNAS CheckPHOTON diff -r 9f6ad2286011 -r 05c551e5bc64 ltmain.sh --- a/ltmain.sh Fri Apr 30 18:33:30 2004 +0000 +++ b/ltmain.sh Thu May 06 15:55:06 2004 +0000 @@ -2975,6 +2975,12 @@ versuffix=".$current"; ;; + qnx) + major=".$current" + versuffix=".$current" + deplibs_check_method="pass_all" + ;; + irix | nonstopux) major=`expr $current - $age + 1` diff -r 9f6ad2286011 -r 05c551e5bc64 src/video/photon/SDL_ph_events.c --- a/src/video/photon/SDL_ph_events.c Fri Apr 30 18:33:30 2004 +0000 +++ b/src/video/photon/SDL_ph_events.c Thu May 06 15:55:06 2004 +0000 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -235,7 +236,13 @@ /* request to resize */ else if (winEvent->event_f==Ph_WM_RESIZE) { - SDL_PrivateResize(winEvent->size.w+1, winEvent->size.h+1); + currently_maximized=0; + #if (_NTO_VERSION < 630) + SDL_PrivateResize(winEvent->size.w+1, winEvent->size.h+1); + #else + /* QNX 6.3.0 have this bug fixed */ + SDL_PrivateResize(winEvent->size.w, winEvent->size.h); + #endif /* _NTO_VERSION */ } /* request to move */ else if (winEvent->event_f==Ph_WM_MOVE) diff -r 9f6ad2286011 -r 05c551e5bc64 src/video/photon/SDL_ph_image.c --- a/src/video/photon/SDL_ph_image.c Fri Apr 30 18:33:30 2004 +0000 +++ b/src/video/photon/SDL_ph_image.c Thu May 06 15:55:06 2004 +0000 @@ -152,8 +152,7 @@ break; } - /* Currently only offscreen contexts with the same bit depth as the - * display can be created. */ + /* Currently offscreen contexts with the same bit depth as display bpp only can be created */ OCImage.offscreen_context = PdCreateOffscreenContext(0, screen->w, screen->h, Pg_OSC_MEM_PAGE_ALIGN); if (OCImage.offscreen_context == NULL) @@ -482,24 +481,57 @@ return -1; } - this->info.blit_hw = 1; + if ((vmode.mode_capabilities1 & PgVM_MODE_CAP1_OFFSCREEN) == PgVM_MODE_CAP1_OFFSCREEN) + { + /* this is a special test for drivers which tries to lie about offscreen capability */ + if (hwcaps.currently_available_video_ram!=0) + { + this->info.hw_available = 1; + } + else + { + this->info.hw_available = 0; + } + } + else + { + this->info.hw_available = 0; + } + + if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_RECTANGLE) == PgVM_MODE_CAP2_RECTANGLE) + { + this->info.blit_fill = 1; + } + else + { + this->info.blit_fill = 0; + } + + if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_BITBLT) == PgVM_MODE_CAP2_BITBLT) + { + this->info.blit_hw = 1; + } + else + { + this->info.blit_hw = 0; + } if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND) == PgVM_MODE_CAP2_ALPHA_BLEND) { - this->info.blit_hw_A = 1; + this->info.blit_hw_A = 1; } else { - this->info.blit_hw_A = 0; + this->info.blit_hw_A = 0; } if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_CHROMA) == PgVM_MODE_CAP2_CHROMA) { - this->info.blit_hw_CC = 1; + this->info.blit_hw_CC = 1; } else { - this->info.blit_hw_CC = 0; + this->info.blit_hw_CC = 0; } return 0; @@ -748,6 +780,11 @@ Uint32 truecolor; int ydisp=0; + if (this->info.blit_fill!=1) + { + return -1; + } + truecolor=ph_ExpandColor(this, surface, color); if (truecolor==0xFFFFFFFFUL) { @@ -885,6 +922,12 @@ PgChromaOn(); } + if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) + { + ph_SetHWAlpha(this, src, src->format->alpha); + PgAlphaOn(); + } + if (dst == this->screen) { if (src == this->screen) @@ -916,6 +959,11 @@ } } + if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) + { + PgAlphaOff(); + } + if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { PgChromaOff(); @@ -935,6 +983,11 @@ int ph_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key) { + if (this->info.blit_hw_CC!=1) + { + return -1; + } + if (surface->hwdata!=NULL) { surface->hwdata->colorkey=ph_ExpandColor(this, surface, key); @@ -950,7 +1003,14 @@ int ph_SetHWAlpha(_THIS, SDL_Surface* surface, Uint8 alpha) { - return -1; + if (this->info.blit_hw_A!=1) + { + return -1; + } + + PgSetAlphaBlend(NULL, alpha); + + return 0; } #ifdef HAVE_OPENGL diff -r 9f6ad2286011 -r 05c551e5bc64 src/video/photon/SDL_ph_video.c --- a/src/video/photon/SDL_ph_video.c Fri Apr 30 18:33:30 2004 +0000 +++ b/src/video/photon/SDL_ph_video.c Thu May 06 15:55:06 2004 +0000 @@ -83,27 +83,28 @@ return 1; } -static SDL_VideoDevice *ph_CreateDevice(int devindex) +static SDL_VideoDevice* ph_CreateDevice(int devindex) { - SDL_VideoDevice *device; + SDL_VideoDevice* device; /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); - if (device) { + if (device) + { memset(device, 0, (sizeof *device)); - device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + device->hidden = (struct SDL_PrivateVideoData*)malloc((sizeof *device->hidden)); device->gl_data = NULL; } - if ((device == NULL) || (device->hidden == NULL)) { + if ((device == NULL) || (device->hidden == NULL)) + { SDL_OutOfMemory(); ph_DeleteDevice(device); - return(0); + return NULL; } memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the driver flags */ - device->handles_any_size = 1; /* JB not true for fullscreen */ + device->handles_any_size = 1; /* Set the function pointers */ device->CreateYUVOverlay = ph_CreateYUVOverlay; @@ -113,7 +114,7 @@ device->ToggleFullScreen = ph_ToggleFullScreen; device->UpdateMouse = ph_UpdateMouse; device->SetColors = ph_SetColors; - device->UpdateRects = NULL; /* set up in ph_SetupUpdateFunction */ + device->UpdateRects = NULL; /* set up in ph_SetupUpdateFunction */ device->VideoQuit = ph_VideoQuit; device->AllocHWSurface = ph_AllocHWSurface; device->CheckHWBlit = ph_CheckHWBlit; @@ -254,6 +255,10 @@ } else { + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_FFRONT | Ph_WM_CONSWITCH); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISFRONT); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISALTKEY); + if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE) { PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL); @@ -450,20 +455,15 @@ OCImage.FrameData1 = NULL; videomode_emulatemode = 0; - this->info.video_mem=hwcaps.currently_available_video_ram/1024; this->info.wm_available = 1; - this->info.hw_available = 1; - this->info.blit_fill = 1; - this->info.blit_hw = 1; - this->info.blit_hw_A = 0; - this->info.blit_hw_CC = 1; + + ph_UpdateHWInfo(this); return 0; } static SDL_Surface* ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) { - PgHWCaps_t hwcaps; const struct ColourMasks* mask; /* Lock the event thread, in multi-threading environments */ @@ -558,6 +558,7 @@ /* Must call at least once for setup image planes */ if (ph_SetupUpdateFunction(this, current, current->flags)==-1) { + /* Error string was filled in the ph_SetupUpdateFunction() */ return NULL; } @@ -573,12 +574,7 @@ visualbpp=bpp; - if (PgGetGraphicsHWCaps(&hwcaps) < 0) - { - SDL_SetError("ph_SetVideoMode(): GetGraphicsHWCaps function failed !\n"); - return NULL; - } - this->info.video_mem=hwcaps.currently_available_video_ram/1024; + ph_UpdateHWInfo(this); SDL_Unlock_EventThread(); diff -r 9f6ad2286011 -r 05c551e5bc64 src/video/photon/SDL_phyuv.c --- a/src/video/photon/SDL_phyuv.c Fri Apr 30 18:33:30 2004 +0000 +++ b/src/video/photon/SDL_phyuv.c Thu May 06 15:55:06 2004 +0000 @@ -42,7 +42,7 @@ #define OVERLAY_STATE_UNINIT 0 #define OVERLAY_STATE_ACTIVE 1 -/* The functions used to manipulate software video overlays */ +/* The functions are used to manipulate software video overlays */ static struct private_yuvhwfuncs ph_yuvfuncs = { ph_LockYUVOverlay, diff -r 9f6ad2286011 -r 05c551e5bc64 test/README --- a/test/README Fri Apr 30 18:33:30 2004 +0000 +++ b/test/README Thu May 06 15:55:06 2004 +0000 @@ -11,7 +11,7 @@ loopwave Audio test -- loop playing a WAV file testcdrom Sample audio CD control program testkeys List the available keyboard keys - testvidinfo Show the pixel format of the display + testvidinfo Show the pixel format of the display and perfom the benchmark checkkeys Watch the key events to check the keyboard testwin Display a BMP image at various depths graywin Display a gray gradient and center mouse on spacebar @@ -22,4 +22,5 @@ threadwin Test multi-threaded event handling testgl A very simple example of using OpenGL with SDL testjoystick List joysticks and watch joystick events - + testoverlay Tests the software/hardware overlay functionality. + testoverlay2 Tests the overlay flickering/scaling during playback. diff -r 9f6ad2286011 -r 05c551e5bc64 test/testalpha.c --- a/test/testalpha.c Fri Apr 30 18:33:30 2004 +0000 +++ b/test/testalpha.c Thu May 06 15:55:06 2004 +0000 @@ -380,6 +380,37 @@ exit(1); } + /* Print out information about our surfaces */ + printf("Screen is at %d bits per pixel\n",screen->format->BitsPerPixel); + if ( (screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) { + printf("Screen is in video memory\n"); + } else { + printf("Screen is in system memory\n"); + } + if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { + printf("Screen has double-buffering enabled\n"); + } + if ( (sprite->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) { + printf("Sprite is in video memory\n"); + } else { + printf("Sprite is in system memory\n"); + } + + /* Run a sample blit to trigger blit acceleration */ + { SDL_Rect dst; + dst.x = 0; + dst.y = 0; + dst.w = sprite->w; + dst.h = sprite->h; + SDL_BlitSurface(sprite, NULL, screen, &dst); + SDL_FillRect(screen, &dst, 0); + } + if ( (sprite->flags & SDL_HWACCEL) == SDL_HWACCEL ) { + printf("Sprite blit uses hardware alpha acceleration\n"); + } else { + printf("Sprite blit dosn't uses hardware alpha acceleration\n"); + } + /* Set a clipping rectangle to clip the outside edge of the screen */ { SDL_Rect clip; clip.x = 32; diff -r 9f6ad2286011 -r 05c551e5bc64 test/testoverlay2.c --- a/test/testoverlay2.c Fri Apr 30 18:33:30 2004 +0000 +++ b/test/testoverlay2.c Thu May 06 15:55:06 2004 +0000 @@ -254,13 +254,15 @@ static void PrintUsage(char *argv0) { fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0); - fprintf(stderr, "Where 'arg' is one of:\n"); + fprintf(stderr, "\n"); + fprintf(stderr, "Where 'arg' is any of the following options:\n"); + fprintf(stderr, "\n"); fprintf(stderr, " -fps \n"); fprintf(stderr, " -format (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); fprintf(stderr, " -scale (initial scale of the overlay)\n"); fprintf(stderr, " -help (shows this help)\n"); fprintf(stderr, "\n"); - fprintf(stderr, " Press ESC to exit, or SPACE to freeze the movie while application running.\n"); + fprintf(stderr, "Press ESC to exit, or SPACE to freeze the movie while application running.\n"); fprintf(stderr, "\n"); } @@ -466,6 +468,11 @@ free(RawMooseData); overlay=SDL_CreateYUVOverlay(MOOSEPIC_W, MOOSEPIC_H, overlay_format, screen); + if (!overlay) + { + fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError()); + return 7; + } printf("Created %dx%dx%d %s %s overlay\n",overlay->w,overlay->h,overlay->planes, overlay->hw_overlay?"hardware":"software", diff -r 9f6ad2286011 -r 05c551e5bc64 test/testvidinfo.c --- a/test/testvidinfo.c Fri Apr 30 18:33:30 2004 +0000 +++ b/test/testvidinfo.c Thu May 06 15:55:06 2004 +0000 @@ -11,7 +11,9 @@ #define NUM_BLITS 10 #define NUM_UPDATES 500 -#define FLAG_MASK (SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF) +#define FLAG_MASK (SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF | \ + SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCEL | \ + SDL_RLEACCELOK) void PrintFlags(Uint32 flags) { @@ -30,9 +32,15 @@ if ( flags & SDL_SRCCOLORKEY ) { printf(" | SDL_SRCCOLORKEY"); } + if ( flags & SDL_SRCALPHA ) { + printf(" | SDL_SRCALPHA"); + } if ( flags & SDL_RLEACCEL ) { printf(" | SDL_RLEACCEL"); } + if ( flags & SDL_RLEACCELOK ) { + printf(" | SDL_RLEACCELOK"); + } } int RunBlitTests(SDL_Surface *screen, SDL_Surface *bmp, int blitcount) @@ -117,6 +125,10 @@ printf("%d fills and flips in zero seconds!n", frames); } + /* clear the screen after fill test */ + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); + while ( SDL_PollEvent(&event) ) { if ( event.type == SDL_KEYDOWN ) return 0; @@ -142,6 +154,15 @@ printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); } + /* clear the screen after blit test */ + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); + + while ( SDL_PollEvent(&event) ) { + if ( event.type == SDL_KEYDOWN ) + return 0; + } + /* run the colorkeyed blit test */ bmpcc = SDL_LoadBMP("sample.bmp"); if ( ! bmpcc ) { @@ -164,6 +185,15 @@ printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); } + /* clear the screen after cc blit test */ + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); + + while ( SDL_PollEvent(&event) ) { + if ( event.type == SDL_KEYDOWN ) + return 0; + } + /* run the generic blit test */ tmp = bmp; bmp = SDL_DisplayFormat(bmp); @@ -186,6 +216,15 @@ printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); } + /* clear the screen after blit test */ + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); + + while ( SDL_PollEvent(&event) ) { + if ( event.type == SDL_KEYDOWN ) + return 0; + } + /* run the colorkeyed blit test */ tmp = bmpcc; bmpcc = SDL_DisplayFormat(bmpcc); @@ -208,6 +247,81 @@ printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); } + /* clear the screen after cc blit test */ + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); + + while ( SDL_PollEvent(&event) ) { + if ( event.type == SDL_KEYDOWN ) + return 0; + } + + /* run the alpha blit test only if screen bpp>8 */ + if (bmp->format->BitsPerPixel>8) + { + SDL_FreeSurface(bmp); + bmp = SDL_LoadBMP("sample.bmp"); + SDL_SetAlpha(bmp, SDL_SRCALPHA, 85); /* 85 - 33% alpha */ + tmp = bmp; + bmp = SDL_DisplayFormat(bmp); + SDL_FreeSurface(tmp); + if ( ! bmp ) { + printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); + return 0; + } + printf("Running display format alpha blit test: %dx%d at %d bpp, flags: ", + bmp->w, bmp->h, bmp->format->BitsPerPixel); + PrintFlags(bmp->flags); + printf("\n"); + then = SDL_GetTicks(); + frames = RunBlitTests(screen, bmp, NUM_BLITS); + now = SDL_GetTicks(); + seconds = (float)(now - then) / 1000.0f; + if ( seconds > 0.0f ) { + printf("%d alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); + } else { + printf("%d alpha blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); + } + } + + /* clear the screen after alpha blit test */ + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); + + while ( SDL_PollEvent(&event) ) { + if ( event.type == SDL_KEYDOWN ) + return 0; + } + + /* run the cc+alpha blit test only if screen bpp>8 */ + if (bmp->format->BitsPerPixel>8) + { + SDL_FreeSurface(bmpcc); + bmpcc = SDL_LoadBMP("sample.bmp"); + SDL_SetAlpha(bmpcc, SDL_SRCALPHA, 85); /* 85 - 33% alpha */ + SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, *(Uint8 *)bmpcc->pixels); + tmp = bmpcc; + bmpcc = SDL_DisplayFormat(bmpcc); + SDL_FreeSurface(tmp); + if ( ! bmpcc ) { + printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); + return 0; + } + printf("Running display format cc+alpha blit test: %dx%d at %d bpp, flags: ", + bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel); + PrintFlags(bmpcc->flags); + printf("\n"); + then = SDL_GetTicks(); + frames = RunBlitTests(screen, bmpcc, NUM_BLITS); + now = SDL_GetTicks(); + seconds = (float)(now - then) / 1000.0f; + if ( seconds > 0.0f ) { + printf("%d cc+alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); + } else { + printf("%d cc+alpha blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); + } + } + SDL_FreeSurface(bmpcc); SDL_FreeSurface(bmp);