Commit edba2cc8 authored by Sam Lantinga's avatar Sam Lantinga

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
parent 2ca2c6c1
README by Mike Gorchak <mike@malva.ua>, <lestat@i.com.ua> README.QNX by Mike Gorchak <mike@malva.ua>, <lestat@i.com.ua>
Last changed at 14 Feb 2004. Last changed at 24 Apr 2004.
====================================================================== ======================================================================
Table of Contents: Table of Contents:
...@@ -19,8 +19,8 @@ Table of Contents: ...@@ -19,8 +19,8 @@ Table of Contents:
heavily tested yet. heavily tested yet.
If you have QNX RtP version 6.1.0 or above you must download the 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 Photon3D runtime from http://developers.qnx.com or install it from the
public repository or the public CD, available with QNX. OS versions public repository or from the public CD, available with QNX. OS versi-
below 6.1.0 are not supported. ons below 6.1.0 are not supported.
When creating an OpenGL context, software renderer mode is artifi- When creating an OpenGL context, software renderer mode is artifi-
cially selected (QSSL made acceleration only for Voodoo boards in cially selected (QSSL made acceleration only for Voodoo boards in
fullscreen mode, sorry but I don't have this board to test OpenGL - 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. ...@@ -36,22 +36,23 @@ PHOGL_ATTRIB_FORCE_HW or PHOGL_ATTRIB_FAVOR_HW.
====================================================================== ======================================================================
2. Wheel and multi-button mouses: 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. 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. 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. tions.
I've tested it on: I've tested it on:
1. Genius Optical NetScroll/+ (1 wheel) 1. Genius Optical NetScroll/+ PS/2 (1 wheel)
2. A4Tech Optical GreatEye WheelMouse, model: WOP-35. (2 wheels + 2 2. A4Tech Optical GreatEye WheelMouse PS/2, model: WOP-35. (2 wheels
additional buttons). The wheel for vertical scrolling works as usu- + 2 additional buttons). The wheel for vertical scrolling works as
al, but the second wheel for horizontal scrolling emits two sequen- usual, but the second wheel for horizontal scrolling emits two se-
tial events up or down, so it can provide faster scrolling than the quential events up or down, so it can provide faster scrolling than
first wheel. Additional buttons don't emit any events, but it looks the first wheel. Additional buttons don't emit any events, but it
like they're handled by photon in an unusual way - like click to looks like they're handled by photon in an unusual way - like click
front, but works not with any window, looks like bug-o-feature :). to front, but works not with any window, looks like a fun bug-o-fe-
ature :).
====================================================================== ======================================================================
3. CDROM handling issues: 3. CDROM handling issues:
...@@ -89,10 +90,12 @@ script you must manually delete the libtool.m4 stuff from the acinclu- ...@@ -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 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 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 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 but anyway it is broken :), Just remove it, then run "libtoolize
--force --copy", delete the file aclocal.m4 and after that run the --force --copy", delete the file aclocal.m4 if it is exists and after
autogen.sh script. 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: 6. Some building issues:
...@@ -105,16 +108,19 @@ script will be broken. ...@@ -105,16 +108,19 @@ script will be broken.
Run the configure script without x11 support, e.g.: Run the configure script without x11 support, e.g.:
a) for OpenGL support: a) for OpenGL support:
./configure --prefix=/usr \ ./configure --prefix=/usr \
--disable-video-x11 \ --disable-video-x11 \
--disable-shared --disable-shared
b) without OpenGL support: b) without OpenGL support:
./configure --prefix=/usr \ ./configure --prefix=/usr \
--disable-video-x11 \ --disable-video-x11 \
--disable-shared \ --disable-shared \
--disable-video-opengl --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 In the test directory also run the ./configure script without
x11 support, e.g.: x11 support, e.g.:
...@@ -128,10 +134,10 @@ x11 support, e.g.: ...@@ -128,10 +134,10 @@ x11 support, e.g.:
Please note that the photon driver is sensible to the following Please note that the photon driver is sensible to the following
environmental variables: environmental variables:
* SDL_PHOTON_FULLSCREEN_REFRESH - this environment variable controls * SDL_PHOTON_FULLSCREEN_REFRESH - this environment variable controls
the refresh rate in all fullscreen modes. Be carefull !!! Photon drivers the refresh rate in all fullscreen modes. Be carefull !!! Photon
usually do not checking the maximum refresh rate, which video adapter or drivers usually do not checking the maximum refresh rate, which video
monitor supports. adapter or monitor supports.
* SDL_VIDEO_WINDOW_POS - can be set in the "X,Y" format. If X and Y * 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- coordinates are bigger than the current desktop resolution, then win-
...@@ -144,6 +150,6 @@ environmental variable. ...@@ -144,6 +150,6 @@ environmental variable.
* SDL_VIDEO_CENTERED - if this environmental variable exists then the * SDL_VIDEO_CENTERED - if this environmental variable exists then the
window centering is perfomed in the current virtual console. window centering is perfomed in the current virtual console.
The SDL_VIDEO_CENTERED enviromental variable has greater priority Notes: The SDL_VIDEO_CENTERED enviromental variable has greater pri-
than the SDL_VIDEO_WINDOW_POS in case if both variables are supplied ority than the SDL_VIDEO_WINDOW_POS in case if both variables are sup-
to the application. plied to the application.
...@@ -1652,14 +1652,16 @@ newsos6) ...@@ -1652,14 +1652,16 @@ newsos6)
shlibpath_overrides_runpath=yes shlibpath_overrides_runpath=yes
;; ;;
nto-qnx) *qnx* | *nto*)
version_type=linux version_type=qnx
need_lib_prefix=no need_lib_prefix=no
need_version=no need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
soname_spec='${libname}${release}${shared_ext}$major' soname_spec='${libname}${release}.so$major'
shlibpath_var=LD_LIBRARY_PATH shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes shlibpath_overrides_runpath=no
hardcode_into_libs=yes
dynamic_linker='ldqnx.so'
;; ;;
openbsd*) openbsd*)
...@@ -2356,6 +2358,10 @@ irix5* | irix6* | nonstopux*) ...@@ -2356,6 +2358,10 @@ irix5* | irix6* | nonstopux*)
lt_cv_deplibs_check_method=pass_all lt_cv_deplibs_check_method=pass_all
;; ;;
*qnx* | *nto*)
lt_cv_deplibs_check_method=pass_all
;;
# This must be Linux ELF. # This must be Linux ELF.
linux*) linux*)
case $host_cpu in case $host_cpu in
...@@ -2382,10 +2388,6 @@ newos6*) ...@@ -2382,10 +2388,6 @@ newos6*)
lt_cv_file_magic_test_file=/usr/lib/libnls.so lt_cv_file_magic_test_file=/usr/lib/libnls.so
;; ;;
nto-qnx)
lt_cv_deplibs_check_method=unknown
;;
openbsd*) openbsd*)
lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_cmd=/usr/bin/file
lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
...@@ -3614,6 +3616,8 @@ case $host_os in ...@@ -3614,6 +3616,8 @@ case $host_os in
# FIXME: insert proper C++ library support # FIXME: insert proper C++ library support
_LT_AC_TAGVAR(ld_shlibs, $1)=no _LT_AC_TAGVAR(ld_shlibs, $1)=no
;; ;;
*qnx* | *nto*)
;;
*) *)
# FIXME: insert proper C++ library support # FIXME: insert proper C++ library support
_LT_AC_TAGVAR(ld_shlibs, $1)=no _LT_AC_TAGVAR(ld_shlibs, $1)=no
...@@ -4729,6 +4733,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC]) ...@@ -4729,6 +4733,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
;; ;;
esac 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' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;; ;;
...@@ -4768,6 +4776,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC]) ...@@ -4768,6 +4776,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
freebsd*) freebsd*)
# FreeBSD uses GNU C++ # 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*) hpux9* | hpux10* | hpux11*)
case $cc_basename in case $cc_basename in
CC) CC)
...@@ -4988,6 +5000,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC]) ...@@ -4988,6 +5000,10 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
;; ;;
esac 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' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
...@@ -5028,6 +5044,11 @@ AC_MSG_CHECKING([for $compiler option to produce PIC]) ...@@ -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' _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*) irix5* | irix6* | nonstopux*)
_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
# PIC (with -KPIC) is the default. # PIC (with -KPIC) is the default.
......
...@@ -1140,10 +1140,8 @@ case $os in ...@@ -1140,10 +1140,8 @@ case $os in
;; ;;
esac esac
;; ;;
-nto-qnx*)
;;
-nto*) -nto*)
os=`echo $os | sed -e 's|nto|nto-qnx|'` os=-nto-qnx
;; ;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
......
...@@ -528,6 +528,14 @@ CheckNASM() ...@@ -528,6 +528,14 @@ CheckNASM()
SDL_EXTRADIRS="$SDL_EXTRADIRS hermes" SDL_EXTRADIRS="$SDL_EXTRADIRS hermes"
SDL_EXTRALIBS="$SDL_EXTRALIBS hermes/libhermes.la" SDL_EXTRALIBS="$SDL_EXTRALIBS hermes/libhermes.la"
use_nasm=yes 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
fi fi
} }
...@@ -2309,6 +2317,7 @@ case "$target" in ...@@ -2309,6 +2317,7 @@ case "$target" in
ARCH=qnx ARCH=qnx
CheckDummyVideo CheckDummyVideo
CheckDiskAudio CheckDiskAudio
# CheckNASM
CheckDLOPEN CheckDLOPEN
CheckNAS CheckNAS
CheckPHOTON CheckPHOTON
......
...@@ -2975,6 +2975,12 @@ EOF ...@@ -2975,6 +2975,12 @@ EOF
versuffix=".$current"; versuffix=".$current";
;; ;;
qnx)
major=".$current"
versuffix=".$current"
deplibs_check_method="pass_all"
;;
irix | nonstopux) irix | nonstopux)
major=`expr $current - $age + 1` major=`expr $current - $age + 1`
......
...@@ -32,6 +32,7 @@ static char rcsid = ...@@ -32,6 +32,7 @@ static char rcsid =
#include <stdio.h> #include <stdio.h>
#include <setjmp.h> #include <setjmp.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/neutrino.h>
#include <Ph.h> #include <Ph.h>
#include <photon/PkKeyDef.h> #include <photon/PkKeyDef.h>
...@@ -235,7 +236,13 @@ static int ph_DispatchEvent(_THIS) ...@@ -235,7 +236,13 @@ static int ph_DispatchEvent(_THIS)
/* request to resize */ /* request to resize */
else if (winEvent->event_f==Ph_WM_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 */ /* request to move */
else if (winEvent->event_f==Ph_WM_MOVE) else if (winEvent->event_f==Ph_WM_MOVE)
......
...@@ -152,8 +152,7 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen) ...@@ -152,8 +152,7 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen)
break; break;
} }
/* Currently only offscreen contexts with the same bit depth as the /* Currently offscreen contexts with the same bit depth as display bpp only can be created */
* display can be created. */
OCImage.offscreen_context = PdCreateOffscreenContext(0, screen->w, screen->h, Pg_OSC_MEM_PAGE_ALIGN); OCImage.offscreen_context = PdCreateOffscreenContext(0, screen->w, screen->h, Pg_OSC_MEM_PAGE_ALIGN);
if (OCImage.offscreen_context == NULL) if (OCImage.offscreen_context == NULL)
...@@ -482,24 +481,57 @@ int ph_UpdateHWInfo(_THIS) ...@@ -482,24 +481,57 @@ int ph_UpdateHWInfo(_THIS)
return -1; 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) 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 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) 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 else
{ {
this->info.blit_hw_CC = 0; this->info.blit_hw_CC = 0;
} }
return 0; return 0;
...@@ -748,6 +780,11 @@ int ph_FillHWRect(_THIS, SDL_Surface* surface, SDL_Rect* rect, Uint32 color) ...@@ -748,6 +780,11 @@ int ph_FillHWRect(_THIS, SDL_Surface* surface, SDL_Rect* rect, Uint32 color)
Uint32 truecolor; Uint32 truecolor;
int ydisp=0; int ydisp=0;
if (this->info.blit_fill!=1)
{
return -1;
}
truecolor=ph_ExpandColor(this, surface, color); truecolor=ph_ExpandColor(this, surface, color);
if (truecolor==0xFFFFFFFFUL) if (truecolor==0xFFFFFFFFUL)
{ {
...@@ -885,6 +922,12 @@ int ph_HWAccelBlit(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Re ...@@ -885,6 +922,12 @@ int ph_HWAccelBlit(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Re
PgChromaOn(); PgChromaOn();
} }
if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA)
{
ph_SetHWAlpha(this, src, src->format->alpha);
PgAlphaOn();
}
if (dst == this->screen) if (dst == this->screen)
{ {
if (src == this->screen) if (src == this->screen)
...@@ -916,6 +959,11 @@ int ph_HWAccelBlit(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Re ...@@ -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) if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY)
{ {
PgChromaOff(); PgChromaOff();
...@@ -935,6 +983,11 @@ int ph_HWAccelBlit(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Re ...@@ -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) int ph_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
{ {
if (this->info.blit_hw_CC!=1)
{
return -1;
}
if (surface->hwdata!=NULL) if (surface->hwdata!=NULL)
{ {
surface->hwdata->colorkey=ph_ExpandColor(this, surface, key); surface->hwdata->colorkey=ph_ExpandColor(this, surface, key);
...@@ -950,7 +1003,14 @@ int ph_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key) ...@@ -950,7 +1003,14 @@ int ph_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
int ph_SetHWAlpha(_THIS, SDL_Surface* surface, Uint8 alpha) 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 #ifdef HAVE_OPENGL
......
...@@ -83,27 +83,28 @@ static int ph_Available(void) ...@@ -83,27 +83,28 @@ static int ph_Available(void)
return 1; 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 */ /* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
if (device) { if (device)
{
memset(device, 0, (sizeof *device)); memset(device, 0, (sizeof *device));
device->hidden = (struct SDL_PrivateVideoData *) device->hidden = (struct SDL_PrivateVideoData*)malloc((sizeof *device->hidden));
malloc((sizeof *device->hidden));
device->gl_data = NULL; device->gl_data = NULL;
} }
if ((device == NULL) || (device->hidden == NULL)) { if ((device == NULL) || (device->hidden == NULL))
{
SDL_OutOfMemory(); SDL_OutOfMemory();
ph_DeleteDevice(device); ph_DeleteDevice(device);
return(0); return NULL;
} }
memset(device->hidden, 0, (sizeof *device->hidden)); memset(device->hidden, 0, (sizeof *device->hidden));
/* Set the driver flags */ /* Set the driver flags */
device->handles_any_size = 1; /* JB not true for fullscreen */ device->handles_any_size = 1;
/* Set the function pointers */ /* Set the function pointers */
device->CreateYUVOverlay = ph_CreateYUVOverlay; device->CreateYUVOverlay = ph_CreateYUVOverlay;
...@@ -113,7 +114,7 @@ static SDL_VideoDevice *ph_CreateDevice(int devindex) ...@@ -113,7 +114,7 @@ static SDL_VideoDevice *ph_CreateDevice(int devindex)
device->ToggleFullScreen = ph_ToggleFullScreen; device->ToggleFullScreen = ph_ToggleFullScreen;
device->UpdateMouse = ph_UpdateMouse; device->UpdateMouse = ph_UpdateMouse;
device->SetColors = ph_SetColors; 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->VideoQuit = ph_VideoQuit;
device->AllocHWSurface = ph_AllocHWSurface; device->AllocHWSurface = ph_AllocHWSurface;
device->CheckHWBlit = ph_CheckHWBlit; device->CheckHWBlit = ph_CheckHWBlit;
...@@ -254,6 +255,10 @@ static int ph_SetupWindow(_THIS, int w, int h, int flags) ...@@ -254,6 +255,10 @@ static int ph_SetupWindow(_THIS, int w, int h, int flags)
} }
else 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) if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE)
{ {
PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL); 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) ...@@ -450,20 +455,15 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat* vformat)
OCImage.FrameData1 = NULL; OCImage.FrameData1 = NULL;
videomode_emulatemode = 0; videomode_emulatemode = 0;
this->info.video_mem=hwcaps.currently_available_video_ram/1024;
this->info.wm_available = 1; this->info.wm_available = 1;
this->info.hw_available = 1;
this->info.blit_fill = 1; ph_UpdateHWInfo(this);
this->info.blit_hw = 1;
this->info.blit_hw_A = 0;
this->info.blit_hw_CC = 1;
return 0; return 0;
} }
static SDL_Surface* ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) static SDL_Surface* ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
{ {
PgHWCaps_t hwcaps;
const struct ColourMasks* mask; const struct ColourMasks* mask;
/* Lock the event thread, in multi-threading environments */ /* Lock the event thread, in multi-threading environments */
...@@ -558,6 +558,7 @@ static SDL_Surface* ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int ...@@ -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 */ /* Must call at least once for setup image planes */
if (ph_SetupUpdateFunction(this, current, current->flags)==-1) if (ph_SetupUpdateFunction(this, current, current->flags)==-1)
{ {
/* Error string was filled in the ph_SetupUpdateFunction() */
return NULL; return NULL;
} }
...@@ -573,12 +574,7 @@ static SDL_Surface* ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int ...@@ -573,12 +574,7 @@ static SDL_Surface* ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int
visualbpp=bpp; visualbpp=bpp;
if (PgGetGraphicsHWCaps(&hwcaps) < 0) ph_UpdateHWInfo(this);
{
SDL_SetError("ph_SetVideoMode(): GetGraphicsHWCaps function failed !\n");
return NULL;
}
this->info.video_mem=hwcaps.currently_available_video_ram/1024;
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
......
...@@ -42,7 +42,7 @@ static char rcsid = ...@@ -42,7 +42,7 @@ static char rcsid =
#define OVERLAY_STATE_UNINIT 0 #define OVERLAY_STATE_UNINIT 0
#define OVERLAY_STATE_ACTIVE 1 #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 = static struct private_yuvhwfuncs ph_yuvfuncs =
{ {
ph_LockYUVOverlay, ph_LockYUVOverlay,
......
...@@ -11,7 +11,7 @@ These are test programs for the SDL library: ...@@ -11,7 +11,7 @@ These are test programs for the SDL library:
loopwave Audio test -- loop playing a WAV file loopwave Audio test -- loop playing a WAV file
testcdrom Sample audio CD control program testcdrom Sample audio CD control program
testkeys List the available keyboard keys 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 checkkeys Watch the key events to check the keyboard
testwin Display a BMP image at various depths testwin Display a BMP image at various depths
graywin Display a gray gradient and center mouse on spacebar graywin Display a gray gradient and center mouse on spacebar
...@@ -22,4 +22,5 @@ These are test programs for the SDL library: ...@@ -22,4 +22,5 @@ These are test programs for the SDL library:
threadwin Test multi-threaded event handling threadwin Test multi-threaded event handling
testgl A very simple example of using OpenGL with SDL testgl A very simple example of using OpenGL with SDL
testjoystick List joysticks and watch joystick events testjoystick List joysticks and watch joystick events
testoverlay Tests the software/hardware overlay functionality.
testoverlay2 Tests the overlay flickering/scaling during playback.
...@@ -380,6 +380,37 @@ int main(int argc, char *argv[]) ...@@ -380,6 +380,37 @@ int main(int argc, char *argv[])
exit(1); 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 */ /* Set a clipping rectangle to clip the outside edge of the screen */
{ SDL_Rect clip; { SDL_Rect clip;
clip.x = 32; clip.x = 32;
......
...@@ -254,13 +254,15 @@ ConvertRGBtoYUY2(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance) ...@@ -254,13 +254,15 @@ ConvertRGBtoYUY2(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
static void PrintUsage(char *argv0) static void PrintUsage(char *argv0)
{ {
fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", 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, " -fps <frames per second>\n");
fprintf(stderr, " -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\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, " -scale <scale factor> (initial scale of the overlay)\n");
fprintf(stderr, " -help (shows this help)\n"); fprintf(stderr, " -help (shows this help)\n");
fprintf(stderr, "\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"); fprintf(stderr, "\n");
} }
...@@ -466,6 +468,11 @@ int main(int argc, char **argv) ...@@ -466,6 +468,11 @@ int main(int argc, char **argv)
free(RawMooseData); free(RawMooseData);
overlay=SDL_CreateYUVOverlay(MOOSEPIC_W, MOOSEPIC_H, overlay_format, screen); 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, printf("Created %dx%dx%d %s %s overlay\n",overlay->w,overlay->h,overlay->planes,
overlay->hw_overlay?"hardware":"software", overlay->hw_overlay?"hardware":"software",
......
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
#define NUM_BLITS 10 #define NUM_BLITS 10
#define NUM_UPDATES 500 #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) void PrintFlags(Uint32 flags)
{ {
...@@ -30,9 +32,15 @@ void PrintFlags(Uint32 flags) ...@@ -30,9 +32,15 @@ void PrintFlags(Uint32 flags)
if ( flags & SDL_SRCCOLORKEY ) { if ( flags & SDL_SRCCOLORKEY ) {
printf(" | SDL_SRCCOLORKEY"); printf(" | SDL_SRCCOLORKEY");
} }
if ( flags & SDL_SRCALPHA ) {
printf(" | SDL_SRCALPHA");
}
if ( flags & SDL_RLEACCEL ) { if ( flags & SDL_RLEACCEL ) {
printf(" | SDL_RLEACCEL"); printf(" | SDL_RLEACCEL");
} }
if ( flags & SDL_RLEACCELOK ) {
printf(" | SDL_RLEACCELOK");
}
} }
int RunBlitTests(SDL_Surface *screen, SDL_Surface *bmp, int blitcount) int RunBlitTests(SDL_Surface *screen, SDL_Surface *bmp, int blitcount)
...@@ -117,6 +125,10 @@ int RunModeTests(SDL_Surface *screen) ...@@ -117,6 +125,10 @@ int RunModeTests(SDL_Surface *screen)
printf("%d fills and flips in zero seconds!n", frames); 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) ) { while ( SDL_PollEvent(&event) ) {
if ( event.type == SDL_KEYDOWN ) if ( event.type == SDL_KEYDOWN )
return 0; return 0;
...@@ -142,6 +154,15 @@ int RunModeTests(SDL_Surface *screen) ...@@ -142,6 +154,15 @@ int RunModeTests(SDL_Surface *screen)
printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 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 */ /* run the colorkeyed blit test */
bmpcc = SDL_LoadBMP("sample.bmp"); bmpcc = SDL_LoadBMP("sample.bmp");
if ( ! bmpcc ) { if ( ! bmpcc ) {
...@@ -164,6 +185,15 @@ int RunModeTests(SDL_Surface *screen) ...@@ -164,6 +185,15 @@ int RunModeTests(SDL_Surface *screen)
printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 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 */ /* run the generic blit test */
tmp = bmp; tmp = bmp;
bmp = SDL_DisplayFormat(bmp); bmp = SDL_DisplayFormat(bmp);
...@@ -186,6 +216,15 @@ int RunModeTests(SDL_Surface *screen) ...@@ -186,6 +216,15 @@ int RunModeTests(SDL_Surface *screen)
printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 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 */ /* run the colorkeyed blit test */
tmp = bmpcc; tmp = bmpcc;
bmpcc = SDL_DisplayFormat(bmpcc); bmpcc = SDL_DisplayFormat(bmpcc);
...@@ -208,6 +247,81 @@ int RunModeTests(SDL_Surface *screen) ...@@ -208,6 +247,81 @@ int RunModeTests(SDL_Surface *screen)
printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 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(bmpcc);
SDL_FreeSurface(bmp); SDL_FreeSurface(bmp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment