Added initial support for PicoGUI (thanks Micah!)
authorSam Lantinga <slouken@libsdl.org>
Thu, 01 Aug 2002 23:24:13 +0000
changeset 433706de3956894
parent 432 80a35d43a58f
child 434 ed58b98c0d9d
Added initial support for PicoGUI (thanks Micah!)
Makefile.am
README.PicoGUI
configure.in
docs.html
src/video/Makefile.am
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/picogui/.cvsignore
src/video/picogui/Makefile.am
src/video/picogui/SDL_pgevents.c
src/video/picogui/SDL_pgevents_c.h
src/video/picogui/SDL_pgvideo.c
src/video/picogui/SDL_pgvideo.h
     1.1 --- a/Makefile.am	Thu Aug 01 23:08:41 2002 +0000
     1.2 +++ b/Makefile.am	Thu Aug 01 23:24:13 2002 +0000
     1.3 @@ -30,6 +30,7 @@
     1.4  	README.MacOSX	\
     1.5  	README.MiNT	\
     1.6  	README.NanoX	\
     1.7 +	README.PicoGUI	\
     1.8  	README.QNX	\
     1.9  	README.Qtopia	\
    1.10  	README.WinCE	\
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/README.PicoGUI	Thu Aug 01 23:24:13 2002 +0000
     2.3 @@ -0,0 +1,50 @@
     2.4 + ========================
     2.5 +  Using SDL with PicoGUI
     2.6 + ========================
     2.7 +
     2.8 +- Originally contributed by Micah Dowty <micahjd@users.sourceforge.net>
     2.9 +
    2.10 +PicoGUI is a scalable GUI system with a unique architecture, primarily focused
    2.11 +on scalability to various embedded systems. You can find more information
    2.12 +including a FAQ at http://picogui.org
    2.13 +
    2.14 +To use the patch:
    2.15 +
    2.16 +  1. When compiling, add the "--enable-video-picogui" switch to ./configure
    2.17 +
    2.18 +  2. When running your program, ensure that the picogui driver for SDL
    2.19 +     is in use by setting the SDL_VIDEODRIVER environment variable 
    2.20 +     to "picogui".
    2.21 +
    2.22 +  3. The program must also be linked to the C client library for PicoGUI
    2.23 +     (libpgui.so). If the program is being compiled with a patched SDL 
    2.24 +     installed this should be done automatically. If you want to use an
    2.25 +     existing binary with PicoGUI, you can set the LD_PRELOAD environment
    2.26 +     variable to the path of your libpgui.so file.
    2.27 +
    2.28 +Capabilities:
    2.29 +
    2.30 +  So far only basic functionality is provided on true color (linear16/24/32)
    2.31 +  devices. Accessing a memory mapped bitmap, updating the display, and handling
    2.32 +  mouse/keyboard input. This functionality has been tested with several
    2.33 +  applications, including mplayer, Xine, sldroids, and Abuse.
    2.34 +
    2.35 +TODO list:
    2.36 +
    2.37 +  - YUV overlays will be helpful for watching video on set top boxes or other
    2.38 +    embedded devices that have some graphics acceleration hardware
    2.39 +
    2.40 +  - Account for rotated bitmap storage in pgserver
    2.41 +
    2.42 +  - Support for hiding or changing the cursor
    2.43 +
    2.44 +  - The display should be centered when the SDL application is smaller
    2.45 +    than the PicoGUI panel
    2.46 +
    2.47 +  - Fullscreen or any other special modes
    2.48 +
    2.49 +  - Support for indexed and grayscale modes
    2.50 +
    2.51 +  - Probably much more...
    2.52 +
    2.53 +--- The End ---
     3.1 --- a/configure.in	Thu Aug 01 23:08:41 2002 +0000
     3.2 +++ b/configure.in	Thu Aug 01 23:24:13 2002 +0000
     3.3 @@ -1470,6 +1470,32 @@
     3.4      fi
     3.5  }
     3.6  
     3.7 +dnl Set up the PicoGUI video driver if enabled
     3.8 +CheckPicoGUI()
     3.9 +{
    3.10 +    AC_ARG_ENABLE(video-picogui,
    3.11 +[  --enable-video-picogui  use PicoGUI video driver [default=no]],
    3.12 +                  , enable_video_picogui=no)
    3.13 +    if test x$enable_video = xyes -a x$enable_video_picogui = xyes; then
    3.14 +        AC_MSG_CHECKING(for PicoGUI support)
    3.15 +        video_picogui=no
    3.16 +        AC_TRY_COMPILE([
    3.17 +         #include <picogui.h>
    3.18 +        ],[
    3.19 +        ],[
    3.20 +        video_picogui=yes
    3.21 +        ])
    3.22 +        AC_MSG_RESULT($video_picogui)
    3.23 +        if test x$video_picogui = xyes; then
    3.24 +	    SDL_LIBS="$SDL_LIBS -lpgui"
    3.25 +            CFLAGS="$CFLAGS -DENABLE_PICOGUI"
    3.26 +            VIDEO_SUBDIRS="$VIDEO_SUBDIRS picogui"
    3.27 +            VIDEO_DRIVERS="$VIDEO_DRIVERS picogui/libvideo_picogui.la"
    3.28 +        fi
    3.29 +        AC_LANG_C
    3.30 +    fi
    3.31 +}
    3.32 +
    3.33  dnl Set up the Mac toolbox video driver for Mac OS 7-9
    3.34  CheckTOOLBOX()
    3.35  {
    3.36 @@ -1676,6 +1702,7 @@
    3.37          CheckSVGA
    3.38          CheckAAlib
    3.39          CheckQtopia
    3.40 +        CheckPicoGUI
    3.41          CheckOpenGL
    3.42          CheckInputEvents
    3.43          CheckPTHREAD
    3.44 @@ -2602,6 +2629,7 @@
    3.45  src/video/xbios/Makefile
    3.46  src/video/gem/Makefile
    3.47  src/video/qtopia/Makefile
    3.48 +src/video/picogui/Makefile
    3.49  src/events/Makefile
    3.50  src/joystick/Makefile
    3.51  src/joystick/amigaos/Makefile
     4.1 --- a/docs.html	Thu Aug 01 23:08:41 2002 +0000
     4.2 +++ b/docs.html	Thu Aug 01 23:24:13 2002 +0000
     4.3 @@ -16,6 +16,7 @@
     4.4  Major changes since SDL 1.0.0:
     4.5  </H2>
     4.6  <UL>
     4.7 +	<LI> 1.2.5: Added initial support for PicoGUI (thanks Micah!)
     4.8  	<LI> 1.2.5: Fixed SDL_DisplayFormatAlpha() on RGB surfaces with alpha
     4.9  	<LI> 1.2.5: Fixed setting OpenGL mode multiple times on Windows
    4.10  	<LI> 1.2.5: Added support for Qtopia on embedded systems (thanks David!)
     5.1 --- a/src/video/Makefile.am	Thu Aug 01 23:08:41 2002 +0000
     5.2 +++ b/src/video/Makefile.am	Thu Aug 01 23:24:13 2002 +0000
     5.3 @@ -8,7 +8,7 @@
     5.4  DIST_SUBDIRS = dummy x11 dga nanox fbcon directfb vgl svga ggi aalib \
     5.5                 wincommon windib windx5 \
     5.6                 maccommon macdsp macrom quartz \
     5.7 -               bwindow ps2gs photon cybergfx epoc \
     5.8 +               bwindow ps2gs photon cybergfx epoc picogui \
     5.9                 ataricommon xbios gem XFree86
    5.10  
    5.11  DRIVERS = @VIDEO_DRIVERS@
     6.1 --- a/src/video/SDL_sysvideo.h	Thu Aug 01 23:08:41 2002 +0000
     6.2 +++ b/src/video/SDL_sysvideo.h	Thu Aug 01 23:24:13 2002 +0000
     6.3 @@ -401,6 +401,9 @@
     6.4  #ifdef ENABLE_QTOPIA
     6.5  extern VideoBootStrap Qtopia_bootstrap;
     6.6  #endif
     6.7 +#ifdef ENABLE_PICOGUI
     6.8 +extern VideoBootStrap PG_bootstrap;
     6.9 +#endif
    6.10  /* This is the current video device */
    6.11  extern SDL_VideoDevice *current_video;
    6.12  
     7.1 --- a/src/video/SDL_video.c	Thu Aug 01 23:08:41 2002 +0000
     7.2 +++ b/src/video/SDL_video.c	Thu Aug 01 23:24:13 2002 +0000
     7.3 @@ -114,6 +114,9 @@
     7.4  #ifdef ENABLE_QTOPIA
     7.5  	&Qtopia_bootstrap,
     7.6  #endif
     7.7 +#ifdef ENABLE_PICOGUI
     7.8 +	&PG_bootstrap,
     7.9 +#endif
    7.10  	NULL
    7.11  };
    7.12  
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/video/picogui/.cvsignore	Thu Aug 01 23:24:13 2002 +0000
     8.3 @@ -0,0 +1,6 @@
     8.4 +Makefile.in
     8.5 +Makefile
     8.6 +.libs
     8.7 +*.o
     8.8 +*.lo
     8.9 +*.la
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/video/picogui/Makefile.am	Thu Aug 01 23:24:13 2002 +0000
     9.3 @@ -0,0 +1,13 @@
     9.4 +
     9.5 +## Makefile.am for SDL using the PicoGUI video driver
     9.6 +
     9.7 +noinst_LTLIBRARIES = libvideo_picogui.la
     9.8 +libvideo_picogui_la_SOURCES = $(PICOGUI_SRCS)
     9.9 +
    9.10 +# The SDL PicoGUI video driver sources
    9.11 +PICOGUI_SRCS = 			\
    9.12 +	SDL_pgevents.c		\
    9.13 +	SDL_pgevents_c.h	\
    9.14 +	SDL_pgvideo.c		\
    9.15 +	SDL_pgvideo.h
    9.16 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/src/video/picogui/SDL_pgevents.c	Thu Aug 01 23:24:13 2002 +0000
    10.3 @@ -0,0 +1,121 @@
    10.4 +/*
    10.5 +    SDL - Simple DirectMedia Layer
    10.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
    10.7 +
    10.8 +    This library is free software; you can redistribute it and/or
    10.9 +    modify it under the terms of the GNU Library General Public
   10.10 +    License as published by the Free Software Foundation; either
   10.11 +    version 2 of the License, or (at your option) any later version.
   10.12 +
   10.13 +    This library is distributed in the hope that it will be useful,
   10.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   10.16 +    Library General Public License for more details.
   10.17 +
   10.18 +    You should have received a copy of the GNU Library General Public
   10.19 +    License along with this library; if not, write to the Free
   10.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   10.21 +
   10.22 +    Sam Lantinga
   10.23 +    slouken@libsdl.org
   10.24 +
   10.25 +    Micah Dowty
   10.26 +    micahjd@users.sourceforge.net
   10.27 +*/
   10.28 +
   10.29 +#ifdef SAVE_RCSID
   10.30 +static char rcsid =
   10.31 + "@(#) $Id$";
   10.32 +#endif
   10.33 +
   10.34 +#include "SDL.h"
   10.35 +#include "SDL_sysevents.h"
   10.36 +#include "SDL_events_c.h"
   10.37 +#include "SDL_pgvideo.h"
   10.38 +#include "SDL_pgevents_c.h"
   10.39 +
   10.40 +int PG_HandleClose(struct pgEvent *evt)
   10.41 +{
   10.42 +        SDL_PrivateQuit();
   10.43 +	return 1;               /* Intercept the event's normal quit handling */
   10.44 +}
   10.45 +
   10.46 +int PG_HandleResize(struct pgEvent *evt)
   10.47 +{
   10.48 +        SDL_PrivateResize(evt->e.size.w, evt->e.size.h);
   10.49 +	return 0;
   10.50 +}
   10.51 +
   10.52 +int PG_HandleKey(struct pgEvent *evt)
   10.53 +{
   10.54 +        SDL_keysym sym;
   10.55 +	memset(&sym,0,sizeof(sym));
   10.56 +	sym.sym = evt->e.kbd.key;
   10.57 +	sym.mod = evt->e.kbd.mods;
   10.58 +        SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym);
   10.59 +	return 0;
   10.60 +}
   10.61 +
   10.62 +int PG_HandleChar(struct pgEvent *evt)
   10.63 +{
   10.64 +        SDL_keysym sym;
   10.65 +	memset(&sym,0,sizeof(sym));
   10.66 +	sym.unicode = evt->e.kbd.key;
   10.67 +	sym.mod = evt->e.kbd.mods;
   10.68 +        SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym);
   10.69 +	return 0;
   10.70 +}
   10.71 +
   10.72 +int PG_HandleMouseButton(struct pgEvent *evt)
   10.73 +{        
   10.74 +        /* We need to focus the canvas when it's clicked */
   10.75 +        if (evt->extra) {
   10.76 +	        SDL_VideoDevice *this = (SDL_VideoDevice *) evt->extra;
   10.77 +		pgFocus(this->hidden->wCanvas);
   10.78 +	}
   10.79 +        SDL_PrivateMouseButton(evt->type == PG_WE_PNTR_DOWN, evt->e.pntr.chbtn,
   10.80 +			       evt->e.pntr.x, evt->e.pntr.y);
   10.81 +	return 0;
   10.82 +}
   10.83 +
   10.84 +int PG_HandleMouseMotion(struct pgEvent *evt)
   10.85 +{
   10.86 +        SDL_PrivateMouseMotion(evt->e.pntr.btn,0,evt->e.pntr.x, evt->e.pntr.y);
   10.87 +	return 0;
   10.88 +}
   10.89 +
   10.90 +void PG_PumpEvents(_THIS)
   10.91 +{
   10.92 +        /* Process all pending events */
   10.93 +        pgEventPoll();
   10.94 +}
   10.95 +
   10.96 +void PG_InitOSKeymap(_THIS)
   10.97 +{
   10.98 +        /* We need no keymap */
   10.99 +}
  10.100 +
  10.101 +void PG_InitEvents(_THIS)
  10.102 +{
  10.103 +        /* Turn on all the mouse and keyboard triggers for our canvas, normally less important
  10.104 +	 * events like mouse movement are ignored to save bandwidth. */
  10.105 +        pgSetWidget(this->hidden->wCanvas, PG_WP_TRIGGERMASK, 
  10.106 +		    pgGetWidget(this->hidden->wCanvas, PG_WP_TRIGGERMASK) |
  10.107 +		    PG_TRIGGER_UP | PG_TRIGGER_DOWN | PG_TRIGGER_MOVE |
  10.108 +		    PG_TRIGGER_KEYUP | PG_TRIGGER_KEYDOWN | PG_TRIGGER_CHAR,0);
  10.109 +
  10.110 +	/* Start our canvas out focused, so we get keyboard input */
  10.111 +	pgFocus(this->hidden->wCanvas);
  10.112 +
  10.113 +        /* Set up bindings for all the above event handlers */
  10.114 +        pgBind(this->hidden->wApp,    PG_WE_CLOSE, &PG_HandleClose, NULL);
  10.115 +        pgBind(this->hidden->wCanvas, PG_WE_BUILD, &PG_HandleResize, NULL);
  10.116 +        pgBind(this->hidden->wCanvas, PG_WE_KBD_CHAR, &PG_HandleChar, NULL);
  10.117 +        pgBind(this->hidden->wCanvas, PG_WE_KBD_KEYUP, &PG_HandleKey, NULL);
  10.118 +        pgBind(this->hidden->wCanvas, PG_WE_KBD_KEYDOWN, &PG_HandleKey, NULL);
  10.119 +        pgBind(this->hidden->wCanvas, PG_WE_PNTR_MOVE, &PG_HandleMouseMotion, NULL);
  10.120 +        pgBind(this->hidden->wCanvas, PG_WE_PNTR_UP, &PG_HandleMouseButton, NULL);
  10.121 +        pgBind(this->hidden->wCanvas, PG_WE_PNTR_DOWN, &PG_HandleMouseButton, this);
  10.122 +}
  10.123 +
  10.124 +/* end of SDL_pgevents.c ... */
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/video/picogui/SDL_pgevents_c.h	Thu Aug 01 23:24:13 2002 +0000
    11.3 @@ -0,0 +1,41 @@
    11.4 +/*
    11.5 +    SDL - Simple DirectMedia Layer
    11.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
    11.7 +
    11.8 +    This library is free software; you can redistribute it and/or
    11.9 +    modify it under the terms of the GNU Library General Public
   11.10 +    License as published by the Free Software Foundation; either
   11.11 +    version 2 of the License, or (at your option) any later version.
   11.12 +
   11.13 +    This library is distributed in the hope that it will be useful,
   11.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   11.16 +    Library General Public License for more details.
   11.17 +
   11.18 +    You should have received a copy of the GNU Library General Public
   11.19 +    License along with this library; if not, write to the Free
   11.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   11.21 +
   11.22 +    Sam Lantinga
   11.23 +    slouken@libsdl.org
   11.24 +
   11.25 +    Micah Dowty
   11.26 +    micahjd@users.sourceforge.net
   11.27 +*/
   11.28 +
   11.29 +#ifdef SAVE_RCSID
   11.30 +static char rcsid =
   11.31 + "@(#) $Id$";
   11.32 +#endif
   11.33 +
   11.34 +#include "SDL_pgvideo.h"
   11.35 +
   11.36 +/* Variables and functions exported by SDL_sysevents.c to other parts 
   11.37 +   of the native video subsystem (SDL_sysvideo.c)
   11.38 +*/
   11.39 +extern void PG_PumpEvents(_THIS);
   11.40 +extern void PG_InitEvents(_THIS);
   11.41 +extern void PG_InitOSKeymap(_THIS);
   11.42 +
   11.43 +/* end of SDL_pgevents_c.h ... */
   11.44 +
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/video/picogui/SDL_pgvideo.c	Thu Aug 01 23:24:13 2002 +0000
    12.3 @@ -0,0 +1,370 @@
    12.4 +/*
    12.5 +    SDL - Simple DirectMedia Layer
    12.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
    12.7 +
    12.8 +    This library is free software; you can redistribute it and/or
    12.9 +    modify it under the terms of the GNU Library General Public
   12.10 +    License as published by the Free Software Foundation; either
   12.11 +    version 2 of the License, or (at your option) any later version.
   12.12 +
   12.13 +    This library is distributed in the hope that it will be useful,
   12.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.16 +    Library General Public License for more details.
   12.17 +
   12.18 +    You should have received a copy of the GNU Library General Public
   12.19 +    License along with this library; if not, write to the Free
   12.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   12.21 +
   12.22 +    Sam Lantinga
   12.23 +    slouken@libsdl.org
   12.24 +
   12.25 +    Micah Dowty
   12.26 +    micahjd@users.sourceforge.net
   12.27 +*/
   12.28 +
   12.29 +#ifdef SAVE_RCSID
   12.30 +static char rcsid =
   12.31 + "@(#) $Id$";
   12.32 +#endif
   12.33 +
   12.34 +#include <stdio.h>
   12.35 +#include <stdlib.h>
   12.36 +#include <string.h>
   12.37 +
   12.38 +#include "SDL.h"
   12.39 +#include "SDL_error.h"
   12.40 +#include "SDL_video.h"
   12.41 +#include "SDL_mouse.h"
   12.42 +#include "SDL_sysvideo.h"
   12.43 +#include "SDL_pixels_c.h"
   12.44 +#include "SDL_events_c.h"
   12.45 +
   12.46 +#include "SDL_pgvideo.h"
   12.47 +#include "SDL_pgevents_c.h"
   12.48 +
   12.49 +#define PGVID_DRIVER_NAME "picogui"
   12.50 +
   12.51 +/* Initialization/Query functions */
   12.52 +static int PG_VideoInit(_THIS, SDL_PixelFormat *vformat);
   12.53 +static SDL_Rect **PG_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
   12.54 +static SDL_Surface *PG_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
   12.55 +static int PG_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
   12.56 +static void PG_VideoQuit(_THIS);
   12.57 +
   12.58 +/* Hardware surface functions */
   12.59 +static int PG_AllocHWSurface(_THIS, SDL_Surface *surface);
   12.60 +static int PG_LockHWSurface(_THIS, SDL_Surface *surface);
   12.61 +static void PG_UnlockHWSurface(_THIS, SDL_Surface *surface);
   12.62 +static void PG_FreeHWSurface(_THIS, SDL_Surface *surface);
   12.63 +
   12.64 +/* etc. */
   12.65 +static void PG_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
   12.66 +
   12.67 +// The implementation dependent data for the window manager cursor
   12.68 +struct WMcursor {
   12.69 +  /* Our cursor is a PicoGUI theme */
   12.70 +  pghandle theme;
   12.71 +} ;
   12.72 +
   12.73 +/* WM functions */
   12.74 +void PG_SetCaption(_THIS, const char *title, const char *icon);
   12.75 +WMcursor * PG_CreateWMCursor (_THIS,Uint8 * data, Uint8 * mask, 
   12.76 +			      int w, int h, int hot_x, int hot_y);
   12.77 +void PG_FreeWMCursor (_THIS, WMcursor * cursor);
   12.78 +void PG_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
   12.79 +int PG_ShowWMCursor (_THIS, WMcursor * cursor);
   12.80 +
   12.81 +/* PicoGUI driver bootstrap functions */
   12.82 +
   12.83 +static int PG_Available(void)
   12.84 +{
   12.85 +        /* FIXME: The current client lib doesn't give a way to see if the picogui
   12.86 +	 *        server is reachable without causing a fatal error if it isn't.
   12.87 +	 *        This should be fixed in cli_c2, but until then assume we can
   12.88 +	 *        connect. Since more common drivers like X11 are probed first anyway,
   12.89 +	 *        this shouldn't be a huge problem.
   12.90 +	 */
   12.91 +	return(1);
   12.92 +}
   12.93 +
   12.94 +static void PG_DeleteDevice(SDL_VideoDevice *device)
   12.95 +{
   12.96 +	free(device->hidden);
   12.97 +	free(device);
   12.98 +}
   12.99 +
  12.100 +static SDL_VideoDevice *PG_CreateDevice(int devindex)
  12.101 +{
  12.102 +	SDL_VideoDevice *device;
  12.103 +
  12.104 +	/* Initialize all variables that we clean on shutdown */
  12.105 +	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
  12.106 +	if ( device ) {
  12.107 +		memset(device, 0, (sizeof *device));
  12.108 +		device->hidden = (struct SDL_PrivateVideoData *)
  12.109 +				malloc((sizeof *device->hidden));
  12.110 +	}
  12.111 +	if ( (device == NULL) || (device->hidden == NULL) ) {
  12.112 +		SDL_OutOfMemory();
  12.113 +		if ( device ) {
  12.114 +			free(device);
  12.115 +		}
  12.116 +		return(0);
  12.117 +	}
  12.118 +	memset(device->hidden, 0, (sizeof *device->hidden));
  12.119 +
  12.120 +	/* Set the function pointers */
  12.121 +	device->VideoInit = PG_VideoInit;
  12.122 +	device->ListModes = PG_ListModes;
  12.123 +	device->SetVideoMode = PG_SetVideoMode;
  12.124 +	device->CreateYUVOverlay = NULL;
  12.125 +	device->SetColors = PG_SetColors;
  12.126 +	device->UpdateRects = PG_UpdateRects;
  12.127 +	device->VideoQuit = PG_VideoQuit;
  12.128 +	device->AllocHWSurface = PG_AllocHWSurface;
  12.129 +	device->CheckHWBlit = NULL;
  12.130 +	device->FillHWRect = NULL;
  12.131 +	device->SetHWColorKey = NULL;
  12.132 +	device->SetHWAlpha = NULL;
  12.133 +	device->LockHWSurface = PG_LockHWSurface;
  12.134 +	device->UnlockHWSurface = PG_UnlockHWSurface;
  12.135 +	device->FlipHWSurface = NULL;
  12.136 +	device->FreeHWSurface = PG_FreeHWSurface;
  12.137 +	device->SetCaption = PG_SetCaption;
  12.138 +	device->SetIcon = NULL;
  12.139 +	device->IconifyWindow = NULL;
  12.140 +	device->GrabInput = NULL;
  12.141 +
  12.142 +	device->PumpEvents = PG_PumpEvents;
  12.143 +	device->InitOSKeymap = PG_InitOSKeymap;
  12.144 +
  12.145 +	device->ShowWMCursor = PG_ShowWMCursor;
  12.146 +	device->CreateWMCursor = PG_CreateWMCursor;
  12.147 +	device->FreeWMCursor = PG_FreeWMCursor;
  12.148 +	device->WarpWMCursor = PG_WarpWMCursor;
  12.149 +
  12.150 +	device->free = PG_DeleteDevice;
  12.151 +
  12.152 +	return device;
  12.153 +}
  12.154 +
  12.155 +VideoBootStrap PG_bootstrap = {
  12.156 +	PGVID_DRIVER_NAME, "PicoGUI SDL driver",
  12.157 +	PG_Available, PG_CreateDevice
  12.158 +};
  12.159 +
  12.160 +
  12.161 +int PG_VideoInit(_THIS, SDL_PixelFormat *vformat)
  12.162 +{
  12.163 +        /* Connect to the PicoGUI server. No way to process command line args yet,
  12.164 +	 * but since this is based on SHM it's not important to be able to specify
  12.165 +	 * a remote PicoGUI server.
  12.166 +	 *
  12.167 +	 * FIXME: Another nitpick about the current client lib is there's no
  12.168 +	 *        clean way to indicate that command line args are not available.
  12.169 +	 */
  12.170 +        pgInit(0,(char**)"");
  12.171 +	this->hidden->mi = *pgGetVideoMode();
  12.172 +
  12.173 +	/* Create a picogui application and canvas. We'll populate the canvas later. */
  12.174 +	this->hidden->wApp = pgRegisterApp(PG_APP_NORMAL,"SDL",0);
  12.175 +	this->hidden->wCanvas = pgNewWidget(PG_WIDGET_CANVAS,0,0);
  12.176 +	pgSetWidget(PGDEFAULT,
  12.177 +		    PG_WP_SIDE, PG_S_ALL,
  12.178 +		    0);
  12.179 +
  12.180 +	PG_InitEvents(this);
  12.181 +
  12.182 +	/* Determine the screen depth.
  12.183 +	 * We change this during the SDL_SetVideoMode implementation... 
  12.184 +	 * Round up to the nearest Bytes per pixel
  12.185 +	 */
  12.186 +	vformat->BitsPerPixel = this->hidden->mi.bpp;
  12.187 +	vformat->BytesPerPixel = this->hidden->mi.bpp >> 3;
  12.188 +	if (this->hidden->mi.bpp & 7)
  12.189 +	  vformat->BytesPerPixel++;
  12.190 +
  12.191 +	/* We're done! */
  12.192 +	return(0);
  12.193 +}
  12.194 +
  12.195 +SDL_Rect **PG_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
  12.196 +{
  12.197 +   	 return (SDL_Rect **) -1;
  12.198 +}
  12.199 +
  12.200 +SDL_Surface *PG_SetVideoMode(_THIS, SDL_Surface *current,
  12.201 +				int width, int height, int bpp, Uint32 flags)
  12.202 +{
  12.203 +	if ( this->hidden->bitmap ) {
  12.204 +	  /* Free old bitmap */
  12.205 +	  if (current->pixels) {
  12.206 +	    shmdt(current->pixels);
  12.207 +	    current->pixels = NULL;
  12.208 +	  }
  12.209 +	  pgDelete(this->hidden->bitmap);
  12.210 +	}
  12.211 +
  12.212 +	/* Allocate the new pixel format for the screen */
  12.213 +	if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
  12.214 +		SDL_SetError("Couldn't allocate new pixel format for requested mode");
  12.215 +		return(NULL);
  12.216 +	}
  12.217 +
  12.218 +	/* Create a new picogui bitmap */
  12.219 +	this->hidden->bitmap = pgCreateBitmap(width,height);
  12.220 +	this->hidden->shm = *pgMakeSHMBitmap(this->hidden->bitmap);
  12.221 +	current->pixels = shmat(shmget(this->hidden->shm.shm_key,
  12.222 +				       this->hidden->shm.shm_length,0),NULL,0);
  12.223 +
  12.224 +	/* Reset the canvas, and draw persistent and incremental grops.
  12.225 +	 * Use mapping and offsets to center it.
  12.226 +	 */
  12.227 +
  12.228 +	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_NUKE, 0);
  12.229 +
  12.230 +	/* 0. Set the source position during incremental rendering
  12.231 +	 */
  12.232 +	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 5, PG_GROP_SETSRC,0,0,0,0);
  12.233 +	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, PG_GROPF_INCREMENTAL);
  12.234 +
  12.235 +	/* 1. Incremental bitmap rendering
  12.236 +	 */
  12.237 +	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP,
  12.238 +		   0,0,0,0,this->hidden->bitmap);
  12.239 +	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, PG_GROPF_INCREMENTAL);
  12.240 +
  12.241 +	/* 2. Normal bitmap rendering
  12.242 +	 */
  12.243 +	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP,
  12.244 +		   0,0,this->hidden->shm.width,this->hidden->shm.height,this->hidden->bitmap);
  12.245 +     
  12.246 +	/* Set up the new mode framebuffer */
  12.247 +	current->flags = 0;
  12.248 +	current->w = this->hidden->shm.width;
  12.249 +	current->h = this->hidden->shm.height;
  12.250 +	current->pitch = this->hidden->shm.pitch;
  12.251 +
  12.252 +	/* Set up pixel format */
  12.253 +	current->format->BitsPerPixel = this->hidden->shm.bpp;
  12.254 +	current->format->BytesPerPixel = this->hidden->shm.bpp >> 3;
  12.255 +	if (this->hidden->shm.bpp & 7)
  12.256 +	  current->format->BytesPerPixel++;
  12.257 +	current->format->palette = NULL;
  12.258 +	current->format->Rmask = this->hidden->shm.red_mask;
  12.259 +	current->format->Gmask = this->hidden->shm.green_mask;
  12.260 +	current->format->Bmask = this->hidden->shm.blue_mask;
  12.261 +	current->format->Amask = this->hidden->shm.alpha_mask;
  12.262 +	current->format->Rshift = this->hidden->shm.red_shift;
  12.263 +	current->format->Gshift = this->hidden->shm.green_shift;
  12.264 +	current->format->Bshift = this->hidden->shm.blue_shift;
  12.265 +	current->format->Ashift = this->hidden->shm.alpha_shift;
  12.266 +	current->format->Rloss = 8 - this->hidden->shm.red_length;
  12.267 +	current->format->Gloss = 8 - this->hidden->shm.green_length;
  12.268 +	current->format->Bloss = 8 - this->hidden->shm.blue_length;
  12.269 +	current->format->Aloss = 8 - this->hidden->shm.alpha_length;
  12.270 +
  12.271 +	/* Draw the app */
  12.272 +	pgUpdate();
  12.273 +
  12.274 +	/* We're done */
  12.275 +	return(current);
  12.276 +}
  12.277 +
  12.278 +/* We don't actually allow hardware surfaces other than the main one */
  12.279 +static int PG_AllocHWSurface(_THIS, SDL_Surface *surface)
  12.280 +{
  12.281 +	return(-1);
  12.282 +}
  12.283 +static void PG_FreeHWSurface(_THIS, SDL_Surface *surface)
  12.284 +{
  12.285 +	return;
  12.286 +}
  12.287 +
  12.288 +/* We need to wait for vertical retrace on page flipped displays */
  12.289 +static int PG_LockHWSurface(_THIS, SDL_Surface *surface)
  12.290 +{
  12.291 +	return(0);
  12.292 +}
  12.293 +
  12.294 +static void PG_UnlockHWSurface(_THIS, SDL_Surface *surface)
  12.295 +{
  12.296 +	return;
  12.297 +}
  12.298 +
  12.299 +static void PG_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
  12.300 +{
  12.301 +        int i;
  12.302 +	
  12.303 +	for (i = 0; i < numrects; i++) {
  12.304 +	        if (rects[i].w <= 0 || rects[i].h <= 0)
  12.305 +		  continue;
  12.306 +
  12.307 +		/* Schedule an incremental update for this rectangle, using
  12.308 +		 * the canvas gropnodes we've loaded beforehand.
  12.309 +		 */
  12.310 +		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 0);
  12.311 +		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, 
  12.312 +			   rects[i].x, rects[i].y,
  12.313 +			   rects[i].w, rects[i].h);
  12.314 +		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 1);
  12.315 +		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, 
  12.316 +			   rects[i].x, rects[i].y,
  12.317 +			   rects[i].w, rects[i].h);
  12.318 +		
  12.319 +		/* Go perform the update */
  12.320 +		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_INCREMENTAL, 0);
  12.321 +		pgSubUpdate(this->hidden->wCanvas);
  12.322 +	}
  12.323 +}
  12.324 +
  12.325 +int PG_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
  12.326 +{
  12.327 +	/* do nothing of note. */
  12.328 +	return(1);
  12.329 +}
  12.330 +
  12.331 +/* Note:  If we are terminated, this could be called in the middle of
  12.332 +   another SDL video routine -- notably UpdateRects.
  12.333 +*/
  12.334 +void PG_VideoQuit(_THIS)
  12.335 +{
  12.336 +	if (this->screen->pixels != NULL)
  12.337 +	{
  12.338 +		shmdt(this->screen->pixels);
  12.339 +		this->screen->pixels = NULL;
  12.340 +		pgDelete(this->hidden->bitmap);
  12.341 +	}
  12.342 +	pgDelete(this->hidden->wCanvas);
  12.343 +	pgDelete(this->hidden->wApp);
  12.344 +}
  12.345 +
  12.346 +void PG_SetCaption(_THIS, const char *title, const char *icon)
  12.347 +{
  12.348 +        if (title != NULL)
  12.349 +	  pgReplaceText(this->hidden->wApp, title);
  12.350 +	pgUpdate();
  12.351 +}
  12.352 +
  12.353 +/* FIXME: The cursor stuff isn't implemented yet! */
  12.354 +
  12.355 +WMcursor * PG_CreateWMCursor (_THIS,Uint8 * data, Uint8 * mask, 
  12.356 +			      int w, int h, int hot_x, int hot_y)
  12.357 +{
  12.358 +        static WMcursor dummy;
  12.359 +        return &dummy;
  12.360 +}
  12.361 +
  12.362 +void PG_FreeWMCursor (_THIS, WMcursor * cursor)
  12.363 +{
  12.364 +}
  12.365 +
  12.366 +void PG_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
  12.367 +{
  12.368 +}
  12.369 +
  12.370 +int PG_ShowWMCursor (_THIS, WMcursor * cursor)
  12.371 +{
  12.372 +        return 1;
  12.373 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/video/picogui/SDL_pgvideo.h	Thu Aug 01 23:24:13 2002 +0000
    13.3 @@ -0,0 +1,54 @@
    13.4 +/*
    13.5 +    SDL - Simple DirectMedia Layer
    13.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
    13.7 +
    13.8 +    This library is free software; you can redistribute it and/or
    13.9 +    modify it under the terms of the GNU Library General Public
   13.10 +    License as published by the Free Software Foundation; either
   13.11 +    version 2 of the License, or (at your option) any later version.
   13.12 +
   13.13 +    This library is distributed in the hope that it will be useful,
   13.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.16 +    Library General Public License for more details.
   13.17 +
   13.18 +    You should have received a copy of the GNU Library General Public
   13.19 +    License along with this library; if not, write to the Free
   13.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   13.21 +
   13.22 +    Sam Lantinga
   13.23 +    slouken@libsdl.org
   13.24 +
   13.25 +    Micah Dowty
   13.26 +    micahjd@users.sourceforge.net
   13.27 +*/
   13.28 +
   13.29 +#ifdef SAVE_RCSID
   13.30 +static char rcsid =
   13.31 + "@(#) $Id$";
   13.32 +#endif
   13.33 +
   13.34 +#ifndef _SDL_pgvideo_h
   13.35 +#define _SDL_pgvideo_h
   13.36 +
   13.37 +#include "SDL_mouse.h"
   13.38 +#include "SDL_sysvideo.h"
   13.39 +#include "SDL_mutex.h"
   13.40 +
   13.41 +#include <picogui.h>
   13.42 +#include <sys/shm.h>
   13.43 +
   13.44 +/* Hidden "this" pointer for the video functions */
   13.45 +#define _THIS	SDL_VideoDevice *this
   13.46 +
   13.47 +
   13.48 +/* Private display data */
   13.49 +
   13.50 +struct SDL_PrivateVideoData {
   13.51 +  pghandle wApp, wCanvas;        /* PicoGUI widgets */
   13.52 +  pghandle bitmap;
   13.53 +  struct pgshmbitmap shm;        /* shared memory info */
   13.54 +  struct pgmodeinfo mi;          /* PicoGUI video mode info structure */
   13.55 +};
   13.56 +
   13.57 +#endif /* _SDL_pgvideo_h */