Nobody is currently maintaining the QNX code, so removing it for now.
authorSam Lantinga <slouken@libsdl.org>
Tue, 01 Feb 2011 21:40:03 -0800
changeset 51501435f8a6425c
parent 5149 be02be2ea897
child 5151 8ef640410ac9
Nobody is currently maintaining the QNX code, so removing it for now.
README
README.Platforms
README.QNX
configure.in
include/SDL.h
include/SDL_config.h.in
src/video/SDL_renderer_gl.c
src/video/SDL_renderer_gles.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/photon/SDL_photon.c
src/video/photon/SDL_photon.h
src/video/photon/SDL_photon_input.c
src/video/photon/SDL_photon_input.h
src/video/photon/SDL_photon_keycodes.h
src/video/photon/SDL_photon_pixelfmt.c
src/video/photon/SDL_photon_pixelfmt.h
src/video/photon/SDL_photon_render.c
src/video/photon/SDL_photon_render.h
src/video/qnxgf/SDL_gf_input.c
src/video/qnxgf/SDL_gf_input.h
src/video/qnxgf/SDL_gf_opengles.c
src/video/qnxgf/SDL_gf_opengles.h
src/video/qnxgf/SDL_gf_pixelfmt.c
src/video/qnxgf/SDL_gf_pixelfmt.h
src/video/qnxgf/SDL_gf_render.c
src/video/qnxgf/SDL_gf_render.h
src/video/qnxgf/SDL_hiddi_joystick.h
src/video/qnxgf/SDL_hiddi_keyboard.h
src/video/qnxgf/SDL_hiddi_mouse.h
src/video/qnxgf/SDL_qnxgf.c
src/video/qnxgf/SDL_qnxgf.h
test/testdyngles.c
test/testime.c
     1.1 --- a/README	Tue Feb 01 21:23:43 2011 -0800
     1.2 +++ b/README	Tue Feb 01 21:40:03 2011 -0800
     1.3 @@ -13,7 +13,7 @@
     1.4  and 2D framebuffer across multiple platforms.
     1.5  
     1.6  The current version supports Windows, Windows CE, Mac OS X, Linux, FreeBSD,
     1.7 -NetBSD, OpenBSD, BSD/OS, Solaris, QNX, iOS, and Android. The code contains
     1.8 +NetBSD, OpenBSD, BSD/OS, Solaris, iOS, and Android. The code contains
     1.9  support for other operating systems but those are not officially supported.
    1.10  
    1.11  SDL is written in C, but works with C++ natively, and has bindings to
     2.1 --- a/README.Platforms	Tue Feb 01 21:23:43 2011 -0800
     2.2 +++ b/README.Platforms	Tue Feb 01 21:40:03 2011 -0800
     2.3 @@ -30,5 +30,4 @@
     2.4  Platforms that need maintainers
     2.5  ===============================
     2.6  Nintendo DS
     2.7 -QNX
     2.8  Haiku
     3.1 --- a/README.QNX	Tue Feb 01 21:23:43 2011 -0800
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,108 +0,0 @@
     3.4 -README.QNX by Mike Gorchak <mike@malva.ua>, <lestat@i.com.ua>
     3.5 -Last changed at 10 Jun 2009.
     3.6 -
     3.7 -QNX Photon and GF drivers are being constructed, OpenGL ES support is
     3.8 -    finished.  Still no 2D renderer support in GF and Photon drivers.
     3.9 -QNX QSA (QNX Sound Architecture) driver is ready.
    3.10 -QNX HID input driver is finished.
    3.11 -
    3.12 -----------------------
    3.13 - -- SDL QSA driver --
    3.14 -----------------------
    3.15 -
    3.16 -   Due to QNX Sound Architecture limitations software could  not  determine
    3.17 -what playback channels are designed for, so some casus can be. For example,
    3.18 -output after testmultiaudio test utility execution:
    3.19 -
    3.20 -Using audio driver: qsa
    3.21 -playing on device #0: ('Vortex 8820 @ fb000000 d0')...done.
    3.22 -playing on device #1: ('Vortex 8820 @ fb000000 d1')...done.
    3.23 -playing on device #2: ('i8x0 @ d800 d0')...done.
    3.24 -playing on device #3: ('i8x0 @ d800 d1')...done.
    3.25 -playing on all devices...
    3.26 -Open device 3 failed: QSA: snd_pcm_channel_params failed: Invalid argument
    3.27 -
    3.28 -If  speakers  are  connected  to  both  audio  cards: Vortex 8820 and Intel
    3.29 -Integrated Audio we can hear sound playback on device #0 and devices #2, #3
    3.30 -only. Device #1 is an unknown PCM channel which does not produce any sound.
    3.31 -
    3.32 -As for error during device #3 opening, it's caused  by QSA  software  mixer
    3.33 -channel, because  it can't open real hardware device #2, since it's already
    3.34 -opened by SDL.
    3.35 -
    3.36 -After simultaneous sound playback  on  all  devices  utility testmultiaudio
    3.37 -stays running waiting for  sound playback  finish  on  device #1,  which is
    3.38 -locked up due to some Aureal Vortex 8820 driver limitations.
    3.39 -
    3.40 ----------------------
    3.41 - -- SDL GF driver --
    3.42 ----------------------
    3.43 -
    3.44 -Here is an additional information about SDL GF driver:
    3.45 - * 0. Introduction.
    3.46 - * 1. Environment variables which SDL GF driver supports.
    3.47 - * 2. Custom video modes.
    3.48 - * 3. Limitations.
    3.49 -
    3.50 -0. Introduction.
    3.51 -
    3.52 -   SDL GF driver is a layer between  SDL  and  QNX Graphics Framework (GF).
    3.53 -SDL GF driver also supports OpenGL ES  through the  QNX Graphics Framework.
    3.54 -Hardware accelerated features which SDL can support depend on real hardware
    3.55 -capabilities.
    3.56 -
    3.57 -1. Environment variables which GF driver supports.
    3.58 -
    3.59 -   GF  driver  supports  the  following  environment  variables for  QNX GF
    3.60 -specific customization options:
    3.61 -   a) SDL_VIDEO_GF_REFRESH_RATE - refresh  rate  of  video  output  in  Hz.
    3.62 -      Without this environment variable declaration  SDL  controls  refresh
    3.63 -      rate of your display.  If this enironment  variable is set  to 0, SDL
    3.64 -      will control  refresh  rate  of  display,  otherwise  value  of  flag
    3.65 -      SDL_VIDEO_GF_REFRESH_RATE  is  used  for  all  screen  resolutions as
    3.66 -      refresh rate. This example will set 60Hz refresh rate as refresh rate
    3.67 -      for all graphics modes:
    3.68 -
    3.69 -      export SDL_VIDEO_GF_REFRESH_RATE=60
    3.70 -
    3.71 -2. Custom video modes.
    3.72 -
    3.73 -   Since most QNX graphics drivers support GENERIC  video  modes, i.e.  you
    3.74 -can specify any horizontal and vertical resolution and  any  refresh  rate,
    3.75 -SDL GF driver uses its own fullscreen modes list, which can be  incomplete.
    3.76 -You can add any custom video mode, which your QNX graphics driver  supports
    3.77 -by  editing  file  ./src/video/qnxgf/SDL_qnxgf.c.   Custom   graphics  mode
    3.78 -definition looks like this:
    3.79 -
    3.80 -   {0, 1024, 640, 60, NULL},   /* 1024x640 mode is 60Hz only             */
    3.81 -
    3.82 -You must specify horizontal resolution as  the  second  parameter, vertical
    3.83 -resolution as the third one and  refresh  rate  as  the  fourth  parameter.
    3.84 -Please leave the first and the last parameters as 0 and NULL.  Then send me
    3.85 -your changes to e-mail address which is specified in  the  header  of  this
    3.86 -document.
    3.87 -
    3.88 -3. Limitations.
    3.89 -
    3.90 -   There are few limitations while using SDL GF driver:
    3.91 -
    3.92 -   a) Since  GF   driver   supports   fullscreen  modes  only,   when  flag
    3.93 -SDL_WINDOW_FULLSCREEN is not specified, SDL GF driver will try to find  the
    3.94 -fullscreen graphics mode which corresponds to SDL window size. Refresh rate
    3.95 -will be the  lowest  available,  if  SDL_VIDEO_GF_REFRESH_RATE  environment
    3.96 -variable is not set.
    3.97 -   b) As confirmed by QSSL none of existing video  drivers  has  support of
    3.98 -doublescan low-resolution video modes.  So  modes  below  640x480  are  not
    3.99 -supported. If your video driver supports low-resolution video modes, please
   3.100 -add SDL_GF_LOWRESOLUTION flag to the gf_devicename array in the SDL_qnxgf.c
   3.101 -source file.
   3.102 -   c) Since  GF  framework supports hardware mouse cursor only,  you'll get
   3.103 -hardware mouse cursor in case of specific graphics driver supports it.
   3.104 -
   3.105 --------------------------
   3.106 - -- SDL Photon driver --
   3.107 --------------------------
   3.108 -
   3.109 -----------------------------
   3.110 - -- SDL HID input driver --
   3.111 -----------------------------
     4.1 --- a/configure.in	Tue Feb 01 21:23:43 2011 -0800
     4.2 +++ b/configure.in	Tue Feb 01 21:40:03 2011 -0800
     4.3 @@ -1326,70 +1326,6 @@
     4.4      fi
     4.5  }
     4.6  
     4.7 -dnl Check for QNX photon video driver
     4.8 -CheckPHOTON()
     4.9 -{
    4.10 -    AC_ARG_ENABLE(video-photon,
    4.11 -AC_HELP_STRING([--enable-video-photon], [use QNX Photon video driver [[default=yes]]]),
    4.12 -                  , enable_video_photon=yes)
    4.13 -    if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
    4.14 -        AC_MSG_CHECKING(for QNX Photon support)
    4.15 -        video_photon=no
    4.16 -        AC_TRY_COMPILE([
    4.17 -          #include <Ph.h>
    4.18 -          #include <Pt.h>
    4.19 -          #include <photon/Pg.h>
    4.20 -          #include <photon/PdDirect.h>
    4.21 -        ],[
    4.22 -         PgDisplaySettings_t *visual;
    4.23 -        ],[
    4.24 -        video_photon=yes
    4.25 -        ])
    4.26 -        AC_MSG_RESULT($video_photon)
    4.27 -        if test x$video_photon = xyes; then
    4.28 -            AC_DEFINE(SDL_VIDEO_DRIVER_PHOTON)
    4.29 -            SOURCES="$SOURCES $srcdir/src/video/photon/*.c"
    4.30 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lph -lphrender"
    4.31 -            have_video=yes
    4.32 -
    4.33 -            CheckOpenGLQNX
    4.34 -        fi
    4.35 -    fi
    4.36 -}
    4.37 -
    4.38 -dnl Check for QNX photon video driver
    4.39 -CheckQNXGF()
    4.40 -{
    4.41 -    AC_ARG_ENABLE(video-qnxgf,
    4.42 -                  AC_HELP_STRING([--enable-video-qnxgf], [use QNX GF video driver [[default=yes]]]),
    4.43 -                  , enable_video_qnxgf=yes)
    4.44 -    if test x$enable_video = xyes -a x$enable_video_qnxgf = xyes; then
    4.45 -        AC_MSG_CHECKING(for QNX GF support)
    4.46 -        video_qnxgf=no
    4.47 -        AC_TRY_COMPILE([
    4.48 -          #include <gf/gf.h>
    4.49 -          #include <gf/gf3d.h>
    4.50 -        ],[
    4.51 -         gf_3d_config_info_t* gfinfo;
    4.52 -        ],[
    4.53 -        video_qnxgf=yes
    4.54 -        ])
    4.55 -        AC_MSG_RESULT($video_qnxgf)
    4.56 -        if test x$video_qnxgf = xyes; then
    4.57 -            AC_DEFINE(SDL_VIDEO_DRIVER_QNXGF)
    4.58 -            SOURCES="$SOURCES $srcdir/src/video/qnxgf/*.c"
    4.59 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lgf"
    4.60 -
    4.61 -            # Add HIDDI library for HID support using GF
    4.62 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lhiddi"
    4.63 -
    4.64 -            have_video=yes
    4.65 -
    4.66 -            CheckOpenGLESQNX
    4.67 -        fi
    4.68 -    fi
    4.69 -}
    4.70 -
    4.71  dnl Set up the BWindow video driver if enabled
    4.72  CheckBWINDOW()
    4.73  {
    4.74 @@ -1594,65 +1530,6 @@
    4.75      fi
    4.76  }
    4.77  
    4.78 -dnl Find QNX 6.x Software OpenGL
    4.79 -CheckOpenGLQNX()
    4.80 -{
    4.81 -    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
    4.82 -        AC_MSG_CHECKING(for QNX 6.x Photon OpenGL support)
    4.83 -        video_opengl=no
    4.84 -        AC_TRY_COMPILE([
    4.85 -         #include <GL/gl.h>
    4.86 -        ],[
    4.87 -        ],[
    4.88 -        video_opengl=yes
    4.89 -        ])
    4.90 -        AC_MSG_RESULT($video_opengl)
    4.91 -        if test x$video_opengl = xyes; then
    4.92 -            AC_DEFINE(SDL_VIDEO_OPENGL)
    4.93 -            AC_DEFINE(SDL_VIDEO_RENDER_OGL)
    4.94 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
    4.95 -        fi
    4.96 -    fi
    4.97 -}
    4.98 -
    4.99 -dnl Find QNX 6.3 and above OpenGL ES implementation
   4.100 -CheckOpenGLESQNX()
   4.101 -{
   4.102 -    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
   4.103 -        AC_MSG_CHECKING(for QNX OpenGL ES (CM) support)
   4.104 -        video_opengl=no
   4.105 -        AC_TRY_COMPILE([
   4.106 -         #include <GLES/egl.h>
   4.107 -        ],[
   4.108 -        ],[
   4.109 -        video_opengl=yes
   4.110 -        ])
   4.111 -        AC_MSG_RESULT($video_opengl)
   4.112 -        if test x$video_opengl = xyes; then
   4.113 -            AC_DEFINE(SDL_VIDEO_OPENGL_ES)
   4.114 -            AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
   4.115 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CM"
   4.116 -        else
   4.117 -            AC_MSG_CHECKING(for QNX OpenGL ES (CL) support)
   4.118 -            video_opengl=no
   4.119 -            AC_TRY_COMPILE([
   4.120 -             #define COMMON_LITE
   4.121 -             #include <GLES/egl.h>
   4.122 -            ],[
   4.123 -            ],[
   4.124 -            video_opengl=yes
   4.125 -            ])
   4.126 -            AC_MSG_RESULT($video_opengl)
   4.127 -            if test x$video_opengl = xyes; then
   4.128 -                AC_DEFINE(SDL_VIDEO_OPENGL_ES)
   4.129 -                AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
   4.130 -                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CLS"
   4.131 -            fi
   4.132 -        fi
   4.133 -    fi
   4.134 -}
   4.135 -
   4.136 -
   4.137  dnl Check for Windows OpenGL
   4.138  CheckWINDOWSGL()
   4.139  {
   4.140 @@ -1796,10 +1673,6 @@
   4.141              pthread_cflags="-D_REENTRANT"
   4.142              pthread_lib="-L/usr/lib -lpthread"
   4.143              ;;
   4.144 -        *-*-qnx*)
   4.145 -            pthread_cflags=""
   4.146 -            pthread_lib=""
   4.147 -            ;;
   4.148          *-*-osf*)
   4.149              pthread_cflags="-D_REENTRANT"
   4.150              if test x$ac_cv_prog_gcc = xyes; then
   4.151 @@ -2287,54 +2160,6 @@
   4.152              have_timers=yes
   4.153          fi
   4.154          ;;
   4.155 -    *-*-qnx*)
   4.156 -
   4.157 -        EXTRA_CFLAGS="-I/usr/include $CFLAGS"
   4.158 -        EXTRA_LDLAGS="-L/usr/lib $LDFLAGS"
   4.159 -
   4.160 -        ARCH=qnx
   4.161 -        CheckVisibilityHidden
   4.162 -        CheckDummyVideo
   4.163 -        CheckDiskAudio
   4.164 -        CheckDummyAudio
   4.165 -        CheckDLOPEN
   4.166 -        CheckPulseAudio
   4.167 -        CheckESD
   4.168 -        CheckNAS
   4.169 -        CheckPHOTON
   4.170 -        CheckQNXGF
   4.171 -        CheckX11
   4.172 -        CheckOpenGLX11
   4.173 -        CheckPTHREAD
   4.174 -        CheckClockGettime
   4.175 -
   4.176 -
   4.177 -        # Set up files for the audio library
   4.178 -        if test x$enable_audio = xyes; then
   4.179 -            AC_DEFINE(SDL_AUDIO_DRIVER_QSA)
   4.180 -            SOURCES="$SOURCES $srcdir/src/audio/qsa/*.c"
   4.181 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
   4.182 -            have_audio=yes
   4.183 -        fi
   4.184 -        # Set up files for the timer library
   4.185 -        if test x$enable_timers = xyes; then
   4.186 -            AC_DEFINE(SDL_TIMER_UNIX)
   4.187 -            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
   4.188 -            have_timers=yes
   4.189 -        fi
   4.190 -        # Set up dummy files for the joystick for now
   4.191 -        if test x$enable_joystick = xyes; then
   4.192 -            AC_DEFINE(SDL_JOYSTICK_DUMMY)
   4.193 -            SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
   4.194 -            have_joystick=yes
   4.195 -        fi
   4.196 -        # Set up dummy files for the haptic for now
   4.197 -        if test x$enable_haptic = xyes; then
   4.198 -            AC_DEFINE(SDL_HAPTIC_DUMMY)
   4.199 -            SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
   4.200 -            have_haptic=yes
   4.201 -        fi
   4.202 -        ;;
   4.203      *-wince* | *-mingw32ce)
   4.204          ARCH=win32
   4.205          CheckDummyVideo
     5.1 --- a/include/SDL.h	Tue Feb 01 21:23:43 2011 -0800
     5.2 +++ b/include/SDL.h	Tue Feb 01 21:40:03 2011 -0800
     5.3 @@ -37,10 +37,6 @@
     5.4   *  level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
     5.5   *  and 2D framebuffer across multiple platforms.
     5.6   *  
     5.7 - *  The current version supports Windows, Windows CE, Mac OS X, Linux,
     5.8 - *  FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, and QNX. The code contains
     5.9 - *  support for other operating systems but those are not officially supported. 
    5.10 - *  
    5.11   *  SDL is written in C, but works with C++ natively, and has bindings to
    5.12   *  several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
    5.13   *  Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP,
     6.1 --- a/include/SDL_config.h.in	Tue Feb 01 21:23:43 2011 -0800
     6.2 +++ b/include/SDL_config.h.in	Tue Feb 01 21:40:03 2011 -0800
     6.3 @@ -261,8 +261,6 @@
     6.4  #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
     6.5  #undef SDL_VIDEO_DRIVER_DUMMY
     6.6  #undef SDL_VIDEO_DRIVER_NDS
     6.7 -#undef SDL_VIDEO_DRIVER_PHOTON
     6.8 -#undef SDL_VIDEO_DRIVER_QNXGF
     6.9  #undef SDL_VIDEO_DRIVER_WINDOWS
    6.10  #undef SDL_VIDEO_DRIVER_X11
    6.11  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
     7.1 --- a/src/video/SDL_renderer_gl.c	Tue Feb 01 21:23:43 2011 -0800
     7.2 +++ b/src/video/SDL_renderer_gl.c	Tue Feb 01 21:40:03 2011 -0800
     7.3 @@ -211,9 +211,6 @@
     7.4  static int
     7.5  GL_LoadFunctions(GL_RenderData * data)
     7.6  {
     7.7 -#if defined(__QNXNTO__) && (_NTO_VERSION < 630)
     7.8 -#define __SDL_NOGETPROCADDR__
     7.9 -#endif
    7.10  #ifdef __SDL_NOGETPROCADDR__
    7.11  #define SDL_PROC(ret,func,params) data->func=func;
    7.12  #else
     8.1 --- a/src/video/SDL_renderer_gles.c	Tue Feb 01 21:23:43 2011 -0800
     8.2 +++ b/src/video/SDL_renderer_gles.c	Tue Feb 01 21:40:03 2011 -0800
     8.3 @@ -30,14 +30,7 @@
     8.4  #include "SDL_rect_c.h"
     8.5  #include "SDL_yuv_sw_c.h"
     8.6  
     8.7 -#if defined(__QNXNTO__)
     8.8 -/* Include QNX system header to check QNX version later */
     8.9 -#include <sys/neutrino.h>
    8.10 -#endif /* __QNXNTO__ */
    8.11 -
    8.12 -#if defined(SDL_VIDEO_DRIVER_QNXGF)  ||  \
    8.13 -    defined(SDL_VIDEO_DRIVER_PHOTON) ||  \
    8.14 -    defined(SDL_VIDEO_DRIVER_PANDORA)
    8.15 +#if defined(SDL_VIDEO_DRIVER_PANDORA)
    8.16  
    8.17  /* Empty function stub to get OpenGL ES 1.x support without  */
    8.18  /* OpenGL ES extension GL_OES_draw_texture supported         */
    8.19 @@ -47,7 +40,7 @@
    8.20      return;
    8.21  }
    8.22  
    8.23 -#endif /* QNXGF || PHOTON || PANDORA */
    8.24 +#endif /* PANDORA */
    8.25  
    8.26  /* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */
    8.27  
    8.28 @@ -229,16 +222,6 @@
    8.29  
    8.30      renderer->info.flags = SDL_RENDERER_ACCELERATED;
    8.31  
    8.32 -#if defined(__QNXNTO__)
    8.33 -#if _NTO_VERSION<=641
    8.34 -    /* QNX's OpenGL ES implementation is broken regarding             */
    8.35 -    /* packed textures support, affected versions 6.3.2, 6.4.0, 6.4.1 */
    8.36 -    renderer->info.num_texture_formats = 2;
    8.37 -    renderer->info.texture_formats[0] = SDL_PIXELFORMAT_ABGR8888;
    8.38 -    renderer->info.texture_formats[1] = SDL_PIXELFORMAT_BGR24;
    8.39 -#endif /* _NTO_VERSION */
    8.40 -#endif /* __QNXNTO__ */
    8.41 -
    8.42      if (GLES_LoadFunctions(data) < 0) {
    8.43          GLES_DestroyRenderer(renderer);
    8.44          return NULL;
     9.1 --- a/src/video/SDL_sysvideo.h	Tue Feb 01 21:23:43 2011 -0800
     9.2 +++ b/src/video/SDL_sysvideo.h	Tue Feb 01 21:40:03 2011 -0800
     9.3 @@ -397,30 +397,21 @@
     9.4  #if SDL_VIDEO_DRIVER_BWINDOW
     9.5  extern VideoBootStrap BWINDOW_bootstrap;
     9.6  #endif
     9.7 -#if SDL_VIDEO_DRIVER_PHOTON
     9.8 -extern VideoBootStrap photon_bootstrap;
     9.9 +#if SDL_VIDEO_DRIVER_PANDORA
    9.10 +extern VideoBootStrap PND_bootstrap;
    9.11  #endif
    9.12 -#if SDL_VIDEO_DRIVER_QNXGF
    9.13 -extern VideoBootStrap qnxgf_bootstrap;
    9.14 -#endif
    9.15 -#if SDL_VIDEO_DRIVER_EPOC
    9.16 -extern VideoBootStrap EPOC_bootstrap;
    9.17 +#if SDL_VIDEO_DRIVER_NDS
    9.18 +extern VideoBootStrap NDS_bootstrap;
    9.19  #endif
    9.20  #if SDL_VIDEO_DRIVER_UIKIT
    9.21  extern VideoBootStrap UIKIT_bootstrap;
    9.22  #endif
    9.23 +#if SDL_VIDEO_DRIVER_ANDROID
    9.24 +extern VideoBootStrap Android_bootstrap;
    9.25 +#endif
    9.26  #if SDL_VIDEO_DRIVER_DUMMY
    9.27  extern VideoBootStrap DUMMY_bootstrap;
    9.28  #endif
    9.29 -#if SDL_VIDEO_DRIVER_NDS
    9.30 -extern VideoBootStrap NDS_bootstrap;
    9.31 -#endif
    9.32 -#if SDL_VIDEO_DRIVER_PANDORA
    9.33 -extern VideoBootStrap PND_bootstrap;
    9.34 -#endif
    9.35 -#if SDL_VIDEO_DRIVER_ANDROID
    9.36 -extern VideoBootStrap Android_bootstrap;
    9.37 -#endif
    9.38  
    9.39  #define SDL_CurrentDisplay	(&_this->displays[_this->current_display])
    9.40  
    10.1 --- a/src/video/SDL_video.c	Tue Feb 01 21:23:43 2011 -0800
    10.2 +++ b/src/video/SDL_video.c	Tue Feb 01 21:40:03 2011 -0800
    10.3 @@ -70,14 +70,8 @@
    10.4  #if SDL_VIDEO_DRIVER_BWINDOW
    10.5      &BWINDOW_bootstrap,
    10.6  #endif
    10.7 -#if SDL_VIDEO_DRIVER_PHOTON
    10.8 -    &photon_bootstrap,
    10.9 -#endif
   10.10 -#if SDL_VIDEO_DRIVER_QNXGF
   10.11 -    &qnxgf_bootstrap,
   10.12 -#endif
   10.13 -#if SDL_VIDEO_DRIVER_EPOC
   10.14 -    &EPOC_bootstrap,
   10.15 +#if SDL_VIDEO_DRIVER_PANDORA
   10.16 +    &PND_bootstrap,
   10.17  #endif
   10.18  #if SDL_VIDEO_DRIVER_NDS
   10.19      &NDS_bootstrap,
   10.20 @@ -85,15 +79,12 @@
   10.21  #if SDL_VIDEO_DRIVER_UIKIT
   10.22      &UIKIT_bootstrap,
   10.23  #endif
   10.24 +#if SDL_VIDEO_DRIVER_ANDROID
   10.25 +    &Android_bootstrap,
   10.26 +#endif
   10.27  #if SDL_VIDEO_DRIVER_DUMMY
   10.28      &DUMMY_bootstrap,
   10.29  #endif
   10.30 -#if SDL_VIDEO_DRIVER_PANDORA
   10.31 -    &PND_bootstrap,
   10.32 -#endif
   10.33 -#if SDL_VIDEO_DRIVER_ANDROID
   10.34 -    &Android_bootstrap,
   10.35 -#endif
   10.36      NULL
   10.37  };
   10.38  
    11.1 --- a/src/video/photon/SDL_photon.c	Tue Feb 01 21:23:43 2011 -0800
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,2852 +0,0 @@
    11.4 -/*
    11.5 -    SDL - Simple DirectMedia Layer
    11.6 -    Copyright (C) 1997-2010 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 Lesser General Public
   11.10 -    License as published by the Free Software Foundation; either
   11.11 -    version 2.1 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 -    Lesser General Public License for more details.
   11.17 -
   11.18 -    You should have received a copy of the GNU Lesser General Public
   11.19 -    License along with this library; if not, write to the Free Software
   11.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   11.21 -
   11.22 -    Sam Lantinga
   11.23 -    slouken@libsdl.org
   11.24 -
   11.25 -    QNX Photon GUI SDL driver
   11.26 -    Copyright (C) 2009 Mike Gorchak
   11.27 -    (mike@malva.ua, lestat@i.com.ua)
   11.28 -*/
   11.29 -
   11.30 -/* SDL internals */
   11.31 -#include "SDL_config.h"
   11.32 -#include "../SDL_sysvideo.h"
   11.33 -#include "SDL_version.h"
   11.34 -#include "SDL_syswm.h"
   11.35 -#include "SDL_loadso.h"
   11.36 -#include "SDL_events.h"
   11.37 -#include "../../events/SDL_mouse_c.h"
   11.38 -#include "../../events/SDL_keyboard_c.h"
   11.39 -
   11.40 -/* Photon declarations */
   11.41 -#include "SDL_photon.h"
   11.42 -
   11.43 -/* Pixel format conversion routines */
   11.44 -#include "SDL_photon_pixelfmt.h"
   11.45 -
   11.46 -/* Use GF's pixel format functions for OpenGL ES context creation */
   11.47 -#if defined(SDL_VIDEO_OPENGL_ES)
   11.48 -#include "../qnxgf/SDL_gf_pixelfmt.h"
   11.49 -
   11.50 -/* If GF driver is not compiled in, include some of usefull functions */
   11.51 -#if !defined(SDL_VIDEO_DRIVER_QNXGF)
   11.52 -#include "../qnxgf/SDL_gf_pixelfmt.c"
   11.53 -#endif /* SDL_VIDEO_DRIVER_QNXGF */
   11.54 -#endif /* SDL_VIDEO_OPENGL_ES */
   11.55 -
   11.56 -/* Use GF's OpenGL ES 1.1 functions emulation */
   11.57 -#if defined(SDL_VIDEO_OPENGL_ES)
   11.58 -#include "../qnxgf/SDL_gf_opengles.h"
   11.59 -
   11.60 -/* If GF driver is not compiled in, include some of usefull functions */
   11.61 -#if !defined(SDL_VIDEO_DRIVER_QNXGF)
   11.62 -#include "../qnxgf/SDL_gf_opengles.c"
   11.63 -#endif /* SDL_VIDEO_DRIVER_QNXGF */
   11.64 -#endif /* SDL_VIDEO_OPENGL_ES */
   11.65 -
   11.66 -/* Low level device graphics driver names, which they are reporting */
   11.67 -static const Photon_DeviceCaps photon_devicename[] = {
   11.68 -    /* ATI Rage 128 graphics driver (devg-ati_rage128)      */
   11.69 -    {"ati_rage128", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
   11.70 -    ,
   11.71 -    /* Fujitsu Carmine graphics driver (devg-carmine.so)    */
   11.72 -    {"carmine", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
   11.73 -    ,
   11.74 -    /* C&T graphics driver (devg-chips.so)                  */
   11.75 -    {"chips", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
   11.76 -    ,
   11.77 -    /* Fujitsu Coral graphics driver (devg-coral.so)        */
   11.78 -    {"coral", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
   11.79 -    ,
   11.80 -    /* Intel integrated graphics driver (devg-extreme2.so)  */
   11.81 -    {"extreme2", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
   11.82 -    ,
   11.83 -    /* Unaccelerated FB driver (devg-flat.so)               */
   11.84 -    {"flat", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
   11.85 -    ,
   11.86 -    /* NS Geode graphics driver (devg-geode.so)             */
   11.87 -    {"geode", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
   11.88 -    ,
   11.89 -    /* Geode LX graphics driver (devg-geodelx.so)           */
   11.90 -    {"geodelx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
   11.91 -    ,
   11.92 -    /* Intel integrated graphics driver (devg-gma9xx.so)    */
   11.93 -    {"gma", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
   11.94 -    ,
   11.95 -    /* Intel integrated graphics driver (devg-i810.so)      */
   11.96 -    {"i810", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
   11.97 -    ,
   11.98 -    /* Intel integrated graphics driver (devg-i830.so)      */
   11.99 -    {"i830", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.100 -    ,
  11.101 -    /* Geode LX graphics driver (devg-lx800.so)             */
  11.102 -    {"lx800", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.103 -    ,
  11.104 -    /* Matrox Gxx graphics driver (devg-matroxg.so)         */
  11.105 -    {"matroxg", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.106 -    ,
  11.107 -    /* Intel Poulsbo graphics driver (devg-poulsbo.so)      */
  11.108 -    {"poulsbo", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
  11.109 -    ,
  11.110 -    /* ATI Radeon driver (devg-radeon.so)                   */
  11.111 -    {"radeon", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.112 -    ,
  11.113 -    /* ATI Rage driver (devg-rage.so)                       */
  11.114 -    {"rage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.115 -    ,
  11.116 -    /* S3 Savage graphics driver (devg-s3_savage.so)        */
  11.117 -    {"s3_savage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.118 -    ,
  11.119 -    /* SiS630 integrated graphics driver (devg-sis630.so)   */
  11.120 -    {"sis630", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.121 -    ,
  11.122 -    /* PowerVR SGX 535 graphics driver (devg-poulsbo.so)    */
  11.123 -    {"sgx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
  11.124 -    ,
  11.125 -    /* SM Voyager GX graphics driver (devg-smi5xx.so)       */
  11.126 -    {"smi5xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.127 -    ,
  11.128 -    /* Silicon Motion graphics driver (devg-smi7xx.so)      */
  11.129 -    {"smi7xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.130 -    ,
  11.131 -    /* SVGA unaccelerated gfx driver (devg-svga.so)         */
  11.132 -    {"svga", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.133 -    ,
  11.134 -    /* nVidia TNT graphics driver (devg-tnt.so)             */
  11.135 -    {"tnt", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.136 -    ,
  11.137 -    /* VIA integrated graphics driver (devg-tvia.so)        */
  11.138 -    {"tvia", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.139 -    ,
  11.140 -    /* VIA UniChrome graphics driver (devg-unichrome.so)    */
  11.141 -    {"unichrome", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.142 -    ,
  11.143 -    /* VESA unaccelerated gfx driver (devg-vesabios.so)     */
  11.144 -    {"vesa", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.145 -    ,
  11.146 -    /* VmWare graphics driver (devg-volari.so)              */
  11.147 -    {"vmware", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.148 -    ,
  11.149 -    /* XGI XP10 graphics driver (devg-volari.so), OpenGL 1.5 */
  11.150 -    {"volari", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
  11.151 -    ,
  11.152 -    /* End of list */
  11.153 -    {NULL, 0x00000000}
  11.154 -};
  11.155 -
  11.156 -static SDL_bool photon_initialized = SDL_FALSE;
  11.157 -
  11.158 -static int
  11.159 -photon_available(void)
  11.160 -{
  11.161 -    int32_t status;
  11.162 -
  11.163 -    /* Check if Photon was initialized before */
  11.164 -    if (photon_initialized == SDL_FALSE) {
  11.165 -        /* Initialize Photon widget library and open channel to Photon */
  11.166 -        status = PtInit(NULL);
  11.167 -        if (status == 0) {
  11.168 -            photon_initialized = SDL_TRUE;
  11.169 -            return 1;
  11.170 -        } else {
  11.171 -            photon_initialized = SDL_FALSE;
  11.172 -            return 0;
  11.173 -        }
  11.174 -    }
  11.175 -
  11.176 -    return 1;
  11.177 -}
  11.178 -
  11.179 -static void
  11.180 -photon_destroy(SDL_VideoDevice * device)
  11.181 -{
  11.182 -    SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata;
  11.183 -
  11.184 -#if defined(SDL_VIDEO_OPENGL_ES)
  11.185 -    if (phdata->gfinitialized != SDL_FALSE) {
  11.186 -        gf_dev_detach(phdata->gfdev);
  11.187 -    }
  11.188 -#endif /* SDL_VIDEO_OPENGL_ES */
  11.189 -
  11.190 -    if (device->driverdata != NULL) {
  11.191 -        device->driverdata = NULL;
  11.192 -    }
  11.193 -}
  11.194 -
  11.195 -static SDL_VideoDevice *
  11.196 -photon_create(int devindex)
  11.197 -{
  11.198 -    SDL_VideoDevice *device;
  11.199 -    SDL_VideoData *phdata;
  11.200 -    int32_t status;
  11.201 -
  11.202 -    /* Check if photon could be initialized */
  11.203 -    status = photon_available();
  11.204 -    if (status == 0) {
  11.205 -        /* Photon could not be used */
  11.206 -        return NULL;
  11.207 -    }
  11.208 -
  11.209 -    /* Photon agregates all video devices to one with multiple heads */
  11.210 -    if (devindex != 0) {
  11.211 -        /* devindex could be zero only in Photon SDL driver */
  11.212 -        return NULL;
  11.213 -    }
  11.214 -
  11.215 -    /* Initialize SDL_VideoDevice structure */
  11.216 -    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
  11.217 -    if (device == NULL) {
  11.218 -        SDL_OutOfMemory();
  11.219 -        return NULL;
  11.220 -    }
  11.221 -
  11.222 -    /* Initialize internal photon specific data */
  11.223 -    phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
  11.224 -    if (phdata == NULL) {
  11.225 -        SDL_OutOfMemory();
  11.226 -        SDL_free(device);
  11.227 -        return NULL;
  11.228 -    }
  11.229 -    device->driverdata = phdata;
  11.230 -
  11.231 -    /* Get all photon display devices */
  11.232 -    phdata->avail_rids =
  11.233 -        PdGetDevices(&phdata->rid[0], SDL_VIDEO_PHOTON_MAX_RIDS);
  11.234 -    if (phdata->avail_rids > SDL_VIDEO_PHOTON_MAX_RIDS) {
  11.235 -        phdata->avail_rids = SDL_VIDEO_PHOTON_MAX_RIDS;
  11.236 -    }
  11.237 -#if defined(SDL_VIDEO_OPENGL_ES)
  11.238 -    /* TODO: add real device detection versus multiple heads */
  11.239 -    status =
  11.240 -        gf_dev_attach(&phdata->gfdev, GF_DEVICE_INDEX(0),
  11.241 -                      &phdata->gfdev_info);
  11.242 -    if (status != GF_ERR_OK) {
  11.243 -        /* Do not fail right now, if GF can't be attached */
  11.244 -        phdata->gfinitialized = SDL_FALSE;
  11.245 -    } else {
  11.246 -        phdata->gfinitialized = SDL_TRUE;
  11.247 -    }
  11.248 -#endif /* SDL_VIDEO_OPENGL_ES */
  11.249 -
  11.250 -    /* Set default target device */
  11.251 -    status = PdSetTargetDevice(NULL, phdata->rid[0]);
  11.252 -    if (status == -1) {
  11.253 -        SDL_SetError("Photon: Can't set default target device");
  11.254 -#if defined(SDL_VIDEO_OPENGL_ES)
  11.255 -        gf_dev_detach(phdata->gfdev);
  11.256 -#endif /* SDL_VIDEO_OPENGL_ES */
  11.257 -        SDL_free(phdata);
  11.258 -        SDL_free(device);
  11.259 -        return NULL;
  11.260 -    }
  11.261 -    phdata->current_device_id = 0;
  11.262 -
  11.263 -    /* Setup amount of available displays and current display */
  11.264 -    device->num_displays = 0;
  11.265 -    device->current_display = 0;
  11.266 -
  11.267 -    /* Set device free function */
  11.268 -    device->free = photon_destroy;
  11.269 -
  11.270 -    /* Setup all functions which we can handle */
  11.271 -    device->VideoInit = photon_videoinit;
  11.272 -    device->VideoQuit = photon_videoquit;
  11.273 -    device->GetDisplayModes = photon_getdisplaymodes;
  11.274 -    device->SetDisplayMode = photon_setdisplaymode;
  11.275 -    device->CreateWindow = photon_createwindow;
  11.276 -    device->CreateWindowFrom = photon_createwindowfrom;
  11.277 -    device->SetWindowTitle = photon_setwindowtitle;
  11.278 -    device->SetWindowIcon = photon_setwindowicon;
  11.279 -    device->SetWindowPosition = photon_setwindowposition;
  11.280 -    device->SetWindowSize = photon_setwindowsize;
  11.281 -    device->ShowWindow = photon_showwindow;
  11.282 -    device->HideWindow = photon_hidewindow;
  11.283 -    device->RaiseWindow = photon_raisewindow;
  11.284 -    device->MaximizeWindow = photon_maximizewindow;
  11.285 -    device->MinimizeWindow = photon_minimizewindow;
  11.286 -    device->RestoreWindow = photon_restorewindow;
  11.287 -    device->SetWindowGrab = photon_setwindowgrab;
  11.288 -    device->DestroyWindow = photon_destroywindow;
  11.289 -    device->GetWindowWMInfo = photon_getwindowwminfo;
  11.290 -    device->GL_LoadLibrary = photon_gl_loadlibrary;
  11.291 -    device->GL_GetProcAddress = photon_gl_getprocaddres;
  11.292 -    device->GL_UnloadLibrary = photon_gl_unloadlibrary;
  11.293 -    device->GL_CreateContext = photon_gl_createcontext;
  11.294 -    device->GL_MakeCurrent = photon_gl_makecurrent;
  11.295 -    device->GL_SetSwapInterval = photon_gl_setswapinterval;
  11.296 -    device->GL_GetSwapInterval = photon_gl_getswapinterval;
  11.297 -    device->GL_SwapWindow = photon_gl_swapwindow;
  11.298 -    device->GL_DeleteContext = photon_gl_deletecontext;
  11.299 -    device->PumpEvents = photon_pumpevents;
  11.300 -    device->SuspendScreenSaver = photon_suspendscreensaver;
  11.301 -
  11.302 -    return device;
  11.303 -}
  11.304 -
  11.305 -VideoBootStrap photon_bootstrap = {
  11.306 -    "photon",
  11.307 -    "SDL QNX Photon video driver",
  11.308 -    photon_available,
  11.309 -    photon_create
  11.310 -};
  11.311 -
  11.312 -/*****************************************************************************/
  11.313 -/* SDL Video and Display initialization/handling functions                   */
  11.314 -/*****************************************************************************/
  11.315 -int
  11.316 -photon_videoinit(_THIS)
  11.317 -{
  11.318 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
  11.319 -    PgHWCaps_t hwcaps;
  11.320 -    PgVideoModeInfo_t modeinfo;
  11.321 -    int32_t status;
  11.322 -    SDL_VideoDisplay display;
  11.323 -    SDL_DisplayMode current_mode;
  11.324 -    SDL_DisplayData *didata;
  11.325 -    uint32_t it;
  11.326 -    uint32_t jt;
  11.327 -    char *override;
  11.328 -
  11.329 -    /* By default Photon do not uses swap on VSYNC */
  11.330 -#if defined(SDL_VIDEO_OPENGL_ES)
  11.331 -    phdata->swapinterval = 0;
  11.332 -#endif /* SDL_VIDEO_OPENGL_ES */
  11.333 -
  11.334 -    for (it = 0; it < phdata->avail_rids; it++) {
  11.335 -        didata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
  11.336 -        if (didata == NULL) {
  11.337 -            /* memory allocation error */
  11.338 -            SDL_OutOfMemory();
  11.339 -            return -1;
  11.340 -        }
  11.341 -
  11.342 -        /* Allocate two cursors with SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE size */
  11.343 -        /* and 128 bytes of spare place                                    */
  11.344 -        didata->cursor_size =
  11.345 -            ((SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE * 4) >> 3) + 128;
  11.346 -        didata->cursor = (PhCursorDef_t *) SDL_calloc(1, didata->cursor_size);
  11.347 -        if (didata->cursor == NULL) {
  11.348 -            /* memory allocation error */
  11.349 -            SDL_OutOfMemory();
  11.350 -            SDL_free(didata);
  11.351 -            return -1;
  11.352 -        }
  11.353 -
  11.354 -        /* Initialize GF in case of OpenGL ES support is compiled in */
  11.355 -#if defined(SDL_VIDEO_OPENGL_ES)
  11.356 -        /* TODO: add real device detection versus multiple heads */
  11.357 -        if (phdata->gfinitialized == SDL_TRUE) {
  11.358 -            status =
  11.359 -                gf_display_attach(&didata->display, phdata->gfdev, it,
  11.360 -                                  &didata->display_info);
  11.361 -            if (status != GF_ERR_OK) {
  11.362 -                /* Just shutdown GF, do not fail */
  11.363 -                gf_dev_detach(phdata->gfdev);
  11.364 -                phdata->gfinitialized = SDL_FALSE;
  11.365 -            }
  11.366 -        }
  11.367 -#endif /* SDL_VIDEO_OPENGL_ES */
  11.368 -
  11.369 -        /* Check if current device is not the same as target */
  11.370 -        if (phdata->current_device_id != it) {
  11.371 -            /* Set target device as default for Pd and Pg functions */
  11.372 -            status = PdSetTargetDevice(NULL, phdata->rid[it]);
  11.373 -            if (status != 0) {
  11.374 -                SDL_SetError("Photon: Can't set default target device\n");
  11.375 -                SDL_free(didata->cursor);
  11.376 -                SDL_free(didata);
  11.377 -                return -1;
  11.378 -            }
  11.379 -            phdata->current_device_id = it;
  11.380 -        }
  11.381 -
  11.382 -        /* Store device id */
  11.383 -        didata->device_id = it;
  11.384 -
  11.385 -        /* Query photon about graphics hardware caps and current video mode */
  11.386 -        SDL_memset(&hwcaps, 0x00, sizeof(PgHWCaps_t));
  11.387 -        status = PgGetGraphicsHWCaps(&hwcaps);
  11.388 -        if (status != 0) {
  11.389 -            PhRect_t extent;
  11.390 -            PdOffscreenContext_t* curctx;
  11.391 -
  11.392 -            /* If error happens, this also could mean, that photon is working */
  11.393 -            /* under custom (not listed by photon) video mode                 */
  11.394 -            status=PhWindowQueryVisible(Ph_QUERY_GRAPHICS, 0, 0, &extent);
  11.395 -            if (status != 0) {
  11.396 -                SDL_SetError("Photon: Can't get graphics driver region");
  11.397 -                SDL_free(didata->cursor);
  11.398 -                SDL_free(didata);
  11.399 -                return -1;
  11.400 -            }
  11.401 -            modeinfo.width=extent.lr.x+1;
  11.402 -            modeinfo.height=extent.lr.y+1;
  11.403 -            /* Hardcode 60Hz, as the base refresh rate frequency */
  11.404 -            hwcaps.current_rrate=60;
  11.405 -            /* Clear current video driver name, no way to get it somehow */
  11.406 -            hwcaps.chip_name[0]=0x00;
  11.407 -
  11.408 -            /* Create offscreen context from video memory, which is currently */
  11.409 -            /* displayed on the screen                                        */
  11.410 -            curctx=PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
  11.411 -            if (curctx==NULL)
  11.412 -            {
  11.413 -                SDL_SetError("Photon: Can't get display area capabilities");
  11.414 -                SDL_free(didata->cursor);
  11.415 -                SDL_free(didata);
  11.416 -                return -1;
  11.417 -            }
  11.418 -            /* Retrieve current bpp */
  11.419 -            modeinfo.type=curctx->format;
  11.420 -            PhDCRelease(curctx);
  11.421 -        } else {
  11.422 -            /* Get current video mode details */
  11.423 -            status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo);
  11.424 -            if (status != 0) {
  11.425 -                SDL_SetError("Photon: Can't get current video mode information");
  11.426 -                SDL_free(didata->cursor);
  11.427 -                SDL_free(didata);
  11.428 -                return -1;
  11.429 -            }
  11.430 -
  11.431 -            /* Get current video mode 2D capabilities for the renderer */
  11.432 -            didata->mode_2dcaps=0;
  11.433 -            if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND)
  11.434 -            {
  11.435 -               didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND;
  11.436 -            }
  11.437 -            if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT)
  11.438 -            {
  11.439 -               didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_SCALED_BLIT;
  11.440 -            }
  11.441 -        }
  11.442 -
  11.443 -        /* Setup current desktop mode for SDL */
  11.444 -        SDL_zero(current_mode);
  11.445 -        current_mode.w = modeinfo.width;
  11.446 -        current_mode.h = modeinfo.height;
  11.447 -        current_mode.refresh_rate = hwcaps.current_rrate;
  11.448 -        current_mode.format = photon_image_to_sdl_pixelformat(modeinfo.type);
  11.449 -        current_mode.driverdata = NULL;
  11.450 -
  11.451 -        /* Copy device name */
  11.452 -        SDL_strlcpy(didata->description, hwcaps.chip_name,
  11.453 -                    SDL_VIDEO_PHOTON_DEVICENAME_MAX - 1);
  11.454 -
  11.455 -        /* Search device capabilities and possible workarounds */
  11.456 -        jt = 0;
  11.457 -        do {
  11.458 -            if (photon_devicename[jt].name == NULL) {
  11.459 -                break;
  11.460 -            }
  11.461 -            if (SDL_strncmp
  11.462 -                (photon_devicename[jt].name, didata->description,
  11.463 -                 SDL_strlen(photon_devicename[jt].name)) == 0) {
  11.464 -                didata->caps = photon_devicename[jt].caps;
  11.465 -            }
  11.466 -            jt++;
  11.467 -        } while (1);
  11.468 -
  11.469 -        /* Initialize display structure */
  11.470 -        SDL_zero(display);
  11.471 -        display.desktop_mode = current_mode;
  11.472 -        display.current_mode = current_mode;
  11.473 -        display.fullscreen_mode = current_mode;
  11.474 -        display.driverdata = didata;
  11.475 -        didata->current_mode = current_mode;
  11.476 -        SDL_AddVideoDisplay(&display);
  11.477 -
  11.478 -        /* Check for environment variables which could override some SDL settings */
  11.479 -        didata->custom_refresh = 0;
  11.480 -        override = SDL_getenv("SDL_VIDEO_PHOTON_REFRESH_RATE");
  11.481 -        if (override != NULL) {
  11.482 -            if (SDL_sscanf(override, "%u", &didata->custom_refresh) != 1) {
  11.483 -                didata->custom_refresh = 0;
  11.484 -            }
  11.485 -        }
  11.486 -    }
  11.487 -
  11.488 -    /* Add photon input devices */
  11.489 -    status = photon_addinputdevices(_this);
  11.490 -    if (status != 0) {
  11.491 -        /* SDL error is set by photon_addinputdevices() function */
  11.492 -        return -1;
  11.493 -    }
  11.494 -
  11.495 -    /* Add photon renderer to SDL */
  11.496 -    photon_addrenderdriver(_this);
  11.497 -
  11.498 -    /* video has been initialized successfully */
  11.499 -    return 1;
  11.500 -}
  11.501 -
  11.502 -void
  11.503 -photon_videoquit(_THIS)
  11.504 -{
  11.505 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
  11.506 -    SDL_DisplayData *didata;
  11.507 -    uint32_t it;
  11.508 -
  11.509 -    /* SDL will restore our desktop mode on exit */
  11.510 -    for (it = 0; it < _this->num_displays; it++) {
  11.511 -        didata = _this->displays[it].driverdata;
  11.512 -
  11.513 -        if (didata->cursor != NULL) {
  11.514 -            SDL_free(didata->cursor);
  11.515 -        }
  11.516 -#if defined(SDL_VIDEO_OPENGL_ES)
  11.517 -        if (phdata->gfinitialized == SDL_TRUE) {
  11.518 -            /* Detach GF display */
  11.519 -            gf_display_detach(didata->display);
  11.520 -        }
  11.521 -#endif /* SDL_VIDEO_OPENGL_ES */
  11.522 -    }
  11.523 -}
  11.524 -
  11.525 -void
  11.526 -photon_getdisplaymodes(_THIS, SDL_VideoDisplay * display)
  11.527 -{
  11.528 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
  11.529 -    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
  11.530 -    SDL_DisplayMode mode;
  11.531 -    PgVideoModes_t modes;
  11.532 -    PgVideoModeInfo_t modeinfo;
  11.533 -    int32_t status;
  11.534 -    uint32_t it;
  11.535 -    uint32_t jt;
  11.536 -
  11.537 -    /* Check if current device is not the same as target */
  11.538 -    if (phdata->current_device_id != didata->device_id) {
  11.539 -        /* Set target device as default for Pd and Pg functions */
  11.540 -        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
  11.541 -        if (status != 0) {
  11.542 -            SDL_SetError("Photon: Can't set default target device\n");
  11.543 -            return;
  11.544 -        }
  11.545 -        phdata->current_device_id = didata->device_id;
  11.546 -    }
  11.547 -
  11.548 -    /* Get array of available video modes */
  11.549 -    status = PgGetVideoModeList(&modes);
  11.550 -    if (status != 0) {
  11.551 -        SDL_SetError("Photon: Can't get video mode list");
  11.552 -        return;
  11.553 -    }
  11.554 -
  11.555 -    for (it = 0; it < modes.num_modes; it++) {
  11.556 -        status = PgGetVideoModeInfo(modes.modes[it], &modeinfo);
  11.557 -        if (status != 0) {
  11.558 -            /* Maybe something wrong with this particular mode, skip it */
  11.559 -            continue;
  11.560 -        }
  11.561 -
  11.562 -        jt = 0;
  11.563 -        do {
  11.564 -            if (modeinfo.refresh_rates[jt] != 0) {
  11.565 -                mode.w = modeinfo.width;
  11.566 -                mode.h = modeinfo.height;
  11.567 -                mode.refresh_rate = modeinfo.refresh_rates[jt];
  11.568 -                mode.format = photon_image_to_sdl_pixelformat(modeinfo.type);
  11.569 -                mode.driverdata = NULL;
  11.570 -                SDL_AddDisplayMode(display, &mode);
  11.571 -
  11.572 -                /* If mode is RGBA8888, add the same mode as RGBx888 */
  11.573 -                if (modeinfo.type == Pg_IMAGE_DIRECT_8888) {
  11.574 -                    mode.w = modeinfo.width;
  11.575 -                    mode.h = modeinfo.height;
  11.576 -                    mode.refresh_rate = modeinfo.refresh_rates[jt];
  11.577 -                    mode.format = SDL_PIXELFORMAT_RGB888;
  11.578 -                    mode.driverdata = NULL;
  11.579 -                    SDL_AddDisplayMode(display, &mode);
  11.580 -                }
  11.581 -
  11.582 -                /* If mode is RGBA1555, add the same mode as RGBx555 */
  11.583 -                if (modeinfo.type == Pg_IMAGE_DIRECT_1555) {
  11.584 -                    mode.w = modeinfo.width;
  11.585 -                    mode.h = modeinfo.height;
  11.586 -                    mode.refresh_rate = modeinfo.refresh_rates[jt];
  11.587 -                    mode.format = SDL_PIXELFORMAT_RGB555;
  11.588 -                    mode.driverdata = NULL;
  11.589 -                    SDL_AddDisplayMode(display, &mode);
  11.590 -                }
  11.591 -
  11.592 -                jt++;
  11.593 -            } else {
  11.594 -                break;
  11.595 -            }
  11.596 -        } while (1);
  11.597 -    }
  11.598 -}
  11.599 -
  11.600 -int
  11.601 -photon_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
  11.602 -{
  11.603 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
  11.604 -    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
  11.605 -    PgVideoModes_t modes;
  11.606 -    PgVideoModeInfo_t modeinfo;
  11.607 -    PgDisplaySettings_t modesettings;
  11.608 -    uint32_t refresh_rate = 0;
  11.609 -    int32_t status;
  11.610 -    uint32_t it;
  11.611 -
  11.612 -    /* Check if current device is not the same as target */
  11.613 -    if (phdata->current_device_id != didata->device_id) {
  11.614 -        /* Set target device as default for Pd and Pg functions */
  11.615 -        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
  11.616 -        if (status != 0) {
  11.617 -            SDL_SetError("Photon: Can't set default target device\n");
  11.618 -            return -1;
  11.619 -        }
  11.620 -        phdata->current_device_id = didata->device_id;
  11.621 -    }
  11.622 -
  11.623 -    /* Get array of available video modes */
  11.624 -    status = PgGetVideoModeList(&modes);
  11.625 -    if (status != 0) {
  11.626 -        SDL_SetError("Photon: Can't get video mode list");
  11.627 -        return -1;
  11.628 -    }
  11.629 -
  11.630 -    /* Current display dimension and bpp are no more valid */
  11.631 -    didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN;
  11.632 -    didata->current_mode.w = 0;
  11.633 -    didata->current_mode.h = 0;
  11.634 -
  11.635 -    /* Check if custom refresh rate requested */
  11.636 -    if (didata->custom_refresh != 0) {
  11.637 -        refresh_rate = didata->custom_refresh;
  11.638 -    } else {
  11.639 -        refresh_rate = mode->refresh_rate;
  11.640 -    }
  11.641 -
  11.642 -    /* Check if SDL GF driver needs to find appropriate refresh rate itself */
  11.643 -    if (refresh_rate == 0) {
  11.644 -        SDL_DisplayMode tempmode;
  11.645 -
  11.646 -        /* Clear display mode structure */
  11.647 -        SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode));
  11.648 -        tempmode.refresh_rate = 0x0000FFFF;
  11.649 -
  11.650 -        /* Check if window width and height matches one of our modes */
  11.651 -        for (it = 0; it < display->num_display_modes; it++) {
  11.652 -            if ((display->display_modes[it].w == mode->w) &&
  11.653 -                (display->display_modes[it].h == mode->h) &&
  11.654 -                (display->display_modes[it].format == mode->format))
  11.655 -            {
  11.656 -                /* Find the lowest refresh rate available */
  11.657 -                if (tempmode.refresh_rate >
  11.658 -                    display->display_modes[it].refresh_rate) {
  11.659 -                    tempmode = display->display_modes[it];
  11.660 -                }
  11.661 -            }
  11.662 -        }
  11.663 -        if (tempmode.refresh_rate != 0x0000FFFF) {
  11.664 -            refresh_rate = tempmode.refresh_rate;
  11.665 -        } else {
  11.666 -            /* Let video driver decide what to do with this */
  11.667 -            refresh_rate = 0;
  11.668 -        }
  11.669 -    }
  11.670 -
  11.671 -    /* Check if SDL GF driver needs to check custom refresh rate */
  11.672 -    if (didata->custom_refresh != 0) {
  11.673 -        SDL_DisplayMode tempmode;
  11.674 -
  11.675 -        /* Clear display mode structure */
  11.676 -        SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode));
  11.677 -        tempmode.refresh_rate = 0x0000FFFF;
  11.678 -
  11.679 -        /* Check if window width and height matches one of our modes */
  11.680 -        for (it = 0; it < display->num_display_modes; it++) {
  11.681 -            if ((display->display_modes[it].w == mode->w) &&
  11.682 -                (display->display_modes[it].h == mode->h) &&
  11.683 -                (display->display_modes[it].format == mode->format))
  11.684 -            {
  11.685 -                /* Find the lowest refresh rate available */
  11.686 -                if (tempmode.refresh_rate >
  11.687 -                    display->display_modes[it].refresh_rate) {
  11.688 -                    tempmode = display->display_modes[it];
  11.689 -                }
  11.690 -
  11.691 -                /* Check if requested refresh rate found */
  11.692 -                if (refresh_rate ==
  11.693 -                    display->display_modes[it].refresh_rate) {
  11.694 -                    tempmode = display->display_modes[it];
  11.695 -                    break;
  11.696 -                }
  11.697 -            }
  11.698 -        }
  11.699 -        if (tempmode.refresh_rate != 0x0000FFFF) {
  11.700 -            refresh_rate = tempmode.refresh_rate;
  11.701 -        } else {
  11.702 -            /* Let video driver decide what to do with this */
  11.703 -            refresh_rate = 0;
  11.704 -        }
  11.705 -    }
  11.706 -
  11.707 -    /* Find photon's video mode number */
  11.708 -    for (it = 0; it < modes.num_modes; it++) {
  11.709 -        uint32_t jt;
  11.710 -        uint32_t foundrefresh;
  11.711 -
  11.712 -        /* Get current video mode details */
  11.713 -        status = PgGetVideoModeInfo(modes.modes[it], &modeinfo);
  11.714 -        if (status != 0) {
  11.715 -            /* Maybe something wrong with this particular mode, skip it */
  11.716 -            continue;
  11.717 -        }
  11.718 -        if ((modeinfo.width == mode->w) && (modeinfo.height == mode->h) &&
  11.719 -            (modeinfo.type == photon_sdl_to_image_pixelformat(mode->format)))
  11.720 -        {
  11.721 -            /* Mode is found, find requested refresh rate, this case is for */
  11.722 -            /* video drivers, which provide non-generic video modes.        */
  11.723 -            jt = 0;
  11.724 -            foundrefresh = 0;
  11.725 -            do {
  11.726 -                if (modeinfo.refresh_rates[jt] != 0) {
  11.727 -                    if (modeinfo.refresh_rates[jt] == refresh_rate) {
  11.728 -                        foundrefresh = 1;
  11.729 -                        break;
  11.730 -                    }
  11.731 -                    jt++;
  11.732 -                } else {
  11.733 -                    break;
  11.734 -                }
  11.735 -            } while (1);
  11.736 -            if (foundrefresh != 0) {
  11.737 -                break;
  11.738 -            }
  11.739 -        }
  11.740 -    }
  11.741 -
  11.742 -    /* Check if video mode has not been found */
  11.743 -    if (it == modes.num_modes) {
  11.744 -        SDL_SetError("Photon: Can't find appropriate video mode");
  11.745 -        return -1;
  11.746 -    }
  11.747 -
  11.748 -    /* Fill mode settings */
  11.749 -    modesettings.flags = 0x00000000;
  11.750 -    modesettings.mode = modes.modes[it];
  11.751 -    modesettings.refresh = refresh_rate;
  11.752 -
  11.753 -    /* Finally set new video mode */
  11.754 -    status = PgSetVideoMode(&modesettings);
  11.755 -    if (status != 0) {
  11.756 -        SDL_SetError("Photon: Can't set new video mode");
  11.757 -        return -1;
  11.758 -    }
  11.759 -
  11.760 -    /* Store new video mode parameters */
  11.761 -    didata->current_mode = *mode;
  11.762 -    didata->current_mode.refresh_rate = refresh_rate;
  11.763 -
  11.764 -    /* Get current video mode 2D capabilities for the renderer */
  11.765 -    didata->mode_2dcaps=0;
  11.766 -    if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND)
  11.767 -    {
  11.768 -       didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND;
  11.769 -    }
  11.770 -    if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT)
  11.771 -    {
  11.772 -       didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_SCALED_BLIT;
  11.773 -    }
  11.774 -
  11.775 -    return 0;
  11.776 -}
  11.777 -
  11.778 -int
  11.779 -photon_createwindow(_THIS, SDL_Window * window)
  11.780 -{
  11.781 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
  11.782 -    SDL_DisplayData *didata =
  11.783 -        (SDL_DisplayData *) window->display->driverdata;
  11.784 -    SDL_WindowData *wdata;
  11.785 -    PhDim_t winsize;
  11.786 -    PhPoint_t winpos;
  11.787 -    PtArg_t winargs[32];
  11.788 -    uint32_t winargc = 0;
  11.789 -    int32_t status;
  11.790 -    PhRegion_t wregion;
  11.791 -
  11.792 -    /* Allocate window internal data */
  11.793 -    wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
  11.794 -    if (wdata == NULL) {
  11.795 -        SDL_OutOfMemory();
  11.796 -        return -1;
  11.797 -    }
  11.798 -
  11.799 -    /* Setup driver data for this window */
  11.800 -    window->driverdata = wdata;
  11.801 -
  11.802 -    /* Set initial window title */
  11.803 -    if (window->title != NULL) {
  11.804 -        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, window->title, 0);
  11.805 -    } else {
  11.806 -        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, "SDL unnamed application", 0);
  11.807 -    }
  11.808 -
  11.809 -    /* TODO: handle SDL_WINDOW_INPUT_GRABBED */
  11.810 -
  11.811 -    /* Disable default window filling on redraw */
  11.812 -    PtSetArg(&winargs[winargc++], Pt_ARG_BASIC_FLAGS, Pt_TRUE,
  11.813 -             Pt_BASIC_PREVENT_FILL);
  11.814 -
  11.815 -    /* Reset default managed flags to disabled state */
  11.816 -    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE,
  11.817 -             Ph_WM_APP_DEF_MANAGED);
  11.818 -    /* Set which events we will not handle, let WM to handle them */
  11.819 -    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE,
  11.820 -             Ph_WM_BACKDROP | Ph_WM_TOFRONT | Ph_WM_COLLAPSE | Ph_WM_FFRONT |
  11.821 -             Ph_WM_FOCUS | Ph_WM_HELP | Ph_WM_HIDE | Ph_WM_MAX |
  11.822 -             Ph_WM_MENU | Ph_WM_MOVE | Ph_WM_RESTORE | Ph_WM_TASKBAR |
  11.823 -             Ph_WM_TOBACK | Ph_WM_RESIZE);
  11.824 -
  11.825 -    /* Reset default notify events to disable */
  11.826 -    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE,
  11.827 -             Ph_WM_RESIZE | Ph_WM_CLOSE | Ph_WM_HELP);
  11.828 -    /* Set which events we will handle */
  11.829 -    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE,
  11.830 -             Ph_WM_CLOSE | Ph_WM_COLLAPSE | Ph_WM_FOCUS | Ph_WM_MAX |
  11.831 -             Ph_WM_MOVE | Ph_WM_RESIZE | Ph_WM_RESTORE | Ph_WM_HIDE);
  11.832 -
  11.833 -    /* Borderless window can't be resizeable */
  11.834 -    if ((window->flags & SDL_WINDOW_BORDERLESS) == SDL_WINDOW_BORDERLESS) {
  11.835 -        window->flags &= ~(SDL_WINDOW_RESIZABLE);
  11.836 -    }
  11.837 -
  11.838 -    /* Reset all default decorations */
  11.839 -    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE,
  11.840 -             Ph_WM_APP_DEF_RENDER);
  11.841 -
  11.842 -    /* Fullscreen window has its own decorations */
  11.843 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN) {
  11.844 -        window->flags |= SDL_WINDOW_BORDERLESS;
  11.845 -        window->flags &= ~(SDL_WINDOW_RESIZABLE);
  11.846 -        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE,
  11.847 -                 Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_TITLE);
  11.848 -    } else {
  11.849 -        uint32_t decorations =
  11.850 -            Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN |
  11.851 -            Ph_WM_RENDER_TITLE | Ph_WM_RENDER_MOVE;
  11.852 -
  11.853 -        if ((window->flags & SDL_WINDOW_RESIZABLE) == SDL_WINDOW_RESIZABLE) {
  11.854 -            decorations |=
  11.855 -                Ph_WM_RENDER_BORDER | Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX;
  11.856 -            PtSetArg(&winargs[winargc++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE,
  11.857 -                     Pt_RESIZE_XY_AS_REQUIRED);
  11.858 -        }
  11.859 -        if ((window->flags & SDL_WINDOW_BORDERLESS) != SDL_WINDOW_BORDERLESS) {
  11.860 -            decorations |= Ph_WM_RENDER_BORDER;
  11.861 -        }
  11.862 -        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE,
  11.863 -                 decorations);
  11.864 -    }
  11.865 -
  11.866 -    /* Set initial window state */
  11.867 -    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_FALSE,
  11.868 -             Ph_WM_STATE_ISFOCUS);
  11.869 -    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_TRUE,
  11.870 -             Ph_WM_STATE_ISALTKEY);
  11.871 -
  11.872 -    /* Special case, do not handle maximize events, if window can't be resized */
  11.873 -    if ((window->flags & SDL_WINDOW_RESIZABLE) != SDL_WINDOW_RESIZABLE)
  11.874 -    {
  11.875 -       PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE,
  11.876 -                Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE);
  11.877 -    }
  11.878 -
  11.879 -    /* Set window dimension */
  11.880 -    winsize.w = window->w;
  11.881 -    winsize.h = window->h;
  11.882 -    PtSetArg(&winargs[winargc++], Pt_ARG_DIM, &winsize, 0);
  11.883 -
  11.884 -    /* Check if upper level requests WM to position window */
  11.885 -    if ((window->x == SDL_WINDOWPOS_UNDEFINED)
  11.886 -        && (window->y == SDL_WINDOWPOS_UNDEFINED)) {
  11.887 -        /* Do not set widget position, let WM to set it */
  11.888 -    } else {
  11.889 -        if (window->x == SDL_WINDOWPOS_UNDEFINED) {
  11.890 -            window->x = 0;
  11.891 -        }
  11.892 -        if (window->y == SDL_WINDOWPOS_UNDEFINED) {
  11.893 -            window->y = 0;
  11.894 -        }
  11.895 -        if (window->x == SDL_WINDOWPOS_CENTERED) {
  11.896 -            window->x = (didata->current_mode.w - window->w) / 2;
  11.897 -        }
  11.898 -        if (window->y == SDL_WINDOWPOS_CENTERED) {
  11.899 -            window->y = (didata->current_mode.h - window->h) / 2;
  11.900 -        }
  11.901 -
  11.902 -        /* Now set window position */
  11.903 -        winpos.x = window->x;
  11.904 -        winpos.y = window->y;
  11.905 -        PtSetArg(&winargs[winargc++], Pt_ARG_POS, &winpos, 0);
  11.906 -    }
  11.907 -
  11.908 -    /* Check if window must support OpenGL ES rendering */
  11.909 -    if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) {
  11.910 -#if defined(SDL_VIDEO_OPENGL_ES)
  11.911 -        EGLBoolean initstatus;
  11.912 -
  11.913 -        /* Check if GF was initialized correctly */
  11.914 -        if (phdata->gfinitialized == SDL_FALSE) {
  11.915 -            SDL_SetError
  11.916 -                ("Photon: GF initialization failed, no OpenGL ES support");
  11.917 -            return -1;
  11.918 -        }
  11.919 -
  11.920 -        /* Mark this window as OpenGL ES compatible */
  11.921 -        wdata->uses_gles = SDL_TRUE;
  11.922 -
  11.923 -        /* Create connection to OpenGL ES */
  11.924 -        if (phdata->egldisplay == EGL_NO_DISPLAY) {
  11.925 -            phdata->egldisplay = eglGetDisplay(phdata->gfdev);
  11.926 -            if (phdata->egldisplay == EGL_NO_DISPLAY) {
  11.927 -                SDL_SetError("Photon: Can't get connection to OpenGL ES");
  11.928 -                return -1;
  11.929 -            }
  11.930 -
  11.931 -            /* Initialize OpenGL ES library, ignore EGL version */
  11.932 -            initstatus = eglInitialize(phdata->egldisplay, NULL, NULL);
  11.933 -            if (initstatus != EGL_TRUE) {
  11.934 -                SDL_SetError("Photon: Can't init OpenGL ES library");
  11.935 -                return -1;
  11.936 -            }
  11.937 -        }
  11.938 -
  11.939 -        /* Increment GL ES reference count usage */
  11.940 -        phdata->egl_refcount++;
  11.941 -#else
  11.942 -        SDL_SetError("Photon: OpenGL ES support is not compiled in");
  11.943 -        return -1;
  11.944 -#endif /* SDL_VIDEO_OPENGL_ES */
  11.945 -    }
  11.946 -
  11.947 -    /* Finally create the window */
  11.948 -    wdata->window = PtCreateWidget(PtWindow, Pt_NO_PARENT, winargc, winargs);
  11.949 -    if (wdata->window == NULL) {
  11.950 -        SDL_SetError("Photon: Can't create window widget");
  11.951 -        SDL_free(wdata);
  11.952 -        return -1;
  11.953 -    }
  11.954 -
  11.955 -    /* Show widget */
  11.956 -    status = PtRealizeWidget(wdata->window);
  11.957 -    if (status != 0) {
  11.958 -        SDL_SetError("Photon: Can't realize window widget");
  11.959 -        PtDestroyWidget(wdata->window);
  11.960 -        SDL_free(wdata);
  11.961 -        return;
  11.962 -    }
  11.963 -
  11.964 -    /* Just created SDL window always gets focus */
  11.965 -    window->flags |= SDL_WINDOW_INPUT_FOCUS;
  11.966 -
  11.967 -    /* Create window-specific cursor after creation */
  11.968 -    if (didata->cursor_visible == SDL_TRUE) {
  11.969 -        /* Setup cursor type. shape and default color */
  11.970 -        PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR,
  11.971 -                      Ph_CURSOR_DEFAULT_COLOR, 0);
  11.972 -        PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0);
  11.973 -        PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR, didata->cursor,
  11.974 -                      didata->cursor->hdr.len + sizeof(PhRegionDataHdr_t));
  11.975 -    } else {
  11.976 -        PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0);
  11.977 -    }
  11.978 -
  11.979 -    /* Set window region sensible to mouse motion events */
  11.980 -    status =
  11.981 -        PhRegionQuery(PtWidgetRid(wdata->window), &wregion, NULL, NULL, 0);
  11.982 -    if (status != 0) {
  11.983 -        SDL_SetError
  11.984 -            ("Photon: Can't set region sensivity to mouse motion events");
  11.985 -        PtDestroyWidget(wdata->window);
  11.986 -        SDL_free(wdata);
  11.987 -        return -1;
  11.988 -    }
  11.989 -    wregion.events_sense |=
  11.990 -        Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON;
  11.991 -    status = PhRegionChange(Ph_REGION_EV_SENSE, 0, &wregion, NULL, NULL);
  11.992 -    if (status < 0) {
  11.993 -        SDL_SetError("Photon: Can't change region sensivity");
  11.994 -        PtDestroyWidget(wdata->window);
  11.995 -        SDL_free(wdata);
  11.996 -        return -1;
  11.997 -    }
  11.998 -
  11.999 -    /* Flush all widget operations again */
 11.1000 -    PtFlush();
 11.1001 -
 11.1002 -    /* By default last created window got a input focus */
 11.1003 -    SDL_SetKeyboardFocus(0, window);
 11.1004 -
 11.1005 -    /* Emit focus gained event, because photon is not sending it */
 11.1006 -    SDL_OnWindowFocusGained(window);
 11.1007 -
 11.1008 -    /* Window has been successfully created */
 11.1009 -    return 0;
 11.1010 -}
 11.1011 -
 11.1012 -int
 11.1013 -photon_createwindowfrom(_THIS, SDL_Window * window, const void *data)
 11.1014 -{
 11.1015 -    /* TODO: it is possible */
 11.1016 -
 11.1017 -    /* Failed to create window from another window */
 11.1018 -    return -1;
 11.1019 -}
 11.1020 -
 11.1021 -void
 11.1022 -photon_setwindowtitle(_THIS, SDL_Window * window)
 11.1023 -{
 11.1024 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1025 -    int32_t status;
 11.1026 -
 11.1027 -    /* Set window title */
 11.1028 -    if (window->title != NULL) {
 11.1029 -        status =
 11.1030 -            PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, window->title,
 11.1031 -                          0);
 11.1032 -    } else {
 11.1033 -        status = PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, "", 0);
 11.1034 -    }
 11.1035 -
 11.1036 -    if (status != 0) {
 11.1037 -        SDL_SetError("Photon: Can't set window title");
 11.1038 -    }
 11.1039 -
 11.1040 -    /* Flush all widget operations */
 11.1041 -    PtFlush();
 11.1042 -}
 11.1043 -
 11.1044 -void
 11.1045 -photon_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon)
 11.1046 -{
 11.1047 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1048 -    int32_t status;
 11.1049 -
 11.1050 -    /* TODO: Use iconify ? */
 11.1051 -
 11.1052 -    /* Flush all widget operations */
 11.1053 -    PtFlush();
 11.1054 -}
 11.1055 -
 11.1056 -void
 11.1057 -photon_setwindowposition(_THIS, SDL_Window * window)
 11.1058 -{
 11.1059 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1060 -    SDL_DisplayData *didata =
 11.1061 -        (SDL_DisplayData *) window->display->driverdata;
 11.1062 -    PhPoint_t winpos;
 11.1063 -    int32_t status;
 11.1064 -
 11.1065 -    /* Check if upper level requests WM to position window */
 11.1066 -    if ((window->x == SDL_WINDOWPOS_UNDEFINED)
 11.1067 -        && (window->y == SDL_WINDOWPOS_UNDEFINED)) {
 11.1068 -        /* Do not set widget position, let WM to set it */
 11.1069 -    } else {
 11.1070 -        if (window->x == SDL_WINDOWPOS_UNDEFINED) {
 11.1071 -            window->x = 0;
 11.1072 -        }
 11.1073 -        if (window->y == SDL_WINDOWPOS_UNDEFINED) {
 11.1074 -            window->y = 0;
 11.1075 -        }
 11.1076 -        if (window->x == SDL_WINDOWPOS_CENTERED) {
 11.1077 -            window->x = (didata->current_mode.w - window->w) / 2;
 11.1078 -        }
 11.1079 -        if (window->y == SDL_WINDOWPOS_CENTERED) {
 11.1080 -            window->y = (didata->current_mode.h - window->h) / 2;
 11.1081 -        }
 11.1082 -
 11.1083 -        /* Now set window position */
 11.1084 -        winpos.x = window->x;
 11.1085 -        winpos.y = window->y;
 11.1086 -        status = PtSetResource(wdata->window, Pt_ARG_POS, &winpos, 0);
 11.1087 -        if (status != 0) {
 11.1088 -            SDL_SetError("Photon: Can't set window position");
 11.1089 -        }
 11.1090 -    }
 11.1091 -
 11.1092 -    /* Flush all widget operations */
 11.1093 -    PtFlush();
 11.1094 -}
 11.1095 -
 11.1096 -void
 11.1097 -photon_setwindowsize(_THIS, SDL_Window * window)
 11.1098 -{
 11.1099 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1100 -    PhDim_t winsize;
 11.1101 -    int32_t status;
 11.1102 -
 11.1103 -    winsize.w = window->w;
 11.1104 -    winsize.h = window->h;
 11.1105 -
 11.1106 -    status = PtSetResource(wdata->window, Pt_ARG_DIM, &winsize, 0);
 11.1107 -    if (status != 0) {
 11.1108 -        SDL_SetError("Photon: Can't set window size");
 11.1109 -    }
 11.1110 -
 11.1111 -    /* Flush all widget operations */
 11.1112 -    PtFlush();
 11.1113 -}
 11.1114 -
 11.1115 -void
 11.1116 -photon_showwindow(_THIS, SDL_Window * window)
 11.1117 -{
 11.1118 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1119 -    int32_t status;
 11.1120 -
 11.1121 -    /* Bring focus to window and put it in front of others */
 11.1122 -    PtWindowToFront(wdata->window);
 11.1123 -
 11.1124 -    /* Flush all widget operations */
 11.1125 -    PtFlush();
 11.1126 -}
 11.1127 -
 11.1128 -void
 11.1129 -photon_hidewindow(_THIS, SDL_Window * window)
 11.1130 -{
 11.1131 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1132 -    PhWindowEvent_t winevent;
 11.1133 -    int32_t status;
 11.1134 -
 11.1135 -    SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t));
 11.1136 -    winevent.event_f = Ph_WM_HIDE;
 11.1137 -    winevent.rid = PtWidgetRid(wdata->window);
 11.1138 -    winevent.event_state = Ph_WM_EVSTATE_HIDE;
 11.1139 -
 11.1140 -    status = PtForwardWindowEvent(&winevent);
 11.1141 -    if (status != 0) {
 11.1142 -        SDL_SetError("Photon: Can't hide window");
 11.1143 -    }
 11.1144 -
 11.1145 -    /* Flush all widget operations */
 11.1146 -    PtFlush();
 11.1147 -}
 11.1148 -
 11.1149 -void
 11.1150 -photon_raisewindow(_THIS, SDL_Window * window)
 11.1151 -{
 11.1152 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1153 -    PhWindowEvent_t winevent;
 11.1154 -    int32_t status;
 11.1155 -
 11.1156 -    SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t));
 11.1157 -    winevent.event_f = Ph_WM_HIDE;
 11.1158 -    winevent.rid = PtWidgetRid(wdata->window);
 11.1159 -    winevent.event_state = Ph_WM_EVSTATE_UNHIDE;
 11.1160 -
 11.1161 -    status = PtForwardWindowEvent(&winevent);
 11.1162 -    if (status != 0) {
 11.1163 -        SDL_SetError("Photon: Can't hide window");
 11.1164 -    }
 11.1165 -
 11.1166 -    /* Flush all widget operations */
 11.1167 -    PtFlush();
 11.1168 -}
 11.1169 -
 11.1170 -void
 11.1171 -photon_maximizewindow(_THIS, SDL_Window * window)
 11.1172 -{
 11.1173 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1174 -    PhWindowEvent_t winevent;
 11.1175 -    int32_t status;
 11.1176 -
 11.1177 -    /* Flush all widget operations */
 11.1178 -    PtFlush();
 11.1179 -}
 11.1180 -
 11.1181 -void
 11.1182 -photon_minimizewindow(_THIS, SDL_Window * window)
 11.1183 -{
 11.1184 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1185 -    PhWindowEvent_t winevent;
 11.1186 -    int32_t status;
 11.1187 -
 11.1188 -    SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t));
 11.1189 -    winevent.event_f = Ph_WM_HIDE;
 11.1190 -    winevent.rid = PtWidgetRid(wdata->window);
 11.1191 -    winevent.event_state = Ph_WM_EVSTATE_HIDE;
 11.1192 -
 11.1193 -    status = PtForwardWindowEvent(&winevent);
 11.1194 -    if (status != 0) {
 11.1195 -        SDL_SetError("Photon: Can't hide window");
 11.1196 -    }
 11.1197 -
 11.1198 -    /* Flush all widget operations */
 11.1199 -    PtFlush();
 11.1200 -}
 11.1201 -
 11.1202 -void
 11.1203 -photon_restorewindow(_THIS, SDL_Window * window)
 11.1204 -{
 11.1205 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1206 -    PhWindowEvent_t winevent;
 11.1207 -    int32_t status;
 11.1208 -
 11.1209 -    /* Flush all widget operations */
 11.1210 -    PtFlush();
 11.1211 -}
 11.1212 -
 11.1213 -void
 11.1214 -photon_setwindowgrab(_THIS, SDL_Window * window)
 11.1215 -{
 11.1216 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1217 -    PhWindowEvent_t winevent;
 11.1218 -    int32_t status;
 11.1219 -
 11.1220 -    /* Flush all widget operations */
 11.1221 -    PtFlush();
 11.1222 -}
 11.1223 -
 11.1224 -void
 11.1225 -photon_destroywindow(_THIS, SDL_Window * window)
 11.1226 -{
 11.1227 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
 11.1228 -    SDL_DisplayData *didata =
 11.1229 -        (SDL_DisplayData *) window->display->driverdata;
 11.1230 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1231 -    int32_t status;
 11.1232 -
 11.1233 -    if (wdata != NULL) {
 11.1234 -        status = PtDestroyWidget(wdata->window);
 11.1235 -        if (status != 0) {
 11.1236 -            SDL_SetError("Photon: Can't destroy window widget");
 11.1237 -        }
 11.1238 -        wdata->window = NULL;
 11.1239 -
 11.1240 -#if defined(SDL_VIDEO_OPENGL_ES)
 11.1241 -        if (phdata->gfinitialized == SDL_TRUE) {
 11.1242 -            /* Destroy photon handle to GF surface */
 11.1243 -            if (wdata->phsurface != NULL) {
 11.1244 -                PhDCRelease(wdata->phsurface);
 11.1245 -                wdata->phsurface=NULL;
 11.1246 -            }
 11.1247 -
 11.1248 -            /* Destroy OpenGL ES surface if it was created */
 11.1249 -            if (wdata->gles_surface != EGL_NO_SURFACE) {
 11.1250 -                eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
 11.1251 -            }
 11.1252 -
 11.1253 -            /* Free OpenGL ES target surface */
 11.1254 -            if (wdata->gfsurface != NULL) {
 11.1255 -                gf_surface_free(wdata->gfsurface);
 11.1256 -                wdata->gfsurface=NULL;
 11.1257 -            }
 11.1258 -
 11.1259 -            phdata->egl_refcount--;
 11.1260 -            if (phdata->egl_refcount == 0) {
 11.1261 -                /* Terminate connection to OpenGL ES */
 11.1262 -                if (phdata->egldisplay != EGL_NO_DISPLAY) {
 11.1263 -                    eglTerminate(phdata->egldisplay);
 11.1264 -                    phdata->egldisplay = EGL_NO_DISPLAY;
 11.1265 -                }
 11.1266 -            }
 11.1267 -        }
 11.1268 -#endif /* SDL_VIDEO_OPENGL_ES */
 11.1269 -    }
 11.1270 -
 11.1271 -    /* Flush all widget operations */
 11.1272 -    PtFlush();
 11.1273 -}
 11.1274 -
 11.1275 -/*****************************************************************************/
 11.1276 -/* SDL Window Manager function                                               */
 11.1277 -/*****************************************************************************/
 11.1278 -SDL_bool
 11.1279 -photon_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
 11.1280 -{
 11.1281 -    if (info->version.major <= SDL_MAJOR_VERSION) {
 11.1282 -        return SDL_TRUE;
 11.1283 -    } else {
 11.1284 -        SDL_SetError("application not compiled with SDL %d.%d\n",
 11.1285 -                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
 11.1286 -        return SDL_FALSE;
 11.1287 -    }
 11.1288 -
 11.1289 -    /* Failed to get window manager information */
 11.1290 -    return SDL_FALSE;
 11.1291 -}
 11.1292 -
 11.1293 -/*****************************************************************************/
 11.1294 -/* SDL OpenGL/OpenGL ES functions                                            */
 11.1295 -/*****************************************************************************/
 11.1296 -int
 11.1297 -photon_gl_loadlibrary(_THIS, const char *path)
 11.1298 -{
 11.1299 -#if defined(SDL_VIDEO_OPENGL_ES)
 11.1300 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
 11.1301 -
 11.1302 -    if (phdata->gfinitialized != SDL_TRUE) {
 11.1303 -        SDL_SetError
 11.1304 -            ("Photon: GF initialization failed, no OpenGL ES support");
 11.1305 -        return -1;
 11.1306 -    }
 11.1307 -
 11.1308 -    /* Check if OpenGL ES library is specified for GF driver */
 11.1309 -    if (path == NULL) {
 11.1310 -        path = SDL_getenv("SDL_OPENGL_LIBRARY");
 11.1311 -        if (path == NULL) {
 11.1312 -            path = SDL_getenv("SDL_OPENGLES_LIBRARY");
 11.1313 -        }
 11.1314 -    }
 11.1315 -
 11.1316 -    /* Check if default library loading requested */
 11.1317 -    if (path == NULL) {
 11.1318 -        /* Already linked with GF library which provides egl* subset of  */
 11.1319 -        /* functions, use Common profile of OpenGL ES library by default */
 11.1320 -        path = "/usr/lib/libGLES_CM.so.1";
 11.1321 -    }
 11.1322 -
 11.1323 -    /* Load dynamic library */
 11.1324 -    _this->gl_config.dll_handle = SDL_LoadObject(path);
 11.1325 -    if (!_this->gl_config.dll_handle) {
 11.1326 -        /* Failed to load new GL ES library */
 11.1327 -        SDL_SetError("Photon: Failed to locate OpenGL ES library");
 11.1328 -        return -1;
 11.1329 -    }
 11.1330 -
 11.1331 -    /* Store OpenGL ES library path and name */
 11.1332 -    SDL_strlcpy(_this->gl_config.driver_path, path,
 11.1333 -                SDL_arraysize(_this->gl_config.driver_path));
 11.1334 -
 11.1335 -    /* New OpenGL ES library is loaded */
 11.1336 -    return 0;
 11.1337 -#else
 11.1338 -    SDL_SetError("Photon: OpenGL ES support is not compiled in");
 11.1339 -    return -1;
 11.1340 -#endif /* SDL_VIDEO_OPENGL_ES */
 11.1341 -}
 11.1342 -
 11.1343 -void *
 11.1344 -photon_gl_getprocaddres(_THIS, const char *proc)
 11.1345 -{
 11.1346 -#if defined(SDL_VIDEO_OPENGL_ES)
 11.1347 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
 11.1348 -    void *function_address;
 11.1349 -
 11.1350 -    if (phdata->gfinitialized != SDL_TRUE) {
 11.1351 -        SDL_SetError
 11.1352 -            ("Photon: GF initialization failed, no OpenGL ES support");
 11.1353 -        return NULL;
 11.1354 -    }
 11.1355 -
 11.1356 -    /* Try to get function address through the egl interface */
 11.1357 -    function_address = eglGetProcAddress(proc);
 11.1358 -    if (function_address != NULL) {
 11.1359 -        return function_address;
 11.1360 -    }
 11.1361 -
 11.1362 -    /* Then try to get function in the OpenGL ES library */
 11.1363 -    if (_this->gl_config.dll_handle) {
 11.1364 -        function_address =
 11.1365 -            SDL_LoadFunction(_this->gl_config.dll_handle, proc);
 11.1366 -        if (function_address != NULL) {
 11.1367 -            return function_address;
 11.1368 -        }
 11.1369 -    }
 11.1370 -
 11.1371 -    /* Add emulated OpenGL ES 1.1 functions */
 11.1372 -    if (SDL_strcmp(proc, "glTexParameteri") == 0) {
 11.1373 -        return glTexParameteri;
 11.1374 -    }
 11.1375 -    if (SDL_strcmp(proc, "glTexParameteriv") == 0) {
 11.1376 -        return glTexParameteriv;
 11.1377 -    }
 11.1378 -    if (SDL_strcmp(proc, "glColor4ub") == 0) {
 11.1379 -        return glColor4ub;
 11.1380 -    }
 11.1381 -
 11.1382 -    /* Failed to get GL ES function address pointer */
 11.1383 -    SDL_SetError("Photon: Cannot locate OpenGL ES function name");
 11.1384 -    return NULL;
 11.1385 -#else
 11.1386 -    SDL_SetError("Photon: OpenGL ES support is not compiled in");
 11.1387 -    return NULL;
 11.1388 -#endif /* SDL_VIDEO_OPENGL_ES */
 11.1389 -}
 11.1390 -
 11.1391 -void
 11.1392 -photon_gl_unloadlibrary(_THIS)
 11.1393 -{
 11.1394 -#if defined(SDL_VIDEO_OPENGL_ES)
 11.1395 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
 11.1396 -
 11.1397 -    if (phdata->gfinitialized == SDL_TRUE) {
 11.1398 -        /* Unload OpenGL ES library */
 11.1399 -        if (_this->gl_config.dll_handle) {
 11.1400 -            SDL_UnloadObject(_this->gl_config.dll_handle);
 11.1401 -            _this->gl_config.dll_handle = NULL;
 11.1402 -        }
 11.1403 -    } else {
 11.1404 -        SDL_SetError
 11.1405 -            ("Photon: GF initialization failed, no OpenGL ES support");
 11.1406 -    }
 11.1407 -#else
 11.1408 -    SDL_SetError("Photon: OpenGL ES support is not compiled in");
 11.1409 -    return;
 11.1410 -#endif /* SDL_VIDEO_OPENGL_ES */
 11.1411 -}
 11.1412 -
 11.1413 -SDL_GLContext
 11.1414 -photon_gl_createcontext(_THIS, SDL_Window * window)
 11.1415 -{
 11.1416 -#if defined(SDL_VIDEO_OPENGL_ES)
 11.1417 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
 11.1418 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1419 -    SDL_DisplayData *didata =
 11.1420 -        (SDL_DisplayData *) window->display->driverdata;
 11.1421 -    EGLBoolean status;
 11.1422 -    int32_t gfstatus;
 11.1423 -    EGLint configs;
 11.1424 -    uint32_t attr_pos;
 11.1425 -    EGLint attr_value;
 11.1426 -    EGLint cit;
 11.1427 -
 11.1428 -    /* Check if GF was initialized */
 11.1429 -    if (phdata->gfinitialized != SDL_TRUE) {
 11.1430 -        SDL_SetError
 11.1431 -            ("Photon: GF initialization failed, no OpenGL ES support");
 11.1432 -        return NULL;
 11.1433 -    }
 11.1434 -
 11.1435 -    /* Prepare attributes list to pass them to OpenGL ES egl interface */
 11.1436 -    attr_pos = 0;
 11.1437 -    wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID;
 11.1438 -    wdata->gles_attributes[attr_pos++] =
 11.1439 -        qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format);
 11.1440 -    wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE;
 11.1441 -    wdata->gles_attributes[attr_pos++] = _this->gl_config.red_size;
 11.1442 -    wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE;
 11.1443 -    wdata->gles_attributes[attr_pos++] = _this->gl_config.green_size;
 11.1444 -    wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE;
 11.1445 -    wdata->gles_attributes[attr_pos++] = _this->gl_config.blue_size;
 11.1446 -    wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE;
 11.1447 -
 11.1448 -    /* Setup alpha size in bits */
 11.1449 -    if (_this->gl_config.alpha_size) {
 11.1450 -        wdata->gles_attributes[attr_pos++] = _this->gl_config.alpha_size;
 11.1451 -    } else {
 11.1452 -        wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1453 -    }
 11.1454 -
 11.1455 -    /* Setup color buffer size */
 11.1456 -    if (_this->gl_config.buffer_size) {
 11.1457 -        wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE;
 11.1458 -        wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size;
 11.1459 -    } else {
 11.1460 -        wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE;
 11.1461 -        wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1462 -    }
 11.1463 -
 11.1464 -    /* Setup depth buffer bits */
 11.1465 -    wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
 11.1466 -    if (_this->gl_config.depth_size)
 11.1467 -    {
 11.1468 -        wdata->gles_attributes[attr_pos++] = _this->gl_config.depth_size;
 11.1469 -    }
 11.1470 -    else
 11.1471 -    {
 11.1472 -        wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1473 -    }
 11.1474 -
 11.1475 -    /* Setup stencil bits */
 11.1476 -    if (_this->gl_config.stencil_size) {
 11.1477 -        wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
 11.1478 -        wdata->gles_attributes[attr_pos++] = _this->gl_config.stencil_size;
 11.1479 -    } else {
 11.1480 -        wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
 11.1481 -        wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1482 -    }
 11.1483 -
 11.1484 -    /* Set number of samples in multisampling */
 11.1485 -    if (_this->gl_config.multisamplesamples) {
 11.1486 -        wdata->gles_attributes[attr_pos++] = EGL_SAMPLES;
 11.1487 -        wdata->gles_attributes[attr_pos++] =
 11.1488 -            _this->gl_config.multisamplesamples;
 11.1489 -    }
 11.1490 -
 11.1491 -    /* Multisample buffers, OpenGL ES 1.0 spec defines 0 or 1 buffer */
 11.1492 -    if (_this->gl_config.multisamplebuffers) {
 11.1493 -        wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS;
 11.1494 -        wdata->gles_attributes[attr_pos++] =
 11.1495 -            _this->gl_config.multisamplebuffers;
 11.1496 -    }
 11.1497 -
 11.1498 -    /* Finish attributes list */
 11.1499 -    wdata->gles_attributes[attr_pos] = EGL_NONE;
 11.1500 -
 11.1501 -    /* Request first suitable framebuffer configuration */
 11.1502 -    status = eglChooseConfig(phdata->egldisplay, wdata->gles_attributes,
 11.1503 -                             wdata->gles_configs, SDL_VIDEO_GF_OPENGLES_CONFS,
 11.1504 -                             &configs);
 11.1505 -    if (status != EGL_TRUE) {
 11.1506 -        SDL_SetError
 11.1507 -            ("Photon: Can't find closest configuration for OpenGL ES");
 11.1508 -        return NULL;
 11.1509 -    }
 11.1510 -
 11.1511 -    /* Check if nothing has been found, try "don't care" settings */
 11.1512 -    if (configs == 0) {
 11.1513 -        int32_t it;
 11.1514 -        int32_t jt;
 11.1515 -        static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE };
 11.1516 -
 11.1517 -        for (it = 0; it < 4; it++) {
 11.1518 -            for (jt = 16; jt >= 0; jt--) {
 11.1519 -                /* Don't care about color buffer bits, use what exist */
 11.1520 -                /* Replace previous set data with EGL_DONT_CARE       */
 11.1521 -                attr_pos = 0;
 11.1522 -                wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID;
 11.1523 -                wdata->gles_attributes[attr_pos++] =
 11.1524 -                    qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format);
 11.1525 -                wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE;
 11.1526 -                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1527 -                wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE;
 11.1528 -                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1529 -                wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE;
 11.1530 -                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1531 -                wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE;
 11.1532 -                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1533 -                wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE;
 11.1534 -                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1535 -
 11.1536 -                /* Try to find requested or smallest depth */
 11.1537 -                if (_this->gl_config.depth_size) {
 11.1538 -                    wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
 11.1539 -                    wdata->gles_attributes[attr_pos++] = depthbits[it];
 11.1540 -                } else {
 11.1541 -                    wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
 11.1542 -                    wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1543 -                }
 11.1544 -
 11.1545 -                if (_this->gl_config.stencil_size) {
 11.1546 -                    wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
 11.1547 -                    wdata->gles_attributes[attr_pos++] = jt;
 11.1548 -                } else {
 11.1549 -                    wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
 11.1550 -                    wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1551 -                }
 11.1552 -
 11.1553 -                wdata->gles_attributes[attr_pos++] = EGL_SAMPLES;
 11.1554 -                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1555 -                wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS;
 11.1556 -                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
 11.1557 -                wdata->gles_attributes[attr_pos] = EGL_NONE;
 11.1558 -
 11.1559 -                /* Request first suitable framebuffer configuration */
 11.1560 -                status =
 11.1561 -                    eglChooseConfig(phdata->egldisplay,
 11.1562 -                                    wdata->gles_attributes,
 11.1563 -                                    wdata->gles_configs,
 11.1564 -                                    SDL_VIDEO_GF_OPENGLES_CONFS, &configs);
 11.1565 -                if (status != EGL_TRUE) {
 11.1566 -                    SDL_SetError
 11.1567 -                        ("Photon: Can't find closest configuration for OpenGL ES");
 11.1568 -                    return NULL;
 11.1569 -                }
 11.1570 -                if (configs != 0) {
 11.1571 -                    break;
 11.1572 -                }
 11.1573 -            }
 11.1574 -            if (configs != 0) {
 11.1575 -                break;
 11.1576 -            }
 11.1577 -        }
 11.1578 -
 11.1579 -        /* No available configs */
 11.1580 -        if (configs == 0) {
 11.1581 -            SDL_SetError
 11.1582 -                ("Photon: Can't find any configuration for OpenGL ES");
 11.1583 -            return NULL;
 11.1584 -        }
 11.1585 -    }
 11.1586 -
 11.1587 -    /* Initialize config index */
 11.1588 -    wdata->gles_config = 0;
 11.1589 -
 11.1590 -    /* Now check each configuration to find out the best */
 11.1591 -    for (cit = 0; cit < configs; cit++) {
 11.1592 -        uint32_t stencil_found;
 11.1593 -        uint32_t depth_found;
 11.1594 -        EGLint   cur_depth;
 11.1595 -        EGLint   cur_stencil;
 11.1596 -
 11.1597 -        stencil_found = 0;
 11.1598 -        depth_found = 0;
 11.1599 -
 11.1600 -        if (_this->gl_config.stencil_size) {
 11.1601 -            status =
 11.1602 -                eglGetConfigAttrib(phdata->egldisplay,
 11.1603 -                                   wdata->gles_configs[cit], EGL_STENCIL_SIZE,
 11.1604 -                                   &cur_stencil);
 11.1605 -            if (status == EGL_TRUE) {
 11.1606 -                if (cur_stencil != 0) {
 11.1607 -                    stencil_found = 1;
 11.1608 -                }
 11.1609 -            }
 11.1610 -        } else {
 11.1611 -            stencil_found = 1;
 11.1612 -        }
 11.1613 -
 11.1614 -        if (_this->gl_config.depth_size) {
 11.1615 -            status =
 11.1616 -                eglGetConfigAttrib(phdata->egldisplay,
 11.1617 -                                   wdata->gles_configs[cit], EGL_DEPTH_SIZE,
 11.1618 -                                   &cur_depth);
 11.1619 -            if (status == EGL_TRUE) {
 11.1620 -                if (cur_depth != 0) {
 11.1621 -                    depth_found = 1;
 11.1622 -                }
 11.1623 -            }
 11.1624 -        } else {
 11.1625 -            depth_found = 1;
 11.1626 -        }
 11.1627 -
 11.1628 -        /* Exit from loop if found appropriate configuration */
 11.1629 -        if ((depth_found != 0) && (stencil_found != 0)) {
 11.1630 -            /* Store last satisfied configuration id */
 11.1631 -            wdata->gles_config = cit;
 11.1632 -
 11.1633 -            if (cur_depth==_this->gl_config.depth_size)
 11.1634 -            {
 11.1635 -                /* Exact match on depth bits */
 11.1636 -                if (!_this->gl_config.stencil_size)
 11.1637 -                {
 11.1638 -                    /* Stencil is not required */
 11.1639 -                    break;
 11.1640 -                }
 11.1641 -                else
 11.1642 -                {
 11.1643 -                    if (cur_stencil==_this->gl_config.stencil_size)
 11.1644 -                    {
 11.1645 -                        /* Exact match on stencil bits */
 11.1646 -                        break;
 11.1647 -                    }
 11.1648 -                }
 11.1649 -            }
 11.1650 -        }
 11.1651 -    }
 11.1652 -
 11.1653 -    /* If best could not be found, use first or last satisfied */
 11.1654 -    if ((cit == configs) && (wdata->gles_config==0)) {
 11.1655 -        cit = 0;
 11.1656 -        wdata->gles_config = cit;
 11.1657 -    }
 11.1658 -
 11.1659 -    /* Create OpenGL ES context */
 11.1660 -    wdata->gles_context =
 11.1661 -        eglCreateContext(phdata->egldisplay,
 11.1662 -                         wdata->gles_configs[wdata->gles_config],
 11.1663 -                         EGL_NO_CONTEXT, NULL);
 11.1664 -    if (wdata->gles_context == EGL_NO_CONTEXT) {
 11.1665 -        SDL_SetError("Photon: OpenGL ES context creation has been failed");
 11.1666 -        return NULL;
 11.1667 -    }
 11.1668 -
 11.1669 -    /* Check if surface is exist */
 11.1670 -    if (wdata->gfsurface != NULL) {
 11.1671 -        gf_surface_free(wdata->gfsurface);
 11.1672 -        wdata->gfsurface = NULL;
 11.1673 -    }
 11.1674 -
 11.1675 -    /* Create GF surface */
 11.1676 -    gfstatus =
 11.1677 -        gf_surface_create(&wdata->gfsurface, phdata->gfdev, window->w,
 11.1678 -                          window->h,
 11.1679 -                          qnxgf_sdl_to_gf_pixelformat(didata->current_mode.
 11.1680 -                                                      format), NULL,
 11.1681 -                          GF_SURFACE_CREATE_2D_ACCESSIBLE |
 11.1682 -                          GF_SURFACE_CREATE_3D_ACCESSIBLE |
 11.1683 -                          GF_SURFACE_CREATE_SHAREABLE);
 11.1684 -    if (gfstatus != GF_ERR_OK) {
 11.1685 -        eglDestroyContext(phdata->egldisplay, wdata->gles_context);
 11.1686 -        wdata->gles_context = EGL_NO_CONTEXT;
 11.1687 -        SDL_SetError("Photon: Can't create GF 3D surface (%08X)", gfstatus);
 11.1688 -        return NULL;
 11.1689 -    }
 11.1690 -
 11.1691 -    /* Create pixmap 3D target surface */
 11.1692 -    wdata->gles_surface =
 11.1693 -        eglCreatePixmapSurface(phdata->egldisplay,
 11.1694 -                               wdata->gles_configs[wdata->gles_config],
 11.1695 -                               wdata->gfsurface, NULL);
 11.1696 -    if (wdata->gles_surface == EGL_NO_SURFACE) {
 11.1697 -        gf_surface_free(wdata->gfsurface);
 11.1698 -        wdata->gfsurface=NULL;
 11.1699 -        eglDestroyContext(phdata->egldisplay, wdata->gles_context);
 11.1700 -        wdata->gles_context = EGL_NO_CONTEXT;
 11.1701 -        SDL_SetError("Photon: Can't create EGL pixmap surface");
 11.1702 -        return NULL;
 11.1703 -    }
 11.1704 -
 11.1705 -    /* Store last used context and surface */
 11.1706 -    phdata->lgles_surface=wdata->gles_surface;
 11.1707 -    phdata->lgles_context=wdata->gles_context;
 11.1708 -
 11.1709 -    /* Make just created context current */
 11.1710 -    status =
 11.1711 -        eglMakeCurrent(phdata->egldisplay, wdata->gles_surface,
 11.1712 -                       wdata->gles_surface, wdata->gles_context);
 11.1713 -    if (status != EGL_TRUE) {
 11.1714 -        /* Reset last used context and surface */
 11.1715 -        phdata->lgles_surface=EGL_NO_SURFACE;
 11.1716 -        phdata->lgles_context=EGL_NO_CONTEXT;
 11.1717 -
 11.1718 -        /* Destroy OpenGL ES surface */
 11.1719 -        eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
 11.1720 -        wdata->gles_surface=EGL_NO_SURFACE;
 11.1721 -        gf_surface_free(wdata->gfsurface);
 11.1722 -        wdata->gfsurface=NULL;
 11.1723 -        eglDestroyContext(phdata->egldisplay, wdata->gles_context);
 11.1724 -        wdata->gles_context = EGL_NO_CONTEXT;
 11.1725 -        SDL_SetError("Photon: Can't set OpenGL ES context on creation");
 11.1726 -        return NULL;
 11.1727 -    }
 11.1728 -
 11.1729 -    /* Setup into SDL internals state of OpenGL ES:  */
 11.1730 -    /* it is accelerated or not                      */
 11.1731 -    if ((didata->caps & SDL_PHOTON_ACCELERATED_3D) ==
 11.1732 -        SDL_PHOTON_ACCELERATED_3D) {
 11.1733 -        _this->gl_config.accelerated = 1;
 11.1734 -    } else {
 11.1735 -        _this->gl_config.accelerated = 0;
 11.1736 -    }
 11.1737 -
 11.1738 -    /* Always clear stereo enable, since OpenGL ES do not supports stereo */
 11.1739 -    _this->gl_config.stereo = 0;
 11.1740 -
 11.1741 -    /* Get back samples and samplebuffers configurations. Rest framebuffer */
 11.1742 -    /* parameters could be obtained through the OpenGL ES API              */
 11.1743 -    status =
 11.1744 -        eglGetConfigAttrib(phdata->egldisplay,
 11.1745 -                           wdata->gles_configs[wdata->gles_config],
 11.1746 -                           EGL_SAMPLES, &attr_value);
 11.1747 -    if (status == EGL_TRUE) {
 11.1748 -        _this->gl_config.multisamplesamples = attr_value;
 11.1749 -    }
 11.1750 -    status =
 11.1751 -        eglGetConfigAttrib(phdata->egldisplay,
 11.1752 -                           wdata->gles_configs[wdata->gles_config],
 11.1753 -                           EGL_SAMPLE_BUFFERS, &attr_value);
 11.1754 -    if (status == EGL_TRUE) {
 11.1755 -        _this->gl_config.multisamplebuffers = attr_value;
 11.1756 -    }
 11.1757 -
 11.1758 -    /* Get back stencil and depth buffer sizes */
 11.1759 -    status =
 11.1760 -        eglGetConfigAttrib(phdata->egldisplay,
 11.1761 -                           wdata->gles_configs[wdata->gles_config],
 11.1762 -                           EGL_DEPTH_SIZE, &attr_value);
 11.1763 -    if (status == EGL_TRUE) {
 11.1764 -        _this->gl_config.depth_size = attr_value;
 11.1765 -    }
 11.1766 -    status =
 11.1767 -        eglGetConfigAttrib(phdata->egldisplay,
 11.1768 -                           wdata->gles_configs[wdata->gles_config],
 11.1769 -                           EGL_STENCIL_SIZE, &attr_value);
 11.1770 -    if (status == EGL_TRUE) {
 11.1771 -        _this->gl_config.stencil_size = attr_value;
 11.1772 -    }
 11.1773 -
 11.1774 -    /* Under Photon OpenGL ES output can't be double buffered */
 11.1775 -    _this->gl_config.double_buffer = 0;
 11.1776 -
 11.1777 -    /* Check if current device is not the same as target */
 11.1778 -    if (phdata->current_device_id != didata->device_id) {
 11.1779 -        /* Set target device as default for Pd and Pg functions */
 11.1780 -        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
 11.1781 -        if (status != 0) {
 11.1782 -            /* Destroy OpenGL ES surface */
 11.1783 -            eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
 11.1784 -            wdata->gles_surface=EGL_NO_SURFACE;
 11.1785 -            gf_surface_free(wdata->gfsurface);
 11.1786 -            wdata->gfsurface=NULL;
 11.1787 -            eglDestroyContext(phdata->egldisplay, wdata->gles_context);
 11.1788 -            wdata->gles_context = EGL_NO_CONTEXT;
 11.1789 -            SDL_SetError("Photon: Can't set default target device\n");
 11.1790 -            return NULL;
 11.1791 -        }
 11.1792 -        phdata->current_device_id = didata->device_id;
 11.1793 -    }
 11.1794 -
 11.1795 -    wdata->phsurface = PdCreateOffscreenContextGF(wdata->gfsurface);
 11.1796 -    if (wdata->phsurface == NULL) {
 11.1797 -        /* Destroy OpenGL ES surface */
 11.1798 -        eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
 11.1799 -        wdata->gles_surface=EGL_NO_SURFACE;
 11.1800 -        gf_surface_free(wdata->gfsurface);
 11.1801 -        wdata->gfsurface=NULL;
 11.1802 -        eglDestroyContext(phdata->egldisplay, wdata->gles_context);
 11.1803 -        wdata->gles_context = EGL_NO_CONTEXT;
 11.1804 -        SDL_SetError("Photon: Can't bind GF surface to Photon\n");
 11.1805 -        return NULL;
 11.1806 -    }
 11.1807 -
 11.1808 -    /* GL ES context was successfully created */
 11.1809 -    return wdata->gles_context;
 11.1810 -#else
 11.1811 -    SDL_SetError("Photon: OpenGL ES support is not compiled in");
 11.1812 -    return NULL;
 11.1813 -#endif /* SDL_VIDEO_OPENGL_ES */
 11.1814 -}
 11.1815 -
 11.1816 -int
 11.1817 -photon_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context)
 11.1818 -{
 11.1819 -#if defined(SDL_VIDEO_OPENGL_ES)
 11.1820 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
 11.1821 -    SDL_WindowData *wdata;
 11.1822 -    EGLBoolean status;
 11.1823 -
 11.1824 -    if (phdata->gfinitialized != SDL_TRUE) {
 11.1825 -        SDL_SetError
 11.1826 -            ("Photon: GF initialization failed, no OpenGL ES support");
 11.1827 -        return -1;
 11.1828 -    }
 11.1829 -
 11.1830 -    if ((window == NULL) && (context == NULL)) {
 11.1831 -        /* Reset last used context and surface */
 11.1832 -        phdata->lgles_surface=EGL_NO_SURFACE;
 11.1833 -        phdata->lgles_context=EGL_NO_CONTEXT;
 11.1834 -
 11.1835 -        /* Unset current context */
 11.1836 -        status =
 11.1837 -            eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
 11.1838 -                           EGL_NO_CONTEXT);
 11.1839 -        if (status != EGL_TRUE) {
 11.1840 -            /* Failed to set current GL ES context */
 11.1841 -            SDL_SetError("Photon: Can't empty current OpenGL ES context");
 11.1842 -            return -1;
 11.1843 -        }
 11.1844 -    } else {
 11.1845 -        wdata = (SDL_WindowData *) window->driverdata;
 11.1846 -        if (wdata->gles_surface == EGL_NO_SURFACE) {
 11.1847 -            SDL_SetError
 11.1848 -                ("Photon: OpenGL ES surface is not initialized for this window");
 11.1849 -            return -1;
 11.1850 -        }
 11.1851 -        if (wdata->gles_context == EGL_NO_CONTEXT) {
 11.1852 -            SDL_SetError
 11.1853 -                ("Photon: OpenGL ES context is not initialized for this window");
 11.1854 -            return -1;
 11.1855 -        }
 11.1856 -        if (wdata->gles_context != context) {
 11.1857 -            SDL_SetError
 11.1858 -                ("Photon: OpenGL ES context is not belong to this window");
 11.1859 -            return -1;
 11.1860 -        }
 11.1861 -
 11.1862 -        /* Store last set surface and context */
 11.1863 -        phdata->lgles_surface=wdata->gles_surface;
 11.1864 -        phdata->lgles_context=wdata->gles_context;
 11.1865 -
 11.1866 -        /* Set new current context */
 11.1867 -        status =
 11.1868 -            eglMakeCurrent(phdata->egldisplay, wdata->gles_surface,
 11.1869 -                           wdata->gles_surface, wdata->gles_context);
 11.1870 -        if (status != EGL_TRUE) {
 11.1871 -            /* Reset last used context and surface */
 11.1872 -            phdata->lgles_surface=EGL_NO_SURFACE;
 11.1873 -            phdata->lgles_context=EGL_NO_CONTEXT;
 11.1874 -            /* Failed to set current GL ES context */
 11.1875 -            SDL_SetError("Photon: Can't set OpenGL ES context");
 11.1876 -            return -1;
 11.1877 -        }
 11.1878 -    }
 11.1879 -
 11.1880 -    return 0;
 11.1881 -#else
 11.1882 -    SDL_SetError("Photon: OpenGL ES support is not compiled in");
 11.1883 -    return -1;
 11.1884 -#endif /* SDL_VIDEO_OPENGL_ES */
 11.1885 -}
 11.1886 -
 11.1887 -int
 11.1888 -photon_gl_setswapinterval(_THIS, int interval)
 11.1889 -{
 11.1890 -#if defined(SDL_VIDEO_OPENGL_ES)
 11.1891 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
 11.1892 -    EGLBoolean status;
 11.1893 -
 11.1894 -    if (phdata->gfinitialized != SDL_TRUE) {
 11.1895 -        SDL_SetError
 11.1896 -            ("Photon: GF initialization failed, no OpenGL ES support");
 11.1897 -        return -1;
 11.1898 -    }
 11.1899 -
 11.1900 -    /* Check if OpenGL ES connection has been initialized */
 11.1901 -    if (phdata->egldisplay != EGL_NO_DISPLAY) {
 11.1902 -        /* Set swap OpenGL ES interval */
 11.1903 -        status = eglSwapInterval(phdata->egldisplay, interval);
 11.1904 -        if (status == EGL_TRUE) {
 11.1905 -            /* Return success to upper level */
 11.1906 -            phdata->swapinterval = interval;
 11.1907 -            return 0;
 11.1908 -        }
 11.1909 -    }
 11.1910 -
 11.1911 -    /* Failed to set swap interval */
 11.1912 -    SDL_SetError("Photon: Cannot set swap interval");
 11.1913 -    return -1;
 11.1914 -#else
 11.1915 -    SDL_SetError("Photon: OpenGL ES support is not compiled in");
 11.1916 -    return -1;
 11.1917 -#endif /* SDL_VIDEO_OPENGL_ES */
 11.1918 -}
 11.1919 -
 11.1920 -int
 11.1921 -photon_gl_getswapinterval(_THIS)
 11.1922 -{
 11.1923 -#if defined(SDL_VIDEO_OPENGL_ES)
 11.1924 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
 11.1925 -
 11.1926 -    if (phdata->gfinitialized != SDL_TRUE) {
 11.1927 -        SDL_SetError
 11.1928 -            ("Photon: GF initialization failed, no OpenGL ES support");
 11.1929 -        return -1;
 11.1930 -    }
 11.1931 -
 11.1932 -    /* Return default swap interval value */
 11.1933 -    return phdata->swapinterval;
 11.1934 -#else
 11.1935 -    SDL_SetError("Photon: OpenGL ES support is not compiled in");
 11.1936 -    return -1;
 11.1937 -#endif /* SDL_VIDEO_OPENGL_ES */
 11.1938 -}
 11.1939 -
 11.1940 -void
 11.1941 -photon_gl_swapwindow(_THIS, SDL_Window * window)
 11.1942 -{
 11.1943 -#if defined(SDL_VIDEO_OPENGL_ES)
 11.1944 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
 11.1945 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.1946 -    SDL_DisplayData *didata =
 11.1947 -        (SDL_DisplayData *) window->display->driverdata;
 11.1948 -    PhRect_t dst_rect;
 11.1949 -    PhRect_t src_rect;
 11.1950 -    int32_t status;
 11.1951 -
 11.1952 -    if (phdata->gfinitialized != SDL_TRUE) {
 11.1953 -        SDL_SetError
 11.1954 -            ("Photon: GF initialization failed, no OpenGL ES support");
 11.1955 -        return;
 11.1956 -    }
 11.1957 -
 11.1958 -    if (wdata->phsurface==NULL) {
 11.1959 -        SDL_SetError
 11.1960 -            ("Photon: Photon OpenGL ES surface is not initialized");
 11.1961 -        return;
 11.1962 -    }
 11.1963 -
 11.1964 -    /* Many applications do not uses glFinish(), so we call it for them */
 11.1965 -    glFinish();
 11.1966 -
 11.1967 -    /* Wait until OpenGL ES rendering is completed */
 11.1968 -    eglWaitGL();
 11.1969 -
 11.1970 -    /* Wait for VSYNC manually, if it was enabled */
 11.1971 -    if (phdata->swapinterval != 0) {
 11.1972 -        /* Wait for VSYNC, we use GF function, since Photon requires */
 11.1973 -        /* to enter to the Direct mode to call PgWaitVSync()         */
 11.1974 -        gf_display_wait_vsync(didata->display);
 11.1975 -    }
 11.1976 -
 11.1977 -    /* Set blit area */
 11.1978 -    dst_rect = *PtGetCanvas(wdata->window);
 11.1979 -    src_rect.ul.x = 0;
 11.1980 -    src_rect.ul.y = 0;
 11.1981 -    src_rect.lr.x = window->w - 1;
 11.1982 -    src_rect.lr.y = window->h - 1;
 11.1983 -
 11.1984 -    /* Check if current device is not the same as target */
 11.1985 -    if (phdata->current_device_id != didata->device_id) {
 11.1986 -        /* Set target device as default for Pd and Pg functions */
 11.1987 -        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
 11.1988 -        if (status != 0) {
 11.1989 -            SDL_SetError("Photon: Can't set default target device\n");
 11.1990 -            return;
 11.1991 -        }
 11.1992 -        phdata->current_device_id = didata->device_id;
 11.1993 -    }
 11.1994 -
 11.1995 -    /* Blit OpenGL ES pixmap surface directly to window region */
 11.1996 -    PgFFlush(Ph_START_DRAW);
 11.1997 -    PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window));
 11.1998 -    PgClearTranslationCx(PgGetGCCx(PhDCGetCurrent()));
 11.1999 -    PgContextBlit(wdata->phsurface, &src_rect, NULL, &dst_rect);
 11.2000 -    PgFFlush(Ph_DONE_DRAW);
 11.2001 -    PgWaitHWIdle();
 11.2002 -
 11.2003 -    eglSwapBuffers(phdata->egldisplay, wdata->gles_surface);
 11.2004 -#else
 11.2005 -    SDL_SetError("Photon: OpenGL ES support is not compiled in");
 11.2006 -    return;
 11.2007 -#endif /* SDL_VIDEO_OPENGL_ES */
 11.2008 -}
 11.2009 -
 11.2010 -void
 11.2011 -photon_gl_deletecontext(_THIS, SDL_GLContext context)
 11.2012 -{
 11.2013 -#if defined(SDL_VIDEO_OPENGL_ES)
 11.2014 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
 11.2015 -    EGLBoolean status;
 11.2016 -
 11.2017 -    if (phdata->gfinitialized != SDL_TRUE) {
 11.2018 -        SDL_SetError
 11.2019 -            ("Photon: GF initialization failed, no OpenGL ES support");
 11.2020 -        return;
 11.2021 -    }
 11.2022 -
 11.2023 -    /* Check if OpenGL ES connection has been initialized */
 11.2024 -    if (phdata->egldisplay != EGL_NO_DISPLAY) {
 11.2025 -        if (context != EGL_NO_CONTEXT) {
 11.2026 -            /* Check if we are destroying current active context */
 11.2027 -            if (phdata->lgles_context==context) {
 11.2028 -                /* Release current context */
 11.2029 -                eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 11.2030 -                phdata->lgles_context=EGL_NO_CONTEXT;
 11.2031 -                phdata->lgles_surface=EGL_NO_SURFACE;
 11.2032 -            }
 11.2033 -            status = eglDestroyContext(phdata->egldisplay, context);
 11.2034 -            if (status != EGL_TRUE) {
 11.2035 -                /* Error during OpenGL ES context destroying */
 11.2036 -                SDL_SetError("Photon: OpenGL ES context destroy error");
 11.2037 -                return;
 11.2038 -            }
 11.2039 -        }
 11.2040 -    }
 11.2041 -
 11.2042 -    return;
 11.2043 -#else
 11.2044 -    SDL_SetError("Photon: OpenGL ES support is not compiled in");
 11.2045 -    return;
 11.2046 -#endif /* SDL_VIDEO_OPENGL_ES */
 11.2047 -}
 11.2048 -
 11.2049 -/* Helper function, which re-creates surface, not an API */
 11.2050 -int photon_gl_recreatesurface(_THIS, SDL_Window * window, uint32_t width, uint32_t height)
 11.2051 -{
 11.2052 -#if defined(SDL_VIDEO_OPENGL_ES)
 11.2053 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
 11.2054 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 11.2055 -    SDL_DisplayData *didata =
 11.2056 -        (SDL_DisplayData *) window->display->driverdata;
 11.2057 -    SDL_bool makecurrent=SDL_FALSE;
 11.2058 -    int32_t gfstatus;
 11.2059 -
 11.2060 -    /* Check if context has been initialized */
 11.2061 -    if (wdata->gles_context == EGL_NO_CONTEXT) {
 11.2062 -        /* If no, abort surface re-creating */
 11.2063 -        return -1;
 11.2064 -    }
 11.2065 -
 11.2066 -    /* Check if last used surface the same as one which must be re-created */
 11.2067 -    if (phdata->lgles_surface == wdata->gles_surface) {
 11.2068 -        makecurrent=SDL_TRUE;
 11.2069 -        /* Flush all current drawings */
 11.2070 -        glFinish();
 11.2071 -        /* Wait until OpenGL ES rendering is completed */
 11.2072 -        eglWaitGL();
 11.2073 -        /* Release current context */
 11.2074 -        eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 11.2075 -        phdata->lgles_surface=EGL_NO_SURFACE;
 11.2076 -    }
 11.2077 -
 11.2078 -    /* Check if we need to destroy previous surface */
 11.2079 -    if (wdata->gles_surface != EGL_NO_SURFACE) {
 11.2080 -        /* Destroy photon handle to GF surface */
 11.2081 -        if (wdata->phsurface != NULL) {
 11.2082 -            PhDCRelease(wdata->phsurface);
 11.2083 -            wdata->phsurface=NULL;
 11.2084 -        }
 11.2085 -
 11.2086 -        /* Destroy previous surface */
 11.2087 -        eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
 11.2088 -
 11.2089 -        /* Set surface to uninitialized */
 11.2090 -        wdata->gles_surface = EGL_NO_SURFACE;
 11.2091 -
 11.2092 -        if (wdata->gfsurface!=NULL) {
 11.2093 -           gf_surface_free(wdata->gfsurface);
 11.2094 -           wdata->gfsurface=NULL;
 11.2095 -        }
 11.2096 -    }
 11.2097 -
 11.2098 -    /* Create new GF surface */
 11.2099 -    gfstatus =
 11.2100 -        gf_surface_create(&wdata->gfsurface, phdata->gfdev, width,
 11.2101 -                          height,
 11.2102 -                          qnxgf_sdl_to_gf_pixelformat(didata->current_mode.
 11.2103 -                                                      format), NULL,
 11.2104 -                          GF_SURFACE_CREATE_2D_ACCESSIBLE |
 11.2105 -                          GF_SURFACE_CREATE_3D_ACCESSIBLE |
 11.2106 -                          GF_SURFACE_CREATE_SHAREABLE);
 11.2107 -    if (gfstatus != GF_ERR_OK) {
 11.2108 -        SDL_SetError("Photon: Can't create GF 3D surface (%08X)", gfstatus);
 11.2109 -        return -1;
 11.2110 -    }
 11.2111 -
 11.2112 -    /* Create new pixmap 3D target surface */
 11.2113 -    wdata->gles_surface =
 11.2114 -        eglCreatePixmapSurface(phdata->egldisplay,
 11.2115 -                               wdata->gles_configs[wdata->gles_config],
 11.2116 -                               wdata->gfsurface, NULL);
 11.2117 -    if (wdata->gles_surface == EGL_NO_SURFACE) {
 11.2118 -        gf_surface_free(wdata->gfsurface);
 11.2119 -        wdata->gfsurface=NULL;
 11.2120 -        SDL_SetError("Photon: Can't create EGL pixmap surface");
 11.2121 -        return -1;
 11.2122 -    }
 11.2123 -
 11.2124 -    wdata->phsurface = PdCreateOffscreenContextGF(wdata->gfsurface);
 11.2125 -    if (wdata->phsurface == NULL) {
 11.2126 -        /* Destroy OpenGL ES surface */
 11.2127 -        eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
 11.2128 -        wdata->gles_surface=EGL_NO_SURFACE;
 11.2129 -        gf_surface_free(wdata->gfsurface);
 11.2130 -        wdata->gfsurface=NULL;
 11.2131 -        SDL_SetError("Photon: Can't bind GF surface to Photon\n");
 11.2132 -        return -1;
 11.2133 -    }
 11.2134 -
 11.2135 -    /* Check if we need to set this surface and context as current */
 11.2136 -    if (makecurrent == SDL_TRUE) {
 11.2137 -        return photon_gl_makecurrent(_this, window, wdata->gles_context);
 11.2138 -    } else {
 11.2139 -        return 0;
 11.2140 -    }
 11.2141 -#else
 11.2142 -    /* Do nothing, if OpenGL ES support is not compiled in */
 11.2143 -    return 0;
 11.2144 -#endif /* SDL_VIDEO_OPENGL_ES */
 11.2145 -}
 11.2146 -
 11.2147 -/*****************************************************************************/
 11.2148 -/* SDL Event handling function                                               */
 11.2149 -/*****************************************************************************/
 11.2150 -void
 11.2151 -photon_pumpevents(_THIS)
 11.2152 -{
 11.2153 -    uint8_t eventbuffer[SDL_VIDEO_PHOTON_EVENT_SIZE];
 11.2154 -    PhEvent_t *event = (PhEvent_t *) eventbuffer;
 11.2155 -    int32_t status;
 11.2156 -    uint32_t finish = 0;
 11.2157 -    SDL_Window *window;
 11.2158 -    SDL_WindowData *wdata;
 11.2159 -
 11.2160 -    do {
 11.2161 -        status = PhEventPeek(event, SDL_VIDEO_PHOTON_EVENT_SIZE);
 11.2162 -        switch (status) {
 11.2163 -        case Ph_RESIZE_MSG:
 11.2164 -            {
 11.2165 -                SDL_SetError("Photon: Event size too much for buffer");
 11.2166 -                return;
 11.2167 -            }
 11.2168 -            break;
 11.2169 -        case Ph_EVENT_MSG:
 11.2170 -            {
 11.2171 -                /* Find a window, to which this handle destinated */
 11.2172 -                status = 0;
 11.2173 -                for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) {
 11.2174 -                    SDL_VideoDisplay *display = SDL_GetVideoDisplay(i);
 11.2175 -                    for (j = 0; j < display->num_windows; ++j) {
 11.2176 -                        wdata = (SDL_WindowData *) display->windows[j].driverdata;
 11.2177 -
 11.2178 -                        /* Find the proper window */
 11.2179 -                        if (wdata->window != NULL) {
 11.2180 -                            if (PtWidgetRid(wdata->window) ==
 11.2181 -                                event->collector.rid) {
 11.2182 -                                window = (SDL_Window *) &display->windows[it];
 11.2183 -                                status = 1;
 11.2184 -                                break;
 11.2185 -                            }
 11.2186 -                        } else {
 11.2187 -                            continue;
 11.2188 -                        }
 11.2189 -                    }
 11.2190 -                }
 11.2191 -                if (status == 0) {
 11.2192 -                    window = NULL;
 11.2193 -                    wdata = NULL;
 11.2194 -                }
 11.2195 -
 11.2196 -                /* Event is ready */
 11.2197 -                switch (event->type) {
 11.2198 -                case Ph_EV_BOUNDARY:
 11.2199 -                    {
 11.2200 -                        switch (event->subtype) {
 11.2201 -                        case Ph_EV_PTR_ENTER:
 11.2202 -                            {
 11.2203 -                                /* Mouse cursor over handled window */
 11.2204 -                                if (window != NULL) {
 11.2205 -                                    SDL_SendWindowEvent(window,
 11.2206 -                                                        SDL_WINDOWEVENT_ENTER,
 11.2207 -                                                        0, 0);
 11.2208 -                                    SDL_SetMouseFocus(0, window);
 11.2209 -                                }
 11.2210 -                            }
 11.2211 -                            break;
 11.2212 -                        case Ph_EV_PTR_LEAVE:
 11.2213 -                            {
 11.2214 -                                /* Mouse cursor out of handled window */
 11.2215 -                                if (window != NULL) {
 11.2216 -                                    SDL_SendWindowEvent(window,
 11.2217 -                                                        SDL_WINDOWEVENT_LEAVE,
 11.2218 -                                                        0, 0);
 11.2219 -                                }
 11.2220 -                            }
 11.2221 -                            break;
 11.2222 -                        }
 11.2223 -                    }
 11.2224 -                    break;
 11.2225 -                case Ph_EV_PTR_MOTION_BUTTON:
 11.2226 -                case Ph_EV_PTR_MOTION_NOBUTTON:
 11.2227 -                    {
 11.2228 -                        PhPointerEvent_t *pevent = NULL;
 11.2229 -                        PhRect_t *prects = NULL;
 11.2230 -
 11.2231 -                        /* Get event data */
 11.2232 -                        pevent = PhGetData(event);
 11.2233 -                        /* Get associated event rectangles */
 11.2234 -                        prects = PhGetRects(event);
 11.2235 -                        if ((pevent != NULL) && (prects != NULL)) {
 11.2236 -                            SDL_SendMouseMotion(0, 0, prects->ul.x,
 11.2237 -                                                prects->ul.y, 0);
 11.2238 -                        }
 11.2239 -                    }
 11.2240 -                    break;
 11.2241 -                case Ph_EV_BUT_PRESS:
 11.2242 -                    {
 11.2243 -                        /* Button press event */
 11.2244 -                        PhPointerEvent_t *pevent = NULL;
 11.2245 -                        uint32_t sdlbutton = 0x00000000;
 11.2246 -
 11.2247 -                        /* Get event data */
 11.2248 -                        pevent = PhGetData(event);
 11.2249 -                        if (pevent != NULL) {
 11.2250 -                            for (it = 0; it < sizeof(pevent->buttons) * 8;
 11.2251 -                                 it++) {
 11.2252 -                                if ((pevent->buttons & (0x0001 << it)) ==
 11.2253 -                                    (0x0001 << it)) {
 11.2254 -                                    switch (it) {
 11.2255 -                                    case 0:
 11.2256 -                                        {
 11.2257 -                                            sdlbutton = SDL_BUTTON_RIGHT;
 11.2258 -                                        }
 11.2259 -                                        break;
 11.2260 -                                    case 1:
 11.2261 -                                        {
 11.2262 -                                            sdlbutton = SDL_BUTTON_MIDDLE;
 11.2263 -                                        }
 11.2264 -                                        break;
 11.2265 -                                    case 2:
 11.2266 -                                        {
 11.2267 -                                            sdlbutton = SDL_BUTTON_LEFT;
 11.2268 -                                        }
 11.2269 -                                        break;
 11.2270 -                                    default:
 11.2271 -                                        {
 11.2272 -                                            sdlbutton = it + 1;
 11.2273 -                                        }
 11.2274 -                                        break;
 11.2275 -                                    }
 11.2276 -                                    SDL_SendMouseButton(0, SDL_PRESSED,
 11.2277 -                                                        sdlbutton);
 11.2278 -                                }
 11.2279 -                            }
 11.2280 -                        }
 11.2281 -                    }
 11.2282 -                    break;
 11.2283 -                case Ph_EV_BUT_RELEASE:
 11.2284 -                    {
 11.2285 -                        /* Button press event */
 11.2286 -                        PhPointerEvent_t *pevent = NULL;
 11.2287 -                        uint32_t sdlbutton = 0x00000000;
 11.2288 -
 11.2289 -                        /* Get event data */
 11.2290 -                        pevent = PhGetData(event);
 11.2291 -                        if (pevent != NULL) {
 11.2292 -                            for (it = 0; it < sizeof(pevent->buttons) * 8;
 11.2293 -                                 it++) {
 11.2294 -                                if ((pevent->buttons & (0x0001 << it)) ==
 11.2295 -                                    (0x0001 << it)) {
 11.2296 -                                    switch (it) {
 11.2297 -                                    case 0:
 11.2298 -                                        {
 11.2299 -                                            sdlbutton = SDL_BUTTON_RIGHT;
 11.2300 -                                        }
 11.2301 -                                        break;
 11.2302 -                                    case 1:
 11.2303 -                                        {
 11.2304 -                                            sdlbutton = SDL_BUTTON_MIDDLE;
 11.2305 -                                        }
 11.2306 -                                        break;
 11.2307 -                                    case 2:
 11.2308 -                                        {
 11.2309 -                                            sdlbutton = SDL_BUTTON_LEFT;
 11.2310 -                                        }
 11.2311 -                                        break;
 11.2312 -                                    default:
 11.2313 -                                        {
 11.2314 -                                            sdlbutton = it + 1;
 11.2315 -                                        }
 11.2316 -                                        break;
 11.2317 -                                    }
 11.2318 -                                }
 11.2319 -                            }
 11.2320 -                        }
 11.2321 -
 11.2322 -                        switch (event->subtype) {
 11.2323 -                        case Ph_EV_RELEASE_REAL:
 11.2324 -                            {
 11.2325 -                                /* Real release button event */
 11.2326 -                                SDL_SendMouseButton(0, SDL_RELEASED,
 11.2327 -                                                    sdlbutton);
 11.2328 -                            }
 11.2329 -                            break;
 11.2330 -                        case Ph_EV_RELEASE_PHANTOM:
 11.2331 -                            {
 11.2332 -                                /* We will get phantom button release */
 11.2333 -                                /* event in case if it was unpressed  */
 11.2334 -                                /* outside of window                  */
 11.2335 -                                if (window != NULL) {
 11.2336 -                                    if ((window->
 11.2337 -                                         flags & SDL_WINDOW_MOUSE_FOCUS) !=
 11.2338 -                                        SDL_WINDOW_MOUSE_FOCUS) {
 11.2339 -                                        /* Send phantom button release */
 11.2340 -                                        SDL_SendMouseButton(0, SDL_RELEASED,
 11.2341 -                                                            sdlbutton);
 11.2342 -                                    }
 11.2343 -                                }
 11.2344 -                            }
 11.2345 -                            break;
 11.2346 -                        }
 11.2347 -                    }
 11.2348 -                    break;
 11.2349 -                case Ph_EV_EXPOSE:
 11.2350 -                    {
 11.2351 -                        switch (event->subtype) {
 11.2352 -                        case Ph_NORMAL_EXPOSE:
 11.2353 -                            {
 11.2354 -                                PhRect_t *rects = NULL;
 11.2355 -
 11.2356 -                                /* Get array of rectangles to be updated */
 11.2357 -                                rects = PhGetRects(event);
 11.2358 -                                if (rects == NULL) {
 11.2359 -                                    break;
 11.2360 -                                }
 11.2361 -
 11.2362 -                                /* Check if expose come to one of the our windows */
 11.2363 -                                if ((wdata != NULL) && (window != NULL)) {
 11.2364 -                                    /* Check if window uses OpenGL ES */
 11.2365 -                                    if (wdata->uses_gles == SDL_TRUE) {
 11.2366 -                                        #if defined(SDL_VIDEO_OPENGL_ES)
 11.2367 -                                        /* Cycle through each rectangle */
 11.2368 -                                        for (it = 0; it < event->num_rects; it++) {
 11.2369 -                                            /* Blit OpenGL ES pixmap surface directly to window region */
 11.2370 -                                            PgFFlush(Ph_START_DRAW);
 11.2371 -                                            PgSetRegionCx(PhDCGetCurrent(),
 11.2372 -                                                          PtWidgetRid(wdata->
 11.2373 -                                                                      window));
 11.2374 -                                            PgClearTranslationCx(PgGetGCCx
 11.2375 -                                                                 (PhDCGetCurrent
 11.2376 -                                                                  ()));
 11.2377 -                                            PgContextBlit(wdata->phsurface,
 11.2378 -                                                          &rects[it], NULL,
 11.2379 -                                                          &rects[it]);
 11.2380 -                                            PgFFlush(Ph_DONE_DRAW);
 11.2381 -                                            PgWaitHWIdle();
 11.2382 -                                        }
 11.2383 -                                        #endif /* SDL_VIDEO_OPENGL_ES */
 11.2384 -                                    } else {
 11.2385 -                                        /* Cycle through each rectangle */
 11.2386 -                                        for (it = 0; it < event->num_rects;
 11.2387 -                                             it++) {
 11.2388 -                                            /* Blit 2D pixmap surface directly to window region */
 11.2389 -                                            _photon_update_rectangles(window->renderer, &rects[it]);
 11.2390 -                                        }
 11.2391 -                                        PgFlush();
 11.2392 -                                        PgWaitHWIdle();
 11.2393 -                                    }
 11.2394 -                                }
 11.2395 -
 11.2396 -                                /* Flush all blittings */
 11.2397 -                                PgFlush();
 11.2398 -                            }
 11.2399 -                            break;
 11.2400 -                        case Ph_CAPTURE_EXPOSE:
 11.2401 -                            {
 11.2402 -                                /* Check if expose come to one of the our windows */
 11.2403 -                                if ((wdata != NULL) && (window != NULL)) {
 11.2404 -                                    /* Check if window uses OpenGL ES */
 11.2405 -                                    if (wdata->uses_gles == SDL_TRUE) {
 11.2406 -                                        PhRect_t dst_rect;
 11.2407 -                                        PhRect_t src_rect;
 11.2408 -
 11.2409 -                                        /* Set blit area */
 11.2410 -                                        dst_rect =
 11.2411 -                                            *PtGetCanvas(wdata->window);
 11.2412 -                                        src_rect.ul.x = 0;
 11.2413 -                                        src_rect.ul.y = 0;
 11.2414 -                                        src_rect.lr.x = window->w - 1;
 11.2415 -                                        src_rect.lr.y = window->h - 1;
 11.2416 -
 11.2417 -                                        #if defined(SDL_VIDEO_OPENGL_ES)
 11.2418 -                                        /* We need to redraw entire window */
 11.2419 -                                        PgFFlush(Ph_START_DRAW);
 11.2420 -                                        PgSetRegionCx(PhDCGetCurrent(),
 11.2421 -                                                      PtWidgetRid(wdata->
 11.2422 -                                                                  window));
 11.2423 -                                        PgClearTranslationCx(PgGetGCCx
 11.2424 -                                                             (PhDCGetCurrent
 11.2425 -                                                              ()));
 11.2426 -                                        PgContextBlit(wdata->phsurface,
 11.2427 -                                                      &src_rect, NULL,
 11.2428 -                                                      &dst_rect);
 11.2429 -                                        PgFFlush(Ph_DONE_DRAW);
 11.2430 -                                        PgWaitHWIdle();
 11.2431 -                                        #endif /* SDL_VIDEO_OPENGL_ES */
 11.2432 -                                    } else {
 11.2433 -                                        PhRect_t rect;
 11.2434 -
 11.2435 -                                        /* We need to redraw entire window */
 11.2436 -                                        rect.ul.x = 0;
 11.2437 -                                        rect.ul.y = 0;
 11.2438 -                                        rect.lr.x = window->w - 1;
 11.2439 -                                        rect.lr.y = window->h - 1;
 11.2440 -
 11.2441 -                                        /* Blit 2D pixmap surface directly to window region */
 11.2442 -                                        PgFFlush(Ph_START_DRAW);
 11.2443 -                                        _photon_update_rectangles(window->renderer, &rect);
 11.2444 -                                        PgFFlush(Ph_DONE_DRAW);
 11.2445 -                                        PgWaitHWIdle();
 11.2446 -                                    }
 11.2447 -                                }
 11.2448 -                            }
 11.2449 -                            break;
 11.2450 -                        case Ph_GRAPHIC_EXPOSE:
 11.2451 -                            {
 11.2452 -                                /* TODO: What this event means ? */
 11.2453 -                            }
 11.2454 -                            break;
 11.2455 -                        }
 11.2456 -                    }
 11.2457 -                    break;
 11.2458 -                case Ph_EV_INFO:
 11.2459 -                    {
 11.2460 -                        switch (event->subtype)
 11.2461 -                        {
 11.2462 -                           case Ph_OFFSCREEN_INVALID:
 11.2463 -                                {
 11.2464 -                                   uint32_t* type;
 11.2465 -
 11.2466 -                                   type = PhGetData(event);
 11.2467 -                                   switch (*type)
 11.2468 -                                   {
 11.2469 -                                      case Pg_VIDEO_MODE_SWITCHED:
 11.2470 -                                      case Pg_ENTERED_DIRECT:
 11.2471 -                                      case Pg_EXITED_DIRECT:
 11.2472 -                                      case Pg_DRIVER_STARTED:
 11.2473 -                                           {
 11.2474 -                                               /* TODO: */
 11.2475 -                                               /* We must tell the renderer, that it have */
 11.2476 -                                               /* to recreate all surfaces                */
 11.2477 -                                           }
 11.2478 -                                           break;
 11.2479 -                                      default:
 11.2480 -                                           {
 11.2481 -                                           }
 11.2482 -                                           break;
 11.2483 -                                   }
 11.2484 -                                }
 11.2485 -                                break;
 11.2486 -                           default:
 11.2487 -                                break;
 11.2488 -                        }
 11.2489 -                    }
 11.2490 -                    break;
 11.2491 -                case Ph_EV_KEY:
 11.2492 -                    {
 11.2493 -                        PhKeyEvent_t *keyevent = NULL;
 11.2494 -                        SDL_ScanCode scancode = SDL_SCANCODE_UNKNOWN;
 11.2495 -                        SDL_bool pressed = SDL_FALSE;
 11.2496 -
 11.2497 -                        keyevent = PhGetData(event);
 11.2498 -                        if (keyevent == NULL) {
 11.2499 -                            break;
 11.2500 -                        }
 11.2501 -
 11.2502 -                        /* Check if key is repeated */
 11.2503 -                        if ((keyevent->key_flags & Pk_KF_Key_Repeat) ==
 11.2504 -                            Pk_KF_Key_Repeat) {
 11.2505 -                            /* Ignore such events */
 11.2506 -                            break;
 11.2507 -                        }
 11.2508 -
 11.2509 -                        /* Check if key has its own scancode */
 11.2510 -                        if ((keyevent->key_flags & Pk_KF_Scan_Valid) ==
 11.2511 -                            Pk_KF_Scan_Valid) {
 11.2512 -                            if ((keyevent->key_flags & Pk_KF_Key_Down) ==
 11.2513 -                                Pk_KF_Key_Down) {
 11.2514 -                                pressed = SDL_TRUE;
 11.2515 -                            } else {
 11.2516 -                                pressed = SDL_FALSE;
 11.2517 -                            }
 11.2518 -                            scancode =
 11.2519 -                                photon_to_sdl_keymap(keyevent->key_scan);
 11.2520 -
 11.2521 -                            /* Add details for the pressed key */
 11.2522 -                            if ((keyevent->key_flags & Pk_KF_Cap_Valid) ==
 11.2523 -                                Pk_KF_Cap_Valid) {
 11.2524 -                                switch (keyevent->key_cap) {
 11.2525 -                                case Pk_Hyper_R:       /* Right windows flag key */
 11.2526 -                                    scancode = SDL_SCANCODE_RGUI;
 11.2527 -                                    break;
 11.2528 -                                case Pk_Control_R:     /* Right Ctrl key */
 11.2529 -                                    scancode = SDL_SCANCODE_RCTRL;
 11.2530 -                                    break;
 11.2531 -                                case Pk_Alt_R: /* Right Alt key */
 11.2532 -                                    scancode = SDL_SCANCODE_RALT;
 11.2533 -                                    break;
 11.2534 -                                case Pk_Up:    /* Up key but with invalid scan */
 11.2535 -                                    if (scancode != SDL_SCANCODE_UP) {
 11.2536 -                                        /* This is a mouse wheel event */
 11.2537 -                                        SDL_SendMouseWheel(0, 0, 1);
 11.2538 -                                        return;
 11.2539 -                                    }
 11.2540 -                                    break;
 11.2541 -                                case Pk_KP_8:  /* Up arrow or 8 on keypad */
 11.2542 -                                    scancode = SDL_SCANCODE_KP_8;
 11.2543 -                                    break;
 11.2544 -                                case Pk_Down:  /* Down key but with invalid scan */
 11.2545 -                                    if (scancode != SDL_SCANCODE_DOWN) {
 11.2546 -                                        /* This is a mouse wheel event */
 11.2547 -                                        SDL_SendMouseWheel(0, 0, -1);
 11.2548 -                                        return;
 11.2549 -                                    }
 11.2550 -                                    break;
 11.2551 -                                case Pk_KP_2:  /* Down arrow or 2 on keypad */
 11.2552 -                                    scancode = SDL_SCANCODE_KP_2;
 11.2553 -                                    break;
 11.2554 -                                case Pk_Left:  /* Left arrow key */
 11.2555 -                                    scancode = SDL_SCANCODE_LEFT;
 11.2556 -                                    break;
 11.2557 -                                case Pk_KP_4:  /* Left arrow or 4 on keypad */
 11.2558 -                                    scancode = SDL_SCANCODE_KP_4;
 11.2559 -                                    break;
 11.2560 -                                case Pk_Right: /* Right arrow key */
 11.2561 -                                    scancode = SDL_SCANCODE_RIGHT;
 11.2562 -                                    break;
 11.2563 -                                case Pk_KP_6:  /* Right arrow or 6 on keypad */
 11.2564 -                                    scancode = SDL_SCANCODE_KP_6;
 11.2565 -                                    break;
 11.2566 -                                case Pk_Insert:        /* Insert key */
 11.2567 -                                    scancode = SDL_SCANCODE_INSERT;
 11.2568 -                                    break;
 11.2569 -                                case Pk_KP_0:  /* Insert or 0 on keypad */
 11.2570 -                                    scancode = SDL_SCANCODE_KP_0;
 11.2571 -                                    break;
 11.2572 -                                case Pk_Home:  /* Home key */
 11.2573 -                                    scancode = SDL_SCANCODE_HOME;
 11.2574 -                                    break;
 11.2575 -                                case Pk_KP_7:  /* Home or 7 on keypad */
 11.2576 -                                    scancode = SDL_SCANCODE_KP_7;
 11.2577 -                                    break;
 11.2578 -                                case Pk_Pg_Up: /* PageUp key */
 11.2579 -                                    scancode = SDL_SCANCODE_PAGEUP;
 11.2580 -                                    break;
 11.2581 -                                case Pk_KP_9:  /* PgUp or 9 on keypad */
 11.2582 -                                    scancode = SDL_SCANCODE_KP_9;
 11.2583 -                                    break;
 11.2584 -                                case Pk_Delete:        /* Delete key */
 11.2585 -                                    scancode = SDL_SCANCODE_DELETE;
 11.2586 -                                    break;
 11.2587 -                                case Pk_KP_Decimal:    /* Del or . on keypad */
 11.2588 -                                    scancode = SDL_SCANCODE_KP_PERIOD;
 11.2589 -                                    break;
 11.2590 -                                case Pk_End:   /* End key */
 11.2591 -                                    scancode = SDL_SCANCODE_END;
 11.2592 -                                    break;
 11.2593 -                                case Pk_KP_1:  /* End or 1 on keypad */
 11.2594 -                                    scancode = SDL_SCANCODE_KP_1;
 11.2595 -                                    break;
 11.2596 -                                case Pk_Pg_Down:       /* PageDown key */
 11.2597 -                                    scancode = SDL_SCANCODE_PAGEDOWN;
 11.2598 -                                    break;
 11.2599 -                                case Pk_KP_3:  /* PgDn or 3 on keypad */
 11.2600 -                                    scancode = SDL_SCANCODE_KP_3;
 11.2601 -                                    break;
 11.2602 -                                case Pk_KP_5:  /* 5 on keypad */
 11.2603 -                                    scancode = SDL_SCANCODE_KP_5;
 11.2604 -                                    break;
 11.2605 -                                case Pk_KP_Enter:
 11.2606 -                                    scancode = SDL_SCANCODE_KP_ENTER;
 11.2607 -                                    break;
 11.2608 -                                case Pk_KP_Add:
 11.2609 -                                    scancode = SDL_SCANCODE_KP_PLUS;
 11.2610 -                                    break;
 11.2611 -                                case Pk_KP_Subtract:
 11.2612 -                                    scancode = SDL_SCANCODE_KP_MINUS;
 11.2613 -                                    break;
 11.2614 -                                case Pk_KP_Multiply:
 11.2615 -                                    scancode = SDL_SCANCODE_KP_MULTIPLY;
 11.2616 -                                    break;
 11.2617 -                                case Pk_KP_Divide:
 11.2618 -                                    scancode = SDL_SCANCODE_KP_DIVIDE;
 11.2619 -                                    break;
 11.2620 -                                case Pk_Pause:
 11.2621 -                                    scancode = SDL_SCANCODE_PAUSE;
 11.2622 -                                    break;
 11.2623 -                                }
 11.2624 -                            }
 11.2625 -
 11.2626 -                            /* Finally check if scancode has been decoded */
 11.2627 -                            if (scancode == SDL_SCANCODE_UNKNOWN) {
 11.2628 -                                /* Something was pressed, which is not supported */
 11.2629 -                                break;
 11.2630 -                            }
 11.2631 -
 11.2632 -                            /* Report pressed/released key to SDL */
 11.2633 -                            if (pressed == SDL_TRUE) {
 11.2634 -                                SDL_SendKeyboardKey(0, SDL_PRESSED, scancode);
 11.2635 -                            } else {
 11.2636 -                                SDL_SendKeyboardKey(0, SDL_RELEASED,
 11.2637 -                                                    scancode);
 11.2638 -                            }
 11.2639 -
 11.2640 -                            /* Photon doesn't send a release event for PrnScr key */
 11.2641 -                            if ((scancode == SDL_SCANCODE_PRINTSCREEN)
 11.2642 -                                && (pressed)) {
 11.2643 -                                SDL_SendKeyboardKey(0, SDL_RELEASED,
 11.2644 -                                                    scancode);
 11.2645 -                            }
 11.2646 -
 11.2647 -                        }
 11.2648 -
 11.2649 -                        /* Handle UTF-8 text input if requested by caller */
 11.2650 -                        if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY))
 11.2651 -                        {
 11.2652 -                            char text[5];
 11.2653 -
 11.2654 -                            SDL_memset(text, 0x00, 5);
 11.2655 -                            if (PhKeyToMb(text, keyevent)!=-1)
 11.2656 -                            {
 11.2657 -                                SDL_SendKeyboardText(0, text);
 11.2658 -                            }
 11.2659 -                            else
 11.2660 -                            {
 11.2661 -                                /* Just do nothing if it is not a UTF-8 character */
 11.2662 -                            }
 11.2663 -                        }
 11.2664 -                    }
 11.2665 -                    break;
 11.2666 -                case Ph_EV_SERVICE:
 11.2667 -                    {
 11.2668 -                    }
 11.2669 -                    break;
 11.2670 -                case Ph_EV_SYSTEM:
 11.2671 -                    {
 11.2672 -                    }
 11.2673 -                    break;
 11.2674 -                case Ph_EV_WM:
 11.2675 -                    {
 11.2676 -                        PhWindowEvent_t *wmevent = NULL;
 11.2677 -
 11.2678 -                        /* Get associated event data */
 11.2679 -                        wmevent = PhGetData(event);
 11.2680 -                        if (wmevent == NULL) {
 11.2681 -                            break;
 11.2682 -                        }
 11.2683 -
 11.2684 -                        switch (wmevent->event_f) {
 11.2685 -                        case Ph_WM_CLOSE:
 11.2686 -                            {
 11.2687 -                                if (window != NULL) {
 11.2688 -                                    SDL_SendWindowEvent(window,
 11.2689 -                                                        SDL_WINDOWEVENT_CLOSE,
 11.2690 -                                                        0, 0);
 11.2691 -                                }
 11.2692 -                            }
 11.2693 -                            break;
 11.2694 -                        case Ph_WM_FOCUS:
 11.2695 -                            {
 11.2696 -                                if (wmevent->event_state ==
 11.2697 -                                    Ph_WM_EVSTATE_FOCUS) {
 11.2698 -                                    if (window != NULL) {
 11.2699 -                                        PhRegion_t wregion;
 11.2700 -
 11.2701 -                                        SDL_SendWindowEvent(window,
 11.2702 -                                                            SDL_WINDOWEVENT_FOCUS_GAINED,
 11.2703 -                                                            0, 0);
 11.2704 -                                        SDL_SetKeyboardFocus(0, window);
 11.2705 -
 11.2706 -                                        /* Set window region sensible to mouse motion events */
 11.2707 -                                        PhRegionQuery(PtWidgetRid
 11.2708 -                                                      (wdata->window),
 11.2709 -                                                      &wregion, NULL, NULL,
 11.2710 -                                                      0);
 11.2711 -                                        wregion.events_sense |=
 11.2712 -                                            Ph_EV_PTR_MOTION_BUTTON |
 11.2713 -                                            Ph_EV_PTR_MOTION_NOBUTTON;
 11.2714 -                                        PhRegionChange(Ph_REGION_EV_SENSE, 0,
 11.2715 -                                                       &wregion, NULL, NULL);
 11.2716 -
 11.2717 -                                        /* If window got a focus, then it is visible */
 11.2718 -                                        SDL_SendWindowEvent(window,
 11.2719 -                                                            SDL_WINDOWEVENT_SHOWN,
 11.2720 -                                                            0, 0);
 11.2721 -                                    }
 11.2722 -                                }
 11.2723 -                                if (wmevent->event_state ==
 11.2724 -                                    Ph_WM_EVSTATE_FOCUSLOST) {
 11.2725 -                                    if (window != NULL) {
 11.2726 -                                        PhRegion_t wregion;
 11.2727 -
 11.2728 -                                        SDL_SendWindowEvent(window,
 11.2729 -                                                            SDL_WINDOWEVENT_FOCUS_LOST,
 11.2730 -                                                            0, 0);
 11.2731 -
 11.2732 -                                        /* Set window region ignore mouse motion events */
 11.2733 -                                        PhRegionQuery(PtWidgetRid
 11.2734 -                                                      (wdata->window),
 11.2735 -                                                      &wregion, NULL, NULL,
 11.2736 -                                                      0);
 11.2737 -                                        wregion.events_sense &=
 11.2738 -                                            ~(Ph_EV_PTR_MOTION_BUTTON |
 11.2739 -                                              Ph_EV_PTR_MOTION_NOBUTTON);
 11.2740 -                                        PhRegionChange(Ph_REGION_EV_SENSE, 0,
 11.2741 -                                                       &wregion, NULL, NULL);
 11.2742 -                                    }
 11.2743 -                                }
 11.2744 -                            }
 11.2745 -                            break;
 11.2746 -                        case Ph_WM_MOVE:
 11.2747 -                            {
 11.2748 -                                if (window != NULL) {
 11.2749 -                                    SDL_SendWindowEvent(window,
 11.2750 -                                                        SDL_WINDOWEVENT_MOVED,
 11.2751 -                                                        wmevent->pos.x,
 11.2752 -                                                        wmevent->pos.y);
 11.2753 -                                }
 11.2754 -                            }
 11.2755 -                            break;
 11.2756 -                        case Ph_WM_RESIZE:
 11.2757 -                            {
 11.2758 -                                if (window != NULL) {
 11.2759 -                                    /* Set new window position after resize */
 11.2760 -                                    SDL_SendWindowEvent(window,
 11.2761 -                                                        SDL_WINDOWEVENT_MOVED,
 11.2762 -                                                        wmevent->pos.x,
 11.2763 -                                                        wmevent->pos.y);
 11.2764 -
 11.2765 -                                    /* Check if this window uses OpenGL ES */
 11.2766 -                                    if (wdata->uses_gles == SDL_TRUE) {
 11.2767 -                                        /* If so, recreate surface with new dimensions */
 11.2768 -                                        photon_gl_recreatesurface(_this, window, wmevent->size.w, wmevent->size.h);
 11.2769 -                                    }
 11.2770 -
 11.2771 -                                    /* Set new window size after resize */
 11.2772 -                                    SDL_SendWindowEvent(window,
 11.2773 -                                                        SDL_WINDOWEVENT_RESIZED,
 11.2774 -                                                        wmevent->size.w,
 11.2775 -                                                        wmevent->size.h);
 11.2776 -                                }
 11.2777 -                            }
 11.2778 -                            break;
 11.2779 -                        case Ph_WM_HIDE:
 11.2780 -                            {
 11.2781 -                                if (window != NULL) {
 11.2782 -                                    /* Send new window state: minimized */
 11.2783 -                                    SDL_SendWindowEvent(window,
 11.2784 -                                                        SDL_WINDOWEVENT_MINIMIZED,
 11.2785 -                                                        0, 0);
 11.2786 -                                    /* In case window is minimized, then it is hidden */
 11.2787 -                                    SDL_SendWindowEvent(window,
 11.2788 -                                                        SDL_WINDOWEVENT_HIDDEN,
 11.2789 -                                                        0, 0);
 11.2790 -                                }
 11.2791 -                            }
 11.2792 -                            break;
 11.2793 -                        case Ph_WM_MAX:
 11.2794 -                            {
 11.2795 -                                if (window != NULL) {
 11.2796 -                                    if ((window->flags & SDL_WINDOW_RESIZABLE)==SDL_WINDOW_RESIZABLE)
 11.2797 -                                    {
 11.2798 -                                       SDL_SendWindowEvent(window,
 11.2799 -                                                           SDL_WINDOWEVENT_MAXIMIZED,
 11.2800 -                                                           0, 0);
 11.2801 -                                    }
 11.2802 -                                    else
 11.2803 -                                    {
 11.2804 -                                       /* otherwise ignor the resize events */
 11.2805 -                                    }
 11.2806 -                                }
 11.2807 -                            }
 11.2808 -                            break;
 11.2809 -                        case Ph_WM_RESTORE:
 11.2810 -                            {
 11.2811 -                                if (window != NULL) {
 11.2812 -                                    SDL_SendWindowEvent(window,
 11.2813 -                                                        SDL_WINDOWEVENT_RESTORED,
 11.2814 -                                                        0, 0);
 11.2815 -                                }
 11.2816 -                            }
 11.2817 -                            break;
 11.2818 -                        }
 11.2819 -                    }
 11.2820 -                    break;
 11.2821 -                }
 11.2822 -                PtEventHandler(event);
 11.2823 -            }
 11.2824 -            break;
 11.2825 -        case 0:
 11.2826 -            {
 11.2827 -                /* All events are read */
 11.2828 -                finish = 1;
 11.2829 -                break;
 11.2830 -            }
 11.2831 -        case -1:
 11.2832 -            {
 11.2833 -                /* Error occured in event reading */
 11.2834 -                SDL_SetError("Photon: Can't read event");
 11.2835 -                return;
 11.2836 -            }
 11.2837 -            break;
 11.2838 -        }
 11.2839 -        if (finish != 0) {
 11.2840 -            break;
 11.2841 -        }
 11.2842 -    } while (1);
 11.2843 -}
 11.2844 -
 11.2845 -/*****************************************************************************/
 11.2846 -/* SDL screen saver related functions                                        */
 11.2847 -/*****************************************************************************/
 11.2848 -void
 11.2849 -photon_suspendscreensaver(_THIS)
 11.2850 -{
 11.2851 -    /* There is no screensaver in pure console, it may exist when running */
 11.2852 -    /* GF under Photon, but I do not know, how to disable screensaver     */
 11.2853 -}
 11.2854 -
 11.2855 -/* vi: set ts=4 sw=4 expandtab: */
    12.1 --- a/src/video/photon/SDL_photon.h	Tue Feb 01 21:23:43 2011 -0800
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,178 +0,0 @@
    12.4 -/*
    12.5 -    SDL - Simple DirectMedia Layer
    12.6 -    Copyright (C) 1997-2010 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 Lesser General Public
   12.10 -    License as published by the Free Software Foundation; either
   12.11 -    version 2.1 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 -    Lesser General Public License for more details.
   12.17 -
   12.18 -    You should have received a copy of the GNU Lesser General Public
   12.19 -    License along with this library; if not, write to the Free Software
   12.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   12.21 -
   12.22 -    Sam Lantinga
   12.23 -    slouken@libsdl.org
   12.24 -
   12.25 -    QNX Photon GUI SDL driver
   12.26 -    Copyright (C) 2009 Mike Gorchak
   12.27 -    (mike@malva.ua, lestat@i.com.ua)
   12.28 -*/
   12.29 -
   12.30 -#ifndef __SDL_PHOTON_H__
   12.31 -#define __SDL_PHOTON_H__
   12.32 -
   12.33 -/* GF headers must be included first for the Photon GF functions */
   12.34 -#if defined(SDL_VIDEO_OPENGL_ES)
   12.35 -#include <gf/gf.h>
   12.36 -#include <GLES/egl.h>
   12.37 -#endif /* SDL_VIDEO_OPENGL_ES */
   12.38 -
   12.39 -#include "SDL_config.h"
   12.40 -#include "../SDL_sysvideo.h"
   12.41 -
   12.42 -#include <Ph.h>
   12.43 -#include <Pt.h>
   12.44 -#include <photon/PkKeyDef.h>
   12.45 -
   12.46 -/* Maximum display devices, which can handle SDL Photon driver */
   12.47 -#define SDL_VIDEO_PHOTON_MAX_RIDS 16
   12.48 -
   12.49 -typedef struct SDL_VideoData
   12.50 -{
   12.51 -    PhRid_t rid[SDL_VIDEO_PHOTON_MAX_RIDS];
   12.52 -    uint32_t avail_rids;
   12.53 -    uint32_t current_device_id;
   12.54 -#if defined(SDL_VIDEO_OPENGL_ES)
   12.55 -    gf_dev_t gfdev;             /* GF device handle                     */
   12.56 -    gf_dev_info_t gfdev_info;   /* GF device information                */
   12.57 -    SDL_bool gfinitialized;     /* GF device initialization status      */
   12.58 -    EGLDisplay egldisplay;      /* OpenGL ES display connection         */
   12.59 -    uint32_t egl_refcount;      /* OpenGL ES reference count            */
   12.60 -    uint32_t swapinterval;      /* OpenGL ES default swap interval      */
   12.61 -    EGLContext lgles_context;   /* Last used OpenGL ES context          */
   12.62 -    EGLSurface lgles_surface;   /* Last used OpenGL ES target surface   */
   12.63 -#endif /* SDL_VIDEO_OPENGL_ES */
   12.64 -} SDL_VideoData;
   12.65 -
   12.66 -/* This is hardcoded value in photon/Pg.h */
   12.67 -#define SDL_VIDEO_PHOTON_DEVICENAME_MAX  41
   12.68 -#define SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE 128
   12.69 -
   12.70 -/* Maximum event message size with data payload */
   12.71 -#define SDL_VIDEO_PHOTON_EVENT_SIZE 8192
   12.72 -
   12.73 -/* Current video mode graphics capabilities */
   12.74 -#define SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND 0x00000001
   12.75 -#define SDL_VIDEO_PHOTON_CAP_SCALED_BLIT 0x00000002
   12.76 -
   12.77 -typedef struct SDL_DisplayData
   12.78 -{
   12.79 -    uint32_t device_id;
   12.80 -    uint32_t custom_refresh;            /* Custom refresh rate for all modes  */
   12.81 -    SDL_DisplayMode current_mode;       /* Current video mode                 */
   12.82 -    uint8_t description[SDL_VIDEO_PHOTON_DEVICENAME_MAX];
   12.83 -    /* Device description */
   12.84 -    uint32_t caps;                      /* Device capabilities                */
   12.85 -    PhCursorDef_t *cursor;              /* Global cursor settings             */
   12.86 -    SDL_bool cursor_visible;            /* SDL_TRUE if cursor visible         */
   12.87 -    uint32_t cursor_size;               /* Cursor size in memory w/ structure */
   12.88 -    uint32_t mode_2dcaps;               /* Current video mode 2D capabilities */
   12.89 -    SDL_bool direct_mode;               /* Direct mode state                  */
   12.90 -#if defined(SDL_VIDEO_OPENGL_ES)
   12.91 -    gf_display_t display;               /* GF display handle                  */
   12.92 -    gf_display_info_t display_info;     /* GF display information             */
   12.93 -#endif /* SDL_VIDEO_OPENGL_ES */
   12.94 -} SDL_DisplayData;
   12.95 -
   12.96 -/* Maximum amount of OpenGL ES framebuffer configurations */
   12.97 -#define SDL_VIDEO_GF_OPENGLES_CONFS 32
   12.98 -
   12.99 -typedef struct SDL_WindowData
  12.100 -{
  12.101 -    SDL_bool uses_gles;         /* if true window must support OpenGL ES */
  12.102 -    PtWidget_t *window;         /* window handle                         */
  12.103 -#if defined(SDL_VIDEO_OPENGL_ES)
  12.104 -    EGLConfig gles_configs[SDL_VIDEO_GF_OPENGLES_CONFS];
  12.105 -    /* OpenGL ES framebuffer confs */
  12.106 -    EGLint gles_config;                 /* OpenGL ES configuration index      */
  12.107 -    EGLContext gles_context;            /* OpenGL ES context                  */
  12.108 -    EGLint gles_attributes[256];        /* OpenGL ES attributes for context   */
  12.109 -    EGLSurface gles_surface;            /* OpenGL ES target rendering surface */
  12.110 -    gf_surface_t gfsurface;             /* OpenGL ES GF's surface             */
  12.111 -    PdOffscreenContext_t *phsurface;    /* OpenGL ES Photon's surface         */
  12.112 -#endif /* SDL_VIDEO_OPENGL_ES */
  12.113 -} SDL_WindowData;
  12.114 -
  12.115 -/****************************************************************************/
  12.116 -/* Low level Photon graphics driver capabilities                            */
  12.117 -/****************************************************************************/
  12.118 -typedef struct Photon_DeviceCaps
  12.119 -{
  12.120 -    uint8_t *name;
  12.121 -    uint32_t caps;
  12.122 -} Photon_DeviceCaps;
  12.123 -
  12.124 -#define SDL_PHOTON_UNACCELERATED         0x00000000
  12.125 -#define SDL_PHOTON_ACCELERATED           0x00000001
  12.126 -#define SDL_PHOTON_UNACCELERATED_3D      0x00000000
  12.127 -#define SDL_PHOTON_ACCELERATED_3D        0x00000004
  12.128 -
  12.129 -/****************************************************************************/
  12.130 -/* SDL_VideoDevice functions declaration                                    */
  12.131 -/****************************************************************************/
  12.132 -
  12.133 -/* Display and window functions */
  12.134 -int photon_videoinit(_THIS);
  12.135 -void photon_videoquit(_THIS);
  12.136 -void photon_getdisplaymodes(_THIS);
  12.137 -int photon_setdisplaymode(_THIS, SDL_DisplayMode * mode);
  12.138 -int photon_setdisplaygammaramp(_THIS, Uint16 * ramp);
  12.139 -int photon_getdisplaygammaramp(_THIS, Uint16 * ramp);
  12.140 -int photon_createwindow(_THIS, SDL_Window * window);
  12.141 -int photon_createwindowfrom(_THIS, SDL_Window * window, const void *data);
  12.142 -void photon_setwindowtitle(_THIS, SDL_Window * window);
  12.143 -void photon_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon);
  12.144 -void photon_setwindowposition(_THIS, SDL_Window * window);
  12.145 -void photon_setwindowsize(_THIS, SDL_Window * window);
  12.146 -void photon_showwindow(_THIS, SDL_Window * window);
  12.147 -void photon_hidewindow(_THIS, SDL_Window * window);
  12.148 -void photon_raisewindow(_THIS, SDL_Window * window);
  12.149 -void photon_maximizewindow(_THIS, SDL_Window * window);
  12.150 -void photon_minimizewindow(_THIS, SDL_Window * window);
  12.151 -void photon_restorewindow(_THIS, SDL_Window * window);
  12.152 -void photon_setwindowgrab(_THIS, SDL_Window * window);
  12.153 -void photon_destroywindow(_THIS, SDL_Window * window);
  12.154 -
  12.155 -/* Window manager function */
  12.156 -SDL_bool photon_getwindowwminfo(_THIS, SDL_Window * window,
  12.157 -                                struct SDL_SysWMinfo *info);
  12.158 -
  12.159 -/* OpenGL/OpenGL ES functions */
  12.160 -int photon_gl_loadlibrary(_THIS, const char *path);
  12.161 -void *photon_gl_getprocaddres(_THIS, const char *proc);
  12.162 -void photon_gl_unloadlibrary(_THIS);
  12.163 -SDL_GLContext photon_gl_createcontext(_THIS, SDL_Window * window);
  12.164 -int photon_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context);
  12.165 -int photon_gl_setswapinterval(_THIS, int interval);
  12.166 -int photon_gl_getswapinterval(_THIS);
  12.167 -void photon_gl_swapwindow(_THIS, SDL_Window * window);
  12.168 -void photon_gl_deletecontext(_THIS, SDL_GLContext context);
  12.169 -
  12.170 -/* Helper function, which re-creates surface, not an API */
  12.171 -int photon_gl_recreatesurface(_THIS, SDL_Window * window, uint32_t width, uint32_t height);
  12.172 -
  12.173 -/* Event handling function */
  12.174 -void photon_pumpevents(_THIS);
  12.175 -
  12.176 -/* Screen saver related function */
  12.177 -void photon_suspendscreensaver(_THIS);
  12.178 -
  12.179 -#endif /* __SDL_PHOTON_H__ */
  12.180 -
  12.181 -/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/src/video/photon/SDL_photon_input.c	Tue Feb 01 21:23:43 2011 -0800
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,726 +0,0 @@
    13.4 -/*
    13.5 -    SDL - Simple DirectMedia Layer
    13.6 -    Copyright (C) 1997-2010 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 Lesser General Public
   13.10 -    License as published by the Free Software Foundation; either
   13.11 -    version 2.1 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 -    Lesser General Public License for more details.
   13.17 -
   13.18 -    You should have received a copy of the GNU Lesser General Public
   13.19 -    License along with this library; if not, write to the Free Software
   13.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   13.21 -
   13.22 -    Sam Lantinga
   13.23 -    slouken@libsdl.org
   13.24 -
   13.25 -    QNX Photon GUI SDL driver
   13.26 -    Copyright (C) 2009 Mike Gorchak
   13.27 -    (mike@malva.ua, lestat@i.com.ua)
   13.28 -*/
   13.29 -
   13.30 -#include "SDL_photon_input.h"
   13.31 -
   13.32 -#include "SDL_config.h"
   13.33 -#include "SDL_events.h"
   13.34 -#include "../../events/SDL_mouse_c.h"
   13.35 -#include "../../events/SDL_keyboard_c.h"
   13.36 -
   13.37 -#include "SDL_photon_keycodes.h"
   13.38 -
   13.39 -/* Mouse related functions */
   13.40 -SDL_Cursor *photon_createcursor(SDL_Surface * surface, int hot_x, int hot_y);
   13.41 -int photon_showcursor(SDL_Cursor * cursor);
   13.42 -void photon_movecursor(SDL_Cursor * cursor);
   13.43 -void photon_freecursor(SDL_Cursor * cursor);
   13.44 -void photon_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y);
   13.45 -void photon_freemouse(SDL_Mouse * mouse);
   13.46 -
   13.47 -int32_t
   13.48 -photon_addinputdevices(_THIS)
   13.49 -{
   13.50 -    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
   13.51 -    SDL_DisplayData *didata = NULL;
   13.52 -    struct SDL_Mouse photon_mouse;
   13.53 -    SDL_MouseData *mdata = NULL;
   13.54 -    SDL_Keyboard photon_keyboard;
   13.55 -    SDLKey keymap[SDL_NUM_SCANCODES];
   13.56 -    uint32_t it;
   13.57 -
   13.58 -    for (it = 0; it < _this->num_displays; it++) {
   13.59 -        SDL_VideoDisplay *display = &_this->displays[it];
   13.60 -
   13.61 -        /* Clear SDL mouse structure */
   13.62 -        SDL_memset(&photon_mouse, 0x00, sizeof(struct SDL_Mouse));
   13.63 -
   13.64 -        /* Allocate SDL_MouseData structure */
   13.65 -        mdata = (SDL_MouseData *) SDL_calloc(1, sizeof(SDL_MouseData));
   13.66 -        if (mdata == NULL) {
   13.67 -            SDL_OutOfMemory();
   13.68 -            return -1;
   13.69 -        }
   13.70 -
   13.71 -        /* Mark this mouse with ID 0 */
   13.72 -        photon_mouse.id = it;
   13.73 -        photon_mouse.driverdata = (void *) mdata;
   13.74 -        photon_mouse.CreateCursor = photon_createcursor;
   13.75 -        photon_mouse.ShowCursor = photon_showcursor;
   13.76 -        photon_mouse.MoveCursor = photon_movecursor;
   13.77 -        photon_mouse.FreeCursor = photon_freecursor;
   13.78 -        photon_mouse.WarpMouse = photon_warpmouse;
   13.79 -        photon_mouse.FreeMouse = photon_freemouse;
   13.80 -
   13.81 -        /* Get display data */
   13.82 -        didata = (SDL_DisplayData *) display->driverdata;
   13.83 -
   13.84 -        /* Store SDL_DisplayData pointer in the mouse driver internals */
   13.85 -        mdata->didata = didata;
   13.86 -
   13.87 -        /* Register mouse cursor in SDL */
   13.88 -        SDL_AddMouse(&photon_mouse, "Photon mouse cursor", 0, 0, 1);
   13.89 -    }
   13.90 -
   13.91 -    /* Photon maps all keyboards to one */
   13.92 -    SDL_zero(photon_keyboard);
   13.93 -    SDL_AddKeyboard(&photon_keyboard, -1);
   13.94 -
   13.95 -    /* Add default scancode to key mapping */
   13.96 -    SDL_GetDefaultKeymap(keymap);
   13.97 -    SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
   13.98 -
   13.99 -    return 0;
  13.100 -}
  13.101 -
  13.102 -int32_t
  13.103 -photon_delinputdevices(_THIS)
  13.104 -{
  13.105 -    /* Destroy all of the mice */
  13.106 -    SDL_MouseQuit();
  13.107 -}
  13.108 -
  13.109 -/*****************************************************************************/
  13.110 -/* Photon mouse related functions                                            */
  13.111 -/*****************************************************************************/
  13.112 -SDL_Cursor *
  13.113 -photon_createcursor(SDL_Surface * surface, int hot_x, int hot_y)
  13.114 -{
  13.115 -    PhCursorDef_t *internal_cursor;
  13.116 -    SDL_Cursor *sdl_cursor;
  13.117 -    uint8_t *image0 = NULL;
  13.118 -    uint8_t *image1 = NULL;
  13.119 -    uint32_t it;
  13.120 -    uint32_t jt;
  13.121 -    uint32_t shape_color;
  13.122 -
  13.123 -    /* SDL converts monochrome cursor shape to 32bpp cursor shape      */
  13.124 -    /* and we must convert it back to monochrome, this routine handles */
  13.125 -    /* 24/32bpp surfaces only                                          */
  13.126 -    if ((surface->format->BitsPerPixel != 32)
  13.127 -        && (surface->format->BitsPerPixel != 24)) {
  13.128 -        SDL_SetError("Photon: Cursor shape is not 24/32bpp.");
  13.129 -        return NULL;
  13.130 -    }
  13.131 -
  13.132 -    /* Checking data parameters */
  13.133 -    if ((surface->w == 0) || (surface->h == 0)) {
  13.134 -        SDL_SetError("Photon: Cursor shape dimensions are zero");
  13.135 -        return NULL;
  13.136 -    }
  13.137 -
  13.138 -    /* Allocate memory for the internal cursor format */
  13.139 -    internal_cursor = (PhCursorDef_t *) SDL_calloc(1, sizeof(PhCursorDef_t) +
  13.140 -                                                   ((((surface->w +
  13.141 -                                                       7) >> 3) *
  13.142 -                                                     surface->h) * 2) - 1);
  13.143 -    if (internal_cursor == NULL) {
  13.144 -        SDL_OutOfMemory();
  13.145 -        return NULL;
  13.146 -    }
  13.147 -
  13.148 -    /* Allocate memory for the SDL cursor */
  13.149 -    sdl_cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(SDL_Cursor));
  13.150 -    if (sdl_cursor == NULL) {
  13.151 -        SDL_free(internal_cursor);
  13.152 -        SDL_OutOfMemory();
  13.153 -        return NULL;
  13.154 -    }
  13.155 -
  13.156 -    /* Set driverdata as photon cursor format */
  13.157 -    image0 = (uint8_t *) internal_cursor;
  13.158 -    image0 += sizeof(PhCursorDef_t) - 1;
  13.159 -    image1 = image0;
  13.160 -    image1 += ((surface->w + 7) >> 3) * surface->h;
  13.161 -    sdl_cursor->driverdata = (void *) internal_cursor;
  13.162 -    internal_cursor->hdr.len =
  13.163 -        (sizeof(PhCursorDef_t) - sizeof(PhRegionDataHdr_t)) +
  13.164 -        ((((surface->w + 7) >> 3) * surface->h) * 2) - 1;
  13.165 -    internal_cursor->hdr.type = Ph_RDATA_CURSOR;
  13.166 -    internal_cursor->size1.x = surface->w;
  13.167 -    internal_cursor->size1.y = surface->h;
  13.168 -    internal_cursor->size2.x = surface->w;
  13.169 -    internal_cursor->size2.y = surface->h;
  13.170 -    internal_cursor->offset1.x = -hot_x;
  13.171 -    internal_cursor->offset1.y = -hot_y;
  13.172 -    internal_cursor->offset2.x = -hot_x;
  13.173 -    internal_cursor->offset2.y = -hot_y;
  13.174 -    internal_cursor->bytesperline1 = ((surface->w + 7) >> 3);
  13.175 -    internal_cursor->bytesperline2 = ((surface->w + 7) >> 3);
  13.176 -    internal_cursor->color1 = (SDL_PHOTON_MOUSE_COLOR_BLACK) & 0x00FFFFFF;
  13.177 -    internal_cursor->color2 = (SDL_PHOTON_MOUSE_COLOR_WHITE) & 0x00FFFFFF;
  13.178 -
  13.179 -    /* Convert cursor from 32 bpp */
  13.180 -    for (jt = 0; jt < surface->h; jt++) {
  13.181 -        for (it = 0; it < surface->w; it++) {
  13.182 -            shape_color =
  13.183 -                *((uint32_t *) ((uint8_t *) surface->pixels +
  13.184 -                                jt * surface->pitch +
  13.185 -                                it * surface->format->BytesPerPixel));
  13.186 -            switch (shape_color) {
  13.187 -            case SDL_PHOTON_MOUSE_COLOR_BLACK:
  13.188 -                {
  13.189 -                    *(image0 + jt * (internal_cursor->bytesperline1) +
  13.190 -                      (it >> 3)) |= 0x80 >> (it % 8);
  13.191 -                    *(image1 + jt * (internal_cursor->bytesperline2) +
  13.192 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  13.193 -                }
  13.194 -                break;
  13.195 -            case SDL_PHOTON_MOUSE_COLOR_WHITE:
  13.196 -                {
  13.197 -                    *(image0 + jt * (internal_cursor->bytesperline1) +
  13.198 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  13.199 -                    *(image1 + jt * (internal_cursor->bytesperline2) +
  13.200 -                      (it >> 3)) |= 0x80 >> (it % 8);
  13.201 -                }
  13.202 -                break;
  13.203 -            case SDL_PHOTON_MOUSE_COLOR_TRANS:
  13.204 -                {
  13.205 -                    *(image0 + jt * (internal_cursor->bytesperline1) +
  13.206 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  13.207 -                    *(image1 + jt * (internal_cursor->bytesperline2) +
  13.208 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  13.209 -                }
  13.210 -                break;
  13.211 -            default:
  13.212 -                {
  13.213 -                    /* The same as transparent color, must not happen */
  13.214 -                    *(image0 + jt * (internal_cursor->bytesperline1) +
  13.215 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  13.216 -                    *(image1 + jt * (internal_cursor->bytesperline2) +
  13.217 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  13.218 -                }
  13.219 -                break;
  13.220 -            }
  13.221 -        }
  13.222 -    }
  13.223 -
  13.224 -    return sdl_cursor;
  13.225 -}
  13.226 -
  13.227 -int
  13.228 -photon_showcursor(SDL_Cursor * cursor)
  13.229 -{
  13.230 -    SDL_VideoDisplay *display;
  13.231 -    SDL_DisplayData *didata;
  13.232 -    SDL_Window *window;
  13.233 -    SDL_WindowData *wdata;
  13.234 -    PhCursorDef_t *internal_cursor;
  13.235 -    int32_t status;
  13.236 -
  13.237 -    /* Get current window id */
  13.238 -    window = SDL_GetFocusWindow();
  13.239 -    if (!window) {
  13.240 -        SDL_MouseData *mdata = NULL;
  13.241 -
  13.242 -        /* If there is no current window, then someone calls this function */
  13.243 -        /* to set global mouse settings during SDL initialization          */
  13.244 -        if (cursor != NULL) {
  13.245 -            /* Store cursor for future usage */
  13.246 -            mdata = (SDL_MouseData *) cursor->mouse->driverdata;
  13.247 -            didata = (SDL_DisplayData *) mdata->didata;
  13.248 -            internal_cursor = (PhCursorDef_t *) cursor->driverdata;
  13.249 -
  13.250 -            if (didata->cursor_size >=
  13.251 -                (internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t))) {
  13.252 -                SDL_memcpy(didata->cursor, internal_cursor,
  13.253 -                           internal_cursor->hdr.len +
  13.254 -                           sizeof(PhRegionDataHdr_t));
  13.255 -            } else {
  13.256 -                /* Partitial cursor image */
  13.257 -                SDL_memcpy(didata->cursor, internal_cursor,
  13.258 -                           didata->cursor_size);
  13.259 -            }
  13.260 -
  13.261 -            didata->cursor_visible = SDL_TRUE;
  13.262 -            return 0;
  13.263 -        } else {
  13.264 -            /* We can't get SDL_DisplayData at this point, return fake success */
  13.265 -            return 0;
  13.266 -        }
  13.267 -    } else {
  13.268 -        /* Sanity checks */
  13.269 -        display = window->display;
  13.270 -        if (display != NULL) {
  13.271 -            didata = (SDL_DisplayData *) display->driverdata;
  13.272 -            if (didata != NULL) {
  13.273 -                wdata = (SDL_WindowData *) window->driverdata;
  13.274 -                if (wdata == NULL) {
  13.275 -                    return -1;
  13.276 -                }
  13.277 -            } else {
  13.278 -                return -1;
  13.279 -            }
  13.280 -        } else {
  13.281 -            return -1;
  13.282 -        }
  13.283 -    }
  13.284 -
  13.285 -    /* return if window widget has been destroyed already */
  13.286 -    if (wdata->window == NULL) {
  13.287 -        return;
  13.288 -    }
  13.289 -
  13.290 -    /* Check if we need to set new shape or disable cursor shape */
  13.291 -    if (cursor != NULL) {
  13.292 -        /* Retrieve photon cursor shape */
  13.293 -        internal_cursor = (PhCursorDef_t *) cursor->driverdata;
  13.294 -        if (internal_cursor == NULL) {
  13.295 -            SDL_SetError("Photon: Internal cursor data is absent");
  13.296 -            return -1;
  13.297 -        }
  13.298 -
  13.299 -        /* Setup cursor type */
  13.300 -        status =
  13.301 -            PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP,
  13.302 -                          0);
  13.303 -        if (status != 0) {
  13.304 -            SDL_SetError("Photon: Failed to set cursor type to bitmap");
  13.305 -            return -1;
  13.306 -        }
  13.307 -
  13.308 -        /* Setup cursor color to default */
  13.309 -        status =
  13.310 -            PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR,
  13.311 -                          Ph_CURSOR_DEFAULT_COLOR, 0);
  13.312 -        if (status != 0) {
  13.313 -            SDL_SetError("Photon: Failed to set cursor color");
  13.314 -            return -1;
  13.315 -        }
  13.316 -
  13.317 -        /* Setup cursor shape */
  13.318 -        status =
  13.319 -            PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR,
  13.320 -                          internal_cursor,
  13.321 -                          internal_cursor->hdr.len +
  13.322 -                          sizeof(PhRegionDataHdr_t));
  13.323 -        if (status != 0) {
  13.324 -            SDL_SetError("Photon: Failed to set cursor color");
  13.325 -            return -1;
  13.326 -        }
  13.327 -
  13.328 -        /* Store current cursor for future usage */
  13.329 -        if (didata->cursor_size >=
  13.330 -            (internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t))) {
  13.331 -            SDL_memcpy(didata->cursor, internal_cursor,
  13.332 -                       internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t));
  13.333 -        } else {
  13.334 -            /* Partitial cursor image */
  13.335 -            SDL_memcpy(didata->cursor, internal_cursor, didata->cursor_size);
  13.336 -        }
  13.337 -
  13.338 -        /* Set cursor visible */
  13.339 -        didata->cursor_visible = SDL_TRUE;
  13.340 -    } else {
  13.341 -        /* SDL requests to disable cursor */
  13.342 -        status =
  13.343 -            PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE,
  13.344 -                          0);
  13.345 -        if (status != 0) {
  13.346 -            SDL_SetError("Photon: Can't disable cursor");
  13.347 -            return -1;
  13.348 -        }
  13.349 -
  13.350 -        /* Set cursor invisible */
  13.351 -        didata->cursor_visible = SDL_FALSE;
  13.352 -    }
  13.353 -
  13.354 -    /* Flush all pending widget data */
  13.355 -    PtFlush();
  13.356 -
  13.357 -    /* New cursor shape is set */
  13.358 -    return 0;
  13.359 -}
  13.360 -
  13.361 -void
  13.362 -photon_movecursor(SDL_Cursor * cursor)
  13.363 -{
  13.364 -    SDL_VideoDisplay *display;
  13.365 -    SDL_DisplayData *didata;
  13.366 -    SDL_Window *window;
  13.367 -    SDL_WindowData *wdata;
  13.368 -    SDL_WindowID window_id;
  13.369 -    int32_t status;
  13.370 -
  13.371 -    /* Get current window id */
  13.372 -    window_id = SDL_GetFocusWindow();
  13.373 -    if (window_id <= 0) {
  13.374 -        didata = (SDL_DisplayData *) cursor->mouse->driverdata;
  13.375 -    } else {
  13.376 -        /* Sanity checks */
  13.377 -        window = SDL_GetWindowFromID(window_id);
  13.378 -        if (window != NULL) {
  13.379 -            display = window->display;
  13.380 -            if (display != NULL) {
  13.381 -                didata = (SDL_DisplayData *) display->driverdata;
  13.382 -                if (didata != NULL) {
  13.383 -                    wdata = (SDL_WindowData *) window->driverdata;
  13.384 -                    if (wdata == NULL) {
  13.385 -                        return;
  13.386 -                    }
  13.387 -                } else {
  13.388 -                    return;
  13.389 -                }
  13.390 -            } else {
  13.391 -                return;
  13.392 -            }
  13.393 -        } else {
  13.394 -            return;
  13.395 -        }
  13.396 -    }
  13.397 -
  13.398 -    /* No need to move mouse cursor manually in the photon */
  13.399 -
  13.400 -    return;
  13.401 -}
  13.402 -
  13.403 -void
  13.404 -photon_freecursor(SDL_Cursor * cursor)
  13.405 -{
  13.406 -    PhCursorDef_t *internal_cursor = NULL;
  13.407 -
  13.408 -    if (cursor != NULL) {
  13.409 -        internal_cursor = (PhCursorDef_t *) cursor->driverdata;
  13.410 -        if (internal_cursor != NULL) {
  13.411 -            SDL_free(internal_cursor);
  13.412 -            cursor->driverdata = NULL;
  13.413 -        }
  13.414 -    }
  13.415 -}
  13.416 -
  13.417 -void
  13.418 -photon_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y)
  13.419 -{
  13.420 -    SDL_VideoDisplay *display;
  13.421 -    SDL_DisplayData *didata;
  13.422 -    SDL_WindowData *wdata;
  13.423 -    int16_t wx;
  13.424 -    int16_t wy;
  13.425 -
  13.426 -    /* Sanity checks */
  13.427 -    if (window != NULL) {
  13.428 -        display = window->display;
  13.429 -        if (display != NULL) {
  13.430 -            didata = (SDL_DisplayData *) display->driverdata;
  13.431 -            if (didata != NULL) {
  13.432 -                wdata = (SDL_WindowData *) window->driverdata;
  13.433 -                if (wdata == NULL) {
  13.434 -                    return;
  13.435 -                }
  13.436 -            } else {
  13.437 -                return;
  13.438 -            }
  13.439 -        } else {
  13.440 -            return;
  13.441 -        }
  13.442 -    } else {
  13.443 -        return;
  13.444 -    }
  13.445 -
  13.446 -    PtGetAbsPosition(wdata->window, &wx, &wy);
  13.447 -    PhMoveCursorAbs(PhInputGroup(NULL), wx + x, wy + y);
  13.448 -
  13.449 -    return;
  13.450 -}
  13.451 -
  13.452 -void
  13.453 -photon_freemouse(SDL_Mouse * mouse)
  13.454 -{
  13.455 -    if (mouse->driverdata == NULL) {
  13.456 -        return;
  13.457 -    }
  13.458 -
  13.459 -    /* Mouse framework doesn't deletes automatically our driverdata */
  13.460 -    SDL_free(mouse->driverdata);
  13.461 -    mouse->driverdata = NULL;
  13.462 -
  13.463 -    return;
  13.464 -}
  13.465 -
  13.466 -SDL_ScanCode
  13.467 -photon_to_sdl_keymap(uint32_t key)
  13.468 -{
  13.469 -    SDL_ScanCode scancode = SDL_SCANCODE_UNKNOWN;
  13.470 -
  13.471 -    switch (key & 0x0000007F) {
  13.472 -    case PHOTON_SCANCODE_ESCAPE:
  13.473 -        scancode = SDL_SCANCODE_ESCAPE;
  13.474 -        break;
  13.475 -    case PHOTON_SCANCODE_F1:
  13.476 -        scancode = SDL_SCANCODE_F1;
  13.477 -        break;
  13.478 -    case PHOTON_SCANCODE_F2:
  13.479 -        scancode = SDL_SCANCODE_F2;
  13.480 -        break;
  13.481 -    case PHOTON_SCANCODE_F3:
  13.482 -        scancode = SDL_SCANCODE_F3;
  13.483 -        break;
  13.484 -    case PHOTON_SCANCODE_F4:
  13.485 -        scancode = SDL_SCANCODE_F4;
  13.486 -        break;
  13.487 -    case PHOTON_SCANCODE_F5:
  13.488 -        scancode = SDL_SCANCODE_F5;
  13.489 -        break;
  13.490 -    case PHOTON_SCANCODE_F6:
  13.491 -        scancode = SDL_SCANCODE_F6;
  13.492 -        break;
  13.493 -    case PHOTON_SCANCODE_F7:
  13.494 -        scancode = SDL_SCANCODE_F7;
  13.495 -        break;
  13.496 -    case PHOTON_SCANCODE_F8:
  13.497 -        scancode = SDL_SCANCODE_F8;
  13.498 -        break;
  13.499 -    case PHOTON_SCANCODE_F9:
  13.500 -        scancode = SDL_SCANCODE_F9;
  13.501 -        break;
  13.502 -    case PHOTON_SCANCODE_F10:
  13.503 -        scancode = SDL_SCANCODE_F10;
  13.504 -        break;
  13.505 -    case PHOTON_SCANCODE_F11:
  13.506 -        scancode = SDL_SCANCODE_F11;
  13.507 -        break;
  13.508 -    case PHOTON_SCANCODE_F12:
  13.509 -        scancode = SDL_SCANCODE_F12;
  13.510 -        break;
  13.511 -    case PHOTON_SCANCODE_BACKQOUTE:
  13.512 -        scancode = SDL_SCANCODE_GRAVE;
  13.513 -        break;
  13.514 -    case PHOTON_SCANCODE_1:
  13.515 -        scancode = SDL_SCANCODE_1;
  13.516 -        break;
  13.517 -    case PHOTON_SCANCODE_2:
  13.518 -        scancode = SDL_SCANCODE_2;
  13.519 -        break;
  13.520 -    case PHOTON_SCANCODE_3:
  13.521 -        scancode = SDL_SCANCODE_3;
  13.522 -        break;
  13.523 -    case PHOTON_SCANCODE_4:
  13.524 -        scancode = SDL_SCANCODE_4;
  13.525 -        break;
  13.526 -    case PHOTON_SCANCODE_5:
  13.527 -        scancode = SDL_SCANCODE_5;
  13.528 -        break;
  13.529 -    case PHOTON_SCANCODE_6:
  13.530 -        scancode = SDL_SCANCODE_6;
  13.531 -        break;
  13.532 -    case PHOTON_SCANCODE_7:
  13.533 -        scancode = SDL_SCANCODE_7;
  13.534 -        break;
  13.535 -    case PHOTON_SCANCODE_8:
  13.536 -        scancode = SDL_SCANCODE_8;
  13.537 -        break;
  13.538 -    case PHOTON_SCANCODE_9:
  13.539 -        scancode = SDL_SCANCODE_9;
  13.540 -        break;
  13.541 -    case PHOTON_SCANCODE_0:
  13.542 -        scancode = SDL_SCANCODE_0;
  13.543 -        break;
  13.544 -    case PHOTON_SCANCODE_MINUS:
  13.545 -        scancode = SDL_SCANCODE_MINUS;
  13.546 -        break;
  13.547 -    case PHOTON_SCANCODE_EQUAL:
  13.548 -        scancode = SDL_SCANCODE_EQUALS;
  13.549 -        break;
  13.550 -    case PHOTON_SCANCODE_BACKSPACE:
  13.551 -        scancode = SDL_SCANCODE_BACKSPACE;
  13.552 -        break;
  13.553 -    case PHOTON_SCANCODE_TAB:
  13.554 -        scancode = SDL_SCANCODE_TAB;
  13.555 -        break;
  13.556 -    case PHOTON_SCANCODE_Q:
  13.557 -        scancode = SDL_SCANCODE_Q;
  13.558 -        break;
  13.559 -    case PHOTON_SCANCODE_W:
  13.560 -        scancode = SDL_SCANCODE_W;
  13.561 -        break;
  13.562 -    case PHOTON_SCANCODE_E:
  13.563 -        scancode = SDL_SCANCODE_E;
  13.564 -        break;
  13.565 -    case PHOTON_SCANCODE_R:
  13.566 -        scancode = SDL_SCANCODE_R;
  13.567 -        break;
  13.568 -    case PHOTON_SCANCODE_T:
  13.569 -        scancode = SDL_SCANCODE_T;
  13.570 -        break;
  13.571 -    case PHOTON_SCANCODE_Y:
  13.572 -        scancode = SDL_SCANCODE_Y;
  13.573 -        break;
  13.574 -    case PHOTON_SCANCODE_U:
  13.575 -        scancode = SDL_SCANCODE_U;
  13.576 -        break;
  13.577 -    case PHOTON_SCANCODE_I:
  13.578 -        scancode = SDL_SCANCODE_I;
  13.579 -        break;
  13.580 -    case PHOTON_SCANCODE_O:
  13.581 -        scancode = SDL_SCANCODE_O;
  13.582 -        break;
  13.583 -    case PHOTON_SCANCODE_P:
  13.584 -        scancode = SDL_SCANCODE_P;
  13.585 -        break;
  13.586 -    case PHOTON_SCANCODE_LEFT_SQ_BR:
  13.587 -        scancode = SDL_SCANCODE_LEFTBRACKET;
  13.588 -        break;
  13.589 -    case PHOTON_SCANCODE_RIGHT_SQ_BR:
  13.590 -        scancode = SDL_SCANCODE_RIGHTBRACKET;
  13.591 -        break;
  13.592 -    case PHOTON_SCANCODE_ENTER:
  13.593 -        scancode = SDL_SCANCODE_RETURN;
  13.594 -        break;
  13.595 -    case PHOTON_SCANCODE_CAPSLOCK:
  13.596 -        scancode = SDL_SCANCODE_CAPSLOCK;
  13.597 -        break;
  13.598 -    case PHOTON_SCANCODE_A:
  13.599 -        scancode = SDL_SCANCODE_A;
  13.600 -        break;
  13.601 -    case PHOTON_SCANCODE_S:
  13.602 -        scancode = SDL_SCANCODE_S;
  13.603 -        break;
  13.604 -    case PHOTON_SCANCODE_D:
  13.605 -        scancode = SDL_SCANCODE_D;
  13.606 -        break;
  13.607 -    case PHOTON_SCANCODE_F:
  13.608 -        scancode = SDL_SCANCODE_F;
  13.609 -        break;
  13.610 -    case PHOTON_SCANCODE_G:
  13.611 -        scancode = SDL_SCANCODE_G;
  13.612 -        break;
  13.613 -    case PHOTON_SCANCODE_H:
  13.614 -        scancode = SDL_SCANCODE_H;
  13.615 -        break;
  13.616 -    case PHOTON_SCANCODE_J:
  13.617 -        scancode = SDL_SCANCODE_J;
  13.618 -        break;
  13.619 -    case PHOTON_SCANCODE_K:
  13.620 -        scancode = SDL_SCANCODE_K;
  13.621 -        break;
  13.622 -    case PHOTON_SCANCODE_L:
  13.623 -        scancode = SDL_SCANCODE_L;
  13.624 -        break;
  13.625 -    case PHOTON_SCANCODE_SEMICOLON:
  13.626 -        scancode = SDL_SCANCODE_SEMICOLON;
  13.627 -        break;
  13.628 -    case PHOTON_SCANCODE_QUOTE:
  13.629 -        scancode = SDL_SCANCODE_APOSTROPHE;
  13.630 -        break;
  13.631 -    case PHOTON_SCANCODE_BACKSLASH:
  13.632 -        scancode = SDL_SCANCODE_BACKSLASH;
  13.633 -        break;
  13.634 -    case PHOTON_SCANCODE_LEFT_SHIFT:
  13.635 -        scancode = SDL_SCANCODE_LSHIFT;
  13.636 -        break;
  13.637 -    case PHOTON_SCANCODE_Z:
  13.638 -        scancode = SDL_SCANCODE_Z;
  13.639 -        break;
  13.640 -    case PHOTON_SCANCODE_X:
  13.641 -        scancode = SDL_SCANCODE_X;
  13.642 -        break;
  13.643 -    case PHOTON_SCANCODE_C:
  13.644 -        scancode = SDL_SCANCODE_C;
  13.645 -        break;
  13.646 -    case PHOTON_SCANCODE_V:
  13.647 -        scancode = SDL_SCANCODE_V;
  13.648 -        break;
  13.649 -    case PHOTON_SCANCODE_B:
  13.650 -        scancode = SDL_SCANCODE_B;
  13.651 -        break;
  13.652 -    case PHOTON_SCANCODE_N:
  13.653 -        scancode = SDL_SCANCODE_N;
  13.654 -        break;
  13.655 -    case PHOTON_SCANCODE_M:
  13.656 -        scancode = SDL_SCANCODE_M;
  13.657 -        break;
  13.658 -    case PHOTON_SCANCODE_COMMA:
  13.659 -        scancode = SDL_SCANCODE_COMMA;
  13.660 -        break;
  13.661 -    case PHOTON_SCANCODE_POINT:
  13.662 -        scancode = SDL_SCANCODE_PERIOD;
  13.663 -        break;
  13.664 -    case PHOTON_SCANCODE_SLASH:
  13.665 -        scancode = SDL_SCANCODE_SLASH;
  13.666 -        break;
  13.667 -    case PHOTON_SCANCODE_RIGHT_SHIFT:
  13.668 -        scancode = SDL_SCANCODE_RSHIFT;
  13.669 -        break;
  13.670 -    case PHOTON_SCANCODE_CTRL:
  13.671 -        scancode = SDL_SCANCODE_LCTRL;
  13.672 -        break;
  13.673 -    case PHOTON_SCANCODE_WFLAG:
  13.674 -        scancode = SDL_SCANCODE_LGUI;
  13.675 -        break;
  13.676 -    case PHOTON_SCANCODE_ALT:
  13.677 -        scancode = SDL_SCANCODE_LALT;
  13.678 -        break;
  13.679 -    case PHOTON_SCANCODE_SPACE:
  13.680 -        scancode = SDL_SCANCODE_SPACE;
  13.681 -        break;
  13.682 -    case PHOTON_SCANCODE_MENU:
  13.683 -        scancode = SDL_SCANCODE_MENU;
  13.684 -        break;
  13.685 -    case PHOTON_SCANCODE_PRNSCR:
  13.686 -        scancode = SDL_SCANCODE_PRINTSCREEN;
  13.687 -        break;
  13.688 -    case PHOTON_SCANCODE_SCROLLLOCK:
  13.689 -        scancode = SDL_SCANCODE_SCROLLLOCK;
  13.690 -        break;
  13.691 -    case PHOTON_SCANCODE_INSERT:
  13.692 -        scancode = SDL_SCANCODE_INSERT;
  13.693 -        break;
  13.694 -    case PHOTON_SCANCODE_HOME:
  13.695 -        scancode = SDL_SCANCODE_HOME;
  13.696 -        break;
  13.697 -    case PHOTON_SCANCODE_PAGEUP:
  13.698 -        scancode = SDL_SCANCODE_PAGEUP;
  13.699 -        break;
  13.700 -    case PHOTON_SCANCODE_DELETE:
  13.701 -        scancode = SDL_SCANCODE_DELETE;
  13.702 -        break;
  13.703 -    case PHOTON_SCANCODE_END:
  13.704 -        scancode = SDL_SCANCODE_END;
  13.705 -        break;
  13.706 -    case PHOTON_SCANCODE_PAGEDOWN:
  13.707 -        scancode = SDL_SCANCODE_PAGEDOWN;
  13.708 -        break;
  13.709 -    case PHOTON_SCANCODE_UP:
  13.710 -        scancode = SDL_SCANCODE_UP;
  13.711 -        break;
  13.712 -    case PHOTON_SCANCODE_DOWN:
  13.713 -        scancode = SDL_SCANCODE_DOWN;
  13.714 -        break;
  13.715 -    case PHOTON_SCANCODE_LEFT:
  13.716 -        scancode = SDL_SCANCODE_LEFT;
  13.717 -        break;
  13.718 -    case PHOTON_SCANCODE_RIGHT:
  13.719 -        scancode = SDL_SCANCODE_RIGHT;
  13.720 -        break;
  13.721 -    case PHOTON_SCANCODE_NUMLOCK:
  13.722 -        scancode = SDL_SCANCODE_NUMLOCKCLEAR;
  13.723 -        break;
  13.724 -    default:
  13.725 -        break;
  13.726 -    }
  13.727 -
  13.728 -    return scancode;
  13.729 -}
    14.1 --- a/src/video/photon/SDL_photon_input.h	Tue Feb 01 21:23:43 2011 -0800
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,50 +0,0 @@
    14.4 -/*
    14.5 -    SDL - Simple DirectMedia Layer
    14.6 -    Copyright (C) 1997-2010 Sam Lantinga
    14.7 -
    14.8 -    This library is free software; you can redistribute it and/or
    14.9 -    modify it under the terms of the GNU Lesser General Public
   14.10 -    License as published by the Free Software Foundation; either
   14.11 -    version 2.1 of the License, or (at your option) any later version.
   14.12 -
   14.13 -    This library is distributed in the hope that it will be useful,
   14.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14.16 -    Lesser General Public License for more details.
   14.17 -
   14.18 -    You should have received a copy of the GNU Lesser General Public
   14.19 -    License along with this library; if not, write to the Free Software
   14.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   14.21 -
   14.22 -    Sam Lantinga
   14.23 -    slouken@libsdl.org
   14.24 -
   14.25 -    QNX Photon GUI SDL driver
   14.26 -    Copyright (C) 2009 Mike Gorchak
   14.27 -    (mike@malva.ua, lestat@i.com.ua)
   14.28 -*/
   14.29 -
   14.30 -#ifndef __SDL_PHOTON_INPUT_H__
   14.31 -#define __SDL_PHOTON_INPUT_H__
   14.32 -
   14.33 -#include "SDL_config.h"
   14.34 -#include "SDL_video.h"
   14.35 -#include "../SDL_sysvideo.h"
   14.36 -
   14.37 -#include "SDL_photon.h"
   14.38 -
   14.39 -typedef struct SDL_MouseData
   14.40 -{
   14.41 -    SDL_DisplayData *didata;
   14.42 -} SDL_MouseData;
   14.43 -
   14.44 -int32_t photon_addinputdevices(_THIS);
   14.45 -int32_t photon_delinputdevices(_THIS);
   14.46 -
   14.47 -#define SDL_PHOTON_MOUSE_COLOR_BLACK 0xFF000000
   14.48 -#define SDL_PHOTON_MOUSE_COLOR_WHITE 0xFFFFFFFF
   14.49 -#define SDL_PHOTON_MOUSE_COLOR_TRANS 0x00000000
   14.50 -
   14.51 -SDL_ScanCode photon_to_sdl_keymap(uint32_t key);
   14.52 -
   14.53 -#endif /* __SDL_GF_INPUT_H__ */
    15.1 --- a/src/video/photon/SDL_photon_keycodes.h	Tue Feb 01 21:23:43 2011 -0800
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,125 +0,0 @@
    15.4 -/*
    15.5 -    SDL - Simple DirectMedia Layer
    15.6 -    Copyright (C) 1997-2010 Sam Lantinga
    15.7 -
    15.8 -    This library is free software; you can redistribute it and/or
    15.9 -    modify it under the terms of the GNU Lesser General Public
   15.10 -    License as published by the Free Software Foundation; either
   15.11 -    version 2.1 of the License, or (at your option) any later version.
   15.12 -
   15.13 -    This library is distributed in the hope that it will be useful,
   15.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15.16 -    Lesser General Public License for more details.
   15.17 -
   15.18 -    You should have received a copy of the GNU Lesser General Public
   15.19 -    License along with this library; if not, write to the Free Software
   15.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   15.21 -
   15.22 -    Sam Lantinga
   15.23 -    slouken@libsdl.org
   15.24 -
   15.25 -    QNX Photon GUI SDL driver
   15.26 -    Copyright (C) 2009 Mike Gorchak
   15.27 -    (mike@malva.ua, lestat@i.com.ua)
   15.28 -*/
   15.29 -
   15.30 -#ifndef __SDL_PHOTON_KEYCODES_H__
   15.31 -#define __SDL_PHOTON_KEYCODES_H__
   15.32 -
   15.33 -#define PHOTON_SCANCODE_ESCAPE      0x01
   15.34 -#define PHOTON_SCANCODE_F1          0x3B
   15.35 -#define PHOTON_SCANCODE_F2          0x3C
   15.36 -#define PHOTON_SCANCODE_F3          0x3D
   15.37 -#define PHOTON_SCANCODE_F4          0x3E
   15.38 -#define PHOTON_SCANCODE_F5          0x3F
   15.39 -#define PHOTON_SCANCODE_F6          0x40
   15.40 -#define PHOTON_SCANCODE_F7          0x41
   15.41 -#define PHOTON_SCANCODE_F8          0x42
   15.42 -#define PHOTON_SCANCODE_F9          0x43
   15.43 -#define PHOTON_SCANCODE_F10         0x44
   15.44 -#define PHOTON_SCANCODE_F11         0x57
   15.45 -#define PHOTON_SCANCODE_F12         0x58
   15.46 -
   15.47 -#define PHOTON_SCANCODE_BACKQOUTE   0x29
   15.48 -#define PHOTON_SCANCODE_1           0x02
   15.49 -#define PHOTON_SCANCODE_2           0x03
   15.50 -#define PHOTON_SCANCODE_3           0x04
   15.51 -#define PHOTON_SCANCODE_4           0x05
   15.52 -#define PHOTON_SCANCODE_5           0x06
   15.53 -#define PHOTON_SCANCODE_6           0x07
   15.54 -#define PHOTON_SCANCODE_7           0x08
   15.55 -#define PHOTON_SCANCODE_8           0x09
   15.56 -#define PHOTON_SCANCODE_9           0x0A
   15.57 -#define PHOTON_SCANCODE_0           0x0B
   15.58 -#define PHOTON_SCANCODE_MINUS       0x0C
   15.59 -#define PHOTON_SCANCODE_EQUAL       0x0D
   15.60 -#define PHOTON_SCANCODE_BACKSPACE   0x0E
   15.61 -
   15.62 -#define PHOTON_SCANCODE_TAB         0x0F
   15.63 -#define PHOTON_SCANCODE_Q           0x10
   15.64 -#define PHOTON_SCANCODE_W           0x11
   15.65 -#define PHOTON_SCANCODE_E           0x12
   15.66 -#define PHOTON_SCANCODE_R           0x13
   15.67 -#define PHOTON_SCANCODE_T           0x14
   15.68 -#define PHOTON_SCANCODE_Y           0x15
   15.69 -#define PHOTON_SCANCODE_U           0x16
   15.70 -#define PHOTON_SCANCODE_I           0x17
   15.71 -#define PHOTON_SCANCODE_O           0x18
   15.72 -#define PHOTON_SCANCODE_P           0x19
   15.73 -#define PHOTON_SCANCODE_LEFT_SQ_BR  0x1A
   15.74 -#define PHOTON_SCANCODE_RIGHT_SQ_BR 0x1B
   15.75 -#define PHOTON_SCANCODE_ENTER       0x1C
   15.76 -
   15.77 -#define PHOTON_SCANCODE_CAPSLOCK    0x3A
   15.78 -#define PHOTON_SCANCODE_A           0x1E
   15.79 -#define PHOTON_SCANCODE_S           0x1F
   15.80 -#define PHOTON_SCANCODE_D           0x20
   15.81 -#define PHOTON_SCANCODE_F           0x21
   15.82 -#define PHOTON_SCANCODE_G           0x22
   15.83 -#define PHOTON_SCANCODE_H           0x23
   15.84 -#define PHOTON_SCANCODE_J           0x24
   15.85 -#define PHOTON_SCANCODE_K           0x25
   15.86 -#define PHOTON_SCANCODE_L           0x26
   15.87 -#define PHOTON_SCANCODE_SEMICOLON   0x27
   15.88 -#define PHOTON_SCANCODE_QUOTE       0x28
   15.89 -#define PHOTON_SCANCODE_BACKSLASH   0x2B
   15.90 -
   15.91 -#define PHOTON_SCANCODE_LEFT_SHIFT  0x2A
   15.92 -#define PHOTON_SCANCODE_Z           0x2C
   15.93 -#define PHOTON_SCANCODE_X           0x2D
   15.94 -#define PHOTON_SCANCODE_C           0x2E
   15.95 -#define PHOTON_SCANCODE_V           0x2F
   15.96 -#define PHOTON_SCANCODE_B           0x30
   15.97 -#define PHOTON_SCANCODE_N           0x31
   15.98 -#define PHOTON_SCANCODE_M           0x32
   15.99 -#define PHOTON_SCANCODE_COMMA       0x33
  15.100 -#define PHOTON_SCANCODE_POINT       0x34
  15.101 -#define PHOTON_SCANCODE_SLASH       0x35
  15.102 -#define PHOTON_SCANCODE_RIGHT_SHIFT 0x36
  15.103 -
  15.104 -#define PHOTON_SCANCODE_CTRL        0x1D
  15.105 -#define PHOTON_SCANCODE_WFLAG       0x5B
  15.106 -#define PHOTON_SCANCODE_ALT         0x38
  15.107 -#define PHOTON_SCANCODE_SPACE       0x39
  15.108 -#define PHOTON_SCANCODE_MENU        0x5D
  15.109 -
  15.110 -#define PHOTON_SCANCODE_PRNSCR      0x54        /* only key pressed event, no release */
  15.111 -#define PHOTON_SCANCODE_SCROLLLOCK  0x46
  15.112 -#if 0                                           /* pause doesn't generates a scancode */
  15.113 -#define PHOTON_SCANCODE_PAUSE       0x??
  15.114 -#endif
  15.115 -#define PHOTON_SCANCODE_INSERT      0x52
  15.116 -#define PHOTON_SCANCODE_HOME        0x47
  15.117 -#define PHOTON_SCANCODE_PAGEUP      0x49
  15.118 -#define PHOTON_SCANCODE_DELETE      0x53
  15.119 -#define PHOTON_SCANCODE_END         0x4F
  15.120 -#define PHOTON_SCANCODE_PAGEDOWN    0x51
  15.121 -#define PHOTON_SCANCODE_UP          0x48
  15.122 -#define PHOTON_SCANCODE_DOWN        0x50
  15.123 -#define PHOTON_SCANCODE_LEFT        0x4B
  15.124 -#define PHOTON_SCANCODE_RIGHT       0x4D
  15.125 -
  15.126 -#define PHOTON_SCANCODE_NUMLOCK     0x45
  15.127 -
  15.128 -#endif /* __SDL_PHOTON_KEYCODES_H__ */
    16.1 --- a/src/video/photon/SDL_photon_pixelfmt.c	Tue Feb 01 21:23:43 2011 -0800
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,218 +0,0 @@
    16.4 -/*
    16.5 -    SDL - Simple DirectMedia Layer
    16.6 -    Copyright (C) 1997-2010 Sam Lantinga
    16.7 -
    16.8 -    This library is free software; you can redistribute it and/or
    16.9 -    modify it under the terms of the GNU Lesser General Public
   16.10 -    License as published by the Free Software Foundation; either
   16.11 -    version 2.1 of the License, or (at your option) any later version.
   16.12 -
   16.13 -    This library is distributed in the hope that it will be useful,
   16.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   16.16 -    Lesser General Public License for more details.
   16.17 -
   16.18 -    You should have received a copy of the GNU Lesser General Public
   16.19 -    License along with this library; if not, write to the Free Software
   16.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   16.21 -
   16.22 -    Sam Lantinga
   16.23 -    slouken@libsdl.org
   16.24 -
   16.25 -    QNX Photon GUI SDL driver
   16.26 -    Copyright (C) 2009 Mike Gorchak
   16.27 -    (mike@malva.ua, lestat@i.com.ua)
   16.28 -*/
   16.29 -
   16.30 -#include "SDL_photon_pixelfmt.h"
   16.31 -
   16.32 -uint32_t
   16.33 -photon_bits_to_sdl_pixelformat(uint32_t pixelfmt)
   16.34 -{
   16.35 -    switch (pixelfmt) {
   16.36 -    case 8:
   16.37 -        {
   16.38 -            return SDL_PIXELFORMAT_INDEX8;
   16.39 -        }
   16.40 -        break;
   16.41 -    case 15:
   16.42 -        {
   16.43 -            return SDL_PIXELFORMAT_ARGB1555;
   16.44 -        }
   16.45 -        break;
   16.46 -    case 16:
   16.47 -        {
   16.48 -            return SDL_PIXELFORMAT_RGB565;
   16.49 -        }
   16.50 -        break;
   16.51 -    case 24:
   16.52 -        {
   16.53 -            return SDL_PIXELFORMAT_RGB888;
   16.54 -        }
   16.55 -        break;
   16.56 -    case 32:
   16.57 -        {
   16.58 -            return SDL_PIXELFORMAT_ARGB8888;
   16.59 -        }
   16.60 -        break;
   16.61 -    }
   16.62 -}
   16.63 -
   16.64 -uint32_t
   16.65 -photon_sdl_to_bits_pixelformat(uint32_t pixelfmt)
   16.66 -{
   16.67 -    switch (pixelfmt) {
   16.68 -    case SDL_PIXELFORMAT_INDEX8:
   16.69 -        {
   16.70 -            return 8;
   16.71 -        }
   16.72 -        break;
   16.73 -    case SDL_PIXELFORMAT_ARGB1555:
   16.74 -        {
   16.75 -            return 15;
   16.76 -        }
   16.77 -        break;
   16.78 -    case SDL_PIXELFORMAT_RGB555:
   16.79 -        {
   16.80 -            return 15;
   16.81 -        }
   16.82 -        break;
   16.83 -    case SDL_PIXELFORMAT_ABGR1555:
   16.84 -        {
   16.85 -            return 15;
   16.86 -        }
   16.87 -        break;
   16.88 -    case SDL_PIXELFORMAT_RGB565:
   16.89 -        {
   16.90 -            return 16;
   16.91 -        }
   16.92 -        break;
   16.93 -    case SDL_PIXELFORMAT_RGB24:
   16.94 -        {
   16.95 -            return 24;
   16.96 -        }
   16.97 -        break;
   16.98 -    case SDL_PIXELFORMAT_RGB888:
   16.99 -        {
  16.100 -            return 32;
  16.101 -        }
  16.102 -        break;
  16.103 -    case SDL_PIXELFORMAT_BGRA8888:
  16.104 -        {
  16.105 -            return 32;
  16.106 -        }
  16.107 -        break;
  16.108 -    case SDL_PIXELFORMAT_ARGB8888:
  16.109 -        {
  16.110 -            return 32;
  16.111 -        }
  16.112 -        break;
  16.113 -    case SDL_PIXELFORMAT_YV12:
  16.114 -        {
  16.115 -            return 8;
  16.116 -        }
  16.117 -        break;
  16.118 -    case SDL_PIXELFORMAT_YUY2:
  16.119 -        {
  16.120 -            return 16;
  16.121 -        }
  16.122 -        break;
  16.123 -    case SDL_PIXELFORMAT_UYVY:
  16.124 -        {
  16.125 -            return 16;
  16.126 -        }
  16.127 -        break;
  16.128 -    case SDL_PIXELFORMAT_YVYU:
  16.129 -        {
  16.130 -            return 16;
  16.131 -        }
  16.132 -        break;
  16.133 -    }
  16.134 -
  16.135 -    return 0;
  16.136 -}
  16.137 -
  16.138 -uint32_t
  16.139 -photon_image_to_sdl_pixelformat(uint32_t pixelfmt)
  16.140 -{
  16.141 -    switch (pixelfmt) {
  16.142 -    case Pg_IMAGE_PALETTE_BYTE:
  16.143 -        {
  16.144 -            return SDL_PIXELFORMAT_INDEX8;
  16.145 -        }
  16.146 -        break;
  16.147 -    case Pg_IMAGE_DIRECT_8888:
  16.148 -        {
  16.149 -            return SDL_PIXELFORMAT_ARGB8888;
  16.150 -        }
  16.151 -        break;
  16.152 -    case Pg_IMAGE_DIRECT_888:
  16.153 -        {
  16.154 -            return SDL_PIXELFORMAT_RGB24;
  16.155 -        }
  16.156 -        break;
  16.157 -    case Pg_IMAGE_DIRECT_565:
  16.158 -        {
  16.159 -            return SDL_PIXELFORMAT_RGB565;
  16.160 -        }
  16.161 -        break;
  16.162 -    case Pg_IMAGE_DIRECT_555:
  16.163 -        {
  16.164 -            return SDL_PIXELFORMAT_RGB555;
  16.165 -        }
  16.166 -        break;
  16.167 -    case Pg_IMAGE_DIRECT_1555:
  16.168 -        {
  16.169 -            return SDL_PIXELFORMAT_ARGB1555;
  16.170 -        }
  16.171 -        break;
  16.172 -    }
  16.173 -
  16.174 -    return 0;
  16.175 -}
  16.176 -
  16.177 -uint32_t
  16.178 -photon_sdl_to_image_pixelformat(uint32_t pixelfmt)
  16.179 -{
  16.180 -    switch (pixelfmt) {
  16.181 -    case SDL_PIXELFORMAT_INDEX8:
  16.182 -        {
  16.183 -            return Pg_IMAGE_PALETTE_BYTE;
  16.184 -        }
  16.185 -        break;
  16.186 -    case SDL_PIXELFORMAT_ARGB8888:
  16.187 -        {
  16.188 -            return Pg_IMAGE_DIRECT_8888;
  16.189 -        }
  16.190 -        break;
  16.191 -    case SDL_PIXELFORMAT_RGB888:
  16.192 -        {
  16.193 -            return Pg_IMAGE_DIRECT_8888;
  16.194 -        }
  16.195 -        break;
  16.196 -    case SDL_PIXELFORMAT_RGB24:
  16.197 -        {
  16.198 -            return Pg_IMAGE_DIRECT_888;
  16.199 -        }
  16.200 -        break;
  16.201 -    case SDL_PIXELFORMAT_RGB565:
  16.202 -        {
  16.203 -            return Pg_IMAGE_DIRECT_565;
  16.204 -        }
  16.205 -        break;
  16.206 -    case SDL_PIXELFORMAT_ARGB1555:
  16.207 -        {
  16.208 -            return Pg_IMAGE_DIRECT_1555;
  16.209 -        }
  16.210 -        break;
  16.211 -    case SDL_PIXELFORMAT_RGB555:
  16.212 -        {
  16.213 -            return Pg_IMAGE_DIRECT_555;
  16.214 -        }
  16.215 -        break;
  16.216 -    }
  16.217 -
  16.218 -    return 0;
  16.219 -}
  16.220 -
  16.221 -/* vi: set ts=4 sw=4 expandtab: */
    17.1 --- a/src/video/photon/SDL_photon_pixelfmt.h	Tue Feb 01 21:23:43 2011 -0800
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,42 +0,0 @@
    17.4 -/*
    17.5 -    SDL - Simple DirectMedia Layer
    17.6 -    Copyright (C) 1997-2010 Sam Lantinga
    17.7 -
    17.8 -    This library is free software; you can redistribute it and/or
    17.9 -    modify it under the terms of the GNU Lesser General Public
   17.10 -    License as published by the Free Software Foundation; either
   17.11 -    version 2.1 of the License, or (at your option) any later version.
   17.12 -
   17.13 -    This library is distributed in the hope that it will be useful,
   17.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   17.16 -    Lesser General Public License for more details.
   17.17 -
   17.18 -    You should have received a copy of the GNU Lesser General Public
   17.19 -    License along with this library; if not, write to the Free Software
   17.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   17.21 -
   17.22 -    Sam Lantinga
   17.23 -    slouken@libsdl.org
   17.24 -
   17.25 -    QNX Photon GUI SDL driver
   17.26 -    Copyright (C) 2009 Mike Gorchak
   17.27 -    (mike@malva.ua, lestat@i.com.ua)
   17.28 -*/
   17.29 -
   17.30 -#include "SDL_config.h"
   17.31 -#include "../SDL_sysvideo.h"
   17.32 -
   17.33 -#include <Ph.h>
   17.34 -
   17.35 -#ifndef __SDL_PHOTON_PIXELFMT_H__
   17.36 -#define __SDL_PHOTON_PIXELFMT_H__
   17.37 -
   17.38 -uint32_t photon_bits_to_sdl_pixelformat(uint32_t pixelfmt);
   17.39 -uint32_t photon_sdl_to_bits_pixelformat(uint32_t pixelfmt);
   17.40 -uint32_t photon_image_to_sdl_pixelformat(uint32_t pixelfmt);
   17.41 -uint32_t photon_sdl_to_image_pixelformat(uint32_t pixelfmt);
   17.42 -
   17.43 -#endif /* __SDL_PHOTON_PIXELFMT_H__ */
   17.44 -
   17.45 -/* vi: set ts=4 sw=4 expandtab: */
    18.1 --- a/src/video/photon/SDL_photon_render.c	Tue Feb 01 21:23:43 2011 -0800
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,1419 +0,0 @@
    18.4 -/*
    18.5 -    SDL - Simple DirectMedia Layer
    18.6 -    Copyright (C) 1997-2010 Sam Lantinga
    18.7 -
    18.8 -    This library is free software; you can redistribute it and/or
    18.9 -    modify it under the terms of the GNU Lesser General Public
   18.10 -    License as published by the Free Software Foundation; either
   18.11 -    version 2.1 of the License, or (at your option) any later version.
   18.12 -
   18.13 -    This library is distributed in the hope that it will be useful,
   18.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   18.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   18.16 -    Lesser General Public License for more details.
   18.17 -
   18.18 -    You should have received a copy of the GNU Lesser General Public
   18.19 -    License along with this library; if not, write to the Free Software
   18.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   18.21 -
   18.22 -    Sam Lantinga
   18.23 -    slouken@libsdl.org
   18.24 -
   18.25 -    QNX Photon GUI SDL driver
   18.26 -    Copyright (C) 2009 Mike Gorchak
   18.27 -    (mike@malva.ua, lestat@i.com.ua)
   18.28 -*/
   18.29 -
   18.30 -#include "SDL_config.h"
   18.31 -
   18.32 -#include "../SDL_pixels_c.h"
   18.33 -#include "../SDL_yuv_sw_c.h"
   18.34 -
   18.35 -#include "SDL_video.h"
   18.36 -
   18.37 -#include "SDL_photon_render.h"
   18.38 -#include "SDL_photon.h"
   18.39 -
   18.40 -#ifndef Pg_OSC_MEM_LINEAR_ACCESSIBLE
   18.41 -    /* For QNX 6.3.2 compatibility */
   18.42 -    #define Pg_OSC_MEM_LINEAR_ACCESSIBLE 0
   18.43 -#endif /* Pg_OSC_MEM_LINEAR_ACCESSIBLE */
   18.44 -
   18.45 -static SDL_Renderer *photon_createrenderer(SDL_Window * window, Uint32 flags);
   18.46 -static int photon_displaymodechanged(SDL_Renderer * renderer);
   18.47 -static int photon_activaterenderer(SDL_Renderer * renderer);
   18.48 -static int photon_createtexture(SDL_Renderer * renderer,
   18.49 -                                SDL_Texture * texture);
   18.50 -static int photon_querytexturepixels(SDL_Renderer * renderer,
   18.51 -                                     SDL_Texture * texture, void **pixels,
   18.52 -                                     int *pitch);
   18.53 -static int photon_settexturepalette(SDL_Renderer * renderer,
   18.54 -                                    SDL_Texture * texture,
   18.55 -                                    const SDL_Color * colors, int firstcolor,
   18.56 -                                    int ncolors);
   18.57 -static int photon_gettexturepalette(SDL_Renderer * renderer,
   18.58 -                                    SDL_Texture * texture, SDL_Color * colors,
   18.59 -                                    int firstcolor, int ncolors);
   18.60 -static int photon_updatetexture(SDL_Renderer * renderer,
   18.61 -                                SDL_Texture * texture, const SDL_Rect * rect,
   18.62 -                                const void *pixels, int pitch);
   18.63 -static int photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
   18.64 -                              const SDL_Rect * rect, int markDirty,
   18.65 -                              void **pixels, int *pitch);
   18.66 -static void photon_unlocktexture(SDL_Renderer * renderer,
   18.67 -                                 SDL_Texture * texture);
   18.68 -static void photon_dirtytexture(SDL_Renderer * renderer,
   18.69 -                                SDL_Texture * texture, int numrects,
   18.70 -                                const SDL_Rect * rects);
   18.71 -static int photon_renderpoint(SDL_Renderer * renderer, int x, int y);
   18.72 -static int photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2,
   18.73 -                             int y2);
   18.74 -static int photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect);
   18.75 -static int photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
   18.76 -                             const SDL_Rect * srcrect,
   18.77 -                             const SDL_Rect * dstrect);
   18.78 -static int photon_renderreadpixels(SDL_Renderer * renderer, const SDL_Rect * rect,
   18.79 -                                   Uint32 format, void * pixels, int pitch);
   18.80 -static int photon_renderwritepixels(SDL_Renderer * renderer, const SDL_Rect * rect,
   18.81 -                                    Uint32 format, const void * pixels, int pitch);
   18.82 -static void photon_renderpresent(SDL_Renderer * renderer);
   18.83 -static void photon_destroytexture(SDL_Renderer * renderer,
   18.84 -                                  SDL_Texture * texture);
   18.85 -static void photon_destroyrenderer(SDL_Renderer * renderer);
   18.86 -
   18.87 -static int _photon_recreate_surfaces(SDL_Renderer * renderer);
   18.88 -
   18.89 -SDL_RenderDriver photon_renderdriver = {
   18.90 -    photon_createrenderer,
   18.91 -    {
   18.92 -     "photon",
   18.93 -     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
   18.94 -      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
   18.95 -      SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
   18.96 -      SDL_RENDERER_ACCELERATED),
   18.97 -     9,
   18.98 -     {SDL_PIXELFORMAT_RGB555,
   18.99 -      SDL_PIXELFORMAT_RGB565,
  18.100 -      SDL_PIXELFORMAT_RGB24,
  18.101 -      SDL_PIXELFORMAT_RGB888,
  18.102 -      SDL_PIXELFORMAT_ARGB8888,
  18.103 -      SDL_PIXELFORMAT_YV12,
  18.104 -      SDL_PIXELFORMAT_YUY2,
  18.105 -      SDL_PIXELFORMAT_UYVY,
  18.106 -      SDL_PIXELFORMAT_YVYU},
  18.107 -     0,
  18.108 -     0}
  18.109 -};
  18.110 -
  18.111 -static SDL_Renderer *
  18.112 -photon_createrenderer(SDL_Window * window, Uint32 flags)
  18.113 -{
  18.114 -    SDL_VideoDisplay *display = window->display;
  18.115 -    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
  18.116 -    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
  18.117 -    SDL_Renderer *renderer = NULL;
  18.118 -    SDL_RenderData *rdata = NULL;
  18.119 -
  18.120 -    /* Allocate new renderer structure */
  18.121 -    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer));
  18.122 -    if (renderer == NULL) {
  18.123 -        SDL_OutOfMemory();
  18.124 -        return NULL;
  18.125 -    }
  18.126 -
  18.127 -    /* Allocate renderer data */
  18.128 -    rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData));
  18.129 -    if (rdata == NULL) {
  18.130 -        SDL_free(renderer);
  18.131 -        SDL_OutOfMemory();
  18.132 -        return NULL;
  18.133 -    }
  18.134 -
  18.135 -    renderer->DisplayModeChanged = photon_displaymodechanged;
  18.136 -    renderer->ActivateRenderer = photon_activaterenderer;
  18.137 -    renderer->CreateTexture = photon_createtexture;
  18.138 -    renderer->QueryTexturePixels = photon_querytexturepixels;
  18.139 -    renderer->UpdateTexture = photon_updatetexture;
  18.140 -    renderer->LockTexture = photon_locktexture;
  18.141 -    renderer->UnlockTexture = photon_unlocktexture;
  18.142 -    renderer->DirtyTexture = photon_dirtytexture;
  18.143 -    renderer->RenderPoint = photon_renderpoint;
  18.144 -    renderer->RenderLine = photon_renderline;
  18.145 -    renderer->RenderFill = photon_renderfill;
  18.146 -    renderer->RenderCopy = photon_rendercopy;
  18.147 -    renderer->RenderReadPixels = photon_renderreadpixels;
  18.148 -    renderer->RenderWritePixels = photon_renderwritepixels;
  18.149 -    renderer->RenderPresent = photon_renderpresent;
  18.150 -    renderer->DestroyTexture = photon_destroytexture;
  18.151 -    renderer->DestroyRenderer = photon_destroyrenderer;
  18.152 -    renderer->info = photon_renderdriver.info;
  18.153 -    renderer->window = window;
  18.154 -    renderer->driverdata = rdata;
  18.155 -
  18.156 -    /* Copy direct_mode status */
  18.157 -    rdata->direct_mode=didata->direct_mode;
  18.158 -
  18.159 -    /* Set render acceleration flag in case it is accelerated */
  18.160 -    if ((didata->caps & SDL_PHOTON_ACCELERATED) == SDL_PHOTON_ACCELERATED) {
  18.161 -        renderer->info.flags = SDL_RENDERER_ACCELERATED;
  18.162 -    } else {
  18.163 -        renderer->info.flags = 0;
  18.164 -    }
  18.165 -
  18.166 -    /* Check if upper level requested synchronization on vsync signal */
  18.167 -    if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) {
  18.168 -        if (rdata->direct_mode==SDL_TRUE)
  18.169 -        {
  18.170 -           /* We can control vsync only in direct mode */
  18.171 -           rdata->enable_vsync = SDL_TRUE;
  18.172 -           renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
  18.173 -        }
  18.174 -        else
  18.175 -        {
  18.176 -           rdata->enable_vsync = SDL_FALSE;
  18.177 -        }
  18.178 -    } else {
  18.179 -        rdata->enable_vsync = SDL_FALSE;
  18.180 -    }
  18.181 -
  18.182 -    /* Check what buffer copy/flip scheme is requested */
  18.183 -    rdata->surfaces_count = 0;
  18.184 -    if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) {
  18.185 -        if ((flags & SDL_RENDERER_PRESENTDISCARD) ==
  18.186 -            SDL_RENDERER_PRESENTDISCARD) {
  18.187 -            renderer->info.flags |=
  18.188 -                SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD;
  18.189 -        } else {
  18.190 -            renderer->info.flags |=
  18.191 -                SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
  18.192 -        }
  18.193 -        rdata->surfaces_count = 1;
  18.194 -        rdata->surface_visible_idx = 0;
  18.195 -        rdata->surface_render_idx = 0;
  18.196 -    } else {
  18.197 -        if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) {
  18.198 -            renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
  18.199 -            rdata->surfaces_count = 2;
  18.200 -            rdata->surface_visible_idx = 0;
  18.201 -            rdata->surface_render_idx = 1;
  18.202 -        } else {
  18.203 -            if ((flags & SDL_RENDERER_PRESENTFLIP3) ==
  18.204 -                SDL_RENDERER_PRESENTFLIP3) {
  18.205 -                renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
  18.206 -                rdata->surfaces_count = 3;
  18.207 -                rdata->surface_visible_idx = 0;
  18.208 -                rdata->surface_render_idx = 1;
  18.209 -            } else {
  18.210 -                renderer->info.flags |=
  18.211 -                    SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
  18.212 -                rdata->surfaces_count = 1;
  18.213 -                rdata->surface_visible_idx = 0;
  18.214 -                rdata->surface_render_idx = 0;
  18.215 -            }
  18.216 -        }
  18.217 -    }
  18.218 -
  18.219 -    /* Create new graphics context for the renderer */
  18.220 -    if (rdata->gc==NULL)
  18.221 -    {
  18.222 -       rdata->gc=PgCreateGC(0);
  18.223 -       PgDefaultGC(rdata->gc);
  18.224 -    }
  18.225 -
  18.226 -    /* Setup textures supported by current renderer instance */
  18.227 -    renderer->info.num_texture_formats=1;
  18.228 -    renderer->info.texture_formats[0]=didata->current_mode.format;
  18.229 -
  18.230 -    /* Initialize surfaces */
  18.231 -    _photon_recreate_surfaces(renderer);
  18.232 -
  18.233 -    return renderer;
  18.234 -}
  18.235 -
  18.236 -void
  18.237 -photon_addrenderdriver(_THIS)
  18.238 -{
  18.239 -    uint32_t it;
  18.240 -
  18.241 -    for (it = 0; it < _this->num_displays; it++) {
  18.242 -        SDL_AddRenderDriver(&_this->displays[it], &photon_renderdriver);
  18.243 -    }
  18.244 -}
  18.245 -
  18.246 -/****************************************************************************/
  18.247 -/* Renderer helper functions                                                  */
  18.248 -/****************************************************************************/
  18.249 -
  18.250 -static int _photon_recreate_surfaces(SDL_Renderer * renderer)
  18.251 -{
  18.252 -    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.253 -    SDL_VideoDisplay *display = NULL;
  18.254 -    SDL_DisplayData *didata = NULL;
  18.255 -    SDL_Window *window = NULL;
  18.256 -    SDL_WindowData *wdata = NULL;
  18.257 -    SDL_VideoData *phdata = NULL;
  18.258 -    uint32_t allocate_task=SDL_PHOTON_SURFTYPE_UNKNOWN;
  18.259 -    int32_t status;
  18.260 -
  18.261 -    /* Obtain window and display structures */
  18.262 -    window=SDL_GetWindowFromID(renderer->window);
  18.263 -    wdata=(SDL_WindowData*)window->driverdata;
  18.264 -    display=window->display;
  18.265 -    didata=(SDL_DisplayData *) display->driverdata;
  18.266 -    phdata=(SDL_VideoData *) display->device->driverdata;
  18.267 -
  18.268 -    /* Check if it is OpenGL ES window */
  18.269 -    if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) {
  18.270 -        /* If so, do not waste surfaces */
  18.271 -        rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN;
  18.272 -        return 0;
  18.273 -    }
  18.274 -
  18.275 -    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
  18.276 -    {
  18.277 -       /* Try to allocate offscreen surfaces */
  18.278 -       allocate_task=SDL_PHOTON_SURFTYPE_OFFSCREEN;
  18.279 -    }
  18.280 -    else
  18.281 -    {
  18.282 -       uint32_t it;
  18.283 -
  18.284 -       if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN)
  18.285 -       {
  18.286 -          /* Create offscreen surfaces */
  18.287 -          allocate_task=SDL_PHOTON_SURFTYPE_OFFSCREEN;
  18.288 -
  18.289 -          /* Before destroying surfaces, be sure, that rendering was completed */
  18.290 -          PgFlush();
  18.291 -          PgWaitHWIdle();
  18.292 -
  18.293 -          /* Destroy current surfaces */
  18.294 -          for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++)
  18.295 -          {
  18.296 -             if (rdata->osurfaces[it] != NULL)
  18.297 -             {
  18.298 -                PhDCRelease(rdata->osurfaces[it]);
  18.299 -                rdata->osurfaces[it] = NULL;
  18.300 -             }
  18.301 -          }
  18.302 -       }
  18.303 -       else
  18.304 -       {
  18.305 -          if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_PHIMAGE)
  18.306 -          {
  18.307 -             /* Create shared phimage surfaces */
  18.308 -             allocate_task=SDL_PHOTON_SURFTYPE_PHIMAGE;
  18.309 -
  18.310 -             /* Destroy current surfaces */
  18.311 -             for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++)
  18.312 -             {
  18.313 -                if (rdata->pcontexts[it]!=NULL)
  18.314 -                {
  18.315 -                   PmMemReleaseMC(rdata->pcontexts[it]);
  18.316 -                   rdata->pcontexts[it]=NULL;
  18.317 -                }
  18.318 -                if (rdata->psurfaces[it]!=NULL)
  18.319 -                {
  18.320 -                   if (rdata->psurfaces[it]->palette!=NULL)
  18.321 -                   {
  18.322 -                      SDL_free(rdata->psurfaces[it]->palette);
  18.323 -                      rdata->psurfaces[it]->palette=NULL;
  18.324 -                   }
  18.325 -                   /* Destroy shared memory for PhImage_t */
  18.326 -                   PgShmemDestroy(rdata->psurfaces[it]->image);
  18.327 -                   rdata->psurfaces[it]->image=NULL;
  18.328 -                   SDL_free(rdata->psurfaces[it]);
  18.329 -                   rdata->psurfaces[it]=NULL;
  18.330 -                }
  18.331 -             }
  18.332 -          }
  18.333 -       }
  18.334 -    }
  18.335 -
  18.336 -    /* Check if current device is not the same as target */
  18.337 -    if (phdata->current_device_id != didata->device_id) {
  18.338 -        /* Set target device as default for Pd and Pg functions */
  18.339 -        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
  18.340 -        if (status != 0) {
  18.341 -            SDL_SetError("Photon: Can't set default target device\n");
  18.342 -            return -1;
  18.343 -        }
  18.344 -        phdata->current_device_id = didata->device_id;
  18.345 -    }
  18.346 -
  18.347 -    switch (allocate_task)
  18.348 -    {
  18.349 -       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
  18.350 -            {
  18.351 -               int32_t it;
  18.352 -               int32_t jt;
  18.353 -
  18.354 -               /* Try the hardware accelerated offscreen surfaces first */
  18.355 -               for (it=0; it<rdata->surfaces_count; it++)
  18.356 -               {
  18.357 -                  rdata->osurfaces[it]=PdCreateOffscreenContext(0, window->w, window->h,
  18.358 -                  Pg_OSC_MEM_LINEAR_ACCESSIBLE | Pg_OSC_MEM_PAGE_ALIGN |
  18.359 -                  /* in case if 2D acceleration is available use it */
  18.360 -                  Pg_OSC_MEM_2D_WRITABLE | Pg_OSC_MEM_2D_READABLE);
  18.361 -                  /* If we can't create an offscreen surface, then fallback to software */
  18.362 -                  if (rdata->osurfaces[it]==NULL)
  18.363 -                  {
  18.364 -                     /* Destroy previously allocated surface(s) */
  18.365 -                     for (jt = it - 1; jt > 0; jt--)
  18.366 -                     {
  18.367 -                        PhDCRelease(rdata->osurfaces[jt]);
  18.368 -                        rdata->osurfaces[jt] = NULL;
  18.369 -                     }
  18.370 -                     break;
  18.371 -                  }
  18.372 -               }
  18.373 -
  18.374 -               /* Check if all required surfaces have been created */
  18.375 -               if (rdata->osurfaces[0]!=NULL)
  18.376 -               {
  18.377 -                  rdata->surfaces_type=SDL_PHOTON_SURFTYPE_OFFSCREEN;
  18.378 -                  /* exit from switch if surfaces have been created */
  18.379 -                  break;
  18.380 -               }
  18.381 -               else
  18.382 -               {
  18.383 -                  /* else fall through to software phimage surface allocation */
  18.384 -               }
  18.385 -            }
  18.386 -            /* fall through */
  18.387 -       case SDL_PHOTON_SURFTYPE_PHIMAGE:
  18.388 -            {
  18.389 -               int32_t it;
  18.390 -               int32_t jt;
  18.391 -               uint32_t image_pfmt=photon_sdl_to_image_pixelformat(didata->current_mode.format);
  18.392 -
  18.393 -               /* Try to allocate the software surfaces in shared memory */
  18.394 -               for (it=0; it<rdata->surfaces_count; it++)
  18.395 -               {
  18.396 -                  /* If this surface with palette, create a palette space */
  18.397 -                  if (image_pfmt==Pg_IMAGE_PALETTE_BYTE)
  18.398 -                  {
  18.399 -                     rdata->psurfaces[it]=PhCreateImage(NULL, window->w, window->h,
  18.400 -                        image_pfmt, NULL, 256, 1);
  18.401 -                  }
  18.402 -                  else
  18.403 -                  {
  18.404 -                     rdata->psurfaces[it]=PhCreateImage(NULL, window->w, window->h,
  18.405 -                        image_pfmt, NULL, 0, 1);
  18.406 -                  }
  18.407 -
  18.408 -                  if (rdata->psurfaces[it]!=NULL)
  18.409 -                  {
  18.410 -                     PhPoint_t translation={0, 0};
  18.411 -                     PhDim_t   dimension={window->w, window->h};
  18.412 -
  18.413 -                     /* Create memory context for PhImage_t */
  18.414 -                     rdata->pcontexts[it]=PmMemCreateMC(rdata->psurfaces[it], &dimension, &translation);
  18.415 -                  }
  18.416 -
  18.417 -                  if ((rdata->psurfaces[it]==NULL) || (rdata->pcontexts[it]==NULL))
  18.418 -                  {
  18.419 -                     /* Destroy previously allocated surface(s) */
  18.420 -                     for (jt = it - 1; jt > 0; jt--)
  18.421 -                     {
  18.422 -                        if (rdata->pcontexts[jt]!=NULL)
  18.423 -                        {
  18.424 -                           PmMemReleaseMC(rdata->pcontexts[it]);
  18.425 -                           rdata->pcontexts[jt]=NULL;
  18.426 -                        }
  18.427 -                        if (rdata->psurfaces[jt]!=NULL)
  18.428 -                        {
  18.429 -                           if (rdata->psurfaces[jt]->palette!=NULL)
  18.430 -                           {
  18.431 -                              SDL_free(rdata->psurfaces[jt]->palette);
  18.432 -                              rdata->psurfaces[jt]->palette=NULL;
  18.433 -                           }
  18.434 -                           /* Destroy shared memory for PhImage_t */
  18.435 -                           PgShmemDestroy(rdata->psurfaces[jt]->image);
  18.436 -                           rdata->psurfaces[jt]->image=NULL;
  18.437 -                           SDL_free(rdata->psurfaces[jt]);
  18.438 -                           rdata->psurfaces[jt] = NULL;
  18.439 -                        }
  18.440 -                     }
  18.441 -                     break;
  18.442 -                  }
  18.443 -               }
  18.444 -
  18.445 -               /* Check if all required surfaces have been created */
  18.446 -               if (rdata->psurfaces[0]!=NULL)
  18.447 -               {
  18.448 -                  rdata->surfaces_type=SDL_PHOTON_SURFTYPE_PHIMAGE;
  18.449 -               }
  18.450 -               else
  18.451 -               {
  18.452 -                  rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN;
  18.453 -               }
  18.454 -            }
  18.455 -            break;
  18.456 -       case SDL_PHOTON_SURFTYPE_UNKNOWN:
  18.457 -       default:
  18.458 -            {
  18.459 -               /* do nothing with surface allocation */
  18.460 -               rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN;
  18.461 -            }
  18.462 -            break;
  18.463 -    }
  18.464 -
  18.465 -    /* Check if one of two allocation scheme was successful */
  18.466 -    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
  18.467 -    {
  18.468 -       SDL_SetError("Photon: primary surface(s) allocation failure");
  18.469 -       return -1;
  18.470 -    }
  18.471 -
  18.472 -    /* Store current surface dimensions */
  18.473 -    rdata->window_width=window->w;
  18.474 -    rdata->window_height=window->h;
  18.475 -
  18.476 -    /* If current copy/flip scheme is single buffer, then set initial parameters */
  18.477 -    if ((renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)==SDL_RENDERER_SINGLEBUFFER)
  18.478 -    {
  18.479 -       rdata->surface_visible_idx = 0;
  18.480 -       rdata->surface_render_idx = 0;
  18.481 -    }
  18.482 -
  18.483 -    /* If current copy/flip scheme is double buffer, then set initial parameters */
  18.484 -    if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP2)==SDL_RENDERER_PRESENTFLIP2)
  18.485 -    {
  18.486 -       rdata->surface_visible_idx = 0;
  18.487 -       rdata->surface_render_idx = 1;
  18.488 -    }
  18.489 -
  18.490 -    /* If current copy/flip scheme is triple buffer, then set initial parameters */
  18.491 -    if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP3)==SDL_RENDERER_PRESENTFLIP3)
  18.492 -    {
  18.493 -       rdata->surface_visible_idx = 0;
  18.494 -       rdata->surface_render_idx = 1;
  18.495 -    }
  18.496 -
  18.497 -    switch (rdata->surfaces_type)
  18.498 -    {
  18.499 -       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
  18.500 -            PgSetGCCx(rdata->osurfaces[rdata->surface_render_idx], rdata->gc);
  18.501 -            break;
  18.502 -       case SDL_PHOTON_SURFTYPE_PHIMAGE:
  18.503 -            PgSetGCCx(rdata->pcontexts[rdata->surface_render_idx], rdata->gc);
  18.504 -            break;
  18.505 -       case SDL_PHOTON_SURFTYPE_UNKNOWN:
  18.506 -       default:
  18.507 -            break;
  18.508 -    }
  18.509 -
  18.510 -    return 0;
  18.511 -}
  18.512 -
  18.513 -int _photon_update_rectangles(SDL_Renderer* renderer, PhRect_t* rect)
  18.514 -{
  18.515 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.516 -   SDL_Window *window = window=SDL_GetWindowFromID(renderer->window);
  18.517 -   SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
  18.518 -   PhPoint_t src_point;
  18.519 -
  18.520 -   /* If currently single buffer is in use, we have to flush all data */
  18.521 -   if (rdata->surface_render_idx==rdata->surface_visible_idx)
  18.522 -   {
  18.523 -      /* Flush all undrawn graphics data to surface */
  18.524 -      switch (rdata->surfaces_type)
  18.525 -      {
  18.526 -          case SDL_PHOTON_SURFTYPE_OFFSCREEN:
  18.527 -               PgFlushCx(rdata->osurfaces[rdata->surface_visible_idx]);
  18.528 -               PgWaitHWIdle();
  18.529 -               break;
  18.530 -          case SDL_PHOTON_SURFTYPE_PHIMAGE:
  18.531 -               PmMemFlush(rdata->pcontexts[rdata->surface_visible_idx], rdata->psurfaces[rdata->surface_visible_idx]);
  18.532 -               break;
  18.533 -          case SDL_PHOTON_SURFTYPE_UNKNOWN:
  18.534 -          default:
  18.535 -               return;
  18.536 -      }
  18.537 -   }
  18.538 -
  18.539 -   PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window));
  18.540 -
  18.541 -   src_point.x = rect->ul.x;
  18.542 -   src_point.y = rect->ul.y;
  18.543 -
  18.544 -   switch (rdata->surfaces_type)
  18.545 -   {
  18.546 -       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
  18.547 -            PgContextBlit(rdata->osurfaces[rdata->surface_visible_idx], rect, NULL, rect);
  18.548 -            break;
  18.549 -       case SDL_PHOTON_SURFTYPE_PHIMAGE:
  18.550 -            PgDrawPhImageRectv(&src_point, rdata->psurfaces[rdata->surface_visible_idx], rect, 0);
  18.551 -            break;
  18.552 -       case SDL_PHOTON_SURFTYPE_UNKNOWN:
  18.553 -       default:
  18.554 -            break;
  18.555 -   }
  18.556 -}
  18.557 -
  18.558 -int _photon_set_blending(SDL_Renderer* renderer, uint32_t blendmode, uint32_t globalalpha, uint32_t blendsource)
  18.559 -{
  18.560 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.561 -
  18.562 -   /* Switch on requested graphics context modifiers */
  18.563 -   switch (blendmode)
  18.564 -   {
  18.565 -      case SDL_BLENDMODE_BLEND:
  18.566 -           /* Enable and set chroma key and alpha blending */
  18.567 -           if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
  18.568 -           {
  18.569 -              PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
  18.570 -              PgChromaOnCx(rdata->gc);
  18.571 -           }
  18.572 -           PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1mAs, NULL, NULL, globalalpha, 0);
  18.573 -           PgAlphaOnCx(rdata->gc);
  18.574 -           break;
  18.575 -      case SDL_BLENDMODE_ADD:
  18.576 -           /* Enable and set chroma key and alpha blending */
  18.577 -           if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
  18.578 -           {
  18.579 -              PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
  18.580 -              PgChromaOnCx(rdata->gc);
  18.581 -           }
  18.582 -           PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1, NULL, NULL, globalalpha, 0);
  18.583 -           PgAlphaOnCx(rdata->gc);
  18.584 -           break;
  18.585 -      case SDL_BLENDMODE_NONE:
  18.586 -           /* Do nothing */
  18.587 -           break;
  18.588 -      default:
  18.589 -           return -1;
  18.590 -   }
  18.591 -
  18.592 -   return 0;
  18.593 -}
  18.594 -
  18.595 -int _photon_reset_blending(SDL_Renderer* renderer, uint32_t blendmode, uint32_t blendsource)
  18.596 -{
  18.597 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.598 -
  18.599 -   /* Switch off graphics context modifiers */
  18.600 -   switch (blendmode)
  18.601 -   {
  18.602 -      case SDL_BLENDMODE_BLEND:
  18.603 -           /* Disable chroma key and alpha blending */
  18.604 -           if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
  18.605 -           {
  18.606 -              PgChromaOffCx(rdata->gc);
  18.607 -           }
  18.608 -           PgAlphaOffCx(rdata->gc);
  18.609 -           break;
  18.610 -      case SDL_BLENDMODE_ADD:
  18.611 -           /* Disable chroma key and alpha blending */
  18.612 -           if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
  18.613 -           {
  18.614 -              PgChromaOffCx(rdata->gc);
  18.615 -           }
  18.616 -           PgAlphaOffCx(rdata->gc);
  18.617 -           break;
  18.618 -      case SDL_BLENDMODE_NONE:
  18.619 -           /* Do nothing */
  18.620 -           break;
  18.621 -      default:
  18.622 -           return -1;
  18.623 -   }
  18.624 -
  18.625 -   return 0;
  18.626 -}
  18.627 -
  18.628 -/****************************************************************************/
  18.629 -/* SDL render interface                                                     */
  18.630 -/****************************************************************************/
  18.631 -
  18.632 -static int
  18.633 -photon_activaterenderer(SDL_Renderer * renderer)
  18.634 -{
  18.635 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.636 -   SDL_Window *window = SDL_GetWindowFromID(renderer->window);
  18.637 -   SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;
  18.638 -
  18.639 -   if ((rdata->window_width!=window->w) || (rdata->window_height!=window->h))
  18.640 -   {
  18.641 -      return _photon_recreate_surfaces(renderer);
  18.642 -   }
  18.643 -
  18.644 -   switch (rdata->surfaces_type)
  18.645 -   {
  18.646 -      case SDL_PHOTON_SURFTYPE_OFFSCREEN:
  18.647 -           PgSetGCCx(rdata->osurfaces[rdata->surface_render_idx], rdata->gc);
  18.648 -           break;
  18.649 -      case SDL_PHOTON_SURFTYPE_PHIMAGE:
  18.650 -           PgSetGCCx(rdata->pcontexts[rdata->surface_render_idx], rdata->gc);
  18.651 -           break;
  18.652 -      case SDL_PHOTON_SURFTYPE_UNKNOWN:
  18.653 -      default:
  18.654 -           break;
  18.655 -   }
  18.656 -
  18.657 -   return 0;
  18.658 -}
  18.659 -
  18.660 -static int
  18.661 -photon_displaymodechanged(SDL_Renderer * renderer)
  18.662 -{
  18.663 -    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.664 -    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
  18.665 -    SDL_VideoDisplay *display = window->display;
  18.666 -    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
  18.667 -
  18.668 -    /* Copy direct_mode status */
  18.669 -    rdata->direct_mode=didata->direct_mode;
  18.670 -
  18.671 -    /* Update the surfaces */
  18.672 -    return _photon_recreate_surfaces(renderer);
  18.673 -}
  18.674 -
  18.675 -static int
  18.676 -photon_createtexture(SDL_Renderer * renderer, SDL_Texture * texture)
  18.677 -{
  18.678 -    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.679 -    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
  18.680 -    SDL_VideoDisplay *display = window->display;
  18.681 -    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
  18.682 -    SDL_TextureData *tdata = NULL;
  18.683 -    uint32_t it;
  18.684 -
  18.685 -    /* Check, if it is not initialized */
  18.686 -    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
  18.687 -    {
  18.688 -       SDL_SetError("Photon: can't create texture for OpenGL ES window");
  18.689 -       return -1;
  18.690 -    }
  18.691 -
  18.692 -    /* Check if requested texture format is supported */
  18.693 -    for (it=0; it<renderer->info.num_texture_formats; it++)
  18.694 -    {
  18.695 -       if (renderer->info.texture_formats[it]==texture->format)
  18.696 -       {
  18.697 -          break;
  18.698 -       }
  18.699 -    }
  18.700 -    if (it==renderer->info.num_texture_formats)
  18.701 -    {
  18.702 -       SDL_SetError("Photon: requested texture format is not supported");
  18.703 -       return -1;
  18.704 -    }
  18.705 -
  18.706 -    /* Allocate texture driver data */
  18.707 -    tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData));
  18.708 -    if (tdata == NULL) {
  18.709 -        SDL_OutOfMemory();
  18.710 -        return -1;
  18.711 -    }
  18.712 -
  18.713 -    /* Set texture driver data */
  18.714 -    texture->driverdata = tdata;
  18.715 -
  18.716 -    /* Try offscreen allocation only in case if displayable buffers are also offscreen */
  18.717 -    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN)
  18.718 -    {
  18.719 -       /* Try to allocate offscreen memory first */
  18.720 -       tdata->osurface=PdCreateOffscreenContext(0, texture->w, texture->h,
  18.721 -                       Pg_OSC_MEM_LINEAR_ACCESSIBLE | Pg_OSC_MEM_PAGE_ALIGN |
  18.722 -                       /* in case if 2D acceleration is available use it */
  18.723 -                       Pg_OSC_MEM_2D_WRITABLE | Pg_OSC_MEM_2D_READABLE);
  18.724 -    }
  18.725 -
  18.726 -    /* Check if offscreen allocation has been failed or not performed */
  18.727 -    if (tdata->osurface==NULL)
  18.728 -    {
  18.729 -       PhPoint_t translation={0, 0};
  18.730 -       PhDim_t   dimension={texture->w, texture->h};
  18.731 -       uint32_t  image_pfmt=photon_sdl_to_image_pixelformat(didata->current_mode.format);
  18.732 -
  18.733 -       /* Allocate photon image */
  18.734 -       if (image_pfmt==Pg_IMAGE_PALETTE_BYTE)
  18.735 -       {
  18.736 -          tdata->psurface=PhCreateImage(NULL, texture->w, texture->h,
  18.737 -                          image_pfmt, NULL, 256, 1);
  18.738 -       }
  18.739 -       else
  18.740 -       {
  18.741 -          tdata->psurface=PhCreateImage(NULL, texture->w, texture->h,
  18.742 -                          image_pfmt, NULL, 0, 1);
  18.743 -       }
  18.744 -
  18.745 -       if (tdata->psurface==NULL)
  18.746 -       {
  18.747 -          return -1;
  18.748 -       }
  18.749 -
  18.750 -       /* Create memory context for PhImage_t */
  18.751 -       tdata->pcontext=PmMemCreateMC(tdata->psurface, &dimension, &translation);
  18.752 -       if (tdata->pcontext==NULL)
  18.753 -       {
  18.754 -          /* Destroy PhImage */
  18.755 -          if (tdata->psurface!=NULL)
  18.756 -          {
  18.757 -             if (tdata->psurface->palette!=NULL)
  18.758 -             {
  18.759 -                SDL_free(tdata->psurface->palette);
  18.760 -                tdata->psurface->palette=NULL;
  18.761 -             }
  18.762 -             /* Destroy shared memory for PhImage_t */
  18.763 -             PgShmemDestroy(tdata->psurface->image);
  18.764 -             tdata->psurface->image=NULL;
  18.765 -             SDL_free(tdata->psurface);
  18.766 -             tdata->psurface=NULL;
  18.767 -          }
  18.768 -       }
  18.769 -       tdata->surface_type=SDL_PHOTON_SURFTYPE_PHIMAGE;
  18.770 -    }
  18.771 -    else
  18.772 -    {
  18.773 -       tdata->surface_type=SDL_PHOTON_SURFTYPE_OFFSCREEN;
  18.774 -    }
  18.775 -
  18.776 -    return 0;
  18.777 -}
  18.778 -
  18.779 -static int
  18.780 -photon_querytexturepixels(SDL_Renderer * renderer, SDL_Texture * texture,
  18.781 -                          void **pixels, int *pitch)
  18.782 -{
  18.783 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.784 -   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
  18.785 -
  18.786 -   /* Check, if it is not initialized */
  18.787 -   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
  18.788 -   {
  18.789 -      SDL_SetError("Photon: can't query texture pixels for OpenGL ES window");
  18.790 -      return -1;
  18.791 -   }
  18.792 -
  18.793 -   /* Clear outcoming parameters */
  18.794 -   *pixels=NULL;
  18.795 -   *pitch=0;
  18.796 -
  18.797 -   switch (tdata->surface_type)
  18.798 -   {
  18.799 -      case SDL_PHOTON_SURFTYPE_OFFSCREEN:
  18.800 -           *pixels=(void*)PdGetOffscreenContextPtr(tdata->osurface);
  18.801 -           *pitch=tdata->osurface->pitch;
  18.802 -           break;
  18.803 -      case SDL_PHOTON_SURFTYPE_PHIMAGE:
  18.804 -           *pixels=(void*)tdata->psurface->image;
  18.805 -           *pitch=tdata->psurface->bpl;
  18.806 -           break;
  18.807 -      default:
  18.808 -           break;
  18.809 -   }
  18.810 -
  18.811 -   return 0;
  18.812 -}
  18.813 -
  18.814 -static int
  18.815 -photon_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture,
  18.816 -                     const SDL_Rect * rect, const void *pixels, int pitch)
  18.817 -{
  18.818 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.819 -   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
  18.820 -
  18.821 -   uint8_t* src=(uint8_t*)pixels;
  18.822 -   uint8_t* dst;
  18.823 -   uint32_t dst_pitch;
  18.824 -   uint32_t it;
  18.825 -   uint32_t copy_length;
  18.826 -
  18.827 -   /* Check, if it is not initialized */
  18.828 -   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
  18.829 -   {
  18.830 -       SDL_SetError("Photon: can't update texture for OpenGL ES window");
  18.831 -       return -1;
  18.832 -   }
  18.833 -
  18.834 -   switch (tdata->surface_type)
  18.835 -   {
  18.836 -      case SDL_PHOTON_SURFTYPE_OFFSCREEN:
  18.837 -           dst=(uint8_t*)PdGetOffscreenContextPtr(tdata->osurface);
  18.838 -           dst_pitch=tdata->osurface->pitch;
  18.839 -           if (dst==NULL)
  18.840 -           {
  18.841 -              SDL_SetError("Photon: can't get pointer to texture surface");
  18.842 -              return -1;
  18.843 -           }
  18.844 -           break;
  18.845 -      case SDL_PHOTON_SURFTYPE_PHIMAGE:
  18.846 -           dst=(uint8_t*)tdata->psurface->image;
  18.847 -           dst_pitch=tdata->psurface->bpl;
  18.848 -           if (dst==NULL)
  18.849 -           {
  18.850 -              SDL_SetError("Photon: can't get pointer to texture surface");
  18.851 -              return -1;
  18.852 -           }
  18.853 -           break;
  18.854 -      default:
  18.855 -           SDL_SetError("Photon: invalid internal surface type");
  18.856 -           return -1;
  18.857 -   }
  18.858 -
  18.859 -   dst+=rect->y * dst_pitch + rect->x * SDL_BYTESPERPIXEL(texture->format);
  18.860 -   copy_length=rect->w * SDL_BYTESPERPIXEL(texture->format);
  18.861 -   for (it = 0; it < rect->h; it++)
  18.862 -   {
  18.863 -      SDL_memcpy(dst, src, copy_length);
  18.864 -      src+=pitch;
  18.865 -      dst+=dst_pitch;
  18.866 -   }
  18.867 -
  18.868 -   return 0;
  18.869 -}
  18.870 -
  18.871 -static int
  18.872 -photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
  18.873 -                   const SDL_Rect * rect, int markDirty, void **pixels,
  18.874 -                   int *pitch)
  18.875 -{
  18.876 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.877 -   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
  18.878 -
  18.879 -   /* Check, if it is not initialized */
  18.880 -   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
  18.881 -   {
  18.882 -       SDL_SetError("Photon: can't lock texture for OpenGL ES window");
  18.883 -       return -1;
  18.884 -   }
  18.885 -
  18.886 -   /* Clear outcoming parameters */
  18.887 -   *pixels=NULL;
  18.888 -   *pitch=0;
  18.889 -
  18.890 -   switch (tdata->surface_type)
  18.891 -   {
  18.892 -      case SDL_PHOTON_SURFTYPE_OFFSCREEN:
  18.893 -           *pixels=(void*)((uint8_t*)PdGetOffscreenContextPtr(tdata->osurface) +
  18.894 -                   rect->y * tdata->osurface->pitch +
  18.895 -                   rect->x * SDL_BYTESPERPIXEL(texture->format));
  18.896 -           *pitch=tdata->osurface->pitch;
  18.897 -           break;
  18.898 -      case SDL_PHOTON_SURFTYPE_PHIMAGE:
  18.899 -           *pixels=(void*)((uint8_t*)tdata->psurface->image +
  18.900 -                   rect->y * tdata->osurface->pitch +
  18.901 -                   rect->x * SDL_BYTESPERPIXEL(texture->format));
  18.902 -           *pitch=tdata->psurface->bpl;
  18.903 -           break;
  18.904 -      default:
  18.905 -           break;
  18.906 -   }
  18.907 -
  18.908 -   return 0;
  18.909 -}
  18.910 -
  18.911 -static void
  18.912 -photon_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture)
  18.913 -{
  18.914 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.915 -
  18.916 -   /* Check, if it is not initialized */
  18.917 -   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
  18.918 -   {
  18.919 -       SDL_SetError("Photon: can't unlock texture for OpenGL ES window");
  18.920 -       return;
  18.921 -   }
  18.922 -}
  18.923 -
  18.924 -static void
  18.925 -photon_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture,
  18.926 -                    int numrects, const SDL_Rect * rects)
  18.927 -{
  18.928 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.929 -
  18.930 -   /* Check, if it is not initialized */
  18.931 -   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
  18.932 -   {
  18.933 -       SDL_SetError("Photon: can't update dirty texture for OpenGL ES window");
  18.934 -       return;
  18.935 -   }
  18.936 -}
  18.937 -
  18.938 -static int
  18.939 -photon_renderpoint(SDL_Renderer * renderer, int x, int y)
  18.940 -{
  18.941 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.942 -
  18.943 -   /* Check, if it is not initialized */
  18.944 -   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
  18.945 -   {
  18.946 -       SDL_SetError("Photon: can't render point in OpenGL ES window");
  18.947 -       return -1;
  18.948 -   }
  18.949 -
  18.950 -   /* Enable blending, if requested */
  18.951 -   _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
  18.952 -
  18.953 -   switch (rdata->surfaces_type)
  18.954 -   {
  18.955 -       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
  18.956 -            PgDrawIPixelCx(rdata->osurfaces[rdata->surface_render_idx], x, y);
  18.957 -            break;
  18.958 -       case SDL_PHOTON_SURFTYPE_PHIMAGE:
  18.959 -            PgDrawIPixelCx(rdata->pcontexts[rdata->surface_render_idx], x, y);
  18.960 -            break;
  18.961 -       case SDL_PHOTON_SURFTYPE_UNKNOWN:
  18.962 -       default:
  18.963 -            break;
  18.964 -   }
  18.965 -
  18.966 -   /* Disable blending, if it was enabled */
  18.967 -   _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
  18.968 -
  18.969 -   return 0;
  18.970 -}
  18.971 -
  18.972 -static int
  18.973 -photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
  18.974 -{
  18.975 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
  18.976 -
  18.977 -   /* Check, if it is not initialized */
  18.978 -   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
  18.979 -   {
  18.980 -       SDL_SetError("Photon: can't render line in OpenGL ES window");
  18.981 -       return -1;
  18.982 -   }
  18.983 -
  18.984 -   /* Enable blending, if requested */
  18.985 -   _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
  18.986 -
  18.987 -   switch (rdata->surfaces_type)
  18.988 -   {
  18.989 -       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
  18.990 -            PgDrawILineCx(rdata->osurfaces[rdata->surface_render_idx], x1, y1, x2, y2);
  18.991 -            break;
  18.992 -       case SDL_PHOTON_SURFTYPE_PHIMAGE:
  18.993 -            PgDrawILineCx(rdata->pcontexts[rdata->surface_render_idx], x1, y1, x2, y2);
  18.994 -            break;
  18.995 -       case SDL_PHOTON_SURFTYPE_UNKNOWN:
  18.996 -       default:
  18.997 -            break;
  18.998 -   }
  18.999 -
 18.1000 -   /* Disable blending, if it was enabled */
 18.1001 -   _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
 18.1002 -
 18.1003 -   return 0;
 18.1004 -}
 18.1005 -
 18.1006 -static int
 18.1007 -photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect)
 18.1008 -{
 18.1009 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
 18.1010 -
 18.1011 -   /* Check, if it is not initialized */
 18.1012 -   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
 18.1013 -   {
 18.1014 -       SDL_SetError("Photon: can't render filled box in OpenGL ES window");
 18.1015 -       return -1;
 18.1016 -   }
 18.1017 -
 18.1018 -   /* Enable blending, if requested */
 18.1019 -   _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
 18.1020 -
 18.1021 -   switch (rdata->surfaces_type)
 18.1022 -   {
 18.1023 -       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1024 -            PgDrawIRectCx(rdata->osurfaces[rdata->surface_render_idx], rect->x, rect->y, rect->w+rect->x-1, rect->h+rect->y-1, Pg_DRAW_FILL);
 18.1025 -            break;
 18.1026 -       case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1027 -            PgDrawIRectCx(rdata->pcontexts[rdata->surface_render_idx], rect->x, rect->y, rect->w+rect->x-1, rect->h+rect->y-1, Pg_DRAW_FILL);
 18.1028 -            break;
 18.1029 -       case SDL_PHOTON_SURFTYPE_UNKNOWN:
 18.1030 -       default:
 18.1031 -            break;
 18.1032 -   }
 18.1033 -
 18.1034 -   /* Disable blending, if it was enabled */
 18.1035 -   _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
 18.1036 -
 18.1037 -   return 0;
 18.1038 -}
 18.1039 -
 18.1040 -static int
 18.1041 -photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
 18.1042 -                  const SDL_Rect * srcrect, const SDL_Rect * dstrect)
 18.1043 -{
 18.1044 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
 18.1045 -   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
 18.1046 -
 18.1047 -   PhRect_t src_rect;
 18.1048 -   PhRect_t dst_rect;
 18.1049 -   PhPoint_t dst_point;
 18.1050 -
 18.1051 -   /* Check, if it is not initialized */
 18.1052 -   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
 18.1053 -   {
 18.1054 -       SDL_SetError("Photon: can't blit textures in OpenGL ES window");
 18.1055 -       return -1;
 18.1056 -   }
 18.1057 -
 18.1058 -   _photon_set_blending(renderer, texture->blendMode, texture->a, SDL_PHOTON_TEXTURE_BLEND);
 18.1059 -
 18.1060 -   /* Set source blit area */
 18.1061 -   src_rect.ul.x = srcrect->x;
 18.1062 -   src_rect.ul.y = srcrect->y;
 18.1063 -   src_rect.lr.x = srcrect->x + srcrect->w - 1;
 18.1064 -   src_rect.lr.y = srcrect->y + srcrect->h - 1;
 18.1065 -
 18.1066 -   /* Set destination blit area */
 18.1067 -   dst_rect.ul.x = dstrect->x;
 18.1068 -   dst_rect.ul.y = dstrect->y;
 18.1069 -   dst_rect.lr.x = dstrect->x + dstrect->w - 1;
 18.1070 -   dst_rect.lr.y = dstrect->y + dstrect->h - 1;
 18.1071 -
 18.1072 -   /* Set destination point */
 18.1073 -   dst_point.x = dstrect->x;
 18.1074 -   dst_point.y = dstrect->y;
 18.1075 -
 18.1076 -   /* Do blit */
 18.1077 -   switch (rdata->surfaces_type)
 18.1078 -   {
 18.1079 -       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1080 -            /* two possible combinations */
 18.1081 -            switch (tdata->surface_type)
 18.1082 -            {
 18.1083 -               case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1084 -                    /* easiest full accelerated combination: offscreen->offscreen */
 18.1085 -                    PgContextBlitCx(rdata->osurfaces[rdata->surface_render_idx], tdata->osurface,
 18.1086 -                                    &src_rect, rdata->osurfaces[rdata->surface_render_idx], &dst_rect);
 18.1087 -                    break;
 18.1088 -               case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1089 -                    /* not accelerated combination: PhImage->offscreen */
 18.1090 -                    /* scaling is not supported in this method */
 18.1091 -                    PgDrawPhImageRectCxv(rdata->osurfaces[rdata->surface_render_idx], &dst_point,
 18.1092 -                                         tdata->psurface, &src_rect, 0);
 18.1093 -                    break;
 18.1094 -               default:
 18.1095 -                    break;
 18.1096 -            }
 18.1097 -            break;
 18.1098 -       case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1099 -            /* two possible combinations */
 18.1100 -            switch (tdata->surface_type)
 18.1101 -            {
 18.1102 -               case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1103 -                    /* not supported combination: offscreen->PhImage */
 18.1104 -                    return -1;
 18.1105 -               case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1106 -                    /* not accelerated combination, but fast: PhImage->PhImage */
 18.1107 -                    /* scaling is not supported in this method */
 18.1108 -                    PgDrawPhImageRectCxv(rdata->pcontexts[rdata->surface_render_idx], &dst_point, tdata->psurface, &src_rect, 0);
 18.1109 -                    break;
 18.1110 -               default:
 18.1111 -                    break;
 18.1112 -            }
 18.1113 -            break;
 18.1114 -   }
 18.1115 -
 18.1116 -   _photon_reset_blending(renderer, texture->blendMode, SDL_PHOTON_TEXTURE_BLEND);
 18.1117 -
 18.1118 -   return 0;
 18.1119 -}
 18.1120 -
 18.1121 -static void
 18.1122 -photon_renderpresent(SDL_Renderer * renderer)
 18.1123 -{
 18.1124 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
 18.1125 -   SDL_Window *window = window=SDL_GetWindowFromID(renderer->window);
 18.1126 -   SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
 18.1127 -   PhRect_t src_rect;
 18.1128 -   PhPoint_t src_point;
 18.1129 -
 18.1130 -   /* Check, if it is not initialized */
 18.1131 -   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
 18.1132 -   {
 18.1133 -       SDL_SetError("Photon: can't render present for OpenGL ES window");
 18.1134 -       return;
 18.1135 -   }
 18.1136 -
 18.1137 -   /* Flush all undrawn graphics data to surface */
 18.1138 -   switch (rdata->surfaces_type)
 18.1139 -   {
 18.1140 -       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1141 -            PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
 18.1142 -            PgWaitHWIdle();
 18.1143 -            break;
 18.1144 -       case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1145 -            PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]);
 18.1146 -            break;
 18.1147 -       case SDL_PHOTON_SURFTYPE_UNKNOWN:
 18.1148 -       default:
 18.1149 -            return;
 18.1150 -   }
 18.1151 -
 18.1152 -   PgFFlush(Ph_START_DRAW);
 18.1153 -   PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window));
 18.1154 -
 18.1155 -   /* Set blit area */
 18.1156 -   src_rect.ul.x = 0;
 18.1157 -   src_rect.ul.y = 0;
 18.1158 -   src_rect.lr.x = rdata->window_width - 1;
 18.1159 -   src_rect.lr.y = rdata->window_height - 1;
 18.1160 -
 18.1161 -   src_point.x = 0;
 18.1162 -   src_point.y = 0;
 18.1163 -
 18.1164 -   switch (rdata->surfaces_type)
 18.1165 -   {
 18.1166 -       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1167 -            PgContextBlit(rdata->osurfaces[rdata->surface_render_idx], &src_rect, NULL, &src_rect);
 18.1168 -            break;
 18.1169 -       case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1170 -            PgDrawPhImagev(&src_point, rdata->psurfaces[rdata->surface_render_idx], 0);
 18.1171 -            break;
 18.1172 -       case SDL_PHOTON_SURFTYPE_UNKNOWN:
 18.1173 -       default:
 18.1174 -            break;
 18.1175 -   }
 18.1176 -
 18.1177 -   /* finish blit */
 18.1178 -   PgFFlush(Ph_DONE_DRAW);
 18.1179 -   PgWaitHWIdle();
 18.1180 -
 18.1181 -   /* Check if we are using double buffering */
 18.1182 -   if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2)
 18.1183 -   {
 18.1184 -      rdata->surface_visible_idx=rdata->surface_render_idx;
 18.1185 -      rdata->surface_render_idx=(rdata->surface_render_idx + 1) % 2;
 18.1186 -   }
 18.1187 -
 18.1188 -   /* Check if we are using triple buffering */
 18.1189 -   if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) == SDL_RENDERER_PRESENTFLIP3)
 18.1190 -   {
 18.1191 -      rdata->surface_visible_idx=rdata->surface_render_idx;
 18.1192 -      rdata->surface_render_idx=(rdata->surface_render_idx + 1) % 3;
 18.1193 -   }
 18.1194 -}
 18.1195 -
 18.1196 -static void
 18.1197 -photon_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture)
 18.1198 -{
 18.1199 -   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
 18.1200 -   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
 18.1201 -
 18.1202 -   /* Check if partially created texture must be destroyed */
 18.1203 -   if (tdata==NULL)
 18.1204 -   {
 18.1205 -      return;
 18.1206 -   }
 18.1207 -
 18.1208 -   /* Check, if it is not initialized */
 18.1209 -   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
 18.1210 -   {
 18.1211 -       SDL_SetError("Photon: can't destroy texture for OpenGL ES window");
 18.1212 -       return;
 18.1213 -   }
 18.1214 -
 18.1215 -   switch (tdata->surface_type)
 18.1216 -   {
 18.1217 -      case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1218 -           if (tdata->osurface!=NULL)
 18.1219 -           {
 18.1220 -              PhDCRelease(tdata->osurface);
 18.1221 -              tdata->osurface = NULL;
 18.1222 -           }
 18.1223 -           break;
 18.1224 -      case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1225 -           if (tdata->pcontext!=NULL)
 18.1226 -           {
 18.1227 -              PmMemReleaseMC(tdata->pcontext);
 18.1228 -              tdata->pcontext=NULL;
 18.1229 -           }
 18.1230 -
 18.1231 -           if (tdata->psurface!=NULL)
 18.1232 -           {
 18.1233 -              if (tdata->psurface->palette!=NULL)
 18.1234 -              {
 18.1235 -                 SDL_free(tdata->psurface->palette);
 18.1236 -                 tdata->psurface->palette=NULL;
 18.1237 -              }
 18.1238 -              /* Destroy shared memory for PhImage_t */
 18.1239 -              PgShmemDestroy(tdata->psurface->image);
 18.1240 -              tdata->psurface->image=NULL;
 18.1241 -              SDL_free(tdata->psurface);
 18.1242 -              tdata->psurface=NULL;
 18.1243 -           }
 18.1244 -           break;
 18.1245 -      default:
 18.1246 -           break;
 18.1247 -   }
 18.1248 -}
 18.1249 -
 18.1250 -static void
 18.1251 -photon_destroyrenderer(SDL_Renderer * renderer)
 18.1252 -{
 18.1253 -    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
 18.1254 -    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
 18.1255 -    SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;
 18.1256 -    uint32_t it;
 18.1257 -
 18.1258 -    /* Before destroying the renderer, be sure, that rendering was completed */
 18.1259 -    PgFlush();
 18.1260 -    PgWaitHWIdle();
 18.1261 -
 18.1262 -    /* Destroy graphics context */
 18.1263 -    if (rdata->gc!=NULL)
 18.1264 -    {
 18.1265 -       PgDestroyGC(rdata->gc);
 18.1266 -       rdata->gc=NULL;
 18.1267 -    }
 18.1268 -
 18.1269 -    switch (rdata->surfaces_type)
 18.1270 -    {
 18.1271 -       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1272 -            {
 18.1273 -               /* Destroy current surfaces */
 18.1274 -               for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++)
 18.1275 -               {
 18.1276 -                  if (rdata->osurfaces[it] != NULL)
 18.1277 -                  {
 18.1278 -                     PhDCRelease(rdata->osurfaces[it]);
 18.1279 -                     rdata->osurfaces[it] = NULL;
 18.1280 -                  }
 18.1281 -               }
 18.1282 -            }
 18.1283 -            break;
 18.1284 -       case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1285 -            {
 18.1286 -               /* Destroy current surfaces */
 18.1287 -               for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++)
 18.1288 -               {
 18.1289 -                  if (rdata->pcontexts[it]!=NULL)
 18.1290 -                  {
 18.1291 -                     PmMemReleaseMC(rdata->pcontexts[it]);
 18.1292 -                     rdata->pcontexts[it]=NULL;
 18.1293 -                  }
 18.1294 -                  if (rdata->psurfaces[it]!=NULL)
 18.1295 -                  {
 18.1296 -                     if (rdata->psurfaces[it]->palette!=NULL)
 18.1297 -                     {
 18.1298 -                        SDL_free(rdata->psurfaces[it]->palette);
 18.1299 -                        rdata->psurfaces[it]->palette=NULL;
 18.1300 -                     }
 18.1301 -                     /* Destroy shared memory for PhImage_t */
 18.1302 -                     PgShmemDestroy(rdata->psurfaces[it]->image);
 18.1303 -                     rdata->psurfaces[it]->image=NULL;
 18.1304 -                     SDL_free(rdata->psurfaces[it]);
 18.1305 -                     rdata->psurfaces[it]=NULL;
 18.1306 -                  }
 18.1307 -               }
 18.1308 -            }
 18.1309 -            break;
 18.1310 -       case SDL_PHOTON_SURFTYPE_UNKNOWN:
 18.1311 -       default:
 18.1312 -            {
 18.1313 -               /* nothing to do */
 18.1314 -            }
 18.1315 -            break;
 18.1316 -    }
 18.1317 -}
 18.1318 -
 18.1319 -static int
 18.1320 -photon_renderreadpixels(SDL_Renderer * renderer, const SDL_Rect * rect,
 18.1321 -                        Uint32 format, void * pixels, int pitch)
 18.1322 -{
 18.1323 -    SDL_RenderData *rdata = (SDL_RenderData *)renderer->driverdata;
 18.1324 -    Uint32 sformat=0;
 18.1325 -    uint8_t* spixels=NULL;
 18.1326 -    unsigned int spitch=0;
 18.1327 -
 18.1328 -    /* Flush all undrawn graphics data to surface */
 18.1329 -    switch (rdata->surfaces_type)
 18.1330 -    {
 18.1331 -        case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1332 -             PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
 18.1333 -             PgWaitHWIdle();
 18.1334 -             break;
 18.1335 -        case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1336 -             PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]);
 18.1337 -             break;
 18.1338 -        case SDL_PHOTON_SURFTYPE_UNKNOWN:
 18.1339 -        default:
 18.1340 -             return;
 18.1341 -    }
 18.1342 -
 18.1343 -    switch (rdata->surfaces_type)
 18.1344 -    {
 18.1345 -        case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1346 -             sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_render_idx]->format);
 18.1347 -             spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_render_idx]);
 18.1348 -             spitch=rdata->osurfaces[rdata->surface_render_idx]->pitch;
 18.1349 -             break;
 18.1350 -        case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1351 -             sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_render_idx]->type);
 18.1352 -             spixels=(uint8_t*)rdata->psurfaces[rdata->surface_render_idx]->image;
 18.1353 -             spitch=rdata->psurfaces[rdata->surface_render_idx]->bpl;
 18.1354 -             break;
 18.1355 -        case SDL_PHOTON_SURFTYPE_UNKNOWN:
 18.1356 -        default:
 18.1357 -             SDL_SetError("Photon: surfaces are not initialized");
 18.1358 -             return -1;
 18.1359 -    }
 18.1360 -
 18.1361 -    /* Adjust surface pixels pointer to the rectangle coordinates */
 18.1362 -    spixels+=rect->y*spitch + rect->x*SDL_BYTESPERPIXEL(sformat);
 18.1363 -
 18.1364 -    SDL_ConvertPixels(rect->w, rect->h,
 18.1365 -                      sformat, spixels, spitch,
 18.1366 -                      format, pixels, pitch);
 18.1367 -
 18.1368 -    return 0;
 18.1369 -}
 18.1370 -
 18.1371 -static int
 18.1372 -photon_renderwritepixels(SDL_Renderer * renderer, const SDL_Rect * rect,
 18.1373 -                         Uint32 format, const void * pixels, int pitch)
 18.1374 -{
 18.1375 -    SDL_RenderData *rdata = (SDL_RenderData *)renderer->driverdata;
 18.1376 -    Uint32 sformat=0;
 18.1377 -    uint8_t* spixels=NULL;
 18.1378 -    unsigned int spitch=0;
 18.1379 -
 18.1380 -    /* Flush all undrawn graphics data to surface */
 18.1381 -    switch (rdata->surfaces_type)
 18.1382 -    {
 18.1383 -        case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1384 -             PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
 18.1385 -             PgWaitHWIdle();
 18.1386 -             break;
 18.1387 -        case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1388 -             PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]);
 18.1389 -             break;
 18.1390 -        case SDL_PHOTON_SURFTYPE_UNKNOWN:
 18.1391 -        default:
 18.1392 -             return;
 18.1393 -    }
 18.1394 -
 18.1395 -    switch (rdata->surfaces_type)
 18.1396 -    {
 18.1397 -        case SDL_PHOTON_SURFTYPE_OFFSCREEN:
 18.1398 -             sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_render_idx]->format);
 18.1399 -             spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_render_idx]);
 18.1400 -             spitch=rdata->osurfaces[rdata->surface_render_idx]->pitch;
 18.1401 -             break;
 18.1402 -        case SDL_PHOTON_SURFTYPE_PHIMAGE:
 18.1403 -             sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_render_idx]->type);
 18.1404 -             spixels=(uint8_t*)rdata->psurfaces[rdata->surface_render_idx]->image;
 18.1405 -             spitch=rdata->psurfaces[rdata->surface_render_idx]->bpl;
 18.1406 -             break;
 18.1407 -        case SDL_PHOTON_SURFTYPE_UNKNOWN:
 18.1408 -        default:
 18.1409 -             SDL_SetError("Photon: surfaces are not initialized");
 18.1410 -             return -1;
 18.1411 -    }
 18.1412 -
 18.1413 -    /* Adjust surface pixels pointer to the rectangle coordinates */
 18.1414 -    spixels+=rect->y*spitch + rect->x*SDL_BYTESPERPIXEL(sformat);
 18.1415 -
 18.1416 -    SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch,
 18.1417 -                      sformat, spixels, spitch);
 18.1418 -
 18.1419 -    return 0;
 18.1420 -}
 18.1421 -
 18.1422 -/* vi: set ts=4 sw=4 expandtab: */
    19.1 --- a/src/video/photon/SDL_photon_render.h	Tue Feb 01 21:23:43 2011 -0800
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,76 +0,0 @@
    19.4 -/*
    19.5 -    SDL - Simple DirectMedia Layer
    19.6 -    Copyright (C) 1997-2010 Sam Lantinga
    19.7 -
    19.8 -    This library is free software; you can redistribute it and/or
    19.9 -    modify it under the terms of the GNU Lesser General Public
   19.10 -    License as published by the Free Software Foundation; either
   19.11 -    version 2.1 of the License, or (at your option) any later version.
   19.12 -
   19.13 -    This library is distributed in the hope that it will be useful,
   19.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   19.16 -    Lesser General Public License for more details.
   19.17 -
   19.18 -    You should have received a copy of the GNU Lesser General Public
   19.19 -    License along with this library; if not, write to the Free Software
   19.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   19.21 -
   19.22 -    Sam Lantinga
   19.23 -    slouken@libsdl.org
   19.24 -
   19.25 -    QNX Photon GUI SDL driver
   19.26 -    Copyright (C) 2009 Mike Gorchak
   19.27 -    (mike@malva.ua, lestat@i.com.ua)
   19.28 -*/
   19.29 -
   19.30 -#ifndef __SDL_PHOTON_RENDER_H__
   19.31 -#define __SDL_PHOTON_RENDER_H__
   19.32 -
   19.33 -#include "../SDL_sysvideo.h"
   19.34 -
   19.35 -#include <Ph.h>
   19.36 -#include <photon/PhRender.h>
   19.37 -
   19.38 -#define SDL_PHOTON_MAX_SURFACES 3
   19.39 -
   19.40 -#define SDL_PHOTON_SURFTYPE_UNKNOWN    0x00000000
   19.41 -#define SDL_PHOTON_SURFTYPE_OFFSCREEN  0x00000001
   19.42 -#define SDL_PHOTON_SURFTYPE_PHIMAGE    0x00000002
   19.43 -
   19.44 -#define SDL_PHOTON_UNKNOWN_BLEND       0x00000000
   19.45 -#define SDL_PHOTON_DRAW_BLEND          0x00000001
   19.46 -#define SDL_PHOTON_TEXTURE_BLEND       0x00000002
   19.47 -
   19.48 -typedef struct SDL_RenderData
   19.49 -{
   19.50 -    SDL_bool enable_vsync;              /* VSYNC flip synchronization enable  */
   19.51 -    uint32_t surface_visible_idx;       /* Index of visible surface           */
   19.52 -    uint32_t surface_render_idx;        /* Index of render surface            */
   19.53 -    uint32_t surfaces_count;            /* Amount of allocated surfaces       */
   19.54 -    uint32_t surfaces_type;             /* Type of allocated surfaces         */
   19.55 -    uint32_t window_width;              /* Last active window width           */
   19.56 -    uint32_t window_height;             /* Last active window height          */
   19.57 -    PhGC_t* gc;                         /* Graphics context                   */
   19.58 -    SDL_bool direct_mode;               /* Direct Mode state                  */
   19.59 -    PdOffscreenContext_t* osurfaces[SDL_PHOTON_MAX_SURFACES];
   19.60 -    PhImage_t* psurfaces[SDL_PHOTON_MAX_SURFACES];
   19.61 -    PmMemoryContext_t* pcontexts[SDL_PHOTON_MAX_SURFACES];
   19.62 -} SDL_RenderData;
   19.63 -
   19.64 -typedef struct SDL_TextureData
   19.65 -{
   19.66 -   uint32_t surface_type;
   19.67 -   PdOffscreenContext_t* osurface;
   19.68 -   PhImage_t* psurface;
   19.69 -   PmMemoryContext_t* pcontext;
   19.70 -} SDL_TextureData;
   19.71 -
   19.72 -extern void photon_addrenderdriver(_THIS);
   19.73 -
   19.74 -/* Helper function, which redraws the backbuffer */
   19.75 -int _photon_update_rectangles(SDL_Renderer* renderer, PhRect_t* rect);
   19.76 -
   19.77 -#endif /* __SDL_PHOTON_RENDER_H__ */
   19.78 -
   19.79 -/* vi: set ts=4 sw=4 expandtab: */
    20.1 --- a/src/video/qnxgf/SDL_gf_input.c	Tue Feb 01 21:23:43 2011 -0800
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,1144 +0,0 @@
    20.4 -/*
    20.5 -    SDL - Simple DirectMedia Layer
    20.6 -    Copyright (C) 1997-2010 Sam Lantinga
    20.7 -
    20.8 -    This library is free software; you can redistribute it and/or
    20.9 -    modify it under the terms of the GNU Lesser General Public
   20.10 -    License as published by the Free Software Foundation; either
   20.11 -    version 2.1 of the License, or (at your option) any later version.
   20.12 -
   20.13 -    This library is distributed in the hope that it will be useful,
   20.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20.16 -    Lesser General Public License for more details.
   20.17 -
   20.18 -    You should have received a copy of the GNU Lesser General Public
   20.19 -    License along with this library; if not, write to the Free Software
   20.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   20.21 -
   20.22 -    Sam Lantinga
   20.23 -    slouken@libsdl.org
   20.24 -
   20.25 -    QNX Graphics Framework SDL driver
   20.26 -    Copyright (C) 2009 Mike Gorchak
   20.27 -    (mike@malva.ua, lestat@i.com.ua)
   20.28 -*/
   20.29 -
   20.30 -#include "SDL_gf_input.h"
   20.31 -
   20.32 -#include "SDL_config.h"
   20.33 -#include "SDL_events.h"
   20.34 -#include "../../events/SDL_mouse_c.h"
   20.35 -#include "../../events/SDL_keyboard_c.h"
   20.36 -
   20.37 -/* Include QNX HIDDI definitions */
   20.38 -#include "SDL_hiddi_keyboard.h"
   20.39 -#include "SDL_hiddi_mouse.h"
   20.40 -#include "SDL_hiddi_joystick.h"
   20.41 -
   20.42 -/* Mouse related functions */
   20.43 -SDL_Cursor *gf_createcursor(SDL_Surface * surface, int hot_x, int hot_y);
   20.44 -int gf_showcursor(SDL_Cursor * cursor);
   20.45 -void gf_movecursor(SDL_Cursor * cursor);
   20.46 -void gf_freecursor(SDL_Cursor * cursor);
   20.47 -void gf_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y);
   20.48 -void gf_freemouse(SDL_Mouse * mouse);
   20.49 -
   20.50 -/* HIDDI interacting functions */
   20.51 -static int32_t hiddi_connect_devices();
   20.52 -static int32_t hiddi_disconnect_devices();
   20.53 -
   20.54 -int32_t
   20.55 -gf_addinputdevices(_THIS)
   20.56 -{
   20.57 -    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
   20.58 -    SDL_DisplayData *didata;
   20.59 -    struct SDL_Mouse gf_mouse;
   20.60 -    SDL_Keyboard gf_keyboard;
   20.61 -    SDLKey keymap[SDL_NUM_SCANCODES];
   20.62 -    SDL_MouseData *mdata;
   20.63 -    uint32_t it;
   20.64 -
   20.65 -    for (it = 0; it < _this->num_displays; it++) {
   20.66 -        SDL_VideoDisplay *display = &_this->displays[it];
   20.67 -
   20.68 -        /* Clear SDL mouse structure */
   20.69 -        SDL_memset(&gf_mouse, 0x00, sizeof(struct SDL_Mouse));
   20.70 -
   20.71 -        /* Allocate SDL_MouseData structure */
   20.72 -        mdata = (SDL_MouseData *) SDL_calloc(1, sizeof(SDL_MouseData));
   20.73 -        if (mdata == NULL) {
   20.74 -            SDL_OutOfMemory();
   20.75 -            return -1;
   20.76 -        }
   20.77 -
   20.78 -        /* Mark this mouse with ID 0 */
   20.79 -        gf_mouse.id = it;
   20.80 -        gf_mouse.driverdata = (void *) mdata;
   20.81 -        gf_mouse.CreateCursor = gf_createcursor;
   20.82 -        gf_mouse.ShowCursor = gf_showcursor;
   20.83 -        gf_mouse.MoveCursor = gf_movecursor;
   20.84 -        gf_mouse.FreeCursor = gf_freecursor;
   20.85 -        gf_mouse.WarpMouse = gf_warpmouse;
   20.86 -        gf_mouse.FreeMouse = gf_freemouse;
   20.87 -
   20.88 -        /* Get display data */
   20.89 -        didata = (SDL_DisplayData *) display->driverdata;
   20.90 -
   20.91 -        /* Store SDL_DisplayData pointer in the mouse driver internals */
   20.92 -        mdata->didata = didata;
   20.93 -
   20.94 -        /* Set cursor pos to 0,0 to avoid cursor disappearing in some drivers */
   20.95 -        gf_cursor_set_pos(didata->display, 0, 0, 0);
   20.96 -
   20.97 -        /* Register mouse cursor in SDL */
   20.98 -        SDL_AddMouse(&gf_mouse, "GF mouse cursor", 0, 0, 1);
   20.99 -    }
  20.100 -
  20.101 -    /* Keyboard could be one only */
  20.102 -    SDL_zero(gf_keyboard);
  20.103 -    SDL_AddKeyboard(&gf_keyboard, -1);
  20.104 -
  20.105 -    /* Add scancode to key mapping, HIDDI uses USB HID codes, so */
  20.106 -    /* map will be exact one-to-one */
  20.107 -    SDL_GetDefaultKeymap(keymap);
  20.108 -    SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
  20.109 -
  20.110 -    /* Connect to HID server and enumerate all input devices */
  20.111 -    hiddi_connect_devices();
  20.112 -
  20.113 -    return 0;
  20.114 -}
  20.115 -
  20.116 -int32_t
  20.117 -gf_delinputdevices(_THIS)
  20.118 -{
  20.119 -    /* Disconnect from HID server and release input devices */
  20.120 -    hiddi_disconnect_devices();
  20.121 -
  20.122 -    /* Delete keyboard */
  20.123 -    SDL_KeyboardQuit();
  20.124 -
  20.125 -    /* Destroy all of the mice */
  20.126 -    SDL_MouseQuit();
  20.127 -}
  20.128 -
  20.129 -/*****************************************************************************/
  20.130 -/* GF Mouse related functions                                                */
  20.131 -/*****************************************************************************/
  20.132 -SDL_Cursor *
  20.133 -gf_createcursor(SDL_Surface * surface, int hot_x, int hot_y)
  20.134 -{
  20.135 -    gf_cursor_t *internal_cursor;
  20.136 -    SDL_Cursor *sdl_cursor;
  20.137 -    uint8_t *image0 = NULL;
  20.138 -    uint8_t *image1 = NULL;
  20.139 -    uint32_t it;
  20.140 -    uint32_t jt;
  20.141 -    uint32_t shape_color;
  20.142 -
  20.143 -    /* SDL converts monochrome cursor shape to 32bpp cursor shape      */
  20.144 -    /* and we must convert it back to monochrome, this routine handles */
  20.145 -    /* 24/32bpp surfaces only                                          */
  20.146 -    if ((surface->format->BitsPerPixel != 32)
  20.147 -        && (surface->format->BitsPerPixel != 24)) {
  20.148 -        SDL_SetError("GF: Cursor shape is not 24/32bpp.");
  20.149 -        return NULL;
  20.150 -    }
  20.151 -
  20.152 -    /* Since GF is not checking data, we must check */
  20.153 -    if ((surface->w == 0) || (surface->h == 0)) {
  20.154 -        SDL_SetError("GF: Cursor shape dimensions are zero");
  20.155 -        return NULL;
  20.156 -    }
  20.157 -
  20.158 -    /* Allocate memory for the internal cursor format */
  20.159 -    internal_cursor = (gf_cursor_t *) SDL_calloc(1, sizeof(gf_cursor_t));
  20.160 -    if (internal_cursor == NULL) {
  20.161 -        SDL_OutOfMemory();
  20.162 -        return NULL;
  20.163 -    }
  20.164 -
  20.165 -    /* Allocate memory for the SDL cursor */
  20.166 -    sdl_cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(SDL_Cursor));
  20.167 -    if (sdl_cursor == NULL) {
  20.168 -        SDL_free(internal_cursor);
  20.169 -        SDL_OutOfMemory();
  20.170 -        return NULL;
  20.171 -    }
  20.172 -
  20.173 -    /* Allocate two monochrome images */
  20.174 -    image0 = (uint8_t *) SDL_calloc(1, ((surface->w + 7) / 8) * surface->h);
  20.175 -    if (image0 == NULL) {
  20.176 -        SDL_free(sdl_cursor);
  20.177 -        SDL_free(internal_cursor);
  20.178 -        SDL_OutOfMemory();
  20.179 -        return NULL;
  20.180 -    }
  20.181 -    image1 = (uint8_t *) SDL_calloc(1, ((surface->w + 7) >> 3) * surface->h);
  20.182 -    if (image1 == NULL) {
  20.183 -        SDL_free(image0);
  20.184 -        SDL_free(sdl_cursor);
  20.185 -        SDL_free(internal_cursor);
  20.186 -        SDL_OutOfMemory();
  20.187 -        return NULL;
  20.188 -    }
  20.189 -
  20.190 -    /* Set driverdata as GF cursor format */
  20.191 -    sdl_cursor->driverdata = (void *) internal_cursor;
  20.192 -    internal_cursor->type = GF_CURSOR_BITMAP;
  20.193 -    internal_cursor->hotspot.x = hot_x;
  20.194 -    internal_cursor->hotspot.y = hot_y;
  20.195 -    internal_cursor->cursor.bitmap.w = surface->w;
  20.196 -    internal_cursor->cursor.bitmap.h = surface->h;
  20.197 -    internal_cursor->cursor.bitmap.color0 = SDL_GF_MOUSE_COLOR_BLACK;
  20.198 -    internal_cursor->cursor.bitmap.color1 = SDL_GF_MOUSE_COLOR_WHITE;
  20.199 -
  20.200 -    /* Setup cursor shape images */
  20.201 -    internal_cursor->cursor.bitmap.stride = ((surface->w + 7) >> 3);
  20.202 -    internal_cursor->cursor.bitmap.image0 = image0;
  20.203 -    internal_cursor->cursor.bitmap.image1 = image1;
  20.204 -
  20.205 -    /* Convert cursor from 32 bpp */
  20.206 -    for (jt = 0; jt < surface->h; jt++) {
  20.207 -        for (it = 0; it < surface->w; it++) {
  20.208 -            shape_color =
  20.209 -                *((uint32_t *) ((uint8_t *) surface->pixels +
  20.210 -                                jt * surface->pitch +
  20.211 -                                it * surface->format->BytesPerPixel));
  20.212 -            switch (shape_color) {
  20.213 -            case SDL_GF_MOUSE_COLOR_BLACK:
  20.214 -                {
  20.215 -                    *(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
  20.216 -                      (it >> 3)) |= 0x80 >> (it % 8);
  20.217 -                    *(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
  20.218 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  20.219 -                }
  20.220 -                break;
  20.221 -            case SDL_GF_MOUSE_COLOR_WHITE:
  20.222 -                {
  20.223 -                    *(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
  20.224 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  20.225 -                    *(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
  20.226 -                      (it >> 3)) |= 0x80 >> (it % 8);
  20.227 -                }
  20.228 -                break;
  20.229 -            case SDL_GF_MOUSE_COLOR_TRANS:
  20.230 -                {
  20.231 -                    *(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
  20.232 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  20.233 -                    *(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
  20.234 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  20.235 -                }
  20.236 -                break;
  20.237 -            default:
  20.238 -                {
  20.239 -                    /* The same as transparent color, must not happen */
  20.240 -                    *(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
  20.241 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  20.242 -                    *(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
  20.243 -                      (it >> 3)) &= ~(0x80 >> (it % 8));
  20.244 -                }
  20.245 -                break;
  20.246 -            }
  20.247 -        }
  20.248 -    }
  20.249 -
  20.250 -    return sdl_cursor;
  20.251 -}
  20.252 -
  20.253 -int
  20.254 -gf_showcursor(SDL_Cursor * cursor)
  20.255 -{
  20.256 -    SDL_VideoDisplay *display;
  20.257 -    SDL_DisplayData *didata;
  20.258 -    SDL_Window *window;
  20.259 -    SDL_WindowID window_id;
  20.260 -    gf_cursor_t *internal_cursor;
  20.261 -    int32_t status;
  20.262 -
  20.263 -    /* Get current window id */
  20.264 -    window_id = SDL_GetFocusWindow();
  20.265 -    if (window_id <= 0) {
  20.266 -        SDL_MouseData *mdata = NULL;
  20.267 -
  20.268 -        /* If there is no current window, then someone calls this function */
  20.269 -        /* to set global mouse settings during SDL initialization          */
  20.270 -        if (cursor != NULL) {
  20.271 -            mdata = (SDL_MouseData *) cursor->mouse->driverdata;
  20.272 -            didata = (SDL_DisplayData *) mdata->didata;
  20.273 -            if ((didata == NULL) || (mdata == NULL)) {
  20.274 -                return;
  20.275 -            }
  20.276 -        } else {
  20.277 -            /* We can't get SDL_DisplayData at this point, return fake success */
  20.278 -            return 0;
  20.279 -        }
  20.280 -    } else {
  20.281 -        /* Sanity checks */
  20.282 -        window = SDL_GetWindowFromID(window_id);
  20.283 -        if (window != NULL) {
  20.284 -            display = window->display;
  20.285 -            if (display != NULL) {
  20.286 -                didata = (SDL_DisplayData *) display->driverdata;
  20.287 -                if (didata == NULL) {
  20.288 -                    return -1;
  20.289 -                }
  20.290 -            } else {
  20.291 -                return -1;
  20.292 -            }
  20.293 -        } else {
  20.294 -            return -1;
  20.295 -        }
  20.296 -    }
  20.297 -
  20.298 -    /* Check if we need to set new shape or disable cursor shape */
  20.299 -    if (cursor != NULL) {
  20.300 -        /* Retrieve GF cursor shape */
  20.301 -        internal_cursor = (gf_cursor_t *) cursor->driverdata;
  20.302 -        if (internal_cursor == NULL) {
  20.303 -            SDL_SetError("GF: Internal cursor data is absent");
  20.304 -            return -1;
  20.305 -        }
  20.306 -        if ((internal_cursor->cursor.bitmap.image0 == NULL) ||
  20.307 -            (internal_cursor->cursor.bitmap.image1 == NULL)) {
  20.308 -            SDL_SetError("GF: Cursor shape is absent");
  20.309 -            return -1;
  20.310 -        }
  20.311 -
  20.312 -        /* Store last shown cursor to display data */
  20.313 -        didata->cursor.type = internal_cursor->type;
  20.314 -        didata->cursor.hotspot.x = internal_cursor->hotspot.x;
  20.315 -        didata->cursor.hotspot.y = internal_cursor->hotspot.y;
  20.316 -        if (internal_cursor->cursor.bitmap.w > SDL_VIDEO_GF_MAX_CURSOR_SIZE) {
  20.317 -            didata->cursor.cursor.bitmap.w = SDL_VIDEO_GF_MAX_CURSOR_SIZE;
  20.318 -        } else {
  20.319 -            didata->cursor.cursor.bitmap.w = internal_cursor->cursor.bitmap.w;
  20.320 -        }
  20.321 -
  20.322 -        if (didata->cursor.cursor.bitmap.h > SDL_VIDEO_GF_MAX_CURSOR_SIZE) {
  20.323 -            didata->cursor.cursor.bitmap.h = SDL_VIDEO_GF_MAX_CURSOR_SIZE;
  20.324 -        } else {
  20.325 -            didata->cursor.cursor.bitmap.h = internal_cursor->cursor.bitmap.h;
  20.326 -        }
  20.327 -
  20.328 -        didata->cursor.cursor.bitmap.color0 =
  20.329 -            internal_cursor->cursor.bitmap.color0;
  20.330 -        didata->cursor.cursor.bitmap.color1 =
  20.331 -            internal_cursor->cursor.bitmap.color1;
  20.332 -        didata->cursor.cursor.bitmap.stride =
  20.333 -            internal_cursor->cursor.bitmap.stride;
  20.334 -        SDL_memcpy(didata->cursor.cursor.bitmap.image0,
  20.335 -                   internal_cursor->cursor.bitmap.image0,
  20.336 -                   ((internal_cursor->cursor.bitmap.w +
  20.337 -                     7) / (sizeof(uint8_t) * 8)) *
  20.338 -                   internal_cursor->cursor.bitmap.h);
  20.339 -        SDL_memcpy(didata->cursor.cursor.bitmap.image1,
  20.340 -                   internal_cursor->cursor.bitmap.image1,
  20.341 -                   ((internal_cursor->cursor.bitmap.w +
  20.342 -                     7) / (sizeof(uint8_t) * 8)) *
  20.343 -                   internal_cursor->cursor.bitmap.h);
  20.344 -
  20.345 -        /* Setup cursor shape */
  20.346 -        status = gf_cursor_set(didata->display, 0, internal_cursor);
  20.347 -        if (status != GF_ERR_OK) {
  20.348 -            if (status != GF_ERR_NOSUPPORT) {
  20.349 -                SDL_SetError("GF: Can't set hardware cursor shape");
  20.350 -                return -1;
  20.351 -            }
  20.352 -        }
  20.353 -
  20.354 -        /* Enable just set cursor */
  20.355 -        status = gf_cursor_enable(didata->display, 0);
  20.356 -        if (status != GF_ERR_OK) {
  20.357 -            if (status != GF_ERR_NOSUPPORT) {
  20.358 -                SDL_SetError("GF: Can't enable hardware cursor");
  20.359 -                return -1;
  20.360 -            }
  20.361 -        }
  20.362 -
  20.363 -        /* Set cursor visible */
  20.364 -        didata->cursor_visible = SDL_TRUE;
  20.365 -    } else {
  20.366 -        /* SDL requests to disable cursor */
  20.367 -        status = gf_cursor_disable(didata->display, 0);
  20.368 -        if (status != GF_ERR_OK) {
  20.369 -            if (status != GF_ERR_NOSUPPORT) {
  20.370 -                SDL_SetError("GF: Can't disable hardware cursor");
  20.371 -                return -1;
  20.372 -            }
  20.373 -        }
  20.374 -
  20.375 -        /* Set cursor invisible */
  20.376 -        didata->cursor_visible = SDL_FALSE;
  20.377 -    }
  20.378 -
  20.379 -    /* New cursor shape is set */
  20.380 -    return 0;
  20.381 -}
  20.382 -
  20.383 -void
  20.384 -gf_movecursor(SDL_Cursor * cursor)
  20.385 -{
  20.386 -    SDL_VideoDisplay *display;
  20.387 -    SDL_DisplayData *didata;
  20.388 -    SDL_Window *window;
  20.389 -    SDL_WindowID window_id;
  20.390 -    int32_t status;
  20.391 -    uint32_t xmax;
  20.392 -    uint32_t ymax;
  20.393 -
  20.394 -    /* Get current window id */
  20.395 -    window_id = SDL_GetFocusWindow();
  20.396 -    if (window_id <= 0) {
  20.397 -        didata = (SDL_DisplayData *) cursor->mouse->driverdata;
  20.398 -        if (didata == NULL) {
  20.399 -            return;
  20.400 -        }
  20.401 -    } else {
  20.402 -        /* Sanity checks */
  20.403 -        window = SDL_GetWindowFromID(window_id);
  20.404 -        if (window != NULL) {
  20.405 -            display = window->display;
  20.406 -            if (display != NULL) {
  20.407 -                didata = (SDL_DisplayData *) display->driverdata;
  20.408 -                if (didata == NULL) {
  20.409 -                    return;
  20.410 -                }
  20.411 -            } else {
  20.412 -                return;
  20.413 -            }
  20.414 -        } else {
  20.415 -            return;
  20.416 -        }
  20.417 -    }
  20.418 -
  20.419 -    /* Add checks for out of screen bounds position */
  20.420 -    if (cursor->mouse->x < 0) {
  20.421 -        cursor->mouse->x = 0;
  20.422 -    }
  20.423 -    if (cursor->mouse->y < 0) {
  20.424 -        cursor->mouse->y = 0;
  20.425 -    }
  20.426 -
  20.427 -    /* Get window size to clamp maximum coordinates */
  20.428 -    SDL_GetWindowSize(window_id, &xmax, &ymax);
  20.429 -    if (cursor->mouse->x >= xmax) {
  20.430 -        cursor->mouse->x = xmax - 1;
  20.431 -    }
  20.432 -    if (cursor->mouse->y >= ymax) {
  20.433 -        cursor->mouse->y = ymax - 1;
  20.434 -    }
  20.435 -
  20.436 -    status =
  20.437 -        gf_cursor_set_pos(didata->display, 0, cursor->mouse->x,
  20.438 -                          cursor->mouse->y);
  20.439 -    if (status != GF_ERR_OK) {
  20.440 -        if (status != GF_ERR_NOSUPPORT) {
  20.441 -            SDL_SetError("GF: Can't set hardware cursor position");
  20.442 -            return;
  20.443 -        }
  20.444 -    }
  20.445 -}
  20.446 -
  20.447 -void
  20.448 -gf_freecursor(SDL_Cursor * cursor)
  20.449 -{
  20.450 -    gf_cursor_t *internal_cursor;
  20.451 -
  20.452 -    if (cursor != NULL) {
  20.453 -        internal_cursor = (gf_cursor_t *) cursor->driverdata;
  20.454 -        if (internal_cursor != NULL) {
  20.455 -            if (internal_cursor->cursor.bitmap.image0 != NULL) {
  20.456 -                SDL_free((uint8_t *) internal_cursor->cursor.bitmap.image0);
  20.457 -            }
  20.458 -            if (internal_cursor->cursor.bitmap.image1 != NULL) {
  20.459 -                SDL_free((uint8_t *) internal_cursor->cursor.bitmap.image1);
  20.460 -            }
  20.461 -            SDL_free(internal_cursor);
  20.462 -        }
  20.463 -    }
  20.464 -}
  20.465 -
  20.466 -void
  20.467 -gf_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y)
  20.468 -{
  20.469 -    SDL_VideoDisplay *display;
  20.470 -    SDL_DisplayData *didata;
  20.471 -    uint32_t xmax;
  20.472 -    uint32_t ymax;
  20.473 -    int32_t status;
  20.474 -
  20.475 -    /* Sanity checks */
  20.476 -    if (window != NULL) {
  20.477 -        display = window->display;
  20.478 -        if (display != NULL) {
  20.479 -            didata = (SDL_DisplayData *) display->driverdata;
  20.480 -            if (didata == NULL) {
  20.481 -                return;
  20.482 -            }
  20.483 -        } else {
  20.484 -            return;
  20.485 -        }
  20.486 -    } else {
  20.487 -        return;
  20.488 -    }
  20.489 -
  20.490 -    /* Add checks for out of screen bounds position */
  20.491 -    if (x < 0) {
  20.492 -        x = 0;
  20.493 -    }
  20.494 -    if (y < 0) {
  20.495 -        y = 0;
  20.496 -    }
  20.497 -
  20.498 -    /* Get window size to clamp maximum coordinates */
  20.499 -    SDL_GetWindowSize(window, &xmax, &ymax);
  20.500 -    if (x >= xmax) {
  20.501 -        x = xmax - 1;
  20.502 -    }
  20.503 -    if (y >= ymax) {
  20.504 -        y = ymax - 1;
  20.505 -    }
  20.506 -
  20.507 -    status = gf_cursor_set_pos(didata->display, 0, x, y);
  20.508 -    if (status != GF_ERR_OK) {
  20.509 -        if (status != GF_ERR_NOSUPPORT) {
  20.510 -            SDL_SetError("GF: Can't set hardware cursor position");
  20.511 -            return;
  20.512 -        }
  20.513 -    }
  20.514 -}
  20.515 -
  20.516 -void
  20.517 -gf_freemouse(SDL_Mouse * mouse)
  20.518 -{
  20.519 -    if (mouse->driverdata == NULL) {
  20.520 -        return;
  20.521 -    }
  20.522 -
  20.523 -    /* Mouse framework doesn't deletes automatically our driverdata */
  20.524 -    SDL_free(mouse->driverdata);
  20.525 -    mouse->driverdata = NULL;
  20.526 -
  20.527 -    return;
  20.528 -}
  20.529 -
  20.530 -/*****************************************************************************/
  20.531 -/* HIDDI handlers code                                                       */
  20.532 -/*****************************************************************************/
  20.533 -static key_packet key_last_state[SDL_HIDDI_MAX_DEVICES];
  20.534 -
  20.535 -static void
  20.536 -hiddi_keyboard_handler(uint32_t devno, uint8_t * report_data,
  20.537 -                       uint32_t report_len)
  20.538 -{
  20.539 -    key_packet *packet;
  20.540 -    uint32_t it;
  20.541 -    uint32_t jt;
  20.542 -
  20.543 -    packet = (key_packet *) report_data;
  20.544 -
  20.545 -    /* Check for special states */
  20.546 -    switch (report_len) {
  20.547 -    case 8:                    /* 8 bytes of report length */
  20.548 -        {
  20.549 -            for (it = 0; it < 6; it++) {
  20.550 -                /* Check for keyboard overflow, when it can't handle */
  20.551 -                /* many simultaneous pressed keys */
  20.552 -                if (packet->codes[it] == HIDDI_KEY_OVERFLOW) {
  20.553 -                    return;
  20.554 -                }
  20.555 -            }
  20.556 -        }
  20.557 -        break;
  20.558 -    default:
  20.559 -        {
  20.560 -            /* Do not process unknown reports */
  20.561 -            return;
  20.562 -        }
  20.563 -        break;
  20.564 -    }
  20.565 -
  20.566 -    /* Check if modifier key was pressed */
  20.567 -    if (packet->modifiers != key_last_state[devno].modifiers) {
  20.568 -        if (((packet->modifiers & HIDDI_MKEY_LEFT_CTRL) ==
  20.569 -             HIDDI_MKEY_LEFT_CTRL)
  20.570 -            && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_CTRL) == 0) {
  20.571 -            /* Left Ctrl key was pressed */
  20.572 -            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LCTRL);
  20.573 -        }
  20.574 -        if (((packet->modifiers & HIDDI_MKEY_LEFT_CTRL) == 0) &&
  20.575 -            (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_CTRL) ==
  20.576 -            HIDDI_MKEY_LEFT_CTRL) {
  20.577 -            /* Left Ctrl key was released */
  20.578 -            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LCTRL);
  20.579 -        }
  20.580 -        if (((packet->modifiers & HIDDI_MKEY_LEFT_SHIFT) ==
  20.581 -             HIDDI_MKEY_LEFT_SHIFT)
  20.582 -            && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_SHIFT) == 0) {
  20.583 -            /* Left Shift key was pressed */
  20.584 -            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LSHIFT);
  20.585 -        }
  20.586 -        if (((packet->modifiers & HIDDI_MKEY_LEFT_SHIFT) == 0) &&
  20.587 -            (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_SHIFT) ==
  20.588 -            HIDDI_MKEY_LEFT_SHIFT) {
  20.589 -            /* Left Shift key was released */
  20.590 -            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
  20.591 -        }
  20.592 -        if (((packet->modifiers & HIDDI_MKEY_LEFT_ALT) == HIDDI_MKEY_LEFT_ALT)
  20.593 -            && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_ALT) == 0) {
  20.594 -            /* Left Alt key was pressed */
  20.595 -            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LALT);
  20.596 -        }
  20.597 -        if (((packet->modifiers & HIDDI_MKEY_LEFT_ALT) == 0) &&
  20.598 -            (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_ALT) ==
  20.599 -            HIDDI_MKEY_LEFT_ALT) {
  20.600 -            /* Left Alt key was released */
  20.601 -            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LALT);
  20.602 -        }
  20.603 -        if (((packet->modifiers & HIDDI_MKEY_LEFT_WFLAG) ==
  20.604 -             HIDDI_MKEY_LEFT_WFLAG)
  20.605 -            && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_WFLAG) == 0) {
  20.606 -            /* Left Windows flag key was pressed */
  20.607 -            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LGUI);
  20.608 -        }
  20.609 -        if (((packet->modifiers & HIDDI_MKEY_LEFT_WFLAG) == 0) &&
  20.610 -            (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_WFLAG) ==
  20.611 -            HIDDI_MKEY_LEFT_WFLAG) {
  20.612 -            /* Left Windows flag key was released */
  20.613 -            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LGUI);
  20.614 -        }
  20.615 -        if (((packet->modifiers & HIDDI_MKEY_RIGHT_CTRL) ==
  20.616 -             HIDDI_MKEY_RIGHT_CTRL)
  20.617 -            && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_CTRL) == 0) {
  20.618 -            /* Right Ctrl key was pressed */
  20.619 -            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RCTRL);
  20.620 -        }
  20.621 -        if (((packet->modifiers & HIDDI_MKEY_RIGHT_CTRL) == 0) &&
  20.622 -            (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_CTRL) ==
  20.623 -            HIDDI_MKEY_RIGHT_CTRL) {
  20.624 -            /* Right Ctrl key was released */
  20.625 -            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RCTRL);
  20.626 -        }
  20.627 -        if (((packet->modifiers & HIDDI_MKEY_RIGHT_SHIFT) ==
  20.628 -             HIDDI_MKEY_RIGHT_SHIFT)
  20.629 -            && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_SHIFT) ==
  20.630 -            0) {
  20.631 -            /* Right Shift key was pressed */
  20.632 -            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RSHIFT);
  20.633 -        }
  20.634 -        if (((packet->modifiers & HIDDI_MKEY_RIGHT_SHIFT) == 0) &&
  20.635 -            (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_SHIFT) ==
  20.636 -            HIDDI_MKEY_RIGHT_SHIFT) {
  20.637 -            /* Right Shift key was released */
  20.638 -            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RSHIFT);
  20.639 -        }
  20.640 -        if (((packet->modifiers & HIDDI_MKEY_RIGHT_ALT) ==
  20.641 -             HIDDI_MKEY_RIGHT_ALT)
  20.642 -            && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_ALT) == 0) {
  20.643 -            /* Right Alt key was pressed */
  20.644 -            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RALT);
  20.645 -        }
  20.646 -        if (((packet->modifiers & HIDDI_MKEY_RIGHT_ALT) == 0) &&
  20.647 -            (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_ALT) ==
  20.648 -            HIDDI_MKEY_RIGHT_ALT) {
  20.649 -            /* Right Alt key was released */
  20.650 -            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RALT);
  20.651 -        }
  20.652 -        if (((packet->modifiers & HIDDI_MKEY_RIGHT_WFLAG) ==
  20.653 -             HIDDI_MKEY_RIGHT_WFLAG)
  20.654 -            && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_WFLAG) ==
  20.655 -            0) {
  20.656 -            /* Right Windows flag key was pressed */
  20.657 -            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RGUI);
  20.658 -        }
  20.659 -        if (((packet->modifiers & HIDDI_MKEY_RIGHT_WFLAG) == 0) &&
  20.660 -            (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_WFLAG) ==
  20.661 -            HIDDI_MKEY_RIGHT_WFLAG) {
  20.662 -            /* Right Windows flag key was released */
  20.663 -            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RGUI);
  20.664 -        }
  20.665 -    }
  20.666 -
  20.667 -    /* Check each key in the press/release buffer */
  20.668 -    switch (report_len) {
  20.669 -    case 8:                    /* 8 bytes of report length */
  20.670 -        {
  20.671 -            /* Check if at least one key was unpressed */
  20.672 -            for (it = 0; it < 6; it++) {
  20.673 -                if (key_last_state[devno].codes[it] == HIDDI_KEY_UNPRESSED) {
  20.674 -                    /* if stored keycode is zero, find another */
  20.675 -                    continue;
  20.676 -                }
  20.677 -                for (jt = 0; jt < 6; jt++) {
  20.678 -                    /* Find stored keycode in the current pressed codes */
  20.679 -                    if (packet->codes[jt] == key_last_state[devno].codes[it]) {
  20.680 -                        /* If found then particular key state is not changed */
  20.681 -                        break;
  20.682 -                    }
  20.683 -                }
  20.684 -
  20.685 -                /* Check if pressed key can't longer be found */
  20.686 -                if (jt == 6) {
  20.687 -                    SDL_SendKeyboardKey(0, SDL_RELEASED,
  20.688 -                                        key_last_state[devno].codes[it]);
  20.689 -                }
  20.690 -            }
  20.691 -
  20.692 -            /* Check if at least one new key was pressed */
  20.693 -            for (it = 0; it < 6; it++) {
  20.694 -                if (packet->codes[it] == HIDDI_KEY_UNPRESSED) {
  20.695 -                    continue;
  20.696 -                }
  20.697 -                for (jt = 0; jt < 6; jt++) {
  20.698 -                    /* Find new keycode it the array of old pressed keys */
  20.699 -                    if (packet->codes[it] == key_last_state[devno].codes[jt]) {
  20.700 -                        break;
  20.701 -                    }
  20.702 -                }
  20.703 -
  20.704 -                /* Check if new key was pressed */
  20.705 -                if (jt == 6) {
  20.706 -                    SDL_SendKeyboardKey(0, SDL_PRESSED, packet->codes[it]);
  20.707 -                }
  20.708 -            }
  20.709 -        }
  20.710 -    default:                   /* unknown keyboard report type */
  20.711 -        {
  20.712 -            /* Ignore all unknown reports */
  20.713 -        }
  20.714 -        break;
  20.715 -    }
  20.716 -
  20.717 -    /* Store last state */
  20.718 -    key_last_state[devno] = *packet;
  20.719 -}
  20.720 -
  20.721 -static uint32_t mouse_last_state_button[SDL_HIDDI_MAX_DEVICES];
  20.722 -static uint32_t collect_reports = 0;
  20.723 -
  20.724 -static void
  20.725 -hiddi_mouse_handler(uint32_t devno, uint8_t * report_data,
  20.726 -                    uint32_t report_len)
  20.727 -{
  20.728 -    uint32_t it;
  20.729 -    uint32_t sdlbutton;
  20.730 -
  20.731 -    /* We do not want to collect stored events */
  20.732 -    if (collect_reports == 0) {
  20.733 -        return;
  20.734 -    }
  20.735 -
  20.736 -    /* Check for special states */
  20.737 -    switch (report_len) {
  20.738 -    case 8:                    /* 8 bytes of report length, usually multi-button USB mice */
  20.739 -        {
  20.740 -            mouse_packet8 *packet;
  20.741 -            packet = (mouse_packet8 *) report_data;
  20.742 -
  20.743 -            /* Send motion event if motion really was */
  20.744 -            if ((packet->horizontal_precision != 0)
  20.745 -                || (packet->vertical_precision != 0)) {
  20.746 -                SDL_SendMouseMotion(0, 1, packet->horizontal_precision,
  20.747 -                                    packet->vertical_precision, 0);
  20.748 -            }
  20.749 -
  20.750 -            /* Send mouse button press/release events */
  20.751 -            if (mouse_last_state_button[devno] != packet->buttons) {
  20.752 -                /* Cycle all buttons status */
  20.753 -                for (it = 0; it < 8; it++) {
  20.754 -                    /* convert hiddi button id to sdl button id */
  20.755 -                    switch (it) {
  20.756 -                    case 0:
  20.757 -                        {
  20.758 -                            sdlbutton = SDL_BUTTON_LEFT;
  20.759 -                        }
  20.760 -                        break;
  20.761 -                    case 1:
  20.762 -                        {
  20.763 -                            sdlbutton = SDL_BUTTON_RIGHT;
  20.764 -                        }
  20.765 -                        break;
  20.766 -                    case 2:
  20.767 -                        {
  20.768 -                            sdlbutton = SDL_BUTTON_MIDDLE;
  20.769 -                        }
  20.770 -                        break;
  20.771 -                    default:
  20.772 -                        {
  20.773 -                            sdlbutton = it + 1;
  20.774 -                        }
  20.775 -                        break;
  20.776 -                    }
  20.777 -
  20.778 -                    /* Button pressed */
  20.779 -                    if (((packet->buttons & (0x01 << it)) == (0x01 << it)) &&
  20.780 -                        ((mouse_last_state_button[devno] & (0x01 << it)) ==
  20.781 -                         0x00)) {
  20.782 -                        SDL_SendMouseButton(0, SDL_PRESSED, sdlbutton);
  20.783 -                    }
  20.784 -                    /* Button released */
  20.785 -                    if (((packet->buttons & (0x01 << it)) == 0x00) &&
  20.786 -                        ((mouse_last_state_button[devno] & (0x01 << it)) ==
  20.787 -                         (0x01 << it))) {
  20.788 -                        SDL_SendMouseButton(0, SDL_RELEASED, sdlbutton);
  20.789 -                    }
  20.790 -                }
  20.791 -                mouse_last_state_button[devno] = packet->buttons;
  20.792 -            }
  20.793 -
  20.794 -            /* Send mouse wheel events */
  20.795 -            if (packet->wheel != 0) {
  20.796 -                /* Send vertical wheel event only */
  20.797 -                SDL_SendMouseWheel(0, 0, packet->wheel);
  20.798 -            }
  20.799 -        }
  20.800 -        break;
  20.801 -    case 4:                    /* 4 bytes of report length, usually PS/2 mice */
  20.802 -        {
  20.803 -            mouse_packet4 *packet;
  20.804 -            packet = (mouse_packet4 *) report_data;
  20.805 -
  20.806 -            /* Send motion event if motion really was */
  20.807 -            if ((packet->horizontal != 0) || (packet->vertical != 0)) {
  20.808 -                SDL_SendMouseMotion(0, 1, packet->horizontal,
  20.809 -                                    packet->vertical, 0);
  20.810 -            }
  20.811 -
  20.812 -            /* Send mouse button press/release events */
  20.813 -            if (mouse_last_state_button[devno] != packet->buttons) {
  20.814 -                /* Cycle all buttons status */
  20.815 -                for (it = 0; it < 8; it++) {
  20.816 -                    /* convert hiddi button id to sdl button id */
  20.817 -                    switch (it) {
  20.818 -                    case 0:
  20.819 -                        {
  20.820 -                            sdlbutton = SDL_BUTTON_LEFT;
  20.821 -                        }
  20.822 -                        break;
  20.823 -                    case 1:
  20.824 -                        {
  20.825 -                            sdlbutton = SDL_BUTTON_RIGHT;
  20.826 -                        }
  20.827 -                        break;
  20.828 -                    case 2:
  20.829 -                        {
  20.830 -                            sdlbutton = SDL_BUTTON_MIDDLE;
  20.831 -                        }
  20.832 -                        break;
  20.833 -                    default:
  20.834 -                        {
  20.835 -                            sdlbutton = it + 1;
  20.836 -                        }
  20.837 -                        break;
  20.838 -                    }
  20.839 -
  20.840 -                    /* Button pressed */
  20.841 -                    if (((packet->buttons & (0x01 << it)) == (0x01 << it)) &&
  20.842 -                        ((mouse_last_state_button[devno] & (0x01 << it)) ==
  20.843 -                         0x00)) {
  20.844 -                        SDL_SendMouseButton(0, SDL_PRESSED, sdlbutton);
  20.845 -                    }
  20.846 -                    /* Button released */
  20.847 -                    if (((packet->buttons & (0x01 << it)) == 0x00) &&
  20.848 -                        ((mouse_last_state_button[devno] & (0x01 << it)) ==
  20.849 -                         (0x01 << it))) {
  20.850 -                        SDL_SendMouseButton(0, SDL_RELEASED, sdlbutton);
  20.851 -                    }
  20.852 -                }
  20.853 -                mouse_last_state_button[devno] = packet->buttons;
  20.854 -            }
  20.855 -
  20.856 -            /* Send mouse wheel events */
  20.857 -            if (packet->wheel != 0) {
  20.858 -                /* Send vertical wheel event only */
  20.859 -                SDL_SendMouseWheel(0, 0, packet->wheel);
  20.860 -            }
  20.861 -        }
  20.862 -        break;
  20.863 -    }
  20.864 -}
  20.865 -
  20.866 -/*****************************************************************************/
  20.867 -/* HIDDI interacting code                                                    */
  20.868 -/*****************************************************************************/
  20.869 -static hidd_device_ident_t hiddevice = {
  20.870 -    HIDD_CONNECT_WILDCARD,      /* vendor id:  any */
  20.871 -    HIDD_CONNECT_WILDCARD,      /* product id: any */
  20.872 -    HIDD_CONNECT_WILDCARD,      /* version:    any */
  20.873 -};
  20.874 -
  20.875 -static hidd_connect_parm_t hidparams =
  20.876 -    { NULL, HID_VERSION, HIDD_VERSION, 0, 0, &hiddevice, NULL, 0 };
  20.877 -
  20.878 -static void hiddi_insertion(struct hidd_connection *connection,
  20.879 -                            hidd_device_instance_t * device_instance);
  20.880 -static void hiddi_removal(struct hidd_connection *connection,
  20.881 -                          hidd_device_instance_t * instance);
  20.882 -static void hiddi_report(struct hidd_connection *connection,
  20.883 -                         struct hidd_report *report, void *report_data,
  20.884 -                         uint32_t report_len, uint32_t flags, void *user);
  20.885 -
  20.886 -static hidd_funcs_t hidfuncs =
  20.887 -    { _HIDDI_NFUNCS, hiddi_insertion, hiddi_removal, hiddi_report, NULL };
  20.888 -
  20.889 -/* HID handle, singletone */
  20.890 -struct hidd_connection *connection = NULL;
  20.891 -
  20.892 -/* SDL detected input device types, singletone */
  20.893 -static uint32_t sdl_input_devices[SDL_HIDDI_MAX_DEVICES];
  20.894 -
  20.895 -static int
  20.896 -hiddi_register_for_reports(struct hidd_collection *col,
  20.897 -                           hidd_device_instance_t * device_instance)
  20.898 -{
  20.899 -    int it;
  20.900 -    uint16_t num_col;
  20.901 -    struct hidd_collection **hidd_collections;
  20.902 -    struct hidd_report_instance *report_instance;
  20.903 -    struct hidd_report *report;
  20.904 -    int status = 0;
  20.905 -    hidview_device_t *device;
  20.906 -
  20.907 -    for (it = 0; it < 10 && !status; it++) {
  20.908 -        status =
  20.909 -            hidd_get_report_instance(col, it, HID_INPUT_REPORT,
  20.910 -                                     &report_instance);
  20.911 -        if (status == EOK) {
  20.912 -            status =
  20.913 -                hidd_report_attach(connection, device_instance,
  20.914 -                                   report_instance, 0,
  20.915 -                                   sizeof(hidview_device_t), &report);
  20.916 -            if (status == EOK) {
  20.917 -                device = hidd_report_extra(report);
  20.918 -                device->report = report;
  20.919 -                device->instance = report_instance;
  20.920 -            }
  20.921 -        }
  20.922 -    }
  20.923 -    hidd_get_collections(NULL, col, &hidd_collections, &num_col);
  20.924 -
  20.925 -    for (it = 0; it < num_col; it++) {
  20.926 -        hiddi_register_for_reports(hidd_collections[it], device_instance);
  20.927 -    }
  20.928 -
  20.929 -    return EOK;
  20.930 -}
  20.931 -
  20.932 -static void
  20.933 -hiddi_insertion(struct hidd_connection *connection,
  20.934 -                hidd_device_instance_t * device_instance)
  20.935 -{
  20.936 -    uint32_t it;
  20.937 -    struct hidd_collection **hidd_collections;
  20.938 -    uint16_t num_col;
  20.939 -
  20.940 -    /* get root level collections */
  20.941 -    hidd_get_collections(device_instance, NULL, &hidd_collections, &num_col);
  20.942 -    for (it = 0; it < num_col; it++) {
  20.943 -        hiddi_register_for_reports(hidd_collections[it], device_instance);
  20.944 -    }
  20.945 -}
  20.946 -
  20.947 -static void
  20.948 -hiddi_removal(struct hidd_connection *connection,
  20.949 -              hidd_device_instance_t * instance)
  20.950 -{
  20.951 -    hidd_reports_detach(connection, instance);
  20.952 -}
  20.953 -
  20.954 -static void
  20.955 -hiddi_report(struct hidd_connection *connection, hidd_report_t * report,
  20.956 -             void *report_data, uint32_t report_len, uint32_t flags,
  20.957 -             void *user)
  20.958 -{
  20.959 -    if (report->dev_inst->devno >= SDL_HIDDI_MAX_DEVICES) {
  20.960 -        /* Unknown HID device, with devno number out of supported range */
  20.961 -        return;
  20.962 -    }
  20.963 -
  20.964 -    /* Check device type which generates event */
  20.965 -    switch (sdl_input_devices[report->dev_inst->devno]) {
  20.966 -    case SDL_GF_HIDDI_NONE:
  20.967 -        {
  20.968 -            /* We do not handle other devices type */
  20.969 -            return;
  20.970 -        }
  20.971 -        break;
  20.972 -    case SDL_GF_HIDDI_MOUSE:
  20.973 -        {
  20.974 -            /* Call mouse handler */
  20.975 -            hiddi_mouse_handler(report->dev_inst->devno, report_data,
  20.976 -                                report_len);
  20.977 -        }
  20.978 -        break;
  20.979 -    case SDL_GF_HIDDI_KEYBOARD:
  20.980 -        {
  20.981 -            /* Call keyboard handler */
  20.982 -            hiddi_keyboard_handler(report->dev_inst->devno, report_data,
  20.983 -                                   report_len);
  20.984 -        }
  20.985 -        break;
  20.986 -    case SDL_GF_HIDDI_JOYSTICK:
  20.987 -        {
  20.988 -            /* Call joystick handler */
  20.989 -        }
  20.990 -        break;
  20.991 -    }
  20.992 -}
  20.993 -
  20.994 -static
  20.995 -hiddi_get_device_type(uint8_t * report_data, uint16_t report_length)
  20.996 -{
  20.997 -    hid_byte_t byte;
  20.998 -    uint16_t usage_page = 0;
  20.999 -    uint16_t usage = 0;
 20.1000 -    uint16_t data = 0;
 20.1001 -
 20.1002 -    while (report_length && !(usage_page && usage)) {
 20.1003 -        if (hidp_analyse_byte(*report_data, &byte)) {
 20.1004 -            /* Error in parser, do nothing */
 20.1005 -        }
 20.1006 -        data = hidp_get_data((report_data + 1), &byte);
 20.1007 -        switch (byte.HIDB_Type) {
 20.1008 -        case HID_TYPE_GLOBAL:
 20.1009 -            if (!usage_page && byte.HIDB_Tag == HID_GLOBAL_USAGE_PAGE) {
 20.1010 -                usage_page = data;
 20.1011 -            }
 20.1012 -            break;
 20.1013 -        case HID_TYPE_LOCAL:
 20.1014 -            if (!usage && byte.HIDB_Tag == HID_LOCAL_USAGE) {
 20.1015 -                usage = data;
 20.1016 -            }
 20.1017 -            break;
 20.1018 -        }
 20.1019 -        report_data += byte.HIDB_Length + 1;
 20.1020 -        report_length -= byte.HIDB_Length + 1;
 20.1021 -    }
 20.1022 -
 20.1023 -    switch (usage_page) {
 20.1024 -    case HIDD_PAGE_DESKTOP:
 20.1025 -        {
 20.1026 -            switch (usage) {
 20.1027 -            case HIDD_USAGE_MOUSE:
 20.1028 -                {
 20.1029 -                    return SDL_GF_HIDDI_MOUSE;
 20.1030 -                }
 20.1031 -                break;
 20.1032 -            case HIDD_USAGE_JOYSTICK:
 20.1033 -                {
 20.1034 -                    return SDL_GF_HIDDI_JOYSTICK;
 20.1035 -                }
 20.1036 -                break;
 20.1037 -            case HIDD_USAGE_KEYBOARD:
 20.1038 -                {
 20.1039 -                    return SDL_GF_HIDDI_KEYBOARD;
 20.1040 -                }
 20.1041 -                break;
 20.1042 -            }
 20.1043 -        }
 20.1044 -        break;
 20.1045 -    case HIDD_PAGE_DIGITIZER:
 20.1046 -        {
 20.1047 -            /* Do not handle digitizers */
 20.1048 -        }
 20.1049 -        break;
 20.1050 -    case HIDD_PAGE_CONSUMER:
 20.1051 -        {
 20.1052 -            /* Do not handle consumer input devices */
 20.1053 -        }
 20.1054 -        break;
 20.1055 -    }
 20.1056 -
 20.1057 -    return SDL_GF_HIDDI_NONE;
 20.1058 -}
 20.1059 -
 20.1060 -static int32_t
 20.1061 -hiddi_connect_devices()
 20.1062 -{
 20.1063 -    int32_t status;
 20.1064 -    uint32_t it;
 20.1065 -    uint8_t *report_data;
 20.1066 -    uint16_t report_length;
 20.1067 -    hidd_device_instance_t instance;
 20.1068 -
 20.1069 -    /* Cleanup initial keys and mice state */
 20.1070 -    SDL_memset(key_last_state, 0x00,
 20.1071 -               sizeof(key_packet) * SDL_HIDDI_MAX_DEVICES);
 20.1072 -    SDL_memset(mouse_last_state_button, 0x00,
 20.1073 -               sizeof(uint32_t) * SDL_HIDDI_MAX_DEVICES);
 20.1074 -
 20.1075 -    status = hidd_connect(&hidparams, &connection);
 20.1076 -    if (status != EOK) {
 20.1077 -        connection=NULL;
 20.1078 -        return -1;
 20.1079 -    }
 20.1080 -
 20.1081 -    for (it = 0; it < SDL_HIDDI_MAX_DEVICES; it++) {
 20.1082 -        /* Get device instance */
 20.1083 -        status = hidd_get_device_instance(connection, it, &instance);
 20.1084 -        if (status != EOK) {
 20.1085 -            continue;
 20.1086 -        }
 20.1087 -
 20.1088 -        status =
 20.1089 -            hidd_get_report_desc(connection, &instance, &report_data,
 20.1090 -                                 &report_length);
 20.1091 -        if (status != EOK) {
 20.1092 -            continue;
 20.1093 -        }
 20.1094 -
 20.1095 -        status = hiddi_get_device_type(report_data, report_length);
 20.1096 -        sdl_input_devices[it] = status;
 20.1097 -
 20.1098 -        free(report_data);
 20.1099 -    }
 20.1100 -
 20.1101 -    /* Disconnect from HID server */
 20.1102 -    status = hidd_disconnect(connection);
 20.1103 -    if (status != EOK) {
 20.1104 -        connection=NULL;
 20.1105 -        return -1;
 20.1106 -    }
 20.1107 -
 20.1108 -    /* Add handlers for HID devices */
 20.1109 -    hidparams.funcs = &hidfuncs;
 20.1110 -
 20.1111 -    status = hidd_connect(&hidparams, &connection);
 20.1112 -    if (status != EOK) {
 20.1113 -        connection=NULL;
 20.1114 -        return -1;
 20.1115 -    }
 20.1116 -
 20.1117 -    return 0;
 20.1118 -}
 20.1119 -
 20.1120 -static int32_t
 20.1121 -hiddi_disconnect_devices()
 20.1122 -{
 20.1123 -    int32_t status;
 20.1124 -
 20.1125 -    hiddi_disable_mouse();
 20.1126 -
 20.1127 -    /* Disconnect from HID server */
 20.1128 -    if (connection!=NULL)
 20.1129 -    {
 20.1130 -        status = hidd_disconnect(connection);
 20.1131 -        if (status != EOK) {
 20.1132 -            return -1;
 20.1133 -        }
 20.1134 -    }
 20.1135 -}
 20.1136 -
 20.1137 -void
 20.1138 -hiddi_enable_mouse()
 20.1139 -{
 20.1140 -    collect_reports = 1;
 20.1141 -}
 20.1142 -
 20.1143 -void
 20.1144 -hiddi_disable_mouse()
 20.1145 -{
 20.1146 -    collect_reports = 0;
 20.1147 -}
    21.1 --- a/src/video/qnxgf/SDL_gf_input.h	Tue Feb 01 21:23:43 2011 -0800
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,165 +0,0 @@
    21.4 -/*
    21.5 -    SDL - Simple DirectMedia Layer
    21.6 -    Copyright (C) 1997-2010 Sam Lantinga
    21.7 -
    21.8 -    This library is free software; you can redistribute it and/or
    21.9 -    modify it under the terms of the GNU Lesser General Public
   21.10 -    License as published by the Free Software Foundation; either
   21.11 -    version 2.1 of the License, or (at your option) any later version.
   21.12 -
   21.13 -    This library is distributed in the hope that it will be useful,
   21.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   21.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   21.16 -    Lesser General Public License for more details.
   21.17 -
   21.18 -    You should have received a copy of the GNU Lesser General Public
   21.19 -    License along with this library; if not, write to the Free Software
   21.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   21.21 -
   21.22 -    Sam Lantinga
   21.23 -    slouken@libsdl.org
   21.24 -
   21.25 -    QNX Graphics Framework SDL driver
   21.26 -    Copyright (C) 2009 Mike Gorchak
   21.27 -    (mike@malva.ua, lestat@i.com.ua)
   21.28 -*/
   21.29 -
   21.30 -#ifndef __SDL_GF_INPUT_H__
   21.31 -#define __SDL_GF_INPUT_H__
   21.32 -
   21.33 -#include "SDL_config.h"
   21.34 -#include "SDL_video.h"
   21.35 -#include "../SDL_sysvideo.h"
   21.36 -
   21.37 -#include <errno.h>
   21.38 -
   21.39 -#include <gf/gf.h>
   21.40 -
   21.41 -#include <sys/hiddi.h>
   21.42 -#include <sys/hidut.h>
   21.43 -
   21.44 -#include "SDL_qnxgf.h"
   21.45 -
   21.46 -typedef struct SDL_MouseData
   21.47 -{
   21.48 -    SDL_DisplayData *didata;
   21.49 -} SDL_MouseData;
   21.50 -
   21.51 -int32_t gf_addinputdevices(_THIS);
   21.52 -int32_t gf_delinputdevices(_THIS);
   21.53 -
   21.54 -#define SDL_GF_MOUSE_COLOR_BLACK 0xFF000000
   21.55 -#define SDL_GF_MOUSE_COLOR_WHITE 0xFFFFFFFF
   21.56 -#define SDL_GF_MOUSE_COLOR_TRANS 0x00000000
   21.57 -
   21.58 -/*****************************************************************************/
   21.59 -/* This is HIDDI closed interface declarations                               */
   21.60 -/*****************************************************************************/
   21.61 -#define HID_TYPE_MAIN      0x0
   21.62 -#define HID_TYPE_GLOBAL    0x1
   21.63 -#define HID_TYPE_LOCAL     0x2
   21.64 -#define HID_TYPE_RESERVED  0x3
   21.65 -
   21.66 -#define HID_GLOBAL_USAGE_PAGE 0x0
   21.67 -#define HID_LOCAL_USAGE       0x0
   21.68 -
   21.69 -typedef struct _hid_byte
   21.70 -{
   21.71 -    uint8_t HIDB_Length;
   21.72 -    uint8_t HIDB_Type;
   21.73 -    uint8_t HIDB_Tag;
   21.74 -    uint8_t reserved[1];
   21.75 -} hid_byte_t;
   21.76 -
   21.77 -typedef struct _hidd_global_item
   21.78 -{
   21.79 -    uint16_t usage_page;
   21.80 -    uint16_t logical_min;
   21.81 -    uint16_t logical_max;
   21.82 -    uint16_t physical_min;
   21.83 -    uint16_t physical_max;
   21.84 -    uint16_t unit_expo;
   21.85 -    uint16_t unit;
   21.86 -    uint16_t report_size;
   21.87 -    uint16_t report_id;
   21.88 -    uint16_t report_count;
   21.89 -} hidd_global_item_t;
   21.90 -
   21.91 -typedef struct _hidd_local_item
   21.92 -{
   21.93 -    uint16_t type;
   21.94 -    uint8_t reserved[2];
   21.95 -    uint32_t value;
   21.96 -    struct _hidd_local_item *next_local;
   21.97 -    struct _hidd_local_item *alt_local;
   21.98 -} hidd_local_item_t;
   21.99 -
  21.100 -typedef struct _hidd_local_table
  21.101 -{
  21.102 -    hidd_local_item_t *usage_info;
  21.103 -    hidd_local_item_t *designator_info;
  21.104 -    hidd_local_item_t *string_info;
  21.105 -    uint8_t delimiter;
  21.106 -    uint8_t reserved[3];
  21.107 -} hidd_local_table_t;
  21.108 -
  21.109 -typedef struct _hidd_field
  21.110 -{
  21.111 -    struct hidd_report_instance *report;
  21.112 -    struct hidd_collection *collection;
  21.113 -    uint16_t report_offset;
  21.114 -    uint16_t flags;
  21.115 -    hidd_global_item_t gitem;
  21.116 -    hidd_local_table_t *ltable;
  21.117 -    struct _hidd_field *next_field;
  21.118 -    void *user;
  21.119 -} hidd_field_t;
  21.120 -
  21.121 -typedef struct hidd_report_instance
  21.122 -{
  21.123 -    uint8_t report_id;
  21.124 -    uint8_t reserved[1];
  21.125 -    uint16_t report_type;
  21.126 -    hidd_field_t *field;
  21.127 -    uint16_t num_field;
  21.128 -    uint16_t byte_len;
  21.129 -    uint16_t bit_len;
  21.130 -    uint8_t reserved2[2];
  21.131 -    struct hidd_collection *collection;
  21.132 -    struct hidd_report_instance *next_col_report;
  21.133 -    struct hidd_report_instance *next_report;
  21.134 -} hidd_report_instance_t;
  21.135 -
  21.136 -typedef struct hidd_report
  21.137 -{
  21.138 -    TAILQ_ENTRY(hidd_report) link;
  21.139 -    hidd_report_instance_t *rinst;
  21.140 -    hidd_device_instance_t *dev_inst;
  21.141 -    uint32_t flags;
  21.142 -    struct hidd_connection *connection;
  21.143 -    void *user;
  21.144 -} hidd_report_t;
  21.145 -
  21.146 -typedef struct hidview_device
  21.147 -{
  21.148 -    struct hidd_report_instance *instance;
  21.149 -    struct hidd_report *report;
  21.150 -} hidview_device_t;
  21.151 -
  21.152 -/*****************************************************************************/
  21.153 -/* Closed HIDDI interface declarations end                                   */
  21.154 -/*****************************************************************************/
  21.155 -
  21.156 -/* Maximum devices and subdevices amount per host */
  21.157 -#define SDL_HIDDI_MAX_DEVICES 64
  21.158 -
  21.159 -/* Detected device/subdevice type for SDL */
  21.160 -#define SDL_GF_HIDDI_NONE     0x00000000
  21.161 -#define SDL_GF_HIDDI_MOUSE    0x00000001
  21.162 -#define SDL_GF_HIDDI_KEYBOARD 0x00000002
  21.163 -#define SDL_GF_HIDDI_JOYSTICK 0x00000003
  21.164 -
  21.165 -extern void hiddi_enable_mouse();
  21.166 -extern void hiddi_disable_mouse();
  21.167 -
  21.168 -#endif /* __SDL_GF_INPUT_H__ */
    22.1 --- a/src/video/qnxgf/SDL_gf_opengles.c	Tue Feb 01 21:23:43 2011 -0800
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,54 +0,0 @@
    22.4 -/*
    22.5 -    SDL - Simple DirectMedia Layer
    22.6 -    Copyright (C) 1997-2010 Sam Lantinga
    22.7 -
    22.8 -    This library is free software; you can redistribute it and/or
    22.9 -    modify it under the terms of the GNU Lesser General Public
   22.10 -    License as published by the Free Software Foundation; either
   22.11 -    version 2.1 of the License, or (at your option) any later version.
   22.12 -
   22.13 -    This library is distributed in the hope that it will be useful,
   22.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   22.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   22.16 -    Lesser General Public License for more details.
   22.17 -
   22.18 -    You should have received a copy of the GNU Lesser General Public
   22.19 -    License along with this library; if not, write to the Free Software
   22.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   22.21 -
   22.22 -    Sam Lantinga
   22.23 -    slouken@libsdl.org
   22.24 -
   22.25 -    QNX Graphics Framework SDL driver
   22.26 -    Copyright (C) 2009 Mike Gorchak
   22.27 -    (mike@malva.ua, lestat@i.com.ua)
   22.28 -*/
   22.29 -
   22.30 -#include <GLES/gl.h>
   22.31 -#include <GLES/glext.h>
   22.32 -
   22.33 -/* This is OpenGL ES 1.0 helper functions from OpenGL ES 1.1 specification,  */
   22.34 -/* which could be implemented independently from hardware, just wrappers     */
   22.35 -
   22.36 -GLAPI void APIENTRY
   22.37 -glTexParameteri(GLenum target, GLenum pname, GLint param)
   22.38 -{
   22.39 -    glTexParameterx(target, pname, (GLfixed) param);
   22.40 -    return;
   22.41 -}
   22.42 -
   22.43 -GLAPI void APIENTRY
   22.44 -glTexParameteriv(GLenum target, GLenum pname, const GLint * params)
   22.45 -{
   22.46 -    /* Retrieve one parameter only */
   22.47 -    glTexParameterx(target, pname, (GLfixed) * params);
   22.48 -    return;
   22.49 -}
   22.50 -
   22.51 -GLAPI void APIENTRY
   22.52 -glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
   22.53 -{
   22.54 -    glColor4f(((GLfloat) red) / 255.f, ((GLfloat) green) / 255.f,
   22.55 -              ((GLfloat) blue) / 255.f, ((GLfloat) alpha) / 255.f);
   22.56 -    return;
   22.57 -}
    23.1 --- a/src/video/qnxgf/SDL_gf_opengles.h	Tue Feb 01 21:23:43 2011 -0800
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,39 +0,0 @@
    23.4 -/*
    23.5 -    SDL - Simple DirectMedia Layer
    23.6 -    Copyright (C) 1997-2010 Sam Lantinga
    23.7 -
    23.8 -    This library is free software; you can redistribute it and/or
    23.9 -    modify it under the terms of the GNU Lesser General Public
   23.10 -    License as published by the Free Software Foundation; either
   23.11 -    version 2.1 of the License, or (at your option) any later version.
   23.12 -
   23.13 -    This library is distributed in the hope that it will be useful,
   23.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   23.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   23.16 -    Lesser General Public License for more details.
   23.17 -
   23.18 -    You should have received a copy of the GNU Lesser General Public
   23.19 -    License along with this library; if not, write to the Free Software
   23.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   23.21 -
   23.22 -    Sam Lantinga
   23.23 -    slouken@libsdl.org
   23.24 -
   23.25 -    QNX Graphics Framework SDL driver
   23.26 -    Copyright (C) 2009 Mike Gorchak
   23.27 -    (mike@malva.ua, lestat@i.com.ua)
   23.28 -*/
   23.29 -
   23.30 -#ifndef __SDL_GF_OPENGLES_H__
   23.31 -#define __SDL_GF_OPENGLES_H__
   23.32 -
   23.33 -#include <GLES/gl.h>
   23.34 -#include <GLES/glext.h>
   23.35 -
   23.36 -GLAPI void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param);
   23.37 -GLAPI void APIENTRY glTexParameteriv(GLenum target, GLenum pname,
   23.38 -                                     const GLint * params);
   23.39 -GLAPI void APIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue,
   23.40 -                               GLubyte alpha);
   23.41 -
   23.42 -#endif /* __SDL_GF_OPENGLES_H__ */
    24.1 --- a/src/video/qnxgf/SDL_gf_pixelfmt.c	Tue Feb 01 21:23:43 2011 -0800
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,187 +0,0 @@
    24.4 -/*
    24.5 -    SDL - Simple DirectMedia Layer
    24.6 -    Copyright (C) 1997-2010 Sam Lantinga
    24.7 -
    24.8 -    This library is free software; you can redistribute it and/or
    24.9 -    modify it under the terms of the GNU Lesser General Public
   24.10 -    License as published by the Free Software Foundation; either
   24.11 -    version 2.1 of the License, or (at your option) any later version.
   24.12 -
   24.13 -    This library is distributed in the hope that it will be useful,
   24.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   24.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   24.16 -    Lesser General Public License for more details.
   24.17 -
   24.18 -    You should have received a copy of the GNU Lesser General Public
   24.19 -    License along with this library; if not, write to the Free Software
   24.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   24.21 -
   24.22 -    Sam Lantinga
   24.23 -    slouken@libsdl.org
   24.24 -
   24.25 -    QNX Graphics Framework SDL driver
   24.26 -    Copyright (C) 2009 Mike Gorchak
   24.27 -    (mike@malva.ua, lestat@i.com.ua)
   24.28 -*/
   24.29 -
   24.30 -#include "SDL_config.h"
   24.31 -#include "SDL_gf_pixelfmt.h"
   24.32 -
   24.33 -gf_format_t
   24.34 -qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt)
   24.35 -{
   24.36 -    switch (pixelfmt) {
   24.37 -    case SDL_PIXELFORMAT_INDEX8:
   24.38 -        {
   24.39 -            return GF_FORMAT_PAL8;
   24.40 -        }
   24.41 -        break;
   24.42 -    case SDL_PIXELFORMAT_ARGB1555:
   24.43 -        {
   24.44 -            return GF_FORMAT_PACK_ARGB1555;
   24.45 -        }
   24.46 -        break;
   24.47 -    case SDL_PIXELFORMAT_RGB555:
   24.48 -        {
   24.49 -            /* RGB555 is the same as ARGB1555, but alpha is ignored */
   24.50 -            return GF_FORMAT_PACK_ARGB1555;
   24.51 -        }
   24.52 -        break;
   24.53 -    case SDL_PIXELFORMAT_RGB565:
   24.54 -        {
   24.55 -            return GF_FORMAT_PACK_RGB565;
   24.56 -        }
   24.57 -        break;
   24.58 -    case SDL_PIXELFORMAT_BGR565:
   24.59 -        {
   24.60 -            return GF_FORMAT_PKBE_RGB565;
   24.61 -        }
   24.62 -        break;
   24.63 -    case SDL_PIXELFORMAT_RGB24:
   24.64 -        {
   24.65 -            /* GF has wrong components order */
   24.66 -            return GF_FORMAT_BGR888;
   24.67 -        }
   24.68 -        break;
   24.69 -    case SDL_PIXELFORMAT_RGB888:
   24.70 -        {
   24.71 -            /* The same format as ARGB8888, but with alpha ignored */
   24.72 -            /* and GF has wrong components order                   */
   24.73 -            return GF_FORMAT_BGRA8888;
   24.74 -        }
   24.75 -        break;
   24.76 -    case SDL_PIXELFORMAT_ARGB8888:
   24.77 -        {
   24.78 -            /* GF has wrong components order */
   24.79 -            return GF_FORMAT_BGRA8888;
   24.80 -        }
   24.81 -        break;
   24.82 -    case SDL_PIXELFORMAT_BGRA8888:
   24.83 -        {
   24.84 -            /* GF has wrong components order */
   24.85 -            return GF_FORMAT_ARGB8888;
   24.86 -        }
   24.87 -        break;
   24.88 -    case SDL_PIXELFORMAT_YV12:
   24.89 -        {
   24.90 -            return GF_FORMAT_PLANAR_YUV_YV12;
   24.91 -        }
   24.92 -        break;
   24.93 -    case SDL_PIXELFORMAT_YUY2:
   24.94 -        {
   24.95 -            return GF_FORMAT_PACK_YUV_YUY2;
   24.96 -        }
   24.97 -        break;
   24.98 -    case SDL_PIXELFORMAT_UYVY:
   24.99 -        {
  24.100 -            return GF_FORMAT_PACK_YUV_UYVY;
  24.101 -        }
  24.102 -        break;
  24.103 -    case SDL_PIXELFORMAT_YVYU:
  24.104 -        {
  24.105 -            return GF_FORMAT_PACK_YUV_YVYU;
  24.106 -        }
  24.107 -        break;
  24.108 -    }
  24.109 -
  24.110 -    return GF_FORMAT_INVALID;
  24.111 -}
  24.112 -
  24.113 -uint32_t
  24.114 -qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt)
  24.115 -{
  24.116 -    switch (pixelfmt) {
  24.117 -    case GF_FORMAT_PAL8:
  24.118 -        {
  24.119 -            return SDL_PIXELFORMAT_INDEX8;
  24.120 -        }
  24.121 -        break;
  24.122 -    case GF_FORMAT_PKLE_ARGB1555:
  24.123 -        {
  24.124 -            return SDL_PIXELFORMAT_ARGB1555;
  24.125 -        }
  24.126 -        break;
  24.127 -    case GF_FORMAT_PACK_ARGB1555:
  24.128 -        {
  24.129 -            return SDL_PIXELFORMAT_ARGB1555;
  24.130 -        }
  24.131 -        break;
  24.132 -    case GF_FORMAT_PKBE_RGB565:
  24.133 -        {
  24.134 -            return SDL_PIXELFORMAT_BGR565;
  24.135 -        }
  24.136 -        break;
  24.137 -    case GF_FORMAT_PKLE_RGB565:
  24.138 -        {
  24.139 -            return SDL_PIXELFORMAT_RGB565;
  24.140 -        }
  24.141 -        break;
  24.142 -    case GF_FORMAT_PACK_RGB565:
  24.143 -        {
  24.144 -            return SDL_PIXELFORMAT_RGB565;
  24.145 -        }
  24.146 -        break;
  24.147 -    case GF_FORMAT_BGR888:
  24.148 -        {