summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2004-05-06 15:55:06 +0000
committerSam Lantinga <slouken@libsdl.org>2004-05-06 15:55:06 +0000
commitedba2cc827ece6f0a32f636e496961f8ad47ef58 (patch)
treed58fad40c01c919618a28494fd34fa0a0f380f42
parent2ca2c6c186125dedb91077c7c38f232f6c71a23a (diff)
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. --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40887
-rw-r--r--README.QNX64
-rw-r--r--acinclude.m439
-rwxr-xr-xconfig.sub4
-rw-r--r--configure.in9
-rw-r--r--ltmain.sh6
-rw-r--r--src/video/photon/SDL_ph_events.c9
-rw-r--r--src/video/photon/SDL_ph_image.c76
-rw-r--r--src/video/photon/SDL_ph_video.c40
-rw-r--r--src/video/photon/SDL_phyuv.c2
-rw-r--r--test/README5
-rw-r--r--test/testalpha.c31
-rw-r--r--test/testoverlay2.c11
-rw-r--r--test/testvidinfo.c116
13 files changed, 334 insertions, 78 deletions
diff --git a/README.QNX b/README.QNX
index 2b4992e8..995afbec 100644
--- a/README.QNX
+++ b/README.QNX
@@ -1,5 +1,5 @@
-README by Mike Gorchak <mike@malva.ua>, <lestat@i.com.ua>
-Last changed at 14 Feb 2004.
+README.QNX by Mike Gorchak <mike@malva.ua>, <lestat@i.com.ua>
+Last changed at 24 Apr 2004.
======================================================================
Table of Contents:
@@ -19,8 +19,8 @@ Table of Contents:
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 @@ PHOGL_ATTRIB_FORCE_HW or PHOGL_ATTRIB_FAVOR_HW.
======================================================================
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 @@ script you must manually delete the libtool.m4 stuff from the acinclu-
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 @@ script will be broken.
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 @@ x11 support, e.g.:
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 @@ environmental variable.
* 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 --git a/acinclude.m4 b/acinclude.m4
index 6854e0a3..e555dd07 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1652,14 +1652,16 @@ newsos6)
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 @@ irix5* | irix6* | nonstopux*)
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 @@ newos6*)
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 @@ case $host_os in
# 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 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
;;
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 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
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 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
;;
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 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
_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 --git a/config.sub b/config.sub
index 9772e87d..277a01d0 100755
--- a/config.sub
+++ b/config.sub
@@ -1140,10 +1140,8 @@ case $os in
;;
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 --git a/configure.in b/configure.in
index de2ca562..288a1eeb 100644
--- a/configure.in
+++ b/configure.in
@@ -528,6 +528,14 @@ CheckNASM()
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 @@ case "$target" in
ARCH=qnx
CheckDummyVideo
CheckDiskAudio
+ # CheckNASM
CheckDLOPEN
CheckNAS
CheckPHOTON
diff --git a/ltmain.sh b/ltmain.sh
index bdfdbf88..13b13494 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -2975,6 +2975,12 @@ EOF
versuffix=".$current";
;;
+ qnx)
+ major=".$current"
+ versuffix=".$current"
+ deplibs_check_method="pass_all"
+ ;;
+
irix | nonstopux)
major=`expr $current - $age + 1`
diff --git a/src/video/photon/SDL_ph_events.c b/src/video/photon/SDL_ph_events.c
index 18feb13f..068506fe 100644
--- a/src/video/photon/SDL_ph_events.c
+++ b/src/video/photon/SDL_ph_events.c
@@ -32,6 +32,7 @@ static char rcsid =
#include <stdio.h>
#include <setjmp.h>
#include <sys/time.h>
+#include <sys/neutrino.h>
#include <Ph.h>
#include <photon/PkKeyDef.h>
@@ -235,7 +236,13 @@ static int ph_DispatchEvent(_THIS)
/* 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 --git a/src/video/photon/SDL_ph_image.c b/src/video/photon/SDL_ph_image.c
index ff69a028..38b046c5 100644
--- a/src/video/photon/SDL_ph_image.c
+++ b/src/video/photon/SDL_ph_image.c
@@ -152,8 +152,7 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen)
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 @@ int ph_UpdateHWInfo(_THIS)
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 @@ int ph_FillHWRect(_THIS, SDL_Surface* surface, SDL_Rect* rect, Uint32 color)
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 @@ int ph_HWAccelBlit(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Re
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 @@ int ph_HWAccelBlit(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Re
}
}
+ if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA)
+ {
+ PgAlphaOff();
+ }
+
if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY)
{
PgChromaOff();
@@ -935,6 +983,11 @@ int ph_HWAccelBlit(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Re
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_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
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 --git a/src/video/photon/SDL_ph_video.c b/src/video/photon/SDL_ph_video.c
index f6625565..1c608e4f 100644
--- a/src/video/photon/SDL_ph_video.c
+++ b/src/video/photon/SDL_ph_video.c
@@ -83,27 +83,28 @@ static int ph_Available(void)
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 @@ static SDL_VideoDevice *ph_CreateDevice(int devindex)
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 @@ static int ph_SetupWindow(_THIS, int w, int h, int flags)
}
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 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat* vformat)
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 @@ static SDL_Surface* ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int
/* 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 @@ static SDL_Surface* ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int
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 --git a/src/video/photon/SDL_phyuv.c b/src/video/photon/SDL_phyuv.c
index 141ab799..a73b988c 100644
--- a/src/video/photon/SDL_phyuv.c
+++ b/src/video/photon/SDL_phyuv.c
@@ -42,7 +42,7 @@ static char rcsid =
#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 --git a/test/README b/test/README
index d2c14176..742ecbb0 100644
--- a/test/README
+++ b/test/README
@@ -11,7 +11,7 @@ These are test programs for the SDL library:
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 @@ These are test programs for the SDL library:
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 --git a/test/testalpha.c b/test/testalpha.c
index 1c231dd3..d0a0b44f 100644
--- a/test/testalpha.c
+++ b/test/testalpha.c
@@ -380,6 +380,37 @@ int main(int argc, char *argv[])
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 --git a/test/testoverlay2.c b/test/testoverlay2.c
index 3b94bf8a..405988fd 100644
--- a/test/testoverlay2.c
+++ b/test/testoverlay2.c
@@ -254,13 +254,15 @@ ConvertRGBtoYUY2(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
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 <frames per second>\n");
fprintf(stderr, " -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
fprintf(stderr, " -scale <scale factor> (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 @@ int main(int argc, char **argv)
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 --git a/test/testvidinfo.c b/test/testvidinfo.c
index 2b4b1d02..25950210 100644
--- a/test/testvidinfo.c
+++ b/test/testvidinfo.c
@@ -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 @@ void PrintFlags(Uint32 flags)
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 @@ int RunModeTests(SDL_Surface *screen)
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 @@ int RunModeTests(SDL_Surface *screen)
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 @@ int RunModeTests(SDL_Surface *screen)
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 @@ int RunModeTests(SDL_Surface *screen)
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 @@ int RunModeTests(SDL_Surface *screen)
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);