changeset 5218:b1b0811a1ccc

merged
author Eric Wing <ewing . public |-at-| gmail . com>
date Sun, 06 Feb 2011 21:23:32 -0800
parents b0797947dd1c (diff) 2c500f37abcf (current diff)
children adfcdd311ae0
files Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj Xcode-iPhoneOS/Template/SDL Application/Default.png Xcode-iPhoneOS/Template/SDL Application/Icon.png Xcode-iPhoneOS/Template/SDL Application/Info.plist Xcode-iPhoneOS/Template/SDL Application/___PROJECTNAME___.xcodeproj/TemplateIcon.icns Xcode-iPhoneOS/Template/SDL Application/___PROJECTNAME___.xcodeproj/TemplateInfo.plist Xcode-iPhoneOS/Template/SDL Application/___PROJECTNAME___.xcodeproj/project.pbxproj Xcode-iPhoneOS/Template/SDL Application/build/Debug-iphonesimulator/___PROJECTNAME___.app.dSYM/Contents/Info.plist Xcode-iPhoneOS/Template/SDL Application/build/Debug-iphonesimulator/___PROJECTNAME___.app.dSYM/Contents/Resources/DWARF/___PROJECTNAME___ Xcode-iPhoneOS/Template/SDL Application/build/Debug-iphonesimulator/___PROJECTNAME___.app/Default.png Xcode-iPhoneOS/Template/SDL Application/build/Debug-iphonesimulator/___PROJECTNAME___.app/Icon.png Xcode-iPhoneOS/Template/SDL Application/build/Debug-iphonesimulator/___PROJECTNAME___.app/Info.plist Xcode-iPhoneOS/Template/SDL Application/build/Debug-iphonesimulator/___PROJECTNAME___.app/PkgInfo Xcode-iPhoneOS/Template/SDL Application/build/Debug-iphonesimulator/___PROJECTNAME___.app/___PROJECTNAME___ Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/Debug-iphonesimulator/___PROJECTNAME___.build/Objects-normal/i386/___PROJECTNAME___.LinkFileList Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/Debug-iphonesimulator/___PROJECTNAME___.build/___PROJECTNAME___-all-target-headers.hmap Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/Debug-iphonesimulator/___PROJECTNAME___.build/___PROJECTNAME___-generated-files.hmap Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/Debug-iphonesimulator/___PROJECTNAME___.build/___PROJECTNAME___-own-target-headers.hmap Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/Debug-iphonesimulator/___PROJECTNAME___.build/___PROJECTNAME___-project-headers.hmap Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/Debug-iphonesimulator/___PROJECTNAME___.build/___PROJECTNAME___.dep Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/Debug-iphonesimulator/___PROJECTNAME___.build/___PROJECTNAME___.hmap Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/Debug-iphonesimulator/___PROJECTNAME___.build/___PROJECTNAME___~.dep Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/categories.pbxbtree Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/cdecls.pbxbtree Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/decls.pbxbtree Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/files.pbxbtree Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/imports.pbxbtree Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/pbxindex.header Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/protocols.pbxbtree Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/refs.pbxbtree Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/strings.pbxstrings/control Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/strings.pbxstrings/strings Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/subclasses.pbxbtree Xcode-iPhoneOS/Template/SDL Application/build/___PROJECTNAME___.build/___PROJECTNAME___.pbxindex/symbols0.pbxsymbols Xcode-iPhoneOS/Template/SDL Application/main.c
diffstat 230 files changed, 16673 insertions(+), 39209 deletions(-) [+]
line wrap: on
line diff
--- a/Android.mk	Tue Feb 01 00:37:02 2011 -0800
+++ b/Android.mk	Sun Feb 06 21:23:32 2011 -0800
@@ -30,6 +30,8 @@
 	$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/power/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/render/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
@@ -38,6 +40,6 @@
 	$(wildcard $(LOCAL_PATH)/src/video/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/video/android/*.c))
 
-LOCAL_LDLIBS := -ldl -lGLESv1_CM -llog
+LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog
 
 include $(BUILD_SHARED_LIBRARY)
--- a/Makefile.in	Tue Feb 01 00:37:02 2011 -0800
+++ b/Makefile.in	Sun Feb 06 21:23:32 2011 -0800
@@ -53,6 +53,7 @@
 	SDL_events.h \
 	SDL_gesture.h \
 	SDL_haptic.h \
+	SDL_hints.h \
 	SDL_input.h \
 	SDL_joystick.h \
 	SDL_keyboard.h \
@@ -69,9 +70,9 @@
 	SDL_power.h \
 	SDL_quit.h \
 	SDL_rect.h \
+	SDL_render.h \
 	SDL_revision.h \
 	SDL_rwops.h \
-	SDL_scalemode.h \
 	SDL_scancode.h \
 	SDL_shape.h \
 	SDL_stdinc.h \
--- a/README	Tue Feb 01 00:37:02 2011 -0800
+++ b/README	Sun Feb 06 21:23:32 2011 -0800
@@ -13,7 +13,7 @@
 and 2D framebuffer across multiple platforms.
 
 The current version supports Windows, Windows CE, Mac OS X, Linux, FreeBSD,
-NetBSD, OpenBSD, BSD/OS, Solaris, QNX, iOS, and Android. The code contains
+NetBSD, OpenBSD, BSD/OS, Solaris, iOS, and Android. The code contains
 support for other operating systems but those are not officially supported.
 
 SDL is written in C, but works with C++ natively, and has bindings to
--- a/README.DirectFB	Tue Feb 01 00:37:02 2011 -0800
+++ b/README.DirectFB	Sun Feb 06 21:23:32 2011 -0800
@@ -71,9 +71,9 @@
 As of this writing 20100802 you need to pull Mesa from git and do the following:
 
 ------------------------
-git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
+git clone git://anongit.freedesktop.org/git/mesa/mesa
 cd mesa 
-git clone git://anongit.freedesktop.org/git/mesa/mesa
+git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
 ------------------------
 
 Edit configs/linux-directfb so that the Directories-section looks like
--- a/README.Platforms	Tue Feb 01 00:37:02 2011 -0800
+++ b/README.Platforms	Sun Feb 06 21:23:32 2011 -0800
@@ -30,5 +30,4 @@
 Platforms that need maintainers
 ===============================
 Nintendo DS
-QNX
 Haiku
--- a/README.QNX	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-README.QNX by Mike Gorchak <mike@malva.ua>, <lestat@i.com.ua>
-Last changed at 10 Jun 2009.
-
-QNX Photon and GF drivers are being constructed, OpenGL ES support is
-    finished.  Still no 2D renderer support in GF and Photon drivers.
-QNX QSA (QNX Sound Architecture) driver is ready.
-QNX HID input driver is finished.
-
-----------------------
- -- SDL QSA driver --
-----------------------
-
-   Due to QNX Sound Architecture limitations software could  not  determine
-what playback channels are designed for, so some casus can be. For example,
-output after testmultiaudio test utility execution:
-
-Using audio driver: qsa
-playing on device #0: ('Vortex 8820 @ fb000000 d0')...done.
-playing on device #1: ('Vortex 8820 @ fb000000 d1')...done.
-playing on device #2: ('i8x0 @ d800 d0')...done.
-playing on device #3: ('i8x0 @ d800 d1')...done.
-playing on all devices...
-Open device 3 failed: QSA: snd_pcm_channel_params failed: Invalid argument
-
-If  speakers  are  connected  to  both  audio  cards: Vortex 8820 and Intel
-Integrated Audio we can hear sound playback on device #0 and devices #2, #3
-only. Device #1 is an unknown PCM channel which does not produce any sound.
-
-As for error during device #3 opening, it's caused  by QSA  software  mixer
-channel, because  it can't open real hardware device #2, since it's already
-opened by SDL.
-
-After simultaneous sound playback  on  all  devices  utility testmultiaudio
-stays running waiting for  sound playback  finish  on  device #1,  which is
-locked up due to some Aureal Vortex 8820 driver limitations.
-
----------------------
- -- SDL GF driver --
----------------------
-
-Here is an additional information about SDL GF driver:
- * 0. Introduction.
- * 1. Environment variables which SDL GF driver supports.
- * 2. Custom video modes.
- * 3. Limitations.
-
-0. Introduction.
-
-   SDL GF driver is a layer between  SDL  and  QNX Graphics Framework (GF).
-SDL GF driver also supports OpenGL ES  through the  QNX Graphics Framework.
-Hardware accelerated features which SDL can support depend on real hardware
-capabilities.
-
-1. Environment variables which GF driver supports.
-
-   GF  driver  supports  the  following  environment  variables for  QNX GF
-specific customization options:
-   a) SDL_VIDEO_GF_REFRESH_RATE - refresh  rate  of  video  output  in  Hz.
-      Without this environment variable declaration  SDL  controls  refresh
-      rate of your display.  If this enironment  variable is set  to 0, SDL
-      will control  refresh  rate  of  display,  otherwise  value  of  flag
-      SDL_VIDEO_GF_REFRESH_RATE  is  used  for  all  screen  resolutions as
-      refresh rate. This example will set 60Hz refresh rate as refresh rate
-      for all graphics modes:
-
-      export SDL_VIDEO_GF_REFRESH_RATE=60
-
-2. Custom video modes.
-
-   Since most QNX graphics drivers support GENERIC  video  modes, i.e.  you
-can specify any horizontal and vertical resolution and  any  refresh  rate,
-SDL GF driver uses its own fullscreen modes list, which can be  incomplete.
-You can add any custom video mode, which your QNX graphics driver  supports
-by  editing  file  ./src/video/qnxgf/SDL_qnxgf.c.   Custom   graphics  mode
-definition looks like this:
-
-   {0, 1024, 640, 60, NULL},   /* 1024x640 mode is 60Hz only             */
-
-You must specify horizontal resolution as  the  second  parameter, vertical
-resolution as the third one and  refresh  rate  as  the  fourth  parameter.
-Please leave the first and the last parameters as 0 and NULL.  Then send me
-your changes to e-mail address which is specified in  the  header  of  this
-document.
-
-3. Limitations.
-
-   There are few limitations while using SDL GF driver:
-
-   a) Since  GF   driver   supports   fullscreen  modes  only,   when  flag
-SDL_WINDOW_FULLSCREEN is not specified, SDL GF driver will try to find  the
-fullscreen graphics mode which corresponds to SDL window size. Refresh rate
-will be the  lowest  available,  if  SDL_VIDEO_GF_REFRESH_RATE  environment
-variable is not set.
-   b) As confirmed by QSSL none of existing video  drivers  has  support of
-doublescan low-resolution video modes.  So  modes  below  640x480  are  not
-supported. If your video driver supports low-resolution video modes, please
-add SDL_GF_LOWRESOLUTION flag to the gf_devicename array in the SDL_qnxgf.c
-source file.
-   c) Since  GF  framework supports hardware mouse cursor only,  you'll get
-hardware mouse cursor in case of specific graphics driver supports it.
-
--------------------------
- -- SDL Photon driver --
--------------------------
-
-----------------------------
- -- SDL HID input driver --
-----------------------------
--- a/VisualC/SDL/SDL_VS2005.vcproj	Tue Feb 01 00:37:02 2011 -0800
+++ b/VisualC/SDL/SDL_VS2005.vcproj	Sun Feb 06 21:23:32 2011 -0800
@@ -856,14 +856,6 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\windows\SDL_gdirender.c"
-			>
-		</File>
-		<File
-			RelativePath="..\..\src\video\windows\SDL_gdirender.h"
-			>
-		</File>
-		<File
 			RelativePath="..\..\src\events\SDL_gesture.c"
 			>
 		</File>
--- a/VisualC/SDL/SDL_VS2008.vcproj	Tue Feb 01 00:37:02 2011 -0800
+++ b/VisualC/SDL/SDL_VS2008.vcproj	Sun Feb 06 21:23:32 2011 -0800
@@ -30,7 +30,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadfood&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;xcopy /d /q /y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -201,7 +201,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadfood&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;xcopy /d /q /y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -386,6 +386,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_blendmode.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_clipboard.h"
 				>
 			</File>
@@ -422,10 +426,22 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_gesture.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_haptic.h"
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_hints.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\include\SDL_input.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_joystick.h"
 				>
 			</File>
@@ -486,6 +502,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_render.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_revision.h"
 				>
 			</File>
@@ -498,6 +518,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_shape.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_stdinc.h"
 				>
 			</File>
@@ -518,6 +542,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_touch.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_types.h"
 				>
 			</File>
@@ -583,7 +611,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\mmx.h"
+			RelativePath="..\..\src\render\mmx.h"
 			>
 		</File>
 		<File
@@ -619,14 +647,6 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_alphamult.c"
-			>
-		</File>
-		<File
-			RelativePath="..\..\src\video\SDL_alphamult.h"
-			>
-		</File>
-		<File
 			RelativePath="..\..\src\SDL_assert.c"
 			>
 		</File>
@@ -663,19 +683,27 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_blendfillrect.c"
+			RelativePath="..\..\src\render\software\SDL_blendfillrect.c"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\render\software\SDL_blendfillrect.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_blendline.c"
+			RelativePath="..\..\src\render\software\SDL_blendline.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_blendpoint.c"
+			RelativePath="..\..\src\render\software\SDL_blendline.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_blendrect.c"
+			RelativePath="..\..\src\render\software\SDL_blendpoint.c"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\render\software\SDL_blendpoint.h"
 			>
 		</File>
 		<File
@@ -751,14 +779,6 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\windows\SDL_d3drender.c"
-			>
-		</File>
-		<File
-			RelativePath="..\..\src\video\windows\SDL_d3drender.h"
-			>
-		</File>
-		<File
 			RelativePath="..\..\src\audio\windib\SDL_dibaudio.c"
 			>
 		</File>
@@ -775,19 +795,23 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_draw.h"
+			RelativePath="..\..\src\render\software\SDL_draw.h"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\render\software\SDL_drawline.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_drawline.c"
+			RelativePath="..\..\src\render\software\SDL_drawline.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_drawpoint.c"
+			RelativePath="..\..\src\render\software\SDL_drawpoint.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_drawrect.c"
+			RelativePath="..\..\src\render\software\SDL_drawpoint.h"
 			>
 		</File>
 		<File
@@ -843,14 +867,6 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\windows\SDL_gdirender.c"
-			>
-		</File>
-		<File
-			RelativePath="..\..\src\video\windows\SDL_gdirender.h"
-			>
-		</File>
-		<File
 			RelativePath="..\..\src\events\SDL_gesture.c"
 			>
 		</File>
@@ -875,6 +891,10 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\src\SDL_hints.c"
+			>
+		</File>
+		<File
 			RelativePath="..\..\src\stdlib\SDL_iconv.c"
 			>
 		</File>
@@ -951,11 +971,11 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\dummy\SDL_nullrender.c"
+			RelativePath="..\..\src\video\dummy\SDL_nullframebuffer.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\dummy\SDL_nullrender_c.h"
+			RelativePath="..\..\src\video\dummy\SDL_nullframebuffer_c.h"
 			>
 		</File>
 		<File
@@ -995,19 +1015,23 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_renderer_gl.c"
+			RelativePath="..\..\src\render\SDL_render.c"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\render\direct3d\SDL_render_d3d.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_renderer_gl.h"
+			RelativePath="..\..\src\render\opengl\SDL_render_gl.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_renderer_sw.c"
+			RelativePath="..\..\src\render\software\SDL_render_sw.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_renderer_sw.h"
+			RelativePath="..\..\src\render\software\SDL_render_sw_c.h"
 			>
 		</File>
 		<File
@@ -1083,6 +1107,10 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\src\render\SDL_sysrender.h"
+			>
+		</File>
+		<File
 			RelativePath="..\..\src\thread\windows\SDL_syssem.c"
 			>
 		</File>
@@ -1183,6 +1211,14 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\src\video\windows\SDL_windowsframebuffer.c"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\video\windows\SDL_windowsframebuffer.h"
+			>
+		</File>
+		<File
 			RelativePath="..\..\src\video\windows\SDL_windowsgamma.c"
 			>
 		</File>
@@ -1247,15 +1283,15 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_yuv_mmx.c"
+			RelativePath="..\..\src\render\SDL_yuv_mmx.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_yuv_sw.c"
+			RelativePath="..\..\src\render\SDL_yuv_sw.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_yuv_sw_c.h"
+			RelativePath="..\..\src\render\SDL_yuv_sw_c.h"
 			>
 		</File>
 		<File
--- a/VisualC/SDL/SDL_VS2010.vcxproj	Tue Feb 01 00:37:02 2011 -0800
+++ b/VisualC/SDL/SDL_VS2010.vcxproj	Sun Feb 06 21:23:32 2011 -0800
@@ -75,7 +75,7 @@
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
       <Command>echo Copying SDL_config_windows.h to SDL_config.h...
-copy /Y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
+xcopy /d /q /y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
 echo Creating stub SDL_revision.h file...
@@ -153,7 +153,7 @@
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
       <Command>echo Copying SDL_config_windows.h to SDL_config.h...
-copy /Y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
+xcopy /d /q /y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
 echo Creating stub SDL_revision.h file...
@@ -231,6 +231,7 @@
     <ClInclude Include="..\..\include\SDL_assert.h" />
     <ClInclude Include="..\..\include\SDL_atomic.h" />
     <ClInclude Include="..\..\include\SDL_audio.h" />
+    <ClInclude Include="..\..\include\SDL_blendmode.h" />
     <ClInclude Include="..\..\include\SDL_clipboard.h" />
     <ClInclude Include="..\..\include\SDL_compat.h" />
     <ClInclude Include="..\..\include\SDL_config.h" />
@@ -240,7 +241,10 @@
     <ClInclude Include="..\..\include\SDL_endian.h" />
     <ClInclude Include="..\..\include\SDL_error.h" />
     <ClInclude Include="..\..\include\SDL_events.h" />
+    <ClInclude Include="..\..\include\SDL_gesture.h" />
     <ClInclude Include="..\..\include\SDL_haptic.h" />
+    <ClInclude Include="..\..\include\SDL_hints.h" />
+    <ClInclude Include="..\..\include\SDL_input.h" />
     <ClInclude Include="..\..\include\SDL_joystick.h" />
     <ClInclude Include="..\..\include\SDL_keyboard.h" />
     <ClInclude Include="..\..\include\SDL_keysym.h" />
@@ -256,6 +260,7 @@
     <ClInclude Include="..\..\include\SDL_power.h" />
     <ClInclude Include="..\..\include\SDL_quit.h" />
     <ClInclude Include="..\..\include\SDL_rect.h" />
+    <ClInclude Include="..\..\include\SDL_render.h" />
     <ClInclude Include="..\..\include\SDL_revision.h" />
     <ClInclude Include="..\..\include\SDL_rwops.h" />
     <ClInclude Include="..\..\include\SDL_scancode.h" />
@@ -265,6 +270,7 @@
     <ClInclude Include="..\..\include\SDL_syswm.h" />
     <ClInclude Include="..\..\include\SDL_thread.h" />
     <ClInclude Include="..\..\include\SDL_timer.h" />
+    <ClInclude Include="..\..\include\SDL_touch.h" />
     <ClInclude Include="..\..\include\SDL_types.h" />
     <ClInclude Include="..\..\include\SDL_version.h" />
     <ClInclude Include="..\..\include\SDL_video.h" />
@@ -277,26 +283,32 @@
     <ClInclude Include="..\..\src\events\SDL_touch_c.h" />
     <ClInclude Include="..\..\src\libm\math.h" />
     <ClInclude Include="..\..\src\libm\math_private.h" />
-    <ClInclude Include="..\..\src\video\mmx.h" />
-    <ClInclude Include="..\..\src\video\SDL_alphamult.h" />
+    <ClInclude Include="..\..\src\render\mmx.h" />
+    <ClInclude Include="..\..\src\render\SDL_sysrender.h" />
+    <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h" />
     <ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
     <ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
     <ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
+    <ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h" />
+    <ClInclude Include="..\..\src\render\software\SDL_blendline.h" />
+    <ClInclude Include="..\..\src\render\software\SDL_blendpoint.h" />
+    <ClInclude Include="..\..\src\render\software\SDL_draw.h" />
+    <ClInclude Include="..\..\src\render\software\SDL_drawline.h" />
+    <ClInclude Include="..\..\src\render\software\SDL_drawpoint.h" />
+    <ClInclude Include="..\..\src\render\software\SDL_render_sw_c.h" />
+    <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h" />
     <ClInclude Include="..\..\src\video\SDL_blit.h" />
     <ClInclude Include="..\..\src\video\SDL_blit_auto.h" />
     <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
     <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
     <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
-    <ClInclude Include="..\..\src\video\windows\SDL_d3drender.h" />
     <ClInclude Include="..\..\src\audio\windib\SDL_dibaudio.h" />
     <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
-    <ClInclude Include="..\..\src\video\SDL_draw.h" />
     <ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
     <ClInclude Include="..\..\src\audio\windx5\SDL_dx5audio.h" />
     <ClInclude Include="..\..\src\SDL_error_c.h" />
     <ClInclude Include="..\..\src\events\SDL_events_c.h" />
     <ClInclude Include="..\..\src\SDL_fatal.h" />
-    <ClInclude Include="..\..\src\video\windows\SDL_gdirender.h" />
     <ClInclude Include="..\..\src\video\SDL_glesfuncs.h" />
     <ClInclude Include="..\..\src\video\SDL_glfuncs.h" />
     <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
@@ -307,12 +319,9 @@
     <ClInclude Include="..\..\src\audio\SDL_mixer_MMX_VC.h" />
     <ClInclude Include="..\..\src\events\SDL_mouse_c.h" />
     <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_c.h" />
-    <ClInclude Include="..\..\src\video\dummy\SDL_nullrender_c.h" />
     <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h" />
     <ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
     <ClInclude Include="..\..\src\video\SDL_rect_c.h" />
-    <ClInclude Include="..\..\src\video\SDL_renderer_gl.h" />
-    <ClInclude Include="..\..\src\video\SDL_renderer_sw.h" />
     <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
     <ClInclude Include="..\..\src\video\SDL_stretch_c.h" />
     <ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
@@ -329,6 +338,7 @@
     <ClInclude Include="..\..\src\audio\SDL_wave.h" />
     <ClInclude Include="..\..\src\video\windows\SDL_windowsclipboard.h" />
     <ClInclude Include="..\..\src\video\windows\SDL_windowsevents.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_windowsframebuffer.h" />
     <ClInclude Include="..\..\src\video\windows\SDL_windowsgamma.h" />
     <ClInclude Include="..\..\src\video\windows\SDL_windowskeyboard.h" />
     <ClInclude Include="..\..\src\video\windows\SDL_windowsmodes.h" />
@@ -338,7 +348,6 @@
     <ClInclude Include="..\..\src\video\windows\SDL_windowsvideo.h" />
     <ClInclude Include="..\..\src\video\windows\SDL_windowswindow.h" />
     <ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
-    <ClInclude Include="..\..\src\video\SDL_yuv_sw_c.h" />
     <ClInclude Include="..\..\src\video\windows\wmmsg.h" />
   </ItemGroup>
   <ItemGroup>
@@ -361,8 +370,18 @@
     <ClCompile Include="..\..\src\libm\s_floor.c" />
     <ClCompile Include="..\..\src\libm\s_scalbn.c" />
     <ClCompile Include="..\..\src\libm\s_sin.c" />
+    <ClCompile Include="..\..\src\render\direct3d\SDL_render_d3d.c" />
+    <ClCompile Include="..\..\src\render\opengl\SDL_render_gl.c" />
+    <ClCompile Include="..\..\src\render\SDL_render.c" />
+    <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
+    <ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
+    <ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c" />
+    <ClCompile Include="..\..\src\render\software\SDL_blendline.c" />
+    <ClCompile Include="..\..\src\render\software\SDL_blendpoint.c" />
+    <ClCompile Include="..\..\src\render\software\SDL_drawline.c" />
+    <ClCompile Include="..\..\src\render\software\SDL_drawpoint.c" />
+    <ClCompile Include="..\..\src\render\software\SDL_render_sw.c" />
     <ClCompile Include="..\..\src\SDL.c" />
-    <ClCompile Include="..\..\src\video\SDL_alphamult.c" />
     <ClCompile Include="..\..\src\SDL_assert.c" />
     <ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
     <ClCompile Include="..\..\src\atomic\SDL_spinlock.c" />
@@ -370,10 +389,8 @@
     <ClCompile Include="..\..\src\audio\SDL_audiocvt.c" />
     <ClCompile Include="..\..\src\audio\SDL_audiodev.c" />
     <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c" />
-    <ClCompile Include="..\..\src\video\SDL_blendfillrect.c" />
-    <ClCompile Include="..\..\src\video\SDL_blendline.c" />
-    <ClCompile Include="..\..\src\video\SDL_blendpoint.c" />
-    <ClCompile Include="..\..\src\video\SDL_blendrect.c" />
+    <ClCompile Include="..\..\src\SDL_hints.c" />
+    <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c" />
     <ClCompile Include="..\..\src\video\SDL_blit.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_0.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_1.c" />
@@ -387,12 +404,8 @@
     <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
     <ClCompile Include="..\..\src\video\SDL_clipboard.c" />
     <ClCompile Include="..\..\src\video\SDL_shape.c" />
-    <ClCompile Include="..\..\src\video\windows\SDL_d3drender.c" />
     <ClCompile Include="..\..\src\audio\windib\SDL_dibaudio.c" />
     <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c" />
-    <ClCompile Include="..\..\src\video\SDL_drawline.c" />
-    <ClCompile Include="..\..\src\video\SDL_drawpoint.c" />
-    <ClCompile Include="..\..\src\video\SDL_drawrect.c" />
     <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c" />
     <ClCompile Include="..\..\src\audio\windx5\SDL_dx5audio.c" />
     <ClCompile Include="..\..\src\joystick\windows\SDL_dxjoystick.c" />
@@ -401,7 +414,6 @@
     <ClCompile Include="..\..\src\SDL_fatal.c" />
     <ClCompile Include="..\..\src\video\SDL_fillrect.c" />
     <ClCompile Include="..\..\src\video\SDL_gamma.c" />
-    <ClCompile Include="..\..\src\video\windows\SDL_gdirender.c" />
     <ClCompile Include="..\..\src\stdlib\SDL_getenv.c" />
     <ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
     <ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
@@ -415,15 +427,12 @@
     <ClCompile Include="..\..\src\joystick\windows\SDL_mmjoystick.c" />
     <ClCompile Include="..\..\src\events\SDL_mouse.c" />
     <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c" />
-    <ClCompile Include="..\..\src\video\dummy\SDL_nullrender.c" />
     <ClCompile Include="..\..\src\video\dummy\SDL_nullvideo.c" />
     <ClCompile Include="..\..\src\video\SDL_pixels.c" />
     <ClCompile Include="..\..\src\power\SDL_power.c" />
     <ClCompile Include="..\..\src\stdlib\SDL_qsort.c" />
     <ClCompile Include="..\..\src\events\SDL_quit.c" />
     <ClCompile Include="..\..\src\video\SDL_rect.c" />
-    <ClCompile Include="..\..\src\video\SDL_renderer_gl.c" />
-    <ClCompile Include="..\..\src\video\SDL_renderer_sw.c" />
     <ClCompile Include="..\..\src\video\SDL_RLEaccel.c" />
     <ClCompile Include="..\..\src\file\SDL_rwops.c" />
     <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
@@ -443,6 +452,7 @@
     <ClCompile Include="..\..\src\audio\SDL_wave.c" />
     <ClCompile Include="..\..\src\video\windows\SDL_windowsclipboard.c" />
     <ClCompile Include="..\..\src\video\windows\SDL_windowsevents.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_windowsframebuffer.c" />
     <ClCompile Include="..\..\src\video\windows\SDL_windowsgamma.c" />
     <ClCompile Include="..\..\src\video\windows\SDL_windowskeyboard.c" />
     <ClCompile Include="..\..\src\video\windows\SDL_windowsmodes.c" />
@@ -452,10 +462,8 @@
     <ClCompile Include="..\..\src\video\windows\SDL_windowsvideo.c" />
     <ClCompile Include="..\..\src\video\windows\SDL_windowswindow.c" />
     <ClCompile Include="..\..\src\events\SDL_windowevents.c" />
-    <ClCompile Include="..\..\src\video\SDL_yuv_mmx.c" />
-    <ClCompile Include="..\..\src\video\SDL_yuv_sw.c" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
--- a/VisualC/SDL_VS2008.sln	Tue Feb 01 00:37:02 2011 -0800
+++ b/VisualC/SDL_VS2008.sln	Sun Feb 06 21:23:32 2011 -0800
@@ -84,12 +84,6 @@
 		{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
 	EndProjectSection
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpalette", "tests\testpalette\testpalette_VS2008.vcproj", "{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}"
-	ProjectSection(ProjectDependencies) = postProject
-		{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
-		{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
-	EndProjectSection
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testplatform", "tests\testplatform\testplatform_VS2008.vcproj", "{26932B24-EFC6-4E3A-B277-ED653DA37968}"
 	ProjectSection(ProjectDependencies) = postProject
 		{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
@@ -301,15 +295,6 @@
 		{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Release|Win32.ActiveCfg = Release|Win32
 		{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Release|Win32.Build.0 = Release|Win32
 		{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Release|x64.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|Win32.ActiveCfg = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|Win32.Build.0 = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|x64.ActiveCfg = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release_NoSTDIO|Win32.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release_NoSTDIO|Win32.Build.0 = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release_NoSTDIO|x64.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|Win32.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|Win32.Build.0 = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|x64.ActiveCfg = Release|Win32
 		{26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.ActiveCfg = Debug|Win32
 		{26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.Build.0 = Debug|Win32
 		{26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|x64.ActiveCfg = Debug|Win32
@@ -418,7 +403,6 @@
 		{55812185-D13C-4022-9C81-32E0F4A08304} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{9E320A14-B443-4DD7-8725-B7020DCFF730} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{26932B24-EFC6-4E3A-B277-ED653DA37968} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{5D0930C0-7C91-4ECE-9014-7B7DDE9502E5} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
--- a/VisualC/SDL_VS2010.sln	Tue Feb 01 00:37:02 2011 -0800
+++ b/VisualC/SDL_VS2010.sln	Sun Feb 06 21:23:32 2011 -0800
@@ -49,12 +49,6 @@
 		{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
 	EndProjectSection
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpalette", "tests\testpalette\testpalette_VS2010.vcxproj", "{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}"
-	ProjectSection(ProjectDependencies) = postProject
-		{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
-		{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
-	EndProjectSection
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testvidinfo", "tests\testvidinfo\testvidinfo_VS2010.vcxproj", "{575FD095-EDAB-4BD4-B733-CD4A874F6FB0}"
 	ProjectSection(ProjectDependencies) = postProject
 		{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
@@ -230,14 +224,6 @@
 		{55812185-D13C-4022-9C81-32E0F4A08304}.Release|Win32.ActiveCfg = Release|Win32
 		{55812185-D13C-4022-9C81-32E0F4A08304}.Release|Win32.Build.0 = Release|Win32
 		{55812185-D13C-4022-9C81-32E0F4A08304}.Release|x64.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|Win32.ActiveCfg = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|Win32.Build.0 = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|x64.ActiveCfg = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release_NoSTDIO|Win32.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release_NoSTDIO|x64.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|Win32.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|Win32.Build.0 = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|x64.ActiveCfg = Release|Win32
 		{575FD095-EDAB-4BD4-B733-CD4A874F6FB0}.Debug|Win32.ActiveCfg = Debug|Win32
 		{575FD095-EDAB-4BD4-B733-CD4A874F6FB0}.Debug|Win32.Build.0 = Debug|Win32
 		{575FD095-EDAB-4BD4-B733-CD4A874F6FB0}.Debug|x64.ActiveCfg = Debug|Win32
@@ -361,7 +347,6 @@
 		{D974A0DF-3E2E-445C-A2EB-E899E9B582CB} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{272D976B-A1DF-4DEB-BD7F-5C0D330E0C7D} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{55812185-D13C-4022-9C81-32E0F4A08304} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{575FD095-EDAB-4BD4-B733-CD4A874F6FB0} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{0FFD1A21-11DB-492C-A989-E4F195B0C441} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{6AF0724B-BAC1-4C9D-AFBF-F63B4A2FB8FB} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
--- a/VisualC/tests/testpalette/testpalette_VS2005.vcproj	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,217 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8.00"
-	Name="testpalette"
-	ProjectGUID="{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				PreprocessorDefinitions="NDEBUG"
-				MkTypLibCompatible="true"
-				SuppressStartupBanner="true"
-				TargetEnvironment="1"
-				TypeLibraryName=".\Release/testpalette.tlb"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="..\..\..\include"
-				PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
-				StringPooling="true"
-				RuntimeLibrary="2"
-				EnableFunctionLevelLinking="true"
-				UsePrecompiledHeader="0"
-				PrecompiledHeaderFile=".\Release/testpalette.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="1033"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalOptions="/MACHINE:I386"
-				OutputFile=".\Release/testpalette.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="true"
-				ProgramDatabaseFile=".\Release/testpalette.pdb"
-				SubSystem="2"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\Debug"
-			IntermediateDirectory=".\Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				PreprocessorDefinitions="_DEBUG"
-				MkTypLibCompatible="true"
-				SuppressStartupBanner="true"
-				TargetEnvironment="1"
-				TypeLibraryName=".\Debug/testpalette.tlb"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="..\..\..\include"
-				PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS"
-				RuntimeLibrary="2"
-				UsePrecompiledHeader="0"
-				PrecompiledHeaderFile=".\Debug/testpalette.pch"
-				AssemblerListingLocation=".\Debug/"
-				ObjectFile=".\Debug/"
-				ProgramDataBaseFileName=".\Debug/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				DebugInformationFormat="4"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1033"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalOptions="/MACHINE:I386"
-				OutputFile=".\Debug/testpalette.exe"
-				LinkIncremental="2"
-				SuppressStartupBanner="true"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile=".\Debug/testpalette.pdb"
-				SubSystem="2"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<File
-			RelativePath="..\..\Sdl\Debug\SDL.lib"
-			>
-		</File>
-		<File
-			RelativePath="..\..\SDLmain\Debug\SDLmain.lib"
-			>
-		</File>
-		<File
-			RelativePath="..\..\..\test\testpalette.c"
-			>
-		</File>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
--- a/VisualC/tests/testpalette/testpalette_VS2008.vcproj	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="9.00"
-	Name="testpalette"
-	ProjectGUID="{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}"
-	TargetFrameworkVersion="131072"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				PreprocessorDefinitions="NDEBUG"
-				MkTypLibCompatible="true"
-				SuppressStartupBanner="true"
-				TargetEnvironment="1"
-				TypeLibraryName=".\Release/testpalette.tlb"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="..\..\..\include"
-				PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
-				StringPooling="true"
-				RuntimeLibrary="2"
-				EnableFunctionLevelLinking="true"
-				UsePrecompiledHeader="0"
-				PrecompiledHeaderFile=".\Release/testpalette.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="1033"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalOptions="/MACHINE:I386"
-				OutputFile=".\Release/testpalette.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="true"
-				ProgramDatabaseFile=".\Release/testpalette.pdb"
-				SubSystem="2"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				Description="Copy SDL and data files"
-				CommandLine="copy $(SolutionDir)\SDL\$(ConfigurationName)\SDL.dll $(TargetDir)\SDL.dll&#x0D;&#x0A;copy $(SolutionDir)\..\test\sail.bmp $(ProjectDir)\sail.bmp&#x0D;&#x0A;"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\Debug"
-			IntermediateDirectory=".\Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				PreprocessorDefinitions="_DEBUG"
-				MkTypLibCompatible="true"
-				SuppressStartupBanner="true"
-				TargetEnvironment="1"
-				TypeLibraryName=".\Debug/testpalette.tlb"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="..\..\..\include"
-				PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS"
-				RuntimeLibrary="3"
-				UsePrecompiledHeader="0"
-				PrecompiledHeaderFile=".\Debug/testpalette.pch"
-				AssemblerListingLocation=".\Debug/"
-				ObjectFile=".\Debug/"
-				ProgramDataBaseFileName=".\Debug/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				DebugInformationFormat="4"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1033"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalOptions="/MACHINE:I386"
-				OutputFile=".\Debug/testpalette.exe"
-				LinkIncremental="2"
-				SuppressStartupBanner="true"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile=".\Debug/testpalette.pdb"
-				SubSystem="2"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				Description="Copy SDL and data files"
-				CommandLine="copy $(SolutionDir)\SDL\$(ConfigurationName)\SDL.dll $(TargetDir)\SDL.dll&#x0D;&#x0A;copy $(SolutionDir)\..\test\sail.bmp $(ProjectDir)\sail.bmp&#x0D;&#x0A;"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<File
-			RelativePath="..\..\..\test\testpalette.c"
-			>
-		</File>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
--- a/VisualC/tests/testpalette/testpalette_VS2010.vcxproj	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectName>testpalette</ProjectName>
-    <RootNamespace>testpalette</RootNamespace>
-    <ProjectGuid>{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}</ProjectGuid>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseOfMfc>false</UseOfMfc>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseOfMfc>false</UseOfMfc>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup>
-    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
-    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\Release\</OutDir>
-    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\Release\</IntDir>
-    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
-    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</OutDir>
-    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</IntDir>
-    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Midl>
-      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <MkTypLibCompatible>true</MkTypLibCompatible>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <TargetEnvironment>Win32</TargetEnvironment>
-      <TypeLibraryName>.\Release/testpalette.tlb</TypeLibraryName>
-    </Midl>
-    <ClCompile>
-      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
-      <AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <StringPooling>true</StringPooling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <PrecompiledHeaderOutputFile>.\Release/testpalette.pch</PrecompiledHeaderOutputFile>
-      <AssemblerListingLocation>.\Release/</AssemblerListingLocation>
-      <ObjectFileName>.\Release/</ObjectFileName>
-      <ProgramDataBaseFileName>.\Release/</ProgramDataBaseFileName>
-      <WarningLevel>Level3</WarningLevel>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <CompileAs>Default</CompileAs>
-    </ClCompile>
-    <ResourceCompile>
-      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <Culture>0x0409</Culture>
-    </ResourceCompile>
-    <Link>
-      <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions>
-      <OutputFile>.\Release/testpalette.exe</OutputFile>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <ProgramDatabaseFile>.\Release/testpalette.pdb</ProgramDatabaseFile>
-      <SubSystem>Windows</SubSystem>
-    </Link>
-    <PostBuildEvent>
-      <Command>copy $(SolutionDir)\SDL\$(ConfigurationName)\SDL.dll $(TargetDir)\SDL.dll
-copy $(SolutionDir)\..\test\sail.bmp $(ProjectDir)\sail.bmp</Command>
-    </PostBuildEvent>
-    <PostBuildEvent>
-      <Message>Copy SDL and data files</Message>
-    </PostBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Midl>
-      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <MkTypLibCompatible>true</MkTypLibCompatible>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <TargetEnvironment>Win32</TargetEnvironment>
-      <TypeLibraryName>.\Debug/testpalette.tlb</TypeLibraryName>
-    </Midl>
-    <ClCompile>
-      <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <PrecompiledHeaderOutputFile>.\Debug/testpalette.pch</PrecompiledHeaderOutputFile>
-      <AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
-      <ObjectFileName>.\Debug/</ObjectFileName>
-      <ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
-      <WarningLevel>Level3</WarningLevel>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
-      <CompileAs>Default</CompileAs>
-    </ClCompile>
-    <ResourceCompile>
-      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <Culture>0x0409</Culture>
-    </ResourceCompile>
-    <Link>
-      <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions>
-      <OutputFile>.\Debug/testpalette.exe</OutputFile>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <ProgramDatabaseFile>.\Debug/testpalette.pdb</ProgramDatabaseFile>
-      <SubSystem>Windows</SubSystem>
-    </Link>
-    <PostBuildEvent>
-      <Command>copy $(SolutionDir)\SDL\$(ConfigurationName)\SDL.dll $(TargetDir)\SDL.dll
-copy $(SolutionDir)\..\test\sail.bmp $(ProjectDir)\sail.bmp</Command>
-    </PostBuildEvent>
-    <PostBuildEvent>
-      <Message>Copy SDL and data files</Message>
-    </PostBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <Library Include="..\..\Sdl\Debug\SDL.lib" />
-    <Library Include="..\..\SDLmain\Debug\SDLmain.lib" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="..\..\..\test\testpalette.c" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>
\ No newline at end of file
--- a/VisualCE/SDL/SDL.vcproj	Tue Feb 01 00:37:02 2011 -0800
+++ b/VisualCE/SDL/SDL.vcproj	Sun Feb 06 21:23:32 2011 -0800
@@ -738,10 +738,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_alphamult.c"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\SDL_assert.c"
 				>
 			</File>
@@ -766,19 +762,15 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_blendfillrect.c"
+				RelativePath="..\..\src\render\software\SDL_blendfillrect.c"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_blendline.c"
+				RelativePath="..\..\src\render\software\SDL_blendline.c"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_blendpoint.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\SDL_blendrect.c"
+				RelativePath="..\..\src\render\software\SDL_blendpoint.c"
 				>
 			</File>
 			<File
@@ -818,10 +810,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\windows\SDL_ceddrawrender.c"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\video\SDL_clipboard.c"
 				>
 			</File>
@@ -838,10 +826,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\windows\SDL_d3drender.c"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\audio\windib\SDL_dibaudio.c"
 				>
 			</File>
@@ -850,15 +834,11 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_drawline.c"
+				RelativePath="..\..\src\render\software\SDL_drawline.c"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_drawpoint.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\SDL_drawrect.c"
+				RelativePath="..\..\src\render\software\SDL_drawpoint.c"
 				>
 			</File>
 			<File
@@ -886,14 +866,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\windows\SDL_gapirender.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\windows\SDL_gdirender.c"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\events\SDL_gesture.c"
 				>
 			</File>
@@ -934,7 +906,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\dummy\SDL_nullrender.c"
+				RelativePath="..\..\src\video\dummy\SDL_nullframebuffer.c"
 				>
 			</File>
 			<File
@@ -962,7 +934,11 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_renderer_sw.c"
+				RelativePath="..\..\src\render\SDL_render.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\render\software\SDL_renderer_sw.c"
 				>
 			</File>
 			<File
@@ -1066,6 +1042,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsframebuffer.c"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\video\windows\SDL_windowsgamma.c"
 				>
 			</File>
@@ -1098,11 +1078,11 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_yuv_mmx.c"
+				RelativePath="..\..\src\render\SDL_yuv_mmx.c"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_yuv_sw.c"
+				RelativePath="..\..\src\render\SDL_yuv_sw.c"
 				>
 			</File>
 			<File
@@ -1131,7 +1111,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\mmx.h"
+				RelativePath="..\..\src\render\mmx.h"
 				>
 			</File>
 			<File
@@ -1151,10 +1131,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_alphamult.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\SDL_assert_c.h"
 				>
 			</File>
@@ -1171,6 +1147,18 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\render\software\SDL_blendfillrect.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\render\software\SDL_blendline.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\render\software\SDL_blendpoint.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\video\SDL_blit.h"
 				>
 			</File>
@@ -1187,18 +1175,10 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\windows\SDL_ceddrawrender.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\events\SDL_clipboardevents_c.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\windows\SDL_d3drender.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\audio\windib\SDL_dibaudio.h"
 				>
 			</File>
@@ -1207,7 +1187,15 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_draw.h"
+				RelativePath="..\..\src\render\software\SDL_draw.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\render\software\SDL_drawline.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\render\software\SDL_drawpoint.h"
 				>
 			</File>
 			<File
@@ -1227,18 +1215,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\windows\SDL_gapirender.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\windows\SDL_gapirender_c.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\windows\SDL_gdirender.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\events\SDL_gesture_c.h"
 				>
 			</File>
@@ -1279,7 +1255,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\dummy\SDL_nullrender_c.h"
+				RelativePath="..\..\src\video\dummy\SDL_nullframebuffer_c.h"
 				>
 			</File>
 			<File
@@ -1295,7 +1271,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_renderer_sw.h"
+				RelativePath="..\..\src\render\software\SDL_renderer_sw_c.h"
 				>
 			</File>
 			<File
@@ -1323,6 +1299,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\render\SDL_sysrender.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\thread\SDL_systhread.h"
 				>
 			</File>
@@ -1375,6 +1355,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsframebuffer.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\video\windows\SDL_windowsgamma.h"
 				>
 			</File>
@@ -1407,7 +1391,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_yuv_sw_c.h"
+				RelativePath="..\..\src\render\SDL_yuv_sw_c.h"
 				>
 			</File>
 			<File
--- a/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj	Tue Feb 01 00:37:02 2011 -0800
+++ b/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj	Sun Feb 06 21:23:32 2011 -0800
@@ -748,7 +748,7 @@
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = ../../include;
-				LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../SDLiPod/build/Release-iphoneos\"";
+				LIBRARY_SEARCH_PATHS = "";
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_CFLAGS = "";
 				PREBINDING = NO;
@@ -767,7 +767,7 @@
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = ../../include;
-				LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../SDLiPod/build/Release-iphoneos\"";
+				LIBRARY_SEARCH_PATHS = "";
 				OTHER_CFLAGS = "";
 				PREBINDING = NO;
 				PRELINK_LIBS = "";
--- a/Xcode-iPhoneOS/Demos/src/accelerometer.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/Xcode-iPhoneOS/Demos/src/accelerometer.c	Sun Feb 06 21:23:32 2011 -0800
@@ -31,7 +31,7 @@
 static SDL_Texture *space = 0;       /* texture for space (background */
 
 void
-render(void)
+render(SDL_Renderer *renderer)
 {
 
 
@@ -97,28 +97,24 @@
     }
 
     /* draw the background */
-    SDL_RenderCopy(space, NULL, NULL);
+    SDL_RenderCopy(renderer, space, NULL, NULL);
 
     /* draw the ship */
     shipData.rect.x = shipData.x;
     shipData.rect.y = shipData.y;
 
-    SDL_RenderCopy(ship, NULL, &shipData.rect);
+    SDL_RenderCopy(renderer, ship, NULL, &shipData.rect);
 
     /* update screen */
-    SDL_RenderPresent();
+    SDL_RenderPresent(renderer);
 
 }
 
 void
-initializeTextures()
+initializeTextures(SDL_Renderer *renderer)
 {
 
     SDL_Surface *bmp_surface;
-    SDL_Surface *bmp_surface_rgba;
-    int format = SDL_PIXELFORMAT_ABGR8888;      /* desired texture format */
-    Uint32 Rmask, Gmask, Bmask, Amask;  /* masks for desired format */
-    int bpp;                    /* bits per pixel for desired format */
 
     /* load the ship */
     bmp_surface = SDL_LoadBMP("ship.bmp");
@@ -128,20 +124,9 @@
     /* set blue to transparent on the ship */
     SDL_SetColorKey(bmp_surface, 1,
                     SDL_MapRGB(bmp_surface->format, 0, 0, 255));
-    SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
-    /*
-       create a new RGBA surface and blit the bmp to it
-       this is an extra step, but it seems to be necessary for the color key to work
-
-       does the fact that this is necessary indicate a bug in SDL?
-     */
-    bmp_surface_rgba =
-        SDL_CreateRGBSurface(0, bmp_surface->w, bmp_surface->h, bpp, Rmask,
-                             Gmask, Bmask, Amask);
-    SDL_BlitSurface(bmp_surface, NULL, bmp_surface_rgba, NULL);
 
     /* create ship texture from surface */
-    ship = SDL_CreateTextureFromSurface(format, bmp_surface_rgba);
+    ship = SDL_CreateTextureFromSurface(renderer, bmp_surface);
     if (ship == 0) {
         fatalError("could not create ship texture");
     }
@@ -151,7 +136,6 @@
     shipData.rect.w = bmp_surface->w;
     shipData.rect.h = bmp_surface->h;
 
-    SDL_FreeSurface(bmp_surface_rgba);
     SDL_FreeSurface(bmp_surface);
 
     /* load the space background */
@@ -160,7 +144,7 @@
         fatalError("could not load space.bmp");
     }
     /* create space texture from surface */
-    space = SDL_CreateTextureFromSurface(format, bmp_surface);
+    space = SDL_CreateTextureFromSurface(renderer, bmp_surface);
     if (space == 0) {
         fatalError("could not create space texture");
     }
@@ -175,6 +159,7 @@
 {
 
     SDL_Window *window;         /* main window */
+	SDL_Renderer *renderer;
     Uint32 startFrame;          /* time frame began to process */
     Uint32 endFrame;            /* time frame ended processing */
     Uint32 delay;               /* time to pause waiting to draw next frame */
@@ -189,7 +174,7 @@
     window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
                                 SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN |
                                 SDL_WINDOW_BORDERLESS);
-    SDL_CreateRenderer(window, 0, 0);
+    renderer = SDL_CreateRenderer(window, 0, 0);
 
     /* print out some info about joysticks and try to open accelerometer for use */
     printf("There are %d joysticks available\n", SDL_NumJoysticks());
@@ -208,7 +193,7 @@
            SDL_JoystickNumButtons(accelerometer));
 
     /* load graphics */
-    initializeTextures();
+    initializeTextures(renderer);
 
     /* setup ship */
     shipData.x = (SCREEN_WIDTH - shipData.rect.w) / 2;
@@ -226,7 +211,7 @@
                 done = 1;
             }
         }
-        render();
+        render(renderer);
         endFrame = SDL_GetTicks();
 
         /* figure out how much time we have left, and then sleep */
--- a/Xcode-iPhoneOS/Demos/src/fireworks.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/Xcode-iPhoneOS/Demos/src/fireworks.c	Sun Feb 06 21:23:32 2011 -0800
@@ -173,9 +173,6 @@
     /* draw our particles! */
     glDrawArrays(GL_POINTS, 0, num_active_particles);
 
-    /* update screen */
-    SDL_RenderPresent();
-
 }
 
 /*
@@ -437,6 +434,7 @@
         }
         stepParticles();
         drawParticles();
+		SDL_GL_SwapWindow(window);
         endFrame = SDL_GetTicks();
 
         /* figure out how much time we have left, and then sleep */
--- a/Xcode-iPhoneOS/Demos/src/happy.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/Xcode-iPhoneOS/Demos/src/happy.c	Sun Feb 06 21:23:32 2011 -0800
@@ -36,7 +36,7 @@
 }
 
 void
-render(void)
+render(SDL_Renderer *renderer)
 {
 
     int i;
@@ -58,8 +58,8 @@
     dstRect.h = HAPPY_FACE_SIZE;
 
     /* fill background in with black */
-    SDL_SetRenderDrawColor(0, 0, 0, 255);
-    SDL_RenderFill(NULL);
+    SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
+    SDL_RenderClear(renderer);
 
     /*
        loop through all the happy faces:
@@ -86,10 +86,10 @@
         }
         dstRect.x = faces[i].x;
         dstRect.y = faces[i].y;
-        SDL_RenderCopy(texture, &srcRect, &dstRect);
+        SDL_RenderCopy(renderer, texture, &srcRect, &dstRect);
     }
     /* update screen */
-    SDL_RenderPresent();
+    SDL_RenderPresent(renderer);
 
 }
 
@@ -97,13 +97,9 @@
 	loads the happyface graphic into a texture
 */
 void
-initializeTexture()
+initializeTexture(SDL_Renderer *renderer)
 {
     SDL_Surface *bmp_surface;
-    SDL_Surface *bmp_surface_rgba;
-    int format = SDL_PIXELFORMAT_ABGR8888;      /* desired texture format */
-    Uint32 Rmask, Gmask, Bmask, Amask;  /* masks for desired format */
-    int bpp;                    /* bits per pixel for desired format */
     /* load the bmp */
     bmp_surface = SDL_LoadBMP("icon.bmp");
     if (bmp_surface == NULL) {
@@ -112,26 +108,15 @@
     /* set white to transparent on the happyface */
     SDL_SetColorKey(bmp_surface, 1,
                     SDL_MapRGB(bmp_surface->format, 255, 255, 255));
-    SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
-    /*
-       create a new RGBA surface and blit the bmp to it
-       this is an extra step, but it seems to be necessary
-       is this a bug?
-     */
-    bmp_surface_rgba =
-        SDL_CreateRGBSurface(0, bmp_surface->w, bmp_surface->h, bpp, Rmask,
-                             Gmask, Bmask, Amask);
-    SDL_BlitSurface(bmp_surface, NULL, bmp_surface_rgba, NULL);
 
     /* convert RGBA surface to texture */
-    texture = SDL_CreateTextureFromSurface(format, bmp_surface_rgba);
+    texture = SDL_CreateTextureFromSurface(renderer, bmp_surface);
     if (texture == 0) {
         fatalError("could not create texture");
     }
     SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
 
     /* free up allocated memory */
-    SDL_FreeSurface(bmp_surface_rgba);
     SDL_FreeSurface(bmp_surface);
 }
 
@@ -140,6 +125,7 @@
 {
 
     SDL_Window *window;
+	SDL_Renderer *renderer;
     Uint32 startFrame;
     Uint32 endFrame;
     Uint32 delay;
@@ -153,9 +139,9 @@
                                 SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN |
                                 SDL_WINDOW_BORDERLESS);
 
-    SDL_CreateRenderer(window, -1, 0);
+    renderer = SDL_CreateRenderer(window, -1, 0);
 
-    initializeTexture();
+    initializeTexture(renderer);
     initializeHappyFaces();
 
     /* main loop */
@@ -168,7 +154,7 @@
                 done = 1;
             }
         }
-        render();
+        render(renderer);
         endFrame = SDL_GetTicks();
 
         /* figure out how much time we have left, and then sleep */
--- a/Xcode-iPhoneOS/Demos/src/mixer.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/Xcode-iPhoneOS/Demos/src/mixer.c	Sun Feb 06 21:23:32 2011 -0800
@@ -33,7 +33,6 @@
 void handleMouseButtonDown(SDL_Event * event);
 void handleMouseButtonUp(SDL_Event * event);
 int playSound(struct sound *);
-void render(void);
 void initializeButtons();
 void audioCallback(void *userdata, Uint8 * stream, int len);
 void loadSound(const char *file, struct sound *s);
@@ -163,20 +162,20 @@
 
 /* draws buttons to screen */
 void
-render(void)
+render(SDL_Renderer *renderer)
 {
     int i;
-    SDL_SetRenderDrawColor(50, 50, 50, 255);
-    SDL_RenderFill(NULL);       /* draw background (gray) */
+    SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255);
+    SDL_RenderClear(renderer);       /* draw background (gray) */
     /* draw the drum buttons */
     for (i = 0; i < NUM_DRUMS; i++) {
         SDL_Color color =
             buttons[i].isPressed ? buttons[i].downColor : buttons[i].upColor;
-        SDL_SetRenderDrawColor(color.r, color.g, color.b, color.unused);
-        SDL_RenderFill(&buttons[i].rect);
+        SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.unused);
+        SDL_RenderFillRect(renderer, &buttons[i].rect);
     }
     /* update the screen */
-    SDL_RenderPresent();
+    SDL_RenderPresent(renderer);
 }
 
 /*
@@ -274,6 +273,7 @@
 
     int done;                   /* has user tried to quit ? */
     SDL_Window *window;         /* main window */
+	SDL_Renderer *renderer;
     SDL_Event event;
     Uint32 startFrame;          /* holds when frame started processing */
     Uint32 endFrame;            /* holds when frame ended processing */
@@ -285,7 +285,7 @@
     window =
         SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
                          SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS);
-    SDL_CreateRenderer(window, 0, 0);
+    renderer = SDL_CreateRenderer(window, 0, 0);
 
     /* initialize the mixer */
     SDL_memset(&mixer, 0, sizeof(mixer));
@@ -328,7 +328,7 @@
                 break;
             }
         }
-        render();               /* draw buttons */
+        render(renderer);               /* draw buttons */
         endFrame = SDL_GetTicks();
 
         /* figure out how much time we have left, and then sleep */
--- a/Xcode-iPhoneOS/Demos/src/rectangles.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/Xcode-iPhoneOS/Demos/src/rectangles.c	Sun Feb 06 21:23:32 2011 -0800
@@ -9,7 +9,7 @@
 #include "common.h"
 
 void
-render(void)
+render(SDL_Renderer *renderer)
 {
 
     Uint8 r, g, b;
@@ -26,11 +26,11 @@
     b = randomInt(50, 255);
 
     /*  Fill the rectangle in the color */
-    SDL_SetRenderDrawColor(r, g, b, 255);
-    SDL_RenderFill(&rect);
+    SDL_SetRenderDrawColor(renderer, r, g, b, 255);
+    SDL_RenderFillRect(renderer, &rect);
 
     /* update screen */
-    SDL_RenderPresent();
+    SDL_RenderPresent(renderer);
 
 }
 
@@ -39,6 +39,7 @@
 {
 
     SDL_Window *window;
+	SDL_Renderer *renderer;
     int done;
     SDL_Event event;
 
@@ -57,13 +58,14 @@
     if (window == 0) {
         fatalError("Could not initialize Window");
     }
-    if (SDL_CreateRenderer(window, -1, 0) != 0) {
+    renderer = SDL_CreateRenderer(window, -1, 0);
+	if (!renderer) {
         fatalError("Could not create renderer");
     }
 
     /* Fill screen with black */
-    SDL_SetRenderDrawColor(0, 0, 0, 255);
-    SDL_RenderFill(NULL);
+    SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
+    SDL_RenderClear(renderer);
 
     /* Enter render loop, waiting for user to quit */
     done = 0;
@@ -73,7 +75,7 @@
                 done = 1;
             }
         }
-        render();
+        render(renderer);
         SDL_Delay(1);
     }
 
--- a/Xcode-iPhoneOS/Demos/src/touch.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/Xcode-iPhoneOS/Demos/src/touch.c	Sun Feb 06 21:23:32 2011 -0800
@@ -18,7 +18,7 @@
 	this is accomplished by drawing several blots spaced PIXELS_PER_ITERATION apart
 */
 void
-drawLine(float startx, float starty, float dx, float dy)
+drawLine(SDL_Renderer *renderer, float startx, float starty, float dx, float dy)
 {
 
     float distance = sqrt(dx * dx + dy * dy);   /* length of line segment (pythagoras) */
@@ -43,7 +43,7 @@
         x += dx_prime;
         y += dy_prime;
         /* draw brush blot */
-        SDL_RenderCopy(brush, NULL, &dstRect);
+        SDL_RenderCopy(renderer, brush, NULL, &dstRect);
     }
 }
 
@@ -51,7 +51,7 @@
 	loads the brush texture
 */
 void
-initializeTexture()
+initializeTexture(SDL_Renderer *renderer)
 {
     SDL_Surface *bmp_surface;
     bmp_surface = SDL_LoadBMP("stroke.bmp");
@@ -59,7 +59,7 @@
         fatalError("could not load stroke.bmp");
     }
     brush =
-        SDL_CreateTextureFromSurface(SDL_PIXELFORMAT_ABGR8888, bmp_surface);
+        SDL_CreateTextureFromSurface(renderer, bmp_surface);
     SDL_FreeSurface(bmp_surface);
     if (brush == 0) {
         fatalError("could not create brush texture");
@@ -78,6 +78,7 @@
     Uint8 state;                /* mouse (touch) state */
     SDL_Event event;
     SDL_Window *window;         /* main window */
+	SDL_Renderer *renderer;
     int done;                   /* does user want to quit? */
 
     /* initialize SDL */
@@ -89,15 +90,15 @@
     window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
                                 SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN |
                                 SDL_WINDOW_BORDERLESS);
-    SDL_CreateRenderer(window, 0, 0);
+    renderer = SDL_CreateRenderer(window, 0, 0);
 
     /*load brush texture */
-    initializeTexture();
+    initializeTexture(renderer);
 
     /* fill canvass initially with all black */
-    SDL_SetRenderDrawColor(0, 0, 0, 255);
-    SDL_RenderFill(NULL);
-    SDL_RenderPresent();
+    SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
+    SDL_RenderClear();
+    SDL_RenderPresent(renderer);
 
     done = 0;
     while (!done && SDL_WaitEvent(&event)) {
@@ -109,8 +110,8 @@
             state = SDL_GetMouseState(&x, &y);  /* get its location */
             SDL_GetRelativeMouseState(&dx, &dy);        /* find how much the mouse moved */
             if (state & SDL_BUTTON_LMASK) {     /* is the mouse (touch) down? */
-                drawLine(x - dx, y - dy, dx, dy);       /* draw line segment */
-                SDL_RenderPresent();
+                drawLine(renderer, x - dx, y - dy, dx, dy);       /* draw line segment */
+                SDL_RenderPresent(renderer);
             }
             break;
         }
--- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Tue Feb 01 00:37:02 2011 -0800
+++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Sun Feb 06 21:23:32 2011 -0800
@@ -74,34 +74,34 @@
 		0098A5631195B4D900343137 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5621195B4D900343137 /* OpenGLES.framework */; };
 		0098A5651195B4D900343137 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5641195B4D900343137 /* UIKit.framework */; };
 		0098A5851195B5E200343137 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5841195B5E200343137 /* QuartzCore.framework */; };
+		0402A85812FE70C600CECEE3 /* SDL_render_gles2.c in Sources */ = {isa = PBXBuildFile; fileRef = 0402A85512FE70C600CECEE3 /* SDL_render_gles2.c */; };
+		0402A85912FE70C600CECEE3 /* SDL_shaders_gles2.c in Sources */ = {isa = PBXBuildFile; fileRef = 0402A85612FE70C600CECEE3 /* SDL_shaders_gles2.c */; };
+		0402A85A12FE70C600CECEE3 /* SDL_shaders_gles2.h in Headers */ = {isa = PBXBuildFile; fileRef = 0402A85712FE70C600CECEE3 /* SDL_shaders_gles2.h */; };
+		04043B8D12FEA9350076DB1F /* SDL_opengles2.h in Headers */ = {isa = PBXBuildFile; fileRef = 04043B8C12FEA9350076DB1F /* SDL_opengles2.h */; };
+		041B2CD912FA0E9E0087D585 /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2CD812FA0E9E0087D585 /* SDL_render.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		041B2CF112FA0F680087D585 /* SDL_render.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2CEA12FA0F680087D585 /* SDL_render.c */; };
+		041B2CF212FA0F680087D585 /* SDL_sysrender.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2CEB12FA0F680087D585 /* SDL_sysrender.h */; };
 		0420497011E6F03D007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */; };
 		0420497111E6F03D007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */; };
-		043DD76F10FD8A0000DED673 /* SDL_alphamult.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76B10FD8A0000DED673 /* SDL_alphamult.c */; };
-		043DD77010FD8A0000DED673 /* SDL_alphamult.h in Headers */ = {isa = PBXBuildFile; fileRef = 043DD76C10FD8A0000DED673 /* SDL_alphamult.h */; };
-		043DD77110FD8A0000DED673 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */; };
-		043DD77210FD8A0000DED673 /* SDL_drawrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76E10FD8A0000DED673 /* SDL_drawrect.c */; };
+		04409BA612FA989600FB9AA8 /* mmx.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409BA212FA989600FB9AA8 /* mmx.h */; };
+		04409BA712FA989600FB9AA8 /* SDL_yuv_mmx.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409BA312FA989600FB9AA8 /* SDL_yuv_mmx.c */; };
+		04409BA812FA989600FB9AA8 /* SDL_yuv_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409BA412FA989600FB9AA8 /* SDL_yuv_sw_c.h */; };
+		04409BA912FA989600FB9AA8 /* SDL_yuv_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409BA512FA989600FB9AA8 /* SDL_yuv_sw.c */; };
+		0442EC4B12FE1BFF004C9285 /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = 0442EC4A12FE1BFF004C9285 /* SDL_hints.h */; };
+		0442EC5012FE1C1E004C9285 /* SDL_render_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0442EC4E12FE1C1E004C9285 /* SDL_render_sw_c.h */; };
+		0442EC5112FE1C1E004C9285 /* SDL_render_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC4F12FE1C1E004C9285 /* SDL_render_sw.c */; };
+		0442EC5312FE1C28004C9285 /* SDL_render_gles.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC5212FE1C28004C9285 /* SDL_render_gles.c */; };
+		0442EC5512FE1C3F004C9285 /* SDL_hints.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC5412FE1C3F004C9285 /* SDL_hints.c */; };
 		04461DEE0EA76BA3006C462D /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = 04461DED0EA76BA3006C462D /* SDL_haptic.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		044E5FB511E6069F0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB311E6069F0076F181 /* SDL_clipboard.h */; };
-		044E5FB611E6069F0076F181 /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB411E6069F0076F181 /* SDL_input.h */; };
+		044E5FB511E6069F0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB311E6069F0076F181 /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		044E5FB611E6069F0076F181 /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB411E6069F0076F181 /* SDL_input.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		044E5FB811E606EB0076F181 /* SDL_clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 044E5FB711E606EB0076F181 /* SDL_clipboard.c */; };
-		0463873F0F0B5B7D0041FD65 /* SDL_blendline.c in Sources */ = {isa = PBXBuildFile; fileRef = 046387370F0B5B7D0041FD65 /* SDL_blendline.c */; };
-		046387400F0B5B7D0041FD65 /* SDL_blendpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 046387380F0B5B7D0041FD65 /* SDL_blendpoint.c */; };
-		046387410F0B5B7D0041FD65 /* SDL_blendrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 046387390F0B5B7D0041FD65 /* SDL_blendrect.c */; };
 		046387420F0B5B7D0041FD65 /* SDL_blit_slow.h in Headers */ = {isa = PBXBuildFile; fileRef = 0463873A0F0B5B7D0041FD65 /* SDL_blit_slow.h */; };
-		046387430F0B5B7D0041FD65 /* SDL_draw.h in Headers */ = {isa = PBXBuildFile; fileRef = 0463873B0F0B5B7D0041FD65 /* SDL_draw.h */; };
-		046387440F0B5B7D0041FD65 /* SDL_drawline.c in Sources */ = {isa = PBXBuildFile; fileRef = 0463873C0F0B5B7D0041FD65 /* SDL_drawline.c */; };
-		046387450F0B5B7D0041FD65 /* SDL_drawpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 0463873D0F0B5B7D0041FD65 /* SDL_drawpoint.c */; };
 		046387460F0B5B7D0041FD65 /* SDL_fillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 0463873E0F0B5B7D0041FD65 /* SDL_fillrect.c */; };
 		047677BB0EA76A31008ABAF1 /* SDL_syshaptic.c in Sources */ = {isa = PBXBuildFile; fileRef = 047677B80EA76A31008ABAF1 /* SDL_syshaptic.c */; };
 		047677BC0EA76A31008ABAF1 /* SDL_haptic.c in Sources */ = {isa = PBXBuildFile; fileRef = 047677B90EA76A31008ABAF1 /* SDL_haptic.c */; };
 		047677BD0EA76A31008ABAF1 /* SDL_syshaptic.h in Headers */ = {isa = PBXBuildFile; fileRef = 047677BA0EA76A31008ABAF1 /* SDL_syshaptic.h */; };
 		047AF1B30EA98D6C00811173 /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = 047AF1B20EA98D6C00811173 /* SDL_sysloadso.c */; };
-		0495E68A0E97408800152DFE /* SDL_glesfuncs.h in Headers */ = {isa = PBXBuildFile; fileRef = 0495E6840E97408800152DFE /* SDL_glesfuncs.h */; };
-		0495E68B0E97408800152DFE /* SDL_glfuncs.h in Headers */ = {isa = PBXBuildFile; fileRef = 0495E6850E97408800152DFE /* SDL_glfuncs.h */; };
-		0495E68C0E97408800152DFE /* SDL_renderer_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 0495E6860E97408800152DFE /* SDL_renderer_gl.c */; };
-		0495E68D0E97408800152DFE /* SDL_renderer_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0495E6870E97408800152DFE /* SDL_renderer_gl.h */; };
-		0495E68E0E97408800152DFE /* SDL_renderer_gles.c in Sources */ = {isa = PBXBuildFile; fileRef = 0495E6880E97408800152DFE /* SDL_renderer_gles.c */; };
-		0495E68F0E97408800152DFE /* SDL_renderer_gles.h in Headers */ = {isa = PBXBuildFile; fileRef = 0495E6890E97408800152DFE /* SDL_renderer_gles.h */; };
 		04B2ECEC1025CE4800F9BC5F /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = 04B2ECE61025CE4800F9BC5F /* SDL_atomic.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		04B2ECED1025CE4800F9BC5F /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = 04B2ECE71025CE4800F9BC5F /* SDL_power.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		04B2ECEE1025CE4800F9BC5F /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = 04B2ECE81025CE4800F9BC5F /* SDL_revision.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -110,16 +110,28 @@
 		04BA9D6411EF474A00B60E01 /* SDL_gesture.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BA9D6011EF474A00B60E01 /* SDL_gesture.c */; };
 		04BA9D6511EF474A00B60E01 /* SDL_touch_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D6111EF474A00B60E01 /* SDL_touch_c.h */; };
 		04BA9D6611EF474A00B60E01 /* SDL_touch.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BA9D6211EF474A00B60E01 /* SDL_touch.c */; };
-		04BA9D7D11EF497E00B60E01 /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D7B11EF497E00B60E01 /* SDL_gesture.h */; };
-		04BA9D7E11EF497E00B60E01 /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D7C11EF497E00B60E01 /* SDL_touch.h */; };
-		04EC8B521025D12900431D42 /* SDL_config_iphoneos.h in Headers */ = {isa = PBXBuildFile; fileRef = 04EC8B501025D12900431D42 /* SDL_config_iphoneos.h */; };
-		04F2AF541104ABC300D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF531104ABC300D6DDF7 /* SDL_assert.h */; };
+		04BA9D7D11EF497E00B60E01 /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D7B11EF497E00B60E01 /* SDL_gesture.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		04BA9D7E11EF497E00B60E01 /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D7C11EF497E00B60E01 /* SDL_touch.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		04EC8B521025D12900431D42 /* SDL_config_iphoneos.h in Headers */ = {isa = PBXBuildFile; fileRef = 04EC8B501025D12900431D42 /* SDL_config_iphoneos.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		04F2AF541104ABC300D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF531104ABC300D6DDF7 /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		04F2AF561104ABD200D6DDF7 /* SDL_assert.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F2AF551104ABD200D6DDF7 /* SDL_assert.c */; };
+		04F7807612FB751400FC43C0 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7806A12FB751400FC43C0 /* SDL_blendfillrect.c */; };
+		04F7807712FB751400FC43C0 /* SDL_blendfillrect.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7806B12FB751400FC43C0 /* SDL_blendfillrect.h */; };
+		04F7807812FB751400FC43C0 /* SDL_blendline.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7806C12FB751400FC43C0 /* SDL_blendline.c */; };
+		04F7807912FB751400FC43C0 /* SDL_blendline.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7806D12FB751400FC43C0 /* SDL_blendline.h */; };
+		04F7807A12FB751400FC43C0 /* SDL_blendpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7806E12FB751400FC43C0 /* SDL_blendpoint.c */; };
+		04F7807B12FB751400FC43C0 /* SDL_blendpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7806F12FB751400FC43C0 /* SDL_blendpoint.h */; };
+		04F7807C12FB751400FC43C0 /* SDL_draw.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7807012FB751400FC43C0 /* SDL_draw.h */; };
+		04F7807D12FB751400FC43C0 /* SDL_drawline.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7807112FB751400FC43C0 /* SDL_drawline.c */; };
+		04F7807E12FB751400FC43C0 /* SDL_drawline.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7807212FB751400FC43C0 /* SDL_drawline.h */; };
+		04F7807F12FB751400FC43C0 /* SDL_drawpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7807312FB751400FC43C0 /* SDL_drawpoint.c */; };
+		04F7808012FB751400FC43C0 /* SDL_drawpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7807412FB751400FC43C0 /* SDL_drawpoint.h */; };
+		04F7808412FB753F00FC43C0 /* SDL_nullframebuffer_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7808212FB753F00FC43C0 /* SDL_nullframebuffer_c.h */; };
+		04F7808512FB753F00FC43C0 /* SDL_nullframebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7808312FB753F00FC43C0 /* SDL_nullframebuffer.c */; };
 		04FFAB8B12E23B8D00BA343D /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8912E23B8D00BA343D /* SDL_atomic.c */; };
 		04FFAB8C12E23B8D00BA343D /* SDL_spinlock.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */; };
-		04FFAB9612E23BDC00BA343D /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */; };
-		04FFAB9712E23BDC00BA343D /* SDL_scalemode.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9412E23BDC00BA343D /* SDL_scalemode.h */; };
-		04FFAB9812E23BDC00BA343D /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9512E23BDC00BA343D /* SDL_shape.h */; };
+		04FFAB9612E23BDC00BA343D /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		04FFAB9812E23BDC00BA343D /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9512E23BDC00BA343D /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		56ED04E1118A8EE200A56AA6 /* SDL_power.c in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E0118A8EE200A56AA6 /* SDL_power.c */; };
 		56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */; };
 		FD24846D0E5655AE0021E198 /* SDL_uikitkeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = FD24846B0E5655AE0021E198 /* SDL_uikitkeyboard.h */; };
@@ -210,7 +222,6 @@
 		FD689F270E26E5D900F90B21 /* SDL_uikitopenglview.m in Sources */ = {isa = PBXBuildFile; fileRef = FD689F170E26E5D900F90B21 /* SDL_uikitopenglview.m */; };
 		FD689FCE0E26E9D400F90B21 /* SDL_uikitappdelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FD689FCC0E26E9D400F90B21 /* SDL_uikitappdelegate.m */; };
 		FD689FCF0E26E9D400F90B21 /* SDL_uikitappdelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = FD689FCD0E26E9D400F90B21 /* SDL_uikitappdelegate.h */; };
-		FD6C83B60DEA66E500ABEE55 /* SDL_systimer.h in Headers */ = {isa = PBXBuildFile; fileRef = FD99BA2D0DD52EDC00FB1D6B /* SDL_systimer.h */; };
 		FD8BD7AC0E27DCA400B52CD5 /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = FD8BD7AB0E27DCA400B52CD5 /* SDL_opengles.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		FD8BD8250E27E25900B52CD5 /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = FD8BD8190E27E25900B52CD5 /* SDL_sysloadso.c */; };
 		FDA6844D0DF2374E00F98A1A /* SDL_blit.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA683000DF2374E00F98A1A /* SDL_blit.c */; };
@@ -230,22 +241,14 @@
 		FDA6845C0DF2374E00F98A1A /* SDL_pixels.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA6830F0DF2374E00F98A1A /* SDL_pixels.c */; };
 		FDA6845D0DF2374E00F98A1A /* SDL_pixels_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA683100DF2374E00F98A1A /* SDL_pixels_c.h */; };
 		FDA6845E0DF2374E00F98A1A /* SDL_rect.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA683110DF2374E00F98A1A /* SDL_rect.c */; };
-		FDA6845F0DF2374E00F98A1A /* SDL_rect_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA683120DF2374E00F98A1A /* SDL_rect_c.h */; };
-		FDA684600DF2374E00F98A1A /* SDL_renderer_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA683130DF2374E00F98A1A /* SDL_renderer_sw.c */; };
-		FDA684610DF2374E00F98A1A /* SDL_renderer_sw.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA683140DF2374E00F98A1A /* SDL_renderer_sw.h */; };
 		FDA684620DF2374E00F98A1A /* SDL_RLEaccel.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA683150DF2374E00F98A1A /* SDL_RLEaccel.c */; };
 		FDA684630DF2374E00F98A1A /* SDL_RLEaccel_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA683160DF2374E00F98A1A /* SDL_RLEaccel_c.h */; };
 		FDA684640DF2374E00F98A1A /* SDL_stretch.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA683170DF2374E00F98A1A /* SDL_stretch.c */; };
 		FDA684660DF2374E00F98A1A /* SDL_surface.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA683190DF2374E00F98A1A /* SDL_surface.c */; };
 		FDA684670DF2374E00F98A1A /* SDL_sysvideo.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA6831A0DF2374E00F98A1A /* SDL_sysvideo.h */; };
 		FDA684680DF2374E00F98A1A /* SDL_video.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA6831B0DF2374E00F98A1A /* SDL_video.c */; };
-		FDA684690DF2374E00F98A1A /* SDL_yuv_mmx.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA6831C0DF2374E00F98A1A /* SDL_yuv_mmx.c */; };
-		FDA6846A0DF2374E00F98A1A /* SDL_yuv_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA6831D0DF2374E00F98A1A /* SDL_yuv_sw.c */; };
-		FDA6846B0DF2374E00F98A1A /* SDL_yuv_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA6831E0DF2374E00F98A1A /* SDL_yuv_sw_c.h */; };
 		FDA685FB0DF244C800F98A1A /* SDL_nullevents.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA685F50DF244C800F98A1A /* SDL_nullevents.c */; };
 		FDA685FC0DF244C800F98A1A /* SDL_nullevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA685F60DF244C800F98A1A /* SDL_nullevents_c.h */; };
-		FDA685FD0DF244C800F98A1A /* SDL_nullrender.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA685F70DF244C800F98A1A /* SDL_nullrender.c */; };
-		FDA685FE0DF244C800F98A1A /* SDL_nullrender_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA685F80DF244C800F98A1A /* SDL_nullrender_c.h */; };
 		FDA685FF0DF244C800F98A1A /* SDL_nullvideo.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA685F90DF244C800F98A1A /* SDL_nullvideo.c */; };
 		FDA686000DF244C800F98A1A /* SDL_nullvideo.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA685FA0DF244C800F98A1A /* SDL_nullvideo.h */; };
 		FDC656480E560DF800311C8E /* jumphack.c in Sources */ = {isa = PBXBuildFile; fileRef = FDC656440E560DF800311C8E /* jumphack.c */; };
@@ -342,34 +345,34 @@
 		0098A5621195B4D900343137 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
 		0098A5641195B4D900343137 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
 		0098A5841195B5E200343137 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+		0402A85512FE70C600CECEE3 /* SDL_render_gles2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render_gles2.c; sourceTree = "<group>"; };
+		0402A85612FE70C600CECEE3 /* SDL_shaders_gles2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_shaders_gles2.c; sourceTree = "<group>"; };
+		0402A85712FE70C600CECEE3 /* SDL_shaders_gles2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_shaders_gles2.h; sourceTree = "<group>"; };
+		04043B8C12FEA9350076DB1F /* SDL_opengles2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_opengles2.h; path = ../../include/SDL_opengles2.h; sourceTree = SOURCE_ROOT; };
+		041B2CD812FA0E9E0087D585 /* SDL_render.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_render.h; path = ../../include/SDL_render.h; sourceTree = SOURCE_ROOT; };
+		041B2CEA12FA0F680087D585 /* SDL_render.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render.c; sourceTree = "<group>"; };
+		041B2CEB12FA0F680087D585 /* SDL_sysrender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysrender.h; sourceTree = "<group>"; };
 		0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_clipboardevents_c.h; sourceTree = "<group>"; };
 		0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = "<group>"; };
-		043DD76B10FD8A0000DED673 /* SDL_alphamult.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_alphamult.c; sourceTree = "<group>"; };
-		043DD76C10FD8A0000DED673 /* SDL_alphamult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_alphamult.h; sourceTree = "<group>"; };
-		043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = "<group>"; };
-		043DD76E10FD8A0000DED673 /* SDL_drawrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawrect.c; sourceTree = "<group>"; };
+		04409BA212FA989600FB9AA8 /* mmx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mmx.h; sourceTree = "<group>"; };
+		04409BA312FA989600FB9AA8 /* SDL_yuv_mmx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_mmx.c; sourceTree = "<group>"; };
+		04409BA412FA989600FB9AA8 /* SDL_yuv_sw_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_yuv_sw_c.h; sourceTree = "<group>"; };
+		04409BA512FA989600FB9AA8 /* SDL_yuv_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_sw.c; sourceTree = "<group>"; };
+		0442EC4A12FE1BFF004C9285 /* SDL_hints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_hints.h; path = ../../include/SDL_hints.h; sourceTree = SOURCE_ROOT; };
+		0442EC4E12FE1C1E004C9285 /* SDL_render_sw_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_render_sw_c.h; sourceTree = "<group>"; };
+		0442EC4F12FE1C1E004C9285 /* SDL_render_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render_sw.c; sourceTree = "<group>"; };
+		0442EC5212FE1C28004C9285 /* SDL_render_gles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render_gles.c; sourceTree = "<group>"; };
+		0442EC5412FE1C3F004C9285 /* SDL_hints.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_hints.c; path = ../../src/SDL_hints.c; sourceTree = SOURCE_ROOT; };
 		04461DED0EA76BA3006C462D /* SDL_haptic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_haptic.h; path = ../../include/SDL_haptic.h; sourceTree = SOURCE_ROOT; };
 		044E5FB311E6069F0076F181 /* SDL_clipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_clipboard.h; path = ../../include/SDL_clipboard.h; sourceTree = SOURCE_ROOT; };
 		044E5FB411E6069F0076F181 /* SDL_input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_input.h; path = ../../include/SDL_input.h; sourceTree = SOURCE_ROOT; };
 		044E5FB711E606EB0076F181 /* SDL_clipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboard.c; sourceTree = "<group>"; };
-		046387370F0B5B7D0041FD65 /* SDL_blendline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendline.c; sourceTree = "<group>"; };
-		046387380F0B5B7D0041FD65 /* SDL_blendpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendpoint.c; sourceTree = "<group>"; };
-		046387390F0B5B7D0041FD65 /* SDL_blendrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendrect.c; sourceTree = "<group>"; };
 		0463873A0F0B5B7D0041FD65 /* SDL_blit_slow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blit_slow.h; sourceTree = "<group>"; };
-		0463873B0F0B5B7D0041FD65 /* SDL_draw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_draw.h; sourceTree = "<group>"; };
-		0463873C0F0B5B7D0041FD65 /* SDL_drawline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawline.c; sourceTree = "<group>"; };
-		0463873D0F0B5B7D0041FD65 /* SDL_drawpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawpoint.c; sourceTree = "<group>"; };
 		0463873E0F0B5B7D0041FD65 /* SDL_fillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_fillrect.c; sourceTree = "<group>"; };
 		047677B80EA76A31008ABAF1 /* SDL_syshaptic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_syshaptic.c; sourceTree = "<group>"; };
 		047677B90EA76A31008ABAF1 /* SDL_haptic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_haptic.c; path = ../../src/haptic/SDL_haptic.c; sourceTree = SOURCE_ROOT; };
 		047677BA0EA76A31008ABAF1 /* SDL_syshaptic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_syshaptic.h; path = ../../src/haptic/SDL_syshaptic.h; sourceTree = SOURCE_ROOT; };
 		047AF1B20EA98D6C00811173 /* SDL_sysloadso.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_sysloadso.c; sourceTree = "<group>"; };
-		0495E6840E97408800152DFE /* SDL_glesfuncs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_glesfuncs.h; sourceTree = "<group>"; };
-		0495E6850E97408800152DFE /* SDL_glfuncs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_glfuncs.h; sourceTree = "<group>"; };
-		0495E6860E97408800152DFE /* SDL_renderer_gl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_gl.c; sourceTree = "<group>"; };
-		0495E6870E97408800152DFE /* SDL_renderer_gl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_gl.h; sourceTree = "<group>"; };
-		0495E6880E97408800152DFE /* SDL_renderer_gles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_gles.c; sourceTree = "<group>"; };
-		0495E6890E97408800152DFE /* SDL_renderer_gles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_gles.h; sourceTree = "<group>"; };
 		04B2ECE61025CE4800F9BC5F /* SDL_atomic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_atomic.h; path = ../../include/SDL_atomic.h; sourceTree = SOURCE_ROOT; };
 		04B2ECE71025CE4800F9BC5F /* SDL_power.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_power.h; path = ../../include/SDL_power.h; sourceTree = SOURCE_ROOT; };
 		04B2ECE81025CE4800F9BC5F /* SDL_revision.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_revision.h; path = ../../include/SDL_revision.h; sourceTree = SOURCE_ROOT; };
@@ -383,10 +386,22 @@
 		04EC8B501025D12900431D42 /* SDL_config_iphoneos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_config_iphoneos.h; path = ../../include/SDL_config_iphoneos.h; sourceTree = SOURCE_ROOT; };
 		04F2AF531104ABC300D6DDF7 /* SDL_assert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_assert.h; path = ../../include/SDL_assert.h; sourceTree = SOURCE_ROOT; };
 		04F2AF551104ABD200D6DDF7 /* SDL_assert.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_assert.c; path = ../../src/SDL_assert.c; sourceTree = SOURCE_ROOT; };
+		04F7806A12FB751400FC43C0 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = "<group>"; };
+		04F7806B12FB751400FC43C0 /* SDL_blendfillrect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blendfillrect.h; sourceTree = "<group>"; };
+		04F7806C12FB751400FC43C0 /* SDL_blendline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendline.c; sourceTree = "<group>"; };
+		04F7806D12FB751400FC43C0 /* SDL_blendline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blendline.h; sourceTree = "<group>"; };
+		04F7806E12FB751400FC43C0 /* SDL_blendpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendpoint.c; sourceTree = "<group>"; };
+		04F7806F12FB751400FC43C0 /* SDL_blendpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blendpoint.h; sourceTree = "<group>"; };
+		04F7807012FB751400FC43C0 /* SDL_draw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_draw.h; sourceTree = "<group>"; };
+		04F7807112FB751400FC43C0 /* SDL_drawline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawline.c; sourceTree = "<group>"; };
+		04F7807212FB751400FC43C0 /* SDL_drawline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_drawline.h; sourceTree = "<group>"; };
+		04F7807312FB751400FC43C0 /* SDL_drawpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawpoint.c; sourceTree = "<group>"; };
+		04F7807412FB751400FC43C0 /* SDL_drawpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_drawpoint.h; sourceTree = "<group>"; };
+		04F7808212FB753F00FC43C0 /* SDL_nullframebuffer_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullframebuffer_c.h; sourceTree = "<group>"; };
+		04F7808312FB753F00FC43C0 /* SDL_nullframebuffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullframebuffer.c; sourceTree = "<group>"; };
 		04FFAB8912E23B8D00BA343D /* SDL_atomic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_atomic.c; sourceTree = "<group>"; };
 		04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_spinlock.c; sourceTree = "<group>"; };
 		04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_blendmode.h; path = ../../include/SDL_blendmode.h; sourceTree = SOURCE_ROOT; };
-		04FFAB9412E23BDC00BA343D /* SDL_scalemode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_scalemode.h; path = ../../include/SDL_scalemode.h; sourceTree = SOURCE_ROOT; };
 		04FFAB9512E23BDC00BA343D /* SDL_shape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_shape.h; path = ../../include/SDL_shape.h; sourceTree = SOURCE_ROOT; };
 		56ED04E0118A8EE200A56AA6 /* SDL_power.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_power.c; path = ../../src/power/SDL_power.c; sourceTree = SOURCE_ROOT; };
 		56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_syspower.m; path = ../../src/power/uikit/SDL_syspower.m; sourceTree = SOURCE_ROOT; };
@@ -477,7 +492,6 @@
 		FD99B98E0DD52EDC00FB1D6B /* default_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = default_cursor.h; sourceTree = "<group>"; };
 		FD99B98F0DD52EDC00FB1D6B /* scancodes_darwin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_darwin.h; sourceTree = "<group>"; };
 		FD99B9900DD52EDC00FB1D6B /* scancodes_linux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_linux.h; sourceTree = "<group>"; };
-		FD99B9910DD52EDC00FB1D6B /* scancodes_win32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_win32.h; sourceTree = "<group>"; };
 		FD99B9920DD52EDC00FB1D6B /* scancodes_xfree86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_xfree86.h; sourceTree = "<group>"; };
 		FD99B9930DD52EDC00FB1D6B /* SDL_events.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_events.c; sourceTree = "<group>"; };
 		FD99B9940DD52EDC00FB1D6B /* SDL_events_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_events_c.h; sourceTree = "<group>"; };
@@ -505,7 +519,6 @@
 		FD99BA140DD52EDC00FB1D6B /* SDL_systhread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_systhread.h; sourceTree = "<group>"; };
 		FD99BA150DD52EDC00FB1D6B /* SDL_thread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_thread.c; sourceTree = "<group>"; };
 		FD99BA160DD52EDC00FB1D6B /* SDL_thread_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_thread_c.h; sourceTree = "<group>"; };
-		FD99BA2D0DD52EDC00FB1D6B /* SDL_systimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_systimer.h; sourceTree = "<group>"; };
 		FD99BA2E0DD52EDC00FB1D6B /* SDL_timer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_timer.c; sourceTree = "<group>"; };
 		FD99BA2F0DD52EDC00FB1D6B /* SDL_timer_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_timer_c.h; sourceTree = "<group>"; };
 		FD99BA310DD52EDC00FB1D6B /* SDL_systimer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_systimer.c; sourceTree = "<group>"; };
@@ -526,22 +539,14 @@
 		FDA6830F0DF2374E00F98A1A /* SDL_pixels.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_pixels.c; sourceTree = "<group>"; };
 		FDA683100DF2374E00F98A1A /* SDL_pixels_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_pixels_c.h; sourceTree = "<group>"; };
 		FDA683110DF2374E00F98A1A /* SDL_rect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rect.c; sourceTree = "<group>"; };
-		FDA683120DF2374E00F98A1A /* SDL_rect_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_rect_c.h; sourceTree = "<group>"; };
-		FDA683130DF2374E00F98A1A /* SDL_renderer_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_sw.c; sourceTree = "<group>"; };
-		FDA683140DF2374E00F98A1A /* SDL_renderer_sw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_sw.h; sourceTree = "<group>"; };
 		FDA683150DF2374E00F98A1A /* SDL_RLEaccel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_RLEaccel.c; sourceTree = "<group>"; };
 		FDA683160DF2374E00F98A1A /* SDL_RLEaccel_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_RLEaccel_c.h; sourceTree = "<group>"; };
 		FDA683170DF2374E00F98A1A /* SDL_stretch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_stretch.c; sourceTree = "<group>"; };
 		FDA683190DF2374E00F98A1A /* SDL_surface.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_surface.c; sourceTree = "<group>"; };
 		FDA6831A0DF2374E00F98A1A /* SDL_sysvideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysvideo.h; sourceTree = "<group>"; };
 		FDA6831B0DF2374E00F98A1A /* SDL_video.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_video.c; sourceTree = "<group>"; };
-		FDA6831C0DF2374E00F98A1A /* SDL_yuv_mmx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_mmx.c; sourceTree = "<group>"; };
-		FDA6831D0DF2374E00F98A1A /* SDL_yuv_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_sw.c; sourceTree = "<group>"; };
-		FDA6831E0DF2374E00F98A1A /* SDL_yuv_sw_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_yuv_sw_c.h; sourceTree = "<group>"; };
 		FDA685F50DF244C800F98A1A /* SDL_nullevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullevents.c; sourceTree = "<group>"; };
 		FDA685F60DF244C800F98A1A /* SDL_nullevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullevents_c.h; sourceTree = "<group>"; };
-		FDA685F70DF244C800F98A1A /* SDL_nullrender.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullrender.c; sourceTree = "<group>"; };
-		FDA685F80DF244C800F98A1A /* SDL_nullrender_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullrender_c.h; sourceTree = "<group>"; };
 		FDA685F90DF244C800F98A1A /* SDL_nullvideo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullvideo.c; sourceTree = "<group>"; };
 		FDA685FA0DF244C800F98A1A /* SDL_nullvideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullvideo.h; sourceTree = "<group>"; };
 		FDC261780E3A3FC8001C4554 /* keyinfotable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keyinfotable.h; sourceTree = "<group>"; };
@@ -687,6 +692,61 @@
 			path = cocoa;
 			sourceTree = "<group>";
 		};
+		0402A85412FE70C600CECEE3 /* opengles2 */ = {
+			isa = PBXGroup;
+			children = (
+				0402A85512FE70C600CECEE3 /* SDL_render_gles2.c */,
+				0402A85612FE70C600CECEE3 /* SDL_shaders_gles2.c */,
+				0402A85712FE70C600CECEE3 /* SDL_shaders_gles2.h */,
+			);
+			path = opengles2;
+			sourceTree = "<group>";
+		};
+		041B2CE312FA0F680087D585 /* render */ = {
+			isa = PBXGroup;
+			children = (
+				041B2CE812FA0F680087D585 /* opengles */,
+				0402A85412FE70C600CECEE3 /* opengles2 */,
+				041B2CEC12FA0F680087D585 /* software */,
+				04409BA212FA989600FB9AA8 /* mmx.h */,
+				041B2CEA12FA0F680087D585 /* SDL_render.c */,
+				041B2CEB12FA0F680087D585 /* SDL_sysrender.h */,
+				04409BA312FA989600FB9AA8 /* SDL_yuv_mmx.c */,
+				04409BA412FA989600FB9AA8 /* SDL_yuv_sw_c.h */,
+				04409BA512FA989600FB9AA8 /* SDL_yuv_sw.c */,
+			);
+			name = render;
+			path = ../../src/render;
+			sourceTree = SOURCE_ROOT;
+		};
+		041B2CE812FA0F680087D585 /* opengles */ = {
+			isa = PBXGroup;
+			children = (
+				0442EC5212FE1C28004C9285 /* SDL_render_gles.c */,
+			);
+			path = opengles;
+			sourceTree = "<group>";
+		};
+		041B2CEC12FA0F680087D585 /* software */ = {
+			isa = PBXGroup;
+			children = (
+				04F7806A12FB751400FC43C0 /* SDL_blendfillrect.c */,
+				04F7806B12FB751400FC43C0 /* SDL_blendfillrect.h */,
+				04F7806C12FB751400FC43C0 /* SDL_blendline.c */,
+				04F7806D12FB751400FC43C0 /* SDL_blendline.h */,
+				04F7806E12FB751400FC43C0 /* SDL_blendpoint.c */,
+				04F7806F12FB751400FC43C0 /* SDL_blendpoint.h */,
+				04F7807012FB751400FC43C0 /* SDL_draw.h */,
+				04F7807112FB751400FC43C0 /* SDL_drawline.c */,
+				04F7807212FB751400FC43C0 /* SDL_drawline.h */,
+				04F7807312FB751400FC43C0 /* SDL_drawpoint.c */,
+				04F7807412FB751400FC43C0 /* SDL_drawpoint.h */,
+				0442EC4E12FE1C1E004C9285 /* SDL_render_sw_c.h */,
+				0442EC4F12FE1C1E004C9285 /* SDL_render_sw.c */,
+			);
+			path = software;
+			sourceTree = "<group>";
+		};
 		047677B60EA769DF008ABAF1 /* haptic */ = {
 			isa = PBXGroup;
 			children = (
@@ -868,15 +928,13 @@
 		FD99B8BC0DD52E5C00FB1D6B /* Public Headers */ = {
 			isa = PBXGroup;
 			children = (
-				04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */,
-				04FFAB9412E23BDC00BA343D /* SDL_scalemode.h */,
-				04FFAB9512E23BDC00BA343D /* SDL_shape.h */,
 				FD99B8CC0DD52EB400FB1D6B /* begin_code.h */,
 				FD99B8CD0DD52EB400FB1D6B /* close_code.h */,
 				FD99B8F50DD52EB400FB1D6B /* SDL.h */,
 				04F2AF531104ABC300D6DDF7 /* SDL_assert.h */,
 				04B2ECE61025CE4800F9BC5F /* SDL_atomic.h */,
 				FD99B8CF0DD52EB400FB1D6B /* SDL_audio.h */,
+				04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */,
 				044E5FB311E6069F0076F181 /* SDL_clipboard.h */,
 				FD99B8D10DD52EB400FB1D6B /* SDL_compat.h */,
 				04B2ED061025CF9E00F9BC5F /* SDL_config.h */,
@@ -888,6 +946,7 @@
 				FD99B8DD0DD52EB400FB1D6B /* SDL_events.h */,
 				04BA9D7B11EF497E00B60E01 /* SDL_gesture.h */,
 				04461DED0EA76BA3006C462D /* SDL_haptic.h */,
+				0442EC4A12FE1BFF004C9285 /* SDL_hints.h */,
 				044E5FB411E6069F0076F181 /* SDL_input.h */,
 				FD99B8DE0DD52EB400FB1D6B /* SDL_joystick.h */,
 				FD99B8DF0DD52EB400FB1D6B /* SDL_keyboard.h */,
@@ -899,14 +958,17 @@
 				FD99B8E50DD52EB400FB1D6B /* SDL_name.h */,
 				FD99B8E60DD52EB400FB1D6B /* SDL_opengl.h */,
 				FD8BD7AB0E27DCA400B52CD5 /* SDL_opengles.h */,
+				04043B8C12FEA9350076DB1F /* SDL_opengles2.h */,
 				FD99B8E70DD52EB400FB1D6B /* SDL_pixels.h */,
 				FD99B8E80DD52EB400FB1D6B /* SDL_platform.h */,
 				04B2ECE71025CE4800F9BC5F /* SDL_power.h */,
 				FD99B8E90DD52EB400FB1D6B /* SDL_quit.h */,
 				FD99B8EA0DD52EB400FB1D6B /* SDL_rect.h */,
+				041B2CD812FA0E9E0087D585 /* SDL_render.h */,
 				04B2ECE81025CE4800F9BC5F /* SDL_revision.h */,
 				FD99B8EB0DD52EB400FB1D6B /* SDL_rwops.h */,
 				FD99B8EC0DD52EB400FB1D6B /* SDL_scancode.h */,
+				04FFAB9512E23BDC00BA343D /* SDL_shape.h */,
 				FD99B8ED0DD52EB400FB1D6B /* SDL_stdinc.h */,
 				FD99B8EE0DD52EB400FB1D6B /* SDL_surface.h */,
 				FD99B8EF0DD52EB400FB1D6B /* SDL_syswm.h */,
@@ -923,13 +985,6 @@
 		FD99B8BD0DD52E6D00FB1D6B /* Library Source */ = {
 			isa = PBXGroup;
 			children = (
-				04F2AF551104ABD200D6DDF7 /* SDL_assert.c */,
-				FD99B9D30DD52EDC00FB1D6B /* SDL_compat.c */,
-				FD99B9D40DD52EDC00FB1D6B /* SDL_error_c.h */,
-				FD99B9D50DD52EDC00FB1D6B /* SDL_error.c */,
-				FD99B9D60DD52EDC00FB1D6B /* SDL_fatal.c */,
-				FD99B9D70DD52EDC00FB1D6B /* SDL_fatal.h */,
-				FD99B9D80DD52EDC00FB1D6B /* SDL.c */,
 				04B2ECEF1025CEB900F9BC5F /* atomic */,
 				FD99B8FB0DD52EDC00FB1D6B /* audio */,
 				FD99B98A0DD52EDC00FB1D6B /* cpuinfo */,
@@ -939,10 +994,19 @@
 				FD5F9D080E0E08B3008E885B /* joystick */,
 				FD8BD8150E27E25900B52CD5 /* loadso */,
 				56ED04DE118A8E9A00A56AA6 /* power */,
+				041B2CE312FA0F680087D585 /* render */,
 				FD3F4A6F0DEA620800C5B771 /* stdlib */,
 				FD99B9E00DD52EDC00FB1D6B /* thread */,
 				FD99BA1E0DD52EDC00FB1D6B /* timer */,
 				FDA682420DF2374D00F98A1A /* video */,
+				04F2AF551104ABD200D6DDF7 /* SDL_assert.c */,
+				FD99B9D30DD52EDC00FB1D6B /* SDL_compat.c */,
+				FD99B9D40DD52EDC00FB1D6B /* SDL_error_c.h */,
+				FD99B9D50DD52EDC00FB1D6B /* SDL_error.c */,
+				FD99B9D60DD52EDC00FB1D6B /* SDL_fatal.c */,
+				FD99B9D70DD52EDC00FB1D6B /* SDL_fatal.h */,
+				0442EC5412FE1C3F004C9285 /* SDL_hints.c */,
+				FD99B9D80DD52EDC00FB1D6B /* SDL.c */,
 			);
 			name = "Library Source";
 			sourceTree = "<group>";
@@ -1001,7 +1065,6 @@
 				FD99B98E0DD52EDC00FB1D6B /* default_cursor.h */,
 				FD99B98F0DD52EDC00FB1D6B /* scancodes_darwin.h */,
 				FD99B9900DD52EDC00FB1D6B /* scancodes_linux.h */,
-				FD99B9910DD52EDC00FB1D6B /* scancodes_win32.h */,
 				FD99B9920DD52EDC00FB1D6B /* scancodes_xfree86.h */,
 				0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */,
 				0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */,
@@ -1058,10 +1121,9 @@
 		FD99BA1E0DD52EDC00FB1D6B /* timer */ = {
 			isa = PBXGroup;
 			children = (
-				FD99BA2D0DD52EDC00FB1D6B /* SDL_systimer.h */,
+				FD99BA300DD52EDC00FB1D6B /* unix */,
 				FD99BA2E0DD52EDC00FB1D6B /* SDL_timer.c */,
 				FD99BA2F0DD52EDC00FB1D6B /* SDL_timer_c.h */,
-				FD99BA300DD52EDC00FB1D6B /* unix */,
 			);
 			name = timer;
 			path = ../../src/timer;
@@ -1078,21 +1140,8 @@
 		FDA682420DF2374D00F98A1A /* video */ = {
 			isa = PBXGroup;
 			children = (
-				044E5FB711E606EB0076F181 /* SDL_clipboard.c */,
 				FD689F090E26E5D900F90B21 /* uikit */,
 				FDA685F40DF244C800F98A1A /* dummy */,
-				0495E6850E97408800152DFE /* SDL_glfuncs.h */,
-				0495E6840E97408800152DFE /* SDL_glesfuncs.h */,
-				0495E6860E97408800152DFE /* SDL_renderer_gl.c */,
-				0495E6870E97408800152DFE /* SDL_renderer_gl.h */,
-				0495E6880E97408800152DFE /* SDL_renderer_gles.c */,
-				0495E6890E97408800152DFE /* SDL_renderer_gles.h */,
-				043DD76B10FD8A0000DED673 /* SDL_alphamult.c */,
-				043DD76C10FD8A0000DED673 /* SDL_alphamult.h */,
-				043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */,
-				046387370F0B5B7D0041FD65 /* SDL_blendline.c */,
-				046387380F0B5B7D0041FD65 /* SDL_blendpoint.c */,
-				046387390F0B5B7D0041FD65 /* SDL_blendrect.c */,
 				FDA683000DF2374E00F98A1A /* SDL_blit.c */,
 				FDA683010DF2374E00F98A1A /* SDL_blit.h */,
 				FDA683020DF2374E00F98A1A /* SDL_blit_0.c */,
@@ -1106,28 +1155,19 @@
 				FDA6830A0DF2374E00F98A1A /* SDL_blit_slow.c */,
 				0463873A0F0B5B7D0041FD65 /* SDL_blit_slow.h */,
 				FDA6830B0DF2374E00F98A1A /* SDL_bmp.c */,
-				0463873B0F0B5B7D0041FD65 /* SDL_draw.h */,
-				0463873C0F0B5B7D0041FD65 /* SDL_drawline.c */,
-				0463873D0F0B5B7D0041FD65 /* SDL_drawpoint.c */,
-				043DD76E10FD8A0000DED673 /* SDL_drawrect.c */,
+				044E5FB711E606EB0076F181 /* SDL_clipboard.c */,
 				0463873E0F0B5B7D0041FD65 /* SDL_fillrect.c */,
 				FDA6830D0DF2374E00F98A1A /* SDL_gamma.c */,
 				FDA6830E0DF2374E00F98A1A /* SDL_leaks.h */,
 				FDA6830F0DF2374E00F98A1A /* SDL_pixels.c */,
 				FDA683100DF2374E00F98A1A /* SDL_pixels_c.h */,
 				FDA683110DF2374E00F98A1A /* SDL_rect.c */,
-				FDA683120DF2374E00F98A1A /* SDL_rect_c.h */,
-				FDA683130DF2374E00F98A1A /* SDL_renderer_sw.c */,
-				FDA683140DF2374E00F98A1A /* SDL_renderer_sw.h */,
 				FDA683150DF2374E00F98A1A /* SDL_RLEaccel.c */,
 				FDA683160DF2374E00F98A1A /* SDL_RLEaccel_c.h */,
 				FDA683170DF2374E00F98A1A /* SDL_stretch.c */,
 				FDA683190DF2374E00F98A1A /* SDL_surface.c */,
 				FDA6831A0DF2374E00F98A1A /* SDL_sysvideo.h */,
 				FDA6831B0DF2374E00F98A1A /* SDL_video.c */,
-				FDA6831C0DF2374E00F98A1A /* SDL_yuv_mmx.c */,
-				FDA6831D0DF2374E00F98A1A /* SDL_yuv_sw.c */,
-				FDA6831E0DF2374E00F98A1A /* SDL_yuv_sw_c.h */,
 			);
 			name = video;
 			path = ../../src/video;
@@ -1138,8 +1178,8 @@
 			children = (
 				FDA685F50DF244C800F98A1A /* SDL_nullevents.c */,
 				FDA685F60DF244C800F98A1A /* SDL_nullevents_c.h */,
-				FDA685F70DF244C800F98A1A /* SDL_nullrender.c */,
-				FDA685F80DF244C800F98A1A /* SDL_nullrender_c.h */,
+				04F7808212FB753F00FC43C0 /* SDL_nullframebuffer_c.h */,
+				04F7808312FB753F00FC43C0 /* SDL_nullframebuffer.c */,
 				FDA685F90DF244C800F98A1A /* SDL_nullvideo.c */,
 				FDA685FA0DF244C800F98A1A /* SDL_nullvideo.h */,
 			);
@@ -1153,7 +1193,6 @@
 			isa = PBXHeadersBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				FD6C83B60DEA66E500ABEE55 /* SDL_systimer.h in Headers */,
 				FD3F495C0DEA5B2100C5B771 /* begin_code.h in Headers */,
 				FD3F495D0DEA5B2100C5B771 /* close_code.h in Headers */,
 				FD3F495F0DEA5B2100C5B771 /* SDL_audio.h in Headers */,
@@ -1192,13 +1231,9 @@
 				FDA684550DF2374E00F98A1A /* SDL_blit_copy.h in Headers */,
 				FDA6845B0DF2374E00F98A1A /* SDL_leaks.h in Headers */,
 				FDA6845D0DF2374E00F98A1A /* SDL_pixels_c.h in Headers */,
-				FDA6845F0DF2374E00F98A1A /* SDL_rect_c.h in Headers */,
-				FDA684610DF2374E00F98A1A /* SDL_renderer_sw.h in Headers */,
 				FDA684630DF2374E00F98A1A /* SDL_RLEaccel_c.h in Headers */,
 				FDA684670DF2374E00F98A1A /* SDL_sysvideo.h in Headers */,
-				FDA6846B0DF2374E00F98A1A /* SDL_yuv_sw_c.h in Headers */,
 				FDA685FC0DF244C800F98A1A /* SDL_nullevents_c.h in Headers */,
-				FDA685FE0DF244C800F98A1A /* SDL_nullrender_c.h in Headers */,
 				FDA686000DF244C800F98A1A /* SDL_nullvideo.h in Headers */,
 				FD5F9D300E0E08B3008E885B /* SDL_joystick_c.h in Headers */,
 				FD5F9D310E0E08B3008E885B /* SDL_sysjoystick.h in Headers */,
@@ -1213,20 +1248,14 @@
 				FD8BD7AC0E27DCA400B52CD5 /* SDL_opengles.h in Headers */,
 				FDC656490E560DF800311C8E /* jumphack.h in Headers */,
 				FD24846D0E5655AE0021E198 /* SDL_uikitkeyboard.h in Headers */,
-				0495E68A0E97408800152DFE /* SDL_glesfuncs.h in Headers */,
-				0495E68B0E97408800152DFE /* SDL_glfuncs.h in Headers */,
-				0495E68D0E97408800152DFE /* SDL_renderer_gl.h in Headers */,
-				0495E68F0E97408800152DFE /* SDL_renderer_gles.h in Headers */,
 				047677BD0EA76A31008ABAF1 /* SDL_syshaptic.h in Headers */,
 				04461DEE0EA76BA3006C462D /* SDL_haptic.h in Headers */,
 				046387420F0B5B7D0041FD65 /* SDL_blit_slow.h in Headers */,
-				046387430F0B5B7D0041FD65 /* SDL_draw.h in Headers */,
 				04B2ECEC1025CE4800F9BC5F /* SDL_atomic.h in Headers */,
 				04B2ECED1025CE4800F9BC5F /* SDL_power.h in Headers */,
 				04B2ECEE1025CE4800F9BC5F /* SDL_revision.h in Headers */,
 				04B2ED081025CF9E00F9BC5F /* SDL_config.h in Headers */,
 				04EC8B521025D12900431D42 /* SDL_config_iphoneos.h in Headers */,
-				043DD77010FD8A0000DED673 /* SDL_alphamult.h in Headers */,
 				04F2AF541104ABC300D6DDF7 /* SDL_assert.h in Headers */,
 				006E9888119552DD001DE610 /* SDL_rwopsbundlesupport.h in Headers */,
 				044E5FB511E6069F0076F181 /* SDL_clipboard.h in Headers */,
@@ -1237,8 +1266,22 @@
 				04BA9D7D11EF497E00B60E01 /* SDL_gesture.h in Headers */,
 				04BA9D7E11EF497E00B60E01 /* SDL_touch.h in Headers */,
 				04FFAB9612E23BDC00BA343D /* SDL_blendmode.h in Headers */,
-				04FFAB9712E23BDC00BA343D /* SDL_scalemode.h in Headers */,
 				04FFAB9812E23BDC00BA343D /* SDL_shape.h in Headers */,
+				041B2CD912FA0E9E0087D585 /* SDL_render.h in Headers */,
+				041B2CF212FA0F680087D585 /* SDL_sysrender.h in Headers */,
+				04409BA612FA989600FB9AA8 /* mmx.h in Headers */,
+				04409BA812FA989600FB9AA8 /* SDL_yuv_sw_c.h in Headers */,
+				04F7807712FB751400FC43C0 /* SDL_blendfillrect.h in Headers */,
+				04F7807912FB751400FC43C0 /* SDL_blendline.h in Headers */,
+				04F7807B12FB751400FC43C0 /* SDL_blendpoint.h in Headers */,
+				04F7807C12FB751400FC43C0 /* SDL_draw.h in Headers */,
+				04F7807E12FB751400FC43C0 /* SDL_drawline.h in Headers */,
+				04F7808012FB751400FC43C0 /* SDL_drawpoint.h in Headers */,
+				04F7808412FB753F00FC43C0 /* SDL_nullframebuffer_c.h in Headers */,
+				0442EC4B12FE1BFF004C9285 /* SDL_hints.h in Headers */,
+				0442EC5012FE1C1E004C9285 /* SDL_render_sw_c.h in Headers */,
+				0402A85A12FE70C600CECEE3 /* SDL_shaders_gles2.h in Headers */,
+				04043B8D12FEA9350076DB1F /* SDL_opengles2.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1459,15 +1502,11 @@
 				FDA6845A0DF2374E00F98A1A /* SDL_gamma.c in Sources */,
 				FDA6845C0DF2374E00F98A1A /* SDL_pixels.c in Sources */,
 				FDA6845E0DF2374E00F98A1A /* SDL_rect.c in Sources */,
-				FDA684600DF2374E00F98A1A /* SDL_renderer_sw.c in Sources */,
 				FDA684620DF2374E00F98A1A /* SDL_RLEaccel.c in Sources */,
 				FDA684640DF2374E00F98A1A /* SDL_stretch.c in Sources */,
 				FDA684660DF2374E00F98A1A /* SDL_surface.c in Sources */,
 				FDA684680DF2374E00F98A1A /* SDL_video.c in Sources */,
-				FDA684690DF2374E00F98A1A /* SDL_yuv_mmx.c in Sources */,
-				FDA6846A0DF2374E00F98A1A /* SDL_yuv_sw.c in Sources */,
 				FDA685FB0DF244C800F98A1A /* SDL_nullevents.c in Sources */,
-				FDA685FD0DF244C800F98A1A /* SDL_nullrender.c in Sources */,
 				FDA685FF0DF244C800F98A1A /* SDL_nullvideo.c in Sources */,
 				FD5F9D2F0E0E08B3008E885B /* SDL_joystick.c in Sources */,
 				FD689EFB0E26E57800F90B21 /* SDL_coreaudio_iphone.c in Sources */,
@@ -1482,20 +1521,10 @@
 				FD689FCE0E26E9D400F90B21 /* SDL_uikitappdelegate.m in Sources */,
 				FD8BD8250E27E25900B52CD5 /* SDL_sysloadso.c in Sources */,
 				FDC656480E560DF800311C8E /* jumphack.c in Sources */,
-				0495E68C0E97408800152DFE /* SDL_renderer_gl.c in Sources */,
-				0495E68E0E97408800152DFE /* SDL_renderer_gles.c in Sources */,
 				047677BB0EA76A31008ABAF1 /* SDL_syshaptic.c in Sources */,
 				047677BC0EA76A31008ABAF1 /* SDL_haptic.c in Sources */,
 				047AF1B30EA98D6C00811173 /* SDL_sysloadso.c in Sources */,
-				0463873F0F0B5B7D0041FD65 /* SDL_blendline.c in Sources */,
-				046387400F0B5B7D0041FD65 /* SDL_blendpoint.c in Sources */,
-				046387410F0B5B7D0041FD65 /* SDL_blendrect.c in Sources */,
-				046387440F0B5B7D0041FD65 /* SDL_drawline.c in Sources */,
-				046387450F0B5B7D0041FD65 /* SDL_drawpoint.c in Sources */,
 				046387460F0B5B7D0041FD65 /* SDL_fillrect.c in Sources */,
-				043DD76F10FD8A0000DED673 /* SDL_alphamult.c in Sources */,
-				043DD77110FD8A0000DED673 /* SDL_blendfillrect.c in Sources */,
-				043DD77210FD8A0000DED673 /* SDL_drawrect.c in Sources */,
 				04F2AF561104ABD200D6DDF7 /* SDL_assert.c in Sources */,
 				56ED04E1118A8EE200A56AA6 /* SDL_power.c in Sources */,
 				56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */,
@@ -1506,6 +1535,20 @@
 				04BA9D6611EF474A00B60E01 /* SDL_touch.c in Sources */,
 				04FFAB8B12E23B8D00BA343D /* SDL_atomic.c in Sources */,
 				04FFAB8C12E23B8D00BA343D /* SDL_spinlock.c in Sources */,
+				041B2CF112FA0F680087D585 /* SDL_render.c in Sources */,
+				04409BA712FA989600FB9AA8 /* SDL_yuv_mmx.c in Sources */,
+				04409BA912FA989600FB9AA8 /* SDL_yuv_sw.c in Sources */,
+				04F7807612FB751400FC43C0 /* SDL_blendfillrect.c in Sources */,
+				04F7807812FB751400FC43C0 /* SDL_blendline.c in Sources */,
+				04F7807A12FB751400FC43C0 /* SDL_blendpoint.c in Sources */,
+				04F7807D12FB751400FC43C0 /* SDL_drawline.c in Sources */,
+				04F7807F12FB751400FC43C0 /* SDL_drawpoint.c in Sources */,
+				04F7808512FB753F00FC43C0 /* SDL_nullframebuffer.c in Sources */,
+				0442EC5112FE1C1E004C9285 /* SDL_render_sw.c in Sources */,
+				0442EC5312FE1C28004C9285 /* SDL_render_gles.c in Sources */,
+				0442EC5512FE1C3F004C9285 /* SDL_hints.c in Sources */,
+				0402A85812FE70C600CECEE3 /* SDL_render_gles2.c in Sources */,
+				0402A85912FE70C600CECEE3 /* SDL_shaders_gles2.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Tue Feb 01 00:37:02 2011 -0800
+++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Sun Feb 06 21:23:32 2011 -0800
@@ -121,12 +121,40 @@
 		00D8DA281195093100638393 /* SDL_at.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA151195093100638393 /* SDL_at.c */; };
 		00D8DA291195093100638393 /* surface.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA181195093100638393 /* surface.c */; };
 		00D8DA2A1195093100638393 /* testsdl.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA1A1195093100638393 /* testsdl.c */; };
+		04043BBB12FEB1BE0076DB1F /* SDL_glfuncs.h in Headers */ = {isa = PBXBuildFile; fileRef = 04043BBA12FEB1BE0076DB1F /* SDL_glfuncs.h */; };
+		04043BBC12FEB1BE0076DB1F /* SDL_glfuncs.h in Headers */ = {isa = PBXBuildFile; fileRef = 04043BBA12FEB1BE0076DB1F /* SDL_glfuncs.h */; };
+		041B2C9512FA0D2A0087D585 /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2C9412FA0D2A0087D585 /* SDL_render.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		041B2C9612FA0D2A0087D585 /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2C9412FA0D2A0087D585 /* SDL_render.h */; };
+		041B2CA512FA0D680087D585 /* SDL_render.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2C9E12FA0D680087D585 /* SDL_render.c */; };
+		041B2CA612FA0D680087D585 /* SDL_sysrender.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2C9F12FA0D680087D585 /* SDL_sysrender.h */; };
+		041B2CAB12FA0D680087D585 /* SDL_render.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2C9E12FA0D680087D585 /* SDL_render.c */; };
+		041B2CAC12FA0D680087D585 /* SDL_sysrender.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2C9F12FA0D680087D585 /* SDL_sysrender.h */; };
+		04409B9112FA97ED00FB9AA8 /* mmx.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409B8D12FA97ED00FB9AA8 /* mmx.h */; };
+		04409B9212FA97ED00FB9AA8 /* SDL_yuv_mmx.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409B8E12FA97ED00FB9AA8 /* SDL_yuv_mmx.c */; };
+		04409B9312FA97ED00FB9AA8 /* SDL_yuv_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409B8F12FA97ED00FB9AA8 /* SDL_yuv_sw_c.h */; };
+		04409B9412FA97ED00FB9AA8 /* SDL_yuv_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409B9012FA97ED00FB9AA8 /* SDL_yuv_sw.c */; };
+		04409B9512FA97ED00FB9AA8 /* mmx.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409B8D12FA97ED00FB9AA8 /* mmx.h */; };
+		04409B9612FA97ED00FB9AA8 /* SDL_yuv_mmx.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409B8E12FA97ED00FB9AA8 /* SDL_yuv_mmx.c */; };
+		04409B9712FA97ED00FB9AA8 /* SDL_yuv_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409B8F12FA97ED00FB9AA8 /* SDL_yuv_sw_c.h */; };
+		04409B9812FA97ED00FB9AA8 /* SDL_yuv_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409B9012FA97ED00FB9AA8 /* SDL_yuv_sw.c */; };
+		0442EC1312FE1B79004C9285 /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = 0442EC1212FE1B79004C9285 /* SDL_hints.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		0442EC1412FE1B79004C9285 /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = 0442EC1212FE1B79004C9285 /* SDL_hints.h */; };
+		0442EC1812FE1BBA004C9285 /* SDL_render_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC1712FE1BBA004C9285 /* SDL_render_gl.c */; };
+		0442EC1912FE1BBA004C9285 /* SDL_render_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC1712FE1BBA004C9285 /* SDL_render_gl.c */; };
+		0442EC1C12FE1BCB004C9285 /* SDL_render_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0442EC1A12FE1BCB004C9285 /* SDL_render_sw_c.h */; };
+		0442EC1D12FE1BCB004C9285 /* SDL_render_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC1B12FE1BCB004C9285 /* SDL_render_sw.c */; };
+		0442EC1E12FE1BCB004C9285 /* SDL_render_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0442EC1A12FE1BCB004C9285 /* SDL_render_sw_c.h */; };
+		0442EC1F12FE1BCB004C9285 /* SDL_render_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC1B12FE1BCB004C9285 /* SDL_render_sw.c */; };
+		0442EC5A12FE1C60004C9285 /* SDL_x11framebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC5812FE1C60004C9285 /* SDL_x11framebuffer.c */; };
+		0442EC5B12FE1C60004C9285 /* SDL_x11framebuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0442EC5912FE1C60004C9285 /* SDL_x11framebuffer.h */; };
+		0442EC5C12FE1C60004C9285 /* SDL_x11framebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC5812FE1C60004C9285 /* SDL_x11framebuffer.c */; };
+		0442EC5D12FE1C60004C9285 /* SDL_x11framebuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0442EC5912FE1C60004C9285 /* SDL_x11framebuffer.h */; };
+		0442EC5F12FE1C75004C9285 /* SDL_hints.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC5E12FE1C75004C9285 /* SDL_hints.c */; };
+		0442EC6012FE1C75004C9285 /* SDL_hints.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC5E12FE1C75004C9285 /* SDL_hints.c */; };
 		044E5F8511E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		044E5F8611E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; };
 		0469A10B12EE4BF100B846D6 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10912EE4BF100B846D6 /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		0469A10C12EE4BF100B846D6 /* SDL_scalemode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		0469A10D12EE4BF100B846D6 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10912EE4BF100B846D6 /* SDL_blendmode.h */; };
-		0469A10E12EE4BF100B846D6 /* SDL_scalemode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */; };
 		04BD000812E6671800899322 /* SDL_diskaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD8812E6671700899322 /* SDL_diskaudio.c */; };
 		04BD000912E6671800899322 /* SDL_diskaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFD8912E6671700899322 /* SDL_diskaudio.h */; };
 		04BD001012E6671800899322 /* SDL_dummyaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD9412E6671700899322 /* SDL_dummyaudio.c */; };
@@ -155,7 +183,6 @@
 		04BD004312E6671800899322 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD712E6671700899322 /* default_cursor.h */; };
 		04BD004412E6671800899322 /* scancodes_darwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD812E6671700899322 /* scancodes_darwin.h */; };
 		04BD004512E6671800899322 /* scancodes_linux.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD912E6671700899322 /* scancodes_linux.h */; };
-		04BD004612E6671800899322 /* scancodes_win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDA12E6671700899322 /* scancodes_win32.h */; };
 		04BD004712E6671800899322 /* scancodes_xfree86.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDB12E6671700899322 /* scancodes_xfree86.h */; };
 		04BD004812E6671800899322 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDDC12E6671700899322 /* SDL_clipboardevents.c */; };
 		04BD004912E6671800899322 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDD12E6671700899322 /* SDL_clipboardevents_c.h */; };
@@ -212,7 +239,6 @@
 		04BD00C912E6671800899322 /* SDL_systhread.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE8B12E6671800899322 /* SDL_systhread.h */; };
 		04BD00CA12E6671800899322 /* SDL_thread.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFE8C12E6671800899322 /* SDL_thread.c */; };
 		04BD00CB12E6671800899322 /* SDL_thread_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE8D12E6671800899322 /* SDL_thread_c.h */; };
-		04BD00D612E6671800899322 /* SDL_systimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE9E12E6671800899322 /* SDL_systimer.h */; };
 		04BD00D712E6671800899322 /* SDL_timer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFE9F12E6671800899322 /* SDL_timer.c */; };
 		04BD00D812E6671800899322 /* SDL_timer_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEA012E6671800899322 /* SDL_timer_c.h */; };
 		04BD00D912E6671800899322 /* SDL_systimer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEA212E6671800899322 /* SDL_systimer.c */; };
@@ -236,17 +262,8 @@
 		04BD010412E6671800899322 /* SDL_cocoawindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFED312E6671800899322 /* SDL_cocoawindow.m */; };
 		04BD011712E6671800899322 /* SDL_nullevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEE812E6671800899322 /* SDL_nullevents.c */; };
 		04BD011812E6671800899322 /* SDL_nullevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEE912E6671800899322 /* SDL_nullevents_c.h */; };
-		04BD011912E6671800899322 /* SDL_nullrender.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEEA12E6671800899322 /* SDL_nullrender.c */; };
-		04BD011A12E6671800899322 /* SDL_nullrender_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEEB12E6671800899322 /* SDL_nullrender_c.h */; };
 		04BD011B12E6671800899322 /* SDL_nullvideo.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEEC12E6671800899322 /* SDL_nullvideo.c */; };
 		04BD011C12E6671800899322 /* SDL_nullvideo.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEED12E6671800899322 /* SDL_nullvideo.h */; };
-		04BD013212E6671800899322 /* mmx.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF0412E6671800899322 /* mmx.h */; };
-		04BD016F12E6671800899322 /* SDL_alphamult.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4812E6671800899322 /* SDL_alphamult.c */; };
-		04BD017012E6671800899322 /* SDL_alphamult.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF4912E6671800899322 /* SDL_alphamult.h */; };
-		04BD017112E6671800899322 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4A12E6671800899322 /* SDL_blendfillrect.c */; };
-		04BD017212E6671800899322 /* SDL_blendline.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4B12E6671800899322 /* SDL_blendline.c */; };
-		04BD017312E6671800899322 /* SDL_blendpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4C12E6671800899322 /* SDL_blendpoint.c */; };
-		04BD017412E6671800899322 /* SDL_blendrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4D12E6671800899322 /* SDL_blendrect.c */; };
 		04BD017512E6671800899322 /* SDL_blit.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4E12E6671800899322 /* SDL_blit.c */; };
 		04BD017612E6671800899322 /* SDL_blit.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF4F12E6671800899322 /* SDL_blit.h */; };
 		04BD017712E6671800899322 /* SDL_blit_0.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5012E6671800899322 /* SDL_blit_0.c */; };
@@ -261,25 +278,12 @@
 		04BD018012E6671800899322 /* SDL_blit_slow.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF5912E6671800899322 /* SDL_blit_slow.h */; };
 		04BD018112E6671800899322 /* SDL_bmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5A12E6671800899322 /* SDL_bmp.c */; };
 		04BD018212E6671800899322 /* SDL_clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5B12E6671800899322 /* SDL_clipboard.c */; };
-		04BD018312E6671800899322 /* SDL_draw.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF5C12E6671800899322 /* SDL_draw.h */; };
-		04BD018412E6671800899322 /* SDL_drawline.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5D12E6671800899322 /* SDL_drawline.c */; };
-		04BD018512E6671800899322 /* SDL_drawpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5E12E6671800899322 /* SDL_drawpoint.c */; };
-		04BD018612E6671800899322 /* SDL_drawrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5F12E6671800899322 /* SDL_drawrect.c */; };
 		04BD018712E6671800899322 /* SDL_fillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6012E6671800899322 /* SDL_fillrect.c */; };
 		04BD018812E6671800899322 /* SDL_gamma.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6112E6671800899322 /* SDL_gamma.c */; };
-		04BD018912E6671800899322 /* SDL_glesfuncs.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6212E6671800899322 /* SDL_glesfuncs.h */; };
-		04BD018A12E6671800899322 /* SDL_glfuncs.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6312E6671800899322 /* SDL_glfuncs.h */; };
 		04BD018B12E6671800899322 /* SDL_leaks.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6412E6671800899322 /* SDL_leaks.h */; };
 		04BD018C12E6671800899322 /* SDL_pixels.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6512E6671800899322 /* SDL_pixels.c */; };
 		04BD018D12E6671800899322 /* SDL_pixels_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6612E6671800899322 /* SDL_pixels_c.h */; };
 		04BD018E12E6671800899322 /* SDL_rect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6712E6671800899322 /* SDL_rect.c */; };
-		04BD018F12E6671800899322 /* SDL_rect_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6812E6671800899322 /* SDL_rect_c.h */; };
-		04BD019012E6671800899322 /* SDL_renderer_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6912E6671800899322 /* SDL_renderer_gl.c */; };
-		04BD019112E6671800899322 /* SDL_renderer_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6A12E6671800899322 /* SDL_renderer_gl.h */; };
-		04BD019212E6671800899322 /* SDL_renderer_gles.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6B12E6671800899322 /* SDL_renderer_gles.c */; };
-		04BD019312E6671800899322 /* SDL_renderer_gles.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6C12E6671800899322 /* SDL_renderer_gles.h */; };
-		04BD019412E6671800899322 /* SDL_renderer_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6D12E6671800899322 /* SDL_renderer_sw.c */; };
-		04BD019512E6671800899322 /* SDL_renderer_sw.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6E12E6671800899322 /* SDL_renderer_sw.h */; };
 		04BD019612E6671800899322 /* SDL_RLEaccel.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6F12E6671800899322 /* SDL_RLEaccel.c */; };
 		04BD019712E6671800899322 /* SDL_RLEaccel_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF7012E6671800899322 /* SDL_RLEaccel_c.h */; };
 		04BD019812E6671800899322 /* SDL_shape.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7112E6671800899322 /* SDL_shape.c */; };
@@ -288,9 +292,6 @@
 		04BD019B12E6671800899322 /* SDL_surface.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7412E6671800899322 /* SDL_surface.c */; };
 		04BD019C12E6671800899322 /* SDL_sysvideo.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF7512E6671800899322 /* SDL_sysvideo.h */; };
 		04BD019D12E6671800899322 /* SDL_video.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7612E6671800899322 /* SDL_video.c */; };
-		04BD019E12E6671800899322 /* SDL_yuv_mmx.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7712E6671800899322 /* SDL_yuv_mmx.c */; };
-		04BD019F12E6671800899322 /* SDL_yuv_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7812E6671800899322 /* SDL_yuv_sw.c */; };
-		04BD01A012E6671800899322 /* SDL_yuv_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF7912E6671800899322 /* SDL_yuv_sw_c.h */; };
 		04BD01DB12E6671800899322 /* imKStoUCS.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFB812E6671800899322 /* imKStoUCS.c */; };
 		04BD01DC12E6671800899322 /* imKStoUCS.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFB912E6671800899322 /* imKStoUCS.h */; };
 		04BD01DD12E6671800899322 /* SDL_x11clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFBA12E6671800899322 /* SDL_x11clipboard.c */; };
@@ -311,8 +312,6 @@
 		04BD01EC12E6671800899322 /* SDL_x11opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFC912E6671800899322 /* SDL_x11opengl.h */; };
 		04BD01ED12E6671800899322 /* SDL_x11opengles.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCA12E6671800899322 /* SDL_x11opengles.c */; };
 		04BD01EE12E6671800899322 /* SDL_x11opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCB12E6671800899322 /* SDL_x11opengles.h */; };
-		04BD01EF12E6671800899322 /* SDL_x11render.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCC12E6671800899322 /* SDL_x11render.c */; };
-		04BD01F012E6671800899322 /* SDL_x11render.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCD12E6671800899322 /* SDL_x11render.h */; };
 		04BD01F112E6671800899322 /* SDL_x11shape.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCE12E6671800899322 /* SDL_x11shape.c */; };
 		04BD01F212E6671800899322 /* SDL_x11shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCF12E6671800899322 /* SDL_x11shape.h */; };
 		04BD01F312E6671800899322 /* SDL_x11sym.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFD012E6671800899322 /* SDL_x11sym.h */; };
@@ -325,7 +324,6 @@
 		04BD01FA12E6671800899322 /* extutil.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFD912E6671800899322 /* extutil.h */; };
 		04BD01FB12E6671800899322 /* panoramiXext.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDA12E6671800899322 /* panoramiXext.h */; };
 		04BD01FC12E6671800899322 /* panoramiXproto.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDB12E6671800899322 /* panoramiXproto.h */; };
-		04BD01FD12E6671800899322 /* StdCmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDC12E6671800899322 /* StdCmap.h */; };
 		04BD01FE12E6671800899322 /* Xext.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDD12E6671800899322 /* Xext.h */; };
 		04BD01FF12E6671800899322 /* xf86dga.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDE12E6671800899322 /* xf86dga.h */; };
 		04BD020012E6671800899322 /* xf86dga1.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDF12E6671800899322 /* xf86dga1.h */; };
@@ -340,14 +338,6 @@
 		04BD020912E6671800899322 /* README in Resources */ = {isa = PBXBuildFile; fileRef = 04BDFFE812E6671800899322 /* README */; };
 		04BD020A12E6671800899322 /* Xinerama.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFEA12E6671800899322 /* Xinerama.c */; };
 		04BD020B12E6671800899322 /* xme.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFEC12E6671800899322 /* xme.c */; };
-		04BD020C12E6671800899322 /* AllCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFEE12E6671800899322 /* AllCmap.c */; };
-		04BD020D12E6671800899322 /* CmapAlloc.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFEF12E6671800899322 /* CmapAlloc.c */; };
-		04BD020E12E6671800899322 /* CrCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF012E6671800899322 /* CrCmap.c */; };
-		04BD020F12E6671800899322 /* DelCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF112E6671800899322 /* DelCmap.c */; };
-		04BD021012E6671800899322 /* Distinct.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF212E6671800899322 /* Distinct.c */; };
-		04BD021112E6671800899322 /* LookupCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF312E6671800899322 /* LookupCmap.c */; };
-		04BD021212E6671800899322 /* StdCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF412E6671800899322 /* StdCmap.c */; };
-		04BD021312E6671800899322 /* VisCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF512E6671800899322 /* VisCmap.c */; };
 		04BD021412E6671800899322 /* Xv.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF712E6671800899322 /* Xv.c */; };
 		04BD021512E6671800899322 /* Xvlibint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFF812E6671800899322 /* Xvlibint.h */; };
 		04BD021612E6671800899322 /* XF86VMode.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFFA12E6671800899322 /* XF86VMode.c */; };
@@ -381,7 +371,6 @@
 		04BD025E12E6671800899322 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD712E6671700899322 /* default_cursor.h */; };
 		04BD025F12E6671800899322 /* scancodes_darwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD812E6671700899322 /* scancodes_darwin.h */; };
 		04BD026012E6671800899322 /* scancodes_linux.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD912E6671700899322 /* scancodes_linux.h */; };
-		04BD026112E6671800899322 /* scancodes_win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDA12E6671700899322 /* scancodes_win32.h */; };
 		04BD026212E6671800899322 /* scancodes_xfree86.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDB12E6671700899322 /* scancodes_xfree86.h */; };
 		04BD026312E6671800899322 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDDC12E6671700899322 /* SDL_clipboardevents.c */; };
 		04BD026412E6671800899322 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDD12E6671700899322 /* SDL_clipboardevents_c.h */; };
@@ -438,7 +427,6 @@
 		04BD02E312E6671800899322 /* SDL_systhread.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE8B12E6671800899322 /* SDL_systhread.h */; };
 		04BD02E412E6671800899322 /* SDL_thread.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFE8C12E6671800899322 /* SDL_thread.c */; };
 		04BD02E512E6671800899322 /* SDL_thread_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE8D12E6671800899322 /* SDL_thread_c.h */; };
-		04BD02F012E6671800899322 /* SDL_systimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE9E12E6671800899322 /* SDL_systimer.h */; };
 		04BD02F112E6671800899322 /* SDL_timer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFE9F12E6671800899322 /* SDL_timer.c */; };
 		04BD02F212E6671800899322 /* SDL_timer_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEA012E6671800899322 /* SDL_timer_c.h */; };
 		04BD02F312E6671800899322 /* SDL_systimer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEA212E6671800899322 /* SDL_systimer.c */; };
@@ -462,17 +450,8 @@
 		04BD031E12E6671800899322 /* SDL_cocoawindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFED312E6671800899322 /* SDL_cocoawindow.m */; };
 		04BD033112E6671800899322 /* SDL_nullevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEE812E6671800899322 /* SDL_nullevents.c */; };
 		04BD033212E6671800899322 /* SDL_nullevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEE912E6671800899322 /* SDL_nullevents_c.h */; };
-		04BD033312E6671800899322 /* SDL_nullrender.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEEA12E6671800899322 /* SDL_nullrender.c */; };
-		04BD033412E6671800899322 /* SDL_nullrender_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEEB12E6671800899322 /* SDL_nullrender_c.h */; };
 		04BD033512E6671800899322 /* SDL_nullvideo.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEEC12E6671800899322 /* SDL_nullvideo.c */; };
 		04BD033612E6671800899322 /* SDL_nullvideo.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEED12E6671800899322 /* SDL_nullvideo.h */; };
-		04BD034C12E6671800899322 /* mmx.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF0412E6671800899322 /* mmx.h */; };
-		04BD038912E6671800899322 /* SDL_alphamult.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4812E6671800899322 /* SDL_alphamult.c */; };
-		04BD038A12E6671800899322 /* SDL_alphamult.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF4912E6671800899322 /* SDL_alphamult.h */; };
-		04BD038B12E6671800899322 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4A12E6671800899322 /* SDL_blendfillrect.c */; };
-		04BD038C12E6671800899322 /* SDL_blendline.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4B12E6671800899322 /* SDL_blendline.c */; };
-		04BD038D12E6671800899322 /* SDL_blendpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4C12E6671800899322 /* SDL_blendpoint.c */; };
-		04BD038E12E6671800899322 /* SDL_blendrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4D12E6671800899322 /* SDL_blendrect.c */; };
 		04BD038F12E6671800899322 /* SDL_blit.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF4E12E6671800899322 /* SDL_blit.c */; };
 		04BD039012E6671800899322 /* SDL_blit.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF4F12E6671800899322 /* SDL_blit.h */; };
 		04BD039112E6671800899322 /* SDL_blit_0.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5012E6671800899322 /* SDL_blit_0.c */; };
@@ -487,25 +466,12 @@
 		04BD039A12E6671800899322 /* SDL_blit_slow.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF5912E6671800899322 /* SDL_blit_slow.h */; };
 		04BD039B12E6671800899322 /* SDL_bmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5A12E6671800899322 /* SDL_bmp.c */; };
 		04BD039C12E6671800899322 /* SDL_clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5B12E6671800899322 /* SDL_clipboard.c */; };
-		04BD039D12E6671800899322 /* SDL_draw.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF5C12E6671800899322 /* SDL_draw.h */; };
-		04BD039E12E6671800899322 /* SDL_drawline.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5D12E6671800899322 /* SDL_drawline.c */; };
-		04BD039F12E6671800899322 /* SDL_drawpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5E12E6671800899322 /* SDL_drawpoint.c */; };
-		04BD03A012E6671800899322 /* SDL_drawrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF5F12E6671800899322 /* SDL_drawrect.c */; };
 		04BD03A112E6671800899322 /* SDL_fillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6012E6671800899322 /* SDL_fillrect.c */; };
 		04BD03A212E6671800899322 /* SDL_gamma.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6112E6671800899322 /* SDL_gamma.c */; };
-		04BD03A312E6671800899322 /* SDL_glesfuncs.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6212E6671800899322 /* SDL_glesfuncs.h */; };
-		04BD03A412E6671800899322 /* SDL_glfuncs.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6312E6671800899322 /* SDL_glfuncs.h */; };
 		04BD03A512E6671800899322 /* SDL_leaks.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6412E6671800899322 /* SDL_leaks.h */; };
 		04BD03A612E6671800899322 /* SDL_pixels.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6512E6671800899322 /* SDL_pixels.c */; };
 		04BD03A712E6671800899322 /* SDL_pixels_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6612E6671800899322 /* SDL_pixels_c.h */; };
 		04BD03A812E6671800899322 /* SDL_rect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6712E6671800899322 /* SDL_rect.c */; };
-		04BD03A912E6671800899322 /* SDL_rect_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6812E6671800899322 /* SDL_rect_c.h */; };
-		04BD03AA12E6671800899322 /* SDL_renderer_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6912E6671800899322 /* SDL_renderer_gl.c */; };
-		04BD03AB12E6671800899322 /* SDL_renderer_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6A12E6671800899322 /* SDL_renderer_gl.h */; };
-		04BD03AC12E6671800899322 /* SDL_renderer_gles.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6B12E6671800899322 /* SDL_renderer_gles.c */; };
-		04BD03AD12E6671800899322 /* SDL_renderer_gles.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6C12E6671800899322 /* SDL_renderer_gles.h */; };
-		04BD03AE12E6671800899322 /* SDL_renderer_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6D12E6671800899322 /* SDL_renderer_sw.c */; };
-		04BD03AF12E6671800899322 /* SDL_renderer_sw.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6E12E6671800899322 /* SDL_renderer_sw.h */; };
 		04BD03B012E6671800899322 /* SDL_RLEaccel.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6F12E6671800899322 /* SDL_RLEaccel.c */; };
 		04BD03B112E6671800899322 /* SDL_RLEaccel_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF7012E6671800899322 /* SDL_RLEaccel_c.h */; };
 		04BD03B212E6671800899322 /* SDL_shape.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7112E6671800899322 /* SDL_shape.c */; };
@@ -514,9 +480,6 @@
 		04BD03B512E6671800899322 /* SDL_surface.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7412E6671800899322 /* SDL_surface.c */; };
 		04BD03B612E6671800899322 /* SDL_sysvideo.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF7512E6671800899322 /* SDL_sysvideo.h */; };
 		04BD03B712E6671800899322 /* SDL_video.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7612E6671800899322 /* SDL_video.c */; };
-		04BD03B812E6671800899322 /* SDL_yuv_mmx.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7712E6671800899322 /* SDL_yuv_mmx.c */; };
-		04BD03B912E6671800899322 /* SDL_yuv_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7812E6671800899322 /* SDL_yuv_sw.c */; };
-		04BD03BA12E6671800899322 /* SDL_yuv_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF7912E6671800899322 /* SDL_yuv_sw_c.h */; };
 		04BD03F312E6671800899322 /* imKStoUCS.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFB812E6671800899322 /* imKStoUCS.c */; };
 		04BD03F412E6671800899322 /* imKStoUCS.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFB912E6671800899322 /* imKStoUCS.h */; };
 		04BD03F512E6671800899322 /* SDL_x11clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFBA12E6671800899322 /* SDL_x11clipboard.c */; };
@@ -537,8 +500,6 @@
 		04BD040412E6671800899322 /* SDL_x11opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFC912E6671800899322 /* SDL_x11opengl.h */; };
 		04BD040512E6671800899322 /* SDL_x11opengles.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCA12E6671800899322 /* SDL_x11opengles.c */; };
 		04BD040612E6671800899322 /* SDL_x11opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCB12E6671800899322 /* SDL_x11opengles.h */; };
-		04BD040712E6671800899322 /* SDL_x11render.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCC12E6671800899322 /* SDL_x11render.c */; };
-		04BD040812E6671800899322 /* SDL_x11render.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCD12E6671800899322 /* SDL_x11render.h */; };
 		04BD040912E6671800899322 /* SDL_x11shape.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCE12E6671800899322 /* SDL_x11shape.c */; };
 		04BD040A12E6671800899322 /* SDL_x11shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCF12E6671800899322 /* SDL_x11shape.h */; };
 		04BD040B12E6671800899322 /* SDL_x11sym.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFD012E6671800899322 /* SDL_x11sym.h */; };
@@ -551,7 +512,6 @@
 		04BD041212E6671800899322 /* extutil.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFD912E6671800899322 /* extutil.h */; };
 		04BD041312E6671800899322 /* panoramiXext.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDA12E6671800899322 /* panoramiXext.h */; };
 		04BD041412E6671800899322 /* panoramiXproto.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDB12E6671800899322 /* panoramiXproto.h */; };
-		04BD041512E6671800899322 /* StdCmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDC12E6671800899322 /* StdCmap.h */; };
 		04BD041612E6671800899322 /* Xext.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDD12E6671800899322 /* Xext.h */; };
 		04BD041712E6671800899322 /* xf86dga.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDE12E6671800899322 /* xf86dga.h */; };
 		04BD041812E6671800899322 /* xf86dga1.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFDF12E6671800899322 /* xf86dga1.h */; };
@@ -565,14 +525,6 @@
 		04BD042012E6671800899322 /* Xvproto.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFE712E6671800899322 /* Xvproto.h */; };
 		04BD042112E6671800899322 /* Xinerama.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFEA12E6671800899322 /* Xinerama.c */; };
 		04BD042212E6671800899322 /* xme.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFEC12E6671800899322 /* xme.c */; };
-		04BD042312E6671800899322 /* AllCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFEE12E6671800899322 /* AllCmap.c */; };
-		04BD042412E6671800899322 /* CmapAlloc.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFEF12E6671800899322 /* CmapAlloc.c */; };
-		04BD042512E6671800899322 /* CrCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF012E6671800899322 /* CrCmap.c */; };
-		04BD042612E6671800899322 /* DelCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF112E6671800899322 /* DelCmap.c */; };
-		04BD042712E6671800899322 /* Distinct.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF212E6671800899322 /* Distinct.c */; };
-		04BD042812E6671800899322 /* LookupCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF312E6671800899322 /* LookupCmap.c */; };
-		04BD042912E6671800899322 /* StdCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF412E6671800899322 /* StdCmap.c */; };
-		04BD042A12E6671800899322 /* VisCmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF512E6671800899322 /* VisCmap.c */; };
 		04BD042B12E6671800899322 /* Xv.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFF712E6671800899322 /* Xv.c */; };
 		04BD042C12E6671800899322 /* Xvlibint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFF812E6671800899322 /* Xvlibint.h */; };
 		04BD042D12E6671800899322 /* XF86VMode.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFFA12E6671800899322 /* XF86VMode.c */; };
@@ -582,6 +534,32 @@
 		04DEA57311E6006A00386CAC /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DEA56F11E6006A00386CAC /* SDL_input.h */; };
 		04F2AF691104AC4500D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		04F2AF6A1104AC4500D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */; };
+		04F7803912FB748500FC43C0 /* SDL_nullframebuffer_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7803712FB748500FC43C0 /* SDL_nullframebuffer_c.h */; };
+		04F7803A12FB748500FC43C0 /* SDL_nullframebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7803812FB748500FC43C0 /* SDL_nullframebuffer.c */; };
+		04F7803B12FB748500FC43C0 /* SDL_nullframebuffer_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7803712FB748500FC43C0 /* SDL_nullframebuffer_c.h */; };
+		04F7803C12FB748500FC43C0 /* SDL_nullframebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7803812FB748500FC43C0 /* SDL_nullframebuffer.c */; };
+		04F7804912FB74A200FC43C0 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7803D12FB74A200FC43C0 /* SDL_blendfillrect.c */; };
+		04F7804A12FB74A200FC43C0 /* SDL_blendfillrect.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7803E12FB74A200FC43C0 /* SDL_blendfillrect.h */; };
+		04F7804B12FB74A200FC43C0 /* SDL_blendline.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7803F12FB74A200FC43C0 /* SDL_blendline.c */; };
+		04F7804C12FB74A200FC43C0 /* SDL_blendline.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804012FB74A200FC43C0 /* SDL_blendline.h */; };
+		04F7804D12FB74A200FC43C0 /* SDL_blendpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7804112FB74A200FC43C0 /* SDL_blendpoint.c */; };
+		04F7804E12FB74A200FC43C0 /* SDL_blendpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804212FB74A200FC43C0 /* SDL_blendpoint.h */; };
+		04F7804F12FB74A200FC43C0 /* SDL_draw.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804312FB74A200FC43C0 /* SDL_draw.h */; };
+		04F7805012FB74A200FC43C0 /* SDL_drawline.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7804412FB74A200FC43C0 /* SDL_drawline.c */; };
+		04F7805112FB74A200FC43C0 /* SDL_drawline.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804512FB74A200FC43C0 /* SDL_drawline.h */; };
+		04F7805212FB74A200FC43C0 /* SDL_drawpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7804612FB74A200FC43C0 /* SDL_drawpoint.c */; };
+		04F7805312FB74A200FC43C0 /* SDL_drawpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */; };
+		04F7805512FB74A200FC43C0 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7803D12FB74A200FC43C0 /* SDL_blendfillrect.c */; };
+		04F7805612FB74A200FC43C0 /* SDL_blendfillrect.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7803E12FB74A200FC43C0 /* SDL_blendfillrect.h */; };
+		04F7805712FB74A200FC43C0 /* SDL_blendline.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7803F12FB74A200FC43C0 /* SDL_blendline.c */; };
+		04F7805812FB74A200FC43C0 /* SDL_blendline.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804012FB74A200FC43C0 /* SDL_blendline.h */; };
+		04F7805912FB74A200FC43C0 /* SDL_blendpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7804112FB74A200FC43C0 /* SDL_blendpoint.c */; };
+		04F7805A12FB74A200FC43C0 /* SDL_blendpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804212FB74A200FC43C0 /* SDL_blendpoint.h */; };
+		04F7805B12FB74A200FC43C0 /* SDL_draw.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804312FB74A200FC43C0 /* SDL_draw.h */; };
+		04F7805C12FB74A200FC43C0 /* SDL_drawline.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7804412FB74A200FC43C0 /* SDL_drawline.c */; };
+		04F7805D12FB74A200FC43C0 /* SDL_drawline.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804512FB74A200FC43C0 /* SDL_drawline.h */; };
+		04F7805E12FB74A200FC43C0 /* SDL_drawpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7804612FB74A200FC43C0 /* SDL_drawpoint.c */; };
+		04F7805F12FB74A200FC43C0 /* SDL_drawpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */; };
 		453773821207C518002F0F45 /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 453773811207C518002F0F45 /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		8CB0A77811F6A87F00CBA2DE /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CB0A77611F6A87F00CBA2DE /* SDL_gesture.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		8CB0A77911F6A87F00CBA2DE /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CB0A77711F6A87F00CBA2DE /* SDL_touch.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -714,9 +692,23 @@
 		00D8DA191195093100638393 /* surface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = surface.h; sourceTree = "<group>"; };
 		00D8DA1A1195093100638393 /* testsdl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testsdl.c; path = ../../test/automated/testsdl.c; sourceTree = SOURCE_ROOT; };
 		00F5D79E0990CA0D0051C449 /* UniversalBinaryNotes.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = UniversalBinaryNotes.rtf; sourceTree = "<group>"; };
+		04043BBA12FEB1BE0076DB1F /* SDL_glfuncs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_glfuncs.h; sourceTree = "<group>"; };
+		041B2C9412FA0D2A0087D585 /* SDL_render.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_render.h; path = ../../include/SDL_render.h; sourceTree = SOURCE_ROOT; };
+		041B2C9E12FA0D680087D585 /* SDL_render.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render.c; sourceTree = "<group>"; };
+		041B2C9F12FA0D680087D585 /* SDL_sysrender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysrender.h; sourceTree = "<group>"; };
+		04409B8D12FA97ED00FB9AA8 /* mmx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mmx.h; sourceTree = "<group>"; };
+		04409B8E12FA97ED00FB9AA8 /* SDL_yuv_mmx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_mmx.c; sourceTree = "<group>"; };
+		04409B8F12FA97ED00FB9AA8 /* SDL_yuv_sw_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_yuv_sw_c.h; sourceTree = "<group>"; };
+		04409B9012FA97ED00FB9AA8 /* SDL_yuv_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_sw.c; sourceTree = "<group>"; };
+		0442EC1212FE1B79004C9285 /* SDL_hints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_hints.h; path = ../../include/SDL_hints.h; sourceTree = SOURCE_ROOT; };
+		0442EC1712FE1BBA004C9285 /* SDL_render_gl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render_gl.c; sourceTree = "<group>"; };
+		0442EC1A12FE1BCB004C9285 /* SDL_render_sw_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_render_sw_c.h; sourceTree = "<group>"; };
+		0442EC1B12FE1BCB004C9285 /* SDL_render_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render_sw.c; sourceTree = "<group>"; };
+		0442EC5812FE1C60004C9285 /* SDL_x11framebuffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11framebuffer.c; sourceTree = "<group>"; };
+		0442EC5912FE1C60004C9285 /* SDL_x11framebuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_x11framebuffer.h; sourceTree = "<group>"; };
+		0442EC5E12FE1C75004C9285 /* SDL_hints.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_hints.c; path = ../../src/SDL_hints.c; sourceTree = SOURCE_ROOT; };
 		044E5F8411E6051C0076F181 /* SDL_clipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_clipboard.h; path = ../../include/SDL_clipboard.h; sourceTree = SOURCE_ROOT; };
 		0469A10912EE4BF100B846D6 /* SDL_blendmode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_blendmode.h; path = ../../include/SDL_blendmode.h; sourceTree = SOURCE_ROOT; };
-		0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_scalemode.h; path = ../../include/SDL_scalemode.h; sourceTree = SOURCE_ROOT; };
 		04BDFD7412E6671700899322 /* SDL_atomic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_atomic.c; sourceTree = "<group>"; };
 		04BDFD7512E6671700899322 /* SDL_spinlock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_spinlock.c; sourceTree = "<group>"; };
 		04BDFD8812E6671700899322 /* SDL_diskaudio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_diskaudio.c; sourceTree = "<group>"; };
@@ -747,7 +739,6 @@
 		04BDFDD712E6671700899322 /* default_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = default_cursor.h; sourceTree = "<group>"; };
 		04BDFDD812E6671700899322 /* scancodes_darwin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_darwin.h; sourceTree = "<group>"; };
 		04BDFDD912E6671700899322 /* scancodes_linux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_linux.h; sourceTree = "<group>"; };
-		04BDFDDA12E6671700899322 /* scancodes_win32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_win32.h; sourceTree = "<group>"; };
 		04BDFDDB12E6671700899322 /* scancodes_xfree86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_xfree86.h; sourceTree = "<group>"; };
 		04BDFDDC12E6671700899322 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = "<group>"; };
 		04BDFDDD12E6671700899322 /* SDL_clipboardevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_clipboardevents_c.h; sourceTree = "<group>"; };
@@ -804,7 +795,6 @@
 		04BDFE8B12E6671800899322 /* SDL_systhread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_systhread.h; sourceTree = "<group>"; };
 		04BDFE8C12E6671800899322 /* SDL_thread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_thread.c; sourceTree = "<group>"; };
 		04BDFE8D12E6671800899322 /* SDL_thread_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_thread_c.h; sourceTree = "<group>"; };
-		04BDFE9E12E6671800899322 /* SDL_systimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_systimer.h; sourceTree = "<group>"; };
 		04BDFE9F12E6671800899322 /* SDL_timer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_timer.c; sourceTree = "<group>"; };
 		04BDFEA012E6671800899322 /* SDL_timer_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_timer_c.h; sourceTree = "<group>"; };
 		04BDFEA212E6671800899322 /* SDL_systimer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_systimer.c; sourceTree = "<group>"; };
@@ -828,17 +818,8 @@
 		04BDFED312E6671800899322 /* SDL_cocoawindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoawindow.m; sourceTree = "<group>"; };
 		04BDFEE812E6671800899322 /* SDL_nullevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullevents.c; sourceTree = "<group>"; };
 		04BDFEE912E6671800899322 /* SDL_nullevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullevents_c.h; sourceTree = "<group>"; };
-		04BDFEEA12E6671800899322 /* SDL_nullrender.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullrender.c; sourceTree = "<group>"; };
-		04BDFEEB12E6671800899322 /* SDL_nullrender_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullrender_c.h; sourceTree = "<group>"; };
 		04BDFEEC12E6671800899322 /* SDL_nullvideo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullvideo.c; sourceTree = "<group>"; };
 		04BDFEED12E6671800899322 /* SDL_nullvideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullvideo.h; sourceTree = "<group>"; };
-		04BDFF0412E6671800899322 /* mmx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mmx.h; sourceTree = "<group>"; };
-		04BDFF4812E6671800899322 /* SDL_alphamult.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_alphamult.c; sourceTree = "<group>"; };
-		04BDFF4912E6671800899322 /* SDL_alphamult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_alphamult.h; sourceTree = "<group>"; };
-		04BDFF4A12E6671800899322 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = "<group>"; };
-		04BDFF4B12E6671800899322 /* SDL_blendline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendline.c; sourceTree = "<group>"; };
-		04BDFF4C12E6671800899322 /* SDL_blendpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendpoint.c; sourceTree = "<group>"; };
-		04BDFF4D12E6671800899322 /* SDL_blendrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendrect.c; sourceTree = "<group>"; };
 		04BDFF4E12E6671800899322 /* SDL_blit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blit.c; sourceTree = "<group>"; };
 		04BDFF4F12E6671800899322 /* SDL_blit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blit.h; sourceTree = "<group>"; };
 		04BDFF5012E6671800899322 /* SDL_blit_0.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blit_0.c; sourceTree = "<group>"; };
@@ -853,25 +834,12 @@
 		04BDFF5912E6671800899322 /* SDL_blit_slow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blit_slow.h; sourceTree = "<group>"; };
 		04BDFF5A12E6671800899322 /* SDL_bmp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_bmp.c; sourceTree = "<group>"; };
 		04BDFF5B12E6671800899322 /* SDL_clipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboard.c; sourceTree = "<group>"; };
-		04BDFF5C12E6671800899322 /* SDL_draw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_draw.h; sourceTree = "<group>"; };
-		04BDFF5D12E6671800899322 /* SDL_drawline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawline.c; sourceTree = "<group>"; };
-		04BDFF5E12E6671800899322 /* SDL_drawpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawpoint.c; sourceTree = "<group>"; };
-		04BDFF5F12E6671800899322 /* SDL_drawrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawrect.c; sourceTree = "<group>"; };
 		04BDFF6012E6671800899322 /* SDL_fillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_fillrect.c; sourceTree = "<group>"; };
 		04BDFF6112E6671800899322 /* SDL_gamma.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_gamma.c; sourceTree = "<group>"; };
-		04BDFF6212E6671800899322 /* SDL_glesfuncs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_glesfuncs.h; sourceTree = "<group>"; };
-		04BDFF6312E6671800899322 /* SDL_glfuncs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_glfuncs.h; sourceTree = "<group>"; };
 		04BDFF6412E6671800899322 /* SDL_leaks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_leaks.h; sourceTree = "<group>"; };
 		04BDFF6512E6671800899322 /* SDL_pixels.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_pixels.c; sourceTree = "<group>"; };
 		04BDFF6612E6671800899322 /* SDL_pixels_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_pixels_c.h; sourceTree = "<group>"; };
 		04BDFF6712E6671800899322 /* SDL_rect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rect.c; sourceTree = "<group>"; };
-		04BDFF6812E6671800899322 /* SDL_rect_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_rect_c.h; sourceTree = "<group>"; };
-		04BDFF6912E6671800899322 /* SDL_renderer_gl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_gl.c; sourceTree = "<group>"; };
-		04BDFF6A12E6671800899322 /* SDL_renderer_gl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_gl.h; sourceTree = "<group>"; };
-		04BDFF6B12E6671800899322 /* SDL_renderer_gles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_gles.c; sourceTree = "<group>"; };
-		04BDFF6C12E6671800899322 /* SDL_renderer_gles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_gles.h; sourceTree = "<group>"; };
-		04BDFF6D12E6671800899322 /* SDL_renderer_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_sw.c; sourceTree = "<group>"; };
-		04BDFF6E12E6671800899322 /* SDL_renderer_sw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_sw.h; sourceTree = "<group>"; };
 		04BDFF6F12E6671800899322 /* SDL_RLEaccel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_RLEaccel.c; sourceTree = "<group>"; };
 		04BDFF7012E6671800899322 /* SDL_RLEaccel_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_RLEaccel_c.h; sourceTree = "<group>"; };
 		04BDFF7112E6671800899322 /* SDL_shape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_shape.c; sourceTree = "<group>"; };
@@ -880,9 +848,6 @@
 		04BDFF7412E6671800899322 /* SDL_surface.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_surface.c; sourceTree = "<group>"; };
 		04BDFF7512E6671800899322 /* SDL_sysvideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysvideo.h; sourceTree = "<group>"; };
 		04BDFF7612E6671800899322 /* SDL_video.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_video.c; sourceTree = "<group>"; };
-		04BDFF7712E6671800899322 /* SDL_yuv_mmx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_mmx.c; sourceTree = "<group>"; };
-		04BDFF7812E6671800899322 /* SDL_yuv_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_sw.c; sourceTree = "<group>"; };
-		04BDFF7912E6671800899322 /* SDL_yuv_sw_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_yuv_sw_c.h; sourceTree = "<group>"; };
 		04BDFFB812E6671800899322 /* imKStoUCS.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = imKStoUCS.c; sourceTree = "<group>"; };
 		04BDFFB912E6671800899322 /* imKStoUCS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imKStoUCS.h; sourceTree = "<group>"; };
 		04BDFFBA12E6671800899322 /* SDL_x11clipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11clipboard.c; sourceTree = "<group>"; };
@@ -903,8 +868,6 @@
 		04BDFFC912E6671800899322 /* SDL_x11opengl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_x11opengl.h; sourceTree = "<group>"; };
 		04BDFFCA12E6671800899322 /* SDL_x11opengles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11opengles.c; sourceTree = "<group>"; };
 		04BDFFCB12E6671800899322 /* SDL_x11opengles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_x11opengles.h; sourceTree = "<group>"; };
-		04BDFFCC12E6671800899322 /* SDL_x11render.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11render.c; sourceTree = "<group>"; };
-		04BDFFCD12E6671800899322 /* SDL_x11render.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_x11render.h; sourceTree = "<group>"; };
 		04BDFFCE12E6671800899322 /* SDL_x11shape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11shape.c; sourceTree = "<group>"; };
 		04BDFFCF12E6671800899322 /* SDL_x11shape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_x11shape.h; sourceTree = "<group>"; };
 		04BDFFD012E6671800899322 /* SDL_x11sym.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_x11sym.h; sourceTree = "<group>"; };
@@ -917,7 +880,6 @@
 		04BDFFD912E6671800899322 /* extutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = extutil.h; sourceTree = "<group>"; };
 		04BDFFDA12E6671800899322 /* panoramiXext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = panoramiXext.h; sourceTree = "<group>"; };
 		04BDFFDB12E6671800899322 /* panoramiXproto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = panoramiXproto.h; sourceTree = "<group>"; };
-		04BDFFDC12E6671800899322 /* StdCmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StdCmap.h; sourceTree = "<group>"; };
 		04BDFFDD12E6671800899322 /* Xext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Xext.h; sourceTree = "<group>"; };
 		04BDFFDE12E6671800899322 /* xf86dga.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xf86dga.h; sourceTree = "<group>"; };
 		04BDFFDF12E6671800899322 /* xf86dga1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xf86dga1.h; sourceTree = "<group>"; };
@@ -932,19 +894,24 @@
 		04BDFFE812E6671800899322 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
 		04BDFFEA12E6671800899322 /* Xinerama.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Xinerama.c; sourceTree = "<group>"; };
 		04BDFFEC12E6671800899322 /* xme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xme.c; sourceTree = "<group>"; };
-		04BDFFEE12E6671800899322 /* AllCmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = AllCmap.c; sourceTree = "<group>"; };
-		04BDFFEF12E6671800899322 /* CmapAlloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CmapAlloc.c; sourceTree = "<group>"; };
-		04BDFFF012E6671800899322 /* CrCmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CrCmap.c; sourceTree = "<group>"; };
-		04BDFFF112E6671800899322 /* DelCmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DelCmap.c; sourceTree = "<group>"; };
-		04BDFFF212E6671800899322 /* Distinct.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Distinct.c; sourceTree = "<group>"; };
-		04BDFFF312E6671800899322 /* LookupCmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = LookupCmap.c; sourceTree = "<group>"; };
-		04BDFFF412E6671800899322 /* StdCmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = StdCmap.c; sourceTree = "<group>"; };
-		04BDFFF512E6671800899322 /* VisCmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = VisCmap.c; sourceTree = "<group>"; };
 		04BDFFF712E6671800899322 /* Xv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Xv.c; sourceTree = "<group>"; };
 		04BDFFF812E6671800899322 /* Xvlibint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Xvlibint.h; sourceTree = "<group>"; };
 		04BDFFFA12E6671800899322 /* XF86VMode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = XF86VMode.c; sourceTree = "<group>"; };
 		04DEA56F11E6006A00386CAC /* SDL_input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_input.h; path = ../../include/SDL_input.h; sourceTree = SOURCE_ROOT; };
 		04F2AF681104AC4500D6DDF7 /* SDL_assert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_assert.h; path = ../../include/SDL_assert.h; sourceTree = SOURCE_ROOT; };
+		04F7803712FB748500FC43C0 /* SDL_nullframebuffer_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullframebuffer_c.h; sourceTree = "<group>"; };
+		04F7803812FB748500FC43C0 /* SDL_nullframebuffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullframebuffer.c; sourceTree = "<group>"; };
+		04F7803D12FB74A200FC43C0 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = "<group>"; };
+		04F7803E12FB74A200FC43C0 /* SDL_blendfillrect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blendfillrect.h; sourceTree = "<group>"; };
+		04F7803F12FB74A200FC43C0 /* SDL_blendline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendline.c; sourceTree = "<group>"; };
+		04F7804012FB74A200FC43C0 /* SDL_blendline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blendline.h; sourceTree = "<group>"; };
+		04F7804112FB74A200FC43C0 /* SDL_blendpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendpoint.c; sourceTree = "<group>"; };
+		04F7804212FB74A200FC43C0 /* SDL_blendpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blendpoint.h; sourceTree = "<group>"; };
+		04F7804312FB74A200FC43C0 /* SDL_draw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_draw.h; sourceTree = "<group>"; };
+		04F7804412FB74A200FC43C0 /* SDL_drawline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawline.c; sourceTree = "<group>"; };
+		04F7804512FB74A200FC43C0 /* SDL_drawline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_drawline.h; sourceTree = "<group>"; };
+		04F7804612FB74A200FC43C0 /* SDL_drawpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawpoint.c; sourceTree = "<group>"; };
+		04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_drawpoint.h; sourceTree = "<group>"; };
 		0C5AF5E501191D2B7F000001 /* begin_code.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = begin_code.h; path = ../../include/begin_code.h; sourceTree = SOURCE_ROOT; };
 		0C5AF5E601191D2B7F000001 /* close_code.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = close_code.h; path = ../../include/close_code.h; sourceTree = SOURCE_ROOT; };
 		0C5AF5E801191D2B7F000001 /* SDL_audio.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SDL_audio.h; path = ../../include/SDL_audio.h; sourceTree = SOURCE_ROOT; };
@@ -969,7 +936,6 @@
 		0C5AF5FE01191D2B7F000001 /* SDL_video.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SDL_video.h; path = ../../include/SDL_video.h; sourceTree = SOURCE_ROOT; };
 		0C5AF5FF01191D2B7F000001 /* SDL.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SDL.h; path = ../../include/SDL.h; sourceTree = SOURCE_ROOT; };
 		453773811207C518002F0F45 /* SDL_shape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_shape.h; path = ../../include/SDL_shape.h; sourceTree = SOURCE_ROOT; };
-		8C93F0EA11F803710014F54D /* gestureSDLTest-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "gestureSDLTest-Info.plist"; sourceTree = "<group>"; };
 		8CB0A77611F6A87F00CBA2DE /* SDL_gesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_gesture.h; path = ../../include/SDL_gesture.h; sourceTree = SOURCE_ROOT; };
 		8CB0A77711F6A87F00CBA2DE /* SDL_touch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_touch.h; path = ../../include/SDL_touch.h; sourceTree = SOURCE_ROOT; };
 		B29A290D04E5B28700A80002 /* SDL_loadso.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SDL_loadso.h; path = ../../include/SDL_loadso.h; sourceTree = "<group>"; };
@@ -1165,6 +1131,7 @@
 				0C5AF5EE01191D2B7F000001 /* SDL_events.h */,
 				8CB0A77611F6A87F00CBA2DE /* SDL_gesture.h */,
 				00CFA67C106B44CE00758660 /* SDL_haptic.h */,
+				0442EC1212FE1B79004C9285 /* SDL_hints.h */,
 				04DEA56F11E6006A00386CAC /* SDL_input.h */,
 				0C5AF5F001191D2B7F000001 /* SDL_joystick.h */,
 				0C5AF5F101191D2B7F000001 /* SDL_keyboard.h */,
@@ -1180,9 +1147,9 @@
 				00CFA67E106B44CE00758660 /* SDL_power.h */,
 				0C5AF5F701191D2B7F000001 /* SDL_quit.h */,
 				00CFA67F106B44CE00758660 /* SDL_rect.h */,
+				041B2C9412FA0D2A0087D585 /* SDL_render.h */,
 				00A6EBD91078D569001EEA06 /* SDL_revision.h */,
 				0C5AF5F801191D2B7F000001 /* SDL_rwops.h */,
-				0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */,
 				00CFA680106B44CE00758660 /* SDL_scancode.h */,
 				453773811207C518002F0F45 /* SDL_shape.h */,
 				00162D3909BD1FA90037C8D0 /* SDL_stdinc.h */,
@@ -1211,6 +1178,51 @@
 			name = Products;
 			sourceTree = "<group>";
 		};
+		041B2C9712FA0D680087D585 /* render */ = {
+			isa = PBXGroup;
+			children = (
+				041B2C9A12FA0D680087D585 /* opengl */,
+				041B2CA012FA0D680087D585 /* software */,
+				04409B8D12FA97ED00FB9AA8 /* mmx.h */,
+				041B2C9E12FA0D680087D585 /* SDL_render.c */,
+				041B2C9F12FA0D680087D585 /* SDL_sysrender.h */,
+				04409B8E12FA97ED00FB9AA8 /* SDL_yuv_mmx.c */,
+				04409B8F12FA97ED00FB9AA8 /* SDL_yuv_sw_c.h */,
+				04409B9012FA97ED00FB9AA8 /* SDL_yuv_sw.c */,
+			);
+			name = render;
+			path = ../../src/render;
+			sourceTree = SOURCE_ROOT;
+		};
+		041B2C9A12FA0D680087D585 /* opengl */ = {
+			isa = PBXGroup;
+			children = (
+				04043BBA12FEB1BE0076DB1F /* SDL_glfuncs.h */,
+				0442EC1712FE1BBA004C9285 /* SDL_render_gl.c */,
+			);
+			path = opengl;
+			sourceTree = "<group>";
+		};
+		041B2CA012FA0D680087D585 /* software */ = {
+			isa = PBXGroup;
+			children = (
+				04F7803D12FB74A200FC43C0 /* SDL_blendfillrect.c */,
+				04F7803E12FB74A200FC43C0 /* SDL_blendfillrect.h */,
+				04F7803F12FB74A200FC43C0 /* SDL_blendline.c */,
+				04F7804012FB74A200FC43C0 /* SDL_blendline.h */,
+				04F7804112FB74A200FC43C0 /* SDL_blendpoint.c */,
+				04F7804212FB74A200FC43C0 /* SDL_blendpoint.h */,
+				04F7804312FB74A200FC43C0 /* SDL_draw.h */,
+				04F7804412FB74A200FC43C0 /* SDL_drawline.c */,
+				04F7804512FB74A200FC43C0 /* SDL_drawline.h */,
+				04F7804612FB74A200FC43C0 /* SDL_drawpoint.c */,
+				04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */,
+				0442EC1A12FE1BCB004C9285 /* SDL_render_sw_c.h */,
+				0442EC1B12FE1BCB004C9285 /* SDL_render_sw.c */,
+			);
+			path = software;
+			sourceTree = "<group>";
+		};
 		04BDFD7312E6671700899322 /* atomic */ = {
 			isa = PBXGroup;
 			children = (
@@ -1292,7 +1304,6 @@
 				04BDFDD712E6671700899322 /* default_cursor.h */,
 				04BDFDD812E6671700899322 /* scancodes_darwin.h */,
 				04BDFDD912E6671700899322 /* scancodes_linux.h */,
-				04BDFDDA12E6671700899322 /* scancodes_win32.h */,
 				04BDFDDB12E6671700899322 /* scancodes_xfree86.h */,
 				04BDFDDC12E6671700899322 /* SDL_clipboardevents.c */,
 				04BDFDDD12E6671700899322 /* SDL_clipboardevents_c.h */,
@@ -1462,7 +1473,6 @@
 			isa = PBXGroup;
 			children = (
 				04BDFEA112E6671800899322 /* unix */,
-				04BDFE9E12E6671800899322 /* SDL_systimer.h */,
 				04BDFE9F12E6671800899322 /* SDL_timer.c */,
 				04BDFEA012E6671800899322 /* SDL_timer_c.h */,
 			);
@@ -1485,13 +1495,6 @@
 				04BDFEE712E6671800899322 /* dummy */,
 				04BDFFB712E6671800899322 /* x11 */,
 				04BDFFD712E6671800899322 /* Xext */,
-				04BDFF0412E6671800899322 /* mmx.h */,
-				04BDFF4812E6671800899322 /* SDL_alphamult.c */,
-				04BDFF4912E6671800899322 /* SDL_alphamult.h */,
-				04BDFF4A12E6671800899322 /* SDL_blendfillrect.c */,
-				04BDFF4B12E6671800899322 /* SDL_blendline.c */,
-				04BDFF4C12E6671800899322 /* SDL_blendpoint.c */,
-				04BDFF4D12E6671800899322 /* SDL_blendrect.c */,
 				04BDFF4E12E6671800899322 /* SDL_blit.c */,
 				04BDFF4F12E6671800899322 /* SDL_blit.h */,
 				04BDFF5012E6671800899322 /* SDL_blit_0.c */,
@@ -1506,25 +1509,12 @@
 				04BDFF5912E6671800899322 /* SDL_blit_slow.h */,
 				04BDFF5A12E6671800899322 /* SDL_bmp.c */,
 				04BDFF5B12E6671800899322 /* SDL_clipboard.c */,
-				04BDFF5C12E6671800899322 /* SDL_draw.h */,
-				04BDFF5D12E6671800899322 /* SDL_drawline.c */,
-				04BDFF5E12E6671800899322 /* SDL_drawpoint.c */,
-				04BDFF5F12E6671800899322 /* SDL_drawrect.c */,
 				04BDFF6012E6671800899322 /* SDL_fillrect.c */,
 				04BDFF6112E6671800899322 /* SDL_gamma.c */,
-				04BDFF6212E6671800899322 /* SDL_glesfuncs.h */,
-				04BDFF6312E6671800899322 /* SDL_glfuncs.h */,
 				04BDFF6412E6671800899322 /* SDL_leaks.h */,
 				04BDFF6512E6671800899322 /* SDL_pixels.c */,
 				04BDFF6612E6671800899322 /* SDL_pixels_c.h */,
 				04BDFF6712E6671800899322 /* SDL_rect.c */,
-				04BDFF6812E6671800899322 /* SDL_rect_c.h */,
-				04BDFF6912E6671800899322 /* SDL_renderer_gl.c */,
-				04BDFF6A12E6671800899322 /* SDL_renderer_gl.h */,
-				04BDFF6B12E6671800899322 /* SDL_renderer_gles.c */,
-				04BDFF6C12E6671800899322 /* SDL_renderer_gles.h */,
-				04BDFF6D12E6671800899322 /* SDL_renderer_sw.c */,
-				04BDFF6E12E6671800899322 /* SDL_renderer_sw.h */,
 				04BDFF6F12E6671800899322 /* SDL_RLEaccel.c */,
 				04BDFF7012E6671800899322 /* SDL_RLEaccel_c.h */,
 				04BDFF7112E6671800899322 /* SDL_shape.c */,
@@ -1533,9 +1523,6 @@
 				04BDFF7412E6671800899322 /* SDL_surface.c */,
 				04BDFF7512E6671800899322 /* SDL_sysvideo.h */,
 				04BDFF7612E6671800899322 /* SDL_video.c */,
-				04BDFF7712E6671800899322 /* SDL_yuv_mmx.c */,
-				04BDFF7812E6671800899322 /* SDL_yuv_sw.c */,
-				04BDFF7912E6671800899322 /* SDL_yuv_sw_c.h */,
 			);
 			name = video;
 			path = ../../src/video;
@@ -1571,8 +1558,8 @@
 			children = (
 				04BDFEE812E6671800899322 /* SDL_nullevents.c */,
 				04BDFEE912E6671800899322 /* SDL_nullevents_c.h */,
-				04BDFEEA12E6671800899322 /* SDL_nullrender.c */,
-				04BDFEEB12E6671800899322 /* SDL_nullrender_c.h */,
+				04F7803712FB748500FC43C0 /* SDL_nullframebuffer_c.h */,
+				04F7803812FB748500FC43C0 /* SDL_nullframebuffer.c */,
 				04BDFEEC12E6671800899322 /* SDL_nullvideo.c */,
 				04BDFEED12E6671800899322 /* SDL_nullvideo.h */,
 			);
@@ -1590,6 +1577,8 @@
 				04BDFFBD12E6671800899322 /* SDL_x11dyn.h */,
 				04BDFFBE12E6671800899322 /* SDL_x11events.c */,
 				04BDFFBF12E6671800899322 /* SDL_x11events.h */,
+				0442EC5812FE1C60004C9285 /* SDL_x11framebuffer.c */,
+				0442EC5912FE1C60004C9285 /* SDL_x11framebuffer.h */,
 				04BDFFC012E6671800899322 /* SDL_x11gamma.c */,
 				04BDFFC112E6671800899322 /* SDL_x11gamma.h */,
 				04BDFFC212E6671800899322 /* SDL_x11keyboard.c */,
@@ -1602,8 +1591,6 @@
 				04BDFFC912E6671800899322 /* SDL_x11opengl.h */,
 				04BDFFCA12E6671800899322 /* SDL_x11opengles.c */,
 				04BDFFCB12E6671800899322 /* SDL_x11opengles.h */,
-				04BDFFCC12E6671800899322 /* SDL_x11render.c */,
-				04BDFFCD12E6671800899322 /* SDL_x11render.h */,
 				04BDFFCE12E6671800899322 /* SDL_x11shape.c */,
 				04BDFFCF12E6671800899322 /* SDL_x11shape.h */,
 				04BDFFD012E6671800899322 /* SDL_x11sym.h */,
@@ -1624,7 +1611,6 @@
 				04BDFFE812E6671800899322 /* README */,
 				04BDFFE912E6671800899322 /* Xinerama */,
 				04BDFFEB12E6671800899322 /* XME */,
-				04BDFFED12E6671800899322 /* XmuStdCmap */,
 				04BDFFF612E6671800899322 /* Xv */,
 				04BDFFF912E6671800899322 /* Xxf86vm */,
 			);
@@ -1637,7 +1623,6 @@
 				04BDFFD912E6671800899322 /* extutil.h */,
 				04BDFFDA12E6671800899322 /* panoramiXext.h */,
 				04BDFFDB12E6671800899322 /* panoramiXproto.h */,
-				04BDFFDC12E6671800899322 /* StdCmap.h */,
 				04BDFFDD12E6671800899322 /* Xext.h */,
 				04BDFFDE12E6671800899322 /* xf86dga.h */,
 				04BDFFDF12E6671800899322 /* xf86dga1.h */,
@@ -1669,21 +1654,6 @@
 			path = XME;
 			sourceTree = "<group>";
 		};
-		04BDFFED12E6671800899322 /* XmuStdCmap */ = {
-			isa = PBXGroup;
-			children = (
-				04BDFFEE12E6671800899322 /* AllCmap.c */,
-				04BDFFEF12E6671800899322 /* CmapAlloc.c */,
-				04BDFFF012E6671800899322 /* CrCmap.c */,
-				04BDFFF112E6671800899322 /* DelCmap.c */,
-				04BDFFF212E6671800899322 /* Distinct.c */,
-				04BDFFF312E6671800899322 /* LookupCmap.c */,
-				04BDFFF412E6671800899322 /* StdCmap.c */,
-				04BDFFF512E6671800899322 /* VisCmap.c */,
-			);
-			path = XmuStdCmap;
-			sourceTree = "<group>";
-		};
 		04BDFFF612E6671800899322 /* Xv */ = {
 			isa = PBXGroup;
 			children = (
@@ -1715,7 +1685,6 @@
 				BECDF66B0761BA81005FE872 /* Info-Framework.plist */,
 				BEC562FE0761C0E800A33029 /* Linked Frameworks */,
 				00D8D9F11195090700638393 /* testsdl-Info.plist */,
-				8C93F0EA11F803710014F54D /* gestureSDLTest-Info.plist */,
 			);
 			comments = "To build Universal Binaries, we have experimented with a variety of different options.\nThe complication is that we must retain compatibility with at least 10.2. \nThe Universal Binary defaults only work for > 10.3.9\n\nSo far, we have found:\ngcc 4.0.0 with Xcode 2.1 always links against libgcc_s. gcc 4.0.1 from Xcode 2.2 fixes this problem.\n\nBut gcc 4.0 will not work with < 10.3.9 because we continue to get an undefined symbol to _fprintf$LDBL128.\nSo we must use gcc 3.3 on PPC to accomplish 10.2 support. (But 4.0 is required for i386.)\n\nSetting the deployment target to 10.4 will disable prebinding, so for PPC, we set it less than 10.4 to preserve prebinding for legacy support.\n\nSetting the PPC SDKROOT to /Developers/SDKs/MacOSX10.2.8.sdk will link to 63.0.0 libSystem.B.dylib. Leaving it at current or 10.4u links to 88.1.2. However, as long as we are using gcc 3.3, it doesn't seem to matter as testing has demonstrated both will run. We have decided not to invoke the 10.2.8 SDK because it is not a default installed component with Xcode which will probably cause most people problems. However, rather than deleting the SDKROOT_ppc entry entirely, we have mapped it to 10.4u in case we decide we need to change this setting.\n\nTo use Altivec or SSE, we needed architecture specific flags:\nOTHER_CFLAGS_ppc\nOTHER_CFLAGS_i386\nOTHER_CFLAGS=$(OTHER_CFLAGS_($CURRENT_ARCH))\n\nThe general OTHER_CFLAGS needed to be manually mapped to architecture specific options because Xcode didn't do this automatically for us.\n\n\n";
 			name = SDLFramework;
@@ -1740,6 +1709,7 @@
 				04BDFDFF12E6671700899322 /* joystick */,
 				04BDFE2F12E6671700899322 /* loadso */,
 				04BDFE4512E6671700899322 /* power */,
+				041B2C9712FA0D680087D585 /* render */,
 				04BDFE5D12E6671700899322 /* stdlib */,
 				04BDFE6412E6671800899322 /* thread */,
 				04BDFE9512E6671800899322 /* timer */,
@@ -1751,6 +1721,7 @@
 				04BDFE5912E6671700899322 /* SDL_error.c */,
 				04BDFE5A12E6671700899322 /* SDL_fatal.c */,
 				04BDFE5B12E6671700899322 /* SDL_fatal.h */,
+				0442EC5E12FE1C75004C9285 /* SDL_hints.c */,
 				04BDFE5C12E6671700899322 /* SDL.c */,
 			);
 			name = "Library Source";
@@ -1872,7 +1843,6 @@
 				04BD004312E6671800899322 /* default_cursor.h in Headers */,
 				04BD004412E6671800899322 /* scancodes_darwin.h in Headers */,
 				04BD004512E6671800899322 /* scancodes_linux.h in Headers */,
-				04BD004612E6671800899322 /* scancodes_win32.h in Headers */,
 				04BD004712E6671800899322 /* scancodes_xfree86.h in Headers */,
 				04BD004912E6671800899322 /* SDL_clipboardevents_c.h in Headers */,
 				04BD004B12E6671800899322 /* SDL_events_c.h in Headers */,
@@ -1895,7 +1865,6 @@
 				04BD00C212E6671800899322 /* SDL_systhread_c.h in Headers */,
 				04BD00C912E6671800899322 /* SDL_systhread.h in Headers */,
 				04BD00CB12E6671800899322 /* SDL_thread_c.h in Headers */,
-				04BD00D612E6671800899322 /* SDL_systimer.h in Headers */,
 				04BD00D812E6671800899322 /* SDL_timer_c.h in Headers */,
 				04BD00F312E6671800899322 /* SDL_cocoaclipboard.h in Headers */,
 				04BD00F512E6671800899322 /* SDL_cocoaevents.h in Headers */,
@@ -1907,27 +1876,16 @@
 				04BD010112E6671800899322 /* SDL_cocoavideo.h in Headers */,
 				04BD010312E6671800899322 /* SDL_cocoawindow.h in Headers */,
 				04BD011812E6671800899322 /* SDL_nullevents_c.h in Headers */,
-				04BD011A12E6671800899322 /* SDL_nullrender_c.h in Headers */,
 				04BD011C12E6671800899322 /* SDL_nullvideo.h in Headers */,
-				04BD013212E6671800899322 /* mmx.h in Headers */,
-				04BD017012E6671800899322 /* SDL_alphamult.h in Headers */,
 				04BD017612E6671800899322 /* SDL_blit.h in Headers */,
 				04BD017B12E6671800899322 /* SDL_blit_auto.h in Headers */,
 				04BD017D12E6671800899322 /* SDL_blit_copy.h in Headers */,
 				04BD018012E6671800899322 /* SDL_blit_slow.h in Headers */,
-				04BD018312E6671800899322 /* SDL_draw.h in Headers */,
-				04BD018912E6671800899322 /* SDL_glesfuncs.h in Headers */,
-				04BD018A12E6671800899322 /* SDL_glfuncs.h in Headers */,
 				04BD018B12E6671800899322 /* SDL_leaks.h in Headers */,
 				04BD018D12E6671800899322 /* SDL_pixels_c.h in Headers */,
-				04BD018F12E6671800899322 /* SDL_rect_c.h in Headers */,
-				04BD019112E6671800899322 /* SDL_renderer_gl.h in Headers */,
-				04BD019312E6671800899322 /* SDL_renderer_gles.h in Headers */,
-				04BD019512E6671800899322 /* SDL_renderer_sw.h in Headers */,
 				04BD019712E6671800899322 /* SDL_RLEaccel_c.h in Headers */,
 				04BD019912E6671800899322 /* SDL_shape_internals.h in Headers */,
 				04BD019C12E6671800899322 /* SDL_sysvideo.h in Headers */,
-				04BD01A012E6671800899322 /* SDL_yuv_sw_c.h in Headers */,
 				04BD01DC12E6671800899322 /* imKStoUCS.h in Headers */,
 				04BD01DE12E6671800899322 /* SDL_x11clipboard.h in Headers */,
 				04BD01E012E6671800899322 /* SDL_x11dyn.h in Headers */,
@@ -1938,7 +1896,6 @@
 				04BD01EA12E6671800899322 /* SDL_x11mouse.h in Headers */,
 				04BD01EC12E6671800899322 /* SDL_x11opengl.h in Headers */,
 				04BD01EE12E6671800899322 /* SDL_x11opengles.h in Headers */,
-				04BD01F012E6671800899322 /* SDL_x11render.h in Headers */,
 				04BD01F212E6671800899322 /* SDL_x11shape.h in Headers */,
 				04BD01F312E6671800899322 /* SDL_x11sym.h in Headers */,
 				04BD01F512E6671800899322 /* SDL_x11touch.h in Headers */,
@@ -1947,7 +1904,6 @@
 				04BD01FA12E6671800899322 /* extutil.h in Headers */,
 				04BD01FB12E6671800899322 /* panoramiXext.h in Headers */,
 				04BD01FC12E6671800899322 /* panoramiXproto.h in Headers */,
-				04BD01FD12E6671800899322 /* StdCmap.h in Headers */,
 				04BD01FE12E6671800899322 /* Xext.h in Headers */,
 				04BD01FF12E6671800899322 /* xf86dga.h in Headers */,
 				04BD020012E6671800899322 /* xf86dga1.h in Headers */,
@@ -1961,7 +1917,21 @@
 				04BD020812E6671800899322 /* Xvproto.h in Headers */,
 				04BD021512E6671800899322 /* Xvlibint.h in Headers */,
 				0469A10B12EE4BF100B846D6 /* SDL_blendmode.h in Headers */,
-				0469A10C12EE4BF100B846D6 /* SDL_scalemode.h in Headers */,
+				041B2C9512FA0D2A0087D585 /* SDL_render.h in Headers */,
+				041B2CA612FA0D680087D585 /* SDL_sysrender.h in Headers */,
+				04409B9112FA97ED00FB9AA8 /* mmx.h in Headers */,
+				04409B9312FA97ED00FB9AA8 /* SDL_yuv_sw_c.h in Headers */,
+				04F7803912FB748500FC43C0 /* SDL_nullframebuffer_c.h in Headers */,
+				04F7804A12FB74A200FC43C0 /* SDL_blendfillrect.h in Headers */,
+				04F7804C12FB74A200FC43C0 /* SDL_blendline.h in Headers */,
+				04F7804E12FB74A200FC43C0 /* SDL_blendpoint.h in Headers */,
+				04F7804F12FB74A200FC43C0 /* SDL_draw.h in Headers */,
+				04F7805112FB74A200FC43C0 /* SDL_drawline.h in Headers */,
+				04F7805312FB74A200FC43C0 /* SDL_drawpoint.h in Headers */,
+				0442EC1312FE1B79004C9285 /* SDL_hints.h in Headers */,
+				0442EC1C12FE1BCB004C9285 /* SDL_render_sw_c.h in Headers */,
+				0442EC5B12FE1C60004C9285 /* SDL_x11framebuffer.h in Headers */,
+				04043BBB12FEB1BE0076DB1F /* SDL_glfuncs.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2002,7 +1972,6 @@
 				04BD025E12E6671800899322 /* default_cursor.h in Headers */,
 				04BD025F12E6671800899322 /* scancodes_darwin.h in Headers */,
 				04BD026012E6671800899322 /* scancodes_linux.h in Headers */,
-				04BD026112E6671800899322 /* scancodes_win32.h in Headers */,
 				04BD026212E6671800899322 /* scancodes_xfree86.h in Headers */,
 				04BD026412E6671800899322 /* SDL_clipboardevents_c.h in Headers */,
 				04BD026612E6671800899322 /* SDL_events_c.h in Headers */,
@@ -2025,7 +1994,6 @@
 				04BD02DC12E6671800899322 /* SDL_systhread_c.h in Headers */,
 				04BD02E312E6671800899322 /* SDL_systhread.h in Headers */,
 				04BD02E512E6671800899322 /* SDL_thread_c.h in Headers */,
-				04BD02F012E6671800899322 /* SDL_systimer.h in Headers */,
 				04BD02F212E6671800899322 /* SDL_timer_c.h in Headers */,
 				04BD030D12E6671800899322 /* SDL_cocoaclipboard.h in Headers */,
 				04BD030F12E6671800899322 /* SDL_cocoaevents.h in Headers */,
@@ -2037,27 +2005,16 @@
 				04BD031B12E6671800899322 /* SDL_cocoavideo.h in Headers */,
 				04BD031D12E6671800899322 /* SDL_cocoawindow.h in Headers */,
 				04BD033212E6671800899322 /* SDL_nullevents_c.h in Headers */,
-				04BD033412E6671800899322 /* SDL_nullrender_c.h in Headers */,
 				04BD033612E6671800899322 /* SDL_nullvideo.h in Headers */,
-				04BD034C12E6671800899322 /* mmx.h in Headers */,
-				04BD038A12E6671800899322 /* SDL_alphamult.h in Headers */,
 				04BD039012E6671800899322 /* SDL_blit.h in Headers */,
 				04BD039512E6671800899322 /* SDL_blit_auto.h in Headers */,
 				04BD039712E6671800899322 /* SDL_blit_copy.h in Headers */,
 				04BD039A12E6671800899322 /* SDL_blit_slow.h in Headers */,
-				04BD039D12E6671800899322 /* SDL_draw.h in Headers */,
-				04BD03A312E6671800899322 /* SDL_glesfuncs.h in Headers */,
-				04BD03A412E6671800899322 /* SDL_glfuncs.h in Headers */,
 				04BD03A512E6671800899322 /* SDL_leaks.h in Headers */,
 				04BD03A712E6671800899322 /* SDL_pixels_c.h in Headers */,
-				04BD03A912E6671800899322 /* SDL_rect_c.h in Headers */,
-				04BD03AB12E6671800899322 /* SDL_renderer_gl.h in Headers */,
-				04BD03AD12E6671800899322 /* SDL_renderer_gles.h in Headers */,
-				04BD03AF12E6671800899322 /* SDL_renderer_sw.h in Headers */,
 				04BD03B112E6671800899322 /* SDL_RLEaccel_c.h in Headers */,
 				04BD03B312E6671800899322 /* SDL_shape_internals.h in Headers */,
 				04BD03B612E6671800899322 /* SDL_sysvideo.h in Headers */,
-				04BD03BA12E6671800899322 /* SDL_yuv_sw_c.h in Headers */,
 				04BD03F412E6671800899322 /* imKStoUCS.h in Headers */,
 				04BD03F612E6671800899322 /* SDL_x11clipboard.h in Headers */,
 				04BD03F812E6671800899322 /* SDL_x11dyn.h in Headers */,
@@ -2068,7 +2025,6 @@
 				04BD040212E6671800899322 /* SDL_x11mouse.h in Headers */,
 				04BD040412E6671800899322 /* SDL_x11opengl.h in Headers */,
 				04BD040612E6671800899322 /* SDL_x11opengles.h in Headers */,
-				04BD040812E6671800899322 /* SDL_x11render.h in Headers */,
 				04BD040A12E6671800899322 /* SDL_x11shape.h in Headers */,
 				04BD040B12E6671800899322 /* SDL_x11sym.h in Headers */,
 				04BD040D12E6671800899322 /* SDL_x11touch.h in Headers */,
@@ -2077,7 +2033,6 @@
 				04BD041212E6671800899322 /* extutil.h in Headers */,
 				04BD041312E6671800899322 /* panoramiXext.h in Headers */,
 				04BD041412E6671800899322 /* panoramiXproto.h in Headers */,
-				04BD041512E6671800899322 /* StdCmap.h in Headers */,
 				04BD041612E6671800899322 /* Xext.h in Headers */,
 				04BD041712E6671800899322 /* xf86dga.h in Headers */,
 				04BD041812E6671800899322 /* xf86dga1.h in Headers */,
@@ -2091,7 +2046,21 @@
 				04BD042012E6671800899322 /* Xvproto.h in Headers */,
 				04BD042C12E6671800899322 /* Xvlibint.h in Headers */,
 				0469A10D12EE4BF100B846D6 /* SDL_blendmode.h in Headers */,
-				0469A10E12EE4BF100B846D6 /* SDL_scalemode.h in Headers */,
+				041B2C9612FA0D2A0087D585 /* SDL_render.h in Headers */,
+				041B2CAC12FA0D680087D585 /* SDL_sysrender.h in Headers */,
+				04409B9512FA97ED00FB9AA8 /* mmx.h in Headers */,
+				04409B9712FA97ED00FB9AA8 /* SDL_yuv_sw_c.h in Headers */,
+				04F7803B12FB748500FC43C0 /* SDL_nullframebuffer_c.h in Headers */,
+				04F7805612FB74A200FC43C0 /* SDL_blendfillrect.h in Headers */,
+				04F7805812FB74A200FC43C0 /* SDL_blendline.h in Headers */,
+				04F7805A12FB74A200FC43C0 /* SDL_blendpoint.h in Headers */,
+				04F7805B12FB74A200FC43C0 /* SDL_draw.h in Headers */,
+				04F7805D12FB74A200FC43C0 /* SDL_drawline.h in Headers */,
+				04F7805F12FB74A200FC43C0 /* SDL_drawpoint.h in Headers */,
+				0442EC1412FE1B79004C9285 /* SDL_hints.h in Headers */,
+				0442EC1E12FE1BCB004C9285 /* SDL_render_sw_c.h in Headers */,
+				0442EC5D12FE1C60004C9285 /* SDL_x11framebuffer.h in Headers */,
+				04043BBC12FEB1BE0076DB1F /* SDL_glfuncs.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2411,13 +2380,7 @@
 				04BD010212E6671800899322 /* SDL_cocoavideo.m in Sources */,
 				04BD010412E6671800899322 /* SDL_cocoawindow.m in Sources */,
 				04BD011712E6671800899322 /* SDL_nullevents.c in Sources */,
-				04BD011912E6671800899322 /* SDL_nullrender.c in Sources */,
 				04BD011B12E6671800899322 /* SDL_nullvideo.c in Sources */,
-				04BD016F12E6671800899322 /* SDL_alphamult.c in Sources */,
-				04BD017112E6671800899322 /* SDL_blendfillrect.c in Sources */,
-				04BD017212E6671800899322 /* SDL_blendline.c in Sources */,
-				04BD017312E6671800899322 /* SDL_blendpoint.c in Sources */,
-				04BD017412E6671800899322 /* SDL_blendrect.c in Sources */,
 				04BD017512E6671800899322 /* SDL_blit.c in Sources */,
 				04BD017712E6671800899322 /* SDL_blit_0.c in Sources */,
 				04BD017812E6671800899322 /* SDL_blit_1.c in Sources */,
@@ -2428,23 +2391,15 @@
 				04BD017F12E6671800899322 /* SDL_blit_slow.c in Sources */,
 				04BD018112E6671800899322 /* SDL_bmp.c in Sources */,
 				04BD018212E6671800899322 /* SDL_clipboard.c in Sources */,
-				04BD018412E6671800899322 /* SDL_drawline.c in Sources */,
-				04BD018512E6671800899322 /* SDL_drawpoint.c in Sources */,
-				04BD018612E6671800899322 /* SDL_drawrect.c in Sources */,
 				04BD018712E6671800899322 /* SDL_fillrect.c in Sources */,
 				04BD018812E6671800899322 /* SDL_gamma.c in Sources */,
 				04BD018C12E6671800899322 /* SDL_pixels.c in Sources */,
 				04BD018E12E6671800899322 /* SDL_rect.c in Sources */,
-				04BD019012E6671800899322 /* SDL_renderer_gl.c in Sources */,
-				04BD019212E6671800899322 /* SDL_renderer_gles.c in Sources */,
-				04BD019412E6671800899322 /* SDL_renderer_sw.c in Sources */,
 				04BD019612E6671800899322 /* SDL_RLEaccel.c in Sources */,
 				04BD019812E6671800899322 /* SDL_shape.c in Sources */,
 				04BD019A12E6671800899322 /* SDL_stretch.c in Sources */,
 				04BD019B12E6671800899322 /* SDL_surface.c in Sources */,
 				04BD019D12E6671800899322 /* SDL_video.c in Sources */,
-				04BD019E12E6671800899322 /* SDL_yuv_mmx.c in Sources */,
-				04BD019F12E6671800899322 /* SDL_yuv_sw.c in Sources */,
 				04BD01DB12E6671800899322 /* imKStoUCS.c in Sources */,
 				04BD01DD12E6671800899322 /* SDL_x11clipboard.c in Sources */,
 				04BD01DF12E6671800899322 /* SDL_x11dyn.c in Sources */,
@@ -2455,23 +2410,27 @@
 				04BD01E912E6671800899322 /* SDL_x11mouse.c in Sources */,
 				04BD01EB12E6671800899322 /* SDL_x11opengl.c in Sources */,
 				04BD01ED12E6671800899322 /* SDL_x11opengles.c in Sources */,
-				04BD01EF12E6671800899322 /* SDL_x11render.c in Sources */,
 				04BD01F112E6671800899322 /* SDL_x11shape.c in Sources */,
 				04BD01F412E6671800899322 /* SDL_x11touch.c in Sources */,
 				04BD01F612E6671800899322 /* SDL_x11video.c in Sources */,
 				04BD01F812E6671800899322 /* SDL_x11window.c in Sources */,
 				04BD020A12E6671800899322 /* Xinerama.c in Sources */,
 				04BD020B12E6671800899322 /* xme.c in Sources */,
-				04BD020C12E6671800899322 /* AllCmap.c in Sources */,
-				04BD020D12E6671800899322 /* CmapAlloc.c in Sources */,
-				04BD020E12E6671800899322 /* CrCmap.c in Sources */,
-				04BD020F12E6671800899322 /* DelCmap.c in Sources */,
-				04BD021012E6671800899322 /* Distinct.c in Sources */,
-				04BD021112E6671800899322 /* LookupCmap.c in Sources */,
-				04BD021212E6671800899322 /* StdCmap.c in Sources */,
-				04BD021312E6671800899322 /* VisCmap.c in Sources */,
 				04BD021412E6671800899322 /* Xv.c in Sources */,
 				04BD021612E6671800899322 /* XF86VMode.c in Sources */,
+				041B2CA512FA0D680087D585 /* SDL_render.c in Sources */,
+				04409B9212FA97ED00FB9AA8 /* SDL_yuv_mmx.c in Sources */,
+				04409B9412FA97ED00FB9AA8 /* SDL_yuv_sw.c in Sources */,
+				04F7803A12FB748500FC43C0 /* SDL_nullframebuffer.c in Sources */,
+				04F7804912FB74A200FC43C0 /* SDL_blendfillrect.c in Sources */,
+				04F7804B12FB74A200FC43C0 /* SDL_blendline.c in Sources */,
+				04F7804D12FB74A200FC43C0 /* SDL_blendpoint.c in Sources */,
+				04F7805012FB74A200FC43C0 /* SDL_drawline.c in Sources */,
+				04F7805212FB74A200FC43C0 /* SDL_drawpoint.c in Sources */,
+				0442EC1812FE1BBA004C9285 /* SDL_render_gl.c in Sources */,
+				0442EC1D12FE1BCB004C9285 /* SDL_render_sw.c in Sources */,
+				0442EC5A12FE1C60004C9285 /* SDL_x11framebuffer.c in Sources */,
+				0442EC5F12FE1C75004C9285 /* SDL_hints.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2540,13 +2499,7 @@
 				04BD031C12E6671800899322 /* SDL_cocoavideo.m in Sources */,
 				04BD031E12E6671800899322 /* SDL_cocoawindow.m in Sources */,
 				04BD033112E6671800899322 /* SDL_nullevents.c in Sources */,
-				04BD033312E6671800899322 /* SDL_nullrender.c in Sources */,
 				04BD033512E6671800899322 /* SDL_nullvideo.c in Sources */,
-				04BD038912E6671800899322 /* SDL_alphamult.c in Sources */,
-				04BD038B12E6671800899322 /* SDL_blendfillrect.c in Sources */,
-				04BD038C12E6671800899322 /* SDL_blendline.c in Sources */,
-				04BD038D12E6671800899322 /* SDL_blendpoint.c in Sources */,
-				04BD038E12E6671800899322 /* SDL_blendrect.c in Sources */,
 				04BD038F12E6671800899322 /* SDL_blit.c in Sources */,
 				04BD039112E6671800899322 /* SDL_blit_0.c in Sources */,
 				04BD039212E6671800899322 /* SDL_blit_1.c in Sources */,
@@ -2557,23 +2510,15 @@
 				04BD039912E6671800899322 /* SDL_blit_slow.c in Sources */,
 				04BD039B12E6671800899322 /* SDL_bmp.c in Sources */,
 				04BD039C12E6671800899322 /* SDL_clipboard.c in Sources */,
-				04BD039E12E6671800899322 /* SDL_drawline.c in Sources */,
-				04BD039F12E6671800899322 /* SDL_drawpoint.c in Sources */,
-				04BD03A012E6671800899322 /* SDL_drawrect.c in Sources */,
 				04BD03A112E6671800899322 /* SDL_fillrect.c in Sources */,
 				04BD03A212E6671800899322 /* SDL_gamma.c in Sources */,
 				04BD03A612E6671800899322 /* SDL_pixels.c in Sources */,
 				04BD03A812E6671800899322 /* SDL_rect.c in Sources */,
-				04BD03AA12E6671800899322 /* SDL_renderer_gl.c in Sources */,
-				04BD03AC12E6671800899322 /* SDL_renderer_gles.c in Sources */,
-				04BD03AE12E6671800899322 /* SDL_renderer_sw.c in Sources */,
 				04BD03B012E6671800899322 /* SDL_RLEaccel.c in Sources */,
 				04BD03B212E6671800899322 /* SDL_shape.c in Sources */,
 				04BD03B412E6671800899322 /* SDL_stretch.c in Sources */,
 				04BD03B512E6671800899322 /* SDL_surface.c in Sources */,
 				04BD03B712E6671800899322 /* SDL_video.c in Sources */,
-				04BD03B812E6671800899322 /* SDL_yuv_mmx.c in Sources */,
-				04BD03B912E6671800899322 /* SDL_yuv_sw.c in Sources */,
 				04BD03F312E6671800899322 /* imKStoUCS.c in Sources */,
 				04BD03F512E6671800899322 /* SDL_x11clipboard.c in Sources */,
 				04BD03F712E6671800899322 /* SDL_x11dyn.c in Sources */,
@@ -2584,23 +2529,27 @@
 				04BD040112E6671800899322 /* SDL_x11mouse.c in Sources */,
 				04BD040312E6671800899322 /* SDL_x11opengl.c in Sources */,
 				04BD040512E6671800899322 /* SDL_x11opengles.c in Sources */,
-				04BD040712E6671800899322 /* SDL_x11render.c in Sources */,
 				04BD040912E6671800899322 /* SDL_x11shape.c in Sources */,
 				04BD040C12E6671800899322 /* SDL_x11touch.c in Sources */,
 				04BD040E12E6671800899322 /* SDL_x11video.c in Sources */,
 				04BD041012E6671800899322 /* SDL_x11window.c in Sources */,
 				04BD042112E6671800899322 /* Xinerama.c in Sources */,
 				04BD042212E6671800899322 /* xme.c in Sources */,
-				04BD042312E6671800899322 /* AllCmap.c in Sources */,
-				04BD042412E6671800899322 /* CmapAlloc.c in Sources */,
-				04BD042512E6671800899322 /* CrCmap.c in Sources */,
-				04BD042612E6671800899322 /* DelCmap.c in Sources */,
-				04BD042712E6671800899322 /* Distinct.c in Sources */,
-				04BD042812E6671800899322 /* LookupCmap.c in Sources */,
-				04BD042912E6671800899322 /* StdCmap.c in Sources */,
-				04BD042A12E6671800899322 /* VisCmap.c in Sources */,
 				04BD042B12E6671800899322 /* Xv.c in Sources */,
 				04BD042D12E6671800899322 /* XF86VMode.c in Sources */,
+				041B2CAB12FA0D680087D585 /* SDL_render.c in Sources */,
+				04409B9612FA97ED00FB9AA8 /* SDL_yuv_mmx.c in Sources */,
+				04409B9812FA97ED00FB9AA8 /* SDL_yuv_sw.c in Sources */,
+				04F7803C12FB748500FC43C0 /* SDL_nullframebuffer.c in Sources */,
+				04F7805512FB74A200FC43C0 /* SDL_blendfillrect.c in Sources */,
+				04F7805712FB74A200FC43C0 /* SDL_blendline.c in Sources */,
+				04F7805912FB74A200FC43C0 /* SDL_blendpoint.c in Sources */,
+				04F7805C12FB74A200FC43C0 /* SDL_drawline.c in Sources */,
+				04F7805E12FB74A200FC43C0 /* SDL_drawpoint.c in Sources */,
+				0442EC1912FE1BBA004C9285 /* SDL_render_gl.c in Sources */,
+				0442EC1F12FE1BCB004C9285 /* SDL_render_sw.c in Sources */,
+				0442EC5C12FE1C60004C9285 /* SDL_x11framebuffer.c in Sources */,
+				0442EC6012FE1C75004C9285 /* SDL_hints.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
--- a/configure.in	Tue Feb 01 00:37:02 2011 -0800
+++ b/configure.in	Sun Feb 06 21:23:32 2011 -0800
@@ -330,11 +330,13 @@
 
 # Standard C sources
 SOURCES="$SOURCES $srcdir/src/*.c"
+SOURCES="$SOURCES $srcdir/src/atomic/*.c"
 SOURCES="$SOURCES $srcdir/src/audio/*.c"
-SOURCES="$SOURCES $srcdir/src/atomic/*.c"
 SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
 SOURCES="$SOURCES $srcdir/src/events/*.c"
 SOURCES="$SOURCES $srcdir/src/file/*.c"
+SOURCES="$SOURCES $srcdir/src/render/*.c"
+SOURCES="$SOURCES $srcdir/src/render/*/*.c"
 SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
 SOURCES="$SOURCES $srcdir/src/thread/*.c"
 SOURCES="$SOURCES $srcdir/src/timer/*.c"
@@ -1116,7 +1118,6 @@
 
             AC_DEFINE(SDL_VIDEO_DRIVER_X11)
             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
-            SOURCES="$SOURCES $srcdir/src/video/Xext/XmuStdCmap/*.c"
             EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
 
             if test x$enable_x11_shared = xmaybe; then
@@ -1259,139 +1260,6 @@
             if test x$definitely_enable_video_x11_scrnsaver = xyes; then
                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_SCRNSAVER)
             fi
-            AC_ARG_ENABLE(video-x11-xrender,
-AC_HELP_STRING([--enable-video-x11-xrender], [enable X11 Xrender extension [[default=yes]]]),
-                            , enable_video_x11_xrender=yes)
-            if test x$enable_video_x11_xrender = xyes; then
-                AC_CHECK_HEADER(X11/extensions/Xrender.h,
-                                have_xrender_h_hdr=yes,
-                                have_xrender_h_hdr=no,
-                                [#include <X11/Xlib.h>
-                                ])
-                if test x$have_xrender_h_hdr = xyes; then
-                    if test x$enable_x11_shared = xyes && test x$xrender_lib != x ; then
-                        echo "-- dynamic libXrender -> $xrender_lib"
-                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER, "$xrender_lib")
-                        definitely_enable_video_x11_xrender=yes
-                    else
-                        AC_CHECK_LIB(Xrender, XRenderQueryExtension, have_xrender_lib=yes)
-                        if test x$have_xrender_lib = xyes ; then
-                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrender"
-                            definitely_enable_video_x11_xrender=yes
-                        fi
-                    fi
-                fi
-            fi
-            if test x$definitely_enable_video_x11_xrender = xyes; then
-                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRENDER)
-            fi
-            AC_ARG_ENABLE(video-x11-xdamage-xfixes,
-AC_HELP_STRING([--enable-video-x11-xdamage-xfixes], [enable X11 Xdamage and Xfixes extensions [[default=yes]]]),
-                            , enable_video_x11_xdamage=yes)
-            if test x$enable_video_x11_xdamage = xyes && test x$definitely_enable_video_x11_xrender = xyes ; then
-                AC_CHECK_HEADER(X11/extensions/Xdamage.h,
-                                have_xdamage_h_hdr=yes,
-                                have_xdamage_h_hdr=no,
-                                [#include <X11/Xlib.h>
-                                ])
-                AC_CHECK_HEADER(X11/extensions/Xfixes.h,
-                                have_xfixes_h_hdr=yes,
-                                have_xfixes_h_hdr=no,
-                                [#include <X11/Xlib.h>
-                                ])
-                if test x$have_xdamage_h_hdr = xyes && test x$have_xfixes_h_hdr = xyes ; then
-                    if test x$enable_x11_shared = xyes && test x$xdamage_lib != x && test x$xfixes_lib != x ; then
-                        echo "-- dynamic libXdamage -> $xdamage_lib"
-                        echo "-- dynamic libXfixes -> $xfixes_lib"
-                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XDAMAGE, "$xdamage_lib")
-                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES, "$xfixes_lib")
-                        definitely_enable_video_x11_xdamage=yes
-                        definitely_enable_video_x11_xfixes=yes
-                    else
-                        AC_CHECK_LIB(Xdamage, XDamageQueryExtension, have_xdamage_lib=yes)
-                        AC_CHECK_LIB(Xfixes, XFixesQueryExtension, have_xfixes_lib=yes)
-                        if test x$have_xdamage_lib = xyes && test x$have_xfixes_lib = xyes ; then
-                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXdamage -lXfixes"
-                            definitely_enable_video_x11_xdamage=yes
-                            definitely_enable_video_x11_xfixes=yes
-                        fi
-                    fi
-                fi
-            fi
-            if test x$definitely_enable_video_x11_xdamage = xyes && test x$definitely_enable_video_x11_xfixes = xyes ; then
-                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XDAMAGE)
-                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XFIXES)
-            fi
-            AC_ARG_ENABLE(render-x11,
-AC_HELP_STRING([--enable-render-x11], [enable the X11 render driver [[default=yes]]]),
-                                , enable_render_x11=yes)
-            if test x$enable_render_x11 = xyes; then
-                AC_DEFINE(SDL_VIDEO_RENDER_X11)
-            fi
-        fi
-    fi
-}
-
-dnl Check for QNX photon video driver
-CheckPHOTON()
-{
-    AC_ARG_ENABLE(video-photon,
-AC_HELP_STRING([--enable-video-photon], [use QNX Photon video driver [[default=yes]]]),
-                  , enable_video_photon=yes)
-    if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
-        AC_MSG_CHECKING(for QNX Photon support)
-        video_photon=no
-        AC_TRY_COMPILE([
-          #include <Ph.h>
-          #include <Pt.h>
-          #include <photon/Pg.h>
-          #include <photon/PdDirect.h>
-        ],[
-         PgDisplaySettings_t *visual;
-        ],[
-        video_photon=yes
-        ])
-        AC_MSG_RESULT($video_photon)
-        if test x$video_photon = xyes; then
-            AC_DEFINE(SDL_VIDEO_DRIVER_PHOTON)
-            SOURCES="$SOURCES $srcdir/src/video/photon/*.c"
-            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lph -lphrender"
-            have_video=yes
-
-            CheckOpenGLQNX
-        fi
-    fi
-}
-
-dnl Check for QNX photon video driver
-CheckQNXGF()
-{
-    AC_ARG_ENABLE(video-qnxgf,
-                  AC_HELP_STRING([--enable-video-qnxgf], [use QNX GF video driver [[default=yes]]]),
-                  , enable_video_qnxgf=yes)
-    if test x$enable_video = xyes -a x$enable_video_qnxgf = xyes; then
-        AC_MSG_CHECKING(for QNX GF support)
-        video_qnxgf=no
-        AC_TRY_COMPILE([
-          #include <gf/gf.h>
-          #include <gf/gf3d.h>
-        ],[
-         gf_3d_config_info_t* gfinfo;
-        ],[
-        video_qnxgf=yes
-        ])
-        AC_MSG_RESULT($video_qnxgf)
-        if test x$video_qnxgf = xyes; then
-            AC_DEFINE(SDL_VIDEO_DRIVER_QNXGF)
-            SOURCES="$SOURCES $srcdir/src/video/qnxgf/*.c"
-            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lgf"
-
-            # Add HIDDI library for HID support using GF
-            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lhiddi"
-
-            have_video=yes
-
-            CheckOpenGLESQNX
         fi
     fi
 }
@@ -1444,8 +1312,7 @@
         video_directfb=no
 
         DIRECTFB_REQUIRED_VERSION=1.0.0
-
-        AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no)
+        AC_PATH_PROGS(DIRECTFBCONFIG, directfb-config, no, [$prefix/bin:$PATH])
         if test x$DIRECTFBCONFIG = xno; then
             AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
             if test x$PKG_CONFIG != xno; then
@@ -1485,13 +1352,15 @@
                               , enable_directfb_shared=yes)
 
             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
+            AC_DEFINE(SDL_VIDEO_RENDER_DIRECTFB)
             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
 
             AC_MSG_CHECKING(for directfb dynamic loading support)
             directfb_shared=no
-            directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
-
+            directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS"`]
+            # | sed 's/.*\/\(.*\)/\1/; q'`]
+AC_MSG_WARN("directfb $directfb_lib")
             if test x$have_loadso != xyes && \
                test x$enable_directfb_shared = xyes; then
                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
@@ -1600,65 +1469,6 @@
     fi
 }
 
-dnl Find QNX 6.x Software OpenGL
-CheckOpenGLQNX()
-{
-    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
-        AC_MSG_CHECKING(for QNX 6.x Photon OpenGL support)
-        video_opengl=no
-        AC_TRY_COMPILE([
-         #include <GL/gl.h>
-        ],[
-        ],[
-        video_opengl=yes
-        ])
-        AC_MSG_RESULT($video_opengl)
-        if test x$video_opengl = xyes; then
-            AC_DEFINE(SDL_VIDEO_OPENGL)
-            AC_DEFINE(SDL_VIDEO_RENDER_OGL)
-            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
-        fi
-    fi
-}
-
-dnl Find QNX 6.3 and above OpenGL ES implementation
-CheckOpenGLESQNX()
-{
-    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
-        AC_MSG_CHECKING(for QNX OpenGL ES (CM) support)
-        video_opengl=no
-        AC_TRY_COMPILE([
-         #include <GLES/egl.h>
-        ],[
-        ],[
-        video_opengl=yes
-        ])
-        AC_MSG_RESULT($video_opengl)
-        if test x$video_opengl = xyes; then
-            AC_DEFINE(SDL_VIDEO_OPENGL_ES)
-            AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
-            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CM"
-        else
-            AC_MSG_CHECKING(for QNX OpenGL ES (CL) support)
-            video_opengl=no
-            AC_TRY_COMPILE([
-             #define COMMON_LITE
-             #include <GLES/egl.h>
-            ],[
-            ],[
-            video_opengl=yes
-            ])
-            AC_MSG_RESULT($video_opengl)
-            if test x$video_opengl = xyes; then
-                AC_DEFINE(SDL_VIDEO_OPENGL_ES)
-                AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
-                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CLS"
-            fi
-        fi
-    fi
-}
-
-
 dnl Check for Windows OpenGL
 CheckWINDOWSGL()
 {
@@ -1802,10 +1612,6 @@
             pthread_cflags="-D_REENTRANT"
             pthread_lib="-L/usr/lib -lpthread"
             ;;
-        *-*-qnx*)
-            pthread_cflags=""
-            pthread_lib=""
-            ;;
         *-*-osf*)
             pthread_cflags="-D_REENTRANT"
             if test x$ac_cv_prog_gcc = xyes; then
@@ -2293,54 +2099,6 @@
             have_timers=yes
         fi
         ;;
-    *-*-qnx*)
-
-        EXTRA_CFLAGS="-I/usr/include $CFLAGS"
-        EXTRA_LDLAGS="-L/usr/lib $LDFLAGS"
-
-        ARCH=qnx
-        CheckVisibilityHidden
-        CheckDummyVideo
-        CheckDiskAudio
-        CheckDummyAudio
-        CheckDLOPEN
-        CheckPulseAudio
-        CheckESD
-        CheckNAS
-        CheckPHOTON
-        CheckQNXGF
-        CheckX11
-        CheckOpenGLX11
-        CheckPTHREAD
-        CheckClockGettime
-
-
-        # Set up files for the audio library
-        if test x$enable_audio = xyes; then
-            AC_DEFINE(SDL_AUDIO_DRIVER_QSA)
-            SOURCES="$SOURCES $srcdir/src/audio/qsa/*.c"
-            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
-            have_audio=yes
-        fi
-        # Set up files for the timer library
-        if test x$enable_timers = xyes; then
-            AC_DEFINE(SDL_TIMER_UNIX)
-            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
-            have_timers=yes
-        fi
-        # Set up dummy files for the joystick for now
-        if test x$enable_joystick = xyes; then
-            AC_DEFINE(SDL_JOYSTICK_DUMMY)
-            SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
-            have_joystick=yes
-        fi
-        # Set up dummy files for the haptic for now
-        if test x$enable_haptic = xyes; then
-            AC_DEFINE(SDL_HAPTIC_DUMMY)
-            SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
-            have_haptic=yes
-        fi
-        ;;
     *-wince* | *-mingw32ce)
         ARCH=win32
         CheckDummyVideo
@@ -2351,24 +2109,6 @@
             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS)
             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
             have_video=yes
-            AC_ARG_ENABLE(render-gdi,
-AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
-                                , enable_render_gdi=yes)
-            if test x$enable_render_gdi = xyes; then
-                AC_DEFINE(SDL_VIDEO_RENDER_GDI)
-            fi
-            AC_ARG_ENABLE(render-gapi,
-AC_HELP_STRING([--enable-render-gapi], [enable the GAPI/RAWFRAMEBUFFER render driver [[default=yes]]]),
-                                , enable_render_gapi=yes)
-            if test x$enable_render_gapi = xyes -a x$have_wince = xyes; then
-                AC_DEFINE(SDL_VIDEO_RENDER_GAPI)
-            fi
-            AC_ARG_ENABLE(render-ddraw,
-AC_HELP_STRING([--enable-render-ddraw], [enable the Mobile DirectDraw render driver [[default=yes]]]),
-                                , enable_render_ddraw=yes)
-            if test x$enable_render_ddraw = xyes -a x$have_wince = xyes -a x$have_ddraw = xyes; then
-                AC_DEFINE(SDL_VIDEO_RENDER_DDRAW)
-            fi
             AC_ARG_ENABLE(render-d3d,
 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
                                 , enable_render_d3d=yes)
@@ -2457,12 +2197,6 @@
             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS)
             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
             have_video=yes
-            AC_ARG_ENABLE(render-gdi,
-AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
-                                , enable_render_gdi=yes)
-            if test x$enable_render_gdi = xyes; then
-                AC_DEFINE(SDL_VIDEO_RENDER_GDI)
-            fi
             AC_ARG_ENABLE(render-d3d,
 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
                                 , enable_render_d3d=yes)
--- a/include/SDL.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL.h	Sun Feb 06 21:23:32 2011 -0800
@@ -37,10 +37,6 @@
  *  level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
  *  and 2D framebuffer across multiple platforms.
  *  
- *  The current version supports Windows, Windows CE, Mac OS X, Linux,
- *  FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, and QNX. The code contains
- *  support for other operating systems but those are not officially supported. 
- *  
  *  SDL is written in C, but works with C++ natively, and has bindings to
  *  several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
  *  Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP,
@@ -83,9 +79,11 @@
 #include "SDL_endian.h"
 #include "SDL_error.h"
 #include "SDL_events.h"
+#include "SDL_hints.h"
 #include "SDL_loadso.h"
 #include "SDL_mutex.h"
 #include "SDL_power.h"
+#include "SDL_render.h"
 #include "SDL_rwops.h"
 #include "SDL_thread.h"
 #include "SDL_timer.h"
--- a/include/SDL_atomic.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_atomic.h	Sun Feb 06 21:23:32 2011 -0800
@@ -123,9 +123,10 @@
 /*@}*//*SDL AtomicLock*/
 
 
-/* The compiler barrier prevents the compiler from reordering
-   reads and writes to globally visible variables across the call.
-*/
+/**
+ * The compiler barrier prevents the compiler from reordering
+ * reads and writes to globally visible variables across the call.
+ */
 #ifdef _MSC_VER
 void _ReadWriteBarrier(void);
 #pragma intrinsic(_ReadWriteBarrier)
@@ -270,7 +271,7 @@
 #ifndef SDL_AtomicCASPtr
 #define SDL_AtomicCASPtr SDL_AtomicCASPtr_
 #endif
-extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr_(void **a, void *oldval, void *newval);
+extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr_(void* *a, void *oldval, void *newval);
 
 /**
  * \brief Set a pointer to a value atomically.
--- a/include/SDL_blendmode.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_blendmode.h	Sun Feb 06 21:23:32 2011 -0800
@@ -43,12 +43,9 @@
 typedef enum
 {
     SDL_BLENDMODE_NONE = 0x00000000,     /**< No blending */
-    SDL_BLENDMODE_MASK = 0x00000001,     /**< dst = A ? src : dst 
-                                              (alpha is mask) */
-    
-    SDL_BLENDMODE_BLEND = 0x00000002,    /**< dst = (src * A) + (dst * (1-A)) */
-    SDL_BLENDMODE_ADD = 0x00000004,      /**< dst = (src * A) + dst */
-    SDL_BLENDMODE_MOD = 0x00000008       /**< dst = src * dst */
+    SDL_BLENDMODE_BLEND = 0x00000001,    /**< dst = (src * A) + (dst * (1-A)) */
+    SDL_BLENDMODE_ADD = 0x00000002,      /**< dst = (src * A) + dst */
+    SDL_BLENDMODE_MOD = 0x00000004       /**< dst = src * dst */
 } SDL_BlendMode;
 
 /* Ends C function definitions when using C++ */
--- a/include/SDL_compat.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_compat.h	Sun Feb 06 21:23:32 2011 -0800
@@ -208,14 +208,6 @@
     SDL_GRAB_ON = 1
 } SDL_GrabMode;
 
-typedef enum
-{
-    SDL_TEXTURESCALEMODE_NONE = SDL_SCALEMODE_NONE,
-    SDL_TEXTURESCALEMODE_FAST = SDL_SCALEMODE_FAST,
-    SDL_TEXTURESCALEMODE_SLOW = SDL_SCALEMODE_SLOW,
-    SDL_TEXTURESCALEMODE_BEST = SDL_SCALEMODE_BEST
-} SDL_TextureScaleMode;
-
 struct SDL_SysWMinfo;
 
 /**
@@ -281,8 +273,8 @@
 #define SDL_AllocSurface    SDL_CreateRGBSurface
 
 extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);
-extern DECLSPEC char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
-extern DECLSPEC char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
+extern DECLSPEC const char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
+extern DECLSPEC const char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
 extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
 extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
                                             int height,
@@ -336,12 +328,8 @@
 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
 
-typedef SDL_Texture* SDL_TextureID;
 typedef SDL_Window* SDL_WindowID;
 
-#define SDL_RenderPoint SDL_RenderDrawPoint
-#define SDL_RenderLine SDL_RenderDrawLine
-#define SDL_RenderFill(X)  (X) ? SDL_RenderFillRect(X) : SDL_RenderClear()
 #define SDL_KillThread(X)
 
 /* The timeslice and timer resolution are no longer relevant */
--- a/include/SDL_config.h.default	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_config.h.default	Sun Feb 06 21:23:32 2011 -0800
@@ -32,16 +32,16 @@
  */
  
 /* Add any platform that doesn't build using the configure system. */
-#if defined(__NINTENDODS__)
-#include "SDL_config_nintendods.h"
+#if defined(__WIN32__)
+#include "SDL_config_windows.h"
+#elif defined(__MACOSX__)
+#include "SDL_config_macosx.h"
+#elif defined(__IPHONEOS__) 
+#include "SDL_config_iphoneos.h"
 #elif defined(__ANDROID__)
 #include "SDL_config_android.h"
-#elif defined(__IPHONEOS__) 
-#include "SDL_config_iphoneos.h"
-#elif defined(__MACOSX__)
-#include "SDL_config_macosx.h"
-#elif defined(__WINDOWS__)
-#include "SDL_config_windows.h"
+#elif defined(__NINTENDODS__)
+#include "SDL_config_nintendods.h"
 #else
 #include "SDL_config_minimal.h"
 #endif /* platform config */
--- a/include/SDL_config.h.in	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_config.h.in	Sun Feb 06 21:23:32 2011 -0800
@@ -261,36 +261,25 @@
 #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
 #undef SDL_VIDEO_DRIVER_DUMMY
 #undef SDL_VIDEO_DRIVER_NDS
-#undef SDL_VIDEO_DRIVER_PHOTON
-#undef SDL_VIDEO_DRIVER_QNXGF
 #undef SDL_VIDEO_DRIVER_WINDOWS
 #undef SDL_VIDEO_DRIVER_X11
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
-#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS
-#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XDAMAGE
-#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES
 #undef SDL_VIDEO_DRIVER_X11_VIDMODE
 #undef SDL_VIDEO_DRIVER_X11_XINERAMA
 #undef SDL_VIDEO_DRIVER_X11_XRANDR
 #undef SDL_VIDEO_DRIVER_X11_XINPUT
 #undef SDL_VIDEO_DRIVER_X11_SCRNSAVER
 #undef SDL_VIDEO_DRIVER_X11_XV
-#undef SDL_VIDEO_DRIVER_X11_XRENDER
-#undef SDL_VIDEO_DRIVER_X11_XDAMAGE
-#undef SDL_VIDEO_DRIVER_X11_XFIXES
 #undef SDL_VIDEO_DRIVER_X11_XSHAPE
 
 #undef SDL_VIDEO_RENDER_D3D
-#undef SDL_VIDEO_RENDER_GDI
 #undef SDL_VIDEO_RENDER_OGL
 #undef SDL_VIDEO_RENDER_OGL_ES
-#undef SDL_VIDEO_RENDER_X11
-#undef SDL_VIDEO_RENDER_GAPI
-#undef SDL_VIDEO_RENDER_DDRAW
+#undef SDL_VIDEO_RENDER_DIRECTFB
 
 /* Enable OpenGL support */
 #undef SDL_VIDEO_OPENGL
--- a/include/SDL_config_android.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_config_android.h	Sun Feb 06 21:23:32 2011 -0800
@@ -142,5 +142,6 @@
 /* Enable OpenGL ES */
 #define SDL_VIDEO_OPENGL_ES	1
 #define SDL_VIDEO_RENDER_OGL_ES	1
+#define SDL_VIDEO_RENDER_OGL_ES2	1
 
 #endif /* _SDL_config_minimal_h */
--- a/include/SDL_config_iphoneos.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_config_iphoneos.h	Sun Feb 06 21:23:32 2011 -0800
@@ -145,6 +145,7 @@
 /* enable OpenGL ES */
 #define SDL_VIDEO_OPENGL_ES	1
 #define SDL_VIDEO_RENDER_OGL_ES	1
+#define SDL_VIDEO_RENDER_OGL_ES2	1
 
 /* Enable system power support */
 #define SDL_POWER_UIKIT 1
--- a/include/SDL_config_macosx.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_config_macosx.h	Sun Feb 06 21:23:32 2011 -0800
@@ -151,9 +151,6 @@
 #ifndef SDL_VIDEO_RENDER_OGL
 #define SDL_VIDEO_RENDER_OGL	1
 #endif
-#ifndef SDL_VIDEO_RENDER_X11
-#define SDL_VIDEO_RENDER_X11	1
-#endif
 
 /* Enable OpenGL support */
 #ifndef SDL_VIDEO_OPENGL
--- a/include/SDL_config_windows.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_config_windows.h	Sun Feb 06 21:23:32 2011 -0800
@@ -178,18 +178,11 @@
 #define SDL_VIDEO_DRIVER_DUMMY	1
 #define SDL_VIDEO_DRIVER_WINDOWS	1
 
-#ifdef _WIN32_WCE
-#ifndef SDL_VIDEO_RENDER_GAPI
-#define SDL_VIDEO_RENDER_GAPI	1
-#endif
-#else
+#ifndef _WIN32_WCE
 #ifndef SDL_VIDEO_RENDER_D3D
 #define SDL_VIDEO_RENDER_D3D	1
 #endif
 #endif
-#ifndef SDL_VIDEO_RENDER_GDI
-#define SDL_VIDEO_RENDER_GDI	1
-#endif
 
 /* Enable OpenGL support */
 #ifndef _WIN32_WCE
--- a/include/SDL_events.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_events.h	Sun Feb 06 21:23:32 2011 -0800
@@ -581,6 +581,18 @@
                                                     void **userdata);
 
 /**
+ *  Add a function which is called when an event is added to the queue.
+ */
+extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
+                                               void *userdata);
+
+/**
+ *  Remove an event watch function added with SDL_AddEventWatch()
+ */
+extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
+                                               void *userdata);
+
+/**
  *  Run the filter function on the current event queue, removing any
  *  events for which the filter returns 0.
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_hints.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,155 @@
+/*
+    SDL - Simple DihintsMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+/**
+ *  \file SDL_hints.h
+ *  
+ *  Official documentation for SDL configuration variables
+ *
+ *  This file contains functions to set and get configuration hints,
+ *  as well as listing each of them alphabetically.
+ *
+ *  The convention for naming hints is SDL_HINT_X, where "SDL_X" is
+ *  the environment variable that can be used to override the default.
+ *
+ *  In general these hints are just that - they may or may not be
+ *  supported or applicable on any given platform, but they provide
+ *  a way for an application or user to give the library a hint as
+ *  to how they would like the library to work.
+ */
+
+#ifndef _SDL_hints_h
+#define _SDL_hints_h
+
+#include "SDL_stdinc.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+/**
+ *  \brief  A variable controlling how 3D acceleration is used to accelerate the SDL 1.2 screen surface. 
+ *
+ *  SDL can try to accelerate the SDL 1.2 screen surface by using streaming
+ *  textures with a 3D rendering engine.  This variable controls whether and
+ *  how this is done.
+ *
+ *  This variable can be set to the following values:
+ *    "0"       - Disable 3D acceleration
+ *    "1"       - Enable 3D acceleration, using the default renderer.
+ *    "X"       - Enable 3D acceleration, using X where X is one of the valid rendering drivers.  (e.g. "direct3d", "opengl", etc.)
+ *
+ *  By default SDL tries to make a best guess for each platform whether
+ *  to use acceleration or not.
+ */
+#define SDL_HINT_FRAMEBUFFER_ACCELERATION   "SDL_FRAMEBUFFER_ACCELERATION"
+
+/**
+ *  \brief  A variable specifying which render driver to use.
+ *
+ *  If the application doesn't pick a specific renderer to use, this variable
+ *  specifies the name of the preferred renderer.  If the preferred renderer
+ *  can't be initialized, the normal default renderer is used.
+ *
+ *  This variable is case insensitive and can be set to the following values:
+ *    "direct3d"
+ *    "opengl"
+ *    "opengles"
+ *    "software"
+ */
+#define SDL_HINT_RENDER_DRIVER              "SDL_RENDER_DRIVER"
+
+/**
+ *  \brief  A variable controlling whether updates to the SDL 1.2 screen surface should be synchronized with the vertical refresh, to avoid tearing.
+ *
+ *  This variable can be set to the following values:
+ *    "0"       - Disable vsync
+ *    "1"       - Enable vsync
+ *
+ *  By default SDL does not sync screen surface updates with vertical refresh.
+ */
+#define SDL_HINT_RENDER_VSYNC               "SDL_RENDER_VSYNC"
+
+
+/**
+ *  \brief  An enumeration of hint priorities
+ */
+typedef enum
+{
+    SDL_HINT_DEFAULT,
+    SDL_HINT_NORMAL,
+    SDL_HINT_OVERRIDE
+} SDL_HintPriority;
+
+
+/**
+ *  \brief Set a hint with a specific priority
+ *
+ *  The priority controls the behavior when setting a hint that already
+ *  has a value.  Hints will replace existing hints of their priority and
+ *  lower.  Environment variables are considered to have override priority.
+ * 
+ *  \return SDL_TRUE if the hint was set, SDL_FALSE otherwise
+ */
+extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name,
+                                                         const char *value,
+                                                         SDL_HintPriority priority);
+
+/**
+ *  \brief Set a hint with normal priority
+ * 
+ *  \return SDL_TRUE if the hint was set, SDL_FALSE otherwise
+ */
+extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name,
+                                             const char *value);
+
+
+/**
+ *  \brief Get a hint
+ *  
+ *  \return The string value of a hint variable.
+ */
+extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name);
+
+/**
+ *  \brief  Clear all hints
+ *
+ *  This function is called during SDL_Quit() to free stored hints.
+ */
+extern DECLSPEC void SDLCALL SDL_ClearHints();
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_hints_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/include/SDL_opengles.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_opengles.h	Sun Feb 06 21:23:32 2011 -0800
@@ -1,1039 +1,39 @@
 /*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
- 
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- 
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- Lesser General Public License for more details.
- 
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- 
- Sam Lantinga
- slouken@libsdl.org
- */
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
 
 /**
  *  \file SDL_opengles.h
  *  
- *  This is a simple file to encapsulate the OpenGL ES API headers.
- *  
- *  Headers copied from The Kronos Group website.
- *  	http://www.khronos.org/opengles/
+ *  This is a simple file to encapsulate the OpenGL ES 1.X API headers.
  */
 
-#ifndef __gles_h_
-#define __gles_h_
-
-/* $Id: gl.h 4533 2007-11-26 11:19:35Z markc $ */
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 #ifdef __IPHONEOS__
-#include <OpenGLES/ES1/gl.h>    /* Header File For The OpenGL ES Library */
+#include <OpenGLES/ES1/gl.h>
+#include <OpenGLES/ES1/glext.h>
+#else
+#include <GLES/gl.h>
+#include <GLES/glext.h>
 #endif
 
 #ifndef APIENTRY
 #define APIENTRY
 #endif
-
-#ifndef GL_APIENTRY
-#define GL_APIENTRY
-#endif
-
-#ifndef GL_API
-#define GL_API
-#endif                          /* GL_API */
-
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.0 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-    typedef unsigned int GLenum;
-    typedef unsigned char GLboolean;
-    typedef unsigned int GLbitfield;
-    typedef signed char GLbyte;
-    typedef short GLshort;
-    typedef int GLint;
-    typedef int GLsizei;
-    typedef unsigned char GLubyte;
-    typedef unsigned short GLushort;
-    typedef unsigned int GLuint;
-    typedef float GLfloat;
-    typedef float GLclampf;
-    typedef void GLvoid;
-    typedef int GLfixed;
-    typedef int GLclampx;
-
-    typedef int GLintptr;
-    typedef int GLsizeiptr;
-
-
-/*************************************************************/
-
-/* OpenGL ES core versions */
-#define GL_VERSION_ES_CM_1_0		  1
-#define GL_VERSION_ES_CL_1_0		  1
-#define GL_VERSION_ES_CM_1_1		  1
-#define GL_VERSION_ES_CL_1_1		  1
-
-/* ClearBufferMask */
-#define GL_DEPTH_BUFFER_BIT               0x00000100
-#define GL_STENCIL_BUFFER_BIT             0x00000400
-#define GL_COLOR_BUFFER_BIT               0x00004000
-
-/* Boolean */
-#define GL_FALSE                          0
-#define GL_TRUE                           1
-
-/* BeginMode */
-#define GL_POINTS                         0x0000
-#define GL_LINES                          0x0001
-#define GL_LINE_LOOP                      0x0002
-#define GL_LINE_STRIP                     0x0003
-#define GL_TRIANGLES                      0x0004
-#define GL_TRIANGLE_STRIP                 0x0005
-#define GL_TRIANGLE_FAN                   0x0006
-
-/* AlphaFunction */
-#define GL_NEVER                          0x0200
-#define GL_LESS                           0x0201
-#define GL_EQUAL                          0x0202
-#define GL_LEQUAL                         0x0203
-#define GL_GREATER                        0x0204
-#define GL_NOTEQUAL                       0x0205
-#define GL_GEQUAL                         0x0206
-#define GL_ALWAYS                         0x0207
-
-/* BlendingFactorDest */
-#define GL_ZERO                           0
-#define GL_ONE                            1
-#define GL_SRC_COLOR                      0x0300
-#define GL_ONE_MINUS_SRC_COLOR            0x0301
-#define GL_SRC_ALPHA                      0x0302
-#define GL_ONE_MINUS_SRC_ALPHA            0x0303
-#define GL_DST_ALPHA                      0x0304
-#define GL_ONE_MINUS_DST_ALPHA            0x0305
-
-/* BlendingFactorSrc */
-/*      GL_ZERO */
-/*      GL_ONE */
-#define GL_DST_COLOR                      0x0306
-#define GL_ONE_MINUS_DST_COLOR            0x0307
-#define GL_SRC_ALPHA_SATURATE             0x0308
-/*      GL_SRC_ALPHA */
-/*      GL_ONE_MINUS_SRC_ALPHA */
-/*      GL_DST_ALPHA */
-/*      GL_ONE_MINUS_DST_ALPHA */
-
-/* ClipPlaneName */
-#define GL_CLIP_PLANE0                    0x3000
-#define GL_CLIP_PLANE1                    0x3001
-#define GL_CLIP_PLANE2                    0x3002
-#define GL_CLIP_PLANE3                    0x3003
-#define GL_CLIP_PLANE4                    0x3004
-#define GL_CLIP_PLANE5                    0x3005
-
-/* ColorMaterialFace */
-/*      GL_FRONT_AND_BACK */
-
-/* ColorMaterialParameter */
-/*      GL_AMBIENT_AND_DIFFUSE */
-
-/* ColorPointerType */
-/*      GL_UNSIGNED_BYTE */
-/*      GL_FLOAT */
-/*      GL_FIXED */
-
-/* CullFaceMode */
-#define GL_FRONT                          0x0404
-#define GL_BACK                           0x0405
-#define GL_FRONT_AND_BACK                 0x0408
-
-/* DepthFunction */
-/*      GL_NEVER */
-/*      GL_LESS */
-/*      GL_EQUAL */
-/*      GL_LEQUAL */
-/*      GL_GREATER */
-/*      GL_NOTEQUAL */
-/*      GL_GEQUAL */
-/*      GL_ALWAYS */
-
-/* EnableCap */
-#define GL_FOG                            0x0B60
-#define GL_LIGHTING                       0x0B50
-#define GL_TEXTURE_2D                     0x0DE1
-#define GL_CULL_FACE                      0x0B44
-#define GL_ALPHA_TEST                     0x0BC0
-#define GL_BLEND                          0x0BE2
-#define GL_COLOR_LOGIC_OP                 0x0BF2
-#define GL_DITHER                         0x0BD0
-#define GL_STENCIL_TEST                   0x0B90
-#define GL_DEPTH_TEST                     0x0B71
-/*      GL_LIGHT0 */
-/*      GL_LIGHT1 */
-/*      GL_LIGHT2 */
-/*      GL_LIGHT3 */
-/*      GL_LIGHT4 */
-/*      GL_LIGHT5 */
-/*      GL_LIGHT6 */
-/*      GL_LIGHT7 */
-#define GL_POINT_SMOOTH                   0x0B10
-#define GL_LINE_SMOOTH                    0x0B20
-#define GL_SCISSOR_TEST                   0x0C11
-#define GL_COLOR_MATERIAL                 0x0B57
-#define GL_NORMALIZE                      0x0BA1
-#define GL_RESCALE_NORMAL                 0x803A
-#define GL_POLYGON_OFFSET_FILL            0x8037
-#define GL_VERTEX_ARRAY                   0x8074
-#define GL_NORMAL_ARRAY                   0x8075
-#define GL_COLOR_ARRAY                    0x8076
-#define GL_TEXTURE_COORD_ARRAY            0x8078
-#define GL_MULTISAMPLE                    0x809D
-#define GL_SAMPLE_ALPHA_TO_COVERAGE       0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE            0x809F
-#define GL_SAMPLE_COVERAGE                0x80A0
-
-/* ErrorCode */
-#define GL_NO_ERROR                       0
-#define GL_INVALID_ENUM                   0x0500
-#define GL_INVALID_VALUE                  0x0501
-#define GL_INVALID_OPERATION              0x0502
-#define GL_STACK_OVERFLOW                 0x0503
-#define GL_STACK_UNDERFLOW                0x0504
-#define GL_OUT_OF_MEMORY                  0x0505
-
-/* FogMode */
-/*      GL_LINEAR */
-#define GL_EXP                            0x0800
-#define GL_EXP2                           0x0801
-
-/* FogParameter */
-#define GL_FOG_DENSITY                    0x0B62
-#define GL_FOG_START                      0x0B63
-#define GL_FOG_END                        0x0B64
-#define GL_FOG_MODE                       0x0B65
-#define GL_FOG_COLOR                      0x0B66
-
-/* FrontFaceDirection */
-#define GL_CW                             0x0900
-#define GL_CCW                            0x0901
-
-/* GetPName */
-#define GL_CURRENT_COLOR                  0x0B00
-#define GL_CURRENT_NORMAL                 0x0B02
-#define GL_CURRENT_TEXTURE_COORDS         0x0B03
-#define GL_POINT_SIZE                     0x0B11
-#define GL_POINT_SIZE_MIN                 0x8126
-#define GL_POINT_SIZE_MAX                 0x8127
-#define GL_POINT_FADE_THRESHOLD_SIZE      0x8128
-#define GL_POINT_DISTANCE_ATTENUATION     0x8129
-#define GL_SMOOTH_POINT_SIZE_RANGE        0x0B12
-#define GL_LINE_WIDTH                     0x0B21
-#define GL_SMOOTH_LINE_WIDTH_RANGE        0x0B22
-#define GL_ALIASED_POINT_SIZE_RANGE       0x846D
-#define GL_ALIASED_LINE_WIDTH_RANGE       0x846E
-#define GL_CULL_FACE_MODE                 0x0B45
-#define GL_FRONT_FACE                     0x0B46
-#define GL_SHADE_MODEL                    0x0B54
-#define GL_DEPTH_RANGE                    0x0B70
-#define GL_DEPTH_WRITEMASK                0x0B72
-#define GL_DEPTH_CLEAR_VALUE              0x0B73
-#define GL_DEPTH_FUNC                     0x0B74
-#define GL_STENCIL_CLEAR_VALUE            0x0B91
-#define GL_STENCIL_FUNC                   0x0B92
-#define GL_STENCIL_VALUE_MASK             0x0B93
-#define GL_STENCIL_FAIL                   0x0B94
-#define GL_STENCIL_PASS_DEPTH_FAIL        0x0B95
-#define GL_STENCIL_PASS_DEPTH_PASS        0x0B96
-#define GL_STENCIL_REF                    0x0B97
-#define GL_STENCIL_WRITEMASK              0x0B98
-#define GL_MATRIX_MODE                    0x0BA0
-#define GL_VIEWPORT                       0x0BA2
-#define GL_MODELVIEW_STACK_DEPTH          0x0BA3
-#define GL_PROJECTION_STACK_DEPTH         0x0BA4
-#define GL_TEXTURE_STACK_DEPTH            0x0BA5
-#define GL_MODELVIEW_MATRIX               0x0BA6
-#define GL_PROJECTION_MATRIX              0x0BA7
-#define GL_TEXTURE_MATRIX                 0x0BA8
-#define GL_ALPHA_TEST_FUNC                0x0BC1
-#define GL_ALPHA_TEST_REF                 0x0BC2
-#define GL_BLEND_DST                      0x0BE0
-#define GL_BLEND_SRC                      0x0BE1
-#define GL_LOGIC_OP_MODE                  0x0BF0
-#define GL_SCISSOR_BOX                    0x0C10
-#define GL_SCISSOR_TEST                   0x0C11
-#define GL_COLOR_CLEAR_VALUE              0x0C22
-#define GL_COLOR_WRITEMASK                0x0C23
-#define GL_UNPACK_ALIGNMENT               0x0CF5
-#define GL_PACK_ALIGNMENT                 0x0D05
-#define GL_MAX_LIGHTS                     0x0D31
-#define GL_MAX_CLIP_PLANES                0x0D32
-#define GL_MAX_TEXTURE_SIZE               0x0D33
-#define GL_MAX_MODELVIEW_STACK_DEPTH      0x0D36
-#define GL_MAX_PROJECTION_STACK_DEPTH     0x0D38
-#define GL_MAX_TEXTURE_STACK_DEPTH        0x0D39
-#define GL_MAX_VIEWPORT_DIMS              0x0D3A
-#define GL_MAX_TEXTURE_UNITS              0x84E2
-#define GL_SUBPIXEL_BITS                  0x0D50
-#define GL_RED_BITS                       0x0D52
-#define GL_GREEN_BITS                     0x0D53
-#define GL_BLUE_BITS                      0x0D54
-#define GL_ALPHA_BITS                     0x0D55
-#define GL_DEPTH_BITS                     0x0D56
-#define GL_STENCIL_BITS                   0x0D57
-#define GL_POLYGON_OFFSET_UNITS           0x2A00
-#define GL_POLYGON_OFFSET_FILL            0x8037
-#define GL_POLYGON_OFFSET_FACTOR          0x8038
-#define GL_TEXTURE_BINDING_2D             0x8069
-#define GL_VERTEX_ARRAY_SIZE              0x807A
-#define GL_VERTEX_ARRAY_TYPE              0x807B
-#define GL_VERTEX_ARRAY_STRIDE            0x807C
-#define GL_NORMAL_ARRAY_TYPE              0x807E
-#define GL_NORMAL_ARRAY_STRIDE            0x807F
-#define GL_COLOR_ARRAY_SIZE               0x8081
-#define GL_COLOR_ARRAY_TYPE               0x8082
-#define GL_COLOR_ARRAY_STRIDE             0x8083
-#define GL_TEXTURE_COORD_ARRAY_SIZE       0x8088
-#define GL_TEXTURE_COORD_ARRAY_TYPE       0x8089
-#define GL_TEXTURE_COORD_ARRAY_STRIDE     0x808A
-#define GL_VERTEX_ARRAY_POINTER           0x808E
-#define GL_NORMAL_ARRAY_POINTER           0x808F
-#define GL_COLOR_ARRAY_POINTER            0x8090
-#define GL_TEXTURE_COORD_ARRAY_POINTER    0x8092
-#define GL_SAMPLE_BUFFERS                 0x80A8
-#define GL_SAMPLES                        0x80A9
-#define GL_SAMPLE_COVERAGE_VALUE          0x80AA
-#define GL_SAMPLE_COVERAGE_INVERT         0x80AB
-
-/* OpenGL ES 1.0 defines, they gone in 1.1 and 2.0 */
-#ifndef GL_MAX_ELEMENTS_VERTICES
-#define GL_MAX_ELEMENTS_VERTICES          0x80E8
-#endif                          /* GL_MAX_ELEMENTS_VERTICES */
-#ifndef GL_MAX_ELEMENTS_INDICES
-#define GL_MAX_ELEMENTS_INDICES           0x80E9
-#endif                          /* GL_MAX_ELEMENTS_INDICES */
-
-/* GetTextureParameter */
-/*      GL_TEXTURE_MAG_FILTER */
-/*      GL_TEXTURE_MIN_FILTER */
-/*      GL_TEXTURE_WRAP_S */
-/*      GL_TEXTURE_WRAP_T */
-
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
-#define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3
-
-/* HintMode */
-#define GL_DONT_CARE                      0x1100
-#define GL_FASTEST                        0x1101
-#define GL_NICEST                         0x1102
-
-/* HintTarget */
-#define GL_PERSPECTIVE_CORRECTION_HINT    0x0C50
-#define GL_POINT_SMOOTH_HINT              0x0C51
-#define GL_LINE_SMOOTH_HINT               0x0C52
-#define GL_FOG_HINT                       0x0C54
-#define GL_GENERATE_MIPMAP_HINT           0x8192
-
-/* LightModelParameter */
-#define GL_LIGHT_MODEL_AMBIENT            0x0B53
-#define GL_LIGHT_MODEL_TWO_SIDE           0x0B52
-
-/* LightParameter */
-#define GL_AMBIENT                        0x1200
-#define GL_DIFFUSE                        0x1201
-#define GL_SPECULAR                       0x1202
-#define GL_POSITION                       0x1203
-#define GL_SPOT_DIRECTION                 0x1204
-#define GL_SPOT_EXPONENT                  0x1205
-#define GL_SPOT_CUTOFF                    0x1206
-#define GL_CONSTANT_ATTENUATION           0x1207
-#define GL_LINEAR_ATTENUATION             0x1208
-#define GL_QUADRATIC_ATTENUATION          0x1209
-
-/* DataType */
-#define GL_BYTE                           0x1400
-#define GL_UNSIGNED_BYTE                  0x1401
-#define GL_SHORT                          0x1402
-#define GL_UNSIGNED_SHORT                 0x1403
-#define GL_FLOAT                          0x1406
-#define GL_FIXED                          0x140C
-
-/* LogicOp */
-#define GL_CLEAR                          0x1500
-#define GL_AND                            0x1501
-#define GL_AND_REVERSE                    0x1502
-#define GL_COPY                           0x1503
-#define GL_AND_INVERTED                   0x1504
-#define GL_NOOP                           0x1505
-#define GL_XOR                            0x1506
-#define GL_OR                             0x1507
-#define GL_NOR                            0x1508
-#define GL_EQUIV                          0x1509
-#define GL_INVERT                         0x150A
-#define GL_OR_REVERSE                     0x150B
-#define GL_COPY_INVERTED                  0x150C
-#define GL_OR_INVERTED                    0x150D
-#define GL_NAND                           0x150E
-#define GL_SET                            0x150F
-
-/* MaterialFace */
-/*      GL_FRONT_AND_BACK */
-
-/* MaterialParameter */
-#define GL_EMISSION                       0x1600
-#define GL_SHININESS                      0x1601
-#define GL_AMBIENT_AND_DIFFUSE            0x1602
-/*      GL_AMBIENT */
-/*      GL_DIFFUSE */
-/*      GL_SPECULAR */
-
-/* MatrixMode */
-#define GL_MODELVIEW                      0x1700
-#define GL_PROJECTION                     0x1701
-#define GL_TEXTURE                        0x1702
-
-/* NormalPointerType */
-/*      GL_BYTE */
-/*      GL_SHORT */
-/*      GL_FLOAT */
-/*      GL_FIXED */
-
-/* PixelFormat */
-#define GL_ALPHA                          0x1906
-#define GL_RGB                            0x1907
-#define GL_RGBA                           0x1908
-#define GL_LUMINANCE                      0x1909
-#define GL_LUMINANCE_ALPHA                0x190A
-
-/* PixelStoreParameter */
-#define GL_UNPACK_ALIGNMENT               0x0CF5
-#define GL_PACK_ALIGNMENT                 0x0D05
-
-/* PixelType */
-/*      GL_UNSIGNED_BYTE */
-#define GL_UNSIGNED_SHORT_4_4_4_4         0x8033
-#define GL_UNSIGNED_SHORT_5_5_5_1         0x8034
-#define GL_UNSIGNED_SHORT_5_6_5           0x8363
-
-/* ShadingModel */
-#define GL_FLAT                           0x1D00
-#define GL_SMOOTH                         0x1D01
-
-/* StencilFunction */
-/*      GL_NEVER */
-/*      GL_LESS */
-/*      GL_EQUAL */
-/*      GL_LEQUAL */
-/*      GL_GREATER */
-/*      GL_NOTEQUAL */
-/*      GL_GEQUAL */
-/*      GL_ALWAYS */
-
-/* StencilOp */
-/*      GL_ZERO */
-#define GL_KEEP                           0x1E00
-#define GL_REPLACE                        0x1E01
-#define GL_INCR                           0x1E02
-#define GL_DECR                           0x1E03
-/*      GL_INVERT */
-
-/* StringName */
-#define GL_VENDOR                         0x1F00
-#define GL_RENDERER                       0x1F01
-#define GL_VERSION                        0x1F02
-#define GL_EXTENSIONS                     0x1F03
-
-/* TexCoordPointerType */
-/*      GL_SHORT */
-/*      GL_FLOAT */
-/*      GL_FIXED */
-/*      GL_BYTE */
-
-/* TextureEnvMode */
-#define GL_MODULATE                       0x2100
-#define GL_DECAL                          0x2101
-/*      GL_BLEND */
-#define GL_ADD                            0x0104
-/*      GL_REPLACE */
-
-/* TextureEnvParameter */
-#define GL_TEXTURE_ENV_MODE               0x2200
-#define GL_TEXTURE_ENV_COLOR              0x2201
-
-/* TextureEnvTarget */
-#define GL_TEXTURE_ENV                    0x2300
-
-/* TextureMagFilter */
-#define GL_NEAREST                        0x2600
-#define GL_LINEAR                         0x2601
-
-/* TextureMinFilter */
-/*      GL_NEAREST */
-/*      GL_LINEAR */
-#define GL_NEAREST_MIPMAP_NEAREST         0x2700
-#define GL_LINEAR_MIPMAP_NEAREST          0x2701
-#define GL_NEAREST_MIPMAP_LINEAR          0x2702
-#define GL_LINEAR_MIPMAP_LINEAR           0x2703
-
-/* TextureParameterName */
-#define GL_TEXTURE_MAG_FILTER             0x2800
-#define GL_TEXTURE_MIN_FILTER             0x2801
-#define GL_TEXTURE_WRAP_S                 0x2802
-#define GL_TEXTURE_WRAP_T                 0x2803
-#define GL_GENERATE_MIPMAP                0x8191
-
-/* TextureTarget */
-/*      GL_TEXTURE_2D */
-
-/* TextureUnit */
-#define GL_TEXTURE0                       0x84C0
-#define GL_TEXTURE1                       0x84C1
-#define GL_TEXTURE2                       0x84C2
-#define GL_TEXTURE3                       0x84C3
-#define GL_TEXTURE4                       0x84C4
-#define GL_TEXTURE5                       0x84C5
-#define GL_TEXTURE6                       0x84C6
-#define GL_TEXTURE7                       0x84C7
-#define GL_TEXTURE8                       0x84C8
-#define GL_TEXTURE9                       0x84C9
-#define GL_TEXTURE10                      0x84CA
-#define GL_TEXTURE11                      0x84CB
-#define GL_TEXTURE12                      0x84CC
-#define GL_TEXTURE13                      0x84CD
-#define GL_TEXTURE14                      0x84CE
-#define GL_TEXTURE15                      0x84CF
-#define GL_TEXTURE16                      0x84D0
-#define GL_TEXTURE17                      0x84D1
-#define GL_TEXTURE18                      0x84D2
-#define GL_TEXTURE19                      0x84D3
-#define GL_TEXTURE20                      0x84D4
-#define GL_TEXTURE21                      0x84D5
-#define GL_TEXTURE22                      0x84D6
-#define GL_TEXTURE23                      0x84D7
-#define GL_TEXTURE24                      0x84D8
-#define GL_TEXTURE25                      0x84D9
-#define GL_TEXTURE26                      0x84DA
-#define GL_TEXTURE27                      0x84DB
-#define GL_TEXTURE28                      0x84DC
-#define GL_TEXTURE29                      0x84DD
-#define GL_TEXTURE30                      0x84DE
-#define GL_TEXTURE31                      0x84DF
-#define GL_ACTIVE_TEXTURE                 0x84E0
-#define GL_CLIENT_ACTIVE_TEXTURE          0x84E1
-
-/* TextureWrapMode */
-#define GL_REPEAT                         0x2901
-#define GL_CLAMP_TO_EDGE                  0x812F
-
-/* VertexPointerType */
-/*      GL_SHORT */
-/*      GL_FLOAT */
-/*      GL_FIXED */
-/*      GL_BYTE */
-
-/* LightName */
-#define GL_LIGHT0                         0x4000
-#define GL_LIGHT1                         0x4001
-#define GL_LIGHT2                         0x4002
-#define GL_LIGHT3                         0x4003
-#define GL_LIGHT4                         0x4004
-#define GL_LIGHT5                         0x4005
-#define GL_LIGHT6                         0x4006
-#define GL_LIGHT7                         0x4007
-
-/* Buffer Objects */
-#define GL_ARRAY_BUFFER                   0x8892
-#define GL_ELEMENT_ARRAY_BUFFER           0x8893
-
-#define GL_ARRAY_BUFFER_BINDING               0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING       0x8895
-#define GL_VERTEX_ARRAY_BUFFER_BINDING        0x8896
-#define GL_NORMAL_ARRAY_BUFFER_BINDING        0x8897
-#define GL_COLOR_ARRAY_BUFFER_BINDING         0x8898
-#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
-
-#define GL_STATIC_DRAW                    0x88E4
-#define GL_DYNAMIC_DRAW                   0x88E8
-
-#define GL_BUFFER_SIZE                    0x8764
-#define GL_BUFFER_USAGE                   0x8765
-
-/* Texture combine + dot3 */
-#define GL_SUBTRACT                       0x84E7
-#define GL_COMBINE                        0x8570
-#define GL_COMBINE_RGB                    0x8571
-#define GL_COMBINE_ALPHA                  0x8572
-#define GL_RGB_SCALE                      0x8573
-#define GL_ADD_SIGNED                     0x8574
-#define GL_INTERPOLATE                    0x8575
-#define GL_CONSTANT                       0x8576
-#define GL_PRIMARY_COLOR                  0x8577
-#define GL_PREVIOUS                       0x8578
-#define GL_OPERAND0_RGB                   0x8590
-#define GL_OPERAND1_RGB                   0x8591
-#define GL_OPERAND2_RGB                   0x8592
-#define GL_OPERAND0_ALPHA                 0x8598
-#define GL_OPERAND1_ALPHA                 0x8599
-#define GL_OPERAND2_ALPHA                 0x859A
-
-#define GL_ALPHA_SCALE                    0x0D1C
-
-#define GL_SRC0_RGB                       0x8580
-#define GL_SRC1_RGB                       0x8581
-#define GL_SRC2_RGB                       0x8582
-#define GL_SRC0_ALPHA                     0x8588
-#define GL_SRC1_ALPHA                     0x8589
-#define GL_SRC2_ALPHA                     0x858A
-
-#define GL_DOT3_RGB                       0x86AE
-#define GL_DOT3_RGBA                      0x86AF
-
-/*------------------------------------------------------------------------*
- * required OES extension tokens
- *------------------------------------------------------------------------*/
-
-/* OES_read_format */
-#ifndef GL_OES_read_format
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES                   0x8B9A
-#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES                 0x8B9B
-#endif
-
-/* GL_OES_compressed_paletted_texture */
-#ifndef GL_OES_compressed_paletted_texture
-#define GL_PALETTE4_RGB8_OES                                    0x8B90
-#define GL_PALETTE4_RGBA8_OES                                   0x8B91
-#define GL_PALETTE4_R5_G6_B5_OES                                0x8B92
-#define GL_PALETTE4_RGBA4_OES                                   0x8B93
-#define GL_PALETTE4_RGB5_A1_OES                                 0x8B94
-#define GL_PALETTE8_RGB8_OES                                    0x8B95
-#define GL_PALETTE8_RGBA8_OES                                   0x8B96
-#define GL_PALETTE8_R5_G6_B5_OES                                0x8B97
-#define GL_PALETTE8_RGBA4_OES                                   0x8B98
-#define GL_PALETTE8_RGB5_A1_OES                                 0x8B99
-#endif
-
-/* OES_point_size_array */
-#ifndef GL_OES_point_size_array
-#define GL_POINT_SIZE_ARRAY_OES                                 0x8B9C
-#define GL_POINT_SIZE_ARRAY_TYPE_OES                            0x898A
-#define GL_POINT_SIZE_ARRAY_STRIDE_OES                          0x898B
-#define GL_POINT_SIZE_ARRAY_POINTER_OES                         0x898C
-#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES                  0x8B9F
-#endif
-
-/* GL_OES_point_sprite */
-#ifndef GL_OES_point_sprite
-#define GL_POINT_SPRITE_OES                                     0x8861
-#define GL_COORD_REPLACE_OES                                    0x8862
-#endif
-
-/* GL_OES_draw_texture */
-#ifndef GL_OES_draw_texture
-#define GL_TEXTURE_CROP_RECT_OES                                0x8B9D
-#endif                          /* GL_OES_draw_texture */
-
-/*  GL_OES_vertex_buffer_object */
-#ifndef GL_OES_vertex_buffer_object
-#define GL_ARRAY_BUFFER_OES                                     0x8892
-#define GL_ELEMENT_ARRAY_BUFFER_OES                             0x8893
-#define GL_ARRAY_BUFFER_BINDING_OES                             0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING_OES                     0x8895
-#define GL_VERTEX_ARRAY_BUFFER_BINDING_OES                      0x8896
-#define GL_NORMAL_ARRAY_BUFFER_BINDING_OES                      0x8897
-#define GL_COLOR_ARRAY_BUFFER_BINDING_OES                       0x8898
-#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_OES               0x889A
-#define GL_STATIC_DRAW_OES                                      0x88E4
-#define GL_DYNAMIC_DRAW_OES                                     0x88E8
-#define GL_WRITE_ONLY_OES                                       0x88B9
-#define GL_BUFFER_SIZE_OES                                      0x8764
-#define GL_BUFFER_USAGE_OES                                     0x8765
-#define GL_BUFFER_ACCESS_OES                                    0x88BB
-#endif                          /* GL_OES_vertex_buffer_object */
-
-/*************************************************************/
-
-/* Available only in Common profile */
-    GL_API void GL_APIENTRY glAlphaFunc(GLenum func, GLclampf ref);
-    GL_API void GL_APIENTRY glClearColor(GLclampf red, GLclampf green,
-                                         GLclampf blue, GLclampf alpha);
-    GL_API void GL_APIENTRY glClearDepthf(GLclampf depth);
-    GL_API void GL_APIENTRY glClipPlanef(GLenum plane,
-                                         const GLfloat * equation);
-    GL_API void GL_APIENTRY glColor4f(GLfloat red, GLfloat green,
-                                      GLfloat blue, GLfloat alpha);
-    GL_API void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar);
-    GL_API void GL_APIENTRY glFogf(GLenum pname, GLfloat param);
-    GL_API void GL_APIENTRY glFogfv(GLenum pname, const GLfloat * params);
-    GL_API void GL_APIENTRY glFrustumf(GLfloat left, GLfloat right,
-                                       GLfloat bottom, GLfloat top,
-                                       GLfloat zNear, GLfloat zFar);
-    GL_API void GL_APIENTRY glGetClipPlanef(GLenum pname, GLfloat eqn[4]);
-    GL_API void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat * params);
-    GL_API void GL_APIENTRY glGetLightfv(GLenum light, GLenum pname,
-                                         GLfloat * params);
-    GL_API void GL_APIENTRY glGetMaterialfv(GLenum face, GLenum pname,
-                                            GLfloat * params);
-    GL_API void GL_APIENTRY glGetTexEnvfv(GLenum env, GLenum pname,
-                                          GLfloat * params);
-    GL_API void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname,
-                                                GLfloat * params);
-    GL_API void GL_APIENTRY glLightModelf(GLenum pname, GLfloat param);
-    GL_API void GL_APIENTRY glLightModelfv(GLenum pname,
-                                           const GLfloat * params);
-    GL_API void GL_APIENTRY glLightf(GLenum light, GLenum pname,
-                                     GLfloat param);
-    GL_API void GL_APIENTRY glLightfv(GLenum light, GLenum pname,
-                                      const GLfloat * params);
-    GL_API void GL_APIENTRY glLineWidth(GLfloat width);
-    GL_API void GL_APIENTRY glLoadMatrixf(const GLfloat * m);
-    GL_API void GL_APIENTRY glMaterialf(GLenum face, GLenum pname,
-                                        GLfloat param);
-    GL_API void GL_APIENTRY glMaterialfv(GLenum face, GLenum pname,
-                                         const GLfloat * params);
-    GL_API void GL_APIENTRY glMultMatrixf(const GLfloat * m);
-    GL_API void GL_APIENTRY glMultiTexCoord4f(GLenum target, GLfloat s,
-                                              GLfloat t, GLfloat r,
-                                              GLfloat q);
-    GL_API void GL_APIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz);
-    GL_API void GL_APIENTRY glOrthof(GLfloat left, GLfloat right,
-                                     GLfloat bottom, GLfloat top,
-                                     GLfloat zNear, GLfloat zFar);
-    GL_API void GL_APIENTRY glPointParameterf(GLenum pname, GLfloat param);
-    GL_API void GL_APIENTRY glPointParameterfv(GLenum pname,
-                                               const GLfloat * params);
-    GL_API void GL_APIENTRY glPointSize(GLfloat size);
-    GL_API void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units);
-    GL_API void GL_APIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y,
-                                      GLfloat z);
-    GL_API void GL_APIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z);
-    GL_API void GL_APIENTRY glTexEnvf(GLenum target, GLenum pname,
-                                      GLfloat param);
-    GL_API void GL_APIENTRY glTexEnvfv(GLenum target, GLenum pname,
-                                       const GLfloat * params);
-    GL_API void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname,
-                                            GLfloat param);
-    GL_API void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname,
-                                             const GLfloat * params);
-    GL_API void GL_APIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z);
-
-/* Available in both Common and Common-Lite profiles */
-    GL_API void GL_APIENTRY glActiveTexture(GLenum texture);
-    GL_API void GL_APIENTRY glAlphaFuncx(GLenum func, GLclampx ref);
-    GL_API void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer);
-    GL_API void GL_APIENTRY glBindTexture(GLenum target, GLuint texture);
-    GL_API void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor);
-    GL_API void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size,
-                                         const GLvoid * data, GLenum usage);
-    GL_API void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset,
-                                            GLsizeiptr size,
-                                            const GLvoid * data);
-    GL_API void GL_APIENTRY glClear(GLbitfield mask);
-    GL_API void GL_APIENTRY glClearColorx(GLclampx red, GLclampx green,
-                                          GLclampx blue, GLclampx alpha);
-    GL_API void GL_APIENTRY glClearDepthx(GLclampx depth);
-    GL_API void GL_APIENTRY glClearStencil(GLint s);
-    GL_API void GL_APIENTRY glClientActiveTexture(GLenum texture);
-    GL_API void GL_APIENTRY glClipPlanex(GLenum plane,
-                                         const GLfixed * equation);
-    GL_API void GL_APIENTRY glColor4ub(GLubyte red, GLubyte green,
-                                       GLubyte blue, GLubyte alpha);
-    GL_API void GL_APIENTRY glColor4x(GLfixed red, GLfixed green,
-                                      GLfixed blue, GLfixed alpha);
-    GL_API void GL_APIENTRY glColorMask(GLboolean red, GLboolean green,
-                                        GLboolean blue, GLboolean alpha);
-    GL_API void GL_APIENTRY glColorPointer(GLint size, GLenum type,
-                                           GLsizei stride,
-                                           const GLvoid * pointer);
-    GL_API void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level,
-                                                   GLenum internalformat,
-                                                   GLsizei width,
-                                                   GLsizei height,
-                                                   GLint border,
-                                                   GLsizei imageSize,
-                                                   const GLvoid * data);
-    GL_API void GL_APIENTRY glCompressedTexSubImage2D(GLenum target,
-                                                      GLint level,
-                                                      GLint xoffset,
-                                                      GLint yoffset,
-                                                      GLsizei width,
-                                                      GLsizei height,
-                                                      GLenum format,
-                                                      GLsizei imageSize,
-                                                      const GLvoid * data);
-    GL_API void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level,
-                                             GLenum internalformat, GLint x,
-                                             GLint y, GLsizei width,
-                                             GLsizei height, GLint border);
-    GL_API void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level,
-                                                GLint xoffset, GLint yoffset,
-                                                GLint x, GLint y,
-                                                GLsizei width,
-                                                GLsizei height);
-    GL_API void GL_APIENTRY glCullFace(GLenum mode);
-    GL_API void GL_APIENTRY glDeleteBuffers(GLsizei n,
-                                            const GLuint * buffers);
-    GL_API void GL_APIENTRY glDeleteTextures(GLsizei n,
-                                             const GLuint * textures);
-    GL_API void GL_APIENTRY glDepthFunc(GLenum func);
-    GL_API void GL_APIENTRY glDepthMask(GLboolean flag);
-    GL_API void GL_APIENTRY glDepthRangex(GLclampx zNear, GLclampx zFar);
-    GL_API void GL_APIENTRY glDisable(GLenum cap);
-    GL_API void GL_APIENTRY glDisableClientState(GLenum array);
-    GL_API void GL_APIENTRY glDrawArrays(GLenum mode, GLint first,
-                                         GLsizei count);
-    GL_API void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count,
-                                           GLenum type,
-                                           const GLvoid * indices);
-    GL_API void GL_APIENTRY glEnable(GLenum cap);
-    GL_API void GL_APIENTRY glEnableClientState(GLenum array);
-    GL_API void GL_APIENTRY glFinish(void);
-    GL_API void GL_APIENTRY glFlush(void);
-    GL_API void GL_APIENTRY glFogx(GLenum pname, GLfixed param);
-    GL_API void GL_APIENTRY glFogxv(GLenum pname, const GLfixed * params);
-    GL_API void GL_APIENTRY glFrontFace(GLenum mode);
-    GL_API void GL_APIENTRY glFrustumx(GLfixed left, GLfixed right,
-                                       GLfixed bottom, GLfixed top,
-                                       GLfixed zNear, GLfixed zFar);
-    GL_API void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean * params);
-    GL_API void GL_APIENTRY glGetBufferParameteriv(GLenum target,
-                                                   GLenum pname,
-                                                   GLint * params);
-    GL_API void GL_APIENTRY glGetClipPlanex(GLenum pname, GLfixed eqn[4]);
-    GL_API void GL_APIENTRY glGenBuffers(GLsizei n, GLuint * buffers);
-    GL_API void GL_APIENTRY glGenTextures(GLsizei n, GLuint * textures);
-    GL_API GLenum GL_APIENTRY glGetError(void);
-    GL_API void GL_APIENTRY glGetFixedv(GLenum pname, GLfixed * params);
-    GL_API void GL_APIENTRY glGetIntegerv(GLenum pname, GLint * params);
-    GL_API void GL_APIENTRY glGetLightxv(GLenum light, GLenum pname,
-                                         GLfixed * params);
-    GL_API void GL_APIENTRY glGetMaterialxv(GLenum face, GLenum pname,
-                                            GLfixed * params);
-    GL_API void GL_APIENTRY glGetPointerv(GLenum pname, void **params);
-    GL_API const GLubyte *GL_APIENTRY glGetString(GLenum name);
-    GL_API void GL_APIENTRY glGetTexEnviv(GLenum env, GLenum pname,
-                                          GLint * params);
-    GL_API void GL_APIENTRY glGetTexEnvxv(GLenum env, GLenum pname,
-                                          GLfixed * params);
-    GL_API void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname,
-                                                GLint * params);
-    GL_API void GL_APIENTRY glGetTexParameterxv(GLenum target, GLenum pname,
-                                                GLfixed * params);
-    GL_API void GL_APIENTRY glHint(GLenum target, GLenum mode);
-    GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer);
-    GL_API GLboolean GL_APIENTRY glIsEnabled(GLenum cap);
-    GL_API GLboolean GL_APIENTRY glIsTexture(GLuint texture);
-    GL_API void GL_APIENTRY glLightModelx(GLenum pname, GLfixed param);
-    GL_API void GL_APIENTRY glLightModelxv(GLenum pname,
-                                           const GLfixed * params);
-    GL_API void GL_APIENTRY glLightx(GLenum light, GLenum pname,
-                                     GLfixed param);
-    GL_API void GL_APIENTRY glLightxv(GLenum light, GLenum pname,
-                                      const GLfixed * params);
-    GL_API void GL_APIENTRY glLineWidthx(GLfixed width);
-    GL_API void GL_APIENTRY glLoadIdentity(void);
-    GL_API void GL_APIENTRY glLoadMatrixx(const GLfixed * m);
-    GL_API void GL_APIENTRY glLogicOp(GLenum opcode);
-    GL_API void GL_APIENTRY glMaterialx(GLenum face, GLenum pname,
-                                        GLfixed param);
-    GL_API void GL_APIENTRY glMaterialxv(GLenum face, GLenum pname,
-                                         const GLfixed * params);
-    GL_API void GL_APIENTRY glMatrixMode(GLenum mode);
-    GL_API void GL_APIENTRY glMultMatrixx(const GLfixed * m);
-    GL_API void GL_APIENTRY glMultiTexCoord4x(GLenum target, GLfixed s,
-                                              GLfixed t, GLfixed r,
-                                              GLfixed q);
-    GL_API void GL_APIENTRY glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz);
-    GL_API void GL_APIENTRY glNormalPointer(GLenum type, GLsizei stride,
-                                            const GLvoid * pointer);
-    GL_API void GL_APIENTRY glOrthox(GLfixed left, GLfixed right,
-                                     GLfixed bottom, GLfixed top,
-                                     GLfixed zNear, GLfixed zFar);
-    GL_API void GL_APIENTRY glPixelStorei(GLenum pname, GLint param);
-    GL_API void GL_APIENTRY glPointParameterx(GLenum pname, GLfixed param);
-    GL_API void GL_APIENTRY glPointParameterxv(GLenum pname,
-                                               const GLfixed * params);
-    GL_API void GL_APIENTRY glPointSizex(GLfixed size);
-    GL_API void GL_APIENTRY glPolygonOffsetx(GLfixed factor, GLfixed units);
-    GL_API void GL_APIENTRY glPopMatrix(void);
-    GL_API void GL_APIENTRY glPushMatrix(void);
-    GL_API void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width,
-                                         GLsizei height, GLenum format,
-                                         GLenum type, GLvoid * pixels);
-    GL_API void GL_APIENTRY glRotatex(GLfixed angle, GLfixed x, GLfixed y,
-                                      GLfixed z);
-    GL_API void GL_APIENTRY glSampleCoverage(GLclampf value,
-                                             GLboolean invert);
-    GL_API void GL_APIENTRY glSampleCoveragex(GLclampx value,
-                                              GLboolean invert);
-    GL_API void GL_APIENTRY glScalex(GLfixed x, GLfixed y, GLfixed z);
-    GL_API void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width,
-                                      GLsizei height);
-    GL_API void GL_APIENTRY glShadeModel(GLenum mode);
-    GL_API void GL_APIENTRY glStencilFunc(GLenum func, GLint ref,
-                                          GLuint mask);
-    GL_API void GL_APIENTRY glStencilMask(GLuint mask);
-    GL_API void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail,
-                                        GLenum zpass);
-    GL_API void GL_APIENTRY glTexCoordPointer(GLint size, GLenum type,
-                                              GLsizei stride,
-                                              const GLvoid * pointer);
-    GL_API void GL_APIENTRY glTexEnvi(GLenum target, GLenum pname,
-                                      GLint param);
-    GL_API void GL_APIENTRY glTexEnvx(GLenum target, GLenum pname,
-                                      GLfixed param);
-    GL_API void GL_APIENTRY glTexEnviv(GLenum target, GLenum pname,
-                                       const GLint * params);
-    GL_API void GL_APIENTRY glTexEnvxv(GLenum target, GLenum pname,
-                                       const GLfixed * params);
-    GL_API void GL_APIENTRY glTexImage2D(GLenum target, GLint level,
-                                         GLint internalformat, GLsizei width,
-                                         GLsizei height, GLint border,
-                                         GLenum format, GLenum type,
-                                         const GLvoid * pixels);
-    GL_API void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname,
-                                            GLint param);
-    GL_API void GL_APIENTRY glTexParameterx(GLenum target, GLenum pname,
-                                            GLfixed param);
-    GL_API void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname,
-                                             const GLint * params);
-    GL_API void GL_APIENTRY glTexParameterxv(GLenum target, GLenum pname,
-                                             const GLfixed * params);
-    GL_API void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level,
-                                            GLint xoffset, GLint yoffset,
-                                            GLsizei width, GLsizei height,
-                                            GLenum format, GLenum type,
-                                            const GLvoid * pixels);
-    GL_API void GL_APIENTRY glTranslatex(GLfixed x, GLfixed y, GLfixed z);
-    GL_API void GL_APIENTRY glVertexPointer(GLint size, GLenum type,
-                                            GLsizei stride,
-                                            const GLvoid * pointer);
-    GL_API void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width,
-                                       GLsizei height);
-
-/*------------------------------------------------------------------------*
- * Required OES extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_OES_read_format */
-#ifndef GL_OES_read_format
-#define GL_OES_read_format 1
-#endif
-
-/* GL_OES_compressed_paletted_texture */
-#ifndef GL_OES_compressed_paletted_texture
-#define GL_OES_compressed_paletted_texture 1
-#endif
-
-/* GL_OES_point_size_array */
-#ifndef GL_OES_point_size_array
-#define GL_OES_point_size_array 1
-    GL_API void GL_APIENTRY glPointSizePointerOES(GLenum type, GLsizei stride,
-                                                  const GLvoid * pointer);
-#endif
-
-/* GL_OES_query_matrix */
-#ifndef GL_OES_query_matrix
-#define GL_OES_query_matrix 1
-    GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES(GLfixed mantissa[16],
-                                                    GLint exponent[16]);
-#endif                          /* GL_OES_query_matrix */
-
-/* GL_OES_point_sprite */
-#ifndef GL_OES_point_sprite
-#define GL_OES_point_sprite 1
-#endif
-
-/* GL_OES_draw_texture */
-#ifndef GL_OES_draw_texture
-#define GL_OES_draw_texture 1
-    GL_API void GL_APIENTRY glDrawTexsOES(GLshort x, GLshort y, GLshort z,
-                                          GLshort width, GLshort height);
-    GL_API void GL_APIENTRY glDrawTexiOES(GLint x, GLint y, GLint z,
-                                          GLint width, GLint height);
-    GL_API void GL_APIENTRY glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z,
-                                          GLfixed width, GLfixed height);
-    GL_API void GL_APIENTRY glDrawTexsvOES(const GLshort * coords);
-    GL_API void GL_APIENTRY glDrawTexivOES(const GLint * coords);
-    GL_API void GL_APIENTRY glDrawTexxvOES(const GLfixed * coords);
-    GL_API void GL_APIENTRY glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z,
-                                          GLfloat width, GLfloat height);
-    GL_API void GL_APIENTRY glDrawTexfvOES(const GLfloat * coords);
-#endif                          /* GL_OES_draw_texture */
-
-/* GL_OES_single_precision */
-#ifndef GL_OES_single_precision
-#define GL_OES_single_precision 1
-    GL_API void GL_APIENTRY glDepthRangefOES(GLclampf zNear, GLclampf zFar);
-    GL_API void GL_APIENTRY glFrustumfOES(GLfloat left, GLfloat right,
-                                          GLfloat bottom, GLfloat top,
-                                          GLfloat zNear, GLfloat zFar);
-    GL_API void GL_APIENTRY glOrthofOES(GLfloat left, GLfloat right,
-                                        GLfloat bottom, GLfloat top,
-                                        GLfloat zNear, GLfloat zFar);
-    GL_API void GL_APIENTRY glClipPlanefOES(GLenum plane,
-                                            const GLfloat * equation);
-    GL_API void GL_APIENTRY glGetClipPlanefOES(GLenum pname, GLfloat eqn[4]);
-    GL_API void GL_APIENTRY glClearDepthfOES(GLclampf depth);
-#endif                          /* GL_OES_single_precision */
-
-/* GL_OES_vertex_buffer_object */
-#ifndef GL_OES_vertex_buffer_object
-#define GL_OES_vertex_buffer_object 1
-    GL_API void APIENTRY glBindBufferOES(GLenum, GLuint);
-    GL_API void APIENTRY glDeleteBuffersOES(GLsizei, const GLuint *);
-    GL_API void APIENTRY glGenBuffersOES(GLsizei, GLuint *);
-    GL_API GLboolean APIENTRY glIsBufferOES(GLuint);
-    GL_API void APIENTRY glBufferDataOES(GLenum, GLsizeiptr, const GLvoid *,
-                                         GLenum);
-    GL_API void APIENTRY glBufferSubDataOES(GLenum, GLintptr, GLsizeiptr,
-                                            const GLvoid *);
-    GL_API void APIENTRY glGetBufferParameterivOES(GLenum, GLenum, GLint *);
-#endif                          /* GL_OES_vertex_buffer_object */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif                          /* __gles_h_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_opengles2.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,39 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+/**
+ *  \file SDL_opengles.h
+ *  
+ *  This is a simple file to encapsulate the OpenGL ES 2.0 API headers.
+ */
+
+#ifdef __IPHONEOS__
+#include <OpenGLES/ES2/gl.h>
+#include <OpenGLES/ES2/glext.h>
+#else
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
--- a/include/SDL_pixels.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_pixels.h	Sun Feb 06 21:23:32 2011 -0800
@@ -122,18 +122,26 @@
 #define SDL_PIXELORDER(X)	(((X) >> 20) & 0x0F)
 #define SDL_PIXELLAYOUT(X)	(((X) >> 16) & 0x0F)
 #define SDL_BITSPERPIXEL(X)	(((X) >> 8) & 0xFF)
-#define SDL_BYTESPERPIXEL(X)	(((X) >> 0) & 0xFF)
+#define SDL_BYTESPERPIXEL(X) \
+    (SDL_ISPIXELFORMAT_FOURCC(X) ? \
+        ((((X) == SDL_PIXELFORMAT_YV12) || \
+          ((X) == SDL_PIXELFORMAT_IYUV) || \
+          ((X) == SDL_PIXELFORMAT_YUY2) || \
+          ((X) == SDL_PIXELFORMAT_UYVY) || \
+          ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF))
 
 #define SDL_ISPIXELFORMAT_INDEXED(format)   \
-    ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
-     (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
-     (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))
+    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
+     ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
+      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
+      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
 
 #define SDL_ISPIXELFORMAT_ALPHA(format)   \
-    ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
-     (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
-     (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
-     (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))
+    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
+     ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
+      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
+      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
+      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA)))
 
 #define SDL_ISPIXELFORMAT_FOURCC(format)    \
     ((format) && !((format) & 0x80000000))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_render.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,587 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+/**
+ *  \file SDL_render.h
+ *  
+ *  Header file for SDL 2D rendering functions.
+ *
+ *  This API supports the following features:
+ *      * single pixel points
+ *      * single pixel lines
+ *      * filled rectangles
+ *      * texture images
+ *
+ *  The primitives may be drawn in opaque, blended, or additive modes.
+ *
+ *  The texture images may be drawn in opaque, blended, or additive modes.
+ *  They can have an additional color tint or alpha modulation applied to
+ *  them, and may also be stretched with linear interpolation.
+ *
+ *  This API is designed to accelerate simple 2D operations. You may
+ *  want more functionality such as rotation and particle effects and
+ *  in that case you should use SDL's OpenGL/Direct3D support or one
+ *  of the many good 3D engines.
+ */
+
+#ifndef _SDL_render_h
+#define _SDL_render_h
+
+#include "SDL_stdinc.h"
+#include "SDL_rect.h"
+#include "SDL_video.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+/**
+ *  \brief Flags used when creating a rendering context
+ */
+typedef enum
+{
+    SDL_RENDERER_ACCELERATED = 0x00000001,      /**< The renderer uses hardware 
+                                                     acceleration */
+    SDL_RENDERER_PRESENTVSYNC = 0x00000002      /**< Present is synchronized 
+                                                     with the refresh rate */
+} SDL_RendererFlags;
+
+/**
+ *  \brief Information on the capabilities of a render driver or context.
+ */
+typedef struct SDL_RendererInfo
+{
+    const char *name;           /**< The name of the renderer */
+    Uint32 flags;               /**< Supported ::SDL_RendererFlags */
+    Uint32 num_texture_formats; /**< The number of available texture formats */
+    Uint32 texture_formats[16]; /**< The available texture formats */
+    int max_texture_width;      /**< The maximimum texture width */
+    int max_texture_height;     /**< The maximimum texture height */
+} SDL_RendererInfo;
+
+/**
+ *  \brief The access pattern allowed for a texture.
+ */
+typedef enum
+{
+    SDL_TEXTUREACCESS_STATIC,    /**< Changes rarely, not lockable */
+    SDL_TEXTUREACCESS_STREAMING  /**< Changes frequently, lockable */
+} SDL_TextureAccess;
+
+/**
+ *  \brief The texture channel modulation used in SDL_RenderCopy().
+ */
+typedef enum
+{
+    SDL_TEXTUREMODULATE_NONE = 0x00000000,     /**< No modulation */
+    SDL_TEXTUREMODULATE_COLOR = 0x00000001,    /**< srcC = srcC * color */
+    SDL_TEXTUREMODULATE_ALPHA = 0x00000002     /**< srcA = srcA * alpha */
+} SDL_TextureModulate;
+
+/**
+ *  \brief A structure representing rendering state
+ */
+struct SDL_Renderer;
+typedef struct SDL_Renderer SDL_Renderer;
+
+/**
+ *  \brief An efficient driver-specific representation of pixel data
+ */
+struct SDL_Texture;
+typedef struct SDL_Texture SDL_Texture;
+
+
+/* Function prototypes */
+
+/**
+ *  \brief Get the number of 2D rendering drivers available for the current 
+ *         display.
+ *  
+ *  A render driver is a set of code that handles rendering and texture
+ *  management on a particular display.  Normally there is only one, but
+ *  some drivers may have several available with different capabilities.
+ *  
+ *  \sa SDL_GetRenderDriverInfo()
+ *  \sa SDL_CreateRenderer()
+ */
+extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
+
+/**
+ *  \brief Get information about a specific 2D rendering driver for the current 
+ *         display.
+ *  
+ *  \param index The index of the driver to query information about.
+ *  \param info  A pointer to an SDL_RendererInfo struct to be filled with 
+ *               information on the rendering driver.
+ *  
+ *  \return 0 on success, -1 if the index was out of range.
+ *  
+ *  \sa SDL_CreateRenderer()
+ */
+extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index,
+                                                    SDL_RendererInfo * info);
+
+/**
+ *  \brief Create a 2D rendering context for a window.
+ *  
+ *  \param window The window where rendering is displayed.
+ *  \param index    The index of the rendering driver to initialize, or -1 to 
+ *                  initialize the first one supporting the requested flags.
+ *  \param flags    ::SDL_RendererFlags.
+ *  
+ *  \return A valid rendering context or NULL if there was an error.
+ *  
+ *  \sa SDL_CreateSoftwareRenderer()
+ *  \sa SDL_GetRendererInfo()
+ *  \sa SDL_DestroyRenderer()
+ */
+extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
+                                               int index, Uint32 flags);
+
+/**
+ *  \brief Create a 2D software rendering context for a surface.
+ *  
+ *  \param surface The surface where rendering is done.
+ *  
+ *  \return A valid rendering context or NULL if there was an error.
+ *  
+ *  \sa SDL_CreateRenderer()
+ *  \sa SDL_DestroyRenderer()
+ */
+extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface);
+
+/**
+ *  \brief Get information about a rendering context.
+ */
+extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer,
+                                                SDL_RendererInfo * info);
+
+/**
+ *  \brief Create a texture for a rendering context.
+ *  
+ *  \param format The format of the texture.
+ *  \param access One of the enumerated values in ::SDL_TextureAccess.
+ *  \param w      The width of the texture in pixels.
+ *  \param h      The height of the texture in pixels.
+ *  
+ *  \return The created texture is returned, or 0 if no rendering context was 
+ *          active,  the format was unsupported, or the width or height were out
+ *          of range.
+ *  
+ *  \sa SDL_QueryTexture()
+ *  \sa SDL_DestroyTexture()
+ */
+extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,                                                        Uint32 format,
+                                                        int access, int w,
+                                                        int h);
+
+/**
+ *  \brief Create a texture from an existing surface.
+ *  
+ *  \param surface The surface containing pixel data used to fill the texture.
+ *  
+ *  \return The created texture is returned, or 0 on error.
+ *  
+ *  \note The surface is not modified or freed by this function.
+ *  
+ *  \sa SDL_QueryTexture()
+ *  \sa SDL_DestroyTexture()
+ */
+extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
+
+/**
+ *  \brief Query the attributes of a texture
+ *  
+ *  \param texture A texture to be queried.
+ *  \param format  A pointer filled in with the raw format of the texture.  The 
+ *                 actual format may differ, but pixel transfers will use this 
+ *                 format.
+ *  \param access  A pointer filled in with the actual access to the texture.
+ *  \param w       A pointer filled in with the width of the texture in pixels.
+ *  \param h       A pointer filled in with the height of the texture in pixels.
+ *  
+ *  \return 0 on success, or -1 if the texture is not valid.
+ */
+extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
+                                             Uint32 * format, int *access,
+                                             int *w, int *h);
+
+/**
+ *  \brief Set an additional color value used in render copy operations.
+ *  
+ *  \param texture The texture to update.
+ *  \param r       The red color value multiplied into copy operations.
+ *  \param g       The green color value multiplied into copy operations.
+ *  \param b       The blue color value multiplied into copy operations.
+ *  
+ *  \return 0 on success, or -1 if the texture is not valid or color modulation 
+ *          is not supported.
+ *  
+ *  \sa SDL_GetTextureColorMod()
+ */
+extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
+                                                   Uint8 r, Uint8 g, Uint8 b);
+
+
+/**
+ *  \brief Get the additional color value used in render copy operations.
+ *  
+ *  \param texture The texture to query.
+ *  \param r         A pointer filled in with the current red color value.
+ *  \param g         A pointer filled in with the current green color value.
+ *  \param b         A pointer filled in with the current blue color value.
+ *  
+ *  \return 0 on success, or -1 if the texture is not valid.
+ *  
+ *  \sa SDL_SetTextureColorMod()
+ */
+extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
+                                                   Uint8 * r, Uint8 * g,
+                                                   Uint8 * b);
+
+/**
+ *  \brief Set an additional alpha value used in render copy operations.
+ *  
+ *  \param texture The texture to update.
+ *  \param alpha     The alpha value multiplied into copy operations.
+ *  
+ *  \return 0 on success, or -1 if the texture is not valid or alpha modulation 
+ *          is not supported.
+ *  
+ *  \sa SDL_GetTextureAlphaMod()
+ */
+extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
+                                                   Uint8 alpha);
+
+/**
+ *  \brief Get the additional alpha value used in render copy operations.
+ *  
+ *  \param texture The texture to query.
+ *  \param alpha     A pointer filled in with the current alpha value.
+ *  
+ *  \return 0 on success, or -1 if the texture is not valid.
+ *  
+ *  \sa SDL_SetTextureAlphaMod()
+ */
+extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
+                                                   Uint8 * alpha);
+
+/**
+ *  \brief Set the blend mode used for texture copy operations.
+ *  
+ *  \param texture The texture to update.
+ *  \param blendMode ::SDL_BlendMode to use for texture blending.
+ *  
+ *  \return 0 on success, or -1 if the texture is not valid or the blend mode is
+ *          not supported.
+ *  
+ *  \note If the blend mode is not supported, the closest supported mode is
+ *        chosen.
+ *  
+ *  \sa SDL_GetTextureBlendMode()
+ */
+extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
+                                                    SDL_BlendMode blendMode);
+
+/**
+ *  \brief Get the blend mode used for texture copy operations.
+ *  
+ *  \param texture   The texture to query.
+ *  \param blendMode A pointer filled in with the current blend mode.
+ *  
+ *  \return 0 on success, or -1 if the texture is not valid.
+ *  
+ *  \sa SDL_SetTextureBlendMode()
+ */
+extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
+                                                    SDL_BlendMode *blendMode);
+
+/**
+ *  \brief Update the given texture rectangle with new pixel data.
+ *  
+ *  \param texture   The texture to update
+ *  \param rect      A pointer to the rectangle of pixels to update, or NULL to 
+ *                   update the entire texture.
+ *  \param pixels    The raw pixel data.
+ *  \param pitch     The number of bytes between rows of pixel data.
+ *  
+ *  \return 0 on success, or -1 if the texture is not valid.
+ *  
+ *  \note This is a fairly slow function.
+ */
+extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
+                                              const SDL_Rect * rect,
+                                              const void *pixels, int pitch);
+
+/**
+ *  \brief Lock a portion of the texture for pixel access.
+ *  
+ *  \param texture   The texture to lock for access, which was created with 
+ *                   ::SDL_TEXTUREACCESS_STREAMING.
+ *  \param rect      A pointer to the rectangle to lock for access. If the rect 
+ *                   is NULL, the entire texture will be locked.
+ *  \param pixels    This is filled in with a pointer to the locked pixels, 
+ *                   appropriately offset by the locked area.
+ *  \param pitch     This is filled in with the pitch of the locked pixels.
+ *  
+ *  \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING.
+ *  
+ *  \sa SDL_UnlockTexture()
+ */
+extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
+                                            const SDL_Rect * rect,
+                                            void **pixels, int *pitch);
+
+/**
+ *  \brief Unlock a texture, uploading the changes to video memory, if needed.
+ *  
+ *  \sa SDL_LockTexture()
+ */
+extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
+
+/**
+ *  \brief Set the color used for drawing operations (Fill and Line).
+ *  
+ *  \param r The red value used to draw on the rendering target.
+ *  \param g The green value used to draw on the rendering target.
+ *  \param b The blue value used to draw on the rendering target.
+ *  \param a The alpha value used to draw on the rendering target, usually 
+ *           ::SDL_ALPHA_OPAQUE (255).
+ *  
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDL_SetRenderDrawColor(SDL_Renderer * renderer,
+                                           Uint8 r, Uint8 g, Uint8 b,
+                                           Uint8 a);
+
+/**
+ *  \brief Get the color used for drawing operations (Fill and Line).
+ *  
+ *  \param r A pointer to the red value used to draw on the rendering target.
+ *  \param g A pointer to the green value used to draw on the rendering target.
+ *  \param b A pointer to the blue value used to draw on the rendering target.
+ *  \param a A pointer to the alpha value used to draw on the rendering target, 
+ *           usually ::SDL_ALPHA_OPAQUE (255).
+ *  
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDL_GetRenderDrawColor(SDL_Renderer * renderer,
+                                           Uint8 * r, Uint8 * g, Uint8 * b,
+                                           Uint8 * a);
+
+/**
+ *  \brief Set the blend mode used for drawing operations (Fill and Line).
+ *  
+ *  \param blendMode ::SDL_BlendMode to use for blending.
+ *  
+ *  \return 0 on success, or -1 on error
+ *  
+ *  \note If the blend mode is not supported, the closest supported mode is 
+ *        chosen.
+ *  
+ *  \sa SDL_GetRenderDrawBlendMode()
+ */
+extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
+                                                       SDL_BlendMode blendMode);
+
+/**
+ *  \brief Get the blend mode used for drawing operations.
+ *  
+ *  \param blendMode A pointer filled in with the current blend mode.
+ *  
+ *  \return 0 on success, or -1 on error
+ *  
+ *  \sa SDL_SetRenderDrawBlendMode()
+ */
+extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
+                                                       SDL_BlendMode *blendMode);
+
+/**
+ *  \brief Clear the current rendering target with the drawing color
+ */
+extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
+
+/**
+ *  \brief Draw a point on the current rendering target.
+ *  
+ *  \param x The x coordinate of the point.
+ *  \param y The y coordinate of the point.
+ *  
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
+                                                int x, int y);
+
+/**
+ *  \brief Draw multiple points on the current rendering target.
+ *  
+ *  \param points The points to draw
+ *  \param count The number of points to draw
+ *  
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
+                                                 const SDL_Point * points,
+                                                 int count);
+
+/**
+ *  \brief Draw a line on the current rendering target.
+ *  
+ *  \param x1 The x coordinate of the start point.
+ *  \param y1 The y coordinate of the start point.
+ *  \param x2 The x coordinate of the end point.
+ *  \param y2 The y coordinate of the end point.
+ *  
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
+                                               int x1, int y1, int x2, int y2);
+
+/**
+ *  \brief Draw a series of connected lines on the current rendering target.
+ *  
+ *  \param points The points along the lines
+ *  \param count The number of points, drawing count-1 lines
+ *  
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
+                                                const SDL_Point * points,
+                                                int count);
+
+/**
+ *  \brief Draw a rectangle on the current rendering target.
+ *  
+ *  \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
+ *  
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
+                                               const SDL_Rect * rect);
+
+/**
+ *  \brief Draw some number of rectangles on the current rendering target.
+ *  
+ *  \param rects A pointer to an array of destination rectangles.
+ *  \param count The number of rectangles.
+ *  
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
+                                                const SDL_Rect ** rects,
+                                                int count);
+
+/**
+ *  \brief Fill a rectangle on the current rendering target with the drawing color.
+ *  
+ *  \param rect A pointer to the destination rectangle, or NULL for the entire 
+ *              rendering target.
+ *  
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
+                                               const SDL_Rect * rect);
+
+/**
+ *  \brief Fill some number of rectangles on the current rendering target with the drawing color.
+ *  
+ *  \param rects A pointer to an array of destination rectangles.
+ *  \param count The number of rectangles.
+ *  
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
+                                                const SDL_Rect ** rect,
+                                                int count);
+
+/**
+ *  \brief Copy a portion of the texture to the current rendering target.
+ *  
+ *  \param texture The source texture.
+ *  \param srcrect   A pointer to the source rectangle, or NULL for the entire 
+ *                   texture.
+ *  \param dstrect   A pointer to the destination rectangle, or NULL for the 
+ *                   entire rendering target.
+ *  
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
+                                           SDL_Texture * texture,
+                                           const SDL_Rect * srcrect,
+                                           const SDL_Rect * dstrect);
+
+/**
+ *  \brief Read pixels from the current rendering target.
+ *  
+ *  \param rect   A pointer to the rectangle to read, or NULL for the entire 
+ *                render target.
+ *  \param format The desired format of the pixel data, or 0 to use the format
+ *                of the rendering target
+ *  \param pixels A pointer to be filled in with the pixel data
+ *  \param pitch  The pitch of the pixels parameter.
+ *  
+ *  \return 0 on success, or -1 if pixel reading is not supported.
+ *  
+ *  \warning This is a very slow operation, and should not be used frequently.
+ */
+extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
+                                                 const SDL_Rect * rect,
+                                                 Uint32 format,
+                                                 void *pixels, int pitch);
+
+/**
+ *  \brief Update the screen with rendering performed.
+ */
+extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
+
+/**
+ *  \brief Destroy the specified texture.
+ *  
+ *  \sa SDL_CreateTexture()
+ *  \sa SDL_CreateTextureFromSurface()
+ */
+extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
+
+/**
+ *  \brief Destroy the rendering context for a window and free associated
+ *         textures.
+ *  
+ *  \sa SDL_CreateRenderer()
+ */
+extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_render_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/include/SDL_scalemode.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-/**
- *  \file SDL_scalemode.h
- *  
- *  Header file declaring the SDL_ScaleMode enumeration
- */
-
-#ifndef _SDL_scalemode_h
-#define _SDL_scalemode_h
-
-#include "begin_code.h"
-/* Set up for C function definitions, even when using C++ */
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/**
- *  \brief The texture scale mode used in SDL_RenderCopy().
- */
-typedef enum
-{
-    SDL_SCALEMODE_NONE = 0x00000000,     /**< No scaling, rectangles must
-                                              match dimensions */
-    
-    SDL_SCALEMODE_FAST = 0x00000001,     /**< Point sampling or 
-                                              equivalent algorithm */
-    
-    SDL_SCALEMODE_SLOW = 0x00000002,     /**< Linear filtering or 
-                                              equivalent algorithm */
-    
-    SDL_SCALEMODE_BEST = 0x00000004      /**< Bicubic filtering or 
-                                              equivalent algorithm */
-} SDL_ScaleMode;
-
-
-/* Ends C function definitions when using C++ */
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-#include "close_code.h"
-
-#endif /* _SDL_video_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/include/SDL_surface.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_surface.h	Sun Feb 06 21:23:32 2011 -0800
@@ -33,7 +33,6 @@
 #include "SDL_pixels.h"
 #include "SDL_rect.h"
 #include "SDL_blendmode.h"
-#include "SDL_scalemode.h"
 #include "SDL_rwops.h"
 
 #include "begin_code.h"
@@ -318,37 +317,6 @@
                                                     SDL_BlendMode *blendMode);
 
 /**
- *  \brief Set the scale mode used for blit operations.
- *  
- *  \param surface   The surface to update.
- *  \param scaleMode ::SDL_ScaleMode to use for blit scaling.
- *  
- *  \return 0 on success, or -1 if the surface is not valid or the scale mode is
- *          not supported.
- *  
- *  \note If the scale mode is not supported, the closest supported mode is 
- *        chosen.  Currently only ::SDL_TEXTURESCALEMODE_FAST is supported on 
- *        surfaces.
- *  
- *  \sa SDL_GetSurfaceScaleMode()
- */
-extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface * surface,
-                                                    SDL_ScaleMode scaleMode);
-
-/**
- *  \brief Get the scale mode used for blit operations.
- *  
- *  \param surface   The surface to query.
- *  \param scaleMode A pointer filled in with the current scale mode.
- *  
- *  \return 0 on success, or -1 if the surface is not valid.
- *  
- *  \sa SDL_SetSurfaceScaleMode()
- */
-extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface * surface,
-                                                    SDL_ScaleMode *scaleMode);
-
-/**
  *  Sets the clipping rectangle for the destination surface in a blit.
  *  
  *  If the clip rectangle is NULL, clipping will be disabled.
@@ -396,85 +364,6 @@
                                               void * dst, int dst_pitch);
 
 /**
- *  Draws a point with \c color.
- *
- *  The color should be a pixel of the format used by the surface, and 
- *  can be generated by the SDL_MapRGB() function.
- *  
- *  \return 0 on success, or -1 on error.
- */
-extern DECLSPEC int SDLCALL SDL_DrawPoint
-    (SDL_Surface * dst, int x, int y, Uint32 color);
-extern DECLSPEC int SDLCALL SDL_DrawPoints
-    (SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
-
-/**
- *  Blends a point with an RGBA value.
- *  
- *  \return 0 on success, or -1 on error.
- */
-extern DECLSPEC int SDLCALL SDL_BlendPoint
-    (SDL_Surface * dst, int x, int y,
-     SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
-extern DECLSPEC int SDLCALL SDL_BlendPoints
-    (SDL_Surface * dst, const SDL_Point * points, int count,
-     SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
-
-/**
- *  Draws a line with \c color.
- *  
- *  The color should be a pixel of the format used by the surface, and 
- *  can be generated by the SDL_MapRGB() function.
- *  
- *  \return 0 on success, or -1 on error.
- */
-extern DECLSPEC int SDLCALL SDL_DrawLine
-    (SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color);
-extern DECLSPEC int SDLCALL SDL_DrawLines
-    (SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
-
-/**
- *  Blends an RGBA value along a line.
- *  
- *  \return 0 on success, or -1 on error.
- */
-extern DECLSPEC int SDLCALL SDL_BlendLine
-    (SDL_Surface * dst, int x1, int y1, int x2, int y2,
-     SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
-extern DECLSPEC int SDLCALL SDL_BlendLines
-    (SDL_Surface * dst, const SDL_Point * points, int count,
-     SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
-
-/**
- *  Draws the given rectangle with \c color.
- *  
- *  If \c rect is NULL, the whole surface will be outlined with \c color.
- *  
- *  The color should be a pixel of the format used by the surface, and 
- *  can be generated by the SDL_MapRGB() function.
- *  
- *  \return 0 on success, or -1 on error.
- */
-extern DECLSPEC int SDLCALL SDL_DrawRect
-    (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
-extern DECLSPEC int SDLCALL SDL_DrawRects
-    (SDL_Surface * dst, const SDL_Rect ** rects, int count, Uint32 color);
-
-/**
- *  Blends an RGBA value into the outline of the given rectangle.
- *  
- *  If \c rect is NULL, the whole surface will have a blended outline.
- *  
- *  \return 0 on success, or -1 on error.
- */
-extern DECLSPEC int SDLCALL SDL_BlendRect
-    (SDL_Surface * dst, const SDL_Rect * rect,
-     SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
-extern DECLSPEC int SDLCALL SDL_BlendRects
-    (SDL_Surface * dst, const SDL_Rect ** rects, int count,
-     SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
-
-/**
  *  Performs a fast fill of the given rectangle with \c color.
  *  
  *  If \c rect is NULL, the whole surface will be filled with \c color.
@@ -490,20 +379,6 @@
     (SDL_Surface * dst, const SDL_Rect ** rects, int count, Uint32 color);
 
 /**
- *  Blends an RGBA value into the given rectangle.
- *  
- *  If \c rect is NULL, the whole surface will be blended with the color.
- *  
- *  \return This function returns 0 on success, or -1 on error.
- */
-extern DECLSPEC int SDLCALL SDL_BlendFillRect
-    (SDL_Surface * dst, const SDL_Rect * rect,
-     SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
-extern DECLSPEC int SDLCALL SDL_BlendFillRects
-    (SDL_Surface * dst, const SDL_Rect ** rects, int count,
-     SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
-
-/**
  *  Performs a fast blit from the source surface to the destination surface.
  *  
  *  This assumes that the source and destination rectangles are
--- a/include/SDL_syswm.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_syswm.h	Sun Feb 06 21:23:32 2011 -0800
@@ -77,7 +77,7 @@
 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
 
 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
-#include <directfb/directfb.h>
+#include <directfb.h>
 #endif
 
 #if defined(SDL_VIDEO_DRIVER_COCOA)
--- a/include/SDL_video.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/include/SDL_video.h	Sun Feb 06 21:23:32 2011 -0800
@@ -32,8 +32,6 @@
 #include "SDL_stdinc.h"
 #include "SDL_pixels.h"
 #include "SDL_rect.h"
-#include "SDL_blendmode.h"
-#include "SDL_scalemode.h"
 #include "SDL_surface.h"
 
 #include "begin_code.h"
@@ -148,80 +146,6 @@
 } SDL_WindowEventID;
 
 /**
- *  \brief Flags used when creating a rendering context
- */
-typedef enum
-{
-    SDL_RENDERER_SINGLEBUFFER = 0x00000001,     /**< Render directly to the 
-                                                     window, if possible */
-    
-    SDL_RENDERER_PRESENTCOPY = 0x00000002,      /**< Present uses a copy from 
-                                                     back buffer to the front 
-                                                     buffer */
-    
-    SDL_RENDERER_PRESENTFLIP2 = 0x00000004,     /**< Present uses a flip, 
-                                                     swapping back buffer and 
-                                                     front buffer */
-    
-    SDL_RENDERER_PRESENTFLIP3 = 0x00000008,     /**< Present uses a flip, 
-                                                     rotating between two back 
-                                                     buffers and a front buffer
-                                                 */
-    
-    SDL_RENDERER_PRESENTDISCARD = 0x00000010,   /**< Present leaves the contents
-                                                     of the backbuffer undefined
-                                                 */
-    
-    SDL_RENDERER_PRESENTVSYNC = 0x00000020,     /**< Present is synchronized 
-                                                     with the refresh rate */
-    
-    SDL_RENDERER_ACCELERATED = 0x00000040       /**< The renderer uses hardware 
-                                                     acceleration */
-    
-    } SDL_RendererFlags;
-
-/**
- *  \brief Information on the capabilities of a render driver or context.
- */
-typedef struct SDL_RendererInfo
-{
-    const char *name;           /**< The name of the renderer */
-    Uint32 flags;               /**< Supported ::SDL_RendererFlags */
-    Uint32 mod_modes;           /**< A mask of supported channel modulation */
-    Uint32 blend_modes;         /**< A mask of supported blend modes */
-    Uint32 scale_modes;         /**< A mask of supported scale modes */
-    Uint32 num_texture_formats; /**< The number of available texture formats */
-    Uint32 texture_formats[50]; /**< The available texture formats */
-    int max_texture_width;      /**< The maximimum texture width */
-    int max_texture_height;     /**< The maximimum texture height */
-} SDL_RendererInfo;
-
-/**
- *  \brief The access pattern allowed for a texture.
- */
-typedef enum
-{
-    SDL_TEXTUREACCESS_STATIC,    /**< Changes rarely, not lockable */
-    SDL_TEXTUREACCESS_STREAMING  /**< Changes frequently, lockable */
-} SDL_TextureAccess;
-
-/**
- *  \brief The texture channel modulation used in SDL_RenderCopy().
- */
-typedef enum
-{
-    SDL_TEXTUREMODULATE_NONE = 0x00000000,     /**< No modulation */
-    SDL_TEXTUREMODULATE_COLOR = 0x00000001,    /**< srcC = srcC * color */
-    SDL_TEXTUREMODULATE_ALPHA = 0x00000002     /**< srcA = srcA * alpha */
-} SDL_TextureModulate;
-
-/**
- *  \brief An efficient driver-specific representation of pixel data
- */
-struct SDL_Texture;
-typedef struct SDL_Texture SDL_Texture;
-
-/**
  *  \brief An opaque handle to an OpenGL context.
  */
 typedef void *SDL_GLContext;
@@ -432,23 +356,9 @@
                                                      SDL_DisplayMode * mode);
 
 /**
- *  \brief Set the palette entries for indexed display modes.
- *  
- *  \return 0 on success, or -1 if the display mode isn't palettized or the 
- *          colors couldn't be set.
+ *  \brief Get the pixel format associated with the window.
  */
-extern DECLSPEC int SDLCALL SDL_SetDisplayPalette(const SDL_Color * colors,
-                                                  int firstcolor,
-                                                  int ncolors);
-
-/**
- *  \brief Gets the palette entries for indexed display modes.
- *  
- *  \return 0 on success, or -1 if the display mode isn't palettized
- */
-extern DECLSPEC int SDLCALL SDL_GetDisplayPalette(SDL_Color * colors,
-                                                  int firstcolor,
-                                                  int ncolors);
+extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
 
 /**
  *  \brief Set the gamma correction for each of the color channels on the 
@@ -573,24 +483,39 @@
                                                SDL_Surface * icon);
 
 /**
- *  \brief Associate an arbitrary pointer with a window.
+ *  \brief Associate an arbitrary named pointer with a window.
  *  
+ *  \param window   The window to associate with the pointer.
+ *  \param name     The name of the pointer.
+ *  \param userdata The associated pointer.
+ *
+ *  \return The previous value associated with 'name'
+ *
+ *  \note The name is case-sensitive.
+ *
  *  \sa SDL_GetWindowData()
  */
-extern DECLSPEC void SDLCALL SDL_SetWindowData(SDL_Window * window,
-                                               void *userdata);
+extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window,
+                                                const char *name,
+                                                void *userdata);
 
 /**
  *  \brief Retrieve the data pointer associated with a window.
  *  
+ *  \param window   The window to query.
+ *  \param name     The name of the pointer.
+ *
+ *  \return The value associated with 'name'
+ *  
  *  \sa SDL_SetWindowData()
  */
-extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window);
+extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window,
+                                                const char *name);
 
 /**
  *  \brief Set the position of a window.
  *  
- *  \param window The window to reposition.
+ *  \param window   The window to reposition.
  *  \param x        The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or
                     ::SDL_WINDOWPOS_UNDEFINED.
  *  \param y        The y coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or
@@ -683,6 +608,40 @@
                                                     int fullscreen);
 
 /**
+ *  \brief Get an SDL surface associated with the window.
+ *
+ *  \return A surface in the optimal format for the window, or NULL on error.
+ *
+ *  \note You may not combine this with 3D or the rendering API on this window.
+ *
+ *  \sa SDL_UpdateWindowSurface()
+ *  \sa SDL_UpdateWindowSurfaceRects()
+ */
+extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window);
+
+/**
+ *  \brief Copy the window surface to the screen.
+ *
+ *  \return 0 on success, or -1 on error.
+ *
+ *  \sa SDL_GetWindowSurface()
+ *  \sa SDL_UpdateWindowSurfaceRects()
+ */
+extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window);
+
+/**
+ *  \brief Copy a number of rectangles on the window surface to the screen.
+ *
+ *  \return 0 on success, or -1 on error.
+ *
+ *  \sa SDL_GetWindowSurface()
+ *  \sa SDL_UpdateWindowSurfaceRect()
+ */
+extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
+                                                         int numrects,
+                                                         SDL_Rect * rects);
+
+/**
  *  \brief Set a window's input grab mode.
  *  
  *  \param mode This is 1 to grab input, and 0 to release input.
@@ -716,566 +675,6 @@
  */
 extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window);
 
-/**
- *  \brief Get the number of 2D rendering drivers available for the current 
- *         display.
- *  
- *  A render driver is a set of code that handles rendering and texture
- *  management on a particular display.  Normally there is only one, but
- *  some drivers may have several available with different capabilities.
- *  
- *  \sa SDL_GetRenderDriverInfo()
- *  \sa SDL_CreateRenderer()
- */
-extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
-
-/**
- *  \brief Get information about a specific 2D rendering driver for the current 
- *         display.
- *  
- *  \param index The index of the driver to query information about.
- *  \param info  A pointer to an SDL_RendererInfo struct to be filled with 
- *               information on the rendering driver.
- *  
- *  \return 0 on success, -1 if the index was out of range.
- *  
- *  \sa SDL_CreateRenderer()
- */
-extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index,
-                                                    SDL_RendererInfo * info);
-
-/**
- *  \brief Create and make active a 2D rendering context for a window.
- *  
- *  \param window The window where rendering is displayed.
- *  \param index    The index of the rendering driver to initialize, or -1 to 
- *                  initialize the first one supporting the requested flags.
- *  \param flags    ::SDL_RendererFlags.
- *  
- *  \return 0 on success, -1 if there was an error creating the renderer.
- *  
- *  \sa SDL_SelectRenderer()
- *  \sa SDL_GetRendererInfo()
- *  \sa SDL_DestroyRenderer()
- */
-extern DECLSPEC int SDLCALL SDL_CreateRenderer(SDL_Window * window,
-                                               int index, Uint32 flags);
-
-/**
- *  \brief Select the rendering context for a particular window.
- *  
- *  \return 0 on success, -1 if the selected window doesn't have a
- *          rendering context.
- */
-extern DECLSPEC int SDLCALL SDL_SelectRenderer(SDL_Window * window);
-
-/**
- *  \brief Get information about the current rendering context.
- */
-extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_RendererInfo * info);
-
-/**
- *  \brief Create a texture for the current rendering context.
- *  
- *  \param format The format of the texture.
- *  \param access One of the enumerated values in ::SDL_TextureAccess.
- *  \param w      The width of the texture in pixels.
- *  \param h      The height of the texture in pixels.
- *  
- *  \return The created texture is returned, or 0 if no rendering context was 
- *          active,  the format was unsupported, or the width or height were out
- *          of range.
- *  
- *  \sa SDL_QueryTexture()
- *  \sa SDL_DestroyTexture()
- */
-extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(Uint32 format,
-                                                        int access, int w,
-                                                        int h);
-
-/**
- *  \brief Create a texture from an existing surface.
- *  
- *  \param format The format of the texture, or 0 to pick an appropriate format.
- *  \param surface The surface containing pixel data used to fill the texture.
- *  
- *  \return The created texture is returned, or 0 if no rendering context was 
- *          active,  the format was unsupported, or the surface width or height 
- *          were out of range.
- *  
- *  \note The surface is not modified or freed by this function.
- *  
- *  \sa SDL_QueryTexture()
- *  \sa SDL_DestroyTexture()
- */
-extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(Uint32
-                                                                   format,
-                                                                   SDL_Surface
-                                                                   * surface);
-
-/**
- *  \brief Query the attributes of a texture
- *  
- *  \param texture A texture to be queried.
- *  \param format  A pointer filled in with the raw format of the texture.  The 
- *                 actual format may differ, but pixel transfers will use this 
- *                 format.
- *  \param access  A pointer filled in with the actual access to the texture.
- *  \param w       A pointer filled in with the width of the texture in pixels.
- *  \param h       A pointer filled in with the height of the texture in pixels.
- *  
- *  \return 0 on success, or -1 if the texture is not valid.
- */
-extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
-                                             Uint32 * format, int *access,
-                                             int *w, int *h);
-
-/**
- *  \brief Query the pixels of a texture, if the texture does not need to be 
- *         locked for pixel access.
- *  
- *  \param texture A texture to be queried, which was created with 
- *                   ::SDL_TEXTUREACCESS_STREAMING.
- *  \param pixels    A pointer filled with a pointer to the pixels for the 
- *                   texture.
- *  \param pitch     A pointer filled in with the pitch of the pixel data.
- *  
- *  \return 0 on success, or -1 if the texture is not valid, or must be locked 
- *          for pixel access.
- */
-extern DECLSPEC int SDLCALL SDL_QueryTexturePixels(SDL_Texture * texture,
-                                                   void **pixels, int *pitch);
-
-/**
- *  \brief Set the color palette of an indexed texture.
- *  
- *  \param texture  The texture to update.
- *  \param colors     The array of RGB color data.
- *  \param firstcolor The first index to update.
- *  \param ncolors    The number of palette entries to fill with the color data.
- *  
- *  \return 0 on success, or -1 if the texture is not valid or not an indexed 
- *          texture.
- */
-extern DECLSPEC int SDLCALL SDL_SetTexturePalette(SDL_Texture * texture,
-                                                  const SDL_Color * colors,
-                                                  int firstcolor,
-                                                  int ncolors);
-
-/**
- *  \brief Get the color palette from an indexed texture if it has one.
- *  
- *  \param texture  The texture to update.
- *  \param colors     The array to fill with RGB color data.
- *  \param firstcolor The first index to retrieve.
- *  \param ncolors    The number of palette entries to retrieve.
- *  
- *  \return 0 on success, or -1 if the texture is not valid or not an indexed 
- *          texture.
- */
-extern DECLSPEC int SDLCALL SDL_GetTexturePalette(SDL_Texture * texture,
-                                                  SDL_Color * colors,
-                                                  int firstcolor,
-                                                  int ncolors);
-
-/**
- *  \brief Set an additional color value used in render copy operations.
- *  
- *  \param texture The texture to update.
- *  \param r       The red color value multiplied into copy operations.
- *  \param g       The green color value multiplied into copy operations.
- *  \param b       The blue color value multiplied into copy operations.
- *  
- *  \return 0 on success, or -1 if the texture is not valid or color modulation 
- *          is not supported.
- *  
- *  \sa SDL_GetTextureColorMod()
- */
-extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
-                                                   Uint8 r, Uint8 g, Uint8 b);
-
-
-/**
- *  \brief Get the additional color value used in render copy operations.
- *  
- *  \param texture The texture to query.
- *  \param r         A pointer filled in with the current red color value.
- *  \param g         A pointer filled in with the current green color value.
- *  \param b         A pointer filled in with the current blue color value.
- *  
- *  \return 0 on success, or -1 if the texture is not valid.
- *  
- *  \sa SDL_SetTextureColorMod()
- */
-extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
-                                                   Uint8 * r, Uint8 * g,
-                                                   Uint8 * b);
-
-/**
- *  \brief Set an additional alpha value used in render copy operations.
- *  
- *  \param texture The texture to update.
- *  \param alpha     The alpha value multiplied into copy operations.
- *  
- *  \return 0 on success, or -1 if the texture is not valid or alpha modulation 
- *          is not supported.
- *  
- *  \sa SDL_GetTextureAlphaMod()
- */
-extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
-                                                   Uint8 alpha);
-
-/**
- *  \brief Get the additional alpha value used in render copy operations.
- *  
- *  \param texture The texture to query.
- *  \param alpha     A pointer filled in with the current alpha value.
- *  
- *  \return 0 on success, or -1 if the texture is not valid.
- *  
- *  \sa SDL_SetTextureAlphaMod()
- */
-extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
-                                                   Uint8 * alpha);
-
-/**
- *  \brief Set the blend mode used for texture copy operations.
- *  
- *  \param texture The texture to update.
- *  \param blendMode ::SDL_BlendMode to use for texture blending.
- *  
- *  \return 0 on success, or -1 if the texture is not valid or the blend mode is
- *          not supported.
- *  
- *  \note If the blend mode is not supported, the closest supported mode is
- *        chosen.
- *  
- *  \sa SDL_GetTextureBlendMode()
- */
-extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
-                                                    SDL_BlendMode blendMode);
-
-/**
- *  \brief Get the blend mode used for texture copy operations.
- *  
- *  \param texture The texture to query.
- *  \param blendMode A pointer filled in with the current blend mode.
- *  
- *  \return 0 on success, or -1 if the texture is not valid.
- *  
- *  \sa SDL_SetTextureBlendMode()
- */
-extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
-                                                    SDL_BlendMode *blendMode);
-
-/**
- *  \brief Set the scale mode used for texture copy operations.
- *  
- *  \param texture The texture to update.
- *  \param scaleMode ::SDL_ScaleMode to use for texture scaling.
- *  
- *  \return 0 on success, or -1 if the texture is not valid or the scale mode is
- *          not supported.
- *  
- *  \note If the scale mode is not supported, the closest supported mode is
- *        chosen.
- *  
- *  \sa SDL_GetTextureScaleMode()
- */
-extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture,
-                                                    SDL_ScaleMode scaleMode);
-
-/**
- *  \brief Get the scale mode used for texture copy operations.
- *  
- *  \param texture The texture to query.
- *  \param scaleMode A pointer filled in with the current scale mode.
- *  
- *  \return 0 on success, or -1 if the texture is not valid.
- *  
- *  \sa SDL_SetTextureScaleMode()
- */
-extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture,
-                                                    SDL_ScaleMode *scaleMode);
-
-/**
- *  \brief Update the given texture rectangle with new pixel data.
- *  
- *  \param texture The texture to update
- *  \param rect      A pointer to the rectangle of pixels to update, or NULL to 
- *                   update the entire texture.
- *  \param pixels    The raw pixel data.
- *  \param pitch     The number of bytes between rows of pixel data.
- *  
- *  \return 0 on success, or -1 if the texture is not valid.
- *  
- *  \note This is a fairly slow function.
- */
-extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
-                                              const SDL_Rect * rect,
-                                              const void *pixels, int pitch);
-
-/**
- *  \brief Lock a portion of the texture for pixel access.
- *  
- *  \param texture The texture to lock for access, which was created with 
- *                   ::SDL_TEXTUREACCESS_STREAMING.
- *  \param rect      A pointer to the rectangle to lock for access. If the rect 
- *                   is NULL, the entire texture will be locked.
- *  \param markDirty If this is nonzero, the locked area will be marked dirty 
- *                   when the texture is unlocked.
- *  \param pixels    This is filled in with a pointer to the locked pixels, 
- *                   appropriately offset by the locked area.
- *  \param pitch     This is filled in with the pitch of the locked pixels.
- *  
- *  \return 0 on success, or -1 if the texture is not valid or was created with 
- *          ::SDL_TEXTUREACCESS_STATIC.
- *  
- *  \sa SDL_DirtyTexture()
- *  \sa SDL_UnlockTexture()
- */
-extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
-                                            const SDL_Rect * rect,
-                                            int markDirty, void **pixels,
-                                            int *pitch);
-
-/**
- *  \brief Unlock a texture, uploading the changes to video memory, if needed.
- *  
- *  \sa SDL_LockTexture()
- *  \sa SDL_DirtyTexture()
- */
-extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
-
-/**
- *  \brief Mark the specified rectangles of the texture as dirty.
- *  
- *  \param texture The texture to mark dirty, which was created with 
- *                   ::SDL_TEXTUREACCESS_STREAMING.
- *  \param numrects  The number of rectangles pointed to by rects.
- *  \param rects     The pointer to an array of dirty rectangles.
- *  
- *  \sa SDL_LockTexture()
- *  \sa SDL_UnlockTexture()
- */
-extern DECLSPEC void SDLCALL SDL_DirtyTexture(SDL_Texture * texture,
-                                              int numrects,
-                                              const SDL_Rect * rects);
-
-/**
- *  \brief Set the color used for drawing operations (Fill and Line).
- *  
- *  \param r The red value used to draw on the rendering target.
- *  \param g The green value used to draw on the rendering target.
- *  \param b The blue value used to draw on the rendering target.
- *  \param a The alpha value used to draw on the rendering target, usually 
- *           ::SDL_ALPHA_OPAQUE (255).
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- */
-extern DECLSPEC int SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b,
-                                           Uint8 a);
-
-/**
- *  \brief Get the color used for drawing operations (Fill and Line).
- *  
- *  \param r A pointer to the red value used to draw on the rendering target.
- *  \param g A pointer to the green value used to draw on the rendering target.
- *  \param b A pointer to the blue value used to draw on the rendering target.
- *  \param a A pointer to the alpha value used to draw on the rendering target, 
- *           usually ::SDL_ALPHA_OPAQUE (255).
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- */
-extern DECLSPEC int SDL_GetRenderDrawColor(Uint8 * r, Uint8 * g, Uint8 * b,
-                                           Uint8 * a);
-
-/**
- *  \brief Set the blend mode used for drawing operations (Fill and Line).
- *  
- *  \param blendMode ::SDL_BlendMode to use for blending.
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- *  
- *  \note If the blend mode is not supported, the closest supported mode is 
- *        chosen.
- *  
- *  \sa SDL_GetRenderDrawBlendMode()
- */
-extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
-
-/**
- *  \brief Get the blend mode used for drawing operations.
- *  
- *  \param blendMode A pointer filled in with the current blend mode.
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- *  
- *  \sa SDL_SetRenderDrawBlendMode()
- */
-extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_BlendMode *blendMode);
-
-/**
- *  \brief Clear the current rendering target with the drawing color
- */
-extern DECLSPEC int SDLCALL SDL_RenderClear(void);
-
-/**
- *  \brief Draw a point on the current rendering target.
- *  
- *  \param x The x coordinate of the point.
- *  \param y The y coordinate of the point.
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- */
-extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(int x, int y);
-
-/**
- *  \brief Draw multiple points on the current rendering target.
- *  
- *  \param points The points to draw
- *  \param count The number of points to draw
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- */
-extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(const SDL_Point * points,
-                                                 int count);
-
-/**
- *  \brief Draw a line on the current rendering target.
- *  
- *  \param x1 The x coordinate of the start point.
- *  \param y1 The y coordinate of the start point.
- *  \param x2 The x coordinate of the end point.
- *  \param y2 The y coordinate of the end point.
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- */
-extern DECLSPEC int SDLCALL SDL_RenderDrawLine(int x1, int y1, int x2, int y2);
-
-/**
- *  \brief Draw a series of connected lines on the current rendering target.
- *  
- *  \param points The points along the lines
- *  \param count The number of points, drawing count-1 lines
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- */
-extern DECLSPEC int SDLCALL SDL_RenderDrawLines(const SDL_Point * points,
-                                                int count);
-
-/**
- *  \brief Draw a rectangle on the current rendering target.
- *  
- *  \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- */
-extern DECLSPEC int SDLCALL SDL_RenderDrawRect(const SDL_Rect * rect);
-
-/**
- *  \brief Draw some number of rectangles on the current rendering target.
- *  
- *  \param rects A pointer to an array of destination rectangles.
- *  \param count The number of rectangles.
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- */
-extern DECLSPEC int SDLCALL SDL_RenderDrawRects(const SDL_Rect ** rects, int count);
-
-/**
- *  \brief Fill a rectangle on the current rendering target with the drawing color.
- *  
- *  \param rect A pointer to the destination rectangle, or NULL for the entire 
- *              rendering target.
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- */
-extern DECLSPEC int SDLCALL SDL_RenderFillRect(const SDL_Rect * rect);
-
-/**
- *  \brief Fill some number of rectangles on the current rendering target with the drawing color.
- *  
- *  \param rects A pointer to an array of destination rectangles.
- *  \param count The number of rectangles.
- *  
- *  \return 0 on success, or -1 if there is no rendering context current.
- */
-extern DECLSPEC int SDLCALL SDL_RenderFillRects(const SDL_Rect ** rect, int count);
-
-/**
- *  \brief Copy a portion of the texture to the current rendering target.
- *  
- *  \param texture The source texture.
- *  \param srcrect   A pointer to the source rectangle, or NULL for the entire 
- *                   texture.
- *  \param dstrect   A pointer to the destination rectangle, or NULL for the 
- *                   entire rendering target.
- *  
- *  \return 0 on success, or -1 if there is no rendering context current, or the
- *          driver doesn't support the requested operation.
- */
-extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Texture * texture,
-                                           const SDL_Rect * srcrect,
-                                           const SDL_Rect * dstrect);
-
-/**
- *  \brief Read pixels from the current rendering target.
- *  
- *  \param rect   A pointer to the rectangle to read, or NULL for the entire 
- *                render target.
- *  \param format The desired format of the pixel data, or 0 to use the format
- *                of the rendering target
- *  \param pixels A pointer to be filled in with the pixel data
- *  \param pitch  The pitch of the pixels parameter.
- *  
- *  \return 0 on success, or -1 if pixel reading is not supported.
- *  
- *  \warning This is a very slow operation, and should not be used frequently.
- */
-extern DECLSPEC int SDLCALL SDL_RenderReadPixels(const SDL_Rect * rect,
-                                                 Uint32 format,
-                                                 void *pixels, int pitch);
-
-/**
- *  \brief Write pixels to the current rendering target.
- *  
- *  \param rect   A pointer to the rectangle to write, or NULL for the entire 
- *                render target.
- *  \param format The format of the pixel data, or 0 to use the format
- *                of the rendering target
- *  \param pixels A pointer to the pixel data to write.
- *  \param pitch  The pitch of the pixels parameter.
- *  
- *  \return 0 on success, or -1 if pixel writing is not supported.
- *  
- *  \warning This is a very slow operation, and should not be used frequently.
- */
-extern DECLSPEC int SDLCALL SDL_RenderWritePixels(const SDL_Rect * rect,
-                                                  Uint32 format,
-                                                  const void *pixels,
-                                                  int pitch);
-
-/**
- *  \brief Update the screen with rendering performed.
- */
-extern DECLSPEC void SDLCALL SDL_RenderPresent(void);
-
-/**
- *  \brief Destroy the specified texture.
- *  
- *  \sa SDL_CreateTexture()
- *  \sa SDL_CreateTextureFromSurface()
- */
-extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
-
-/**
- *  \brief Destroy the rendering context for a window and free associated
- *         textures.
- *  
- *  \sa SDL_CreateRenderer()
- */
-extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Window * window);
 
 /**
  *  \brief Returns whether the screensaver is currently enabled (default on).
--- a/src/SDL.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/SDL.c	Sun Feb 06 21:23:32 2011 -0800
@@ -246,6 +246,7 @@
     /* Uninstall any parachute signal handlers */
     SDL_UninstallParachute();
 
+    SDL_ClearHints();
     SDL_AssertionsQuit();
 
 #ifdef DEBUG_BUILD
--- a/src/SDL_compat.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/SDL_compat.c	Sun Feb 06 21:23:32 2011 -0800
@@ -28,11 +28,10 @@
 
 #include "video/SDL_sysvideo.h"
 #include "video/SDL_pixels_c.h"
-#include "video/SDL_yuv_sw_c.h"
+#include "render/SDL_yuv_sw_c.h"
+
 
 static SDL_Window *SDL_VideoWindow = NULL;
-static SDL_RendererInfo SDL_VideoRendererInfo;
-static SDL_Texture *SDL_VideoTexture = NULL;
 static SDL_Surface *SDL_VideoSurface = NULL;
 static SDL_Surface *SDL_ShadowSurface = NULL;
 static SDL_Surface *SDL_PublicSurface = NULL;
@@ -42,24 +41,32 @@
 static SDL_Surface *SDL_VideoIcon;
 static int SDL_enabled_UNICODE = 0;
 
-char *
+const char *
 SDL_AudioDriverName(char *namebuf, int maxlen)
 {
     const char *name = SDL_GetCurrentAudioDriver();
     if (name) {
-        SDL_strlcpy(namebuf, name, maxlen);
-        return namebuf;
+        if (namebuf) {
+            SDL_strlcpy(namebuf, name, maxlen);
+            return namebuf;
+        } else {
+            return name;
+        }
     }
     return NULL;
 }
 
-char *
+const char *
 SDL_VideoDriverName(char *namebuf, int maxlen)
 {
     const char *name = SDL_GetCurrentVideoDriver();
     if (name) {
-        SDL_strlcpy(namebuf, name, maxlen);
-        return namebuf;
+        if (namebuf) {
+            SDL_strlcpy(namebuf, name, maxlen);
+            return namebuf;
+        } else {
+            return name;
+        }
     }
     return NULL;
 }
@@ -320,27 +327,6 @@
     return 1;
 }
 
-static int
-SDL_VideoPaletteChanged(void *userdata, SDL_Palette * palette)
-{
-    if (userdata == SDL_ShadowSurface) {
-        /* If the shadow palette changed, make the changes visible */
-        if (!SDL_VideoSurface->format->palette) {
-            SDL_UpdateRect(SDL_ShadowSurface, 0, 0, 0, 0);
-        }
-    }
-    if (userdata == SDL_VideoSurface) {
-        /* The display may not have a palette, but always set texture palette */
-        SDL_SetDisplayPalette(palette->colors, 0, palette->ncolors);
-
-        if (SDL_SetTexturePalette
-            (SDL_VideoTexture, palette->colors, 0, palette->ncolors) < 0) {
-            return -1;
-        }
-    }
-    return 0;
-}
-
 static void
 GetEnvironmentWindowPosition(int w, int h, int *x, int *y)
 {
@@ -362,38 +348,6 @@
     }
 }
 
-static SDL_Surface *
-CreateVideoSurface(SDL_Texture * texture)
-{
-    SDL_Surface *surface;
-    Uint32 format;
-    int w, h;
-    int bpp;
-    Uint32 Rmask, Gmask, Bmask, Amask;
-    void *pixels;
-    int pitch;
-
-    if (SDL_QueryTexture(texture, &format, NULL, &w, &h) < 0) {
-        return NULL;
-    }
-
-    if (!SDL_PixelFormatEnumToMasks
-        (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-        SDL_SetError("Unknown texture format");
-        return NULL;
-    }
-
-    if (SDL_QueryTexturePixels(texture, &pixels, &pitch) == 0) {
-        surface =
-            SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask, Gmask,
-                                     Bmask, Amask);
-    } else {
-        surface =
-            SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
-    }
-    return surface;
-}
-
 static void
 ClearVideoSurface()
 {
@@ -431,10 +385,6 @@
 SDL_ResizeVideoMode(int width, int height, int bpp, Uint32 flags)
 {
     int w, h;
-    Uint32 format;
-    int access;
-    void *pixels;
-    int pitch;
 
     /* We can't resize something we don't have... */
     if (!SDL_VideoWindow) {
@@ -465,27 +415,11 @@
     }
 
     /* Destroy the screen texture and recreate it */
-    SDL_QueryTexture(SDL_VideoTexture, &format, &access, &w, &h);
-    SDL_DestroyTexture(SDL_VideoTexture);
-    SDL_VideoTexture = SDL_CreateTexture(format, access, width, height);
-    if (!SDL_VideoTexture) {
+    SDL_VideoSurface = SDL_GetWindowSurface(SDL_VideoWindow);
+    if (!SDL_VideoSurface) {
         return -1;
     }
 
-    SDL_VideoSurface->w = width;
-    SDL_VideoSurface->h = height;
-    if (SDL_QueryTexturePixels(SDL_VideoTexture, &pixels, &pitch) == 0) {
-        SDL_VideoSurface->pixels = pixels;
-        SDL_VideoSurface->pitch = pitch;
-    } else {
-        SDL_CalculatePitch(SDL_VideoSurface);
-        SDL_VideoSurface->pixels =
-            SDL_realloc(SDL_VideoSurface->pixels,
-                        SDL_VideoSurface->h * SDL_VideoSurface->pitch);
-    }
-    SDL_SetClipRect(SDL_VideoSurface, NULL);
-    SDL_InvalidateMap(SDL_VideoSurface->map);
-
     if (SDL_ShadowSurface) {
         SDL_ShadowSurface->w = width;
         SDL_ShadowSurface->h = height;
@@ -495,6 +429,8 @@
                         SDL_ShadowSurface->h * SDL_ShadowSurface->pitch);
         SDL_SetClipRect(SDL_ShadowSurface, NULL);
         SDL_InvalidateMap(SDL_ShadowSurface->map);
+    } else {
+        SDL_PublicSurface = SDL_VideoSurface;
     }
 
     ClearVideoSurface();
@@ -509,8 +445,6 @@
     int window_x = SDL_WINDOWPOS_UNDEFINED;
     int window_y = SDL_WINDOWPOS_UNDEFINED;
     Uint32 window_flags;
-    Uint32 desktop_format;
-    Uint32 desired_format;
     Uint32 surface_flags;
 
     if (!SDL_GetVideoDevice()) {
@@ -529,6 +463,9 @@
     if (height == 0) {
         height = desktop_mode.h;
     }
+    if (bpp == 0) {
+        bpp = SDL_BITSPERPIXEL(desktop_mode.format);
+    }
 
     /* See if we can simply resize the existing window and surface */
     if (SDL_ResizeVideoMode(width, height, bpp, flags) == 0) {
@@ -542,8 +479,6 @@
         SDL_ShadowSurface = NULL;
     }
     if (SDL_VideoSurface) {
-        SDL_DelPaletteWatch(SDL_VideoSurface->format->palette,
-                            SDL_VideoPaletteChanged, NULL);
         SDL_FreeSurface(SDL_VideoSurface);
         SDL_VideoSurface = NULL;
     }
@@ -600,53 +535,6 @@
         surface_flags |= SDL_NOFRAME;
     }
 
-    /* Set up the desired display mode */
-    desktop_format = desktop_mode.format;
-    if (desktop_format && ((flags & SDL_ANYFORMAT)
-                           || (bpp == SDL_BITSPERPIXEL(desktop_format)))) {
-        desired_format = desktop_format;
-    } else {
-        switch (bpp) {
-        case 0:
-            if (desktop_format) {
-                desired_format = desktop_format;
-            } else {
-                desired_format = SDL_PIXELFORMAT_RGB888;
-            }
-            bpp = SDL_BITSPERPIXEL(desired_format);
-            break;
-        case 8:
-            desired_format = SDL_PIXELFORMAT_INDEX8;
-            break;
-        case 15:
-            desired_format = SDL_PIXELFORMAT_RGB555;
-            break;
-        case 16:
-            desired_format = SDL_PIXELFORMAT_RGB565;
-            break;
-        case 24:
-            desired_format = SDL_PIXELFORMAT_RGB24;
-            break;
-        case 32:
-            desired_format = SDL_PIXELFORMAT_RGB888;
-            break;
-        default:
-            SDL_SetError("Unsupported bpp in SDL_SetVideoMode()");
-            return NULL;
-        }
-    }
-
-    /* Set up the desired display mode */
-    if (flags & SDL_FULLSCREEN) {
-        SDL_DisplayMode mode;
-
-        SDL_zero(mode);
-        mode.format = desired_format;
-        if (SDL_SetWindowDisplayMode(SDL_VideoWindow, &mode) < 0) {
-            return NULL;
-        }
-    }
-
     /* If we're in OpenGL mode, just create a stub surface and we're done! */
     if (flags & SDL_OPENGL) {
         SDL_VideoContext = SDL_GL_CreateContext(SDL_VideoWindow);
@@ -666,47 +554,13 @@
         return SDL_PublicSurface;
     }
 
-    /* Create a renderer for the window */
-    if (SDL_CreateRenderer
-        (SDL_VideoWindow, -1,
-         SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD) < 0) {
-        return NULL;
-    }
-    SDL_GetRendererInfo(&SDL_VideoRendererInfo);
-
-    /* Create a texture for the screen surface */
-    SDL_VideoTexture =
-        SDL_CreateTexture(desired_format, SDL_TEXTUREACCESS_STREAMING, width,
-                          height);
-
-    if (!SDL_VideoTexture) {
-        SDL_VideoTexture =
-            SDL_CreateTexture(desktop_format,
-                              SDL_TEXTUREACCESS_STREAMING, width, height);
-    }
-    if (!SDL_VideoTexture) {
-        return NULL;
-    }
-
     /* Create the screen surface */
-    SDL_VideoSurface = CreateVideoSurface(SDL_VideoTexture);
+    SDL_VideoSurface = SDL_GetWindowSurface(SDL_VideoWindow);
     if (!SDL_VideoSurface) {
         return NULL;
     }
     SDL_VideoSurface->flags |= surface_flags;
 
-    /* Set a default screen palette */
-    if (SDL_VideoSurface->format->palette) {
-        SDL_VideoSurface->flags |= SDL_HWPALETTE;
-        SDL_DitherColors(SDL_VideoSurface->format->palette->colors,
-                         SDL_VideoSurface->format->BitsPerPixel);
-        SDL_AddPaletteWatch(SDL_VideoSurface->format->palette,
-                            SDL_VideoPaletteChanged, SDL_VideoSurface);
-        SDL_SetPaletteColors(SDL_VideoSurface->format->palette,
-                             SDL_VideoSurface->format->palette->colors, 0,
-                             SDL_VideoSurface->format->palette->ncolors);
-    }
-
     /* Create a shadow surface if necessary */
     if ((bpp != SDL_VideoSurface->format->BitsPerPixel)
         && !(flags & SDL_ANYFORMAT)) {
@@ -720,15 +574,8 @@
         /* 8-bit SDL_ShadowSurface surfaces report that they have exclusive palette */
         if (SDL_ShadowSurface->format->palette) {
             SDL_ShadowSurface->flags |= SDL_HWPALETTE;
-            if (SDL_VideoSurface->format->palette) {
-                SDL_SetSurfacePalette(SDL_ShadowSurface,
-                                      SDL_VideoSurface->format->palette);
-            } else {
-                SDL_DitherColors(SDL_ShadowSurface->format->palette->colors,
-                                 SDL_ShadowSurface->format->BitsPerPixel);
-            }
-            SDL_AddPaletteWatch(SDL_ShadowSurface->format->palette,
-                                SDL_VideoPaletteChanged, SDL_ShadowSurface);
+            SDL_DitherColors(SDL_ShadowSurface->format->palette->colors,
+                             SDL_ShadowSurface->format->BitsPerPixel);
         }
     }
     SDL_PublicSurface =
@@ -872,34 +719,7 @@
         screen = SDL_VideoSurface;
     }
     if (screen == SDL_VideoSurface) {
-        if (screen->flags & SDL_PREALLOC) {
-            /* The surface memory is maintained by the renderer */
-            SDL_DirtyTexture(SDL_VideoTexture, numrects, rects);
-        } else {
-            /* The surface memory needs to be copied to texture */
-            int pitch = screen->pitch;
-            int psize = screen->format->BytesPerPixel;
-            for (i = 0; i < numrects; ++i) {
-                const SDL_Rect *rect = &rects[i];
-                void *pixels =
-                    (Uint8 *) screen->pixels + rect->y * pitch +
-                    rect->x * psize;
-                SDL_UpdateTexture(SDL_VideoTexture, rect, pixels, pitch);
-            }
-        }
-        if (SDL_VideoRendererInfo.flags & SDL_RENDERER_PRESENTCOPY) {
-            for (i = 0; i < numrects; ++i) {
-                SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i]);
-            }
-        } else {
-            SDL_Rect rect;
-            rect.x = 0;
-            rect.y = 0;
-            rect.w = screen->w;
-            rect.h = screen->h;
-            SDL_RenderCopy(SDL_VideoTexture, &rect, &rect);
-        }
-        SDL_RenderPresent();
+        SDL_UpdateWindowSurfaceRects(SDL_VideoWindow, numrects, rects);
     }
 }
 
@@ -1505,13 +1325,9 @@
 
 struct private_yuvhwdata
 {
-    Uint16 pitches[3];
-    Uint8 *planes[3];
-
-    SDL_SW_YUVTexture *sw;
-
-    SDL_Texture *texture;
-    Uint32 texture_format;
+    SDL_SW_YUVTexture *texture;
+    SDL_Surface *display;
+    Uint32 display_format;
 };
 
 SDL_Overlay *
@@ -1519,6 +1335,7 @@
 {
     SDL_Overlay *overlay;
     Uint32 texture_format;
+    SDL_SW_YUVTexture *texture;
 
     if ((display->flags & SDL_OPENGL) == SDL_OPENGL) {
         SDL_SetError("YUV overlays are not supported in OpenGL mode");
@@ -1566,6 +1383,16 @@
         return NULL;
     }
 
+    texture = SDL_SW_CreateYUVTexture(texture_format, w, h);
+    if (!texture) {
+        SDL_free(overlay->hwdata);
+        SDL_free(overlay);
+        return NULL;
+    }
+    overlay->hwdata->texture = texture;
+    overlay->hwdata->display = NULL;
+    overlay->hwdata->display_format = SDL_PIXELFORMAT_UNKNOWN;
+
     overlay->format = format;
     overlay->w = w;
     overlay->h = h;
@@ -1574,48 +1401,8 @@
     } else {
         overlay->planes = 1;
     }
-    overlay->pitches = overlay->hwdata->pitches;
-    overlay->pixels = overlay->hwdata->planes;
-
-    switch (format) {
-    case SDL_YV12_OVERLAY:
-    case SDL_IYUV_OVERLAY:
-        overlay->pitches[0] = overlay->w;
-        overlay->pitches[1] = overlay->w / 2;
-        overlay->pitches[2] = overlay->w / 2;
-        break;
-    case SDL_YUY2_OVERLAY:
-    case SDL_UYVY_OVERLAY:
-    case SDL_YVYU_OVERLAY:
-        overlay->pitches[0] = overlay->w * 2;
-        break;
-    }
-
-    overlay->hwdata->texture =
-        SDL_CreateTexture(texture_format, SDL_TEXTUREACCESS_STREAMING, w, h);
-    if (overlay->hwdata->texture) {
-        overlay->hwdata->sw = NULL;
-    } else {
-        SDL_DisplayMode current_mode;
-
-        overlay->hwdata->sw = SDL_SW_CreateYUVTexture(texture_format, w, h);
-        if (!overlay->hwdata->sw) {
-            SDL_FreeYUVOverlay(overlay);
-            return NULL;
-        }
-
-        /* Create a supported RGB format texture for display */
-        SDL_GetCurrentDisplayMode(&current_mode);
-        texture_format = current_mode.format;
-        overlay->hwdata->texture =
-            SDL_CreateTexture(texture_format,
-                              SDL_TEXTUREACCESS_STREAMING, w, h);
-    }
-    if (!overlay->hwdata->texture) {
-        SDL_FreeYUVOverlay(overlay);
-        return NULL;
-    }
-    overlay->hwdata->texture_format = texture_format;
+    overlay->pitches = texture->pitches;
+    overlay->pixels = texture->planes;
 
     return overlay;
 }
@@ -1623,6 +1410,7 @@
 int
 SDL_LockYUVOverlay(SDL_Overlay * overlay)
 {
+    SDL_Rect rect;
     void *pixels;
     int pitch;
 
@@ -1630,18 +1418,16 @@
         SDL_SetError("Passed a NULL overlay");
         return -1;
     }
-    if (overlay->hwdata->sw) {
-        if (SDL_SW_QueryYUVTexturePixels(overlay->hwdata->sw, &pixels, &pitch)
-            < 0) {
-            return -1;
-        }
-    } else {
-        if (SDL_LockTexture
-            (overlay->hwdata->texture, NULL, 1, &pixels, &pitch)
-            < 0) {
-            return -1;
-        }
+
+    rect.x = 0;
+    rect.y = 0;
+    rect.w = overlay->w;
+    rect.h = overlay->h;
+
+    if (SDL_SW_LockYUVTexture(overlay->hwdata->texture, &rect, &pixels, &pitch) < 0) {
+        return -1;
     }
+
     overlay->pixels[0] = (Uint8 *) pixels;
     overlay->pitches[0] = pitch;
     switch (overlay->format) {
@@ -1668,38 +1454,54 @@
     if (!overlay) {
         return;
     }
-    if (overlay->hwdata->sw) {
-        void *pixels;
-        int pitch;
-        if (SDL_LockTexture
-            (overlay->hwdata->texture, NULL, 1, &pixels, &pitch) == 0) {
-            SDL_Rect srcrect;
 
-            srcrect.x = 0;
-            srcrect.y = 0;
-            srcrect.w = overlay->w;
-            srcrect.h = overlay->h;
-            SDL_SW_CopyYUVToRGB(overlay->hwdata->sw, &srcrect,
-                                overlay->hwdata->texture_format,
-                                overlay->w, overlay->h, pixels, pitch);
-            SDL_UnlockTexture(overlay->hwdata->texture);
-        }
-    } else {
-        SDL_UnlockTexture(overlay->hwdata->texture);
-    }
+    SDL_SW_UnlockYUVTexture(overlay->hwdata->texture);
 }
 
 int
 SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect)
 {
+    SDL_Surface *display;
+    SDL_Rect src_rect;
+    SDL_Rect dst_rect;
+    void *pixels;
+
     if (!overlay || !dstrect) {
         SDL_SetError("Passed a NULL overlay or dstrect");
         return -1;
     }
-    if (SDL_RenderCopy(overlay->hwdata->texture, NULL, dstrect) < 0) {
+
+    display = overlay->hwdata->display;
+    if (display != SDL_VideoSurface) {
+        overlay->hwdata->display = display = SDL_VideoSurface;
+        overlay->hwdata->display_format = SDL_MasksToPixelFormatEnum(
+                                                display->format->BitsPerPixel,
+                                                display->format->Rmask,
+                                                display->format->Gmask,
+                                                display->format->Bmask,
+                                                display->format->Amask);
+    }
+
+    src_rect.x = 0;
+    src_rect.y = 0;
+    src_rect.w = overlay->w;
+    src_rect.h = overlay->h;
+
+    if (!SDL_IntersectRect(&display->clip_rect, dstrect, &dst_rect)) {
+        return 0;
+    }
+     
+    pixels = (void *)((Uint8 *)display->pixels +
+                        dst_rect.y * display->pitch +
+                        dst_rect.x * display->format->BytesPerPixel);
+
+    if (SDL_SW_CopyYUVToRGB(overlay->hwdata->texture, &src_rect,
+                            overlay->hwdata->display_format,
+                            dst_rect.w, dst_rect.h,
+                            pixels, display->pitch) < 0) {
         return -1;
     }
-    SDL_RenderPresent();
+    SDL_UpdateWindowSurface(SDL_VideoWindow);
     return 0;
 }
 
@@ -1711,7 +1513,7 @@
     }
     if (overlay->hwdata) {
         if (overlay->hwdata->texture) {
-            SDL_DestroyTexture(overlay->hwdata->texture);
+            SDL_SW_DestroyYUVTexture(overlay->hwdata->texture);
         }
         SDL_free(overlay->hwdata);
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SDL_hints.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,122 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_hints.h"
+
+
+/* Assuming there aren't many hints set and they aren't being queried in
+   critical performance paths, we'll just use a linked list here.
+ */
+typedef struct SDL_Hint {
+    char *name;
+    char *value;
+    SDL_HintPriority priority;
+    struct SDL_Hint *next;
+} SDL_Hint;
+
+static SDL_Hint *SDL_hints;
+
+
+SDL_bool
+SDL_SetHintWithPriority(const char *name, const char *value,
+                        SDL_HintPriority priority)
+{
+    const char *env;
+    SDL_Hint *prev, *hint;
+
+    if (!name || !value) {
+        return SDL_FALSE;
+    }
+
+    env = SDL_getenv(name);
+    if (env && priority < SDL_HINT_OVERRIDE) {
+        return SDL_FALSE;
+    }
+
+    prev = NULL;
+    for (hint = SDL_hints; hint; prev = hint, hint = hint->next) {
+        if (SDL_strcmp(name, hint->name) == 0) {
+            if (priority < hint->priority) {
+                return SDL_FALSE;
+            }
+            if (SDL_strcmp(hint->value, value) != 0) {
+                SDL_free(hint->value);
+                hint->value = SDL_strdup(value);
+            }
+            hint->priority = priority;
+            return SDL_TRUE;
+        }
+    }
+
+    /* Couldn't find the hint, add a new one */
+    hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
+    if (!hint) {
+        return SDL_FALSE;
+    }
+    hint->name = SDL_strdup(name);
+    hint->value = SDL_strdup(value);
+    hint->priority = priority;
+    hint->next = SDL_hints;
+    SDL_hints = hint;
+    return SDL_TRUE;
+}
+
+SDL_bool
+SDL_SetHint(const char *name, const char *value)
+{
+    return SDL_SetHintWithPriority(name, value, SDL_HINT_NORMAL);
+}
+
+const char *
+SDL_GetHint(const char *name)
+{
+    const char *env;
+    SDL_Hint *hint;
+
+    env = SDL_getenv(name);
+    for (hint = SDL_hints; hint; hint = hint->next) {
+        if (SDL_strcmp(name, hint->name) == 0) {
+            if (!env || hint->priority == SDL_HINT_OVERRIDE) {
+                return hint->value;
+            }
+            break;
+        }
+    }
+    return env;
+}
+
+void SDL_ClearHints()
+{
+    SDL_Hint *hint;
+
+    while (SDL_hints) {
+        hint = SDL_hints;
+        SDL_hints = hint->next;
+
+        SDL_free(hint->name);
+        SDL_free(hint->value);
+        SDL_free(hint);
+    }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/events/SDL_events.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/events/SDL_events.c	Sun Feb 06 21:23:32 2011 -0800
@@ -38,6 +38,14 @@
 SDL_EventFilter SDL_EventOK = NULL;
 void *SDL_EventOKParam;
 
+typedef struct SDL_EventWatcher {
+    SDL_EventFilter callback;
+    void *userdata;
+    struct SDL_EventWatcher *next;
+} SDL_EventWatcher;
+
+static SDL_EventWatcher *SDL_event_watchers = NULL;
+
 typedef struct {
     Uint32 bits[8];
 } SDL_DisabledEventBlock;
@@ -96,14 +104,18 @@
             SDL_disabled_events[i] = NULL;
         }
     }
+
+    while (SDL_event_watchers) {
+        SDL_EventWatcher *tmp = SDL_event_watchers;
+        SDL_event_watchers = tmp->next;
+        SDL_free(tmp);
+    }
 }
 
 /* This function (and associated calls) may be called more than once */
 int
 SDL_StartEventLoop(void)
 {
-    int retcode;
-
     /* Clean out the event queue */
     SDL_EventQ.lock = NULL;
     SDL_StopEventLoop();
@@ -340,9 +352,16 @@
 int
 SDL_PushEvent(SDL_Event * event)
 {
+    SDL_EventWatcher *curr;
+
     if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
         return 0;
     }
+
+    for (curr = SDL_event_watchers; curr; curr = curr->next) {
+        curr->callback(curr->userdata, event);
+    }
+
     if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0, 0) <= 0) {
         return -1;
     }
@@ -376,6 +395,43 @@
     return SDL_EventOK ? SDL_TRUE : SDL_FALSE;
 }
 
+/* FIXME: This is not thread-safe yet */
+void
+SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
+{
+    SDL_EventWatcher *watcher;
+
+    watcher = (SDL_EventWatcher *)SDL_malloc(sizeof(*watcher));
+    if (!watcher) {
+        /* Uh oh... */
+        return;
+    }
+    watcher->callback = filter;
+    watcher->userdata = userdata;
+    watcher->next = SDL_event_watchers;
+    SDL_event_watchers = watcher;
+}
+
+/* FIXME: This is not thread-safe yet */
+void
+SDL_DelEventWatch(SDL_EventFilter filter, void *userdata)
+{
+    SDL_EventWatcher *prev = NULL;
+    SDL_EventWatcher *curr;
+
+    for (curr = SDL_event_watchers; curr; prev = curr, curr = curr->next) {
+        if (curr->callback == filter && curr->userdata == userdata) {
+            if (prev) {
+                prev->next = curr->next;
+            } else {
+                SDL_event_watchers = curr->next;
+            }
+            SDL_free(curr);
+            break;
+        }
+    }
+}
+
 void
 SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/SDL_render.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,1103 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* The SDL 2D rendering system */
+
+#include "SDL_hints.h"
+#include "SDL_render.h"
+#include "SDL_sysrender.h"
+#include "../video/SDL_pixels_c.h"
+#include "software/SDL_render_sw_c.h"
+
+
+#define CHECK_RENDERER_MAGIC(renderer, retval) \
+    if (!renderer || renderer->magic != &renderer_magic) { \
+        SDL_SetError("Invalid renderer"); \
+        return retval; \
+    }
+
+#define CHECK_TEXTURE_MAGIC(texture, retval) \
+    if (!texture || texture->magic != &texture_magic) { \
+        SDL_SetError("Invalid texture"); \
+        return retval; \
+    }
+
+
+static const SDL_RenderDriver *render_drivers[] = {
+#if SDL_VIDEO_RENDER_D3D
+    &D3D_RenderDriver,
+#endif
+#if SDL_VIDEO_RENDER_OGL
+    &GL_RenderDriver,
+#endif
+#if SDL_VIDEO_RENDER_OGL_ES2
+    &GLES2_RenderDriver,
+#endif
+#if SDL_VIDEO_RENDER_OGL_ES
+    &GLES_RenderDriver,
+#endif
+#if SDL_VIDEO_RENDER_DIRECTFB
+    &DirectFB_RenderDriver,
+#endif
+    &SW_RenderDriver
+};
+static char renderer_magic;
+static char texture_magic;
+
+int
+SDL_GetNumRenderDrivers(void)
+{
+    return SDL_arraysize(render_drivers);
+}
+
+int
+SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
+{
+    if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
+        SDL_SetError("index must be in the range of 0 - %d",
+                     SDL_GetNumRenderDrivers() - 1);
+        return -1;
+    }
+    *info = render_drivers[index]->info;
+    return 0;
+}
+
+static int
+SDL_RendererEventWatch(void *userdata, SDL_Event *event)
+{
+    SDL_Renderer *renderer = (SDL_Renderer *)userdata;
+
+    if (event->type == SDL_WINDOWEVENT && renderer->WindowEvent) {
+        SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
+        if (window == renderer->window) {
+            renderer->WindowEvent(renderer, &event->window);
+        }
+    }
+    return 0;
+}
+
+SDL_Renderer *
+SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
+{
+    SDL_Renderer *renderer = NULL;
+    int n = SDL_GetNumRenderDrivers();
+    const char *hint;
+
+    hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
+    if (hint) {
+        if (*hint == '0') {
+            flags &= ~SDL_RENDERER_PRESENTVSYNC;
+        } else {
+            flags |= SDL_RENDERER_PRESENTVSYNC;
+        }
+    }
+
+    if (index < 0) {
+        hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
+        if (hint) {
+            for (index = 0; index < n; ++index) {
+                const SDL_RenderDriver *driver = render_drivers[index];
+
+                if (SDL_strcasecmp(hint, driver->info.name) == 0) {
+                    /* Create a new renderer instance */
+                    renderer = driver->CreateRenderer(window, flags);
+                    break;
+                }
+            }
+        }
+
+        if (!renderer) {
+            for (index = 0; index < n; ++index) {
+                const SDL_RenderDriver *driver = render_drivers[index];
+
+                if ((driver->info.flags & flags) == flags) {
+                    /* Create a new renderer instance */
+                    renderer = driver->CreateRenderer(window, flags);
+                    if (renderer) {
+                        /* Yay, we got one! */
+                        break;
+                    }
+                }
+            }
+        }
+        if (index == n) {
+            SDL_SetError("Couldn't find matching render driver");
+            return NULL;
+        }
+    } else {
+        if (index >= SDL_GetNumRenderDrivers()) {
+            SDL_SetError("index must be -1 or in the range of 0 - %d",
+                         SDL_GetNumRenderDrivers() - 1);
+            return NULL;
+        }
+        /* Create a new renderer instance */
+        renderer = render_drivers[index]->CreateRenderer(window, flags);
+    }
+
+    if (renderer) {
+        renderer->magic = &renderer_magic;
+        renderer->window = window;
+
+        SDL_AddEventWatch(SDL_RendererEventWatch, renderer);
+    }
+    return renderer;
+}
+
+SDL_Renderer *
+SDL_CreateSoftwareRenderer(SDL_Surface * surface)
+{
+    return SW_CreateRendererForSurface(surface);
+}
+
+int
+SDL_GetRendererInfo(SDL_Renderer * renderer, SDL_RendererInfo * info)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    *info = renderer->info;
+    return 0;
+}
+
+static SDL_bool
+IsSupportedFormat(SDL_Renderer * renderer, Uint32 format)
+{
+    Uint32 i;
+
+    for (i = 0; i < renderer->info.num_texture_formats; ++i) {
+        if (renderer->info.texture_formats[i] == format) {
+            return SDL_TRUE;
+        }
+    }
+    return SDL_FALSE;
+}
+
+static Uint32
+GetClosestSupportedFormat(SDL_Renderer * renderer, Uint32 format)
+{
+    Uint32 i;
+    SDL_bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(format);
+
+    /* We just want to match the first format that has the same channels */
+    for (i = 0; i < renderer->info.num_texture_formats; ++i) {
+        if (SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == hasAlpha) {
+            return renderer->info.texture_formats[i];
+        }
+    }
+    return renderer->info.texture_formats[0];
+}
+
+SDL_Texture *
+SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h)
+{
+    SDL_Texture *texture;
+
+    CHECK_RENDERER_MAGIC(renderer, NULL);
+
+    if (SDL_ISPIXELFORMAT_INDEXED(format)) {
+        SDL_SetError("Palettized textures are not supported");
+        return NULL;
+    }
+    if (w <= 0 || h <= 0) {
+        SDL_SetError("Texture dimensions can't be 0");
+        return NULL;
+    }
+    texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
+    if (!texture) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+    texture->magic = &texture_magic;
+    texture->format = format;
+    texture->access = access;
+    texture->w = w;
+    texture->h = h;
+    texture->r = 255;
+    texture->g = 255;
+    texture->b = 255;
+    texture->a = 255;
+    texture->renderer = renderer;
+    texture->next = renderer->textures;
+    if (renderer->textures) {
+        renderer->textures->prev = texture;
+    }
+    renderer->textures = texture;
+
+    if (IsSupportedFormat(renderer, format)) {
+        if (renderer->CreateTexture(renderer, texture) < 0) {
+            SDL_DestroyTexture(texture);
+            return 0;
+        }
+    } else {
+        texture->native = SDL_CreateTexture(renderer,
+                                GetClosestSupportedFormat(renderer, format),
+                                access, w, h);
+        if (!texture->native) {
+            SDL_DestroyTexture(texture);
+            return NULL;
+        }
+
+        if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
+            texture->yuv = SDL_SW_CreateYUVTexture(format, w, h);
+            if (!texture->yuv) {
+                SDL_DestroyTexture(texture);
+                return NULL;
+            }
+        } else if (access == SDL_TEXTUREACCESS_STREAMING) {
+            /* The pitch is 4 byte aligned */
+            texture->pitch = (((w * SDL_BYTESPERPIXEL(format)) + 3) & ~3);
+            texture->pixels = SDL_malloc(texture->pitch * h);
+            if (!texture->pixels) {
+                SDL_DestroyTexture(texture);
+                return NULL;
+            }
+        }
+    }
+    return texture;
+}
+
+SDL_Texture *
+SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
+{
+    const SDL_PixelFormat *fmt;
+    SDL_bool needAlpha;
+    Uint32 i;
+    Uint32 format;
+    int bpp;
+    Uint32 Rmask, Gmask, Bmask, Amask;
+    SDL_Texture *texture;
+
+    CHECK_RENDERER_MAGIC(renderer, NULL);
+
+    if (!surface) {
+        SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface");
+        return NULL;
+    }
+
+    /* See what the best texture format is */
+    fmt = surface->format;
+    if (fmt->Amask || SDL_GetColorKey(surface, NULL) == 0) {
+        needAlpha = SDL_TRUE;
+    } else {
+        needAlpha = SDL_FALSE;
+    }
+    format = renderer->info.texture_formats[0];
+    for (i = 0; i < renderer->info.num_texture_formats; ++i) {
+        if (SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) {
+            format = renderer->info.texture_formats[i];
+            break;
+        }
+    }
+
+    if (!SDL_PixelFormatEnumToMasks(format, &bpp,
+                                    &Rmask, &Gmask, &Bmask, &Amask)) {
+        SDL_SetError("Unknown pixel format");
+        return NULL;
+    }
+
+    texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC,
+                                surface->w, surface->h);
+    if (!texture) {
+        return NULL;
+    }
+
+    if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask
+        && Bmask == fmt->Bmask && Amask == fmt->Amask) {
+        if (SDL_MUSTLOCK(surface)) {
+            SDL_LockSurface(surface);
+            SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
+            SDL_UnlockSurface(surface);
+        } else {
+            SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
+        }
+    } else {
+        SDL_PixelFormat dst_fmt;
+        SDL_Surface *temp = NULL;
+
+        /* Set up a destination surface for the texture update */
+        SDL_InitFormat(&dst_fmt, bpp, Rmask, Gmask, Bmask, Amask);
+        temp = SDL_ConvertSurface(surface, &dst_fmt, 0);
+        if (temp) {
+            SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch);
+            SDL_FreeSurface(temp);
+        } else {
+            SDL_DestroyTexture(texture);
+            return NULL;
+        }
+    }
+
+    {
+        Uint8 r, g, b, a;
+        SDL_BlendMode blendMode;
+
+        SDL_GetSurfaceColorMod(surface, &r, &g, &b);
+        SDL_SetTextureColorMod(texture, r, g, b);
+
+        SDL_GetSurfaceAlphaMod(surface, &a);
+        SDL_SetTextureAlphaMod(texture, a);
+
+        if (SDL_GetColorKey(surface, NULL) == 0) {
+            /* We converted to a texture with alpha format */
+            SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
+        } else {
+            SDL_GetSurfaceBlendMode(surface, &blendMode);
+            SDL_SetTextureBlendMode(texture, blendMode);
+        }
+    }
+    return texture;
+}
+
+int
+SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access,
+                 int *w, int *h)
+{
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    if (format) {
+        *format = texture->format;
+    }
+    if (access) {
+        *access = texture->access;
+    }
+    if (w) {
+        *w = texture->w;
+    }
+    if (h) {
+        *h = texture->h;
+    }
+    return 0;
+}
+
+int
+SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    renderer = texture->renderer;
+    if (r < 255 || g < 255 || b < 255) {
+        texture->modMode |= SDL_TEXTUREMODULATE_COLOR;
+    } else {
+        texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
+    }
+    texture->r = r;
+    texture->g = g;
+    texture->b = b;
+    if (texture->native) {
+        return SDL_SetTextureColorMod(texture->native, r, g, b);
+    } else if (renderer->SetTextureColorMod) {
+        return renderer->SetTextureColorMod(renderer, texture);
+    } else {
+        return 0;
+    }
+}
+
+int
+SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g,
+                       Uint8 * b)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    renderer = texture->renderer;
+    if (r) {
+        *r = texture->r;
+    }
+    if (g) {
+        *g = texture->g;
+    }
+    if (b) {
+        *b = texture->b;
+    }
+    return 0;
+}
+
+int
+SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    renderer = texture->renderer;
+    if (alpha < 255) {
+        texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
+    } else {
+        texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
+    }
+    texture->a = alpha;
+    if (texture->native) {
+        return SDL_SetTextureAlphaMod(texture->native, alpha);
+    } else if (renderer->SetTextureAlphaMod) {
+        return renderer->SetTextureAlphaMod(renderer, texture);
+    } else {
+        return 0;
+    }
+}
+
+int
+SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha)
+{
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    if (alpha) {
+        *alpha = texture->a;
+    }
+    return 0;
+}
+
+int
+SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    renderer = texture->renderer;
+    texture->blendMode = blendMode;
+    if (texture->native) {
+        return SDL_SetTextureBlendMode(texture->native, blendMode);
+    } else if (renderer->SetTextureBlendMode) {
+        return renderer->SetTextureBlendMode(renderer, texture);
+    } else {
+        return 0;
+    }
+}
+
+int
+SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode)
+{
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    if (blendMode) {
+        *blendMode = texture->blendMode;
+    }
+    return 0;
+}
+
+static int
+SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect,
+                     const void *pixels, int pitch)
+{
+    SDL_Texture *native = texture->native;
+    SDL_Rect full_rect;
+
+    if (SDL_SW_UpdateYUVTexture(texture->yuv, rect, pixels, pitch) < 0) {
+        return -1;
+    }
+
+    full_rect.x = 0;
+    full_rect.y = 0;
+    full_rect.w = texture->w;
+    full_rect.h = texture->h;
+    rect = &full_rect;
+
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
+        /* We can lock the texture and copy to it */
+        void *native_pixels;
+        int native_pitch;
+
+        if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
+            return -1;
+        }
+        SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
+                            rect->w, rect->h, native_pixels, native_pitch);
+        SDL_UnlockTexture(native);
+    } else {
+        /* Use a temporary buffer for updating */
+        void *temp_pixels;
+        int temp_pitch;
+
+        temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
+        temp_pixels = SDL_malloc(rect->h * temp_pitch);
+        if (!temp_pixels) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
+                            rect->w, rect->h, temp_pixels, temp_pitch);
+        SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch);
+        SDL_free(temp_pixels);
+    }
+    return 0;
+}
+
+static int
+SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect,
+                        const void *pixels, int pitch)
+{
+    SDL_Texture *native = texture->native;
+
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
+        /* We can lock the texture and copy to it */
+        void *native_pixels;
+        int native_pitch;
+
+        if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
+            return -1;
+        }
+        SDL_ConvertPixels(rect->w, rect->h,
+                          texture->format, pixels, pitch,
+                          native->format, native_pixels, native_pitch);
+        SDL_UnlockTexture(native);
+    } else {
+        /* Use a temporary buffer for updating */
+        void *temp_pixels;
+        int temp_pitch;
+
+        temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
+        temp_pixels = SDL_malloc(rect->h * temp_pitch);
+        if (!temp_pixels) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        SDL_ConvertPixels(rect->w, rect->h,
+                          texture->format, pixels, pitch,
+                          native->format, temp_pixels, temp_pitch);
+        SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch);
+        SDL_free(temp_pixels);
+    }
+    return 0;
+}
+
+int
+SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect,
+                  const void *pixels, int pitch)
+{
+    SDL_Renderer *renderer;
+    SDL_Rect full_rect;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    if (!rect) {
+        full_rect.x = 0;
+        full_rect.y = 0;
+        full_rect.w = texture->w;
+        full_rect.h = texture->h;
+        rect = &full_rect;
+    }
+
+    if (texture->yuv) {
+        return SDL_UpdateTextureYUV(texture, rect, pixels, pitch);
+    } else if (texture->native) {
+        return SDL_UpdateTextureNative(texture, rect, pixels, pitch);
+    } else {
+        renderer = texture->renderer;
+        return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
+    }
+}
+
+static int
+SDL_LockTextureYUV(SDL_Texture * texture, const SDL_Rect * rect,
+                   void **pixels, int *pitch)
+{
+    return SDL_SW_LockYUVTexture(texture->yuv, rect, pixels, pitch);
+}
+
+static int
+SDL_LockTextureNative(SDL_Texture * texture, const SDL_Rect * rect,
+                      void **pixels, int *pitch)
+{
+    texture->locked_rect = *rect;
+    *pixels = (void *) ((Uint8 *) texture->pixels +
+                        rect->y * texture->pitch +
+                        rect->x * SDL_BYTESPERPIXEL(texture->format));
+    *pitch = texture->pitch;
+    return 0;
+}
+
+int
+SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect,
+                void **pixels, int *pitch)
+{
+    SDL_Renderer *renderer;
+    SDL_Rect full_rect;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
+        SDL_SetError("SDL_LockTexture(): texture must be streaming");
+        return -1;
+    }
+
+    if (!rect) {
+        full_rect.x = 0;
+        full_rect.y = 0;
+        full_rect.w = texture->w;
+        full_rect.h = texture->h;
+        rect = &full_rect;
+    }
+
+    if (texture->yuv) {
+        return SDL_LockTextureYUV(texture, rect, pixels, pitch);
+    } else if (texture->native) {
+        return SDL_LockTextureNative(texture, rect, pixels, pitch);
+    } else {
+        renderer = texture->renderer;
+        return renderer->LockTexture(renderer, texture, rect, pixels, pitch);
+    }
+}
+
+static void
+SDL_UnlockTextureYUV(SDL_Texture * texture)
+{
+    SDL_Texture *native = texture->native;
+    void *native_pixels;
+    int native_pitch;
+    SDL_Rect rect;
+
+    rect.x = 0;
+    rect.y = 0;
+    rect.w = texture->w;
+    rect.h = texture->h;
+
+    if (SDL_LockTexture(native, &rect, &native_pixels, &native_pitch) < 0) {
+        return;
+    }
+    SDL_SW_CopyYUVToRGB(texture->yuv, &rect, native->format,
+                        rect.w, rect.h, native_pixels, native_pitch);
+    SDL_UnlockTexture(native);
+}
+
+void
+SDL_UnlockTextureNative(SDL_Texture * texture)
+{
+    SDL_Texture *native = texture->native;
+    void *native_pixels;
+    int native_pitch;
+    const SDL_Rect *rect = &texture->locked_rect;
+    const void* pixels = (void *) ((Uint8 *) texture->pixels +
+                        rect->y * texture->pitch +
+                        rect->x * SDL_BYTESPERPIXEL(texture->format));
+    int pitch = texture->pitch;
+
+    if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
+        return;
+    }
+    SDL_ConvertPixels(rect->w, rect->h,
+                      texture->format, pixels, pitch,
+                      native->format, native_pixels, native_pitch);
+    SDL_UnlockTexture(native);
+}
+
+void
+SDL_UnlockTexture(SDL_Texture * texture)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, );
+
+    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
+        return;
+    }
+    if (texture->yuv) {
+        SDL_UnlockTextureYUV(texture);
+    } else if (texture->native) {
+        SDL_UnlockTextureNative(texture);
+    } else {
+        renderer = texture->renderer;
+        renderer->UnlockTexture(renderer, texture);
+    }
+}
+
+int
+SDL_SetRenderDrawColor(SDL_Renderer * renderer,
+                       Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    renderer->r = r;
+    renderer->g = g;
+    renderer->b = b;
+    renderer->a = a;
+    return 0;
+}
+
+int
+SDL_GetRenderDrawColor(SDL_Renderer * renderer,
+                       Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (r) {
+        *r = renderer->r;
+    }
+    if (g) {
+        *g = renderer->g;
+    }
+    if (b) {
+        *b = renderer->b;
+    }
+    if (a) {
+        *a = renderer->a;
+    }
+    return 0;
+}
+
+int
+SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    renderer->blendMode = blendMode;
+    return 0;
+}
+
+int
+SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode *blendMode)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    *blendMode = renderer->blendMode;
+    return 0;
+}
+
+int
+SDL_RenderClear(SDL_Renderer * renderer)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!renderer->RenderClear) {
+        SDL_BlendMode blendMode = renderer->blendMode;
+        int status;
+
+        if (blendMode >= SDL_BLENDMODE_BLEND) {
+            SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
+        }
+
+        status = SDL_RenderFillRect(renderer, NULL);
+
+        if (blendMode >= SDL_BLENDMODE_BLEND) {
+            SDL_SetRenderDrawBlendMode(renderer, blendMode);
+        }
+        return status;
+    }
+    return renderer->RenderClear(renderer);
+}
+
+int
+SDL_RenderDrawPoint(SDL_Renderer * renderer, int x, int y)
+{
+    SDL_Point point;
+
+    point.x = x;
+    point.y = y;
+    return SDL_RenderDrawPoints(renderer, &point, 1);
+}
+
+int
+SDL_RenderDrawPoints(SDL_Renderer * renderer,
+                     const SDL_Point * points, int count)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!points) {
+        SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
+        return -1;
+    }
+    if (count < 1) {
+        return 0;
+    }
+    return renderer->RenderDrawPoints(renderer, points, count);
+}
+
+int
+SDL_RenderDrawLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
+{
+    SDL_Point points[2];
+
+    points[0].x = x1;
+    points[0].y = y1;
+    points[1].x = x2;
+    points[1].y = y2;
+    return SDL_RenderDrawLines(renderer, points, 2);
+}
+
+int
+SDL_RenderDrawLines(SDL_Renderer * renderer,
+                    const SDL_Point * points, int count)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!points) {
+        SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
+        return -1;
+    }
+    if (count < 2) {
+        return 0;
+    }
+    return renderer->RenderDrawLines(renderer, points, count);
+}
+
+int
+SDL_RenderDrawRect(SDL_Renderer * renderer, const SDL_Rect * rect)
+{
+    SDL_Rect full_rect;
+    SDL_Point points[5];
+
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    /* If 'rect' == NULL, then outline the whole surface */
+    if (!rect) {
+        SDL_Window *window = renderer->window;
+
+        full_rect.x = 0;
+        full_rect.y = 0;
+        SDL_GetWindowSize(window, &full_rect.w, &full_rect.h);
+        rect = &full_rect;
+    }
+
+    points[0].x = rect->x;
+    points[0].y = rect->y;
+    points[1].x = rect->x+rect->w-1;
+    points[1].y = rect->y;
+    points[2].x = rect->x+rect->w-1;
+    points[2].y = rect->y+rect->h-1;
+    points[3].x = rect->x;
+    points[3].y = rect->y+rect->h-1;
+    points[4].x = rect->x;
+    points[4].y = rect->y;
+    return SDL_RenderDrawLines(renderer, points, 5);
+}
+
+int
+SDL_RenderDrawRects(SDL_Renderer * renderer,
+                    const SDL_Rect ** rects, int count)
+{
+    int i;
+
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!rects) {
+        SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
+        return -1;
+    }
+    if (count < 1) {
+        return 0;
+    }
+
+    /* Check for NULL rect, which means fill entire window */
+    for (i = 0; i < count; ++i) {
+        if (SDL_RenderDrawRect(renderer, rects[i]) < 0) {
+            return -1;
+        }
+    }
+    return 0;
+}
+
+int
+SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect)
+{
+    return SDL_RenderFillRects(renderer, &rect, 1);
+}
+
+int
+SDL_RenderFillRects(SDL_Renderer * renderer,
+                    const SDL_Rect ** rects, int count)
+{
+    int i;
+
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!rects) {
+        SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
+        return -1;
+    }
+    if (count < 1) {
+        return 0;
+    }
+
+    /* Check for NULL rect, which means fill entire window */
+    for (i = 0; i < count; ++i) {
+        if (rects[i] == NULL) {
+            SDL_Window *window = renderer->window;
+            SDL_Rect full_rect;
+            const SDL_Rect *rect;
+
+            full_rect.x = 0;
+            full_rect.y = 0;
+            SDL_GetWindowSize(window, &full_rect.w, &full_rect.h);
+            rect = &full_rect;
+            return renderer->RenderFillRects(renderer, &rect, 1);
+        }
+    }
+    return renderer->RenderFillRects(renderer, rects, count);
+}
+
+int
+SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+{
+    SDL_Window *window;
+    SDL_Rect real_srcrect;
+    SDL_Rect real_dstrect;
+
+    CHECK_RENDERER_MAGIC(renderer, -1);
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    if (renderer != texture->renderer) {
+        SDL_SetError("Texture was not created with this renderer");
+        return -1;
+    }
+    window = renderer->window;
+
+    real_srcrect.x = 0;
+    real_srcrect.y = 0;
+    real_srcrect.w = texture->w;
+    real_srcrect.h = texture->h;
+    if (srcrect) {
+        if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
+            return 0;
+        }
+    }
+
+    real_dstrect.x = 0;
+    real_dstrect.y = 0;
+    SDL_GetWindowSize(window, &real_dstrect.w, &real_dstrect.h);
+    if (dstrect) {
+        if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) {
+            return 0;
+        }
+        /* Clip srcrect by the same amount as dstrect was clipped */
+        if (dstrect->w != real_dstrect.w) {
+            int deltax = (real_dstrect.x - dstrect->x);
+            int deltaw = (real_dstrect.w - dstrect->w);
+            real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w;
+            real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w;
+        }
+        if (dstrect->h != real_dstrect.h) {
+            int deltay = (real_dstrect.y - dstrect->y);
+            int deltah = (real_dstrect.h - dstrect->h);
+            real_srcrect.y += (deltay * real_srcrect.h) / dstrect->h;
+            real_srcrect.h += (deltah * real_srcrect.h) / dstrect->h;
+        }
+    }
+
+    if (texture->native) {
+        texture = texture->native;
+    }
+
+    return renderer->RenderCopy(renderer, texture, &real_srcrect,
+                                &real_dstrect);
+}
+
+int
+SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                     Uint32 format, void * pixels, int pitch)
+{
+    SDL_Window *window;
+    SDL_Rect real_rect;
+
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!renderer->RenderReadPixels) {
+        SDL_Unsupported();
+        return -1;
+    }
+    window = renderer->window;
+
+    if (!format) {
+        format = SDL_GetWindowPixelFormat(window);
+    }
+
+    real_rect.x = 0;
+    real_rect.y = 0;
+    SDL_GetWindowSize(window, &real_rect.w, &real_rect.h);
+    if (rect) {
+        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
+            return 0;
+        }
+        if (real_rect.y > rect->y) {
+            pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
+        }
+        if (real_rect.x > rect->x) {
+            int bpp = SDL_BYTESPERPIXEL(SDL_GetWindowPixelFormat(window));
+            pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
+        }
+    }
+
+    return renderer->RenderReadPixels(renderer, &real_rect,
+                                      format, pixels, pitch);
+}
+
+void
+SDL_RenderPresent(SDL_Renderer * renderer)
+{
+    CHECK_RENDERER_MAGIC(renderer, );
+
+    renderer->RenderPresent(renderer);
+}
+
+void
+SDL_DestroyTexture(SDL_Texture * texture)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, );
+    texture->magic = NULL;
+
+    renderer = texture->renderer;
+    if (texture->next) {
+        texture->next->prev = texture->prev;
+    }
+    if (texture->prev) {
+        texture->prev->next = texture->next;
+    } else {
+        renderer->textures = texture->next;
+    }
+
+    if (texture->native) {
+        SDL_DestroyTexture(texture->native);
+    }
+    if (texture->yuv) {
+        SDL_SW_DestroyYUVTexture(texture->yuv);
+    }
+    if (texture->pixels) {
+        SDL_free(texture->pixels);
+    }
+
+    renderer->DestroyTexture(renderer, texture);
+    SDL_free(texture);
+}
+
+void
+SDL_DestroyRenderer(SDL_Renderer * renderer)
+{
+    CHECK_RENDERER_MAGIC(renderer, );
+
+    SDL_DelEventWatch(SDL_RendererEventWatch, renderer);
+
+    /* Free existing textures for this renderer */
+    while (renderer->textures) {
+        SDL_DestroyTexture(renderer->textures);
+    }
+
+    /* It's no longer magical... */
+    renderer->magic = NULL;
+
+    /* Free the renderer instance */
+    renderer->DestroyRenderer(renderer);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/SDL_sysrender.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,140 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_sysrender_h
+#define _SDL_sysrender_h
+
+#include "SDL_render.h"
+#include "SDL_events.h"
+#include "SDL_yuv_sw_c.h"
+
+/* The SDL 2D rendering system */
+
+typedef struct SDL_RenderDriver SDL_RenderDriver;
+
+/* Define the SDL texture structure */
+struct SDL_Texture
+{
+    const void *magic;
+    Uint32 format;              /**< The pixel format of the texture */
+    int access;                 /**< SDL_TextureAccess */
+    int w;                      /**< The width of the texture */
+    int h;                      /**< The height of the texture */
+    int modMode;                /**< The texture modulation mode */
+    SDL_BlendMode blendMode;    /**< The texture blend mode */
+    Uint8 r, g, b, a;           /**< Texture modulation values */
+
+    SDL_Renderer *renderer;
+
+    /* Support for formats not supported directly by the renderer */
+    SDL_Texture *native;
+    SDL_SW_YUVTexture *yuv;
+    void *pixels;
+    int pitch;
+    SDL_Rect locked_rect;
+
+    void *driverdata;           /**< Driver specific texture representation */
+
+    SDL_Texture *prev;
+    SDL_Texture *next;
+};
+
+/* Define the SDL renderer structure */
+struct SDL_Renderer
+{
+    const void *magic;
+
+    void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
+    int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
+    int (*SetTextureColorMod) (SDL_Renderer * renderer,
+                               SDL_Texture * texture);
+    int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
+                               SDL_Texture * texture);
+    int (*SetTextureBlendMode) (SDL_Renderer * renderer,
+                                SDL_Texture * texture);
+    int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
+                          const SDL_Rect * rect, const void *pixels,
+                          int pitch);
+    int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
+                        const SDL_Rect * rect, void **pixels, int *pitch);
+    void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
+    int (*RenderClear) (SDL_Renderer * renderer);
+    int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
+                             int count);
+    int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
+                            int count);
+    int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
+                            int count);
+    int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
+                       const SDL_Rect * srcrect, const SDL_Rect * dstrect);
+    int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
+                             Uint32 format, void * pixels, int pitch);
+    void (*RenderPresent) (SDL_Renderer * renderer);
+    void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
+
+    void (*DestroyRenderer) (SDL_Renderer * renderer);
+
+    /* The current renderer info */
+    SDL_RendererInfo info;
+
+    /* The window associated with the renderer */
+    SDL_Window *window;
+
+    /* The list of textures */
+    SDL_Texture *textures;
+
+    Uint8 r, g, b, a;                   /**< Color for drawing operations values */
+    SDL_BlendMode blendMode;            /**< The drawing blend mode */
+
+    void *driverdata;
+};
+
+/* Define the SDL render driver structure */
+struct SDL_RenderDriver
+{
+    SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
+
+    /* Info about the renderer capabilities */
+    SDL_RendererInfo info;
+};
+
+#if SDL_VIDEO_RENDER_D3D
+extern SDL_RenderDriver D3D_RenderDriver;
+#endif
+#if SDL_VIDEO_RENDER_OGL
+extern SDL_RenderDriver GL_RenderDriver;
+#endif
+#if SDL_VIDEO_RENDER_OGL_ES2
+extern SDL_RenderDriver GLES2_RenderDriver;
+#endif
+#if SDL_VIDEO_RENDER_OGL_ES
+extern SDL_RenderDriver GLES_RenderDriver;
+#endif
+#if SDL_VIDEO_RENDER_DIRECTFB
+extern SDL_RenderDriver DirectFB_RenderDriver;
+#endif
+extern SDL_RenderDriver SW_RenderDriver;
+
+#endif /* _SDL_sysrender_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/SDL_yuv_mmx.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,432 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
+
+#include "SDL_stdinc.h"
+
+#include "mmx.h"
+
+/* *INDENT-OFF* */
+
+static mmx_t MMX_0080w    = { .ud = {0x00800080, 0x00800080} };
+static mmx_t MMX_00FFw    = { .ud = {0x00ff00ff, 0x00ff00ff} };
+static mmx_t MMX_FF00w    = { .ud = {0xff00ff00, 0xff00ff00} };
+
+static mmx_t MMX_Ycoeff   = { .uw = {0x004a, 0x004a, 0x004a, 0x004a} };
+
+static mmx_t MMX_UbluRGB  = { .uw = {0x0072, 0x0072, 0x0072, 0x0072} };
+static mmx_t MMX_VredRGB  = { .uw = {0x0059, 0x0059, 0x0059, 0x0059} };
+static mmx_t MMX_UgrnRGB  = { .uw = {0xffea, 0xffea, 0xffea, 0xffea} };
+static mmx_t MMX_VgrnRGB  = { .uw = {0xffd2, 0xffd2, 0xffd2, 0xffd2} };
+
+static mmx_t MMX_Ublu5x5  = { .uw = {0x0081, 0x0081, 0x0081, 0x0081} };
+static mmx_t MMX_Vred5x5  = { .uw = {0x0066, 0x0066, 0x0066, 0x0066} };
+static mmx_t MMX_Ugrn565  = { .uw = {0xffe8, 0xffe8, 0xffe8, 0xffe8} };
+static mmx_t MMX_Vgrn565  = { .uw = {0xffcd, 0xffcd, 0xffcd, 0xffcd} };
+
+static mmx_t MMX_red565   = { .uw = {0xf800, 0xf800, 0xf800, 0xf800} };
+static mmx_t MMX_grn565   = { .uw = {0x07e0, 0x07e0, 0x07e0, 0x07e0} };
+
+/**
+   This MMX assembler is my first assembler/MMX program ever.
+   Thus it maybe buggy.
+   Send patches to:
+   mvogt@rhrk.uni-kl.de
+
+   After it worked fine I have "obfuscated" the code a bit to have
+   more parallism in the MMX units. This means I moved
+   initilisation around and delayed other instruction.
+   Performance measurement did not show that this brought any advantage
+   but in theory it _should_ be faster this way.
+
+   The overall performanve gain to the C based dither was 30%-40%.
+   The MMX routine calculates 256bit=8RGB values in each cycle
+   (4 for row1 & 4 for row2)
+
+   The red/green/blue.. coefficents are taken from the mpeg_play 
+   player. They look nice, but I dont know if you can have
+   better values, to avoid integer rounding errors.
+   
+
+   IMPORTANT:
+   ==========
+
+   It is a requirement that the cr/cb/lum are 8 byte aligned and
+   the out are 16byte aligned or you will/may get segfaults
+
+*/
+
+void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
+                              unsigned char *lum, unsigned char *cr,
+                              unsigned char *cb, unsigned char *out,
+                              int rows, int cols, int mod )
+{
+    Uint32 *row1;
+    Uint32 *row2;
+
+    unsigned char* y = lum +cols*rows;    // Pointer to the end
+    int x = 0;
+    row1 = (Uint32 *)out;                 // 32 bit target
+    row2 = (Uint32 *)out+cols+mod;        // start of second row
+    mod = (mod+cols+mod)*4;               // increment for row1 in byte
+
+    __asm__ __volatile__ (
+        // tap dance to workaround the inability to use %%ebx at will...
+        //  move one thing to the stack...
+        "pushl $0\n"  // save a slot on the stack.
+        "pushl %%ebx\n"  // save %%ebx.
+        "movl %0, %%ebx\n"  // put the thing in ebx.
+        "movl %%ebx,4(%%esp)\n"  // put the thing in the stack slot.
+        "popl %%ebx\n"  // get back %%ebx (the PIC register).
+
+        ".align 8\n"
+        "1:\n"
+
+        // create Cr (result in mm1)
+        "pushl %%ebx\n"
+        "movl 4(%%esp),%%ebx\n"
+        "movd (%%ebx),%%mm1\n"   //         0  0  0  0  v3 v2 v1 v0
+        "popl %%ebx\n"
+        "pxor %%mm7,%%mm7\n"      //         00 00 00 00 00 00 00 00
+        "movd (%2), %%mm2\n"           //    0  0  0  0 l3 l2 l1 l0
+        "punpcklbw %%mm7,%%mm1\n" //         0  v3 0  v2 00 v1 00 v0
+        "punpckldq %%mm1,%%mm1\n" //         00 v1 00 v0 00 v1 00 v0
+        "psubw %9,%%mm1\n"        // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0
+
+        // create Cr_g (result in mm0)
+        "movq %%mm1,%%mm0\n"           // r1 r1 r0 r0 r1 r1 r0 r0
+        "pmullw %10,%%mm0\n"           // red*-46dec=0.7136*64
+        "pmullw %11,%%mm1\n"           // red*89dec=1.4013*64
+        "psraw  $6, %%mm0\n"           // red=red/64
+        "psraw  $6, %%mm1\n"           // red=red/64
+
+        // create L1 L2 (result in mm2,mm4)
+        // L2=lum+cols
+        "movq (%2,%4),%%mm3\n"         //    0  0  0  0 L3 L2 L1 L0
+        "punpckldq %%mm3,%%mm2\n"      //   L3 L2 L1 L0 l3 l2 l1 l0
+        "movq %%mm2,%%mm4\n"           //   L3 L2 L1 L0 l3 l2 l1 l0
+        "pand %12,%%mm2\n"             //   L3 0  L1  0 l3  0 l1  0
+        "pand %13,%%mm4\n"             //   0  L2  0 L0  0 l2  0 l0
+        "psrlw $8,%%mm2\n"             //   0  L3  0 L1  0 l3  0 l1
+
+        // create R (result in mm6)
+        "movq %%mm2,%%mm5\n"           //   0 L3  0 L1  0 l3  0 l1
+        "movq %%mm4,%%mm6\n"           //   0 L2  0 L0  0 l2  0 l0
+        "paddsw  %%mm1, %%mm5\n"       // lum1+red:x R3 x R1 x r3 x r1
+        "paddsw  %%mm1, %%mm6\n"       // lum1+red:x R2 x R0 x r2 x r0
+        "packuswb %%mm5,%%mm5\n"       //  R3 R1 r3 r1 R3 R1 r3 r1
+        "packuswb %%mm6,%%mm6\n"       //  R2 R0 r2 r0 R2 R0 r2 r0
+        "pxor %%mm7,%%mm7\n"      //         00 00 00 00 00 00 00 00
+        "punpcklbw %%mm5,%%mm6\n"      //  R3 R2 R1 R0 r3 r2 r1 r0
+
+        // create Cb (result in mm1)
+        "movd (%1), %%mm1\n"      //         0  0  0  0  u3 u2 u1 u0
+        "punpcklbw %%mm7,%%mm1\n" //         0  u3 0  u2 00 u1 00 u0
+        "punpckldq %%mm1,%%mm1\n" //         00 u1 00 u0 00 u1 00 u0
+        "psubw %9,%%mm1\n"        // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0
+
+        // create Cb_g (result in mm5)
+        "movq %%mm1,%%mm5\n"            // u1 u1 u0 u0 u1 u1 u0 u0
+        "pmullw %14,%%mm5\n"            // blue*-109dec=1.7129*64
+        "pmullw %15,%%mm1\n"            // blue*114dec=1.78125*64
+        "psraw  $6, %%mm5\n"            // blue=red/64
+        "psraw  $6, %%mm1\n"            // blue=blue/64
+
+        // create G (result in mm7)
+        "movq %%mm2,%%mm3\n"      //   0  L3  0 L1  0 l3  0 l1
+        "movq %%mm4,%%mm7\n"      //   0  L2  0 L0  0 l2  0 l1
+        "paddsw  %%mm5, %%mm3\n"  // lum1+Cb_g:x G3t x G1t x g3t x g1t
+        "paddsw  %%mm5, %%mm7\n"  // lum1+Cb_g:x G2t x G0t x g2t x g0t
+        "paddsw  %%mm0, %%mm3\n"  // lum1+Cr_g:x G3  x G1  x g3  x g1
+        "paddsw  %%mm0, %%mm7\n"  // lum1+blue:x G2  x G0  x g2  x g0
+        "packuswb %%mm3,%%mm3\n"  // G3 G1 g3 g1 G3 G1 g3 g1
+        "packuswb %%mm7,%%mm7\n"  // G2 G0 g2 g0 G2 G0 g2 g0
+        "punpcklbw %%mm3,%%mm7\n" // G3 G2 G1 G0 g3 g2 g1 g0
+
+        // create B (result in mm5)
+        "movq %%mm2,%%mm3\n"         //   0  L3  0 L1  0 l3  0 l1
+        "movq %%mm4,%%mm5\n"         //   0  L2  0 L0  0 l2  0 l1
+        "paddsw  %%mm1, %%mm3\n"     // lum1+blue:x B3 x B1 x b3 x b1
+        "paddsw  %%mm1, %%mm5\n"     // lum1+blue:x B2 x B0 x b2 x b0
+        "packuswb %%mm3,%%mm3\n"     // B3 B1 b3 b1 B3 B1 b3 b1
+        "packuswb %%mm5,%%mm5\n"     // B2 B0 b2 b0 B2 B0 b2 b0
+        "punpcklbw %%mm3,%%mm5\n"    // B3 B2 B1 B0 b3 b2 b1 b0
+
+        // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb)
+
+        "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
+        "pxor %%mm4,%%mm4\n"           //  0  0  0  0  0  0  0  0
+        "movq %%mm6,%%mm1\n"           // R3 R2 R1 R0 r3 r2 r1 r0
+        "movq %%mm5,%%mm3\n"           // B3 B2 B1 B0 b3 b2 b1 b0
+
+        // process lower lum
+        "punpcklbw %%mm4,%%mm1\n"      //  0 r3  0 r2  0 r1  0 r0
+        "punpcklbw %%mm4,%%mm3\n"      //  0 b3  0 b2  0 b1  0 b0
+        "movq %%mm1,%%mm2\n"           //  0 r3  0 r2  0 r1  0 r0
+        "movq %%mm3,%%mm0\n"           //  0 b3  0 b2  0 b1  0 b0
+        "punpcklwd %%mm1,%%mm3\n"      //  0 r1  0 b1  0 r0  0 b0
+        "punpckhwd %%mm2,%%mm0\n"      //  0 r3  0 b3  0 r2  0 b2
+
+        "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
+        "movq %%mm7,%%mm1\n"           // G3 G2 G1 G0 g3 g2 g1 g0
+        "punpcklbw %%mm1,%%mm2\n"      // g3  0 g2  0 g1  0 g0  0
+        "punpcklwd %%mm4,%%mm2\n"      //  0  0 g1  0  0  0 g0  0
+        "por %%mm3, %%mm2\n"          //  0 r1 g1 b1  0 r0 g0 b0
+        "movq %%mm2,(%3)\n"          // wrote out ! row1
+
+        "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
+        "punpcklbw %%mm1,%%mm4\n"      // g3  0 g2  0 g1  0 g0  0
+        "punpckhwd %%mm2,%%mm4\n"      //  0  0 g3  0  0  0 g2  0
+        "por %%mm0, %%mm4\n"          //  0 r3 g3 b3  0 r2 g2 b2
+        "movq %%mm4,8(%3)\n"         // wrote out ! row1
+
+        // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb)
+        // this can be done "destructive"
+        "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
+        "punpckhbw %%mm2,%%mm6\n"      //  0 R3  0 R2  0 R1  0 R0
+        "punpckhbw %%mm1,%%mm5\n"      // G3 B3 G2 B2 G1 B1 G0 B0
+        "movq %%mm5,%%mm1\n"           // G3 B3 G2 B2 G1 B1 G0 B0
+        "punpcklwd %%mm6,%%mm1\n"      //  0 R1 G1 B1  0 R0 G0 B0
+        "movq %%mm1,(%5)\n"          // wrote out ! row2
+        "punpckhwd %%mm6,%%mm5\n"      //  0 R3 G3 B3  0 R2 G2 B2
+        "movq %%mm5,8(%5)\n"         // wrote out ! row2
+
+        "addl $4,%2\n"            // lum+4
+        "leal 16(%3),%3\n"        // row1+16
+        "leal 16(%5),%5\n"        // row2+16
+        "addl $2,(%%esp)\n"        // cr+2
+        "addl $2,%1\n"           // cb+2
+
+        "addl $4,%6\n"            // x+4
+        "cmpl %4,%6\n"
+
+        "jl 1b\n"
+        "addl %4,%2\n" // lum += cols
+        "addl %8,%3\n" // row1+= mod
+        "addl %8,%5\n" // row2+= mod
+        "movl $0,%6\n" // x=0
+        "cmpl %7,%2\n"
+        "jl 1b\n"
+
+        "addl $4,%%esp\n"  // get rid of the stack slot we reserved.
+        "emms\n"  // reset MMX registers.
+        :
+        : "m" (cr), "r"(cb),"r"(lum),
+          "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
+          "m"(MMX_0080w),"m"(MMX_VgrnRGB),"m"(MMX_VredRGB),
+          "m"(MMX_FF00w),"m"(MMX_00FFw),"m"(MMX_UgrnRGB),
+          "m"(MMX_UbluRGB)
+    );
+}
+
+void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
+                             unsigned char *lum, unsigned char *cr,
+                             unsigned char *cb, unsigned char *out,
+                             int rows, int cols, int mod )
+{
+    Uint16 *row1;
+    Uint16 *row2;
+
+    unsigned char* y = lum +cols*rows;    /* Pointer to the end */
+    int x = 0;
+    row1 = (Uint16 *)out;                 /* 16 bit target */
+    row2 = (Uint16 *)out+cols+mod;        /* start of second row  */
+    mod = (mod+cols+mod)*2;               /* increment for row1 in byte */
+
+    __asm__ __volatile__(
+        // tap dance to workaround the inability to use %%ebx at will...
+        //  move one thing to the stack...
+        "pushl $0\n"  // save a slot on the stack.
+        "pushl %%ebx\n"  // save %%ebx.
+        "movl %0, %%ebx\n"  // put the thing in ebx.
+        "movl %%ebx, 4(%%esp)\n"  // put the thing in the stack slot.
+        "popl %%ebx\n"  // get back %%ebx (the PIC register).
+
+        ".align 8\n"
+        "1:\n"
+
+        "movd           (%1),                   %%mm0\n" // 4 Cb         0  0  0  0 u3 u2 u1 u0
+        "pxor           %%mm7,                  %%mm7\n"
+        "pushl %%ebx\n"
+        "movl 4(%%esp), %%ebx\n"
+        "movd (%%ebx), %%mm1\n"   // 4 Cr                0  0  0  0 v3 v2 v1 v0
+        "popl %%ebx\n"
+
+        "punpcklbw      %%mm7,                  %%mm0\n" // 4 W cb   0 u3  0 u2  0 u1  0 u0
+        "punpcklbw      %%mm7,                  %%mm1\n" // 4 W cr   0 v3  0 v2  0 v1  0 v0
+        "psubw          %9,                     %%mm0\n"
+        "psubw          %9,                     %%mm1\n"
+        "movq           %%mm0,                  %%mm2\n" // Cb                   0 u3  0 u2  0 u1  0 u0
+        "movq           %%mm1,                  %%mm3\n" // Cr
+        "pmullw         %10,                    %%mm2\n" // Cb2green 0 R3  0 R2  0 R1  0 R0
+        "movq           (%2),                   %%mm6\n" // L1      l7 L6 L5 L4 L3 L2 L1 L0
+        "pmullw         %11,                    %%mm0\n" // Cb2blue
+        "pand           %12,                    %%mm6\n" // L1      00 L6 00 L4 00 L2 00 L0
+        "pmullw         %13,                    %%mm3\n" // Cr2green
+        "movq           (%2),                   %%mm7\n" // L2
+        "pmullw         %14,                    %%mm1\n" // Cr2red
+        "psrlw          $8,                     %%mm7\n"        // L2           00 L7 00 L5 00 L3 00 L1
+        "pmullw         %15,                    %%mm6\n" // lum1
+        "paddw          %%mm3,                  %%mm2\n" // Cb2green + Cr2green == green
+        "pmullw         %15,                    %%mm7\n" // lum2
+
+        "movq           %%mm6,                  %%mm4\n" // lum1
+        "paddw          %%mm0,                  %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0
+        "movq           %%mm4,                  %%mm5\n" // lum1
+        "paddw          %%mm1,                  %%mm4\n" // lum1 +red  00 R6 00 R4 00 R2 00 R0
+        "paddw          %%mm2,                  %%mm5\n" // lum1 +green 00 G6 00 G4 00 G2 00 G0
+        "psraw          $6,                     %%mm4\n" // R1 0 .. 64
+        "movq           %%mm7,                  %%mm3\n" // lum2                       00 L7 00 L5 00 L3 00 L1
+        "psraw          $6,                     %%mm5\n" // G1  - .. +
+        "paddw          %%mm0,                  %%mm7\n" // Lum2 +blue 00 B7 00 B5 00 B3 00 B1
+        "psraw          $6,                     %%mm6\n" // B1         0 .. 64
+        "packuswb       %%mm4,                  %%mm4\n" // R1 R1
+        "packuswb       %%mm5,                  %%mm5\n" // G1 G1
+        "packuswb       %%mm6,                  %%mm6\n" // B1 B1
+        "punpcklbw      %%mm4,                  %%mm4\n"
+        "punpcklbw      %%mm5,                  %%mm5\n"
+
+        "pand           %16,                    %%mm4\n"
+        "psllw          $3,                     %%mm5\n" // GREEN       1
+        "punpcklbw      %%mm6,                  %%mm6\n"
+        "pand           %17,                    %%mm5\n"
+        "pand           %16,                    %%mm6\n"
+        "por            %%mm5,                  %%mm4\n" //
+        "psrlw          $11,                    %%mm6\n" // BLUE        1
+        "movq           %%mm3,                  %%mm5\n" // lum2
+        "paddw          %%mm1,                  %%mm3\n" // lum2 +red      00 R7 00 R5 00 R3 00 R1
+        "paddw          %%mm2,                  %%mm5\n" // lum2 +green 00 G7 00 G5 00 G3 00 G1
+        "psraw          $6,                     %%mm3\n" // R2
+        "por            %%mm6,                  %%mm4\n" // MM4
+        "psraw          $6,                     %%mm5\n" // G2
+        "movq           (%2, %4),               %%mm6\n" // L3 load lum2
+        "psraw          $6,                     %%mm7\n"
+        "packuswb       %%mm3,                  %%mm3\n"
+        "packuswb       %%mm5,                  %%mm5\n"
+        "packuswb       %%mm7,                  %%mm7\n"
+        "pand           %12,                    %%mm6\n" // L3
+        "punpcklbw      %%mm3,                  %%mm3\n"
+        "punpcklbw      %%mm5,                  %%mm5\n"
+        "pmullw         %15,                    %%mm6\n" // lum3
+        "punpcklbw      %%mm7,                  %%mm7\n"
+        "psllw          $3,                     %%mm5\n" // GREEN 2
+        "pand           %16,                    %%mm7\n"
+        "pand           %16,                    %%mm3\n"
+        "psrlw          $11,                    %%mm7\n" // BLUE  2
+        "pand           %17,                    %%mm5\n"
+        "por            %%mm7,                  %%mm3\n"
+        "movq           (%2,%4),                %%mm7\n" // L4 load lum2
+        "por            %%mm5,                  %%mm3\n" //
+        "psrlw          $8,                     %%mm7\n" // L4
+        "movq           %%mm4,                  %%mm5\n"
+        "punpcklwd      %%mm3,                  %%mm4\n"
+        "pmullw         %15,                    %%mm7\n" // lum4
+        "punpckhwd      %%mm3,                  %%mm5\n"
+
+        "movq           %%mm4,                  (%3)\n"  // write row1
+        "movq           %%mm5,                  8(%3)\n" // write row1
+
+        "movq           %%mm6,                  %%mm4\n" // Lum3
+        "paddw          %%mm0,                  %%mm6\n" // Lum3 +blue
+
+        "movq           %%mm4,                  %%mm5\n" // Lum3
+        "paddw          %%mm1,                  %%mm4\n" // Lum3 +red
+        "paddw          %%mm2,                  %%mm5\n" // Lum3 +green
+        "psraw          $6,                     %%mm4\n"
+        "movq           %%mm7,                  %%mm3\n" // Lum4
+        "psraw          $6,                     %%mm5\n"
+        "paddw          %%mm0,                  %%mm7\n" // Lum4 +blue
+        "psraw          $6,                     %%mm6\n" // Lum3 +blue
+        "movq           %%mm3,                  %%mm0\n" // Lum4
+        "packuswb       %%mm4,                  %%mm4\n"
+        "paddw          %%mm1,                  %%mm3\n" // Lum4 +red
+        "packuswb       %%mm5,                  %%mm5\n"
+        "paddw          %%mm2,                  %%mm0\n" // Lum4 +green
+        "packuswb       %%mm6,                  %%mm6\n"
+        "punpcklbw      %%mm4,                  %%mm4\n"
+        "punpcklbw      %%mm5,                  %%mm5\n"
+        "punpcklbw      %%mm6,                  %%mm6\n"
+        "psllw          $3,                     %%mm5\n" // GREEN 3
+        "pand           %16,                    %%mm4\n"
+        "psraw          $6,                     %%mm3\n" // psr 6
+        "psraw          $6,                     %%mm0\n"
+        "pand           %16,                    %%mm6\n" // BLUE
+        "pand           %17,                    %%mm5\n"
+        "psrlw          $11,                    %%mm6\n" // BLUE  3
+        "por            %%mm5,                  %%mm4\n"
+        "psraw          $6,                     %%mm7\n"
+        "por            %%mm6,                  %%mm4\n"
+        "packuswb       %%mm3,                  %%mm3\n"
+        "packuswb       %%mm0,                  %%mm0\n"
+        "packuswb       %%mm7,                  %%mm7\n"
+        "punpcklbw      %%mm3,                  %%mm3\n"
+        "punpcklbw      %%mm0,                  %%mm0\n"
+        "punpcklbw      %%mm7,                  %%mm7\n"
+        "pand           %16,                    %%mm3\n"
+        "pand           %16,                    %%mm7\n" // BLUE
+        "psllw          $3,                     %%mm0\n" // GREEN 4
+        "psrlw          $11,                    %%mm7\n"
+        "pand           %17,                    %%mm0\n"
+        "por            %%mm7,                  %%mm3\n"
+        "por            %%mm0,                  %%mm3\n"
+
+        "movq           %%mm4,                  %%mm5\n"
+
+        "punpcklwd      %%mm3,                  %%mm4\n"
+        "punpckhwd      %%mm3,                  %%mm5\n"
+
+        "movq           %%mm4,                  (%5)\n"
+        "movq           %%mm5,                  8(%5)\n"
+
+        "addl           $8,                     %6\n"
+        "addl           $8,                     %2\n"
+        "addl           $4,                     (%%esp)\n"
+        "addl           $4,                     %1\n"
+        "cmpl           %4,                     %6\n"
+        "leal           16(%3),                 %3\n"
+        "leal           16(%5),%5\n" // row2+16
+
+        "jl             1b\n"
+        "addl           %4,     %2\n" // lum += cols
+        "addl           %8,     %3\n" // row1+= mod
+        "addl           %8,     %5\n" // row2+= mod
+        "movl           $0,     %6\n" // x=0
+        "cmpl           %7,     %2\n"
+        "jl             1b\n"
+        "addl $4, %%esp\n"  // get rid of the stack slot we reserved.
+        "emms\n"
+        :
+        : "m" (cr), "r"(cb),"r"(lum),
+          "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
+          "m"(MMX_0080w),"m"(MMX_Ugrn565),"m"(MMX_Ublu5x5),
+          "m"(MMX_00FFw),"m"(MMX_Vgrn565),"m"(MMX_Vred5x5),
+          "m"(MMX_Ycoeff),"m"(MMX_red565),"m"(MMX_grn565)
+    );
+}
+
+/* *INDENT-ON* */
+
+#endif /* GCC3 i386 inline assembly */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/SDL_yuv_sw.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,1322 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* This is the software implementation of the YUV texture support */
+
+/* This code was derived from code carrying the following copyright notices:
+
+ * Copyright (c) 1995 The Regents of the University of California.
+ * All rights reserved.
+ * 
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice and the following
+ * two paragraphs appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+ * Copyright (c) 1995 Erik Corry
+ * All rights reserved.
+ * 
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice and the following
+ * two paragraphs appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL ERIK CORRY BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+ * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
+ * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ERIK CORRY HAS BEEN ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * ERIK CORRY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+ * BASIS, AND ERIK CORRY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
+ * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+ * Portions of this software Copyright (c) 1995 Brown University.
+ * All rights reserved.
+ * 
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement
+ * is hereby granted, provided that the above copyright notice and the
+ * following two paragraphs appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF BROWN
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * BROWN UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+ * BASIS, AND BROWN UNIVERSITY HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+ * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ */
+
+#include "SDL_video.h"
+#include "SDL_cpuinfo.h"
+#include "SDL_yuv_sw_c.h"
+
+
+/* The colorspace conversion functions */
+
+#if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
+extern void Color565DitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod);
+extern void ColorRGBDitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod);
+#endif
+
+static void
+Color16DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned short *row1;
+    unsigned short *row2;
+    unsigned char *lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row1 = (unsigned short *) out;
+    row2 = row1 + cols + mod;
+    lum2 = lum + cols;
+
+    mod += cols + mod;
+
+    y = rows / 2;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            ++cr;
+            ++cb;
+
+            L = *lum++;
+            *row1++ = (unsigned short) (rgb_2_pix[L + cr_r] |
+                                        rgb_2_pix[L + crb_g] |
+                                        rgb_2_pix[L + cb_b]);
+
+            L = *lum++;
+            *row1++ = (unsigned short) (rgb_2_pix[L + cr_r] |
+                                        rgb_2_pix[L + crb_g] |
+                                        rgb_2_pix[L + cb_b]);
+
+
+            /* Now, do second row.  */
+
+            L = *lum2++;
+            *row2++ = (unsigned short) (rgb_2_pix[L + cr_r] |
+                                        rgb_2_pix[L + crb_g] |
+                                        rgb_2_pix[L + cb_b]);
+
+            L = *lum2++;
+            *row2++ = (unsigned short) (rgb_2_pix[L + cr_r] |
+                                        rgb_2_pix[L + crb_g] |
+                                        rgb_2_pix[L + cb_b]);
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+static void
+Color24DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned int value;
+    unsigned char *row1;
+    unsigned char *row2;
+    unsigned char *lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row1 = out;
+    row2 = row1 + cols * 3 + mod * 3;
+    lum2 = lum + cols;
+
+    mod += cols + mod;
+    mod *= 3;
+
+    y = rows / 2;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            ++cr;
+            ++cb;
+
+            L = *lum++;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            *row1++ = (value) & 0xFF;
+            *row1++ = (value >> 8) & 0xFF;
+            *row1++ = (value >> 16) & 0xFF;
+
+            L = *lum++;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            *row1++ = (value) & 0xFF;
+            *row1++ = (value >> 8) & 0xFF;
+            *row1++ = (value >> 16) & 0xFF;
+
+
+            /* Now, do second row.  */
+
+            L = *lum2++;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            *row2++ = (value) & 0xFF;
+            *row2++ = (value >> 8) & 0xFF;
+            *row2++ = (value >> 16) & 0xFF;
+
+            L = *lum2++;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            *row2++ = (value) & 0xFF;
+            *row2++ = (value >> 8) & 0xFF;
+            *row2++ = (value >> 16) & 0xFF;
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+static void
+Color32DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned int *row1;
+    unsigned int *row2;
+    unsigned char *lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row1 = (unsigned int *) out;
+    row2 = row1 + cols + mod;
+    lum2 = lum + cols;
+
+    mod += cols + mod;
+
+    y = rows / 2;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            ++cr;
+            ++cb;
+
+            L = *lum++;
+            *row1++ = (rgb_2_pix[L + cr_r] |
+                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+
+            L = *lum++;
+            *row1++ = (rgb_2_pix[L + cr_r] |
+                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+
+
+            /* Now, do second row.  */
+
+            L = *lum2++;
+            *row2++ = (rgb_2_pix[L + cr_r] |
+                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+
+            L = *lum2++;
+            *row2++ = (rgb_2_pix[L + cr_r] |
+                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+/*
+ * In this function I make use of a nasty trick. The tables have the lower
+ * 16 bits replicated in the upper 16. This means I can write ints and get
+ * the horisontal doubling for free (almost).
+ */
+static void
+Color16DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned int *row1 = (unsigned int *) out;
+    const int next_row = cols + (mod / 2);
+    unsigned int *row2 = row1 + 2 * next_row;
+    unsigned char *lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    lum2 = lum + cols;
+
+    mod = (next_row * 3) + (mod / 2);
+
+    y = rows / 2;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            ++cr;
+            ++cb;
+
+            L = *lum++;
+            row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] |
+                                        rgb_2_pix[L + crb_g] |
+                                        rgb_2_pix[L + cb_b]);
+            row1++;
+
+            L = *lum++;
+            row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] |
+                                        rgb_2_pix[L + crb_g] |
+                                        rgb_2_pix[L + cb_b]);
+            row1++;
+
+
+            /* Now, do second row. */
+
+            L = *lum2++;
+            row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] |
+                                        rgb_2_pix[L + crb_g] |
+                                        rgb_2_pix[L + cb_b]);
+            row2++;
+
+            L = *lum2++;
+            row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] |
+                                        rgb_2_pix[L + crb_g] |
+                                        rgb_2_pix[L + cb_b]);
+            row2++;
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+static void
+Color24DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned int value;
+    unsigned char *row1 = out;
+    const int next_row = (cols * 2 + mod) * 3;
+    unsigned char *row2 = row1 + 2 * next_row;
+    unsigned char *lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    lum2 = lum + cols;
+
+    mod = next_row * 3 + mod * 3;
+
+    y = rows / 2;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            ++cr;
+            ++cb;
+
+            L = *lum++;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] =
+                row1[next_row + 3 + 0] = (value) & 0xFF;
+            row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] =
+                row1[next_row + 3 + 1] = (value >> 8) & 0xFF;
+            row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] =
+                row1[next_row + 3 + 2] = (value >> 16) & 0xFF;
+            row1 += 2 * 3;
+
+            L = *lum++;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] =
+                row1[next_row + 3 + 0] = (value) & 0xFF;
+            row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] =
+                row1[next_row + 3 + 1] = (value >> 8) & 0xFF;
+            row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] =
+                row1[next_row + 3 + 2] = (value >> 16) & 0xFF;
+            row1 += 2 * 3;
+
+
+            /* Now, do second row. */
+
+            L = *lum2++;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] =
+                row2[next_row + 3 + 0] = (value) & 0xFF;
+            row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] =
+                row2[next_row + 3 + 1] = (value >> 8) & 0xFF;
+            row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] =
+                row2[next_row + 3 + 2] = (value >> 16) & 0xFF;
+            row2 += 2 * 3;
+
+            L = *lum2++;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] =
+                row2[next_row + 3 + 0] = (value) & 0xFF;
+            row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] =
+                row2[next_row + 3 + 1] = (value >> 8) & 0xFF;
+            row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] =
+                row2[next_row + 3 + 2] = (value >> 16) & 0xFF;
+            row2 += 2 * 3;
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+static void
+Color32DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned int *row1 = (unsigned int *) out;
+    const int next_row = cols * 2 + mod;
+    unsigned int *row2 = row1 + 2 * next_row;
+    unsigned char *lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    lum2 = lum + cols;
+
+    mod = (next_row * 3) + mod;
+
+    y = rows / 2;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            ++cr;
+            ++cb;
+
+            L = *lum++;
+            row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] =
+                (rgb_2_pix[L + cr_r] |
+                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row1 += 2;
+
+            L = *lum++;
+            row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] =
+                (rgb_2_pix[L + cr_r] |
+                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row1 += 2;
+
+
+            /* Now, do second row. */
+
+            L = *lum2++;
+            row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] =
+                (rgb_2_pix[L + cr_r] |
+                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row2 += 2;
+
+            L = *lum2++;
+            row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] =
+                (rgb_2_pix[L + cr_r] |
+                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row2 += 2;
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+static void
+Color16DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned short *row;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row = (unsigned short *) out;
+
+    y = rows;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            cr += 4;
+            cb += 4;
+
+            L = *lum;
+            lum += 2;
+            *row++ = (unsigned short) (rgb_2_pix[L + cr_r] |
+                                       rgb_2_pix[L + crb_g] |
+                                       rgb_2_pix[L + cb_b]);
+
+            L = *lum;
+            lum += 2;
+            *row++ = (unsigned short) (rgb_2_pix[L + cr_r] |
+                                       rgb_2_pix[L + crb_g] |
+                                       rgb_2_pix[L + cb_b]);
+
+        }
+
+        row += mod;
+    }
+}
+
+static void
+Color24DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned int value;
+    unsigned char *row;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row = (unsigned char *) out;
+    mod *= 3;
+    y = rows;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            cr += 4;
+            cb += 4;
+
+            L = *lum;
+            lum += 2;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            *row++ = (value) & 0xFF;
+            *row++ = (value >> 8) & 0xFF;
+            *row++ = (value >> 16) & 0xFF;
+
+            L = *lum;
+            lum += 2;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            *row++ = (value) & 0xFF;
+            *row++ = (value >> 8) & 0xFF;
+            *row++ = (value >> 16) & 0xFF;
+
+        }
+        row += mod;
+    }
+}
+
+static void
+Color32DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned int *row;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row = (unsigned int *) out;
+    y = rows;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            cr += 4;
+            cb += 4;
+
+            L = *lum;
+            lum += 2;
+            *row++ = (rgb_2_pix[L + cr_r] |
+                      rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+
+            L = *lum;
+            lum += 2;
+            *row++ = (rgb_2_pix[L + cr_r] |
+                      rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+
+
+        }
+        row += mod;
+    }
+}
+
+/*
+ * In this function I make use of a nasty trick. The tables have the lower
+ * 16 bits replicated in the upper 16. This means I can write ints and get
+ * the horisontal doubling for free (almost).
+ */
+static void
+Color16DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned int *row = (unsigned int *) out;
+    const int next_row = cols + (mod / 2);
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    y = rows;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            cr += 4;
+            cb += 4;
+
+            L = *lum;
+            lum += 2;
+            row[0] = row[next_row] = (rgb_2_pix[L + cr_r] |
+                                      rgb_2_pix[L + crb_g] |
+                                      rgb_2_pix[L + cb_b]);
+            row++;
+
+            L = *lum;
+            lum += 2;
+            row[0] = row[next_row] = (rgb_2_pix[L + cr_r] |
+                                      rgb_2_pix[L + crb_g] |
+                                      rgb_2_pix[L + cb_b]);
+            row++;
+
+        }
+        row += next_row;
+    }
+}
+
+static void
+Color24DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned int value;
+    unsigned char *row = out;
+    const int next_row = (cols * 2 + mod) * 3;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+    y = rows;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            cr += 4;
+            cb += 4;
+
+            L = *lum;
+            lum += 2;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row[0 + 0] = row[3 + 0] = row[next_row + 0] =
+                row[next_row + 3 + 0] = (value) & 0xFF;
+            row[0 + 1] = row[3 + 1] = row[next_row + 1] =
+                row[next_row + 3 + 1] = (value >> 8) & 0xFF;
+            row[0 + 2] = row[3 + 2] = row[next_row + 2] =
+                row[next_row + 3 + 2] = (value >> 16) & 0xFF;
+            row += 2 * 3;
+
+            L = *lum;
+            lum += 2;
+            value = (rgb_2_pix[L + cr_r] |
+                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row[0 + 0] = row[3 + 0] = row[next_row + 0] =
+                row[next_row + 3 + 0] = (value) & 0xFF;
+            row[0 + 1] = row[3 + 1] = row[next_row + 1] =
+                row[next_row + 3 + 1] = (value >> 8) & 0xFF;
+            row[0 + 2] = row[3 + 2] = row[next_row + 2] =
+                row[next_row + 3 + 2] = (value >> 16) & 0xFF;
+            row += 2 * 3;
+
+        }
+        row += next_row;
+    }
+}
+
+static void
+Color32DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod)
+{
+    unsigned int *row = (unsigned int *) out;
+    const int next_row = cols * 2 + mod;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+    mod += mod;
+    y = rows;
+    while (y--) {
+        x = cols_2;
+        while (x--) {
+            register int L;
+
+            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
+            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
+                + colortab[*cb + 2 * 256];
+            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
+            cr += 4;
+            cb += 4;
+
+            L = *lum;
+            lum += 2;
+            row[0] = row[1] = row[next_row] = row[next_row + 1] =
+                (rgb_2_pix[L + cr_r] |
+                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row += 2;
+
+            L = *lum;
+            lum += 2;
+            row[0] = row[1] = row[next_row] = row[next_row + 1] =
+                (rgb_2_pix[L + cr_r] |
+                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
+            row += 2;
+
+
+        }
+
+        row += next_row;
+    }
+}
+
+/*
+ * How many 1 bits are there in the Uint32.
+ * Low performance, do not call often.
+ */
+static int
+number_of_bits_set(Uint32 a)
+{
+    if (!a)
+        return 0;
+    if (a & 1)
+        return 1 + number_of_bits_set(a >> 1);
+    return (number_of_bits_set(a >> 1));
+}
+
+/*
+ * How many 0 bits are there at least significant end of Uint32.
+ * Low performance, do not call often.
+ */
+static int
+free_bits_at_bottom(Uint32 a)
+{
+    /* assume char is 8 bits */
+    if (!a)
+        return sizeof(Uint32) * 8;
+    if (((Sint32) a) & 1l)
+        return 0;
+    return 1 + free_bits_at_bottom(a >> 1);
+}
+
+static int
+SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format)
+{
+    Uint32 *r_2_pix_alloc;
+    Uint32 *g_2_pix_alloc;
+    Uint32 *b_2_pix_alloc;
+    int i;
+    int bpp;
+    Uint32 Rmask, Gmask, Bmask, Amask;
+
+    if (!SDL_PixelFormatEnumToMasks
+        (target_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask) || bpp < 15) {
+        SDL_SetError("Unsupported YUV destination format");
+        return -1;
+    }
+
+    swdata->target_format = target_format;
+    r_2_pix_alloc = &swdata->rgb_2_pix[0 * 768];
+    g_2_pix_alloc = &swdata->rgb_2_pix[1 * 768];
+    b_2_pix_alloc = &swdata->rgb_2_pix[2 * 768];
+
+    /* 
+     * Set up entries 0-255 in rgb-to-pixel value tables.
+     */
+    for (i = 0; i < 256; ++i) {
+        r_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Rmask));
+        r_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Rmask);
+        r_2_pix_alloc[i + 256] |= Amask;
+        g_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Gmask));
+        g_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Gmask);
+        g_2_pix_alloc[i + 256] |= Amask;
+        b_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Bmask));
+        b_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Bmask);
+        b_2_pix_alloc[i + 256] |= Amask;
+    }
+
+    /*
+     * If we have 16-bit output depth, then we double the value
+     * in the top word. This means that we can write out both
+     * pixels in the pixel doubling mode with one op. It is 
+     * harmless in the normal case as storing a 32-bit value
+     * through a short pointer will lose the top bits anyway.
+     */
+    if (SDL_BYTESPERPIXEL(target_format) == 2) {
+        for (i = 0; i < 256; ++i) {
+            r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 16;
+            g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 16;
+            b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 16;
+        }
+    }
+
+    /*
+     * Spread out the values we have to the rest of the array so that
+     * we do not need to check for overflow.
+     */
+    for (i = 0; i < 256; ++i) {
+        r_2_pix_alloc[i] = r_2_pix_alloc[256];
+        r_2_pix_alloc[i + 512] = r_2_pix_alloc[511];
+        g_2_pix_alloc[i] = g_2_pix_alloc[256];
+        g_2_pix_alloc[i + 512] = g_2_pix_alloc[511];
+        b_2_pix_alloc[i] = b_2_pix_alloc[256];
+        b_2_pix_alloc[i + 512] = b_2_pix_alloc[511];
+    }
+
+    /* You have chosen wisely... */
+    switch (swdata->format) {
+    case SDL_PIXELFORMAT_YV12:
+    case SDL_PIXELFORMAT_IYUV:
+        if (SDL_BYTESPERPIXEL(target_format) == 2) {
+#if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
+            /* inline assembly functions */
+            if (SDL_HasMMX() && (Rmask == 0xF800) &&
+                (Gmask == 0x07E0) && (Bmask == 0x001F)
+                && (swdata->w & 15) == 0) {
+/*printf("Using MMX 16-bit 565 dither\n");*/
+                swdata->Display1X = Color565DitherYV12MMX1X;
+            } else {
+/*printf("Using C 16-bit dither\n");*/
+                swdata->Display1X = Color16DitherYV12Mod1X;
+            }
+#else
+            swdata->Display1X = Color16DitherYV12Mod1X;
+#endif
+            swdata->Display2X = Color16DitherYV12Mod2X;
+        }
+        if (SDL_BYTESPERPIXEL(target_format) == 3) {
+            swdata->Display1X = Color24DitherYV12Mod1X;
+            swdata->Display2X = Color24DitherYV12Mod2X;
+        }
+        if (SDL_BYTESPERPIXEL(target_format) == 4) {
+#if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
+            /* inline assembly functions */
+            if (SDL_HasMMX() && (Rmask == 0x00FF0000) &&
+                (Gmask == 0x0000FF00) &&
+                (Bmask == 0x000000FF) && (swdata->w & 15) == 0) {
+/*printf("Using MMX 32-bit dither\n");*/
+                swdata->Display1X = ColorRGBDitherYV12MMX1X;
+            } else {
+/*printf("Using C 32-bit dither\n");*/
+                swdata->Display1X = Color32DitherYV12Mod1X;
+            }
+#else
+            swdata->Display1X = Color32DitherYV12Mod1X;
+#endif
+            swdata->Display2X = Color32DitherYV12Mod2X;
+        }
+        break;
+    case SDL_PIXELFORMAT_YUY2:
+    case SDL_PIXELFORMAT_UYVY:
+    case SDL_PIXELFORMAT_YVYU:
+        if (SDL_BYTESPERPIXEL(target_format) == 2) {
+            swdata->Display1X = Color16DitherYUY2Mod1X;
+            swdata->Display2X = Color16DitherYUY2Mod2X;
+        }
+        if (SDL_BYTESPERPIXEL(target_format) == 3) {
+            swdata->Display1X = Color24DitherYUY2Mod1X;
+            swdata->Display2X = Color24DitherYUY2Mod2X;
+        }
+        if (SDL_BYTESPERPIXEL(target_format) == 4) {
+            swdata->Display1X = Color32DitherYUY2Mod1X;
+            swdata->Display2X = Color32DitherYUY2Mod2X;
+        }
+        break;
+    default:
+        /* We should never get here (caught above) */
+        break;
+    }
+
+    if (swdata->display) {
+        SDL_FreeSurface(swdata->display);
+        swdata->display = NULL;
+    }
+    return 0;
+}
+
+SDL_SW_YUVTexture *
+SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
+{
+    SDL_SW_YUVTexture *swdata;
+    int *Cr_r_tab;
+    int *Cr_g_tab;
+    int *Cb_g_tab;
+    int *Cb_b_tab;
+    int i;
+    int CR, CB;
+
+    swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata));
+    if (!swdata) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    switch (format) {
+    case SDL_PIXELFORMAT_YV12:
+    case SDL_PIXELFORMAT_IYUV:
+    case SDL_PIXELFORMAT_YUY2:
+    case SDL_PIXELFORMAT_UYVY:
+    case SDL_PIXELFORMAT_YVYU:
+        break;
+    default:
+        SDL_SetError("Unsupported YUV format");
+        return NULL;
+    }
+
+    swdata->format = format;
+    swdata->target_format = SDL_PIXELFORMAT_UNKNOWN;
+    swdata->w = w;
+    swdata->h = h;
+    swdata->pixels = (Uint8 *) SDL_malloc(w * h * 2);
+    swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int));
+    swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32));
+    if (!swdata->pixels || !swdata->colortab || !swdata->rgb_2_pix) {
+        SDL_OutOfMemory();
+        SDL_SW_DestroyYUVTexture(swdata);
+        return NULL;
+    }
+
+    /* Generate the tables for the display surface */
+    Cr_r_tab = &swdata->colortab[0 * 256];
+    Cr_g_tab = &swdata->colortab[1 * 256];
+    Cb_g_tab = &swdata->colortab[2 * 256];
+    Cb_b_tab = &swdata->colortab[3 * 256];
+    for (i = 0; i < 256; i++) {
+        /* Gamma correction (luminescence table) and chroma correction
+           would be done here.  See the Berkeley mpeg_play sources.
+         */
+        CB = CR = (i - 128);
+        Cr_r_tab[i] = (int) ((0.419 / 0.299) * CR);
+        Cr_g_tab[i] = (int) (-(0.299 / 0.419) * CR);
+        Cb_g_tab[i] = (int) (-(0.114 / 0.331) * CB);
+        Cb_b_tab[i] = (int) ((0.587 / 0.331) * CB);
+    }
+
+    /* Find the pitch and offset values for the overlay */
+    switch (format) {
+    case SDL_PIXELFORMAT_YV12:
+    case SDL_PIXELFORMAT_IYUV:
+        swdata->pitches[0] = w;
+        swdata->pitches[1] = swdata->pitches[0] / 2;
+        swdata->pitches[2] = swdata->pitches[0] / 2;
+        swdata->planes[0] = swdata->pixels;
+        swdata->planes[1] = swdata->planes[0] + swdata->pitches[0] * h;
+        swdata->planes[2] = swdata->planes[1] + swdata->pitches[1] * h / 2;
+        break;
+    case SDL_PIXELFORMAT_YUY2:
+    case SDL_PIXELFORMAT_UYVY:
+    case SDL_PIXELFORMAT_YVYU:
+        swdata->pitches[0] = w * 2;
+        swdata->planes[0] = swdata->pixels;
+        break;
+    default:
+        /* We should never get here (caught above) */
+        break;
+    }
+
+    /* We're all done.. */
+    return (swdata);
+}
+
+int
+SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels,
+                             int *pitch)
+{
+    *pixels = swdata->planes[0];
+    *pitch = swdata->pitches[0];
+    return 0;
+}
+
+int
+SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
+                        const void *pixels, int pitch)
+{
+    switch (swdata->format) {
+    case SDL_PIXELFORMAT_YV12:
+    case SDL_PIXELFORMAT_IYUV:
+        if (rect
+            && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w
+                || rect->h != swdata->h)) {
+            SDL_SetError
+                ("YV12 and IYUV textures only support full surface updates");
+            return -1;
+        }
+        SDL_memcpy(swdata->pixels, pixels, swdata->h * swdata->w * 2);
+        break;
+    case SDL_PIXELFORMAT_YUY2:
+    case SDL_PIXELFORMAT_UYVY:
+    case SDL_PIXELFORMAT_YVYU:
+        {
+            Uint8 *src, *dst;
+            int row;
+            size_t length;
+
+            src = (Uint8 *) pixels;
+            dst =
+                swdata->planes[0] + rect->y * swdata->pitches[0] +
+                rect->x * 2;
+            length = rect->w * 2;
+            for (row = 0; row < rect->h; ++row) {
+                SDL_memcpy(dst, src, length);
+                src += pitch;
+                dst += swdata->pitches[0];
+            }
+        }
+        break;
+    }
+    return 0;
+}
+
+int
+SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
+                      void **pixels, int *pitch)
+{
+    switch (swdata->format) {
+    case SDL_PIXELFORMAT_YV12:
+    case SDL_PIXELFORMAT_IYUV:
+        if (rect
+            && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w
+                || rect->h != swdata->h)) {
+            SDL_SetError
+                ("YV12 and IYUV textures only support full surface locks");
+            return -1;
+        }
+        break;
+    }
+
+    *pixels = swdata->planes[0] + rect->y * swdata->pitches[0] + rect->x * 2;
+    *pitch = swdata->pitches[0];
+    return 0;
+}
+
+void
+SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata)
+{
+}
+
+int
+SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
+                    Uint32 target_format, int w, int h, void *pixels,
+                    int pitch)
+{
+    int stretch;
+    int scale_2x;
+    Uint8 *lum, *Cr, *Cb;
+    int mod;
+
+    /* Make sure we're set up to display in the desired format */
+    if (target_format != swdata->target_format) {
+        if (SDL_SW_SetupYUVDisplay(swdata, target_format) < 0) {
+            return -1;
+        }
+    }
+
+    stretch = 0;
+    scale_2x = 0;
+    if (srcrect->x || srcrect->y || srcrect->w < swdata->w
+        || srcrect->h < swdata->h) {
+        /* The source rectangle has been clipped.
+           Using a scratch surface is easier than adding clipped
+           source support to all the blitters, plus that would
+           slow them down in the general unclipped case.
+         */
+        stretch = 1;
+    } else if ((srcrect->w != w) || (srcrect->h != h)) {
+        if ((w == 2 * srcrect->w) && (h == 2 * srcrect->h)) {
+            scale_2x = 1;
+        } else {
+            stretch = 1;
+        }
+    }
+    if (stretch) {
+        int bpp;
+        Uint32 Rmask, Gmask, Bmask, Amask;
+
+        if (swdata->display) {
+            swdata->display->w = w;
+            swdata->display->h = h;
+            swdata->display->pixels = pixels;
+            swdata->display->pitch = pitch;
+        } else {
+            /* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */
+            SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask,
+                                       &Bmask, &Amask);
+            swdata->display =
+                SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask,
+                                         Gmask, Bmask, Amask);
+            if (!swdata->display) {
+                return (-1);
+            }
+        }
+        if (!swdata->stretch) {
+            /* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */
+            SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask,
+                                       &Bmask, &Amask);
+            swdata->stretch =
+                SDL_CreateRGBSurface(0, swdata->w, swdata->h, bpp, Rmask,
+                                     Gmask, Bmask, Amask);
+            if (!swdata->stretch) {
+                return (-1);
+            }
+        }
+        pixels = swdata->stretch->pixels;
+        pitch = swdata->stretch->pitch;
+    }
+    switch (swdata->format) {
+    case SDL_PIXELFORMAT_YV12:
+        lum = swdata->planes[0];
+        Cr = swdata->planes[1];
+        Cb = swdata->planes[2];
+        break;
+    case SDL_PIXELFORMAT_IYUV:
+        lum = swdata->planes[0];
+        Cr = swdata->planes[2];
+        Cb = swdata->planes[1];
+        break;
+    case SDL_PIXELFORMAT_YUY2:
+        lum = swdata->planes[0];
+        Cr = lum + 3;
+        Cb = lum + 1;
+        break;
+    case SDL_PIXELFORMAT_UYVY:
+        lum = swdata->planes[0] + 1;
+        Cr = lum + 1;
+        Cb = lum - 1;
+        break;
+    case SDL_PIXELFORMAT_YVYU:
+        lum = swdata->planes[0];
+        Cr = lum + 1;
+        Cb = lum + 3;
+        break;
+    default:
+        SDL_SetError("Unsupported YUV format in copy");
+        return (-1);
+    }
+    mod = (pitch / SDL_BYTESPERPIXEL(target_format));
+
+    if (scale_2x) {
+        mod -= (swdata->w * 2);
+        swdata->Display2X(swdata->colortab, swdata->rgb_2_pix,
+                          lum, Cr, Cb, pixels, swdata->h, swdata->w, mod);
+    } else {
+        mod -= swdata->w;
+        swdata->Display1X(swdata->colortab, swdata->rgb_2_pix,
+                          lum, Cr, Cb, pixels, swdata->h, swdata->w, mod);
+    }
+    if (stretch) {
+        SDL_Rect rect = *srcrect;
+        SDL_SoftStretch(swdata->stretch, &rect, swdata->display, NULL);
+    }
+    return 0;
+}
+
+void
+SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata)
+{
+    if (swdata) {
+        if (swdata->pixels) {
+            SDL_free(swdata->pixels);
+        }
+        if (swdata->colortab) {
+            SDL_free(swdata->colortab);
+        }
+        if (swdata->rgb_2_pix) {
+            SDL_free(swdata->rgb_2_pix);
+        }
+        if (swdata->stretch) {
+            SDL_FreeSurface(swdata->stretch);
+        }
+        if (swdata->display) {
+            SDL_FreeSurface(swdata->display);
+        }
+        SDL_free(swdata);
+    }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/SDL_yuv_sw_c.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,69 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_video.h"
+
+/* This is the software implementation of the YUV texture support */
+
+struct SDL_SW_YUVTexture
+{
+    Uint32 format;
+    Uint32 target_format;
+    int w, h;
+    Uint8 *pixels;
+    int *colortab;
+    Uint32 *rgb_2_pix;
+    void (*Display1X) (int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod);
+    void (*Display2X) (int *colortab, Uint32 * rgb_2_pix,
+                       unsigned char *lum, unsigned char *cr,
+                       unsigned char *cb, unsigned char *out,
+                       int rows, int cols, int mod);
+
+    /* These are just so we don't have to allocate them separately */
+    Uint16 pitches[3];
+    Uint8 *planes[3];
+
+    /* This is a temporary surface in case we have to stretch copy */
+    SDL_Surface *stretch;
+    SDL_Surface *display;
+};
+
+typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture;
+
+SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h);
+int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels,
+                                 int *pitch);
+int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
+                            const void *pixels, int pitch);
+int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
+                          void **pixels, int *pitch);
+void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata);
+int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
+                        Uint32 target_format, int w, int h, void *pixels,
+                        int pitch);
+void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata);
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/direct3d/SDL_render_d3d.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,1048 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#if SDL_VIDEO_RENDER_D3D
+
+#include "../../core/windows/SDL_windows.h"
+
+#include "SDL_loadso.h"
+#include "SDL_syswm.h"
+#include "../SDL_sysrender.h"
+
+#if SDL_VIDEO_RENDER_D3D
+#define D3D_DEBUG_INFO
+#include <d3d9.h>
+#endif
+
+#ifdef ASSEMBLE_SHADER
+///////////////////////////////////////////////////////////////////////////
+// ID3DXBuffer:
+// ------------
+// The buffer object is used by D3DX to return arbitrary size data.
+//
+// GetBufferPointer -
+//    Returns a pointer to the beginning of the buffer.
+//
+// GetBufferSize -
+//    Returns the size of the buffer, in bytes.
+///////////////////////////////////////////////////////////////////////////
+
+typedef interface ID3DXBuffer ID3DXBuffer;
+typedef interface ID3DXBuffer *LPD3DXBUFFER;
+
+// {8BA5FB08-5195-40e2-AC58-0D989C3A0102}
+DEFINE_GUID(IID_ID3DXBuffer, 
+0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2);
+
+#undef INTERFACE
+#define INTERFACE ID3DXBuffer
+
+typedef interface ID3DXBuffer {
+    const struct ID3DXBufferVtbl FAR* lpVtbl;
+} ID3DXBuffer;
+typedef const struct ID3DXBufferVtbl ID3DXBufferVtbl;
+const struct ID3DXBufferVtbl
+{
+    // IUnknown
+    STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
+    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG, Release)(THIS) PURE;
+
+    // ID3DXBuffer
+    STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE;
+    STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE;
+};
+
+HRESULT WINAPI
+    D3DXAssembleShader(
+        LPCSTR                          pSrcData,
+        UINT                            SrcDataLen,
+        CONST LPVOID*                   pDefines,
+        LPVOID                          pInclude,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs);
+
+#endif /* ASSEMBLE_SHADER */
+
+
+/* Direct3D renderer implementation */
+
+static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags);
+static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                             const SDL_Rect * rect, const void *pixels,
+                             int pitch);
+static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                           const SDL_Rect * rect, void **pixels, int *pitch);
+static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int D3D_RenderDrawPoints(SDL_Renderer * renderer,
+                                const SDL_Point * points, int count);
+static int D3D_RenderDrawLines(SDL_Renderer * renderer,
+                               const SDL_Point * points, int count);
+static int D3D_RenderFillRects(SDL_Renderer * renderer,
+                               const SDL_Rect ** rects, int count);
+static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+                          const SDL_Rect * srcrect, const SDL_Rect * dstrect);
+static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                                Uint32 format, void * pixels, int pitch);
+static void D3D_RenderPresent(SDL_Renderer * renderer);
+static void D3D_DestroyTexture(SDL_Renderer * renderer,
+                               SDL_Texture * texture);
+static void D3D_DestroyRenderer(SDL_Renderer * renderer);
+
+
+SDL_RenderDriver D3D_RenderDriver = {
+    D3D_CreateRenderer,
+    {
+     "direct3d",
+     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
+     1,
+     {SDL_PIXELFORMAT_ARGB8888},
+     0,
+     0}
+};
+
+typedef struct
+{
+    void* d3dDLL;
+    IDirect3D9 *d3d;
+    IDirect3DDevice9 *device;
+    UINT adapter;
+    D3DPRESENT_PARAMETERS pparams;
+    SDL_bool beginScene;
+} D3D_RenderData;
+
+typedef struct
+{
+    IDirect3DTexture9 *texture;
+} D3D_TextureData;
+
+typedef struct
+{
+    float x, y, z;
+    float rhw;
+    DWORD color;
+    float u, v;
+} Vertex;
+
+static void
+D3D_SetError(const char *prefix, HRESULT result)
+{
+    const char *error;
+
+    switch (result) {
+    case D3DERR_WRONGTEXTUREFORMAT:
+        error = "WRONGTEXTUREFORMAT";
+        break;
+    case D3DERR_UNSUPPORTEDCOLOROPERATION:
+        error = "UNSUPPORTEDCOLOROPERATION";
+        break;
+    case D3DERR_UNSUPPORTEDCOLORARG:
+        error = "UNSUPPORTEDCOLORARG";
+        break;
+    case D3DERR_UNSUPPORTEDALPHAOPERATION:
+        error = "UNSUPPORTEDALPHAOPERATION";
+        break;
+    case D3DERR_UNSUPPORTEDALPHAARG:
+        error = "UNSUPPORTEDALPHAARG";
+        break;
+    case D3DERR_TOOMANYOPERATIONS:
+        error = "TOOMANYOPERATIONS";
+        break;
+    case D3DERR_CONFLICTINGTEXTUREFILTER:
+        error = "CONFLICTINGTEXTUREFILTER";
+        break;
+    case D3DERR_UNSUPPORTEDFACTORVALUE:
+        error = "UNSUPPORTEDFACTORVALUE";
+        break;
+    case D3DERR_CONFLICTINGRENDERSTATE:
+        error = "CONFLICTINGRENDERSTATE";
+        break;
+    case D3DERR_UNSUPPORTEDTEXTUREFILTER:
+        error = "UNSUPPORTEDTEXTUREFILTER";
+        break;
+    case D3DERR_CONFLICTINGTEXTUREPALETTE:
+        error = "CONFLICTINGTEXTUREPALETTE";
+        break;
+    case D3DERR_DRIVERINTERNALERROR:
+        error = "DRIVERINTERNALERROR";
+        break;
+    case D3DERR_NOTFOUND:
+        error = "NOTFOUND";
+        break;
+    case D3DERR_MOREDATA:
+        error = "MOREDATA";
+        break;
+    case D3DERR_DEVICELOST:
+        error = "DEVICELOST";
+        break;
+    case D3DERR_DEVICENOTRESET:
+        error = "DEVICENOTRESET";
+        break;
+    case D3DERR_NOTAVAILABLE:
+        error = "NOTAVAILABLE";
+        break;
+    case D3DERR_OUTOFVIDEOMEMORY:
+        error = "OUTOFVIDEOMEMORY";
+        break;
+    case D3DERR_INVALIDDEVICE:
+        error = "INVALIDDEVICE";
+        break;
+    case D3DERR_INVALIDCALL:
+        error = "INVALIDCALL";
+        break;
+    case D3DERR_DRIVERINVALIDCALL:
+        error = "DRIVERINVALIDCALL";
+        break;
+    case D3DERR_WASSTILLDRAWING:
+        error = "WASSTILLDRAWING";
+        break;
+    default:
+        error = "UNKNOWN";
+        break;
+    }
+    SDL_SetError("%s: %s", prefix, error);
+}
+
+static D3DFORMAT
+PixelFormatToD3DFMT(Uint32 format)
+{
+    switch (format) {
+    case SDL_PIXELFORMAT_RGB565:
+        return D3DFMT_R5G6B5;
+    case SDL_PIXELFORMAT_RGB888:
+        return D3DFMT_X8R8G8B8;
+    case SDL_PIXELFORMAT_ARGB8888:
+        return D3DFMT_A8R8G8B8;
+    default:
+        return D3DFMT_UNKNOWN;
+    }
+}
+
+static Uint32
+D3DFMTToPixelFormat(D3DFORMAT format)
+{
+    switch (format) {
+    case D3DFMT_R5G6B5:
+        return SDL_PIXELFORMAT_RGB565;
+    case D3DFMT_X8R8G8B8:
+        return SDL_PIXELFORMAT_RGB888;
+    case D3DFMT_A8R8G8B8:
+        return SDL_PIXELFORMAT_ARGB8888;
+    default:
+        return SDL_PIXELFORMAT_UNKNOWN;
+    }
+}
+
+SDL_Renderer *
+D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
+{
+    SDL_Renderer *renderer;
+    D3D_RenderData *data;
+    SDL_SysWMinfo windowinfo;
+    HRESULT result;
+    D3DPRESENT_PARAMETERS pparams;
+    IDirect3DSwapChain9 *chain;
+    D3DCAPS9 caps;
+    Uint32 window_flags;
+    int w, h;
+    SDL_DisplayMode fullscreen_mode;
+
+    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
+    if (!renderer) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        SDL_free(renderer);
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    data->d3dDLL = SDL_LoadObject("D3D9.DLL");
+    if (data->d3dDLL) {
+        IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);
+
+        D3DCreate =
+            (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(data->d3dDLL,
+                                                            "Direct3DCreate9");
+        if (D3DCreate) {
+            data->d3d = D3DCreate(D3D_SDK_VERSION);
+        }
+        if (!data->d3d) {
+            SDL_UnloadObject(data->d3dDLL);
+            data->d3dDLL = NULL;
+        }
+    }
+    if (!data->d3d) {
+        SDL_free(renderer);
+        SDL_free(data);
+        SDL_SetError("Unable to create Direct3D interface");
+        return NULL;
+    }
+
+    renderer->CreateTexture = D3D_CreateTexture;
+    renderer->UpdateTexture = D3D_UpdateTexture;
+    renderer->LockTexture = D3D_LockTexture;
+    renderer->UnlockTexture = D3D_UnlockTexture;
+    renderer->RenderDrawPoints = D3D_RenderDrawPoints;
+    renderer->RenderDrawLines = D3D_RenderDrawLines;
+    renderer->RenderFillRects = D3D_RenderFillRects;
+    renderer->RenderCopy = D3D_RenderCopy;
+    renderer->RenderReadPixels = D3D_RenderReadPixels;
+    renderer->RenderPresent = D3D_RenderPresent;
+    renderer->DestroyTexture = D3D_DestroyTexture;
+    renderer->DestroyRenderer = D3D_DestroyRenderer;
+    renderer->info = D3D_RenderDriver.info;
+    renderer->driverdata = data;
+
+    renderer->info.flags = SDL_RENDERER_ACCELERATED;
+
+    SDL_VERSION(&windowinfo.version);
+    SDL_GetWindowWMInfo(window, &windowinfo);
+
+    window_flags = SDL_GetWindowFlags(window);
+    SDL_GetWindowSize(window, &w, &h);
+    SDL_GetWindowDisplayMode(window, &fullscreen_mode);
+
+    SDL_zero(pparams);
+    pparams.hDeviceWindow = windowinfo.info.win.window;
+    pparams.BackBufferWidth = w;
+    pparams.BackBufferHeight = h;
+    if (window_flags & SDL_WINDOW_FULLSCREEN) {
+        pparams.BackBufferFormat =
+            PixelFormatToD3DFMT(fullscreen_mode.format);
+    } else {
+        pparams.BackBufferFormat = D3DFMT_UNKNOWN;
+    }
+    pparams.BackBufferCount = 1;
+    pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
+
+    if (window_flags & SDL_WINDOW_FULLSCREEN) {
+        pparams.Windowed = FALSE;
+        pparams.FullScreen_RefreshRateInHz =
+            fullscreen_mode.refresh_rate;
+    } else {
+        pparams.Windowed = TRUE;
+        pparams.FullScreen_RefreshRateInHz = 0;
+    }
+    if (flags & SDL_RENDERER_PRESENTVSYNC) {
+        pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+    } else {
+        pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+    }
+
+    /* FIXME: Which adapter? */
+    data->adapter = D3DADAPTER_DEFAULT;
+    IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps);
+
+    result = IDirect3D9_CreateDevice(data->d3d, data->adapter,
+                                     D3DDEVTYPE_HAL,
+                                     pparams.hDeviceWindow,
+                                     (caps.
+                                      DevCaps &
+                                      D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
+                                     D3DCREATE_HARDWARE_VERTEXPROCESSING :
+                                     D3DCREATE_SOFTWARE_VERTEXPROCESSING,
+                                     &pparams, &data->device);
+    if (FAILED(result)) {
+        D3D_DestroyRenderer(renderer);
+        D3D_SetError("CreateDevice()", result);
+        return NULL;
+    }
+    data->beginScene = SDL_TRUE;
+
+    /* Get presentation parameters to fill info */
+    result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
+    if (FAILED(result)) {
+        D3D_DestroyRenderer(renderer);
+        D3D_SetError("GetSwapChain()", result);
+        return NULL;
+    }
+    result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams);
+    if (FAILED(result)) {
+        IDirect3DSwapChain9_Release(chain);
+        D3D_DestroyRenderer(renderer);
+        D3D_SetError("GetPresentParameters()", result);
+        return NULL;
+    }
+    IDirect3DSwapChain9_Release(chain);
+    if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) {
+        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
+    }
+    data->pparams = pparams;
+
+    IDirect3DDevice9_GetDeviceCaps(data->device, &caps);
+    renderer->info.max_texture_width = caps.MaxTextureWidth;
+    renderer->info.max_texture_height = caps.MaxTextureHeight;
+
+    /* Set up parameters for rendering */
+    IDirect3DDevice9_SetVertexShader(data->device, NULL);
+    IDirect3DDevice9_SetFVF(data->device,
+                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
+    IDirect3DDevice9_SetRenderState(data->device, D3DRS_ZENABLE, D3DZB_FALSE);
+    IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
+                                    D3DCULL_NONE);
+    IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
+    /* Enable color modulation by diffuse color */
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLOROP,
+                                          D3DTOP_MODULATE);
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG1,
+                                          D3DTA_TEXTURE);
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG2,
+                                          D3DTA_DIFFUSE);
+    /* Enable alpha modulation by diffuse alpha */
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAOP,
+                                          D3DTOP_MODULATE);
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG1,
+                                          D3DTA_TEXTURE);
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG2,
+                                          D3DTA_DIFFUSE);
+    /* Disable second texture stage, since we're done */
+    IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP,
+                                          D3DTOP_DISABLE);
+    IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP,
+                                          D3DTOP_DISABLE);
+
+    return renderer;
+}
+
+static int
+D3D_Reset(SDL_Renderer * renderer)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    HRESULT result;
+
+    result = IDirect3DDevice9_Reset(data->device, &data->pparams);
+    if (FAILED(result)) {
+        if (result == D3DERR_DEVICELOST) {
+            /* Don't worry about it, we'll reset later... */
+            return 0;
+        } else {
+            D3D_SetError("Reset()", result);
+            return -1;
+        }
+    }
+    IDirect3DDevice9_SetVertexShader(data->device, NULL);
+    IDirect3DDevice9_SetFVF(data->device,
+                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
+    IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
+                                    D3DCULL_NONE);
+    IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
+    return 0;
+}
+
+/* FIXME: This needs to be called... when? */
+#if 0
+static int
+D3D_DisplayModeChanged(SDL_Renderer * renderer)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+    SDL_VideoDisplay *display = window->display;
+
+    data->pparams.BackBufferWidth = window->w;
+    data->pparams.BackBufferHeight = window->h;
+    if (window->flags & SDL_WINDOW_FULLSCREEN) {
+        data->pparams.BackBufferFormat =
+            PixelFormatToD3DFMT(window->fullscreen_mode.format);
+    } else {
+        data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
+    }
+    return D3D_Reset(renderer);
+}
+#endif
+
+static int
+D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+    D3DFORMAT display_format = renderdata->pparams.BackBufferFormat;
+    D3D_TextureData *data;
+    D3DPOOL pool;
+    DWORD usage;
+    HRESULT result;
+
+    data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+
+    texture->driverdata = data;
+
+#ifdef USE_DYNAMIC_TEXTURE
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
+        pool = D3DPOOL_DEFAULT;
+        usage = D3DUSAGE_DYNAMIC;
+    } else
+#endif
+    {
+        pool = D3DPOOL_MANAGED;
+        usage = 0;
+    }
+
+    result =
+        IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
+                                       texture->h, 1, usage,
+                                       PixelFormatToD3DFMT(texture->format),
+                                       pool, &data->texture, NULL);
+    if (FAILED(result)) {
+        D3D_SetError("CreateTexture()", result);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int
+D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                  const SDL_Rect * rect, const void *pixels, int pitch)
+{
+    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
+    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
+    RECT d3drect;
+    D3DLOCKED_RECT locked;
+    const Uint8 *src;
+    Uint8 *dst;
+    int row, length;
+    HRESULT result;
+
+#ifdef USE_DYNAMIC_TEXTURE
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING &&
+        rect->x == 0 && rect->y == 0 &&
+        rect->w == texture->w && rect->h == texture->h) {
+        result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, NULL, D3DLOCK_DISCARD);
+    } else
+#endif
+    {
+        d3drect.left = rect->x;
+        d3drect.right = rect->x + rect->w;
+        d3drect.top = rect->y;
+        d3drect.bottom = rect->y + rect->h;
+        result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
+    }
+
+    if (FAILED(result)) {
+        D3D_SetError("LockRect()", result);
+        return -1;
+    }
+
+    src = pixels;
+    dst = locked.pBits;
+    length = rect->w * SDL_BYTESPERPIXEL(texture->format);
+    if (length == pitch && length == locked.Pitch) {
+        SDL_memcpy(dst, src, length*rect->h);
+    } else {
+        for (row = 0; row < rect->h; ++row) {
+            SDL_memcpy(dst, src, length);
+            src += pitch;
+            dst += locked.Pitch;
+        }
+    }
+    IDirect3DTexture9_UnlockRect(data->texture, 0);
+
+    return 0;
+}
+
+static int
+D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                const SDL_Rect * rect, void **pixels, int *pitch)
+{
+    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
+    RECT d3drect;
+    D3DLOCKED_RECT locked;
+    HRESULT result;
+
+    d3drect.left = rect->x;
+    d3drect.right = rect->x + rect->w;
+    d3drect.top = rect->y;
+    d3drect.bottom = rect->y + rect->h;
+
+    result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
+    if (FAILED(result)) {
+        D3D_SetError("LockRect()", result);
+        return -1;
+    }
+    *pixels = locked.pBits;
+    *pitch = locked.Pitch;
+    return 0;
+}
+
+static void
+D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
+
+    IDirect3DTexture9_UnlockRect(data->texture, 0);
+}
+
+static void
+D3D_SetBlendMode(D3D_RenderData * data, int blendMode)
+{
+    switch (blendMode) {
+    case SDL_BLENDMODE_NONE:
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
+                                        FALSE);
+        break;
+    case SDL_BLENDMODE_BLEND:
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
+                                        TRUE);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
+                                        D3DBLEND_SRCALPHA);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
+                                        D3DBLEND_INVSRCALPHA);
+        break;
+    case SDL_BLENDMODE_ADD:
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
+                                        TRUE);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
+                                        D3DBLEND_SRCALPHA);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
+                                        D3DBLEND_ONE);
+        break;
+    case SDL_BLENDMODE_MOD:
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
+                                        TRUE);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
+                                        D3DBLEND_ZERO);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
+                                        D3DBLEND_SRCCOLOR);
+        break;
+    }
+}
+
+static int
+D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
+                     int count)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    DWORD color;
+    Vertex *vertices;
+    int i;
+    HRESULT result;
+
+    if (data->beginScene) {
+        IDirect3DDevice9_BeginScene(data->device);
+        data->beginScene = SDL_FALSE;
+    }
+
+    D3D_SetBlendMode(data, renderer->blendMode);
+
+    result =
+        IDirect3DDevice9_SetTexture(data->device, 0,
+                                    (IDirect3DBaseTexture9 *) 0);
+    if (FAILED(result)) {
+        D3D_SetError("SetTexture()", result);
+        return -1;
+    }
+
+    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
+
+    vertices = SDL_stack_alloc(Vertex, count);
+    for (i = 0; i < count; ++i) {
+        vertices[i].x = (float) points[i].x;
+        vertices[i].y = (float) points[i].y;
+        vertices[i].z = 0.0f;
+        vertices[i].rhw = 1.0f;
+        vertices[i].color = color;
+        vertices[i].u = 0.0f;
+        vertices[i].v = 0.0f;
+    }
+    result =
+        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, count,
+                                         vertices, sizeof(*vertices));
+    SDL_stack_free(vertices);
+    if (FAILED(result)) {
+        D3D_SetError("DrawPrimitiveUP()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
+                    int count)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    DWORD color;
+    Vertex *vertices;
+    int i;
+    HRESULT result;
+
+    if (data->beginScene) {
+        IDirect3DDevice9_BeginScene(data->device);
+        data->beginScene = SDL_FALSE;
+    }
+
+    D3D_SetBlendMode(data, renderer->blendMode);
+
+    result =
+        IDirect3DDevice9_SetTexture(data->device, 0,
+                                    (IDirect3DBaseTexture9 *) 0);
+    if (FAILED(result)) {
+        D3D_SetError("SetTexture()", result);
+        return -1;
+    }
+
+    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
+
+    vertices = SDL_stack_alloc(Vertex, count);
+    for (i = 0; i < count; ++i) {
+        vertices[i].x = (float) points[i].x;
+        vertices[i].y = (float) points[i].y;
+        vertices[i].z = 0.0f;
+        vertices[i].rhw = 1.0f;
+        vertices[i].color = color;
+        vertices[i].u = 0.0f;
+        vertices[i].v = 0.0f;
+    }
+    result =
+        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count-1,
+                                         vertices, sizeof(*vertices));
+
+    /* DirectX 9 has the same line rasterization semantics as GDI,
+       so we need to close the endpoint of the line */
+    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
+        vertices[0].x = (float) points[count-1].x;
+        vertices[0].y = (float) points[count-1].y;
+        result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices));
+    }
+
+    SDL_stack_free(vertices);
+    if (FAILED(result)) {
+        D3D_SetError("DrawPrimitiveUP()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
+                    int count)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    DWORD color;
+    int i;
+    float minx, miny, maxx, maxy;
+    Vertex vertices[4];
+    HRESULT result;
+
+    if (data->beginScene) {
+        IDirect3DDevice9_BeginScene(data->device);
+        data->beginScene = SDL_FALSE;
+    }
+
+    D3D_SetBlendMode(data, renderer->blendMode);
+
+    result =
+        IDirect3DDevice9_SetTexture(data->device, 0,
+                                    (IDirect3DBaseTexture9 *) 0);
+    if (FAILED(result)) {
+        D3D_SetError("SetTexture()", result);
+        return -1;
+    }
+
+    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
+
+    for (i = 0; i < count; ++i) {
+        const SDL_Rect *rect = rects[i];
+
+        minx = (float) rect->x;
+        miny = (float) rect->y;
+        maxx = (float) rect->x + rect->w;
+        maxy = (float) rect->y + rect->h;
+
+        vertices[0].x = minx;
+        vertices[0].y = miny;
+        vertices[0].z = 0.0f;
+        vertices[0].rhw = 1.0f;
+        vertices[0].color = color;
+        vertices[0].u = 0.0f;
+        vertices[0].v = 0.0f;
+
+        vertices[1].x = maxx;
+        vertices[1].y = miny;
+        vertices[1].z = 0.0f;
+        vertices[1].rhw = 1.0f;
+        vertices[1].color = color;
+        vertices[1].u = 0.0f;
+        vertices[1].v = 0.0f;
+
+        vertices[2].x = maxx;
+        vertices[2].y = maxy;
+        vertices[2].z = 0.0f;
+        vertices[2].rhw = 1.0f;
+        vertices[2].color = color;
+        vertices[2].u = 0.0f;
+        vertices[2].v = 0.0f;
+
+        vertices[3].x = minx;
+        vertices[3].y = maxy;
+        vertices[3].z = 0.0f;
+        vertices[3].rhw = 1.0f;
+        vertices[3].color = color;
+        vertices[3].u = 0.0f;
+        vertices[3].v = 0.0f;
+
+        result =
+            IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN,
+                                             2, vertices, sizeof(*vertices));
+        if (FAILED(result)) {
+            D3D_SetError("DrawPrimitiveUP()", result);
+            return -1;
+        }
+    }
+    return 0;
+}
+
+static int
+D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
+    LPDIRECT3DPIXELSHADER9 shader = NULL;
+    float minx, miny, maxx, maxy;
+    float minu, maxu, minv, maxv;
+    DWORD color;
+    Vertex vertices[4];
+    HRESULT result;
+
+    if (data->beginScene) {
+        IDirect3DDevice9_BeginScene(data->device);
+        data->beginScene = SDL_FALSE;
+    }
+
+    minx = (float) dstrect->x - 0.5f;
+    miny = (float) dstrect->y - 0.5f;
+    maxx = (float) dstrect->x + dstrect->w - 0.5f;
+    maxy = (float) dstrect->y + dstrect->h - 0.5f;
+
+    minu = (float) srcrect->x / texture->w;
+    maxu = (float) (srcrect->x + srcrect->w) / texture->w;
+    minv = (float) srcrect->y / texture->h;
+    maxv = (float) (srcrect->y + srcrect->h) / texture->h;
+
+    color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b);
+
+    vertices[0].x = minx;
+    vertices[0].y = miny;
+    vertices[0].z = 0.0f;
+    vertices[0].rhw = 1.0f;
+    vertices[0].color = color;
+    vertices[0].u = minu;
+    vertices[0].v = minv;
+
+    vertices[1].x = maxx;
+    vertices[1].y = miny;
+    vertices[1].z = 0.0f;
+    vertices[1].rhw = 1.0f;
+    vertices[1].color = color;
+    vertices[1].u = maxu;
+    vertices[1].v = minv;
+
+    vertices[2].x = maxx;
+    vertices[2].y = maxy;
+    vertices[2].z = 0.0f;
+    vertices[2].rhw = 1.0f;
+    vertices[2].color = color;
+    vertices[2].u = maxu;
+    vertices[2].v = maxv;
+
+    vertices[3].x = minx;
+    vertices[3].y = maxy;
+    vertices[3].z = 0.0f;
+    vertices[3].rhw = 1.0f;
+    vertices[3].color = color;
+    vertices[3].u = minu;
+    vertices[3].v = maxv;
+
+    D3D_SetBlendMode(data, texture->blendMode);
+
+    IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
+                                     D3DTEXF_LINEAR);
+    IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
+                                     D3DTEXF_LINEAR);
+
+    result =
+        IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *)
+                                    texturedata->texture);
+    if (FAILED(result)) {
+        D3D_SetError("SetTexture()", result);
+        return -1;
+    }
+    if (shader) {
+        result = IDirect3DDevice9_SetPixelShader(data->device, shader);
+        if (FAILED(result)) {
+            D3D_SetError("SetShader()", result);
+            return -1;
+        }
+    }
+    result =
+        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
+                                         vertices, sizeof(*vertices));
+    if (FAILED(result)) {
+        D3D_SetError("DrawPrimitiveUP()", result);
+        return -1;
+    }
+    if (shader) {
+        result = IDirect3DDevice9_SetPixelShader(data->device, NULL);
+        if (FAILED(result)) {
+            D3D_SetError("SetShader()", result);
+            return -1;
+        }
+    }
+    return 0;
+}
+
+static int
+D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                     Uint32 format, void * pixels, int pitch)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    D3DSURFACE_DESC desc;
+    LPDIRECT3DSURFACE9 backBuffer;
+    LPDIRECT3DSURFACE9 surface;
+    RECT d3drect;
+    D3DLOCKED_RECT locked;
+    HRESULT result;
+
+    result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
+    if (FAILED(result)) {
+        D3D_SetError("GetBackBuffer()", result);
+        return -1;
+    }
+
+    result = IDirect3DSurface9_GetDesc(backBuffer, &desc);
+    if (FAILED(result)) {
+        D3D_SetError("GetDesc()", result);
+        IDirect3DSurface9_Release(backBuffer);
+        return -1;
+    }
+
+    result = IDirect3DDevice9_CreateOffscreenPlainSurface(data->device, desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL);
+    if (FAILED(result)) {
+        D3D_SetError("CreateOffscreenPlainSurface()", result);
+        IDirect3DSurface9_Release(backBuffer);
+        return -1;
+    }
+
+    result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface);
+    if (FAILED(result)) {
+        D3D_SetError("GetRenderTargetData()", result);
+        IDirect3DSurface9_Release(surface);
+        IDirect3DSurface9_Release(backBuffer);
+        return -1;
+    }
+
+    d3drect.left = rect->x;
+    d3drect.right = rect->x + rect->w;
+    d3drect.top = rect->y;
+    d3drect.bottom = rect->y + rect->h;
+
+    result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
+    if (FAILED(result)) {
+        D3D_SetError("LockRect()", result);
+        IDirect3DSurface9_Release(surface);
+        IDirect3DSurface9_Release(backBuffer);
+        return -1;
+    }
+
+    SDL_ConvertPixels(rect->w, rect->h,
+                      D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch,
+                      format, pixels, pitch);
+
+    IDirect3DSurface9_UnlockRect(surface);
+
+    IDirect3DSurface9_Release(surface);
+    IDirect3DSurface9_Release(backBuffer);
+
+    return 0;
+}
+
+static void
+D3D_RenderPresent(SDL_Renderer * renderer)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    HRESULT result;
+
+    if (!data->beginScene) {
+        IDirect3DDevice9_EndScene(data->device);
+        data->beginScene = SDL_TRUE;
+    }
+
+    result = IDirect3DDevice9_TestCooperativeLevel(data->device);
+    if (result == D3DERR_DEVICELOST) {
+        /* We'll reset later */
+        return;
+    }
+    if (result == D3DERR_DEVICENOTRESET) {
+        D3D_Reset(renderer);
+    }
+    result = IDirect3DDevice9_Present(data->device, NULL, NULL, NULL, NULL);
+    if (FAILED(result)) {
+        D3D_SetError("Present()", result);
+    }
+}
+
+static void
+D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
+
+    if (!data) {
+        return;
+    }
+    if (data->texture) {
+        IDirect3DTexture9_Release(data->texture);
+    }
+    SDL_free(data);
+    texture->driverdata = NULL;
+}
+
+static void
+D3D_DestroyRenderer(SDL_Renderer * renderer)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+
+    if (data) {
+        if (data->device) {
+            IDirect3DDevice9_Release(data->device);
+        }
+        if (data->d3d) {
+            IDirect3D9_Release(data->d3d);
+            SDL_UnloadObject(data->d3dDLL);
+        }
+        SDL_free(data);
+    }
+    SDL_free(renderer);
+}
+
+#endif /* SDL_VIDEO_RENDER_D3D */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/mmx.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,642 @@
+/*	mmx.h
+
+	MultiMedia eXtensions GCC interface library for IA32.
+
+	To use this library, simply include this header file
+	and compile with GCC.  You MUST have inlining enabled
+	in order for mmx_ok() to work; this can be done by
+	simply using -O on the GCC command line.
+
+	Compiling with -DMMX_TRACE will cause detailed trace
+	output to be sent to stderr for each mmx operation.
+	This adds lots of code, and obviously slows execution to
+	a crawl, but can be very useful for debugging.
+
+	THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
+	EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+	LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+	AND FITNESS FOR ANY PARTICULAR PURPOSE.
+
+	1997-99 by H. Dietz and R. Fisher
+
+ Notes:
+	It appears that the latest gas has the pand problem fixed, therefore
+	  I'll undefine BROKEN_PAND by default.
+*/
+
+#ifndef _MMX_H
+#define _MMX_H
+
+
+/*	Warning:  at this writing, the version of GAS packaged
+	with most Linux distributions does not handle the
+	parallel AND operation mnemonic correctly.  If the
+	symbol BROKEN_PAND is defined, a slower alternative
+	coding will be used.  If execution of mmxtest results
+	in an illegal instruction fault, define this symbol.
+*/
+#undef	BROKEN_PAND
+
+
+/*	The type of an value that fits in an MMX register
+	(note that long long constant values MUST be suffixed
+	 by LL and unsigned long long values by ULL, lest
+	 they be truncated by the compiler)
+*/
+typedef union
+{
+    long long q;                /* Quadword (64-bit) value */
+    unsigned long long uq;      /* Unsigned Quadword */
+    int d[2];                   /* 2 Doubleword (32-bit) values */
+    unsigned int ud[2];         /* 2 Unsigned Doubleword */
+    short w[4];                 /* 4 Word (16-bit) values */
+    unsigned short uw[4];       /* 4 Unsigned Word */
+    char b[8];                  /* 8 Byte (8-bit) values */
+    unsigned char ub[8];        /* 8 Unsigned Byte */
+    float s[2];                 /* Single-precision (32-bit) value */
+} __attribute__ ((aligned(8))) mmx_t;   /* On an 8-byte (64-bit) boundary */
+
+
+#if 0
+/*	Function to test if multimedia instructions are supported...
+*/
+inline extern int
+mm_support(void)
+{
+    /* Returns 1 if MMX instructions are supported,
+       3 if Cyrix MMX and Extended MMX instructions are supported
+       5 if AMD MMX and 3DNow! instructions are supported
+       0 if hardware does not support any of these
+     */
+    register int rval = 0;
+
+    __asm__ __volatile__(
+                            /* See if CPUID instruction is supported ... */
+                            /* ... Get copies of EFLAGS into eax and ecx */
+                            "pushf\n\t"
+                            "popl %%eax\n\t" "movl %%eax, %%ecx\n\t"
+                            /* ... Toggle the ID bit in one copy and store */
+                            /*     to the EFLAGS reg */
+                            "xorl $0x200000, %%eax\n\t"
+                            "push %%eax\n\t" "popf\n\t"
+                            /* ... Get the (hopefully modified) EFLAGS */
+                            "pushf\n\t" "popl %%eax\n\t"
+                            /* ... Compare and test result */
+                            "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* CPUID not supported */
+                            /* Get standard CPUID information, and
+                               go to a specific vendor section */
+                            "movl $0, %%eax\n\t" "cpuid\n\t"
+                            /* Check for Intel */
+                            "cmpl $0x756e6547, %%ebx\n\t"
+                            "jne TryAMD\n\t"
+                            "cmpl $0x49656e69, %%edx\n\t"
+                            "jne TryAMD\n\t"
+                            "cmpl $0x6c65746e, %%ecx\n"
+                            "jne TryAMD\n\t" "jmp Intel\n\t"
+                            /* Check for AMD */
+                            "\nTryAMD:\n\t"
+                            "cmpl $0x68747541, %%ebx\n\t"
+                            "jne TryCyrix\n\t"
+                            "cmpl $0x69746e65, %%edx\n\t"
+                            "jne TryCyrix\n\t"
+                            "cmpl $0x444d4163, %%ecx\n"
+                            "jne TryCyrix\n\t" "jmp AMD\n\t"
+                            /* Check for Cyrix */
+                            "\nTryCyrix:\n\t"
+                            "cmpl $0x69727943, %%ebx\n\t"
+                            "jne NotSupported2\n\t"
+                            "cmpl $0x736e4978, %%edx\n\t"
+                            "jne NotSupported3\n\t"
+                            "cmpl $0x64616574, %%ecx\n\t"
+                            "jne NotSupported4\n\t"
+                            /* Drop through to Cyrix... */
+                            /* Cyrix Section */
+                            /* See if extended CPUID level 80000001 is supported */
+                            /* The value of CPUID/80000001 for the 6x86MX is undefined
+                               according to the Cyrix CPU Detection Guide (Preliminary
+                               Rev. 1.01 table 1), so we'll check the value of eax for
+                               CPUID/0 to see if standard CPUID level 2 is supported.
+                               According to the table, the only CPU which supports level
+                               2 is also the only one which supports extended CPUID levels.
+                             */
+                            "cmpl $0x2, %%eax\n\t" "jne MMXtest\n\t"    /* Use standard CPUID instead */
+                            /* Extended CPUID supported (in theory), so get extended
+                               features */
+                            "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t"    /* Test for MMX */
+                            "jz NotSupported5\n\t"      /* MMX not supported */
+                            "testl $0x01000000, %%eax\n\t"      /* Test for Ext'd MMX */
+                            "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t"        /* MMX Supported */
+                            "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t"  /* EMMX and MMX Supported */
+                            "jmp Return\n\t"
+                            /* AMD Section */
+                            "AMD:\n\t"
+                            /* See if extended CPUID is supported */
+                            "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t"    /* Use standard CPUID instead */
+                            /* Extended CPUID supported, so get extended features */
+                            "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t"    /* Test for MMX */
+                            "jz NotSupported6\n\t"      /* MMX not supported */
+                            "testl $0x80000000, %%edx\n\t"      /* Test for 3DNow! */
+                            "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t"   /* MMX Supported */
+                            "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t"     /* 3DNow! and MMX Supported */
+                            "jmp Return\n\t"
+                            /* Intel Section */
+                            "Intel:\n\t"
+                            /* Check for MMX */
+                            "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t"      /* Test for MMX */
+                            "jz NotSupported7\n\t"      /* MMX Not supported */
+                            "movl $1, %0:\n\n\t"        /* MMX Supported */
+                            "jmp Return\n\t"
+                            /* Nothing supported */
+                            "\nNotSupported1:\n\t" "#movl $101, %0:\n\n\t" "\nNotSupported2:\n\t" "#movl $102, %0:\n\n\t" "\nNotSupported3:\n\t" "#movl $103, %0:\n\n\t" "\nNotSupported4:\n\t" "#movl $104, %0:\n\n\t" "\nNotSupported5:\n\t" "#movl $105, %0:\n\n\t" "\nNotSupported6:\n\t" "#movl $106, %0:\n\n\t" "\nNotSupported7:\n\t" "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a"(rval):     /* no input */
+                            :"eax", "ebx", "ecx", "edx");
+
+    /* Return */
+    return (rval);
+}
+
+/*	Function to test if mmx instructions are supported...
+*/
+inline extern int
+mmx_ok(void)
+{
+    /* Returns 1 if MMX instructions are supported, 0 otherwise */
+    return (mm_support() & 0x1);
+}
+#endif
+
+/*	Helper functions for the instruction macros that follow...
+	(note that memory-to-register, m2r, instructions are nearly
+	 as efficient as register-to-register, r2r, instructions;
+	 however, memory-to-memory instructions are really simulated
+	 as a convenience, and are only 1/3 as efficient)
+*/
+#ifdef	MMX_TRACE
+
+/*	Include the stuff for printing a trace to stderr...
+*/
+
+#define	mmx_i2r(op, imm, reg) \
+	{ \
+		mmx_t mmx_trace; \
+		mmx_trace.uq = (imm); \
+		printf(#op "_i2r(" #imm "=0x%08x%08x, ", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+		__asm__ __volatile__ ("movq %%" #reg ", %0" \
+				      : "=X" (mmx_trace) \
+				      : /* nothing */ ); \
+		printf(#reg "=0x%08x%08x) => ", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+		__asm__ __volatile__ (#op " %0, %%" #reg \
+				      : /* nothing */ \
+				      : "X" (imm)); \
+		__asm__ __volatile__ ("movq %%" #reg ", %0" \
+				      : "=X" (mmx_trace) \
+				      : /* nothing */ ); \
+		printf(#reg "=0x%08x%08x\n", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+	}
+
+#define	mmx_m2r(op, mem, reg) \
+	{ \
+		mmx_t mmx_trace; \
+		mmx_trace = (mem); \
+		printf(#op "_m2r(" #mem "=0x%08x%08x, ", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+		__asm__ __volatile__ ("movq %%" #reg ", %0" \
+				      : "=X" (mmx_trace) \
+				      : /* nothing */ ); \
+		printf(#reg "=0x%08x%08x) => ", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+		__asm__ __volatile__ (#op " %0, %%" #reg \
+				      : /* nothing */ \
+				      : "X" (mem)); \
+		__asm__ __volatile__ ("movq %%" #reg ", %0" \
+				      : "=X" (mmx_trace) \
+				      : /* nothing */ ); \
+		printf(#reg "=0x%08x%08x\n", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+	}
+
+#define	mmx_r2m(op, reg, mem) \
+	{ \
+		mmx_t mmx_trace; \
+		__asm__ __volatile__ ("movq %%" #reg ", %0" \
+				      : "=X" (mmx_trace) \
+				      : /* nothing */ ); \
+		printf(#op "_r2m(" #reg "=0x%08x%08x, ", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+		mmx_trace = (mem); \
+		printf(#mem "=0x%08x%08x) => ", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+		__asm__ __volatile__ (#op " %%" #reg ", %0" \
+				      : "=X" (mem) \
+				      : /* nothing */ ); \
+		mmx_trace = (mem); \
+		printf(#mem "=0x%08x%08x\n", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+	}
+
+#define	mmx_r2r(op, regs, regd) \
+	{ \
+		mmx_t mmx_trace; \
+		__asm__ __volatile__ ("movq %%" #regs ", %0" \
+				      : "=X" (mmx_trace) \
+				      : /* nothing */ ); \
+		printf(#op "_r2r(" #regs "=0x%08x%08x, ", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+		__asm__ __volatile__ ("movq %%" #regd ", %0" \
+				      : "=X" (mmx_trace) \
+				      : /* nothing */ ); \
+		printf(#regd "=0x%08x%08x) => ", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+		__asm__ __volatile__ (#op " %" #regs ", %" #regd); \
+		__asm__ __volatile__ ("movq %%" #regd ", %0" \
+				      : "=X" (mmx_trace) \
+				      : /* nothing */ ); \
+		printf(#regd "=0x%08x%08x\n", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+	}
+
+#define	mmx_m2m(op, mems, memd) \
+	{ \
+		mmx_t mmx_trace; \
+		mmx_trace = (mems); \
+		printf(#op "_m2m(" #mems "=0x%08x%08x, ", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+		mmx_trace = (memd); \
+		printf(#memd "=0x%08x%08x) => ", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+		__asm__ __volatile__ ("movq %0, %%mm0\n\t" \
+				      #op " %1, %%mm0\n\t" \
+				      "movq %%mm0, %0" \
+				      : "=X" (memd) \
+				      : "X" (mems)); \
+		mmx_trace = (memd); \
+		printf(#memd "=0x%08x%08x\n", \
+			mmx_trace.d[1], mmx_trace.d[0]); \
+	}
+
+#else
+
+/*	These macros are a lot simpler without the tracing...
+*/
+
+#define	mmx_i2r(op, imm, reg) \
+	__asm__ __volatile__ (#op " %0, %%" #reg \
+			      : /* nothing */ \
+			      : "X" (imm) )
+
+#define	mmx_m2r(op, mem, reg) \
+	__asm__ __volatile__ (#op " %0, %%" #reg \
+			      : /* nothing */ \
+			      : "m" (mem))
+
+#define	mmx_r2m(op, reg, mem) \
+	__asm__ __volatile__ (#op " %%" #reg ", %0" \
+			      : "=m" (mem) \
+			      : /* nothing */ )
+
+#define	mmx_r2r(op, regs, regd) \
+	__asm__ __volatile__ (#op " %" #regs ", %" #regd)
+
+#define	mmx_m2m(op, mems, memd) \
+	__asm__ __volatile__ ("movq %0, %%mm0\n\t" \
+			      #op " %1, %%mm0\n\t" \
+			      "movq %%mm0, %0" \
+			      : "=X" (memd) \
+			      : "X" (mems))
+
+#endif
+
+
+/*	1x64 MOVe Quadword
+	(this is both a load and a store...
+	 in fact, it is the only way to store)
+*/
+#define	movq_m2r(var, reg)	mmx_m2r(movq, var, reg)
+#define	movq_r2m(reg, var)	mmx_r2m(movq, reg, var)
+#define	movq_r2r(regs, regd)	mmx_r2r(movq, regs, regd)
+#define	movq(vars, vard) \
+	__asm__ __volatile__ ("movq %1, %%mm0\n\t" \
+			      "movq %%mm0, %0" \
+			      : "=X" (vard) \
+			      : "X" (vars))
+
+
+/*	1x32 MOVe Doubleword
+	(like movq, this is both load and store...
+	 but is most useful for moving things between
+	 mmx registers and ordinary registers)
+*/
+#define	movd_m2r(var, reg)	mmx_m2r(movd, var, reg)
+#define	movd_r2m(reg, var)	mmx_r2m(movd, reg, var)
+#define	movd_r2r(regs, regd)	mmx_r2r(movd, regs, regd)
+#define	movd(vars, vard) \
+	__asm__ __volatile__ ("movd %1, %%mm0\n\t" \
+			      "movd %%mm0, %0" \
+			      : "=X" (vard) \
+			      : "X" (vars))
+
+
+/*	2x32, 4x16, and 8x8 Parallel ADDs
+*/
+#define	paddd_m2r(var, reg)	mmx_m2r(paddd, var, reg)
+#define	paddd_r2r(regs, regd)	mmx_r2r(paddd, regs, regd)
+#define	paddd(vars, vard)	mmx_m2m(paddd, vars, vard)
+
+#define	paddw_m2r(var, reg)	mmx_m2r(paddw, var, reg)
+#define	paddw_r2r(regs, regd)	mmx_r2r(paddw, regs, regd)
+#define	paddw(vars, vard)	mmx_m2m(paddw, vars, vard)
+
+#define	paddb_m2r(var, reg)	mmx_m2r(paddb, var, reg)
+#define	paddb_r2r(regs, regd)	mmx_r2r(paddb, regs, regd)
+#define	paddb(vars, vard)	mmx_m2m(paddb, vars, vard)
+
+
+/*	4x16 and 8x8 Parallel ADDs using Saturation arithmetic
+*/
+#define	paddsw_m2r(var, reg)	mmx_m2r(paddsw, var, reg)
+#define	paddsw_r2r(regs, regd)	mmx_r2r(paddsw, regs, regd)
+#define	paddsw(vars, vard)	mmx_m2m(paddsw, vars, vard)
+
+#define	paddsb_m2r(var, reg)	mmx_m2r(paddsb, var, reg)
+#define	paddsb_r2r(regs, regd)	mmx_r2r(paddsb, regs, regd)
+#define	paddsb(vars, vard)	mmx_m2m(paddsb, vars, vard)
+
+
+/*	4x16 and 8x8 Parallel ADDs using Unsigned Saturation arithmetic
+*/
+#define	paddusw_m2r(var, reg)	mmx_m2r(paddusw, var, reg)
+#define	paddusw_r2r(regs, regd)	mmx_r2r(paddusw, regs, regd)
+#define	paddusw(vars, vard)	mmx_m2m(paddusw, vars, vard)
+
+#define	paddusb_m2r(var, reg)	mmx_m2r(paddusb, var, reg)
+#define	paddusb_r2r(regs, regd)	mmx_r2r(paddusb, regs, regd)
+#define	paddusb(vars, vard)	mmx_m2m(paddusb, vars, vard)
+
+
+/*	2x32, 4x16, and 8x8 Parallel SUBs
+*/
+#define	psubd_m2r(var, reg)	mmx_m2r(psubd, var, reg)
+#define	psubd_r2r(regs, regd)	mmx_r2r(psubd, regs, regd)
+#define	psubd(vars, vard)	mmx_m2m(psubd, vars, vard)
+
+#define	psubw_m2r(var, reg)	mmx_m2r(psubw, var, reg)
+#define	psubw_r2r(regs, regd)	mmx_r2r(psubw, regs, regd)
+#define	psubw(vars, vard)	mmx_m2m(psubw, vars, vard)
+
+#define	psubb_m2r(var, reg)	mmx_m2r(psubb, var, reg)
+#define	psubb_r2r(regs, regd)	mmx_r2r(psubb, regs, regd)
+#define	psubb(vars, vard)	mmx_m2m(psubb, vars, vard)
+
+
+/*	4x16 and 8x8 Parallel SUBs using Saturation arithmetic
+*/
+#define	psubsw_m2r(var, reg)	mmx_m2r(psubsw, var, reg)
+#define	psubsw_r2r(regs, regd)	mmx_r2r(psubsw, regs, regd)
+#define	psubsw(vars, vard)	mmx_m2m(psubsw, vars, vard)
+
+#define	psubsb_m2r(var, reg)	mmx_m2r(psubsb, var, reg)
+#define	psubsb_r2r(regs, regd)	mmx_r2r(psubsb, regs, regd)
+#define	psubsb(vars, vard)	mmx_m2m(psubsb, vars, vard)
+
+
+/*	4x16 and 8x8 Parallel SUBs using Unsigned Saturation arithmetic
+*/
+#define	psubusw_m2r(var, reg)	mmx_m2r(psubusw, var, reg)
+#define	psubusw_r2r(regs, regd)	mmx_r2r(psubusw, regs, regd)
+#define	psubusw(vars, vard)	mmx_m2m(psubusw, vars, vard)
+
+#define	psubusb_m2r(var, reg)	mmx_m2r(psubusb, var, reg)
+#define	psubusb_r2r(regs, regd)	mmx_r2r(psubusb, regs, regd)
+#define	psubusb(vars, vard)	mmx_m2m(psubusb, vars, vard)
+
+
+/*	4x16 Parallel MULs giving Low 4x16 portions of results
+*/
+#define	pmullw_m2r(var, reg)	mmx_m2r(pmullw, var, reg)
+#define	pmullw_r2r(regs, regd)	mmx_r2r(pmullw, regs, regd)
+#define	pmullw(vars, vard)	mmx_m2m(pmullw, vars, vard)
+
+
+/*	4x16 Parallel MULs giving High 4x16 portions of results
+*/
+#define	pmulhw_m2r(var, reg)	mmx_m2r(pmulhw, var, reg)
+#define	pmulhw_r2r(regs, regd)	mmx_r2r(pmulhw, regs, regd)
+#define	pmulhw(vars, vard)	mmx_m2m(pmulhw, vars, vard)
+
+
+/*	4x16->2x32 Parallel Mul-ADD
+	(muls like pmullw, then adds adjacent 16-bit fields
+	 in the multiply result to make the final 2x32 result)
+*/
+#define	pmaddwd_m2r(var, reg)	mmx_m2r(pmaddwd, var, reg)
+#define	pmaddwd_r2r(regs, regd)	mmx_r2r(pmaddwd, regs, regd)
+#define	pmaddwd(vars, vard)	mmx_m2m(pmaddwd, vars, vard)
+
+
+/*	1x64 bitwise AND
+*/
+#ifdef	BROKEN_PAND
+#define	pand_m2r(var, reg) \
+	{ \
+		mmx_m2r(pandn, (mmx_t) -1LL, reg); \
+		mmx_m2r(pandn, var, reg); \
+	}
+#define	pand_r2r(regs, regd) \
+	{ \
+		mmx_m2r(pandn, (mmx_t) -1LL, regd); \
+		mmx_r2r(pandn, regs, regd) \
+	}
+#define	pand(vars, vard) \
+	{ \
+		movq_m2r(vard, mm0); \
+		mmx_m2r(pandn, (mmx_t) -1LL, mm0); \
+		mmx_m2r(pandn, vars, mm0); \
+		movq_r2m(mm0, vard); \
+	}
+#else
+#define	pand_m2r(var, reg)	mmx_m2r(pand, var, reg)
+#define	pand_r2r(regs, regd)	mmx_r2r(pand, regs, regd)
+#define	pand(vars, vard)	mmx_m2m(pand, vars, vard)
+#endif
+
+
+/*	1x64 bitwise AND with Not the destination
+*/
+#define	pandn_m2r(var, reg)	mmx_m2r(pandn, var, reg)
+#define	pandn_r2r(regs, regd)	mmx_r2r(pandn, regs, regd)
+#define	pandn(vars, vard)	mmx_m2m(pandn, vars, vard)
+
+
+/*	1x64 bitwise OR
+*/
+#define	por_m2r(var, reg)	mmx_m2r(por, var, reg)
+#define	por_r2r(regs, regd)	mmx_r2r(por, regs, regd)
+#define	por(vars, vard)	mmx_m2m(por, vars, vard)
+
+
+/*	1x64 bitwise eXclusive OR
+*/
+#define	pxor_m2r(var, reg)	mmx_m2r(pxor, var, reg)
+#define	pxor_r2r(regs, regd)	mmx_r2r(pxor, regs, regd)
+#define	pxor(vars, vard)	mmx_m2m(pxor, vars, vard)
+
+
+/*	2x32, 4x16, and 8x8 Parallel CoMPare for EQuality
+	(resulting fields are either 0 or -1)
+*/
+#define	pcmpeqd_m2r(var, reg)	mmx_m2r(pcmpeqd, var, reg)
+#define	pcmpeqd_r2r(regs, regd)	mmx_r2r(pcmpeqd, regs, regd)
+#define	pcmpeqd(vars, vard)	mmx_m2m(pcmpeqd, vars, vard)
+
+#define	pcmpeqw_m2r(var, reg)	mmx_m2r(pcmpeqw, var, reg)
+#define	pcmpeqw_r2r(regs, regd)	mmx_r2r(pcmpeqw, regs, regd)
+#define	pcmpeqw(vars, vard)	mmx_m2m(pcmpeqw, vars, vard)
+
+#define	pcmpeqb_m2r(var, reg)	mmx_m2r(pcmpeqb, var, reg)
+#define	pcmpeqb_r2r(regs, regd)	mmx_r2r(pcmpeqb, regs, regd)
+#define	pcmpeqb(vars, vard)	mmx_m2m(pcmpeqb, vars, vard)
+
+
+/*	2x32, 4x16, and 8x8 Parallel CoMPare for Greater Than
+	(resulting fields are either 0 or -1)
+*/
+#define	pcmpgtd_m2r(var, reg)	mmx_m2r(pcmpgtd, var, reg)
+#define	pcmpgtd_r2r(regs, regd)	mmx_r2r(pcmpgtd, regs, regd)
+#define	pcmpgtd(vars, vard)	mmx_m2m(pcmpgtd, vars, vard)
+
+#define	pcmpgtw_m2r(var, reg)	mmx_m2r(pcmpgtw, var, reg)
+#define	pcmpgtw_r2r(regs, regd)	mmx_r2r(pcmpgtw, regs, regd)
+#define	pcmpgtw(vars, vard)	mmx_m2m(pcmpgtw, vars, vard)
+
+#define	pcmpgtb_m2r(var, reg)	mmx_m2r(pcmpgtb, var, reg)
+#define	pcmpgtb_r2r(regs, regd)	mmx_r2r(pcmpgtb, regs, regd)
+#define	pcmpgtb(vars, vard)	mmx_m2m(pcmpgtb, vars, vard)
+
+
+/*	1x64, 2x32, and 4x16 Parallel Shift Left Logical
+*/
+#define	psllq_i2r(imm, reg)	mmx_i2r(psllq, imm, reg)
+#define	psllq_m2r(var, reg)	mmx_m2r(psllq, var, reg)
+#define	psllq_r2r(regs, regd)	mmx_r2r(psllq, regs, regd)
+#define	psllq(vars, vard)	mmx_m2m(psllq, vars, vard)
+
+#define	pslld_i2r(imm, reg)	mmx_i2r(pslld, imm, reg)
+#define	pslld_m2r(var, reg)	mmx_m2r(pslld, var, reg)
+#define	pslld_r2r(regs, regd)	mmx_r2r(pslld, regs, regd)
+#define	pslld(vars, vard)	mmx_m2m(pslld, vars, vard)
+
+#define	psllw_i2r(imm, reg)	mmx_i2r(psllw, imm, reg)
+#define	psllw_m2r(var, reg)	mmx_m2r(psllw, var, reg)
+#define	psllw_r2r(regs, regd)	mmx_r2r(psllw, regs, regd)
+#define	psllw(vars, vard)	mmx_m2m(psllw, vars, vard)
+
+
+/*	1x64, 2x32, and 4x16 Parallel Shift Right Logical
+*/
+#define	psrlq_i2r(imm, reg)	mmx_i2r(psrlq, imm, reg)
+#define	psrlq_m2r(var, reg)	mmx_m2r(psrlq, var, reg)
+#define	psrlq_r2r(regs, regd)	mmx_r2r(psrlq, regs, regd)
+#define	psrlq(vars, vard)	mmx_m2m(psrlq, vars, vard)
+
+#define	psrld_i2r(imm, reg)	mmx_i2r(psrld, imm, reg)
+#define	psrld_m2r(var, reg)	mmx_m2r(psrld, var, reg)
+#define	psrld_r2r(regs, regd)	mmx_r2r(psrld, regs, regd)
+#define	psrld(vars, vard)	mmx_m2m(psrld, vars, vard)
+
+#define	psrlw_i2r(imm, reg)	mmx_i2r(psrlw, imm, reg)
+#define	psrlw_m2r(var, reg)	mmx_m2r(psrlw, var, reg)
+#define	psrlw_r2r(regs, regd)	mmx_r2r(psrlw, regs, regd)
+#define	psrlw(vars, vard)	mmx_m2m(psrlw, vars, vard)
+
+
+/*	2x32 and 4x16 Parallel Shift Right Arithmetic
+*/
+#define	psrad_i2r(imm, reg)	mmx_i2r(psrad, imm, reg)
+#define	psrad_m2r(var, reg)	mmx_m2r(psrad, var, reg)
+#define	psrad_r2r(regs, regd)	mmx_r2r(psrad, regs, regd)
+#define	psrad(vars, vard)	mmx_m2m(psrad, vars, vard)
+
+#define	psraw_i2r(imm, reg)	mmx_i2r(psraw, imm, reg)
+#define	psraw_m2r(var, reg)	mmx_m2r(psraw, var, reg)
+#define	psraw_r2r(regs, regd)	mmx_r2r(psraw, regs, regd)
+#define	psraw(vars, vard)	mmx_m2m(psraw, vars, vard)
+
+
+/*	2x32->4x16 and 4x16->8x8 PACK and Signed Saturate
+	(packs source and dest fields into dest in that order)
+*/
+#define	packssdw_m2r(var, reg)	mmx_m2r(packssdw, var, reg)
+#define	packssdw_r2r(regs, regd) mmx_r2r(packssdw, regs, regd)
+#define	packssdw(vars, vard)	mmx_m2m(packssdw, vars, vard)
+
+#define	packsswb_m2r(var, reg)	mmx_m2r(packsswb, var, reg)
+#define	packsswb_r2r(regs, regd) mmx_r2r(packsswb, regs, regd)
+#define	packsswb(vars, vard)	mmx_m2m(packsswb, vars, vard)
+
+
+/*	4x16->8x8 PACK and Unsigned Saturate
+	(packs source and dest fields into dest in that order)
+*/
+#define	packuswb_m2r(var, reg)	mmx_m2r(packuswb, var, reg)
+#define	packuswb_r2r(regs, regd) mmx_r2r(packuswb, regs, regd)
+#define	packuswb(vars, vard)	mmx_m2m(packuswb, vars, vard)
+
+
+/*	2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK Low
+	(interleaves low half of dest with low half of source
+	 as padding in each result field)
+*/
+#define	punpckldq_m2r(var, reg)	mmx_m2r(punpckldq, var, reg)
+#define	punpckldq_r2r(regs, regd) mmx_r2r(punpckldq, regs, regd)
+#define	punpckldq(vars, vard)	mmx_m2m(punpckldq, vars, vard)
+
+#define	punpcklwd_m2r(var, reg)	mmx_m2r(punpcklwd, var, reg)
+#define	punpcklwd_r2r(regs, regd) mmx_r2r(punpcklwd, regs, regd)
+#define	punpcklwd(vars, vard)	mmx_m2m(punpcklwd, vars, vard)
+
+#define	punpcklbw_m2r(var, reg)	mmx_m2r(punpcklbw, var, reg)
+#define	punpcklbw_r2r(regs, regd) mmx_r2r(punpcklbw, regs, regd)
+#define	punpcklbw(vars, vard)	mmx_m2m(punpcklbw, vars, vard)
+
+
+/*	2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK High
+	(interleaves high half of dest with high half of source
+	 as padding in each result field)
+*/
+#define	punpckhdq_m2r(var, reg)	mmx_m2r(punpckhdq, var, reg)
+#define	punpckhdq_r2r(regs, regd) mmx_r2r(punpckhdq, regs, regd)
+#define	punpckhdq(vars, vard)	mmx_m2m(punpckhdq, vars, vard)
+
+#define	punpckhwd_m2r(var, reg)	mmx_m2r(punpckhwd, var, reg)
+#define	punpckhwd_r2r(regs, regd) mmx_r2r(punpckhwd, regs, regd)
+#define	punpckhwd(vars, vard)	mmx_m2m(punpckhwd, vars, vard)
+
+#define	punpckhbw_m2r(var, reg)	mmx_m2r(punpckhbw, var, reg)
+#define	punpckhbw_r2r(regs, regd) mmx_r2r(punpckhbw, regs, regd)
+#define	punpckhbw(vars, vard)	mmx_m2m(punpckhbw, vars, vard)
+
+
+/*	Empty MMx State
+	(used to clean-up when going from mmx to float use
+	 of the registers that are shared by both; note that
+	 there is no float-to-mmx operation needed, because
+	 only the float tag word info is corruptible)
+*/
+#ifdef	MMX_TRACE
+
+#define	emms() \
+	{ \
+		printf("emms()\n"); \
+		__asm__ __volatile__ ("emms"); \
+	}
+
+#else
+
+#define	emms()			__asm__ __volatile__ ("emms")
+
+#endif
+
+#endif
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/opengl/SDL_glfuncs.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,456 @@
+/* list of OpenGL functions sorted alphabetically
+   If you need to use a GL function from the SDL video subsystem,
+   change it's entry from SDL_PROC_UNUSED to SDL_PROC and rebuild.
+*/
+#define SDL_PROC_UNUSED(ret,func,params)
+
+SDL_PROC_UNUSED(void, glAccum, (GLenum, GLfloat))
+SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum, GLclampf))
+SDL_PROC_UNUSED(GLboolean, glAreTexturesResident,
+                (GLsizei, const GLuint *, GLboolean *))
+SDL_PROC_UNUSED(void, glArrayElement, (GLint))
+SDL_PROC(void, glBegin, (GLenum))
+SDL_PROC(void, glBindTexture, (GLenum, GLuint))
+SDL_PROC_UNUSED(void, glBitmap,
+                (GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat,
+                 const GLubyte *))
+SDL_PROC(void, glBlendFunc, (GLenum, GLenum))
+SDL_PROC_UNUSED(void, glCallList, (GLuint))
+SDL_PROC_UNUSED(void, glCallLists, (GLsizei, GLenum, const GLvoid *))
+SDL_PROC(void, glClear, (GLbitfield))
+SDL_PROC_UNUSED(void, glClearAccum, (GLfloat, GLfloat, GLfloat, GLfloat))
+SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
+SDL_PROC_UNUSED(void, glClearDepth, (GLclampd))
+SDL_PROC_UNUSED(void, glClearIndex, (GLfloat))
+SDL_PROC_UNUSED(void, glClearStencil, (GLint))
+SDL_PROC_UNUSED(void, glClipPlane, (GLenum, const GLdouble *))
+SDL_PROC_UNUSED(void, glColor3b, (GLbyte, GLbyte, GLbyte))
+SDL_PROC_UNUSED(void, glColor3bv, (const GLbyte *))
+SDL_PROC_UNUSED(void, glColor3d, (GLdouble, GLdouble, GLdouble))
+SDL_PROC_UNUSED(void, glColor3dv, (const GLdouble *))
+SDL_PROC_UNUSED(void, glColor3f, (GLfloat, GLfloat, GLfloat))
+SDL_PROC_UNUSED(void, glColor3fv, (const GLfloat *))
+SDL_PROC_UNUSED(void, glColor3i, (GLint, GLint, GLint))
+SDL_PROC_UNUSED(void, glColor3iv, (const GLint *))
+SDL_PROC_UNUSED(void, glColor3s, (GLshort, GLshort, GLshort))
+SDL_PROC_UNUSED(void, glColor3sv, (const GLshort *))
+SDL_PROC_UNUSED(void, glColor3ub, (GLubyte, GLubyte, GLubyte))
+SDL_PROC_UNUSED(void, glColor3ubv, (const GLubyte *))
+SDL_PROC_UNUSED(void, glColor3ui, (GLuint, GLuint, GLuint))
+SDL_PROC_UNUSED(void, glColor3uiv, (const GLuint *))
+SDL_PROC_UNUSED(void, glColor3us, (GLushort, GLushort, GLushort))
+SDL_PROC_UNUSED(void, glColor3usv, (const GLushort *))
+SDL_PROC_UNUSED(void, glColor4b, (GLbyte, GLbyte, GLbyte, GLbyte))
+SDL_PROC_UNUSED(void, glColor4bv, (const GLbyte *))
+SDL_PROC_UNUSED(void, glColor4d, (GLdouble, GLdouble, GLdouble, GLdouble))
+SDL_PROC_UNUSED(void, glColor4dv, (const GLdouble *))
+SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat))
+SDL_PROC_UNUSED(void, glColor4fv, (const GLfloat *))
+SDL_PROC_UNUSED(void, glColor4i, (GLint, GLint, GLint, GLint))
+SDL_PROC_UNUSED(void, glColor4iv, (const GLint *))
+SDL_PROC_UNUSED(void, glColor4s, (GLshort, GLshort, GLshort, GLshort))
+SDL_PROC_UNUSED(void, glColor4sv, (const GLshort *))
+SDL_PROC_UNUSED(void, glColor4ub,
+                (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
+SDL_PROC_UNUSED(void, glColor4ubv, (const GLubyte * v))
+SDL_PROC_UNUSED(void, glColor4ui,
+                (GLuint red, GLuint green, GLuint blue, GLuint alpha))
+SDL_PROC_UNUSED(void, glColor4uiv, (const GLuint * v))
+SDL_PROC_UNUSED(void, glColor4us,
+                (GLushort red, GLushort green, GLushort blue, GLushort alpha))
+SDL_PROC_UNUSED(void, glColor4usv, (const GLushort * v))
+SDL_PROC_UNUSED(void, glColorMask,
+                (GLboolean red, GLboolean green, GLboolean blue,
+                 GLboolean alpha))
+SDL_PROC_UNUSED(void, glColorMaterial, (GLenum face, GLenum mode))
+SDL_PROC_UNUSED(void, glColorPointer,
+                (GLint size, GLenum type, GLsizei stride,
+                 const GLvoid * pointer))
+SDL_PROC_UNUSED(void, glCopyPixels,
+                (GLint x, GLint y, GLsizei width, GLsizei height,
+                 GLenum type))
+SDL_PROC_UNUSED(void, glCopyTexImage1D,
+                (GLenum target, GLint level, GLenum internalFormat, GLint x,
+                 GLint y, GLsizei width, GLint border))
+SDL_PROC_UNUSED(void, glCopyTexImage2D,
+                (GLenum target, GLint level, GLenum internalFormat, GLint x,
+                 GLint y, GLsizei width, GLsizei height, GLint border))
+SDL_PROC_UNUSED(void, glCopyTexSubImage1D,
+                (GLenum target, GLint level, GLint xoffset, GLint x, GLint y,
+                 GLsizei width))
+SDL_PROC_UNUSED(void, glCopyTexSubImage2D,
+                (GLenum target, GLint level, GLint xoffset, GLint yoffset,
+                 GLint x, GLint y, GLsizei width, GLsizei height))
+SDL_PROC_UNUSED(void, glCullFace, (GLenum mode))
+SDL_PROC_UNUSED(void, glDeleteLists, (GLuint list, GLsizei range))
+SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint * textures))
+SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func))
+SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag))
+SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar))
+SDL_PROC(void, glDisable, (GLenum cap))
+SDL_PROC_UNUSED(void, glDisableClientState, (GLenum array))
+SDL_PROC_UNUSED(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count))
+SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode))
+SDL_PROC_UNUSED(void, glDrawElements,
+                (GLenum mode, GLsizei count, GLenum type,
+                 const GLvoid * indices))
+SDL_PROC(void, glDrawPixels,
+         (GLsizei width, GLsizei height, GLenum format, GLenum type,
+          const GLvoid * pixels))
+SDL_PROC_UNUSED(void, glEdgeFlag, (GLboolean flag))
+SDL_PROC_UNUSED(void, glEdgeFlagPointer,
+                (GLsizei stride, const GLvoid * pointer))
+SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag))
+SDL_PROC(void, glEnable, (GLenum cap))
+SDL_PROC_UNUSED(void, glEnableClientState, (GLenum array))
+SDL_PROC(void, glEnd, (void))
+SDL_PROC_UNUSED(void, glEndList, (void))
+SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u))
+SDL_PROC_UNUSED(void, glEvalCoord1dv, (const GLdouble * u))
+SDL_PROC_UNUSED(void, glEvalCoord1f, (GLfloat u))
+SDL_PROC_UNUSED(void, glEvalCoord1fv, (const GLfloat * u))
+SDL_PROC_UNUSED(void, glEvalCoord2d, (GLdouble u, GLdouble v))
+SDL_PROC_UNUSED(void, glEvalCoord2dv, (const GLdouble * u))
+SDL_PROC_UNUSED(void, glEvalCoord2f, (GLfloat u, GLfloat v))
+SDL_PROC_UNUSED(void, glEvalCoord2fv, (const GLfloat * u))
+SDL_PROC_UNUSED(void, glEvalMesh1, (GLenum mode, GLint i1, GLint i2))
+SDL_PROC_UNUSED(void, glEvalMesh2,
+                (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2))
+SDL_PROC_UNUSED(void, glEvalPoint1, (GLint i))
+SDL_PROC_UNUSED(void, glEvalPoint2, (GLint i, GLint j))
+SDL_PROC_UNUSED(void, glFeedbackBuffer,
+                (GLsizei size, GLenum type, GLfloat * buffer))
+SDL_PROC_UNUSED(void, glFinish, (void))
+SDL_PROC_UNUSED(void, glFlush, (void))
+SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params))
+SDL_PROC_UNUSED(void, glFogi, (GLenum pname, GLint param))
+SDL_PROC_UNUSED(void, glFogiv, (GLenum pname, const GLint * params))
+SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode))
+SDL_PROC_UNUSED(void, glFrustum,
+                (GLdouble left, GLdouble right, GLdouble bottom,
+                 GLdouble top, GLdouble zNear, GLdouble zFar))
+SDL_PROC_UNUSED(GLuint, glGenLists, (GLsizei range))
+SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures))
+SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params))
+SDL_PROC_UNUSED(void, glGetClipPlane, (GLenum plane, GLdouble * equation))
+SDL_PROC_UNUSED(void, glGetDoublev, (GLenum pname, GLdouble * params))
+SDL_PROC(GLenum, glGetError, (void))
+SDL_PROC_UNUSED(void, glGetFloatv, (GLenum pname, GLfloat * params))
+SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params))
+SDL_PROC_UNUSED(void, glGetLightfv,
+                (GLenum light, GLenum pname, GLfloat * params))
+SDL_PROC_UNUSED(void, glGetLightiv,
+                (GLenum light, GLenum pname, GLint * params))
+SDL_PROC_UNUSED(void, glGetMapdv, (GLenum target, GLenum query, GLdouble * v))
+SDL_PROC_UNUSED(void, glGetMapfv, (GLenum target, GLenum query, GLfloat * v))
+SDL_PROC_UNUSED(void, glGetMapiv, (GLenum target, GLenum query, GLint * v))
+SDL_PROC_UNUSED(void, glGetMaterialfv,
+                (GLenum face, GLenum pname, GLfloat * params))
+SDL_PROC_UNUSED(void, glGetMaterialiv,
+                (GLenum face, GLenum pname, GLint * params))
+SDL_PROC_UNUSED(void, glGetPixelMapfv, (GLenum map, GLfloat * values))
+SDL_PROC_UNUSED(void, glGetPixelMapuiv, (GLenum map, GLuint * values))
+SDL_PROC_UNUSED(void, glGetPixelMapusv, (GLenum map, GLushort * values))
+SDL_PROC_UNUSED(void, glGetPointerv, (GLenum pname, GLvoid * *params))
+SDL_PROC_UNUSED(void, glGetPolygonStipple, (GLubyte * mask))
+SDL_PROC(const GLubyte *, glGetString, (GLenum name))
+SDL_PROC_UNUSED(void, glGetTexEnvfv,
+                (GLenum target, GLenum pname, GLfloat * params))
+SDL_PROC_UNUSED(void, glGetTexEnviv,
+                (GLenum target, GLenum pname, GLint * params))
+SDL_PROC_UNUSED(void, glGetTexGendv,
+                (GLenum coord, GLenum pname, GLdouble * params))
+SDL_PROC_UNUSED(void, glGetTexGenfv,
+                (GLenum coord, GLenum pname, GLfloat * params))
+SDL_PROC_UNUSED(void, glGetTexGeniv,
+                (GLenum coord, GLenum pname, GLint * params))
+SDL_PROC_UNUSED(void, glGetTexImage,
+                (GLenum target, GLint level, GLenum format, GLenum type,
+                 GLvoid * pixels))
+SDL_PROC_UNUSED(void, glGetTexLevelParameterfv,
+                (GLenum target, GLint level, GLenum pname, GLfloat * params))
+SDL_PROC_UNUSED(void, glGetTexLevelParameteriv,
+                (GLenum target, GLint level, GLenum pname, GLint * params))
+SDL_PROC_UNUSED(void, glGetTexParameterfv,
+                (GLenum target, GLenum pname, GLfloat * params))
+SDL_PROC_UNUSED(void, glGetTexParameteriv,
+                (GLenum target, GLenum pname, GLint * params))
+SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode))
+SDL_PROC_UNUSED(void, glIndexMask, (GLuint mask))
+SDL_PROC_UNUSED(void, glIndexPointer,
+                (GLenum type, GLsizei stride, const GLvoid * pointer))
+SDL_PROC_UNUSED(void, glIndexd, (GLdouble c))
+SDL_PROC_UNUSED(void, glIndexdv, (const GLdouble * c))
+SDL_PROC_UNUSED(void, glIndexf, (GLfloat c))
+SDL_PROC_UNUSED(void, glIndexfv, (const GLfloat * c))
+SDL_PROC_UNUSED(void, glIndexi, (GLint c))
+SDL_PROC_UNUSED(void, glIndexiv, (const GLint * c))
+SDL_PROC_UNUSED(void, glIndexs, (GLshort c))
+SDL_PROC_UNUSED(void, glIndexsv, (const GLshort * c))
+SDL_PROC_UNUSED(void, glIndexub, (GLubyte c))
+SDL_PROC_UNUSED(void, glIndexubv, (const GLubyte * c))
+SDL_PROC_UNUSED(void, glInitNames, (void))
+SDL_PROC_UNUSED(void, glInterleavedArrays,
+                (GLenum format, GLsizei stride, const GLvoid * pointer))
+SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap))
+SDL_PROC_UNUSED(GLboolean, glIsList, (GLuint list))
+SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture))
+SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params))
+SDL_PROC_UNUSED(void, glLightModeli, (GLenum pname, GLint param))
+SDL_PROC_UNUSED(void, glLightModeliv, (GLenum pname, const GLint * params))
+SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void, glLightfv,
+                (GLenum light, GLenum pname, const GLfloat * params))
+SDL_PROC_UNUSED(void, glLighti, (GLenum light, GLenum pname, GLint param))
+SDL_PROC_UNUSED(void, glLightiv,
+                (GLenum light, GLenum pname, const GLint * params))
+SDL_PROC_UNUSED(void, glLineStipple, (GLint factor, GLushort pattern))
+SDL_PROC(void, glLineWidth, (GLfloat width))
+SDL_PROC_UNUSED(void, glListBase, (GLuint base))
+SDL_PROC(void, glLoadIdentity, (void))
+SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble * m))
+SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m))
+SDL_PROC_UNUSED(void, glLoadName, (GLuint name))
+SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode))
+SDL_PROC_UNUSED(void, glMap1d,
+                (GLenum target, GLdouble u1, GLdouble u2, GLint stride,
+                 GLint order, const GLdouble * points))
+SDL_PROC_UNUSED(void, glMap1f,
+                (GLenum target, GLfloat u1, GLfloat u2, GLint stride,
+                 GLint order, const GLfloat * points))
+SDL_PROC_UNUSED(void, glMap2d,
+                (GLenum target, GLdouble u1, GLdouble u2, GLint ustride,
+                 GLint uorder, GLdouble v1, GLdouble v2, GLint vstride,
+                 GLint vorder, const GLdouble * points))
+SDL_PROC_UNUSED(void, glMap2f,
+                (GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
+                 GLint uorder, GLfloat v1, GLfloat v2, GLint vstride,
+                 GLint vorder, const GLfloat * points))
+SDL_PROC_UNUSED(void, glMapGrid1d, (GLint un, GLdouble u1, GLdouble u2))
+SDL_PROC_UNUSED(void, glMapGrid1f, (GLint un, GLfloat u1, GLfloat u2))
+SDL_PROC_UNUSED(void, glMapGrid2d,
+                (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1,
+                 GLdouble v2))
+SDL_PROC_UNUSED(void, glMapGrid2f,
+                (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1,
+                 GLfloat v2))
+SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void, glMaterialfv,
+                (GLenum face, GLenum pname, const GLfloat * params))
+SDL_PROC_UNUSED(void, glMateriali, (GLenum face, GLenum pname, GLint param))
+SDL_PROC_UNUSED(void, glMaterialiv,
+                (GLenum face, GLenum pname, const GLint * params))
+SDL_PROC(void, glMatrixMode, (GLenum mode))
+SDL_PROC_UNUSED(void, glMultMatrixd, (const GLdouble * m))
+SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m))
+SDL_PROC_UNUSED(void, glNewList, (GLuint list, GLenum mode))
+SDL_PROC_UNUSED(void, glNormal3b, (GLbyte nx, GLbyte ny, GLbyte nz))
+SDL_PROC_UNUSED(void, glNormal3bv, (const GLbyte * v))
+SDL_PROC_UNUSED(void, glNormal3d, (GLdouble nx, GLdouble ny, GLdouble nz))
+SDL_PROC_UNUSED(void, glNormal3dv, (const GLdouble * v))
+SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz))
+SDL_PROC_UNUSED(void, glNormal3fv, (const GLfloat * v))
+SDL_PROC_UNUSED(void, glNormal3i, (GLint nx, GLint ny, GLint nz))
+SDL_PROC_UNUSED(void, glNormal3iv, (const GLint * v))
+SDL_PROC_UNUSED(void, glNormal3s, (GLshort nx, GLshort ny, GLshort nz))
+SDL_PROC_UNUSED(void, glNormal3sv, (const GLshort * v))
+SDL_PROC_UNUSED(void, glNormalPointer,
+                (GLenum type, GLsizei stride, const GLvoid * pointer))
+SDL_PROC(void, glOrtho,
+         (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
+          GLdouble zNear, GLdouble zFar))
+SDL_PROC_UNUSED(void, glPassThrough, (GLfloat token))
+SDL_PROC_UNUSED(void, glPixelMapfv,
+                (GLenum map, GLsizei mapsize, const GLfloat * values))
+SDL_PROC_UNUSED(void, glPixelMapuiv,
+                (GLenum map, GLsizei mapsize, const GLuint * values))
+SDL_PROC_UNUSED(void, glPixelMapusv,
+                (GLenum map, GLsizei mapsize, const GLushort * values))
+SDL_PROC_UNUSED(void, glPixelStoref, (GLenum pname, GLfloat param))
+SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param))
+SDL_PROC_UNUSED(void, glPixelTransferf, (GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void, glPixelTransferi, (GLenum pname, GLint param))
+SDL_PROC_UNUSED(void, glPixelZoom, (GLfloat xfactor, GLfloat yfactor))
+SDL_PROC(void, glPointSize, (GLfloat size))
+SDL_PROC_UNUSED(void, glPolygonMode, (GLenum face, GLenum mode))
+SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units))
+SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte * mask))
+SDL_PROC_UNUSED(void, glPopAttrib, (void))
+SDL_PROC_UNUSED(void, glPopClientAttrib, (void))
+SDL_PROC_UNUSED(void, glPopMatrix, (void))
+SDL_PROC_UNUSED(void, glPopName, (void))
+SDL_PROC_UNUSED(void, glPrioritizeTextures,
+                (GLsizei n, const GLuint * textures,
+                 const GLclampf * priorities))
+SDL_PROC_UNUSED(void, glPushAttrib, (GLbitfield mask))
+SDL_PROC_UNUSED(void, glPushClientAttrib, (GLbitfield mask))
+SDL_PROC_UNUSED(void, glPushMatrix, (void))
+SDL_PROC_UNUSED(void, glPushName, (GLuint name))
+SDL_PROC_UNUSED(void, glRasterPos2d, (GLdouble x, GLdouble y))
+SDL_PROC_UNUSED(void, glRasterPos2dv, (const GLdouble * v))
+SDL_PROC_UNUSED(void, glRasterPos2f, (GLfloat x, GLfloat y))
+SDL_PROC_UNUSED(void, glRasterPos2fv, (const GLfloat * v))
+SDL_PROC(void, glRasterPos2i, (GLint x, GLint y))
+SDL_PROC_UNUSED(void, glRasterPos2iv, (const GLint * v))
+SDL_PROC_UNUSED(void, glRasterPos2s, (GLshort x, GLshort y))
+SDL_PROC_UNUSED(void, glRasterPos2sv, (const GLshort * v))
+SDL_PROC_UNUSED(void, glRasterPos3d, (GLdouble x, GLdouble y, GLdouble z))
+SDL_PROC_UNUSED(void, glRasterPos3dv, (const GLdouble * v))
+SDL_PROC_UNUSED(void, glRasterPos3f, (GLfloat x, GLfloat y, GLfloat z))
+SDL_PROC_UNUSED(void, glRasterPos3fv, (const GLfloat * v))
+SDL_PROC_UNUSED(void, glRasterPos3i, (GLint x, GLint y, GLint z))
+SDL_PROC_UNUSED(void, glRasterPos3iv, (const GLint * v))
+SDL_PROC_UNUSED(void, glRasterPos3s, (GLshort x, GLshort y, GLshort z))
+SDL_PROC_UNUSED(void, glRasterPos3sv, (const GLshort * v))
+SDL_PROC_UNUSED(void, glRasterPos4d,
+                (GLdouble x, GLdouble y, GLdouble z, GLdouble w))
+SDL_PROC_UNUSED(void, glRasterPos4dv, (const GLdouble * v))
+SDL_PROC_UNUSED(void, glRasterPos4f,
+                (GLfloat x, GLfloat y, GLfloat z, GLfloat w))
+SDL_PROC_UNUSED(void, glRasterPos4fv, (const GLfloat * v))
+SDL_PROC_UNUSED(void, glRasterPos4i, (GLint x, GLint y, GLint z, GLint w))
+SDL_PROC_UNUSED(void, glRasterPos4iv, (const GLint * v))
+SDL_PROC_UNUSED(void, glRasterPos4s,
+                (GLshort x, GLshort y, GLshort z, GLshort w))
+SDL_PROC_UNUSED(void, glRasterPos4sv, (const GLshort * v))
+SDL_PROC(void, glReadBuffer, (GLenum mode))
+SDL_PROC(void, glReadPixels,
+         (GLint x, GLint y, GLsizei width, GLsizei height,
+          GLenum format, GLenum type, GLvoid * pixels))
+SDL_PROC_UNUSED(void, glRectd,
+                (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2))
+SDL_PROC_UNUSED(void, glRectdv, (const GLdouble * v1, const GLdouble * v2))
+SDL_PROC_UNUSED(void, glRectf,
+                (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2))
+SDL_PROC_UNUSED(void, glRectfv, (const GLfloat * v1, const GLfloat * v2))
+SDL_PROC(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2))
+SDL_PROC_UNUSED(void, glRectiv, (const GLint * v1, const GLint * v2))
+SDL_PROC_UNUSED(void, glRects,
+                (GLshort x1, GLshort y1, GLshort x2, GLshort y2))
+SDL_PROC_UNUSED(void, glRectsv, (const GLshort * v1, const GLshort * v2))
+SDL_PROC_UNUSED(GLint, glRenderMode, (GLenum mode))
+SDL_PROC_UNUSED(void, glRotated,
+                (GLdouble angle, GLdouble x, GLdouble y, GLdouble z))
+SDL_PROC_UNUSED(void, glRotatef,
+                (GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
+SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z))
+SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z))
+SDL_PROC_UNUSED(void, glScissor,
+                (GLint x, GLint y, GLsizei width, GLsizei height))
+SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint * buffer))
+SDL_PROC_UNUSED(void, glShadeModel, (GLenum mode))
+SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask))
+SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask))
+SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass))
+SDL_PROC_UNUSED(void, glTexCoord1d, (GLdouble s))
+SDL_PROC_UNUSED(void, glTexCoord1dv, (const GLdouble * v))
+SDL_PROC_UNUSED(void, glTexCoord1f, (GLfloat s))
+SDL_PROC_UNUSED(void, glTexCoord1fv, (const GLfloat * v))
+SDL_PROC_UNUSED(void, glTexCoord1i, (GLint s))
+SDL_PROC_UNUSED(void, glTexCoord1iv, (const GLint * v))
+SDL_PROC_UNUSED(void, glTexCoord1s, (GLshort s))
+SDL_PROC_UNUSED(void, glTexCoord1sv, (const GLshort * v))
+SDL_PROC_UNUSED(void, glTexCoord2d, (GLdouble s, GLdouble t))
+SDL_PROC_UNUSED(void, glTexCoord2dv, (const GLdouble * v))
+SDL_PROC(void, glTexCoord2f, (GLfloat s, GLfloat t))
+SDL_PROC_UNUSED(void, glTexCoord2fv, (const GLfloat * v))
+SDL_PROC_UNUSED(void, glTexCoord2i, (GLint s, GLint t))
+SDL_PROC_UNUSED(void, glTexCoord2iv, (const GLint * v))
+SDL_PROC_UNUSED(void, glTexCoord2s, (GLshort s, GLshort t))
+SDL_PROC_UNUSED(void, glTexCoord2sv, (const GLshort * v))
+SDL_PROC_UNUSED(void, glTexCoord3d, (GLdouble s, GLdouble t, GLdouble r))
+SDL_PROC_UNUSED(void, glTexCoord3dv, (const GLdouble * v))
+SDL_PROC_UNUSED(void, glTexCoord3f, (GLfloat s, GLfloat t, GLfloat r))
+SDL_PROC_UNUSED(void, glTexCoord3fv, (const GLfloat * v))
+SDL_PROC_UNUSED(void, glTexCoord3i, (GLint s, GLint t, GLint r))
+SDL_PROC_UNUSED(void, glTexCoord3iv, (const GLint * v))
+SDL_PROC_UNUSED(void, glTexCoord3s, (GLshort s, GLshort t, GLshort r))
+SDL_PROC_UNUSED(void, glTexCoord3sv, (const GLshort * v))
+SDL_PROC_UNUSED(void, glTexCoord4d,
+                (GLdouble s, GLdouble t, GLdouble r, GLdouble q))
+SDL_PROC_UNUSED(void, glTexCoord4dv, (const GLdouble * v))
+SDL_PROC_UNUSED(void, glTexCoord4f,
+                (GLfloat s, GLfloat t, GLfloat r, GLfloat q))
+SDL_PROC_UNUSED(void, glTexCoord4fv, (const GLfloat * v))
+SDL_PROC_UNUSED(void, glTexCoord4i, (GLint s, GLint t, GLint r, GLint q))
+SDL_PROC_UNUSED(void, glTexCoord4iv, (const GLint * v))
+SDL_PROC_UNUSED(void, glTexCoord4s,
+                (GLshort s, GLshort t, GLshort r, GLshort q))
+SDL_PROC_UNUSED(void, glTexCoord4sv, (const GLshort * v))
+SDL_PROC_UNUSED(void, glTexCoordPointer,
+                (GLint size, GLenum type, GLsizei stride,
+                 const GLvoid * pointer))
+SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void, glTexEnvfv,
+                (GLenum target, GLenum pname, const GLfloat * params))
+SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param))
+SDL_PROC_UNUSED(void, glTexEnviv,
+                (GLenum target, GLenum pname, const GLint * params))
+SDL_PROC_UNUSED(void, glTexGend, (GLenum coord, GLenum pname, GLdouble param))
+SDL_PROC_UNUSED(void, glTexGendv,
+                (GLenum coord, GLenum pname, const GLdouble * params))
+SDL_PROC_UNUSED(void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void, glTexGenfv,
+                (GLenum coord, GLenum pname, const GLfloat * params))
+SDL_PROC_UNUSED(void, glTexGeni, (GLenum coord, GLenum pname, GLint param))
+SDL_PROC_UNUSED(void, glTexGeniv,
+                (GLenum coord, GLenum pname, const GLint * params))
+SDL_PROC_UNUSED(void, glTexImage1D,
+                (GLenum target, GLint level, GLint internalformat,
+                 GLsizei width, GLint border, GLenum format, GLenum type,
+                 const GLvoid * pixels))
+SDL_PROC(void, glTexImage2D,
+         (GLenum target, GLint level, GLint internalformat, GLsizei width,
+          GLsizei height, GLint border, GLenum format, GLenum type,
+          const GLvoid * pixels))
+SDL_PROC_UNUSED(void, glTexParameterf,
+                (GLenum target, GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void, glTexParameterfv,
+                (GLenum target, GLenum pname, const GLfloat * params))
+SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param))
+SDL_PROC_UNUSED(void, glTexParameteriv,
+                (GLenum target, GLenum pname, const GLint * params))
+SDL_PROC_UNUSED(void, glTexSubImage1D,
+                (GLenum target, GLint level, GLint xoffset, GLsizei width,
+                 GLenum format, GLenum type, const GLvoid * pixels))
+SDL_PROC(void, glTexSubImage2D,
+         (GLenum target, GLint level, GLint xoffset, GLint yoffset,
+          GLsizei width, GLsizei height, GLenum format, GLenum type,
+          const GLvoid * pixels))
+SDL_PROC_UNUSED(void, glTranslated, (GLdouble x, GLdouble y, GLdouble z))
+SDL_PROC_UNUSED(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z))
+SDL_PROC_UNUSED(void, glVertex2d, (GLdouble x, GLdouble y))
+SDL_PROC_UNUSED(void, glVertex2dv, (const GLdouble * v))
+SDL_PROC(void, glVertex2f, (GLfloat x, GLfloat y))
+SDL_PROC_UNUSED(void, glVertex2fv, (const GLfloat * v))
+SDL_PROC_UNUSED(void, glVertex2i, (GLint x, GLint y))
+SDL_PROC_UNUSED(void, glVertex2iv, (const GLint * v))
+SDL_PROC_UNUSED(void, glVertex2s, (GLshort x, GLshort y))
+SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort * v))
+SDL_PROC_UNUSED(void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z))
+SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble * v))
+SDL_PROC_UNUSED(void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z))
+SDL_PROC_UNUSED(void, glVertex3fv, (const GLfloat * v))
+SDL_PROC_UNUSED(void, glVertex3i, (GLint x, GLint y, GLint z))
+SDL_PROC_UNUSED(void, glVertex3iv, (const GLint * v))
+SDL_PROC_UNUSED(void, glVertex3s, (GLshort x, GLshort y, GLshort z))
+SDL_PROC_UNUSED(void, glVertex3sv, (const GLshort * v))
+SDL_PROC_UNUSED(void, glVertex4d,
+                (GLdouble x, GLdouble y, GLdouble z, GLdouble w))
+SDL_PROC_UNUSED(void, glVertex4dv, (const GLdouble * v))
+SDL_PROC_UNUSED(void, glVertex4f,
+                (GLfloat x, GLfloat y, GLfloat z, GLfloat w))
+SDL_PROC_UNUSED(void, glVertex4fv, (const GLfloat * v))
+SDL_PROC_UNUSED(void, glVertex4i, (GLint x, GLint y, GLint z, GLint w))
+SDL_PROC_UNUSED(void, glVertex4iv, (const GLint * v))
+SDL_PROC_UNUSED(void, glVertex4s,
+                (GLshort x, GLshort y, GLshort z, GLshort w))
+SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v))
+SDL_PROC_UNUSED(void, glVertexPointer,
+                (GLint size, GLenum type, GLsizei stride,
+                 const GLvoid * pointer))
+SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height))
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/opengl/SDL_render_gl.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,826 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#if SDL_VIDEO_RENDER_OGL
+
+#include "SDL_opengl.h"
+#include "../SDL_sysrender.h"
+
+#ifdef __MACOSX__
+#include <OpenGL/OpenGL.h>
+#endif
+
+
+/* OpenGL renderer implementation */
+
+/* Details on optimizing the texture path on Mac OS X:
+   http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/opengl_texturedata.html
+*/
+
+/* Used to re-create the window with OpenGL capability */
+extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
+
+static const float inv255f = 1.0f / 255.0f;
+
+static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags);
+static void GL_WindowEvent(SDL_Renderer * renderer,
+                           const SDL_WindowEvent *event);
+static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                            const SDL_Rect * rect, const void *pixels,
+                            int pitch);
+static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                          const SDL_Rect * rect, void **pixels, int *pitch);
+static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int GL_RenderClear(SDL_Renderer * renderer);
+static int GL_RenderDrawPoints(SDL_Renderer * renderer,
+                               const SDL_Point * points, int count);
+static int GL_RenderDrawLines(SDL_Renderer * renderer,
+                              const SDL_Point * points, int count);
+static int GL_RenderFillRects(SDL_Renderer * renderer,
+                              const SDL_Rect ** rects, int count);
+static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
+static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                               Uint32 pixel_format, void * pixels, int pitch);
+static void GL_RenderPresent(SDL_Renderer * renderer);
+static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static void GL_DestroyRenderer(SDL_Renderer * renderer);
+
+
+SDL_RenderDriver GL_RenderDriver = {
+    GL_CreateRenderer,
+    {
+     "opengl",
+     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
+     1,
+     {SDL_PIXELFORMAT_ARGB8888},
+     0,
+     0}
+};
+
+typedef struct
+{
+    SDL_GLContext context;
+    SDL_bool updateSize;
+    SDL_bool GL_ARB_texture_rectangle_supported;
+    int blendMode;
+
+    /* OpenGL functions */
+#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
+#include "SDL_glfuncs.h"
+#undef SDL_PROC
+
+    void (*glTextureRangeAPPLE) (GLenum target, GLsizei length,
+                                 const GLvoid * pointer);
+} GL_RenderData;
+
+typedef struct
+{
+    GLuint texture;
+    GLenum type;
+    GLfloat texw;
+    GLfloat texh;
+    GLenum format;
+    GLenum formattype;
+    void *pixels;
+    int pitch;
+} GL_TextureData;
+
+
+static void
+GL_SetError(const char *prefix, GLenum result)
+{
+    const char *error;
+
+    switch (result) {
+    case GL_NO_ERROR:
+        error = "GL_NO_ERROR";
+        break;
+    case GL_INVALID_ENUM:
+        error = "GL_INVALID_ENUM";
+        break;
+    case GL_INVALID_VALUE:
+        error = "GL_INVALID_VALUE";
+        break;
+    case GL_INVALID_OPERATION:
+        error = "GL_INVALID_OPERATION";
+        break;
+    case GL_STACK_OVERFLOW:
+        error = "GL_STACK_OVERFLOW";
+        break;
+    case GL_STACK_UNDERFLOW:
+        error = "GL_STACK_UNDERFLOW";
+        break;
+    case GL_OUT_OF_MEMORY:
+        error = "GL_OUT_OF_MEMORY";
+        break;
+    case GL_TABLE_TOO_LARGE:
+        error = "GL_TABLE_TOO_LARGE";
+        break;
+    default:
+        error = "UNKNOWN";
+        break;
+    }
+    SDL_SetError("%s: %s", prefix, error);
+}
+
+static int
+GL_LoadFunctions(GL_RenderData * data)
+{
+#ifdef __SDL_NOGETPROCADDR__
+#define SDL_PROC(ret,func,params) data->func=func;
+#else
+#define SDL_PROC(ret,func,params) \
+    do { \
+        data->func = SDL_GL_GetProcAddress(#func); \
+        if ( ! data->func ) { \
+            SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \
+            return -1; \
+        } \
+    } while ( 0 );
+#endif /* __SDL_NOGETPROCADDR__ */
+
+#include "SDL_glfuncs.h"
+#undef SDL_PROC
+    return 0;
+}
+
+SDL_Renderer *
+GL_CreateRenderer(SDL_Window * window, Uint32 flags)
+{
+    SDL_Renderer *renderer;
+    GL_RenderData *data;
+    GLint value;
+    Uint32 window_flags;
+
+    window_flags = SDL_GetWindowFlags(window);
+    if (!(window_flags & SDL_WINDOW_OPENGL)) {
+        if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
+            return NULL;
+        }
+    }
+
+    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
+    if (!renderer) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    data = (GL_RenderData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        GL_DestroyRenderer(renderer);
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    renderer->WindowEvent = GL_WindowEvent;
+    renderer->CreateTexture = GL_CreateTexture;
+    renderer->UpdateTexture = GL_UpdateTexture;
+    renderer->LockTexture = GL_LockTexture;
+    renderer->UnlockTexture = GL_UnlockTexture;
+    renderer->RenderClear = GL_RenderClear;
+    renderer->RenderDrawPoints = GL_RenderDrawPoints;
+    renderer->RenderDrawLines = GL_RenderDrawLines;
+    renderer->RenderFillRects = GL_RenderFillRects;
+    renderer->RenderCopy = GL_RenderCopy;
+    renderer->RenderReadPixels = GL_RenderReadPixels;
+    renderer->RenderPresent = GL_RenderPresent;
+    renderer->DestroyTexture = GL_DestroyTexture;
+    renderer->DestroyRenderer = GL_DestroyRenderer;
+    renderer->info = GL_RenderDriver.info;
+    renderer->driverdata = data;
+
+    renderer->info.flags = SDL_RENDERER_ACCELERATED;
+
+    data->context = SDL_GL_CreateContext(window);
+    if (!data->context) {
+        GL_DestroyRenderer(renderer);
+        return NULL;
+    }
+    if (SDL_GL_MakeCurrent(window, data->context) < 0) {
+        GL_DestroyRenderer(renderer);
+        return NULL;
+    }
+
+    if (GL_LoadFunctions(data) < 0) {
+        GL_DestroyRenderer(renderer);
+        return NULL;
+    }
+
+#ifdef __MACOSX__
+    /* Enable multi-threaded rendering */
+    /* Disabled until Ryan finishes his VBO/PBO code...
+       CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine);
+     */
+#endif
+
+    if (flags & SDL_RENDERER_PRESENTVSYNC) {
+        SDL_GL_SetSwapInterval(1);
+    } else {
+        SDL_GL_SetSwapInterval(0);
+    }
+    if (SDL_GL_GetSwapInterval() > 0) {
+        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
+    }
+
+    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
+    renderer->info.max_texture_width = value;
+    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
+    renderer->info.max_texture_height = value;
+
+    if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")
+        || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
+        data->GL_ARB_texture_rectangle_supported = SDL_TRUE;
+    }
+    if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) {
+        data->glTextureRangeAPPLE =
+            (void (*)(GLenum, GLsizei, const GLvoid *))
+            SDL_GL_GetProcAddress("glTextureRangeAPPLE");
+    }
+
+    /* Set up parameters for rendering */
+    data->blendMode = -1;
+    data->glDisable(GL_DEPTH_TEST);
+    data->glDisable(GL_CULL_FACE);
+    /* This ended up causing video discrepancies between OpenGL and Direct3D */
+    /*data->glEnable(GL_LINE_SMOOTH);*/
+    if (data->GL_ARB_texture_rectangle_supported) {
+        data->glEnable(GL_TEXTURE_RECTANGLE_ARB);
+    } else {
+        data->glEnable(GL_TEXTURE_2D);
+    }
+    data->updateSize = SDL_TRUE;
+
+    return renderer;
+}
+
+static SDL_GLContext SDL_CurrentContext = NULL;
+
+static int
+GL_ActivateRenderer(SDL_Renderer * renderer)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+
+    if (SDL_CurrentContext != data->context) {
+        if (SDL_GL_MakeCurrent(window, data->context) < 0) {
+            return -1;
+        }
+        SDL_CurrentContext = data->context;
+    }
+    if (data->updateSize) {
+        int w, h;
+
+        SDL_GetWindowSize(window, &w, &h);
+        data->glMatrixMode(GL_PROJECTION);
+        data->glLoadIdentity();
+        data->glMatrixMode(GL_MODELVIEW);
+        data->glLoadIdentity();
+        data->glViewport(0, 0, w, h);
+        data->glOrtho(0.0, (GLdouble) w, (GLdouble) h, 0.0, 0.0, 1.0);
+        data->updateSize = SDL_FALSE;
+    }
+    return 0;
+}
+
+static void
+GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+
+    if (event->event == SDL_WINDOWEVENT_RESIZED) {
+        /* Rebind the context to the window area and update matrices */
+        SDL_CurrentContext = NULL;
+        data->updateSize = SDL_TRUE;
+    }
+}
+
+static __inline__ int
+power_of_2(int input)
+{
+    int value = 1;
+
+    while (value < input) {
+        value <<= 1;
+    }
+    return value;
+}
+
+static __inline__ SDL_bool
+convert_format(GL_RenderData *renderdata, Uint32 pixel_format,
+               GLint* internalFormat, GLenum* format, GLenum* type)
+{
+    switch (pixel_format) {
+    case SDL_PIXELFORMAT_ARGB8888:
+        *internalFormat = GL_RGBA8;
+        *format = GL_BGRA;
+        *type = GL_UNSIGNED_INT_8_8_8_8_REV;
+        break;
+    default:
+        return SDL_FALSE;
+    }
+    return SDL_TRUE;
+}
+
+static int
+GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
+    GL_TextureData *data;
+    GLint internalFormat;
+    GLenum format, type;
+    int texture_w, texture_h;
+    GLenum result;
+
+    GL_ActivateRenderer(renderer);
+
+    if (!convert_format(renderdata, texture->format, &internalFormat,
+                        &format, &type)) {
+        SDL_SetError("Texture format %s not supported by OpenGL",
+                     SDL_GetPixelFormatName(texture->format));
+        return -1;
+    }
+
+    data = (GL_TextureData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
+        data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
+        data->pixels = SDL_malloc(texture->h * data->pitch);
+        if (!data->pixels) {
+            SDL_OutOfMemory();
+            SDL_free(data);
+            return -1;
+        }
+    }
+
+    texture->driverdata = data;
+
+    renderdata->glGetError();
+    renderdata->glGenTextures(1, &data->texture);
+    if (renderdata->GL_ARB_texture_rectangle_supported) {
+        data->type = GL_TEXTURE_RECTANGLE_ARB;
+        texture_w = texture->w;
+        texture_h = texture->h;
+        data->texw = (GLfloat) texture_w;
+        data->texh = (GLfloat) texture_h;
+    } else {
+        data->type = GL_TEXTURE_2D;
+        texture_w = power_of_2(texture->w);
+        texture_h = power_of_2(texture->h);
+        data->texw = (GLfloat) (texture->w) / texture_w;
+        data->texh = (GLfloat) texture->h / texture_h;
+    }
+
+    data->format = format;
+    data->formattype = type;
+    renderdata->glEnable(data->type);
+    renderdata->glBindTexture(data->type, data->texture);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
+                                GL_LINEAR);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
+                                GL_LINEAR);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
+                                GL_CLAMP_TO_EDGE);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
+                                GL_CLAMP_TO_EDGE);
+#ifdef __MACOSX__
+#ifndef GL_TEXTURE_STORAGE_HINT_APPLE
+#define GL_TEXTURE_STORAGE_HINT_APPLE       0x85BC
+#endif
+#ifndef STORAGE_CACHED_APPLE
+#define STORAGE_CACHED_APPLE                0x85BE
+#endif
+#ifndef STORAGE_SHARED_APPLE
+#define STORAGE_SHARED_APPLE                0x85BF
+#endif
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
+                                    GL_STORAGE_SHARED_APPLE);
+    } else {
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
+                                    GL_STORAGE_CACHED_APPLE);
+    }
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING
+        && texture->format == SDL_PIXELFORMAT_ARGB8888) {
+        renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
+        renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
+                                 texture_h, 0, format, type, data->pixels);
+    }
+    else
+#endif
+    {
+        renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
+                                 texture_h, 0, format, type, NULL);
+    }
+    renderdata->glDisable(data->type);
+    result = renderdata->glGetError();
+    if (result != GL_NO_ERROR) {
+        GL_SetError("glTexImage2D()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static void
+SetupTextureUpdate(GL_RenderData * renderdata, SDL_Texture * texture,
+                   int pitch)
+{
+    renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH,
+                              (pitch / SDL_BYTESPERPIXEL(texture->format)));
+}
+
+static int
+GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                 const SDL_Rect * rect, const void *pixels, int pitch)
+{
+    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
+    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
+    GLenum result;
+
+    GL_ActivateRenderer(renderer);
+
+    renderdata->glGetError();
+    SetupTextureUpdate(renderdata, texture, pitch);
+    renderdata->glEnable(data->type);
+    renderdata->glBindTexture(data->type, data->texture);
+    renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
+                                rect->h, data->format, data->formattype,
+                                pixels);
+    renderdata->glDisable(data->type);
+    result = renderdata->glGetError();
+    if (result != GL_NO_ERROR) {
+        GL_SetError("glTexSubImage2D()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+               const SDL_Rect * rect, void **pixels, int *pitch)
+{
+    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
+
+    *pixels =
+        (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
+                  rect->x * SDL_BYTESPERPIXEL(texture->format));
+    *pitch = data->pitch;
+    return 0;
+}
+
+static void
+GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
+    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
+
+    GL_ActivateRenderer(renderer);
+
+    SetupTextureUpdate(renderdata, texture, data->pitch);
+    renderdata->glEnable(data->type);
+    renderdata->glBindTexture(data->type, data->texture);
+    renderdata->glTexSubImage2D(data->type, 0, 0, 0, texture->w, texture->h,
+                                data->format, data->formattype, data->pixels);
+    renderdata->glDisable(data->type);
+}
+
+static void
+GL_SetBlendMode(GL_RenderData * data, int blendMode)
+{
+    if (blendMode != data->blendMode) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_NONE:
+            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+            data->glDisable(GL_BLEND);
+            break;
+        case SDL_BLENDMODE_BLEND:
+            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+            data->glEnable(GL_BLEND);
+            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+            break;
+        case SDL_BLENDMODE_ADD:
+            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+            data->glEnable(GL_BLEND);
+            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+            break;
+        case SDL_BLENDMODE_MOD:
+            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+            data->glEnable(GL_BLEND);
+            data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
+            break;
+        }
+        data->blendMode = blendMode;
+    }
+}
+
+static int
+GL_RenderClear(SDL_Renderer * renderer)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+
+    GL_ActivateRenderer(renderer);
+
+    data->glClearColor((GLfloat) renderer->r * inv255f,
+                       (GLfloat) renderer->g * inv255f,
+                       (GLfloat) renderer->b * inv255f,
+                       (GLfloat) renderer->a * inv255f);
+
+    data->glClear(GL_COLOR_BUFFER_BIT);
+
+    return 0;
+}
+
+static int
+GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
+                    int count)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    int i;
+
+    GL_ActivateRenderer(renderer);
+
+    GL_SetBlendMode(data, renderer->blendMode);
+
+    data->glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    data->glBegin(GL_POINTS);
+    for (i = 0; i < count; ++i) {
+        data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
+    }
+    data->glEnd();
+
+    return 0;
+}
+
+static int
+GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
+                   int count)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    int i;
+
+    GL_ActivateRenderer(renderer);
+
+    GL_SetBlendMode(data, renderer->blendMode);
+
+    data->glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    if (count > 2 && 
+        points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
+        data->glBegin(GL_LINE_LOOP);
+        /* GL_LINE_LOOP takes care of the final segment */
+        --count;
+        for (i = 0; i < count; ++i) {
+            data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
+        }
+        data->glEnd();
+    } else {
+#if defined(__APPLE__) || defined(__WIN32__)
+#else
+        int x1, y1, x2, y2;
+#endif
+
+        data->glBegin(GL_LINE_STRIP);
+        for (i = 0; i < count; ++i) {
+            data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
+        }
+        data->glEnd();
+
+        /* The line is half open, so we need one more point to complete it.
+         * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html
+         * If we have to, we can use vertical line and horizontal line textures
+         * for vertical and horizontal lines, and then create custom textures
+         * for diagonal lines and software render those.  It's terrible, but at
+         * least it would be pixel perfect.
+         */
+        data->glBegin(GL_POINTS);
+#if defined(__APPLE__) || defined(__WIN32__)
+        /* Mac OS X and Windows seem to always leave the second point open */
+        data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y);
+#else
+        /* Linux seems to leave the right-most or bottom-most point open */
+        x1 = points[0].x;
+        y1 = points[0].y;
+        x2 = points[count-1].x;
+        y2 = points[count-1].y;
+
+        if (x1 > x2) {
+            data->glVertex2f(0.5f + x1, 0.5f + y1);
+        } else if (x2 > x1) {
+            data->glVertex2f(0.5f + x2, 0.5f + y2);
+        } else if (y1 > y2) {
+            data->glVertex2f(0.5f + x1, 0.5f + y1);
+        } else if (y2 > y1) {
+            data->glVertex2f(0.5f + x2, 0.5f + y2);
+        }
+#endif
+        data->glEnd();
+    }
+
+    return 0;
+}
+
+static int
+GL_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    int i;
+
+    GL_ActivateRenderer(renderer);
+
+    GL_SetBlendMode(data, renderer->blendMode);
+
+    data->glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    for (i = 0; i < count; ++i) {
+        const SDL_Rect *rect = rects[i];
+
+        data->glRecti(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
+    }
+
+    return 0;
+}
+
+static int
+GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
+    int minx, miny, maxx, maxy;
+    GLfloat minu, maxu, minv, maxv;
+
+    GL_ActivateRenderer(renderer);
+
+    minx = dstrect->x;
+    miny = dstrect->y;
+    maxx = dstrect->x + dstrect->w;
+    maxy = dstrect->y + dstrect->h;
+
+    minu = (GLfloat) srcrect->x / texture->w;
+    minu *= texturedata->texw;
+    maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
+    maxu *= texturedata->texw;
+    minv = (GLfloat) srcrect->y / texture->h;
+    minv *= texturedata->texh;
+    maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
+    maxv *= texturedata->texh;
+
+    data->glEnable(texturedata->type);
+    data->glBindTexture(texturedata->type, texturedata->texture);
+
+    if (texture->modMode) {
+        data->glColor4f((GLfloat) texture->r * inv255f,
+                        (GLfloat) texture->g * inv255f,
+                        (GLfloat) texture->b * inv255f,
+                        (GLfloat) texture->a * inv255f);
+    } else {
+        data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+    }
+
+    GL_SetBlendMode(data, texture->blendMode);
+
+    data->glBegin(GL_TRIANGLE_STRIP);
+    data->glTexCoord2f(minu, minv);
+    data->glVertex2f((GLfloat) minx, (GLfloat) miny);
+    data->glTexCoord2f(maxu, minv);
+    data->glVertex2f((GLfloat) maxx, (GLfloat) miny);
+    data->glTexCoord2f(minu, maxv);
+    data->glVertex2f((GLfloat) minx, (GLfloat) maxy);
+    data->glTexCoord2f(maxu, maxv);
+    data->glVertex2f((GLfloat) maxx, (GLfloat) maxy);
+    data->glEnd();
+
+    data->glDisable(texturedata->type);
+
+    return 0;
+}
+
+static int
+GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                    Uint32 pixel_format, void * pixels, int pitch)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+    GLint internalFormat;
+    GLenum format, type;
+    Uint8 *src, *dst, *tmp;
+    int w, h, length, rows;
+
+    GL_ActivateRenderer(renderer);
+
+    if (!convert_format(data, pixel_format, &internalFormat, &format, &type)) {
+        /* FIXME: Do a temp copy to a format that is supported */
+        SDL_SetError("Unsupported pixel format");
+        return -1;
+    }
+
+    SDL_GetWindowSize(window, &w, &h);
+
+    data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
+    data->glPixelStorei(GL_PACK_ROW_LENGTH,
+                        (pitch / SDL_BYTESPERPIXEL(pixel_format)));
+
+    data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h,
+                       format, type, pixels);
+
+    /* Flip the rows to be top-down */
+    length = rect->w * SDL_BYTESPERPIXEL(pixel_format);
+    src = (Uint8*)pixels + (rect->h-1)*pitch;
+    dst = (Uint8*)pixels;
+    tmp = SDL_stack_alloc(Uint8, length);
+    rows = rect->h / 2;
+    while (rows--) {
+        SDL_memcpy(tmp, dst, length);
+        SDL_memcpy(dst, src, length);
+        SDL_memcpy(src, tmp, length);
+        dst += pitch;
+        src -= pitch;
+    }
+    SDL_stack_free(tmp);
+
+    return 0;
+}
+
+static void
+GL_RenderPresent(SDL_Renderer * renderer)
+{
+    GL_ActivateRenderer(renderer);
+
+    SDL_GL_SwapWindow(renderer->window);
+}
+
+static void
+GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
+    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
+
+    GL_ActivateRenderer(renderer);
+
+    if (!data) {
+        return;
+    }
+    if (data->texture) {
+        renderdata->glDeleteTextures(1, &data->texture);
+    }
+    if (data->pixels) {
+        SDL_free(data->pixels);
+    }
+    SDL_free(data);
+    texture->driverdata = NULL;
+}
+
+static void
+GL_DestroyRenderer(SDL_Renderer * renderer)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+
+    if (data) {
+        if (data->context) {
+            /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */
+            SDL_GL_DeleteContext(data->context);
+        }
+        SDL_free(data);
+    }
+    SDL_free(renderer);
+}
+
+#endif /* SDL_VIDEO_RENDER_OGL */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/opengles/SDL_render_gles.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,715 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#if SDL_VIDEO_RENDER_OGL_ES
+
+#include "SDL_opengles.h"
+#include "../SDL_sysrender.h"
+
+#if defined(SDL_VIDEO_DRIVER_PANDORA)
+
+/* Empty function stub to get OpenGL ES 1.x support without  */
+/* OpenGL ES extension GL_OES_draw_texture supported         */
+GL_API void GL_APIENTRY
+glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
+{
+    return;
+}
+
+#endif /* PANDORA */
+
+/* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */
+
+/* Used to re-create the window with OpenGL capability */
+extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
+
+static const float inv255f = 1.0f / 255.0f;
+
+static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags);
+static void GLES_WindowEvent(SDL_Renderer * renderer,
+                             const SDL_WindowEvent *event);
+static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                              const SDL_Rect * rect, const void *pixels,
+                              int pitch);
+static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                            const SDL_Rect * rect, void **pixels, int *pitch);
+static void GLES_UnlockTexture(SDL_Renderer * renderer,
+                               SDL_Texture * texture);
+static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
+                                 const SDL_Point * points, int count);
+static int GLES_RenderDrawLines(SDL_Renderer * renderer,
+                                const SDL_Point * points, int count);
+static int GLES_RenderFillRects(SDL_Renderer * renderer,
+                                const SDL_Rect ** rects, int count);
+static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+                           const SDL_Rect * srcrect,
+                           const SDL_Rect * dstrect);
+static void GLES_RenderPresent(SDL_Renderer * renderer);
+static void GLES_DestroyTexture(SDL_Renderer * renderer,
+                                SDL_Texture * texture);
+static void GLES_DestroyRenderer(SDL_Renderer * renderer);
+
+
+SDL_RenderDriver GLES_RenderDriver = {
+    GLES_CreateRenderer,
+    {
+     "opengles",
+     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
+     1,
+     {SDL_PIXELFORMAT_ABGR8888},
+     0,
+     0}
+};
+
+typedef struct
+{
+    SDL_GLContext context;
+    SDL_bool updateSize;
+    int blendMode;
+
+    SDL_bool useDrawTexture;
+    SDL_bool GL_OES_draw_texture_supported;
+} GLES_RenderData;
+
+typedef struct
+{
+    GLuint texture;
+    GLenum type;
+    GLfloat texw;
+    GLfloat texh;
+    GLenum format;
+    GLenum formattype;
+    void *pixels;
+    int pitch;
+} GLES_TextureData;
+
+static void
+GLES_SetError(const char *prefix, GLenum result)
+{
+    const char *error;
+
+    switch (result) {
+    case GL_NO_ERROR:
+        error = "GL_NO_ERROR";
+        break;
+    case GL_INVALID_ENUM:
+        error = "GL_INVALID_ENUM";
+        break;
+    case GL_INVALID_VALUE:
+        error = "GL_INVALID_VALUE";
+        break;
+    case GL_INVALID_OPERATION:
+        error = "GL_INVALID_OPERATION";
+        break;
+    case GL_STACK_OVERFLOW:
+        error = "GL_STACK_OVERFLOW";
+        break;
+    case GL_STACK_UNDERFLOW:
+        error = "GL_STACK_UNDERFLOW";
+        break;
+    case GL_OUT_OF_MEMORY:
+        error = "GL_OUT_OF_MEMORY";
+        break;
+    default:
+        error = "UNKNOWN";
+        break;
+    }
+    SDL_SetError("%s: %s", prefix, error);
+}
+
+SDL_Renderer *
+GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
+{
+
+    SDL_Renderer *renderer;
+    GLES_RenderData *data;
+    GLint value;
+    Uint32 window_flags;
+
+    window_flags = SDL_GetWindowFlags(window);
+    if (!(window_flags & SDL_WINDOW_OPENGL)) {
+        if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
+            return NULL;
+        }
+    }
+
+    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
+    if (!renderer) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        GLES_DestroyRenderer(renderer);
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    renderer->WindowEvent = GLES_WindowEvent;
+    renderer->CreateTexture = GLES_CreateTexture;
+    renderer->UpdateTexture = GLES_UpdateTexture;
+    renderer->LockTexture = GLES_LockTexture;
+    renderer->UnlockTexture = GLES_UnlockTexture;
+    renderer->RenderDrawPoints = GLES_RenderDrawPoints;
+    renderer->RenderDrawLines = GLES_RenderDrawLines;
+    renderer->RenderFillRects = GLES_RenderFillRects;
+    renderer->RenderCopy = GLES_RenderCopy;
+    renderer->RenderPresent = GLES_RenderPresent;
+    renderer->DestroyTexture = GLES_DestroyTexture;
+    renderer->DestroyRenderer = GLES_DestroyRenderer;
+    renderer->info = GLES_RenderDriver.info;
+    renderer->driverdata = data;
+
+    renderer->info.flags = SDL_RENDERER_ACCELERATED;
+
+    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
+    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
+
+    data->context = SDL_GL_CreateContext(window);
+    if (!data->context) {
+        GLES_DestroyRenderer(renderer);
+        return NULL;
+    }
+    if (SDL_GL_MakeCurrent(window, data->context) < 0) {
+        GLES_DestroyRenderer(renderer);
+        return NULL;
+    }
+
+    if (flags & SDL_RENDERER_PRESENTVSYNC) {
+        SDL_GL_SetSwapInterval(1);
+    } else {
+        SDL_GL_SetSwapInterval(0);
+    }
+    if (SDL_GL_GetSwapInterval() > 0) {
+        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
+    }
+
+#if SDL_VIDEO_DRIVER_PANDORA
+    data->GL_OES_draw_texture_supported = SDL_FALSE;
+    data->useDrawTexture = SDL_FALSE;
+#else
+    if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) {
+        data->GL_OES_draw_texture_supported = SDL_TRUE;
+        data->useDrawTexture = SDL_TRUE;
+    } else {
+        data->GL_OES_draw_texture_supported = SDL_FALSE;
+        data->useDrawTexture = SDL_FALSE;
+    }
+#endif
+
+    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
+    renderer->info.max_texture_width = value;
+    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
+    renderer->info.max_texture_height = value;
+
+    /* Set up parameters for rendering */
+    data->blendMode = -1;
+    glDisable(GL_DEPTH_TEST);
+    glDisable(GL_CULL_FACE);
+    data->updateSize = SDL_TRUE;
+
+    glEnableClientState(GL_VERTEX_ARRAY);
+    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+    
+    return renderer;
+}
+
+static SDL_GLContext SDL_CurrentContext = NULL;
+
+static int
+GLES_ActivateRenderer(SDL_Renderer * renderer)
+{
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+
+    if (SDL_CurrentContext != data->context) {
+        if (SDL_GL_MakeCurrent(window, data->context) < 0) {
+            return -1;
+        }
+        SDL_CurrentContext = data->context;
+    }
+    if (data->updateSize) {
+        int w, h;
+
+        SDL_GetWindowSize(window, &w, &h);
+        glMatrixMode(GL_PROJECTION);
+        glLoadIdentity();
+        glMatrixMode(GL_MODELVIEW);
+        glLoadIdentity();
+        glViewport(0, 0, w, h);
+        glOrthof(0.0, (GLfloat) w, (GLfloat) h, 0.0, 0.0, 1.0);
+        data->updateSize = SDL_FALSE;
+    }
+    return 0;
+}
+
+static void
+GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
+{
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+
+    if (event->event == SDL_WINDOWEVENT_RESIZED) {
+        /* Rebind the context to the window area and update matrices */
+        SDL_CurrentContext = NULL;
+        data->updateSize = SDL_TRUE;
+    }
+}
+
+static __inline__ int
+power_of_2(int input)
+{
+    int value = 1;
+
+    while (value < input) {
+        value <<= 1;
+    }
+    return value;
+}
+
+static int
+GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
+    GLES_TextureData *data;
+    GLint internalFormat;
+    GLenum format, type;
+    int texture_w, texture_h;
+    GLenum result;
+
+    GLES_ActivateRenderer(renderer);
+
+    switch (texture->format) {
+    case SDL_PIXELFORMAT_ABGR8888:
+        internalFormat = GL_RGBA;
+        format = GL_RGBA;
+        type = GL_UNSIGNED_BYTE;
+        break;
+    default:
+        SDL_SetError("Texture format not supported");
+        return -1;
+    }
+
+    data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
+        data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
+        data->pixels = SDL_malloc(texture->h * data->pitch);
+        if (!data->pixels) {
+            SDL_OutOfMemory();
+            SDL_free(data);
+            return -1;
+        }
+    }
+
+    texture->driverdata = data;
+
+    glGetError();
+    glEnable(GL_TEXTURE_2D);
+    glGenTextures(1, &data->texture);
+
+    data->type = GL_TEXTURE_2D;
+    /* no NPOV textures allowed in OpenGL ES (yet) */
+    texture_w = power_of_2(texture->w);
+    texture_h = power_of_2(texture->h);
+    data->texw = (GLfloat) texture->w / texture_w;
+    data->texh = (GLfloat) texture->h / texture_h;
+
+    data->format = format;
+    data->formattype = type;
+    glBindTexture(data->type, data->texture);
+    glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
+                                GL_LINEAR);
+    glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
+                                GL_LINEAR);
+    glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
+                                GL_CLAMP_TO_EDGE);
+    glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
+                                GL_CLAMP_TO_EDGE);
+
+    glTexImage2D(data->type, 0, internalFormat, texture_w,
+                             texture_h, 0, format, type, NULL);
+    glDisable(GL_TEXTURE_2D);
+
+    result = glGetError();
+    if (result != GL_NO_ERROR) {
+        GLES_SetError("glTexImage2D()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                   const SDL_Rect * rect, const void *pixels, int pitch)
+{
+    GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
+    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
+    GLenum result;
+    int bpp = SDL_BYTESPERPIXEL(texture->format);
+    void * temp_buffer;
+    void * temp_ptr;
+    int i;
+
+    GLES_ActivateRenderer(renderer);
+
+    glGetError();
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    glEnable(data->type);
+    glBindTexture(data->type, data->texture);
+
+    if( rect->w * bpp == pitch ) {
+         temp_buffer = (void *)pixels; /* No need to reformat */
+    } else {
+         /* Reformatting of mem area required */
+         temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
+         temp_ptr = temp_buffer;
+         for (i = 0; i < rect->h; i++) {
+             SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
+             temp_ptr += rect->w * bpp;
+             pixels += pitch;
+         }
+    }
+
+    glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
+                                rect->h, data->format, data->formattype,
+                                temp_buffer);
+
+    if( temp_buffer != pixels ) {
+        SDL_free(temp_buffer);
+    }
+
+    glDisable(data->type);
+    result = glGetError();
+    if (result != GL_NO_ERROR) {
+        GLES_SetError("glTexSubImage2D()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                 const SDL_Rect * rect, void **pixels, int *pitch)
+{
+    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
+
+    *pixels =
+        (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
+                  rect->x * SDL_BYTESPERPIXEL(texture->format));
+    *pitch = data->pitch;
+    return 0;
+}
+
+static void
+GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
+    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
+
+    GLES_ActivateRenderer(renderer);
+
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    glEnable(data->type);
+    glBindTexture(data->type, data->texture);
+    glTexSubImage2D(data->type, 0, 0, 0, texture->w,
+                                texture->h, data->format, data->formattype,
+                                data->pixels);
+    glDisable(data->type);
+}
+
+static void
+GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
+{
+    if (blendMode != data->blendMode) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_NONE:
+            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+            glDisable(GL_BLEND);
+            break;
+        case SDL_BLENDMODE_BLEND:
+            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+            glEnable(GL_BLEND);
+            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+            break;
+        case SDL_BLENDMODE_ADD:
+            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+            glEnable(GL_BLEND);
+            glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+            break;
+        case SDL_BLENDMODE_MOD:
+            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+            glEnable(GL_BLEND);
+            glBlendFunc(GL_ZERO, GL_SRC_COLOR);
+            break;
+        }
+        data->blendMode = blendMode;
+    }
+}
+
+static int
+GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
+                      int count)
+{
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+    int i;
+    GLshort *vertices;
+
+    GLES_ActivateRenderer(renderer);
+
+    GLES_SetBlendMode(data, renderer->blendMode);
+
+    glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    vertices = SDL_stack_alloc(GLshort, count*2);
+    for (i = 0; i < count; ++i) {
+        vertices[2*i+0] = (GLshort)points[i].x;
+        vertices[2*i+1] = (GLshort)points[i].y;
+    }
+    glVertexPointer(2, GL_SHORT, 0, vertices);
+    glDrawArrays(GL_POINTS, 0, count);
+    SDL_stack_free(vertices);
+
+    return 0;
+}
+
+static int
+GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
+                     int count)
+{
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+    int i;
+    GLshort *vertices;
+
+    GLES_ActivateRenderer(renderer);
+
+    GLES_SetBlendMode(data, renderer->blendMode);
+
+    glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    vertices = SDL_stack_alloc(GLshort, count*2);
+    for (i = 0; i < count; ++i) {
+        vertices[2*i+0] = (GLshort)points[i].x;
+        vertices[2*i+1] = (GLshort)points[i].y;
+    }
+    glVertexPointer(2, GL_SHORT, 0, vertices);
+    if (count > 2 && 
+        points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
+        /* GL_LINE_LOOP takes care of the final segment */
+        --count;
+        glDrawArrays(GL_LINE_LOOP, 0, count);
+    } else {
+        glDrawArrays(GL_LINE_STRIP, 0, count);
+    }
+    SDL_stack_free(vertices);
+
+    return 0;
+}
+
+static int
+GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
+                     int count)
+{
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+    int i;
+
+    GLES_ActivateRenderer(renderer);
+
+    GLES_SetBlendMode(data, renderer->blendMode);
+
+    glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    for (i = 0; i < count; ++i) {
+        const SDL_Rect *rect = rects[i];
+        GLshort minx = rect->x;
+        GLshort maxx = rect->x + rect->w;
+        GLshort miny = rect->y;
+        GLshort maxy = rect->y + rect->h;
+        GLshort vertices[8];
+        vertices[0] = minx;
+        vertices[1] = miny;
+        vertices[2] = maxx;
+        vertices[3] = miny;
+        vertices[4] = minx;
+        vertices[5] = maxy;
+        vertices[6] = maxx;
+        vertices[7] = maxy;
+
+        glVertexPointer(2, GL_SHORT, 0, vertices);
+        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+    }
+
+    return 0;
+}
+
+static int
+GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+                const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+{
+
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+    GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
+    int minx, miny, maxx, maxy;
+    GLfloat minu, maxu, minv, maxv;
+    int i;
+    void *temp_buffer;          /* used for reformatting dirty rect pixels */
+    void *temp_ptr;
+
+    GLES_ActivateRenderer(renderer);
+
+    glEnable(GL_TEXTURE_2D);
+
+    glBindTexture(texturedata->type, texturedata->texture);
+
+    if (texture->modMode) {
+        glColor4f((GLfloat) texture->r * inv255f,
+                        (GLfloat) texture->g * inv255f,
+                        (GLfloat) texture->b * inv255f,
+                        (GLfloat) texture->a * inv255f);
+    } else {
+        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+    }
+
+    GLES_SetBlendMode(data, texture->blendMode);
+
+    if (data->GL_OES_draw_texture_supported && data->useDrawTexture) {
+        /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */
+        GLint cropRect[4];
+        int w, h;
+        SDL_Window *window = renderer->window;
+
+        SDL_GetWindowSize(window, &w, &h);
+        cropRect[0] = srcrect->x;
+        cropRect[1] = srcrect->y + srcrect->h;
+        cropRect[2] = srcrect->w;
+        cropRect[3] = -srcrect->h;
+        glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
+                               cropRect);
+        glDrawTexiOES(dstrect->x, h - dstrect->y - dstrect->h, 0,
+                            dstrect->w, dstrect->h);
+    } else {
+
+        minx = dstrect->x;
+        miny = dstrect->y;
+        maxx = dstrect->x + dstrect->w;
+        maxy = dstrect->y + dstrect->h;
+
+        minu = (GLfloat) srcrect->x / texture->w;
+        minu *= texturedata->texw;
+        maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
+        maxu *= texturedata->texw;
+        minv = (GLfloat) srcrect->y / texture->h;
+        minv *= texturedata->texh;
+        maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
+        maxv *= texturedata->texh;
+
+        GLshort vertices[8];
+        GLfloat texCoords[8];
+
+        vertices[0] = minx;
+        vertices[1] = miny;
+        vertices[2] = maxx;
+        vertices[3] = miny;
+        vertices[4] = minx;
+        vertices[5] = maxy;
+        vertices[6] = maxx;
+        vertices[7] = maxy;
+
+        texCoords[0] = minu;
+        texCoords[1] = minv;
+        texCoords[2] = maxu;
+        texCoords[3] = minv;
+        texCoords[4] = minu;
+        texCoords[5] = maxv;
+        texCoords[6] = maxu;
+        texCoords[7] = maxv;
+
+        glVertexPointer(2, GL_SHORT, 0, vertices);
+        glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
+        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+    }
+
+    glDisable(GL_TEXTURE_2D);
+
+    return 0;
+}
+
+static void
+GLES_RenderPresent(SDL_Renderer * renderer)
+{
+    GLES_ActivateRenderer(renderer);
+
+    SDL_GL_SwapWindow(renderer->window);
+}
+
+static void
+GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
+
+    GLES_ActivateRenderer(renderer);
+
+    if (!data) {
+        return;
+    }
+    if (data->texture) {
+        glDeleteTextures(1, &data->texture);
+    }
+    if (data->pixels) {
+        SDL_free(data->pixels);
+    }
+    SDL_free(data);
+    texture->driverdata = NULL;
+}
+
+static void
+GLES_DestroyRenderer(SDL_Renderer * renderer)
+{
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+
+    if (data) {
+        if (data->context) {
+            SDL_GL_DeleteContext(data->context);
+        }
+        SDL_free(data);
+    }
+    SDL_free(renderer);
+}
+
+#endif /* SDL_VIDEO_RENDER_OGL_ES */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/opengles2/SDL_render_gles2.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,1176 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 2010 itsnotabigtruck.
+
+    Permission is hereby granted, free of charge, to any person obtaining a
+    copy of this software and associated documentation files (the "Software"),
+    to deal in the Software without restriction, including without limitation
+    the rights to use, copy, modify, merge, publish, distribute, sublicense,
+    and/or sell copies of the Software, and to permit persons to whom the
+    Software is furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+    DEALINGS IN THE SOFTWARE.
+*/
+
+#include "SDL_config.h"
+
+#if SDL_VIDEO_RENDER_OGL_ES2
+
+#include "SDL_opengles2.h"
+#include "../SDL_sysrender.h"
+#include "SDL_shaders_gles2.h"
+
+/*************************************************************************************************
+ * Bootstrap data                                                                                *
+ *************************************************************************************************/
+
+static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags);
+
+SDL_RenderDriver GLES2_RenderDriver = {
+    GLES2_CreateRenderer,
+    {
+        "opengles2",
+        (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
+        1,
+        {SDL_PIXELFORMAT_ABGR8888},
+        0,
+        0
+    }
+};
+
+/*************************************************************************************************
+ * Context structures                                                                            *
+ *************************************************************************************************/
+
+typedef struct GLES2_TextureData
+{
+    GLenum texture;
+    GLenum texture_type;
+    GLenum pixel_format;
+    GLenum pixel_type;
+    void *pixel_data;
+    size_t pitch;
+} GLES2_TextureData;
+
+typedef struct GLES2_ShaderCacheEntry
+{
+    GLuint id;
+    GLES2_ShaderType type;
+    const GLES2_ShaderInstance *instance;
+    int references;
+    struct GLES2_ShaderCacheEntry *prev;
+    struct GLES2_ShaderCacheEntry *next;
+} GLES2_ShaderCacheEntry;
+
+typedef struct GLES2_ShaderCache
+{
+    int count;
+    GLES2_ShaderCacheEntry *head;
+} GLES2_ShaderCache;
+
+typedef struct GLES2_ProgramCacheEntry
+{
+    GLuint id;
+    SDL_BlendMode blend_mode;
+    GLES2_ShaderCacheEntry *vertex_shader;
+    GLES2_ShaderCacheEntry *fragment_shader;
+    GLuint uniform_locations[16];
+    struct GLES2_ProgramCacheEntry *prev;
+    struct GLES2_ProgramCacheEntry *next;
+} GLES2_ProgramCacheEntry;
+
+typedef struct GLES2_ProgramCache
+{
+    int count;
+    GLES2_ProgramCacheEntry *head;
+    GLES2_ProgramCacheEntry *tail;
+} GLES2_ProgramCache;
+
+typedef enum
+{
+    GLES2_ATTRIBUTE_POSITION = 0,
+    GLES2_ATTRIBUTE_TEXCOORD = 1
+} GLES2_Attribute;
+
+typedef enum
+{
+    GLES2_UNIFORM_PROJECTION,
+    GLES2_UNIFORM_TEXTURE,
+    GLES2_UNIFORM_MODULATION,
+    GLES2_UNIFORM_COLOR,
+    GLES2_UNIFORM_COLORTABLE
+} GLES2_Uniform;
+
+typedef enum
+{
+    GLES2_IMAGESOURCE_SOLID,
+    GLES2_IMAGESOURCE_TEXTURE
+} GLES2_ImageSource;
+
+typedef struct GLES2_DriverContext
+{
+    SDL_GLContext *context;
+    int shader_format_count;
+    GLenum *shader_formats;
+    GLES2_ShaderCache shader_cache;
+    GLES2_ProgramCache program_cache;
+    GLES2_ProgramCacheEntry *current_program;
+	SDL_bool updateSize;
+} GLES2_DriverContext;
+
+#define GLES2_MAX_CACHED_PROGRAMS 8
+
+/*************************************************************************************************
+ * Renderer state APIs                                                                           *
+ *************************************************************************************************/
+
+static void GLES2_WindowEvent(SDL_Renderer * renderer,
+                              const SDL_WindowEvent *event);
+static int GLES2_ActivateRenderer(SDL_Renderer *renderer);
+static int GLES2_DisplayModeChanged(SDL_Renderer *renderer);
+static void GLES2_DestroyRenderer(SDL_Renderer *renderer);
+
+static SDL_GLContext SDL_CurrentContext = NULL;
+
+static int
+GLES2_ActivateRenderer(SDL_Renderer * renderer)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+    SDL_Window *window = renderer->window;
+
+    if (SDL_CurrentContext != rdata->context) {
+        /* Null out the current program to ensure we set it again */
+        rdata->current_program = NULL;
+
+        if (SDL_GL_MakeCurrent(window, rdata->context) < 0) {
+            return -1;
+        }
+        SDL_CurrentContext = rdata->context;
+    }
+    if (rdata->updateSize) {
+        int w, h;
+
+        SDL_GetWindowSize(window, &w, &h);
+        glViewport(0, 0, w, h);
+        rdata->updateSize = SDL_FALSE;
+    }
+    return 0;
+}
+
+static void
+GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+
+    if (event->event == SDL_WINDOWEVENT_RESIZED) {
+        /* Rebind the context to the window area */
+        SDL_CurrentContext = NULL;
+        rdata->updateSize = SDL_TRUE;
+    }
+}
+
+static void
+GLES2_DestroyRenderer(SDL_Renderer *renderer)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+    GLES2_ProgramCacheEntry *entry;
+    GLES2_ProgramCacheEntry *next;
+
+    /* Deallocate everything */
+    if (rdata) {
+        GLES2_ActivateRenderer(renderer);
+
+        entry = rdata->program_cache.head;
+        while (entry) {
+            glDeleteShader(entry->vertex_shader->id);
+            glDeleteShader(entry->fragment_shader->id);
+            SDL_free(entry->vertex_shader);
+            SDL_free(entry->fragment_shader);
+            glDeleteProgram(entry->id);
+            next = entry->next;
+            SDL_free(entry);
+            entry = next;
+        }
+        if (rdata->context) {
+            SDL_GL_DeleteContext(rdata->context);
+        }
+        if (rdata->shader_formats) {
+            SDL_free(rdata->shader_formats);
+        }
+        SDL_free(rdata);
+    }
+    SDL_free(renderer);
+}
+
+/*************************************************************************************************
+ * Texture APIs                                                                                  *
+ *************************************************************************************************/
+
+static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture);
+static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture);
+static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
+                             void **pixels, int *pitch);
+static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture);
+static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
+                               const void *pixels, int pitch);
+
+static int
+GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+    GLES2_TextureData *tdata;
+    GLenum format;
+    GLenum type;
+
+    GLES2_ActivateRenderer(renderer);
+
+    /* Determine the corresponding GLES texture format params */
+    switch (texture->format)
+    {
+    case SDL_PIXELFORMAT_ABGR8888:
+        format = GL_RGBA;
+        type = GL_UNSIGNED_BYTE;
+        break;
+    default:
+        SDL_SetError("Texture format not supported");
+        return -1;
+    }
+
+    /* Allocate a texture struct */
+    tdata = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData));
+    if (!tdata)
+    {
+        SDL_OutOfMemory();
+        return -1;
+    }
+    tdata->texture = 0;
+    tdata->texture_type = GL_TEXTURE_2D;
+    tdata->pixel_format = format;
+    tdata->pixel_type = type;
+
+    /* Allocate a blob for image data */
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING)
+    {
+        tdata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
+        tdata->pixel_data = SDL_malloc(tdata->pitch * texture->h);
+        if (!tdata->pixel_data)
+        {
+            SDL_OutOfMemory();
+            SDL_free(tdata);
+            return -1;
+        }
+    }
+
+    /* Allocate the texture */
+    glGetError();
+    glGenTextures(1, &tdata->texture);
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(tdata->texture_type, tdata->texture);
+    glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
+    if (glGetError() != GL_NO_ERROR)
+    {
+        SDL_SetError("Texture creation failed");
+        glDeleteTextures(1, &tdata->texture);
+        SDL_free(tdata);
+        return -1;
+    }
+    texture->driverdata = tdata;
+    return 0;
+}
+
+static void
+GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
+{
+    GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
+
+    GLES2_ActivateRenderer(renderer);
+
+    /* Destroy the texture */
+    if (tdata)
+    {
+        glDeleteTextures(1, &tdata->texture);
+        SDL_free(tdata->pixel_data);
+        SDL_free(tdata);
+        texture->driverdata = NULL;
+    }
+}
+
+static int
+GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
+                  void **pixels, int *pitch)
+{
+    GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
+
+    /* Retrieve the buffer/pitch for the specified region */
+    *pixels = (Uint8 *)tdata->pixel_data +
+              (tdata->pitch * rect->y) +
+              (rect->x * SDL_BYTESPERPIXEL(texture->format));
+    *pitch = tdata->pitch;
+
+    return 0;
+}
+
+static void
+GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
+{
+    GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
+
+    GLES2_ActivateRenderer(renderer);
+
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(tdata->texture_type, tdata->texture);
+    glTexSubImage2D(tdata->texture_type, 0, 0, 0, texture->w, texture->h,
+                    tdata->pixel_format, tdata->pixel_type, tdata->pixel_data);
+}
+
+static int
+GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
+                    const void *pixels, int pitch)
+{
+    GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
+    Uint8 *blob = NULL;
+    Uint8 *src;
+    int srcPitch;
+    Uint8 *dest;
+    int y;
+
+    GLES2_ActivateRenderer(renderer);
+
+    /* Bail out if we're supposed to update an empty rectangle */
+    if (rect->w <= 0 || rect->h <= 0)
+        return 0;
+
+    /* Reformat the texture data into a tightly packed array */
+    srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format);
+    src = (Uint8 *)pixels;
+    if (pitch != srcPitch)
+    {
+        blob = (Uint8 *)SDL_malloc(srcPitch * rect->h);
+        if (!blob)
+        {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        src = blob;
+        for (y = 0; y < rect->h; ++y)
+        {
+            SDL_memcpy(src, pixels, srcPitch);
+            src += srcPitch;
+            pixels = (Uint8 *)pixels + pitch;
+        }
+        src = blob;
+    }
+
+    /* Create a texture subimage with the supplied data */
+    glGetError();
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(tdata->texture_type, tdata->texture);
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    glTexSubImage2D(tdata->texture_type,
+                    0,
+                    rect->x,
+                    rect->y,
+                    rect->w,
+                    rect->h,
+                    tdata->pixel_format,
+                    tdata->pixel_type,
+                    src);
+    SDL_free(blob);
+
+    if (glGetError() != GL_NO_ERROR)
+    {
+        SDL_SetError("Failed to update texture");
+        return -1;
+    }
+    return 0;
+}
+
+/*************************************************************************************************
+ * Shader management functions                                                                   *
+ *************************************************************************************************/
+
+static GLES2_ShaderCacheEntry *GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type,
+                                                 SDL_BlendMode blendMode);
+static void GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry);
+static GLES2_ProgramCacheEntry *GLES2_CacheProgram(SDL_Renderer *renderer,
+                                                   GLES2_ShaderCacheEntry *vertex,
+                                                   GLES2_ShaderCacheEntry *fragment,
+                                                   SDL_BlendMode blendMode);
+static int GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source,
+                               SDL_BlendMode blendMode);
+static int GLES2_SetOrthographicProjection(SDL_Renderer *renderer);
+
+static GLES2_ProgramCacheEntry *
+GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex,
+                   GLES2_ShaderCacheEntry *fragment, SDL_BlendMode blendMode)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+    GLES2_ProgramCacheEntry *entry;
+    GLES2_ShaderCacheEntry *shaderEntry;
+    GLint linkSuccessful;
+
+    /* Check if we've already cached this program */
+    entry = rdata->program_cache.head;
+    while (entry)
+    {
+        if (entry->vertex_shader == vertex && entry->fragment_shader == fragment)
+            break;
+        entry = entry->next;
+    }
+    if (entry)
+    {
+        if (rdata->program_cache.count > 1)
+        {
+            if (entry->next)
+                entry->next->prev = entry->prev;
+            if (entry->prev)
+                entry->prev->next = entry->next;
+            entry->prev = NULL;
+            entry->next = rdata->program_cache.head;
+            rdata->program_cache.head->prev = entry;
+            rdata->program_cache.head = entry;
+        }
+        return entry;
+    }
+
+    /* Create a program cache entry */
+    entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry));
+    if (!entry)
+    {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+    entry->vertex_shader = vertex;
+    entry->fragment_shader = fragment;
+    entry->blend_mode = blendMode;
+    
+    /* Create the program and link it */
+    glGetError();
+    entry->id = glCreateProgram();
+    glAttachShader(entry->id, vertex->id);
+    glAttachShader(entry->id, fragment->id);
+    glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_POSITION, "a_position");
+    glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord");
+    glLinkProgram(entry->id);
+    glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful);
+    if (glGetError() != GL_NO_ERROR || !linkSuccessful)
+    {
+        SDL_SetError("Failed to link shader program");
+        glDeleteProgram(entry->id);
+        SDL_free(entry);
+        return NULL;
+    }
+    
+    /* Predetermine locations of uniform variables */
+    entry->uniform_locations[GLES2_UNIFORM_PROJECTION] =
+        glGetUniformLocation(entry->id, "u_projection");
+    entry->uniform_locations[GLES2_UNIFORM_TEXTURE] =
+        glGetUniformLocation(entry->id, "u_texture");
+    entry->uniform_locations[GLES2_UNIFORM_MODULATION] =
+        glGetUniformLocation(entry->id, "u_modulation");
+    entry->uniform_locations[GLES2_UNIFORM_COLOR] =
+        glGetUniformLocation(entry->id, "u_color");
+    entry->uniform_locations[GLES2_UNIFORM_COLORTABLE] =
+        glGetUniformLocation(entry->id, "u_colorTable");
+
+    /* Cache the linked program */
+    if (rdata->program_cache.head)
+    {
+        entry->next = rdata->program_cache.head;
+        rdata->program_cache.head->prev = entry;
+    }
+    else
+    {
+        rdata->program_cache.tail = entry;
+    }
+    rdata->program_cache.head = entry;
+    ++rdata->program_cache.count;
+
+    /* Increment the refcount of the shaders we're using */
+    ++vertex->references;
+    ++fragment->references;
+
+    /* Evict the last entry from the cache if we exceed the limit */
+    if (rdata->program_cache.count > GLES2_MAX_CACHED_PROGRAMS)
+    {
+        shaderEntry = rdata->program_cache.tail->vertex_shader;
+        if (--shaderEntry->references <= 0)
+            GLES2_EvictShader(renderer, shaderEntry);
+        shaderEntry = rdata->program_cache.tail->fragment_shader;
+        if (--shaderEntry->references <= 0)
+            GLES2_EvictShader(renderer, shaderEntry);
+        glDeleteProgram(rdata->program_cache.tail->id);
+        rdata->program_cache.tail = rdata->program_cache.tail->prev;
+        SDL_free(rdata->program_cache.tail->next);
+        rdata->program_cache.tail->next = NULL;
+        --rdata->program_cache.count;
+    }
+    return entry;
+}
+
+static GLES2_ShaderCacheEntry *
+GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode blendMode)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+    const GLES2_Shader *shader;
+    const GLES2_ShaderInstance *instance = NULL;
+    GLES2_ShaderCacheEntry *entry = NULL;
+    GLint compileSuccessful = GL_FALSE;
+    int i, j;
+
+    /* Find the corresponding shader */
+    shader = GLES2_GetShader(type, blendMode);
+    if (!shader)
+    {
+        SDL_SetError("No shader matching the requested characteristics was found");
+        return NULL;
+    }
+    
+    /* Find a matching shader instance that's supported on this hardware */
+    for (i = 0; i < shader->instance_count && !instance; ++i)
+    {
+        for (j = 0; j < rdata->shader_format_count && !instance; ++j)
+        {
+            if (!shader->instances)
+                continue;
+            if (!shader->instances[i])
+                continue;
+            if (shader->instances[i]->format != rdata->shader_formats[j])
+                continue;
+            instance = shader->instances[i];
+        }
+    }
+    if (!instance)
+    {
+        SDL_SetError("The specified shader cannot be loaded on the current platform");
+        return NULL;
+    }
+
+    /* Check if we've already cached this shader */
+    entry = rdata->shader_cache.head;
+    while (entry)
+    {
+        if (entry->instance == instance)
+            break;
+        entry = entry->next;
+    }
+    if (entry)
+        return entry;
+
+    /* Create a shader cache entry */
+    entry = (GLES2_ShaderCacheEntry *)SDL_calloc(1, sizeof(GLES2_ShaderCacheEntry));
+    if (!entry)
+    {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+    entry->type = type;
+    entry->instance = instance;
+
+    /* Compile or load the selected shader instance */
+    glGetError();
+    entry->id = glCreateShader(instance->type);
+    if (instance->format == (GLenum)-1)
+    {
+        glShaderSource(entry->id, 1, (const char **)&instance->data, NULL);
+        glCompileShader(entry->id);
+        glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful);
+    }
+    else
+    {
+        glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length);
+        compileSuccessful = GL_TRUE;
+    }
+    if (glGetError() != GL_NO_ERROR || !compileSuccessful)
+    {
+        char *info = NULL;
+        int length;
+
+        glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length);
+        if (length > 0) {
+            info = SDL_stack_alloc(char, length);
+            if (info) {
+                glGetShaderInfoLog(entry->id, length, &length, info);
+            }
+        }
+        if (info) {
+            SDL_SetError("Failed to load the shader: %s", info);
+            SDL_stack_free(info);
+        } else {
+            SDL_SetError("Failed to load the shader");
+        }
+        glDeleteShader(entry->id);
+        SDL_free(entry);
+        return NULL;
+    }
+
+    /* Link the shader entry in at the front of the cache */
+    if (rdata->shader_cache.head)
+    {
+        entry->next = rdata->shader_cache.head;
+        rdata->shader_cache.head->prev = entry;
+    }
+    rdata->shader_cache.head = entry;
+    ++rdata->shader_cache.count;
+    return entry;
+}
+
+static void
+GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+
+    /* Unlink the shader from the cache */
+    if (entry->next)
+        entry->next->prev = entry->prev;
+    if (entry->prev)
+        entry->prev->next = entry->next;
+    if (rdata->shader_cache.head == entry)
+        rdata->shader_cache.head = entry->next;
+    --rdata->shader_cache.count;
+
+    /* Deallocate the shader */
+    glDeleteShader(entry->id);
+    SDL_free(entry);
+}
+
+static int
+GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendMode blendMode)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+    GLES2_ShaderCacheEntry *vertex = NULL;
+    GLES2_ShaderCacheEntry *fragment = NULL;
+    GLES2_ShaderType vtype, ftype;
+    GLES2_ProgramCacheEntry *program;
+
+    /* Select an appropriate shader pair for the specified modes */
+    vtype = GLES2_SHADER_VERTEX_DEFAULT;
+    switch (source)
+    {
+    case GLES2_IMAGESOURCE_SOLID:
+        ftype = GLES2_SHADER_FRAGMENT_SOLID_SRC;
+        break;
+    case GLES2_IMAGESOURCE_TEXTURE:
+        ftype = GLES2_SHADER_FRAGMENT_TEXTURE_SRC;
+        break;
+    }
+
+    /* Load the requested shaders */
+    vertex = GLES2_CacheShader(renderer, vtype, blendMode);
+    if (!vertex)
+        goto fault;
+    fragment = GLES2_CacheShader(renderer, ftype, blendMode);
+    if (!fragment)
+        goto fault;
+
+    /* Check if we need to change programs at all */
+    if (rdata->current_program &&
+        rdata->current_program->vertex_shader == vertex &&
+        rdata->current_program->fragment_shader == fragment)
+        return 0;
+
+    /* Generate a matching program */
+    program = GLES2_CacheProgram(renderer, vertex, fragment, blendMode);
+    if (!program)
+        goto fault;
+
+    /* Select that program in OpenGL */
+    glGetError();
+    glUseProgram(program->id);
+    if (glGetError() != GL_NO_ERROR)
+    {
+        SDL_SetError("Failed to select program");
+        goto fault;
+    }
+
+    /* Set the current program */
+    rdata->current_program = program;
+
+    /* Activate an orthographic projection */
+    if (GLES2_SetOrthographicProjection(renderer) < 0)
+        goto fault;
+
+    /* Clean up and return */
+    return 0;
+fault:
+    if (vertex && vertex->references <= 0)
+        GLES2_EvictShader(renderer, vertex);
+    if (fragment && fragment->references <= 0)
+        GLES2_EvictShader(renderer, fragment);
+    rdata->current_program = NULL;
+    return -1;
+}
+
+static int
+GLES2_SetOrthographicProjection(SDL_Renderer *renderer)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+    SDL_Window *window = renderer->window;
+    int w, h;
+    GLfloat projection[4][4];
+    GLuint locProjection;
+
+    /* Get the window width and height */
+    SDL_GetWindowSize(window, &w, &h);
+
+    /* Prepare an orthographic projection */
+    projection[0][0] = 2.0f / w;
+    projection[0][1] = 0.0f;
+    projection[0][2] = 0.0f;
+    projection[0][3] = 0.0f;
+    projection[1][0] = 0.0f;
+    projection[1][1] = -2.0f / h;
+    projection[1][2] = 0.0f;
+    projection[1][3] = 0.0f;
+    projection[2][0] = 0.0f;
+    projection[2][1] = 0.0f;
+    projection[2][2] = 1.0f;
+    projection[2][3] = 0.0f;
+    projection[3][0] = -1.0f;
+    projection[3][1] = 1.0f;
+    projection[3][2] = 0.0f;
+    projection[3][3] = 1.0f;
+
+    /* Set the projection matrix */
+    locProjection = rdata->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION];
+    glGetError();
+    glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection);
+    if (glGetError() != GL_NO_ERROR)
+    {
+        SDL_SetError("Failed to set orthographic projection");
+        return -1;
+    }
+    return 0;
+}
+
+/*************************************************************************************************
+ * Rendering functions                                                                           *
+ *************************************************************************************************/
+
+static int GLES2_RenderClear(SDL_Renderer *renderer);
+static int GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count);
+static int GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count);
+static int GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect **rects, int count);
+static int GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect,
+                            const SDL_Rect *dstrect);
+static void GLES2_RenderPresent(SDL_Renderer *renderer);
+
+static int
+GLES2_RenderClear(SDL_Renderer *renderer)
+{
+    float r = (float)renderer->r / 255.0f;
+    float g = (float)renderer->g / 255.0f;
+    float b = (float)renderer->b / 255.0f;
+    float a = (float)renderer->a / 255.0f;
+
+    GLES2_ActivateRenderer(renderer);
+
+    /* Clear the backbuffer with the selected color */
+    glClearColor(r, g, b, a);
+    glClear(GL_COLOR_BUFFER_BIT);
+    return 0;
+}
+
+static void
+GLES2_SetBlendMode(int blendMode)
+{
+    switch (blendMode)
+    {
+    case SDL_BLENDMODE_NONE:
+    default:
+        glDisable(GL_BLEND);
+        break;
+    case SDL_BLENDMODE_BLEND:
+        glEnable(GL_BLEND);
+        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+        break;
+    case SDL_BLENDMODE_ADD:
+        glEnable(GL_BLEND);
+        glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+        break;
+    case SDL_BLENDMODE_MOD:
+        glEnable(GL_BLEND);
+        glBlendFunc(GL_ZERO, GL_SRC_COLOR);
+        break;
+    }
+}
+
+static int
+GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+    GLfloat *vertices;
+    SDL_BlendMode blendMode;
+    int alpha;
+    GLuint locColor;
+    int idx;
+
+    GLES2_ActivateRenderer(renderer);
+
+    blendMode = renderer->blendMode;
+    alpha = renderer->a;
+
+    /* Activate an appropriate shader and set the projection matrix */
+    if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, blendMode) < 0)
+        return -1;
+
+    /* Select the color to draw with */
+    locColor = rdata->current_program->uniform_locations[GLES2_UNIFORM_COLOR];
+    glGetError();
+    glUniform4f(locColor,
+                renderer->r / 255.0f,
+                renderer->g / 255.0f,
+                renderer->b / 255.0f,
+                alpha / 255.0f);
+
+    /* Configure the correct blend mode */
+    GLES2_SetBlendMode(blendMode);
+
+    /* Emit the specified vertices as points */
+    vertices = SDL_stack_alloc(GLfloat, count * 2);
+    for (idx = 0; idx < count; ++idx)
+    {
+        GLfloat x = (GLfloat)points[idx].x + 0.5f;
+        GLfloat y = (GLfloat)points[idx].y + 0.5f;
+
+        vertices[idx * 2] = x;
+        vertices[(idx * 2) + 1] = y;
+    }
+    glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);
+    glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
+    glDrawArrays(GL_POINTS, 0, count);
+    glDisableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);
+    SDL_stack_free(vertices);
+    if (glGetError() != GL_NO_ERROR)
+    {
+        SDL_SetError("Failed to render lines");
+        return -1;
+    }
+    return 0;
+}
+
+static int
+GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+    GLfloat *vertices;
+    SDL_BlendMode blendMode;
+    int alpha;
+    GLuint locColor;
+    int idx;
+
+    GLES2_ActivateRenderer(renderer);
+
+    blendMode = renderer->blendMode;
+    alpha = renderer->a;
+
+    /* Activate an appropriate shader and set the projection matrix */
+    if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, blendMode) < 0)
+        return -1;
+
+    /* Select the color to draw with */
+    locColor = rdata->current_program->uniform_locations[GLES2_UNIFORM_COLOR];
+    glGetError();
+    glUniform4f(locColor,
+                renderer->r / 255.0f,
+                renderer->g / 255.0f,
+                renderer->b / 255.0f,
+                alpha / 255.0f);
+
+    /* Configure the correct blend mode */
+    GLES2_SetBlendMode(blendMode);
+
+    /* Emit a line strip including the specified vertices */
+    vertices = SDL_stack_alloc(GLfloat, count * 2);
+    for (idx = 0; idx < count; ++idx)
+    {
+        GLfloat x = (GLfloat)points[idx].x + 0.5f;
+        GLfloat y = (GLfloat)points[idx].y + 0.5f;
+
+        vertices[idx * 2] = x;
+        vertices[(idx * 2) + 1] = y;
+    }
+    glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);
+    glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
+    glDrawArrays(GL_LINE_STRIP, 0, count);
+    glDisableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);
+    SDL_stack_free(vertices);
+    if (glGetError() != GL_NO_ERROR)
+    {
+        SDL_SetError("Failed to render lines");
+        return -1;
+    }
+    return 0;
+}
+
+static int
+GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect **rects, int count)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+    GLfloat vertices[8];
+    SDL_BlendMode blendMode;
+    int alpha;
+    GLuint locColor;
+    int idx;
+
+    GLES2_ActivateRenderer(renderer);
+
+    blendMode = renderer->blendMode;
+    alpha = renderer->a;
+
+    /* Activate an appropriate shader and set the projection matrix */
+    if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, blendMode) < 0)
+        return -1;
+
+    /* Select the color to draw with */
+    locColor = rdata->current_program->uniform_locations[GLES2_UNIFORM_COLOR];
+    glGetError();
+    glUniform4f(locColor,
+                renderer->r / 255.0f,
+                renderer->g / 255.0f,
+                renderer->b / 255.0f,
+                alpha / 255.0f);
+
+    /* Configure the correct blend mode */
+    GLES2_SetBlendMode(blendMode);
+
+    /* Emit a line loop for each rectangle */
+    glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);
+    for (idx = 0; idx < count; ++idx)
+    {
+        GLfloat xMin = (GLfloat)rects[idx]->x;
+        GLfloat xMax = (GLfloat)(rects[idx]->x + rects[idx]->w);
+        GLfloat yMin = (GLfloat)rects[idx]->y;
+        GLfloat yMax = (GLfloat)(rects[idx]->y + rects[idx]->h);
+
+        vertices[0] = xMin;
+        vertices[1] = yMin;
+        vertices[2] = xMax;
+        vertices[3] = yMin;
+        vertices[4] = xMin;
+        vertices[5] = yMax;
+        vertices[6] = xMax;
+        vertices[7] = yMax;
+        glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
+        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+    }
+    glDisableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);
+    if (glGetError() != GL_NO_ERROR)
+    {
+        SDL_SetError("Failed to render lines");
+        return -1;
+    }
+    return 0;
+}
+
+static int
+GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect,
+                 const SDL_Rect *dstrect)
+{
+    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
+    GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
+    GLES2_ImageSource sourceType;
+    SDL_BlendMode blendMode;
+    int alpha;
+    GLfloat vertices[8];
+    GLfloat texCoords[8];
+    GLuint locTexture;
+    GLuint locModulation;
+    GLuint locColorTable;
+
+    GLES2_ActivateRenderer(renderer);
+
+    /* Activate an appropriate shader and set the projection matrix */
+    blendMode = texture->blendMode;
+    alpha = texture->a;
+    sourceType = GLES2_IMAGESOURCE_TEXTURE;
+    if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0)
+        return -1;
+
+    /* Select the target texture */
+    locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE];
+    glGetError();
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(tdata->texture_type, tdata->texture);
+    glUniform1i(locTexture, 0);
+
+    /* Configure texture blending */
+    GLES2_SetBlendMode(blendMode);
+
+    /* Configure color modulation */
+    locModulation = rdata->current_program->uniform_locations[GLES2_UNIFORM_MODULATION];
+    glUniform4f(locModulation,
+                texture->r / 255.0f,
+                texture->g / 255.0f,
+                texture->b / 255.0f,
+                alpha / 255.0f);
+
+    /* Emit the textured quad */
+    glEnableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD);
+    glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);
+    vertices[0] = (GLfloat)dstrect->x;
+    vertices[1] = (GLfloat)dstrect->y;
+    vertices[2] = (GLfloat)(dstrect->x + dstrect->w);
+    vertices[3] = (GLfloat)dstrect->y;
+    vertices[4] = (GLfloat)dstrect->x;
+    vertices[5] = (GLfloat)(dstrect->y + dstrect->h);
+    vertices[6] = (GLfloat)(dstrect->x + dstrect->w);
+    vertices[7] = (GLfloat)(dstrect->y + dstrect->h);
+    glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
+    texCoords[0] = srcrect->x / (GLfloat)texture->w;
+    texCoords[1] = srcrect->y / (GLfloat)texture->h;
+    texCoords[2] = (srcrect->x + srcrect->w) / (GLfloat)texture->w;
+    texCoords[3] = srcrect->y / (GLfloat)texture->h;
+    texCoords[4] = srcrect->x / (GLfloat)texture->w;
+    texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
+    texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w;
+    texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
+    glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);
+    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+    glDisableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);
+    glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD);
+    if (glGetError() != GL_NO_ERROR)
+    {
+        SDL_SetError("Failed to render texture");
+        return -1;
+    }
+    return 0;
+}
+
+static void
+GLES2_RenderPresent(SDL_Renderer *renderer)
+{
+    GLES2_ActivateRenderer(renderer);
+
+    /* Tell the video driver to swap buffers */
+    SDL_GL_SwapWindow(renderer->window);
+}
+
+/*************************************************************************************************
+ * Renderer instantiation                                                                        *
+ *************************************************************************************************/
+
+#define GL_NVIDIA_PLATFORM_BINARY_NV 0x890B
+
+static SDL_Renderer *
+GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
+{
+    SDL_Renderer *renderer;
+    GLES2_DriverContext *rdata;
+    GLint nFormats;
+#ifndef ZUNE_HD
+    GLboolean hasCompiler;
+#endif
+
+    /* Create the renderer struct */
+    renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer));
+    if (!renderer) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    rdata = (GLES2_DriverContext *)SDL_calloc(1, sizeof(GLES2_DriverContext));
+    if (!rdata) {
+        GLES2_DestroyRenderer(renderer);
+        SDL_OutOfMemory();
+        return NULL;
+    }
+    renderer->info = GLES2_RenderDriver.info;
+    renderer->window = window;
+    renderer->driverdata = rdata;
+
+    renderer->info.flags = SDL_RENDERER_ACCELERATED;
+
+    /* Create an OpenGL ES 2.0 context */
+    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
+    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
+
+    rdata->context = SDL_GL_CreateContext(window);
+    if (!rdata->context)
+    {
+        GLES2_DestroyRenderer(renderer);
+        return NULL;
+    }
+    if (SDL_GL_MakeCurrent(window, rdata->context) < 0) {
+        GLES2_DestroyRenderer(renderer);
+        return NULL;
+    }
+
+    if (flags & SDL_RENDERER_PRESENTVSYNC) {
+        SDL_GL_SetSwapInterval(1);
+    } else {
+        SDL_GL_SetSwapInterval(0);
+    }
+    if (SDL_GL_GetSwapInterval() > 0) {
+        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
+    }
+
+    /* Determine supported shader formats */
+    /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */
+    glGetError();
+#ifdef ZUNE_HD
+    nFormats = 1;
+#else /* !ZUNE_HD */
+    glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats);
+    glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler);
+    if (hasCompiler)
+        ++nFormats;
+#endif /* ZUNE_HD */
+    rdata->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum));
+    if (!rdata->shader_formats)
+    {
+        GLES2_DestroyRenderer(renderer);
+        SDL_OutOfMemory();
+        return NULL;
+    }
+    rdata->shader_format_count = nFormats;
+#ifdef ZUNE_HD
+    rdata->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV;
+#else /* !ZUNE_HD */
+    glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)rdata->shader_formats);
+    if (glGetError() != GL_NO_ERROR)
+    {
+        GLES2_DestroyRenderer(renderer);
+        SDL_SetError("Failed to query supported shader formats");
+        return NULL;
+    }
+    if (hasCompiler)
+        rdata->shader_formats[nFormats - 1] = (GLenum)-1;
+#endif /* ZUNE_HD */
+	
+    rdata->updateSize = SDL_TRUE;
+
+    /* Populate the function pointers for the module */
+    renderer->WindowEvent         = &GLES2_WindowEvent;
+    renderer->CreateTexture       = &GLES2_CreateTexture;
+    renderer->UpdateTexture       = &GLES2_UpdateTexture;
+    renderer->LockTexture         = &GLES2_LockTexture;
+    renderer->UnlockTexture       = &GLES2_UnlockTexture;
+    renderer->RenderClear         = &GLES2_RenderClear;
+    renderer->RenderDrawPoints    = &GLES2_RenderDrawPoints;
+    renderer->RenderDrawLines     = &GLES2_RenderDrawLines;
+    renderer->RenderFillRects     = &GLES2_RenderFillRects;
+    renderer->RenderCopy          = &GLES2_RenderCopy;
+    renderer->RenderPresent       = &GLES2_RenderPresent;
+    renderer->DestroyTexture      = &GLES2_DestroyTexture;
+    renderer->DestroyRenderer     = &GLES2_DestroyRenderer;
+    return renderer;
+}
+
+#endif /* SDL_VIDEO_RENDER_OGL_ES2 */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/opengles2/SDL_shaders_gles2.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,544 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 2010 itsnotabigtruck.
+
+    Permission is hereby granted, free of charge, to any person obtaining a
+    copy of this software and associated documentation files (the "Software"),
+    to deal in the Software without restriction, including without limitation
+    the rights to use, copy, modify, merge, publish, distribute, sublicense,
+    and/or sell copies of the Software, and to permit persons to whom the
+    Software is furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+    DEALINGS IN THE SOFTWARE.
+*/
+
+#include "SDL_config.h"
+
+#if SDL_VIDEO_RENDER_OGL_ES2
+
+#include "SDL_video.h"
+#include "SDL_opengles2.h"
+#include "SDL_shaders_gles2.h"
+#include "SDL_stdinc.h"
+
+/*************************************************************************************************
+ * Vertex/fragment shader source                                                                 *
+ *************************************************************************************************/
+
+static const Uint8 GLES2_VertexSrc_Default_[] = " \
+    uniform mat4 u_projection; \
+    attribute vec4 a_position; \
+    attribute vec2 a_texCoord; \
+    varying vec2 v_texCoord; \
+    \
+    void main() \
+    { \
+        v_texCoord = a_texCoord; \
+        gl_Position = u_projection * a_position; \
+        gl_PointSize = 1.0; \
+    } \
+";
+
+static const Uint8 GLES2_FragmentSrc_SolidSrc_[] = " \
+    precision mediump float; \
+    uniform vec4 u_color; \
+    \
+    void main() \
+    { \
+        gl_FragColor = u_color; \
+    } \
+";
+
+static const Uint8 GLES2_FragmentSrc_TextureSrc_[] = " \
+    precision mediump float; \
+    uniform sampler2D u_texture; \
+    uniform vec4 u_modulation; \
+    varying vec2 v_texCoord; \
+    \
+    void main() \
+    { \
+        gl_FragColor = texture2D(u_texture, v_texCoord); \
+        gl_FragColor *= u_modulation; \
+    } \
+";
+
+static const GLES2_ShaderInstance GLES2_VertexSrc_Default = {
+    GL_VERTEX_SHADER,
+    GLES2_SOURCE_SHADER,
+    sizeof(GLES2_VertexSrc_Default_),
+    GLES2_VertexSrc_Default_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentSrc_SolidSrc = {
+    GL_FRAGMENT_SHADER,
+    GLES2_SOURCE_SHADER,
+    sizeof(GLES2_FragmentSrc_SolidSrc_),
+    GLES2_FragmentSrc_SolidSrc_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureSrc = {
+    GL_FRAGMENT_SHADER,
+    GLES2_SOURCE_SHADER,
+    sizeof(GLES2_FragmentSrc_TextureSrc_),
+    GLES2_FragmentSrc_TextureSrc_
+};
+
+/*************************************************************************************************
+ * Vertex/fragment shader binaries (NVIDIA Tegra 1/2)                                            *
+ *************************************************************************************************/
+
+#if GLES2_INCLUDE_NVIDIA_SHADERS
+
+#define GL_NVIDIA_PLATFORM_BINARY_NV 0x890B
+
+static const Uint8 GLES2_VertexTegra_Default_[] = {
+    243, 193, 1, 142, 31, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
+    0, 0, 46, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 85, 0, 0, 0, 2, 0, 0, 0, 24, 0, 0, 0, 3, 0, 0, 0,
+    91, 0, 0, 0, 1, 0, 0, 0, 16, 0, 0, 0, 5, 0, 0, 0, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 95, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0,
+    13, 0, 0, 0, 102, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 16, 0, 0, 0, 104, 0, 0, 0, 1, 0, 0, 0, 32, 0, 0, 0, 17, 0, 0, 0, 112, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 112, 0, 0, 0, 80, 0, 0, 0, 80, 0, 0, 0, 19, 0, 0, 0, 132, 0,
+    0, 0, 104, 0, 0, 0, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 97,
+    95, 112, 111, 115, 105, 116, 105, 111, 110, 0, 97, 95, 116, 101, 120, 67, 111, 111, 114, 100,
+    0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 112, 114, 111, 106, 101, 99,
+    116, 105, 111, 110, 0, 0, 0, 0, 0, 0, 0, 82, 139, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 80, 139, 0,
+    0, 1, 0, 0, 0, 22, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 33, 0, 0, 0, 92, 139, 0, 0,
+    1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 240, 0, 0, 0, 0, 0, 0, 1, 0,
+    0, 0, 64, 0, 0, 0, 80, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 193, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 66, 24, 0, 6, 34, 108, 28,
+    0, 0, 42, 16, 128, 0, 195, 192, 6, 129, 252, 255, 65, 96, 108, 28, 0, 0, 0, 0, 0, 1, 195, 192,
+    6, 1, 252, 255, 33, 96, 108, 156, 31, 64, 8, 1, 64, 0, 131, 192, 6, 1, 156, 159, 65, 96, 108,
+    28, 0, 0, 85, 32, 0, 1, 195, 192, 6, 1, 252, 255, 33, 96, 108, 156, 31, 64, 0, 64, 64, 0, 131,
+    192, 134, 1, 152, 31, 65, 96, 108, 156, 31, 64, 127, 48, 0, 1, 195, 192, 6, 129, 129, 255, 33,
+    96
+};
+
+static const Uint8 GLES2_FragmentTegra_None_SolidSrc_[] = {
+    155, 191, 159, 1, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
+    0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
+    75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
+    0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
+    0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
+    0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
+    0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241, 0, 0, 0, 240, 0, 0,
+    0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0,
+    0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1,
+    0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 0, 0, 0, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0, 0, 0,
+    0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 0, 40, 0, 0, 0, 242, 65, 63,
+    192, 200, 0, 0, 0, 242, 65, 63, 128, 168, 0, 0, 0, 242, 65, 63, 64, 72, 0, 0, 0, 242, 65, 63,
+    1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
+};
+
+static const Uint8 GLES2_FragmentTegra_Alpha_SolidSrc_[] = {
+    169, 153, 195, 28, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
+    0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
+    75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
+    0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
+    0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
+    0, 220, 0, 0, 0, 220, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
+    0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 118, 118, 17, 241, 0, 0, 0, 240, 0,
+    0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0,
+    0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 21, 32, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78,
+    1, 0, 0, 0, 3, 0, 0, 0, 3, 0, 65, 37, 8, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 21, 0,
+    0, 0, 0, 3, 0, 1, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 39, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 3, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0, 9, 0, 0, 0, 24, 0, 4, 40, 232, 231, 15,
+    0, 0, 242, 65, 62, 194, 72, 1, 0, 0, 250, 65, 63, 194, 40, 1, 0, 0, 250, 65, 63, 192, 168, 1,
+    0, 0, 242, 1, 64, 192, 168, 1, 0, 0, 242, 1, 68, 168, 32, 0, 0, 0, 50, 64, 0, 192, 168, 15,
+    0, 0, 242, 1, 66, 168, 64, 0, 16, 0, 242, 65, 1, 232, 231, 15, 0, 0, 242, 65, 62, 168, 160,
+    0, 0, 0, 50, 64, 2, 104, 192, 0, 0, 36, 48, 66, 4, 232, 231, 15, 0, 0, 242, 65, 62, 3, 0, 6,
+    40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 41, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 2, 0
+};
+
+static const Uint8 GLES2_FragmentTegra_Additive_SolidSrc_[] = {
+    59, 71, 42, 17, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, 0,
+    0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
+    75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
+    0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
+    0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
+    0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
+    0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 22, 22, 17, 241, 0, 0, 0, 240, 0,
+    0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0,
+    0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78,
+    1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0,
+    0, 0, 0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 192, 200, 0, 0, 0, 26,
+    0, 70, 192, 40, 0, 0, 0, 2, 0, 64, 192, 72, 0, 0, 0, 10, 0, 66, 192, 168, 0, 0, 0, 18, 0, 68,
+    1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
+};
+
+static const Uint8 GLES2_FragmentTegra_Modulated_SolidSrc_[] = {
+    37, 191, 49, 17, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, 0,
+    0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
+    75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
+    0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
+    0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
+    0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
+    0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 32, 32, 17, 241, 0, 0, 0, 240, 0,
+    0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0,
+    0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78,
+    1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0,
+    0, 0, 0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 104, 192, 0, 0, 0, 242,
+    1, 70, 8, 32, 0, 0, 0, 242, 1, 64, 40, 64, 0, 0, 0, 242, 1, 66, 72, 160, 0, 0, 0, 242, 1, 68,
+    1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
+};
+
+static const Uint8 GLES2_FragmentTegra_None_TextureSrc_[] = {
+    220, 217, 41, 211, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
+    0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
+    82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
+    0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
+    13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
+    0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
+    0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
+    0, 0, 0, 120, 0, 0, 0, 120, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
+    0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
+    97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
+    2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
+    0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 1, 0, 0, 0, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240,
+    0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 1, 0,
+    0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0,
+    0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 0, 0, 0, 0, 1, 0,
+    0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 1, 0, 0, 0, 2, 0, 4, 38, 186, 81, 78, 16, 2, 1, 0, 0, 1, 0,
+    1, 39, 0, 4, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 104, 192, 0, 0, 0, 242, 1, 70, 8, 32,
+    0, 0, 0, 242, 1, 64, 40, 64, 0, 0, 0, 242, 1, 66, 72, 160, 0, 0, 0, 242, 1, 68, 1, 0, 6, 40,
+    0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
+};
+
+static const Uint8 GLES2_FragmentTegra_Alpha_TextureSrc_[] = {
+    71, 202, 114, 229, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
+    0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
+    82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
+    0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
+    13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
+    0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
+    0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
+    0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
+    0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
+    97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
+    2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
+    0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 1, 118, 118, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0,
+    240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0,
+    1, 0, 0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16,
+    0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0,
+    8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186,
+    81, 78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0,
+    0, 0, 16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 8, 192, 1, 0, 0, 242, 1, 64, 104, 32, 1, 0,
+    0, 242, 1, 70, 72, 64, 1, 0, 0, 242, 1, 68, 154, 192, 0, 0, 37, 34, 64, 3, 8, 32, 0, 0, 5, 58,
+    208, 4, 40, 64, 0, 0, 5, 50, 208, 4, 72, 160, 0, 0, 37, 42, 208, 4, 2, 0, 6, 40, 0, 0, 0, 0,
+    0, 0, 0, 0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0
+};
+
+static const Uint8 GLES2_FragmentTegra_Additive_TextureSrc_[] = {
+    161, 234, 193, 234, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
+    0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
+    82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
+    0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
+    13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
+    0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
+    0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
+    0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
+    0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
+    97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
+    2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
+    0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 1, 22, 22, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240,
+    0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0,
+    0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0,
+    0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0, 8, 0,
+    129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186, 81,
+    78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0,
+    16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 104, 32, 1, 0, 0, 242, 1, 70, 8, 192, 1, 0, 0, 242,
+    1, 64, 72, 64, 1, 0, 0, 242, 1, 68, 136, 192, 0, 0, 0, 26, 64, 4, 136, 32, 0, 0, 0, 2, 64, 7,
+    136, 64, 0, 0, 0, 10, 64, 6, 136, 160, 0, 0, 0, 18, 64, 5, 2, 0, 6, 40, 0, 0, 0, 0, 0, 0, 0,
+    0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0
+};
+
+static const Uint8 GLES2_FragmentTegra_Modulated_TextureSrc_[] = {
+    75, 132, 201, 227, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
+    0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
+    82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
+    0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
+    13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
+    0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
+    0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
+    0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
+    0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
+    97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
+    2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
+    0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 1, 32, 32, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240,
+    0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0,
+    0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0,
+    0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0, 8, 0,
+    129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186, 81,
+    78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0,
+    16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 8, 192, 1, 0, 0, 242, 1, 64, 104, 32, 1, 0, 0, 242,
+    1, 70, 72, 64, 1, 0, 0, 242, 1, 68, 104, 192, 0, 0, 0, 242, 65, 4, 232, 32, 0, 0, 0, 242, 65,
+    0, 40, 64, 0, 0, 0, 242, 65, 6, 72, 160, 0, 0, 0, 242, 65, 5, 2, 0, 6, 40, 0, 0, 0, 0, 0, 0,
+    0, 0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0
+};
+
+static const GLES2_ShaderInstance GLES2_VertexTegra_Default = {
+    GL_VERTEX_SHADER,
+    GL_NVIDIA_PLATFORM_BINARY_NV,
+    sizeof(GLES2_VertexTegra_Default_),
+    GLES2_VertexTegra_Default_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentTegra_None_SolidSrc = {
+    GL_FRAGMENT_SHADER,
+    GL_NVIDIA_PLATFORM_BINARY_NV,
+    sizeof(GLES2_FragmentTegra_None_SolidSrc_),
+    GLES2_FragmentTegra_None_SolidSrc_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentTegra_Alpha_SolidSrc = {
+    GL_FRAGMENT_SHADER,
+    GL_NVIDIA_PLATFORM_BINARY_NV,
+    sizeof(GLES2_FragmentTegra_Alpha_SolidSrc_),
+    GLES2_FragmentTegra_Alpha_SolidSrc_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentTegra_Additive_SolidSrc = {
+    GL_FRAGMENT_SHADER,
+    GL_NVIDIA_PLATFORM_BINARY_NV,
+    sizeof(GLES2_FragmentTegra_Additive_SolidSrc_),
+    GLES2_FragmentTegra_Additive_SolidSrc_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentTegra_Modulated_SolidSrc = {
+    GL_FRAGMENT_SHADER,
+    GL_NVIDIA_PLATFORM_BINARY_NV,
+    sizeof(GLES2_FragmentTegra_Modulated_SolidSrc_),
+    GLES2_FragmentTegra_Modulated_SolidSrc_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentTegra_None_TextureSrc = {
+    GL_FRAGMENT_SHADER,
+    GL_NVIDIA_PLATFORM_BINARY_NV,
+    sizeof(GLES2_FragmentTegra_None_TextureSrc_),
+    GLES2_FragmentTegra_None_TextureSrc_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentTegra_Alpha_TextureSrc = {
+    GL_FRAGMENT_SHADER,
+    GL_NVIDIA_PLATFORM_BINARY_NV,
+    sizeof(GLES2_FragmentTegra_Alpha_TextureSrc_),
+    GLES2_FragmentTegra_Alpha_TextureSrc_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentTegra_Additive_TextureSrc = {
+    GL_FRAGMENT_SHADER,
+    GL_NVIDIA_PLATFORM_BINARY_NV,
+    sizeof(GLES2_FragmentTegra_Additive_TextureSrc_),
+    GLES2_FragmentTegra_Additive_TextureSrc_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentTegra_Modulated_TextureSrc = {
+    GL_FRAGMENT_SHADER,
+    GL_NVIDIA_PLATFORM_BINARY_NV,
+    sizeof(GLES2_FragmentTegra_Modulated_TextureSrc_),
+    GLES2_FragmentTegra_Modulated_TextureSrc_
+};
+
+#endif /* GLES2_INCLUDE_NVIDIA_SHADERS */
+
+/*************************************************************************************************
+ * Vertex/fragment shader definitions                                                            *
+ *************************************************************************************************/
+
+static GLES2_Shader GLES2_VertexShader_Default = {
+    2,
+    {
+#if GLES2_INCLUDE_NVIDIA_SHADERS
+        &GLES2_VertexTegra_Default,
+#endif
+        &GLES2_VertexSrc_Default
+    }
+};
+
+static GLES2_Shader GLES2_FragmentShader_None_SolidSrc = {
+    2,
+    {
+#if GLES2_INCLUDE_NVIDIA_SHADERS
+        &GLES2_FragmentTegra_None_SolidSrc,
+#endif
+        &GLES2_FragmentSrc_SolidSrc
+    }
+};
+
+static GLES2_Shader GLES2_FragmentShader_Alpha_SolidSrc = {
+    2,
+    {
+#if GLES2_INCLUDE_NVIDIA_SHADERS
+        &GLES2_FragmentTegra_Alpha_SolidSrc,
+#endif
+        &GLES2_FragmentSrc_SolidSrc
+    }
+};
+
+static GLES2_Shader GLES2_FragmentShader_Additive_SolidSrc = {
+    2,
+    {
+#if GLES2_INCLUDE_NVIDIA_SHADERS
+        &GLES2_FragmentTegra_Additive_SolidSrc,
+#endif
+        &GLES2_FragmentSrc_SolidSrc
+    }
+};
+
+static GLES2_Shader GLES2_FragmentShader_Modulated_SolidSrc = {
+    2,
+    {
+#if GLES2_INCLUDE_NVIDIA_SHADERS
+        &GLES2_FragmentTegra_Modulated_SolidSrc,
+#endif
+        &GLES2_FragmentSrc_SolidSrc
+    }
+};
+
+static GLES2_Shader GLES2_FragmentShader_None_TextureSrc = {
+    2,
+    {
+#if GLES2_INCLUDE_NVIDIA_SHADERS
+        &GLES2_FragmentTegra_None_TextureSrc,
+#endif
+        &GLES2_FragmentSrc_TextureSrc
+    }
+};
+
+static GLES2_Shader GLES2_FragmentShader_Alpha_TextureSrc = {
+    2,
+    {
+#if GLES2_INCLUDE_NVIDIA_SHADERS
+        &GLES2_FragmentTegra_Alpha_TextureSrc,
+#endif
+        &GLES2_FragmentSrc_TextureSrc
+    }
+};
+
+static GLES2_Shader GLES2_FragmentShader_Additive_TextureSrc = {
+    2,
+    {
+#if GLES2_INCLUDE_NVIDIA_SHADERS
+        &GLES2_FragmentTegra_Additive_TextureSrc,
+#endif
+        &GLES2_FragmentSrc_TextureSrc
+    }
+};
+
+static GLES2_Shader GLES2_FragmentShader_Modulated_TextureSrc = {
+    2,
+    {
+#if GLES2_INCLUDE_NVIDIA_SHADERS
+        &GLES2_FragmentTegra_Modulated_TextureSrc,
+#endif
+        &GLES2_FragmentSrc_TextureSrc
+    }
+};
+
+/*************************************************************************************************
+ * Shader selector                                                                               *
+ *************************************************************************************************/
+
+const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMode)
+{
+    switch (type)
+    {
+    case GLES2_SHADER_VERTEX_DEFAULT:
+        return &GLES2_VertexShader_Default;
+    case GLES2_SHADER_FRAGMENT_SOLID_SRC:
+        switch (blendMode)
+        {
+        case SDL_BLENDMODE_NONE:
+            return &GLES2_FragmentShader_None_SolidSrc;
+        case SDL_BLENDMODE_BLEND:
+            return &GLES2_FragmentShader_Alpha_SolidSrc;
+        case SDL_BLENDMODE_ADD:
+            return &GLES2_FragmentShader_Additive_SolidSrc;
+        case SDL_BLENDMODE_MOD:
+            return &GLES2_FragmentShader_Modulated_SolidSrc;
+        default:
+            return NULL;
+        }
+    case GLES2_SHADER_FRAGMENT_TEXTURE_SRC:
+        switch (blendMode)
+        {
+        case SDL_BLENDMODE_NONE:
+            return &GLES2_FragmentShader_None_TextureSrc;
+        case SDL_BLENDMODE_BLEND:
+            return &GLES2_FragmentShader_Alpha_TextureSrc;
+        case SDL_BLENDMODE_ADD:
+            return &GLES2_FragmentShader_Additive_TextureSrc;
+        case SDL_BLENDMODE_MOD:
+            return &GLES2_FragmentShader_Modulated_TextureSrc;
+        default:
+            return NULL;
+        }
+    default:
+        return NULL;
+    }
+}
+
+#endif /* SDL_VIDEO_RENDER_OGL_ES2 */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/opengles2/SDL_shaders_gles2.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,60 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 2010 itsnotabigtruck.
+
+    Permission is hereby granted, free of charge, to any person obtaining a
+    copy of this software and associated documentation files (the "Software"),
+    to deal in the Software without restriction, including without limitation
+    the rights to use, copy, modify, merge, publish, distribute, sublicense,
+    and/or sell copies of the Software, and to permit persons to whom the
+    Software is furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+    DEALINGS IN THE SOFTWARE.
+*/
+
+#include "SDL_config.h"
+
+#if SDL_VIDEO_RENDER_OGL_ES2
+
+#ifndef SDL_shaderdata_h_
+#define SDL_shaderdata_h_
+
+typedef struct GLES2_ShaderInstance
+{
+    GLenum type;
+    GLenum format;
+    int length;
+    const void *data;
+} GLES2_ShaderInstance;
+
+typedef struct GLES2_Shader
+{
+    int instance_count;
+    const GLES2_ShaderInstance *instances[4];
+} GLES2_Shader;
+
+typedef enum
+{
+    GLES2_SHADER_VERTEX_DEFAULT,
+    GLES2_SHADER_FRAGMENT_SOLID_SRC,
+    GLES2_SHADER_FRAGMENT_TEXTURE_SRC
+} GLES2_ShaderType;
+
+#define GLES2_SOURCE_SHADER (GLenum)-1
+
+const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMode);
+
+#endif /* SDL_shaderdata_h_ */
+
+#endif /* SDL_VIDEO_RENDER_OGL_ES2 */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_blendfillrect.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,348 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_draw.h"
+#include "SDL_blendfillrect.h"
+
+
+static int
+SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
+                         SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    unsigned inva = 0xff - a;
+
+    switch (blendMode) {
+    case SDL_BLENDMODE_BLEND:
+        FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555);
+        break;
+    case SDL_BLENDMODE_ADD:
+        FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555);
+        break;
+    case SDL_BLENDMODE_MOD:
+        FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555);
+        break;
+    default:
+        FILLRECT(Uint16, DRAW_SETPIXEL_RGB555);
+        break;
+    }
+    return 0;
+}
+
+static int
+SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
+                         SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    unsigned inva = 0xff - a;
+
+    switch (blendMode) {
+    case SDL_BLENDMODE_BLEND:
+        FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565);
+        break;
+    case SDL_BLENDMODE_ADD:
+        FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565);
+        break;
+    case SDL_BLENDMODE_MOD:
+        FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565);
+        break;
+    default:
+        FILLRECT(Uint16, DRAW_SETPIXEL_RGB565);
+        break;
+    }
+    return 0;
+}
+
+static int
+SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
+                         SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    unsigned inva = 0xff - a;
+
+    switch (blendMode) {
+    case SDL_BLENDMODE_BLEND:
+        FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB888);
+        break;
+    case SDL_BLENDMODE_ADD:
+        FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888);
+        break;
+    case SDL_BLENDMODE_MOD:
+        FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888);
+        break;
+    default:
+        FILLRECT(Uint32, DRAW_SETPIXEL_RGB888);
+        break;
+    }
+    return 0;
+}
+
+static int
+SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
+                           SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    unsigned inva = 0xff - a;
+
+    switch (blendMode) {
+    case SDL_BLENDMODE_BLEND:
+        FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
+        break;
+    case SDL_BLENDMODE_ADD:
+        FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
+        break;
+    case SDL_BLENDMODE_MOD:
+        FILLRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
+        break;
+    default:
+        FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
+        break;
+    }
+    return 0;
+}
+
+static int
+SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
+                      SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    SDL_PixelFormat *fmt = dst->format;
+    unsigned inva = 0xff - a;
+
+    switch (fmt->BytesPerPixel) {
+    case 2:
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB);
+            break;
+        case SDL_BLENDMODE_ADD:
+            FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB);
+            break;
+        case SDL_BLENDMODE_MOD:
+            FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB);
+            break;
+        default:
+            FILLRECT(Uint16, DRAW_SETPIXEL_RGB);
+            break;
+        }
+        return 0;
+    case 4:
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB);
+            break;
+        case SDL_BLENDMODE_ADD:
+            FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB);
+            break;
+        case SDL_BLENDMODE_MOD:
+            FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB);
+            break;
+        default:
+            FILLRECT(Uint32, DRAW_SETPIXEL_RGB);
+            break;
+        }
+        return 0;
+    default:
+        SDL_Unsupported();
+        return -1;
+    }
+}
+
+static int
+SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
+                       SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    SDL_PixelFormat *fmt = dst->format;
+    unsigned inva = 0xff - a;
+
+    switch (fmt->BytesPerPixel) {
+    case 4:
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA);
+            break;
+        case SDL_BLENDMODE_ADD:
+            FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA);
+            break;
+        case SDL_BLENDMODE_MOD:
+            FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA);
+            break;
+        default:
+            FILLRECT(Uint32, DRAW_SETPIXEL_RGBA);
+            break;
+        }
+        return 0;
+    default:
+        SDL_Unsupported();
+        return -1;
+    }
+}
+
+int
+SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
+                  SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    SDL_Rect clipped;
+
+    if (!dst) {
+        SDL_SetError("Passed NULL destination surface");
+        return -1;
+    }
+
+    /* This function doesn't work on surfaces < 8 bpp */
+    if (dst->format->BitsPerPixel < 8) {
+        SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
+        return -1;
+    }
+
+    /* If 'rect' == NULL, then fill the whole surface */
+    if (rect) {
+        /* Perform clipping */
+        if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
+            return 0;
+        }
+        rect = &clipped;
+    } else {
+        rect = &dst->clip_rect;
+    }
+
+    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
+        r = DRAW_MUL(r, a);
+        g = DRAW_MUL(g, a);
+        b = DRAW_MUL(b, a);
+    }
+
+    switch (dst->format->BitsPerPixel) {
+    case 15:
+        switch (dst->format->Rmask) {
+        case 0x7C00:
+            return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a);
+        }
+        break;
+    case 16:
+        switch (dst->format->Rmask) {
+        case 0xF800:
+            return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a);
+        }
+        break;
+    case 32:
+        switch (dst->format->Rmask) {
+        case 0x00FF0000:
+            if (!dst->format->Amask) {
+                return SDL_BlendFillRect_RGB888(dst, rect, blendMode, r, g, b, a);
+            } else {
+                return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
+            }
+            break;
+        }
+        break;
+    default:
+        break;
+    }
+
+    if (!dst->format->Amask) {
+        return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
+    } else {
+        return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a);
+    }
+}
+
+int
+SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect ** rects, int count,
+                   SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    SDL_Rect clipped;
+    int i;
+    int (*func)(SDL_Surface * dst, const SDL_Rect * rect,
+                SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
+    int status = 0;
+
+    if (!dst) {
+        SDL_SetError("Passed NULL destination surface");
+        return -1;
+    }
+
+    /* This function doesn't work on surfaces < 8 bpp */
+    if (dst->format->BitsPerPixel < 8) {
+        SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
+        return -1;
+    }
+
+    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
+        r = DRAW_MUL(r, a);
+        g = DRAW_MUL(g, a);
+        b = DRAW_MUL(b, a);
+    }
+
+    /* FIXME: Does this function pointer slow things down significantly? */
+    switch (dst->format->BitsPerPixel) {
+    case 15:
+        switch (dst->format->Rmask) {
+        case 0x7C00:
+            func = SDL_BlendFillRect_RGB555;
+        }
+        break;
+    case 16:
+        switch (dst->format->Rmask) {
+        case 0xF800:
+            func = SDL_BlendFillRect_RGB565;
+        }
+        break;
+    case 32:
+        switch (dst->format->Rmask) {
+        case 0x00FF0000:
+            if (!dst->format->Amask) {
+                func = SDL_BlendFillRect_RGB888;
+            } else {
+                func = SDL_BlendFillRect_ARGB8888;
+            }
+            break;
+        }
+        break;
+    default:
+        break;
+    }
+
+    if (!func) {
+        if (!dst->format->Amask) {
+            func = SDL_BlendFillRect_RGB;
+        } else {
+            func = SDL_BlendFillRect_RGBA;
+        }
+    }
+
+    for (i = 0; i < count; ++i) {
+        const SDL_Rect * rect = rects[i];
+
+        /* If 'rect' == NULL, then fill the whole surface */
+        if (rect) {
+            /* Perform clipping */
+            if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
+                continue;
+            }
+            rect = &clipped;
+        } else {
+            rect = &dst->clip_rect;
+        }
+
+        status = func(dst, rect, blendMode, r, g, b, a);
+    }
+    return status;
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_blendfillrect.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,28 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+
+extern int SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
+extern int SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect ** rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_blendline.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,782 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_draw.h"
+#include "SDL_blendline.h"
+#include "SDL_blendpoint.h"
+
+
+static void
+SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2,
+                   SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
+                   SDL_bool draw_end)
+{
+    const SDL_PixelFormat *fmt = dst->format;
+    unsigned r, g, b, a, inva;
+
+    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
+        r = DRAW_MUL(_r, _a);
+        g = DRAW_MUL(_g, _a);
+        b = DRAW_MUL(_b, _a);
+        a = _a;
+    } else {
+        r = _r;
+        g = _g;
+        b = _b;
+        a = _a;
+    }
+    inva = (a ^ 0xff);
+
+    if (y1 == y2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
+            break;
+        default:
+            HLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
+            break;
+        }
+    } else if (x1 == x2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
+            break;
+        default:
+            VLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
+            break;
+        }
+    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
+            break;
+        default:
+            DLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
+            break;
+        }
+    } else {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY2_BLEND_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY2_ADD_RGB, DRAW_SETPIXELXY2_ADD_RGB,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY2_MOD_RGB, DRAW_SETPIXELXY2_MOD_RGB,
+                   draw_end);
+            break;
+        default:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY2_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
+                   draw_end);
+            break;
+        }
+    }
+}
+
+static void
+SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
+                     SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
+                     SDL_bool draw_end)
+{
+    const SDL_PixelFormat *fmt = dst->format;
+    unsigned r, g, b, a, inva;
+
+    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
+        r = DRAW_MUL(_r, _a);
+        g = DRAW_MUL(_g, _a);
+        b = DRAW_MUL(_b, _a);
+        a = _a;
+    } else {
+        r = _r;
+        g = _g;
+        b = _b;
+        a = _a;
+    }
+    inva = (a ^ 0xff);
+
+    if (y1 == y2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
+            break;
+        default:
+            HLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
+            break;
+        }
+    } else if (x1 == x2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
+            break;
+        default:
+            VLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
+            break;
+        }
+    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
+            break;
+        default:
+            DLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
+            break;
+        }
+    } else {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_BLEND_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_ADD_RGB555, DRAW_SETPIXELXY_ADD_RGB555,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_MOD_RGB555, DRAW_SETPIXELXY_MOD_RGB555,
+                   draw_end);
+            break;
+        default:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
+                   draw_end);
+            break;
+        }
+    }
+}
+
+static void
+SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
+                     SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
+                     SDL_bool draw_end)
+{
+    const SDL_PixelFormat *fmt = dst->format;
+    unsigned r, g, b, a, inva;
+
+    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
+        r = DRAW_MUL(_r, _a);
+        g = DRAW_MUL(_g, _a);
+        b = DRAW_MUL(_b, _a);
+        a = _a;
+    } else {
+        r = _r;
+        g = _g;
+        b = _b;
+        a = _a;
+    }
+    inva = (a ^ 0xff);
+
+    if (y1 == y2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
+            break;
+        default:
+            HLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
+            break;
+        }
+    } else if (x1 == x2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
+            break;
+        default:
+            VLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
+            break;
+        }
+    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
+            break;
+        default:
+            DLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
+            break;
+        }
+    } else {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_BLEND_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_ADD_RGB565, DRAW_SETPIXELXY_ADD_RGB565,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_MOD_RGB565, DRAW_SETPIXELXY_MOD_RGB565,
+                   draw_end);
+            break;
+        default:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
+                   draw_end);
+            break;
+        }
+    }
+}
+
+static void
+SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
+                   SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
+                   SDL_bool draw_end)
+{
+    const SDL_PixelFormat *fmt = dst->format;
+    unsigned r, g, b, a, inva;
+
+    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
+        r = DRAW_MUL(_r, _a);
+        g = DRAW_MUL(_g, _a);
+        b = DRAW_MUL(_b, _a);
+        a = _a;
+    } else {
+        r = _r;
+        g = _g;
+        b = _b;
+        a = _a;
+    }
+    inva = (a ^ 0xff);
+
+    if (y1 == y2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
+            break;
+        default:
+            HLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
+            break;
+        }
+    } else if (x1 == x2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
+            break;
+        default:
+            VLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
+            break;
+        }
+    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
+            break;
+        default:
+            DLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
+            break;
+        }
+    } else {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY4_BLEND_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY4_ADD_RGB, DRAW_SETPIXELXY4_ADD_RGB,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY4_MOD_RGB, DRAW_SETPIXELXY4_MOD_RGB,
+                   draw_end);
+            break;
+        default:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY4_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
+                   draw_end);
+            break;
+        }
+    }
+}
+
+static void
+SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
+                    SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
+                    SDL_bool draw_end)
+{
+    const SDL_PixelFormat *fmt = dst->format;
+    unsigned r, g, b, a, inva;
+
+    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
+        r = DRAW_MUL(_r, _a);
+        g = DRAW_MUL(_g, _a);
+        b = DRAW_MUL(_b, _a);
+        a = _a;
+    } else {
+        r = _r;
+        g = _g;
+        b = _b;
+        a = _a;
+    }
+    inva = (a ^ 0xff);
+
+    if (y1 == y2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            HLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            HLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
+            break;
+        default:
+            HLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
+            break;
+        }
+    } else if (x1 == x2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            VLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            VLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
+            break;
+        default:
+            VLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
+            break;
+        }
+    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            DLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            DLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
+            break;
+        default:
+            DLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
+            break;
+        }
+    } else {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY4_BLEND_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY4_ADD_RGBA, DRAW_SETPIXELXY4_ADD_RGBA,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY4_MOD_RGBA, DRAW_SETPIXELXY4_MOD_RGBA,
+                   draw_end);
+            break;
+        default:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY4_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
+                   draw_end);
+            break;
+        }
+    }
+}
+
+static void
+SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
+                     SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
+                     SDL_bool draw_end)
+{
+    const SDL_PixelFormat *fmt = dst->format;
+    unsigned r, g, b, a, inva;
+
+    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
+        r = DRAW_MUL(_r, _a);
+        g = DRAW_MUL(_g, _a);
+        b = DRAW_MUL(_b, _a);
+        a = _a;
+    } else {
+        r = _r;
+        g = _g;
+        b = _b;
+        a = _a;
+    }
+    inva = (a ^ 0xff);
+
+    if (y1 == y2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
+            break;
+        default:
+            HLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
+            break;
+        }
+    } else if (x1 == x2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
+            break;
+        default:
+            VLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
+            break;
+        }
+    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
+            break;
+        default:
+            DLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
+            break;
+        }
+    } else {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_BLEND_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_ADD_RGB888, DRAW_SETPIXELXY_ADD_RGB888,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_MOD_RGB888, DRAW_SETPIXELXY_MOD_RGB888,
+                   draw_end);
+            break;
+        default:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
+                   draw_end);
+            break;
+        }
+    }
+}
+
+static void
+SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
+                       SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
+                       SDL_bool draw_end)
+{
+    const SDL_PixelFormat *fmt = dst->format;
+    unsigned r, g, b, a, inva;
+
+    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
+        r = DRAW_MUL(_r, _a);
+        g = DRAW_MUL(_g, _a);
+        b = DRAW_MUL(_b, _a);
+        a = _a;
+    } else {
+        r = _r;
+        g = _g;
+        b = _b;
+        a = _a;
+    }
+    inva = (a ^ 0xff);
+
+    if (y1 == y2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            HLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            HLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            HLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
+            break;
+        default:
+            HLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
+            break;
+        }
+    } else if (x1 == x2) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            VLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            VLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            VLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
+            break;
+        default:
+            VLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
+            break;
+        }
+    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            DLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            DLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            DLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
+            break;
+        default:
+            DLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
+            break;
+        }
+    } else {
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_BLEND_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_ADD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_ADD_ARGB8888, DRAW_SETPIXELXY_ADD_ARGB8888,
+                   draw_end);
+            break;
+        case SDL_BLENDMODE_MOD:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_MOD_ARGB8888, DRAW_SETPIXELXY_MOD_ARGB8888,
+                   draw_end);
+            break;
+        default:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
+                   draw_end);
+            break;
+        }
+    }
+}
+
+typedef void (*BlendLineFunc) (SDL_Surface * dst,
+                               int x1, int y1, int x2, int y2,
+                               SDL_BlendMode blendMode,
+                               Uint8 r, Uint8 g, Uint8 b, Uint8 a,
+                               SDL_bool draw_end);
+
+static BlendLineFunc
+SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt)
+{
+    switch (fmt->BytesPerPixel) {
+    case 2:
+        if (fmt->Rmask == 0x7C00) {
+            return SDL_BlendLine_RGB555;
+        } else if (fmt->Rmask == 0xF800) {
+            return SDL_BlendLine_RGB565;
+        } else {
+            return SDL_BlendLine_RGB2;
+        }
+        break;
+    case 4:
+        if (fmt->Rmask == 0x00FF0000) {
+            if (fmt->Amask) {
+                return SDL_BlendLine_ARGB8888;
+            } else {
+                return SDL_BlendLine_RGB888;
+            }
+        } else {
+            if (fmt->Amask) {
+                return SDL_BlendLine_RGBA4;
+            } else {
+                return SDL_BlendLine_RGB4;
+            }
+        }
+    }
+    return NULL;
+}
+
+int
+SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
+              SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    BlendLineFunc func;
+
+    if (!dst) {
+        SDL_SetError("SDL_BlendLine(): Passed NULL destination surface");
+        return -1;
+    }
+
+    func = SDL_CalculateBlendLineFunc(dst->format);
+    if (!func) {
+        SDL_SetError("SDL_BlendLine(): Unsupported surface format");
+        return -1;
+    }
+
+    /* Perform clipping */
+    /* FIXME: We don't actually want to clip, as it may change line slope */
+    if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
+        return 0;
+    }
+
+    func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_TRUE);
+    return 0;
+}
+
+int
+SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
+               SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    int i;
+    int x1, y1;
+    int x2, y2;
+    SDL_bool draw_end;
+    BlendLineFunc func;
+
+    if (!dst) {
+        SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
+        return -1;
+    }
+
+    func = SDL_CalculateBlendLineFunc(dst->format);
+    if (!func) {
+        SDL_SetError("SDL_BlendLines(): Unsupported surface format");
+        return -1;
+    }
+
+    for (i = 1; i < count; ++i) {
+        x1 = points[i-1].x;
+        y1 = points[i-1].y;
+        x2 = points[i].x;
+        y2 = points[i].y;
+
+        /* Perform clipping */
+        /* FIXME: We don't actually want to clip, as it may change line slope */
+        if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
+            continue;
+        }
+
+        /* Draw the end if it was clipped */
+        draw_end = (x2 != points[i].x || y2 != points[i].y);
+
+        func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end);
+    }
+    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
+        SDL_BlendPoint(dst, points[count-1].x, points[count-1].y,
+                       blendMode, r, g, b, a);
+    }
+    return 0;
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_blendline.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,28 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+
+extern int SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
+extern int SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_blendpoint.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,346 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_draw.h"
+#include "SDL_blendpoint.h"
+
+
+static int
+SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
+                      Uint8 g, Uint8 b, Uint8 a)
+{
+    unsigned inva = 0xff - a;
+
+    switch (blendMode) {
+    case SDL_BLENDMODE_BLEND:
+        DRAW_SETPIXELXY_BLEND_RGB555(x, y);
+        break;
+    case SDL_BLENDMODE_ADD:
+        DRAW_SETPIXELXY_ADD_RGB555(x, y);
+        break;
+    case SDL_BLENDMODE_MOD:
+        DRAW_SETPIXELXY_MOD_RGB555(x, y);
+        break;
+    default:
+        DRAW_SETPIXELXY_RGB555(x, y);
+        break;
+    }
+    return 0;
+}
+
+static int
+SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
+                      Uint8 g, Uint8 b, Uint8 a)
+{
+    unsigned inva = 0xff - a;
+
+    switch (blendMode) {
+    case SDL_BLENDMODE_BLEND:
+        DRAW_SETPIXELXY_BLEND_RGB565(x, y);
+        break;
+    case SDL_BLENDMODE_ADD:
+        DRAW_SETPIXELXY_ADD_RGB565(x, y);
+        break;
+    case SDL_BLENDMODE_MOD:
+        DRAW_SETPIXELXY_MOD_RGB565(x, y);
+        break;
+    default:
+        DRAW_SETPIXELXY_RGB565(x, y);
+        break;
+    }
+    return 0;
+}
+
+static int
+SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
+                      Uint8 g, Uint8 b, Uint8 a)
+{
+    unsigned inva = 0xff - a;
+
+    switch (blendMode) {
+    case SDL_BLENDMODE_BLEND:
+        DRAW_SETPIXELXY_BLEND_RGB888(x, y);
+        break;
+    case SDL_BLENDMODE_ADD:
+        DRAW_SETPIXELXY_ADD_RGB888(x, y);
+        break;
+    case SDL_BLENDMODE_MOD:
+        DRAW_SETPIXELXY_MOD_RGB888(x, y);
+        break;
+    default:
+        DRAW_SETPIXELXY_RGB888(x, y);
+        break;
+    }
+    return 0;
+}
+
+static int
+SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
+                        Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    unsigned inva = 0xff - a;
+
+    switch (blendMode) {
+    case SDL_BLENDMODE_BLEND:
+        DRAW_SETPIXELXY_BLEND_ARGB8888(x, y);
+        break;
+    case SDL_BLENDMODE_ADD:
+        DRAW_SETPIXELXY_ADD_ARGB8888(x, y);
+        break;
+    case SDL_BLENDMODE_MOD:
+        DRAW_SETPIXELXY_MOD_ARGB8888(x, y);
+        break;
+    default:
+        DRAW_SETPIXELXY_ARGB8888(x, y);
+        break;
+    }
+    return 0;
+}
+
+static int
+SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
+                   Uint8 g, Uint8 b, Uint8 a)
+{
+    SDL_PixelFormat *fmt = dst->format;
+    unsigned inva = 0xff - a;
+
+    switch (fmt->BytesPerPixel) {
+    case 2:
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            DRAW_SETPIXELXY2_BLEND_RGB(x, y);
+            break;
+        case SDL_BLENDMODE_ADD:
+            DRAW_SETPIXELXY2_ADD_RGB(x, y);
+            break;
+        case SDL_BLENDMODE_MOD:
+            DRAW_SETPIXELXY2_MOD_RGB(x, y);
+            break;
+        default:
+            DRAW_SETPIXELXY2_RGB(x, y);
+            break;
+        }
+        return 0;
+    case 4:
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            DRAW_SETPIXELXY4_BLEND_RGB(x, y);
+            break;
+        case SDL_BLENDMODE_ADD:
+            DRAW_SETPIXELXY4_ADD_RGB(x, y);
+            break;
+        case SDL_BLENDMODE_MOD:
+            DRAW_SETPIXELXY4_MOD_RGB(x, y);
+            break;
+        default:
+            DRAW_SETPIXELXY4_RGB(x, y);
+            break;
+        }
+        return 0;
+    default:
+        SDL_Unsupported();
+        return -1;
+    }
+}
+
+static int
+SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
+                    Uint8 g, Uint8 b, Uint8 a)
+{
+    SDL_PixelFormat *fmt = dst->format;
+    unsigned inva = 0xff - a;
+
+    switch (fmt->BytesPerPixel) {
+    case 4:
+        switch (blendMode) {
+        case SDL_BLENDMODE_BLEND:
+            DRAW_SETPIXELXY4_BLEND_RGBA(x, y);
+            break;
+        case SDL_BLENDMODE_ADD:
+            DRAW_SETPIXELXY4_ADD_RGBA(x, y);
+            break;
+        case SDL_BLENDMODE_MOD:
+            DRAW_SETPIXELXY4_MOD_RGBA(x, y);
+            break;
+        default:
+            DRAW_SETPIXELXY4_RGBA(x, y);
+            break;
+        }
+        return 0;
+    default:
+        SDL_Unsupported();
+        return -1;
+    }
+}
+
+int
+SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
+               Uint8 g, Uint8 b, Uint8 a)
+{
+    if (!dst) {
+        SDL_SetError("Passed NULL destination surface");
+        return -1;
+    }
+
+    /* This function doesn't work on surfaces < 8 bpp */
+    if (dst->format->BitsPerPixel < 8) {
+        SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
+        return -1;
+    }
+
+    /* Perform clipping */
+    if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
+        x >= (dst->clip_rect.x + dst->clip_rect.w) ||
+        y >= (dst->clip_rect.y + dst->clip_rect.h)) {
+        return 0;
+    }
+
+    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
+        r = DRAW_MUL(r, a);
+        g = DRAW_MUL(g, a);
+        b = DRAW_MUL(b, a);
+    }
+
+    switch (dst->format->BitsPerPixel) {
+    case 15:
+        switch (dst->format->Rmask) {
+        case 0x7C00:
+            return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
+        }
+        break;
+    case 16:
+        switch (dst->format->Rmask) {
+        case 0xF800:
+            return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
+        }
+        break;
+    case 32:
+        switch (dst->format->Rmask) {
+        case 0x00FF0000:
+            if (!dst->format->Amask) {
+                return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b,
+                                             a);
+            } else {
+                return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b,
+                                               a);
+            }
+            break;
+        }
+        break;
+    default:
+        break;
+    }
+
+    if (!dst->format->Amask) {
+        return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
+    } else {
+        return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
+    }
+}
+
+int
+SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
+                SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    int minx, miny;
+    int maxx, maxy;
+    int i;
+    int x, y;
+    int (*func)(SDL_Surface * dst, int x, int y,
+                SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
+    int status = 0;
+
+    if (!dst) {
+        SDL_SetError("Passed NULL destination surface");
+        return -1;
+    }
+
+    /* This function doesn't work on surfaces < 8 bpp */
+    if (dst->format->BitsPerPixel < 8) {
+        SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
+        return (-1);
+    }
+
+    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
+        r = DRAW_MUL(r, a);
+        g = DRAW_MUL(g, a);
+        b = DRAW_MUL(b, a);
+    }
+
+    /* FIXME: Does this function pointer slow things down significantly? */
+    switch (dst->format->BitsPerPixel) {
+    case 15:
+        switch (dst->format->Rmask) {
+        case 0x7C00:
+            func = SDL_BlendPoint_RGB555;
+            break;
+        }
+        break;
+    case 16:
+        switch (dst->format->Rmask) {
+        case 0xF800:
+            func = SDL_BlendPoint_RGB565;
+            break;
+        }
+        break;
+    case 32:
+        switch (dst->format->Rmask) {
+        case 0x00FF0000:
+            if (!dst->format->Amask) {
+                func = SDL_BlendPoint_RGB888;
+            } else {
+                func = SDL_BlendPoint_ARGB8888;
+            }
+            break;
+        }
+        break;
+    default:
+        break;
+    }
+
+    if (!func) {
+        if (!dst->format->Amask) {
+            func = SDL_BlendPoint_RGB;
+        } else {
+            func = SDL_BlendPoint_RGBA;
+        }
+    }
+
+    minx = dst->clip_rect.x;
+    maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
+    miny = dst->clip_rect.y;
+    maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
+
+    for (i = 0; i < count; ++i) {
+        x = points[i].x;
+        y = points[i].y;
+
+        if (x < minx || x > maxx || y < miny || y > maxy) {
+            continue;
+        }
+        status = func(dst, x, y, blendMode, r, g, b, a);
+    }
+    return status;
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_blendpoint.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,28 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+
+extern int SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
+extern int SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_draw.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,576 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "../../video/SDL_blit.h"
+
+/* This code assumes that r, g, b, a are the source color,
+ * and in the blend and add case, the RGB values are premultiplied by a.
+ */
+
+#define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255)
+
+#define DRAW_FASTSETPIXEL(type) \
+    *pixel = (type) color
+
+#define DRAW_FASTSETPIXEL1 DRAW_FASTSETPIXEL(Uint8)
+#define DRAW_FASTSETPIXEL2 DRAW_FASTSETPIXEL(Uint16)
+#define DRAW_FASTSETPIXEL4 DRAW_FASTSETPIXEL(Uint32)
+
+#define DRAW_FASTSETPIXELXY(x, y, type, bpp, color) \
+    *(type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
+                                   + (x) * bpp) = (type) color
+
+#define DRAW_FASTSETPIXELXY1(x, y) DRAW_FASTSETPIXELXY(x, y, Uint8, 1, color)
+#define DRAW_FASTSETPIXELXY2(x, y) DRAW_FASTSETPIXELXY(x, y, Uint16, 2, color)
+#define DRAW_FASTSETPIXELXY4(x, y) DRAW_FASTSETPIXELXY(x, y, Uint32, 4, color)
+
+#define DRAW_SETPIXEL(setpixel) \
+do { \
+    unsigned sr = r, sg = g, sb = b, sa = a; \
+    setpixel; \
+} while (0)
+
+#define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \
+do { \
+    unsigned sr, sg, sb, sa; sa; \
+    getpixel; \
+    sr = DRAW_MUL(inva, sr) + r; \
+    sg = DRAW_MUL(inva, sg) + g; \
+    sb = DRAW_MUL(inva, sb) + b; \
+    setpixel; \
+} while (0)
+
+#define DRAW_SETPIXEL_ADD(getpixel, setpixel) \
+do { \
+    unsigned sr, sg, sb, sa; sa; \
+    getpixel; \
+    sr += r; if (sr > 0xff) sr = 0xff; \
+    sg += g; if (sg > 0xff) sg = 0xff; \
+    sb += b; if (sb > 0xff) sb = 0xff; \
+    setpixel; \
+} while (0)
+
+#define DRAW_SETPIXEL_MOD(getpixel, setpixel) \
+do { \
+    unsigned sr, sg, sb, sa; sa; \
+    getpixel; \
+    sr = DRAW_MUL(sr, r); \
+    sg = DRAW_MUL(sg, g); \
+    sb = DRAW_MUL(sb, b); \
+    setpixel; \
+} while (0)
+
+#define DRAW_SETPIXELXY(x, y, type, bpp, op) \
+do { \
+    type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
+                                                + (x) * bpp); \
+    op; \
+} while (0)
+
+/*
+ * Define draw operators for RGB555
+ */
+
+#define DRAW_SETPIXEL_RGB555 \
+    DRAW_SETPIXEL(RGB555_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXEL_BLEND_RGB555 \
+    DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
+                        RGB555_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXEL_ADD_RGB555 \
+    DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
+                      RGB555_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXEL_MOD_RGB555 \
+    DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
+                      RGB555_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXELXY_RGB555(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555)
+
+#define DRAW_SETPIXELXY_BLEND_RGB555(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB555)
+
+#define DRAW_SETPIXELXY_ADD_RGB555(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555)
+
+#define DRAW_SETPIXELXY_MOD_RGB555(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB555)
+
+/*
+ * Define draw operators for RGB565
+ */
+
+#define DRAW_SETPIXEL_RGB565 \
+    DRAW_SETPIXEL(RGB565_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXEL_BLEND_RGB565 \
+    DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
+                        RGB565_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXEL_ADD_RGB565 \
+    DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
+                      RGB565_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXEL_MOD_RGB565 \
+    DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
+                      RGB565_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXELXY_RGB565(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565)
+
+#define DRAW_SETPIXELXY_BLEND_RGB565(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB565)
+
+#define DRAW_SETPIXELXY_ADD_RGB565(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565)
+
+#define DRAW_SETPIXELXY_MOD_RGB565(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB565)
+
+/*
+ * Define draw operators for RGB888
+ */
+
+#define DRAW_SETPIXEL_RGB888 \
+    DRAW_SETPIXEL(RGB888_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXEL_BLEND_RGB888 \
+    DRAW_SETPIXEL_BLEND(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
+                        RGB888_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXEL_ADD_RGB888 \
+    DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
+                      RGB888_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXEL_MOD_RGB888 \
+    DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
+                      RGB888_FROM_RGB(*pixel, sr, sg, sb))
+
+#define DRAW_SETPIXELXY_RGB888(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888)
+
+#define DRAW_SETPIXELXY_BLEND_RGB888(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB888)
+
+#define DRAW_SETPIXELXY_ADD_RGB888(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888)
+
+#define DRAW_SETPIXELXY_MOD_RGB888(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888)
+
+/*
+ * Define draw operators for ARGB8888
+ */
+
+#define DRAW_SETPIXEL_ARGB8888 \
+    DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
+
+#define DRAW_SETPIXEL_BLEND_ARGB8888 \
+    DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
+                        ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
+
+#define DRAW_SETPIXEL_ADD_ARGB8888 \
+    DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
+                      ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
+
+#define DRAW_SETPIXEL_MOD_ARGB8888 \
+    DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
+                      ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
+
+#define DRAW_SETPIXELXY_ARGB8888(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888)
+
+#define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888)
+
+#define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888)
+
+#define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888)
+
+/*
+ * Define draw operators for general RGB
+ */
+
+#define DRAW_SETPIXEL_RGB \
+    DRAW_SETPIXEL(PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
+
+#define DRAW_SETPIXEL_BLEND_RGB \
+    DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
+                        PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
+
+#define DRAW_SETPIXEL_ADD_RGB \
+    DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
+                      PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
+
+#define DRAW_SETPIXEL_MOD_RGB \
+    DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
+                      PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
+
+#define DRAW_SETPIXELXY2_RGB(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB)
+
+#define DRAW_SETPIXELXY4_RGB(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB)
+
+#define DRAW_SETPIXELXY2_BLEND_RGB(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB)
+
+#define DRAW_SETPIXELXY4_BLEND_RGB(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB)
+
+#define DRAW_SETPIXELXY2_ADD_RGB(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB)
+
+#define DRAW_SETPIXELXY4_ADD_RGB(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB)
+
+#define DRAW_SETPIXELXY2_MOD_RGB(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB)
+
+#define DRAW_SETPIXELXY4_MOD_RGB(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB)
+
+
+/*
+ * Define draw operators for general RGBA
+ */
+
+#define DRAW_SETPIXEL_RGBA \
+    DRAW_SETPIXEL(PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
+
+#define DRAW_SETPIXEL_BLEND_RGBA \
+    DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
+                        PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
+
+#define DRAW_SETPIXEL_ADD_RGBA \
+    DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
+                      PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
+
+#define DRAW_SETPIXEL_MOD_RGBA \
+    DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
+                      PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
+
+#define DRAW_SETPIXELXY4_RGBA(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA)
+
+#define DRAW_SETPIXELXY4_BLEND_RGBA(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGBA)
+
+#define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA)
+
+#define DRAW_SETPIXELXY4_MOD_RGBA(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGBA)
+
+/*
+ * Define line drawing macro
+ */
+
+#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
+
+/* Horizontal line */
+#define HLINE(type, op, draw_end) \
+{ \
+    int length; \
+    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
+    type *pixel; \
+    if (x1 <= x2) { \
+        pixel = (type *)dst->pixels + y1 * pitch + x1; \
+        length = draw_end ? (x2-x1+1) : (x2-x1); \
+    } else { \
+        pixel = (type *)dst->pixels + y1 * pitch + x2; \
+        if (!draw_end) { \
+            ++pixel; \
+        } \
+        length = draw_end ? (x1-x2+1) : (x1-x2); \
+    } \
+    while (length--) { \
+        op; \
+        ++pixel; \
+    } \
+}
+
+/* Vertical line */
+#define VLINE(type, op, draw_end) \
+{ \
+    int length; \
+    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
+    type *pixel; \
+    if (y1 <= y2) { \
+        pixel = (type *)dst->pixels + y1 * pitch + x1; \
+        length = draw_end ? (y2-y1+1) : (y2-y1); \
+    } else { \
+        pixel = (type *)dst->pixels + y2 * pitch + x1; \
+        if (!draw_end) { \
+            pixel += pitch; \
+        } \
+        length = draw_end ? (y1-y2+1) : (y1-y2); \
+    } \
+    while (length--) { \
+        op; \
+        pixel += pitch; \
+    } \
+}
+
+/* Diagonal line */
+#define DLINE(type, op, draw_end) \
+{ \
+    int length; \
+    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
+    type *pixel; \
+    if (y1 <= y2) { \
+        pixel = (type *)dst->pixels + y1 * pitch + x1; \
+        if (x1 <= x2) { \
+            ++pitch; \
+        } else { \
+            --pitch; \
+        } \
+        length = (y2-y1); \
+    } else { \
+        pixel = (type *)dst->pixels + y2 * pitch + x2; \
+        if (x2 <= x1) { \
+            ++pitch; \
+        } else { \
+            --pitch; \
+        } \
+        if (!draw_end) { \
+            pixel += pitch; \
+        } \
+        length = (y1-y2); \
+    } \
+    if (draw_end) { \
+        ++length; \
+    } \
+    while (length--) { \
+        op; \
+        pixel += pitch; \
+    } \
+}
+
+/* Bresenham's line algorithm */
+#define BLINE(x1, y1, x2, y2, op, draw_end) \
+{ \
+    int i, deltax, deltay, numpixels; \
+    int d, dinc1, dinc2; \
+    int x, xinc1, xinc2; \
+    int y, yinc1, yinc2; \
+ \
+    deltax = ABS(x2 - x1); \
+    deltay = ABS(y2 - y1); \
+ \
+    if (deltax >= deltay) { \
+        numpixels = deltax + 1; \
+        d = (2 * deltay) - deltax; \
+        dinc1 = deltay * 2; \
+        dinc2 = (deltay - deltax) * 2; \
+        xinc1 = 1; \
+        xinc2 = 1; \
+        yinc1 = 0; \
+        yinc2 = 1; \
+    } else { \
+        numpixels = deltay + 1; \
+        d = (2 * deltax) - deltay; \
+        dinc1 = deltax * 2; \
+        dinc2 = (deltax - deltay) * 2; \
+        xinc1 = 0; \
+        xinc2 = 1; \
+        yinc1 = 1; \
+        yinc2 = 1; \
+    } \
+ \
+    if (x1 > x2) { \
+        xinc1 = -xinc1; \
+        xinc2 = -xinc2; \
+    } \
+    if (y1 > y2) { \
+        yinc1 = -yinc1; \
+        yinc2 = -yinc2; \
+    } \
+ \
+    x = x1; \
+    y = y1; \
+ \
+    if (!draw_end) { \
+        --numpixels; \
+    } \
+    for (i = 0; i < numpixels; ++i) { \
+        op(x, y); \
+        if (d < 0) { \
+            d += dinc1; \
+            x += xinc1; \
+            y += yinc1; \
+        } else { \
+            d += dinc2; \
+            x += xinc2; \
+            y += yinc2; \
+        } \
+    } \
+}
+
+/* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */
+#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
+{ \
+    Uint16 ErrorAdj, ErrorAcc; \
+    Uint16 ErrorAccTemp, Weighting; \
+    int DeltaX, DeltaY, Temp, XDir; \
+    unsigned r, g, b, a, inva; \
+ \
+    /* Draw the initial pixel, which is always exactly intersected by \
+       the line and so needs no weighting */ \
+    opaque_op(x1, y1); \
+ \
+    /* Draw the final pixel, which is always exactly intersected by the line \
+       and so needs no weighting */ \
+    if (draw_end) { \
+        opaque_op(x2, y2); \
+    } \
+ \
+    /* Make sure the line runs top to bottom */ \
+    if (y1 > y2) { \
+        Temp = y1; y1 = y2; y2 = Temp; \
+        Temp = x1; x1 = x2; x2 = Temp; \
+    } \
+    DeltaY = y2 - y1; \
+ \
+    if ((DeltaX = x2 - x1) >= 0) { \
+        XDir = 1; \
+    } else { \
+        XDir = -1; \
+        DeltaX = -DeltaX; /* make DeltaX positive */ \
+    } \
+ \
+    /* line is not horizontal, diagonal, or vertical */ \
+    ErrorAcc = 0;  /* initialize the line error accumulator to 0 */ \
+ \
+    /* Is this an X-major or Y-major line? */ \
+    if (DeltaY > DeltaX) { \
+        /* Y-major line; calculate 16-bit fixed-point fractional part of a \
+          pixel that X advances each time Y advances 1 pixel, truncating the \
+          result so that we won't overrun the endpoint along the X axis */ \
+        ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; \
+        /* Draw all pixels other than the first and last */ \
+        while (--DeltaY) { \
+            ErrorAccTemp = ErrorAcc;   /* remember currrent accumulated error */ \
+            ErrorAcc += ErrorAdj;      /* calculate error for next pixel */ \
+            if (ErrorAcc <= ErrorAccTemp) { \
+                /* The error accumulator turned over, so advance the X coord */ \
+                x1 += XDir; \
+            } \
+            y1++; /* Y-major, so always advance Y */ \
+            /* The IntensityBits most significant bits of ErrorAcc give us the \
+             intensity weighting for this pixel, and the complement of the \
+             weighting for the paired pixel */ \
+            Weighting = ErrorAcc >> 8; \
+            { \
+                a = DRAW_MUL(_a, (Weighting ^ 255)); \
+                r = DRAW_MUL(_r, a); \
+                g = DRAW_MUL(_g, a); \
+                b = DRAW_MUL(_b, a); \
+                inva = (a ^ 0xFF); \
+                blend_op(x1, y1); \
+            } \
+            { \
+                a = DRAW_MUL(_a, Weighting); \
+                r = DRAW_MUL(_r, a); \
+                g = DRAW_MUL(_g, a); \
+                b = DRAW_MUL(_b, a); \
+                inva = (a ^ 0xFF); \
+                blend_op(x1 + XDir, y1); \
+            } \
+        } \
+    } else { \
+        /* X-major line; calculate 16-bit fixed-point fractional part of a \
+           pixel that Y advances each time X advances 1 pixel, truncating the \
+           result to avoid overrunning the endpoint along the X axis */ \
+        ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; \
+        /* Draw all pixels other than the first and last */ \
+        while (--DeltaX) { \
+            ErrorAccTemp = ErrorAcc;   /* remember currrent accumulated error */ \
+            ErrorAcc += ErrorAdj;      /* calculate error for next pixel */ \
+            if (ErrorAcc <= ErrorAccTemp) { \
+                /* The error accumulator turned over, so advance the Y coord */ \
+                y1++; \
+            } \
+            x1 += XDir; /* X-major, so always advance X */ \
+            /* The IntensityBits most significant bits of ErrorAcc give us the \
+              intensity weighting for this pixel, and the complement of the \
+              weighting for the paired pixel */ \
+            Weighting = ErrorAcc >> 8; \
+            { \
+                a = DRAW_MUL(_a, (Weighting ^ 255)); \
+                r = DRAW_MUL(_r, a); \
+                g = DRAW_MUL(_g, a); \
+                b = DRAW_MUL(_b, a); \
+                inva = (a ^ 0xFF); \
+                blend_op(x1, y1); \
+            } \
+            { \
+                a = DRAW_MUL(_a, Weighting); \
+                r = DRAW_MUL(_r, a); \
+                g = DRAW_MUL(_g, a); \
+                b = DRAW_MUL(_b, a); \
+                inva = (a ^ 0xFF); \
+                blend_op(x1, y1 + 1); \
+            } \
+        } \
+    } \
+}
+
+#ifdef AA_LINES
+#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
+            WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
+#else
+#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
+            BLINE(x1, y1, x2, y2, opaque_op, draw_end)
+#endif
+
+/*
+ * Define fill rect macro
+ */
+
+#define FILLRECT(type, op) \
+do { \
+    int width = rect->w; \
+    int height = rect->h; \
+    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
+    int skip = pitch - width; \
+    type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
+    while (height--) { \
+        { int n = (width+3)/4; \
+            switch (width & 3) { \
+            case 0: do {   op; pixel++; \
+            case 3:        op; pixel++; \
+            case 2:        op; pixel++; \
+            case 1:        op; pixel++; \
+                    } while ( --n > 0 ); \
+            } \
+        } \
+        pixel += skip; \
+    } \
+} while (0)
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_drawline.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,211 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_draw.h"
+#include "SDL_drawline.h"
+#include "SDL_drawpoint.h"
+
+
+static void
+SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
+              SDL_bool draw_end)
+{
+    if (y1 == y2) {
+        //HLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
+        int length;
+        int pitch = (dst->pitch / dst->format->BytesPerPixel);
+        Uint8 *pixel;
+        if (x1 <= x2) {
+            pixel = (Uint8 *)dst->pixels + y1 * pitch + x1;
+            length = draw_end ? (x2-x1+1) : (x2-x1);
+        } else {
+            pixel = (Uint8 *)dst->pixels + y1 * pitch + x2;
+            if (!draw_end) {
+                ++pixel;
+            }
+            length = draw_end ? (x1-x2+1) : (x1-x2);
+        }
+        SDL_memset(pixel, color, length);
+    } else if (x1 == x2) {
+        VLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
+    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
+        DLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
+    } else {
+        BLINE(x1, y1, x2, y2, DRAW_FASTSETPIXELXY1, draw_end);
+    }
+}
+
+static void
+SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
+              SDL_bool draw_end)
+{
+    if (y1 == y2) {
+        HLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
+    } else if (x1 == x2) {
+        VLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
+    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
+        DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
+    } else {
+        Uint8 _r, _g, _b, _a;
+        const SDL_PixelFormat * fmt = dst->format;
+        SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
+        if (fmt->Rmask == 0x7C00) {
+            AALINE(x1, y1, x2, y2,
+                   DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB555,
+                   draw_end);
+        } else if (fmt->Rmask == 0xF800) {
+            AALINE(x1, y1, x2, y2,
+                   DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB565,
+                   draw_end);
+        } else {
+            AALINE(x1, y1, x2, y2,
+                   DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY2_BLEND_RGB,
+                   draw_end);
+        }
+    }
+}
+
+static void
+SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
+              SDL_bool draw_end)
+{
+    if (y1 == y2) {
+        HLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
+    } else if (x1 == x2) {
+        VLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
+    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
+        DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
+    } else {
+        Uint8 _r, _g, _b, _a;
+        const SDL_PixelFormat * fmt = dst->format;
+        SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
+        if (fmt->Rmask == 0x00FF0000) {
+            if (!fmt->Amask) {
+                AALINE(x1, y1, x2, y2,
+                       DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_RGB888,
+                       draw_end);
+            } else {
+                AALINE(x1, y1, x2, y2,
+                       DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_ARGB8888,
+                       draw_end);
+            }
+        } else {
+            AALINE(x1, y1, x2, y2,
+                   DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY4_BLEND_RGB,
+                   draw_end);
+        }
+    }
+}
+
+typedef void (*DrawLineFunc) (SDL_Surface * dst,
+                              int x1, int y1, int x2, int y2,
+                              Uint32 color, SDL_bool draw_end);
+
+static DrawLineFunc
+SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt)
+{
+    switch (fmt->BytesPerPixel) {
+    case 1:
+        if (fmt->BitsPerPixel < 8) {
+            break;
+        }
+        return SDL_DrawLine1;
+    case 2:
+        return SDL_DrawLine2;
+    case 4:
+        return SDL_DrawLine4;
+    }
+    return NULL;
+}
+
+int
+SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
+{
+    DrawLineFunc func;
+
+    if (!dst) {
+        SDL_SetError("SDL_DrawLine(): Passed NULL destination surface");
+        return -1;
+    }
+
+    func = SDL_CalculateDrawLineFunc(dst->format);
+    if (!func) {
+        SDL_SetError("SDL_DrawLine(): Unsupported surface format");
+        return -1;
+    }
+
+    /* Perform clipping */
+    /* FIXME: We don't actually want to clip, as it may change line slope */
+    if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
+        return 0;
+    }
+
+    func(dst, x1, y1, x2, y2, color, SDL_TRUE);
+    return 0;
+}
+
+int
+SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
+              Uint32 color)
+{
+    int i;
+    int x1, y1;
+    int x2, y2;
+    SDL_bool draw_end;
+    DrawLineFunc func;
+
+    if (!dst) {
+        SDL_SetError("SDL_DrawLines(): Passed NULL destination surface");
+        return -1;
+    }
+
+    func = SDL_CalculateDrawLineFunc(dst->format);
+    if (!func) {
+        SDL_SetError("SDL_DrawLines(): Unsupported surface format");
+        return -1;
+    }
+
+    for (i = 1; i < count; ++i) {
+        x1 = points[i-1].x;
+        y1 = points[i-1].y;
+        x2 = points[i].x;
+        y2 = points[i].y;
+
+        /* Perform clipping */
+        /* FIXME: We don't actually want to clip, as it may change line slope */
+        if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
+            continue;
+        }
+
+        /* Draw the end if it was clipped */
+        draw_end = (x2 != points[i].x || y2 != points[i].y);
+
+        func(dst, x1, y1, x2, y2, color, draw_end);
+    }
+    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
+        SDL_DrawPoint(dst, points[count-1].x, points[count-1].y, color);
+    }
+    return 0;
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_drawline.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,28 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+
+extern int SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color);
+extern int SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_drawpoint.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,117 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_draw.h"
+#include "SDL_drawpoint.h"
+
+
+int
+SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
+{
+    if (!dst) {
+        SDL_SetError("Passed NULL destination surface");
+        return -1;
+    }
+
+    /* This function doesn't work on surfaces < 8 bpp */
+    if (dst->format->BitsPerPixel < 8) {
+        SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
+        return -1;
+    }
+
+    /* Perform clipping */
+    if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
+        x >= (dst->clip_rect.x + dst->clip_rect.w) ||
+        y >= (dst->clip_rect.y + dst->clip_rect.h)) {
+        return 0;
+    }
+
+    switch (dst->format->BytesPerPixel) {
+    case 1:
+        DRAW_FASTSETPIXELXY1(x, y);
+        break;
+    case 2:
+        DRAW_FASTSETPIXELXY2(x, y);
+        break;
+    case 3:
+        SDL_Unsupported();
+        return -1;
+    case 4:
+        DRAW_FASTSETPIXELXY4(x, y);
+        break;
+    }
+    return 0;
+}
+
+int
+SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
+               Uint32 color)
+{
+    int minx, miny;
+    int maxx, maxy;
+    int i;
+    int x, y;
+
+    if (!dst) {
+        SDL_SetError("Passed NULL destination surface");
+        return -1;
+    }
+
+    /* This function doesn't work on surfaces < 8 bpp */
+    if (dst->format->BitsPerPixel < 8) {
+        SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
+        return -1;
+    }
+
+    minx = dst->clip_rect.x;
+    maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
+    miny = dst->clip_rect.y;
+    maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
+
+    for (i = 0; i < count; ++i) {
+        x = points[i].x;
+        y = points[i].y;
+
+        if (x < minx || x > maxx || y < miny || y > maxy) {
+            continue;
+        }
+
+        switch (dst->format->BytesPerPixel) {
+        case 1:
+            DRAW_FASTSETPIXELXY1(x, y);
+            break;
+        case 2:
+            DRAW_FASTSETPIXELXY2(x, y);
+            break;
+        case 3:
+            SDL_Unsupported();
+            return -1;
+        case 4:
+            DRAW_FASTSETPIXELXY4(x, y);
+            break;
+        }
+    }
+    return 0;
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_drawpoint.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,28 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+
+extern int SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color);
+extern int SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_render_sw.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,418 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "../SDL_sysrender.h"
+#include "../../video/SDL_pixels_c.h"
+
+#include "SDL_draw.h"
+#include "SDL_blendfillrect.h"
+#include "SDL_blendline.h"
+#include "SDL_blendpoint.h"
+#include "SDL_drawline.h"
+#include "SDL_drawpoint.h"
+
+
+/* SDL surface based renderer implementation */
+
+static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags);
+static void SW_WindowEvent(SDL_Renderer * renderer,
+                           const SDL_WindowEvent *event);
+static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int SW_SetTextureColorMod(SDL_Renderer * renderer,
+                                 SDL_Texture * texture);
+static int SW_SetTextureAlphaMod(SDL_Renderer * renderer,
+                                 SDL_Texture * texture);
+static int SW_SetTextureBlendMode(SDL_Renderer * renderer,
+                                  SDL_Texture * texture);
+static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                            const SDL_Rect * rect, const void *pixels,
+                            int pitch);
+static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                          const SDL_Rect * rect, void **pixels, int *pitch);
+static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int SW_RenderDrawPoints(SDL_Renderer * renderer,
+                               const SDL_Point * points, int count);
+static int SW_RenderDrawLines(SDL_Renderer * renderer,
+                              const SDL_Point * points, int count);
+static int SW_RenderFillRects(SDL_Renderer * renderer,
+                              const SDL_Rect ** rects, int count);
+static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
+static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                               Uint32 format, void * pixels, int pitch);
+static void SW_RenderPresent(SDL_Renderer * renderer);
+static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static void SW_DestroyRenderer(SDL_Renderer * renderer);
+
+
+SDL_RenderDriver SW_RenderDriver = {
+    SW_CreateRenderer,
+    {
+     "software",
+     0,
+     8,
+     {
+      SDL_PIXELFORMAT_RGB555,
+      SDL_PIXELFORMAT_RGB565,
+      SDL_PIXELFORMAT_RGB888,
+      SDL_PIXELFORMAT_BGR888,
+      SDL_PIXELFORMAT_ARGB8888,
+      SDL_PIXELFORMAT_RGBA8888,
+      SDL_PIXELFORMAT_ABGR8888,
+      SDL_PIXELFORMAT_BGRA8888
+     },
+     0,
+     0}
+};
+
+typedef struct
+{
+    SDL_bool updateSize;
+    SDL_Surface *surface;
+} SW_RenderData;
+
+
+SDL_Renderer *
+SW_CreateRendererForSurface(SDL_Surface * surface)
+{
+    SDL_Renderer *renderer;
+    SW_RenderData *data;
+
+    if (!surface) {
+        SDL_SetError("Can't create renderer for NULL surface");
+        return NULL;
+    }
+
+    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
+    if (!renderer) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        SW_DestroyRenderer(renderer);
+        SDL_OutOfMemory();
+        return NULL;
+    }
+    data->surface = surface;
+
+    renderer->WindowEvent = SW_WindowEvent;
+    renderer->CreateTexture = SW_CreateTexture;
+    renderer->SetTextureColorMod = SW_SetTextureColorMod;
+    renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod;
+    renderer->SetTextureBlendMode = SW_SetTextureBlendMode;
+    renderer->UpdateTexture = SW_UpdateTexture;
+    renderer->LockTexture = SW_LockTexture;
+    renderer->UnlockTexture = SW_UnlockTexture;
+    renderer->DestroyTexture = SW_DestroyTexture;
+    renderer->RenderDrawPoints = SW_RenderDrawPoints;
+    renderer->RenderDrawLines = SW_RenderDrawLines;
+    renderer->RenderFillRects = SW_RenderFillRects;
+    renderer->RenderCopy = SW_RenderCopy;
+    renderer->RenderReadPixels = SW_RenderReadPixels;
+    renderer->RenderPresent = SW_RenderPresent;
+    renderer->DestroyRenderer = SW_DestroyRenderer;
+    renderer->info = SW_RenderDriver.info;
+    renderer->driverdata = data;
+
+    return renderer;
+}
+
+SDL_Renderer *
+SW_CreateRenderer(SDL_Window * window, Uint32 flags)
+{
+    SDL_Surface *surface;
+
+    surface = SDL_GetWindowSurface(window);
+    if (!surface) {
+        return NULL;
+    }
+    return SW_CreateRendererForSurface(surface);
+}
+
+static SDL_Surface *
+SW_ActivateRenderer(SDL_Renderer * renderer)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+
+    if (data->updateSize) {
+        data->surface = SDL_GetWindowSurface(window);
+        data->updateSize = SDL_FALSE;
+    }
+    return data->surface;
+}
+
+static void
+SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+
+    if (event->event == SDL_WINDOWEVENT_RESIZED) {
+        data->updateSize = SDL_TRUE;
+    }
+}
+
+static int
+SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    int bpp;
+    Uint32 Rmask, Gmask, Bmask, Amask;
+
+    if (!SDL_PixelFormatEnumToMasks
+        (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
+        SDL_SetError("Unknown texture format");
+        return -1;
+    }
+
+    texture->driverdata =
+        SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask,
+                             Bmask, Amask);
+    SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g,
+                           texture->b);
+    SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a);
+    SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
+
+    if (texture->access == SDL_TEXTUREACCESS_STATIC) {
+        SDL_SetSurfaceRLE(texture->driverdata, 1);
+    }
+
+    if (!texture->driverdata) {
+        return -1;
+    }
+    return 0;
+}
+
+static int
+SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
+                                  texture->b);
+}
+
+static int
+SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    return SDL_SetSurfaceAlphaMod(surface, texture->a);
+}
+
+static int
+SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
+}
+
+static int
+SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                 const SDL_Rect * rect, const void *pixels, int pitch)
+{
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    Uint8 *src, *dst;
+    int row;
+    size_t length;
+
+    src = (Uint8 *) pixels;
+    dst = (Uint8 *) surface->pixels +
+                        rect->y * surface->pitch +
+                        rect->x * surface->format->BytesPerPixel;
+    length = rect->w * surface->format->BytesPerPixel;
+    for (row = 0; row < rect->h; ++row) {
+        SDL_memcpy(dst, src, length);
+        src += pitch;
+        dst += surface->pitch;
+    }
+    return 0;
+}
+
+static int
+SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+               const SDL_Rect * rect, void **pixels, int *pitch)
+{
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+
+    *pixels =
+        (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
+                  rect->x * surface->format->BytesPerPixel);
+    *pitch = surface->pitch;
+    return 0;
+}
+
+static void
+SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+}
+
+static int
+SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
+                    int count)
+{
+    SDL_Surface *surface = SW_ActivateRenderer(renderer);
+
+    if (!surface) {
+        return -1;
+    }
+
+    /* Draw the points! */
+    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
+        Uint32 color = SDL_MapRGBA(surface->format,
+                                   renderer->r, renderer->g, renderer->b,
+                                   renderer->a);
+
+        return SDL_DrawPoints(surface, points, count, color);
+    } else {
+        return SDL_BlendPoints(surface, points, count,
+                               renderer->blendMode,
+                               renderer->r, renderer->g, renderer->b,
+                               renderer->a);
+    }
+}
+
+static int
+SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
+                   int count)
+{
+    SDL_Surface *surface = SW_ActivateRenderer(renderer);
+
+    if (!surface) {
+        return -1;
+    }
+
+    /* Draw the lines! */
+    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
+        Uint32 color = SDL_MapRGBA(surface->format,
+                                   renderer->r, renderer->g, renderer->b,
+                                   renderer->a);
+
+        return SDL_DrawLines(surface, points, count, color);
+    } else {
+        return SDL_BlendLines(surface, points, count,
+                              renderer->blendMode,
+                              renderer->r, renderer->g, renderer->b,
+                              renderer->a);
+    }
+}
+
+static int
+SW_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
+                   int count)
+{
+    SDL_Surface *surface = SW_ActivateRenderer(renderer);
+
+    if (!surface) {
+        return -1;
+    }
+
+    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
+        Uint32 color = SDL_MapRGBA(surface->format,
+                                   renderer->r, renderer->g, renderer->b,
+                                   renderer->a);
+        return SDL_FillRects(surface, rects, count, color);
+    } else {
+        return SDL_BlendFillRects(surface, rects, count,
+                                     renderer->blendMode,
+                                     renderer->r, renderer->g, renderer->b,
+                                     renderer->a);
+    }
+}
+
+static int
+SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+{
+    SDL_Surface *surface = SW_ActivateRenderer(renderer);
+    SDL_Surface *src = (SDL_Surface *) texture->driverdata;
+    SDL_Rect final_rect = *dstrect;
+
+    if (!surface) {
+        return -1;
+    }
+    return SDL_BlitSurface(src, srcrect, surface, &final_rect);
+}
+
+static int
+SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                    Uint32 format, void * pixels, int pitch)
+{
+    SDL_Surface *surface = SW_ActivateRenderer(renderer);
+    Uint32 src_format;
+    void *src_pixels;
+
+    if (!surface) {
+        return -1;
+    }
+
+    if (rect->x < 0 || rect->x+rect->w > surface->w ||
+        rect->y < 0 || rect->y+rect->h > surface->h) {
+        SDL_SetError("Tried to read outside of surface bounds");
+        return -1;
+    }
+
+    src_format = SDL_MasksToPixelFormatEnum(
+                    surface->format->BitsPerPixel,
+                    surface->format->Rmask, surface->format->Gmask,
+                    surface->format->Bmask, surface->format->Amask);
+
+    src_pixels = (void*)((Uint8 *) surface->pixels +
+                    rect->y * surface->pitch +
+                    rect->x * surface->format->BytesPerPixel);
+
+    return SDL_ConvertPixels(rect->w, rect->h,
+                             src_format, src_pixels, surface->pitch,
+                             format, pixels, pitch);
+}
+
+static void
+SW_RenderPresent(SDL_Renderer * renderer)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+
+    if (window) {
+        SDL_UpdateWindowSurface(window);
+    }
+}
+
+static void
+SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+
+    SDL_FreeSurface(surface);
+}
+
+static void
+SW_DestroyRenderer(SDL_Renderer * renderer)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+
+    if (data) {
+        SDL_free(data);
+    }
+    SDL_free(renderer);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_render_sw_c.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,25 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+extern SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface * surface);
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_alphamult.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_blit.h"
-#include "SDL_alphamult.h"
-
-/* Functions to pre-multiply the alpha channel into the color channels */
-
-#define DEFINE_PREMULTIPLY_FUNC(fmt) \
-void \
-SDL_PreMultiplyAlpha##fmt(int w, int h, Uint32 *pixels, int pitch) \
-{ \
-    pitch /= 4; \
-    while (h--) { \
-        int n; \
-        Uint32 *row = pixels; \
-        Uint32 pixel; \
-        unsigned r, g, b, a; \
- \
-        for (n = w; n--; ) { \
-            pixel = *row; \
-            RGBA_FROM_##fmt(pixel, r, g, b, a); \
-            r = (r * a) / 255; \
-            g = (g * a) / 255; \
-            b = (b * a) / 255; \
-            fmt##_FROM_RGBA(*row, r, g, b, a); \
-            ++row; \
-        } \
-        pixels += pitch; \
-    } \
-}
-
-/* *INDENT-OFF* */
-DEFINE_PREMULTIPLY_FUNC(ARGB8888)
-DEFINE_PREMULTIPLY_FUNC(RGBA8888)
-DEFINE_PREMULTIPLY_FUNC(ABGR8888)
-DEFINE_PREMULTIPLY_FUNC(BGRA8888)
-/* *INDENT-ON* */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_alphamult.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-/* Functions to pre-multiply the alpha channel into the color channels */
-
-#define DEFINE_PREMULTIPLY_FUNC(fmt) \
-void \
-SDL_PreMultiplyAlpha##fmt(int w, int h, Uint32 *pixels, int pitch);
-
-/* *INDENT-OFF* */
-DEFINE_PREMULTIPLY_FUNC(ARGB8888)
-DEFINE_PREMULTIPLY_FUNC(RGBA8888)
-DEFINE_PREMULTIPLY_FUNC(ABGR8888)
-DEFINE_PREMULTIPLY_FUNC(BGRA8888)
-/* *INDENT-ON* */
-
-#undef DEFINE_PREMULTIPLY_FUNC
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_blendfillrect.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,347 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_video.h"
-#include "SDL_draw.h"
-
-static int
-SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
-                         SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    unsigned inva = 0xff - a;
-
-    switch (blendMode) {
-    case SDL_BLENDMODE_BLEND:
-        FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555);
-        break;
-    case SDL_BLENDMODE_ADD:
-        FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555);
-        break;
-    case SDL_BLENDMODE_MOD:
-        FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555);
-        break;
-    default:
-        FILLRECT(Uint16, DRAW_SETPIXEL_RGB555);
-        break;
-    }
-    return 0;
-}
-
-static int
-SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
-                         SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    unsigned inva = 0xff - a;
-
-    switch (blendMode) {
-    case SDL_BLENDMODE_BLEND:
-        FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565);
-        break;
-    case SDL_BLENDMODE_ADD:
-        FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565);
-        break;
-    case SDL_BLENDMODE_MOD:
-        FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565);
-        break;
-    default:
-        FILLRECT(Uint16, DRAW_SETPIXEL_RGB565);
-        break;
-    }
-    return 0;
-}
-
-static int
-SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
-                         SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    unsigned inva = 0xff - a;
-
-    switch (blendMode) {
-    case SDL_BLENDMODE_BLEND:
-        FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB888);
-        break;
-    case SDL_BLENDMODE_ADD:
-        FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888);
-        break;
-    case SDL_BLENDMODE_MOD:
-        FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888);
-        break;
-    default:
-        FILLRECT(Uint32, DRAW_SETPIXEL_RGB888);
-        break;
-    }
-    return 0;
-}
-
-static int
-SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
-                           SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    unsigned inva = 0xff - a;
-
-    switch (blendMode) {
-    case SDL_BLENDMODE_BLEND:
-        FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
-        break;
-    case SDL_BLENDMODE_ADD:
-        FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
-        break;
-    case SDL_BLENDMODE_MOD:
-        FILLRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
-        break;
-    default:
-        FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
-        break;
-    }
-    return 0;
-}
-
-static int
-SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
-                      SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    SDL_PixelFormat *fmt = dst->format;
-    unsigned inva = 0xff - a;
-
-    switch (fmt->BytesPerPixel) {
-    case 2:
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB);
-            break;
-        case SDL_BLENDMODE_ADD:
-            FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB);
-            break;
-        case SDL_BLENDMODE_MOD:
-            FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB);
-            break;
-        default:
-            FILLRECT(Uint16, DRAW_SETPIXEL_RGB);
-            break;
-        }
-        return 0;
-    case 4:
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB);
-            break;
-        case SDL_BLENDMODE_ADD:
-            FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB);
-            break;
-        case SDL_BLENDMODE_MOD:
-            FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB);
-            break;
-        default:
-            FILLRECT(Uint32, DRAW_SETPIXEL_RGB);
-            break;
-        }
-        return 0;
-    default:
-        SDL_Unsupported();
-        return -1;
-    }
-}
-
-static int
-SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
-                       SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    SDL_PixelFormat *fmt = dst->format;
-    unsigned inva = 0xff - a;
-
-    switch (fmt->BytesPerPixel) {
-    case 4:
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA);
-            break;
-        case SDL_BLENDMODE_ADD:
-            FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA);
-            break;
-        case SDL_BLENDMODE_MOD:
-            FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA);
-            break;
-        default:
-            FILLRECT(Uint32, DRAW_SETPIXEL_RGBA);
-            break;
-        }
-        return 0;
-    default:
-        SDL_Unsupported();
-        return -1;
-    }
-}
-
-int
-SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
-                  SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    SDL_Rect clipped;
-
-    if (!dst) {
-        SDL_SetError("Passed NULL destination surface");
-        return -1;
-    }
-
-    /* This function doesn't work on surfaces < 8 bpp */
-    if (dst->format->BitsPerPixel < 8) {
-        SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
-        return -1;
-    }
-
-    /* If 'rect' == NULL, then fill the whole surface */
-    if (rect) {
-        /* Perform clipping */
-        if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
-            return 0;
-        }
-        rect = &clipped;
-    } else {
-        rect = &dst->clip_rect;
-    }
-
-    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
-        r = DRAW_MUL(r, a);
-        g = DRAW_MUL(g, a);
-        b = DRAW_MUL(b, a);
-    }
-
-    switch (dst->format->BitsPerPixel) {
-    case 15:
-        switch (dst->format->Rmask) {
-        case 0x7C00:
-            return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a);
-        }
-        break;
-    case 16:
-        switch (dst->format->Rmask) {
-        case 0xF800:
-            return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a);
-        }
-        break;
-    case 32:
-        switch (dst->format->Rmask) {
-        case 0x00FF0000:
-            if (!dst->format->Amask) {
-                return SDL_BlendFillRect_RGB888(dst, rect, blendMode, r, g, b, a);
-            } else {
-                return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
-            }
-            break;
-        }
-        break;
-    default:
-        break;
-    }
-
-    if (!dst->format->Amask) {
-        return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
-    } else {
-        return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a);
-    }
-}
-
-int
-SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect ** rects, int count,
-                   SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    SDL_Rect clipped;
-    int i;
-    int (*func)(SDL_Surface * dst, const SDL_Rect * rect,
-                SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
-    int status = 0;
-
-    if (!dst) {
-        SDL_SetError("Passed NULL destination surface");
-        return -1;
-    }
-
-    /* This function doesn't work on surfaces < 8 bpp */
-    if (dst->format->BitsPerPixel < 8) {
-        SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
-        return -1;
-    }
-
-    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
-        r = DRAW_MUL(r, a);
-        g = DRAW_MUL(g, a);
-        b = DRAW_MUL(b, a);
-    }
-
-    /* FIXME: Does this function pointer slow things down significantly? */
-    switch (dst->format->BitsPerPixel) {
-    case 15:
-        switch (dst->format->Rmask) {
-        case 0x7C00:
-            func = SDL_BlendFillRect_RGB555;
-        }
-        break;
-    case 16:
-        switch (dst->format->Rmask) {
-        case 0xF800:
-            func = SDL_BlendFillRect_RGB565;
-        }
-        break;
-    case 32:
-        switch (dst->format->Rmask) {
-        case 0x00FF0000:
-            if (!dst->format->Amask) {
-                func = SDL_BlendFillRect_RGB888;
-            } else {
-                func = SDL_BlendFillRect_ARGB8888;
-            }
-            break;
-        }
-        break;
-    default:
-        break;
-    }
-
-    if (!func) {
-        if (!dst->format->Amask) {
-            func = SDL_BlendFillRect_RGB;
-        } else {
-            func = SDL_BlendFillRect_RGBA;
-        }
-    }
-
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect * rect = rects[i];
-
-        /* If 'rect' == NULL, then fill the whole surface */
-        if (rect) {
-            /* Perform clipping */
-            if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
-                continue;
-            }
-            rect = &clipped;
-        } else {
-            rect = &dst->clip_rect;
-        }
-
-        status = func(dst, rect, blendMode, r, g, b, a);
-    }
-    return status;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_blendline.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,780 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_draw.h"
-
-
-static void
-SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2,
-                   SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
-                   SDL_bool draw_end)
-{
-    const SDL_PixelFormat *fmt = dst->format;
-    unsigned r, g, b, a, inva;
-
-    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
-        r = DRAW_MUL(_r, _a);
-        g = DRAW_MUL(_g, _a);
-        b = DRAW_MUL(_b, _a);
-        a = _a;
-    } else {
-        r = _r;
-        g = _g;
-        b = _b;
-        a = _a;
-    }
-    inva = (a ^ 0xff);
-
-    if (y1 == y2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
-            break;
-        default:
-            HLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
-            break;
-        }
-    } else if (x1 == x2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
-            break;
-        default:
-            VLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
-            break;
-        }
-    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
-            break;
-        default:
-            DLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
-            break;
-        }
-    } else {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY2_BLEND_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY2_ADD_RGB, DRAW_SETPIXELXY2_ADD_RGB,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY2_MOD_RGB, DRAW_SETPIXELXY2_MOD_RGB,
-                   draw_end);
-            break;
-        default:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY2_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
-                   draw_end);
-            break;
-        }
-    }
-}
-
-static void
-SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
-                     SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
-                     SDL_bool draw_end)
-{
-    const SDL_PixelFormat *fmt = dst->format;
-    unsigned r, g, b, a, inva;
-
-    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
-        r = DRAW_MUL(_r, _a);
-        g = DRAW_MUL(_g, _a);
-        b = DRAW_MUL(_b, _a);
-        a = _a;
-    } else {
-        r = _r;
-        g = _g;
-        b = _b;
-        a = _a;
-    }
-    inva = (a ^ 0xff);
-
-    if (y1 == y2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
-            break;
-        default:
-            HLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
-            break;
-        }
-    } else if (x1 == x2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
-            break;
-        default:
-            VLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
-            break;
-        }
-    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
-            break;
-        default:
-            DLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
-            break;
-        }
-    } else {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_BLEND_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_ADD_RGB555, DRAW_SETPIXELXY_ADD_RGB555,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_MOD_RGB555, DRAW_SETPIXELXY_MOD_RGB555,
-                   draw_end);
-            break;
-        default:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
-                   draw_end);
-            break;
-        }
-    }
-}
-
-static void
-SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
-                     SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
-                     SDL_bool draw_end)
-{
-    const SDL_PixelFormat *fmt = dst->format;
-    unsigned r, g, b, a, inva;
-
-    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
-        r = DRAW_MUL(_r, _a);
-        g = DRAW_MUL(_g, _a);
-        b = DRAW_MUL(_b, _a);
-        a = _a;
-    } else {
-        r = _r;
-        g = _g;
-        b = _b;
-        a = _a;
-    }
-    inva = (a ^ 0xff);
-
-    if (y1 == y2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
-            break;
-        default:
-            HLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
-            break;
-        }
-    } else if (x1 == x2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
-            break;
-        default:
-            VLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
-            break;
-        }
-    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
-            break;
-        default:
-            DLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
-            break;
-        }
-    } else {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_BLEND_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_ADD_RGB565, DRAW_SETPIXELXY_ADD_RGB565,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_MOD_RGB565, DRAW_SETPIXELXY_MOD_RGB565,
-                   draw_end);
-            break;
-        default:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
-                   draw_end);
-            break;
-        }
-    }
-}
-
-static void
-SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
-                   SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
-                   SDL_bool draw_end)
-{
-    const SDL_PixelFormat *fmt = dst->format;
-    unsigned r, g, b, a, inva;
-
-    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
-        r = DRAW_MUL(_r, _a);
-        g = DRAW_MUL(_g, _a);
-        b = DRAW_MUL(_b, _a);
-        a = _a;
-    } else {
-        r = _r;
-        g = _g;
-        b = _b;
-        a = _a;
-    }
-    inva = (a ^ 0xff);
-
-    if (y1 == y2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
-            break;
-        default:
-            HLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
-            break;
-        }
-    } else if (x1 == x2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
-            break;
-        default:
-            VLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
-            break;
-        }
-    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
-            break;
-        default:
-            DLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
-            break;
-        }
-    } else {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY4_BLEND_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY4_ADD_RGB, DRAW_SETPIXELXY4_ADD_RGB,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY4_MOD_RGB, DRAW_SETPIXELXY4_MOD_RGB,
-                   draw_end);
-            break;
-        default:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY4_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
-                   draw_end);
-            break;
-        }
-    }
-}
-
-static void
-SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
-                    SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
-                    SDL_bool draw_end)
-{
-    const SDL_PixelFormat *fmt = dst->format;
-    unsigned r, g, b, a, inva;
-
-    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
-        r = DRAW_MUL(_r, _a);
-        g = DRAW_MUL(_g, _a);
-        b = DRAW_MUL(_b, _a);
-        a = _a;
-    } else {
-        r = _r;
-        g = _g;
-        b = _b;
-        a = _a;
-    }
-    inva = (a ^ 0xff);
-
-    if (y1 == y2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            HLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            HLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
-            break;
-        default:
-            HLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
-            break;
-        }
-    } else if (x1 == x2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            VLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            VLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
-            break;
-        default:
-            VLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
-            break;
-        }
-    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            DLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            DLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
-            break;
-        default:
-            DLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
-            break;
-        }
-    } else {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY4_BLEND_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY4_ADD_RGBA, DRAW_SETPIXELXY4_ADD_RGBA,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY4_MOD_RGBA, DRAW_SETPIXELXY4_MOD_RGBA,
-                   draw_end);
-            break;
-        default:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY4_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
-                   draw_end);
-            break;
-        }
-    }
-}
-
-static void
-SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
-                     SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
-                     SDL_bool draw_end)
-{
-    const SDL_PixelFormat *fmt = dst->format;
-    unsigned r, g, b, a, inva;
-
-    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
-        r = DRAW_MUL(_r, _a);
-        g = DRAW_MUL(_g, _a);
-        b = DRAW_MUL(_b, _a);
-        a = _a;
-    } else {
-        r = _r;
-        g = _g;
-        b = _b;
-        a = _a;
-    }
-    inva = (a ^ 0xff);
-
-    if (y1 == y2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
-            break;
-        default:
-            HLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
-            break;
-        }
-    } else if (x1 == x2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
-            break;
-        default:
-            VLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
-            break;
-        }
-    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
-            break;
-        default:
-            DLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
-            break;
-        }
-    } else {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_BLEND_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_ADD_RGB888, DRAW_SETPIXELXY_ADD_RGB888,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_MOD_RGB888, DRAW_SETPIXELXY_MOD_RGB888,
-                   draw_end);
-            break;
-        default:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
-                   draw_end);
-            break;
-        }
-    }
-}
-
-static void
-SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
-                       SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
-                       SDL_bool draw_end)
-{
-    const SDL_PixelFormat *fmt = dst->format;
-    unsigned r, g, b, a, inva;
-
-    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
-        r = DRAW_MUL(_r, _a);
-        g = DRAW_MUL(_g, _a);
-        b = DRAW_MUL(_b, _a);
-        a = _a;
-    } else {
-        r = _r;
-        g = _g;
-        b = _b;
-        a = _a;
-    }
-    inva = (a ^ 0xff);
-
-    if (y1 == y2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            HLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            HLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            HLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
-            break;
-        default:
-            HLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
-            break;
-        }
-    } else if (x1 == x2) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            VLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            VLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            VLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
-            break;
-        default:
-            VLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
-            break;
-        }
-    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            DLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            DLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            DLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
-            break;
-        default:
-            DLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
-            break;
-        }
-    } else {
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_BLEND_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_ADD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_ADD_ARGB8888, DRAW_SETPIXELXY_ADD_ARGB8888,
-                   draw_end);
-            break;
-        case SDL_BLENDMODE_MOD:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_MOD_ARGB8888, DRAW_SETPIXELXY_MOD_ARGB8888,
-                   draw_end);
-            break;
-        default:
-            AALINE(x1, y1, x2, y2,
-                   DRAW_SETPIXELXY_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
-                   draw_end);
-            break;
-        }
-    }
-}
-
-typedef void (*BlendLineFunc) (SDL_Surface * dst,
-                               int x1, int y1, int x2, int y2,
-                               SDL_BlendMode blendMode,
-                               Uint8 r, Uint8 g, Uint8 b, Uint8 a,
-                               SDL_bool draw_end);
-
-static BlendLineFunc
-SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt)
-{
-    switch (fmt->BytesPerPixel) {
-    case 2:
-        if (fmt->Rmask == 0x7C00) {
-            return SDL_BlendLine_RGB555;
-        } else if (fmt->Rmask == 0xF800) {
-            return SDL_BlendLine_RGB565;
-        } else {
-            return SDL_BlendLine_RGB2;
-        }
-        break;
-    case 4:
-        if (fmt->Rmask == 0x00FF0000) {
-            if (fmt->Amask) {
-                return SDL_BlendLine_ARGB8888;
-            } else {
-                return SDL_BlendLine_RGB888;
-            }
-        } else {
-            if (fmt->Amask) {
-                return SDL_BlendLine_RGBA4;
-            } else {
-                return SDL_BlendLine_RGB4;
-            }
-        }
-    }
-    return NULL;
-}
-
-int
-SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
-              SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    BlendLineFunc func;
-
-    if (!dst) {
-        SDL_SetError("SDL_BlendLine(): Passed NULL destination surface");
-        return -1;
-    }
-
-    func = SDL_CalculateBlendLineFunc(dst->format);
-    if (!func) {
-        SDL_SetError("SDL_BlendLine(): Unsupported surface format");
-        return -1;
-    }
-
-    /* Perform clipping */
-    /* FIXME: We don't actually want to clip, as it may change line slope */
-    if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
-        return 0;
-    }
-
-    func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_TRUE);
-    return 0;
-}
-
-int
-SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
-               SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    int i;
-    int x1, y1;
-    int x2, y2;
-    SDL_bool draw_end;
-    BlendLineFunc func;
-
-    if (!dst) {
-        SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
-        return -1;
-    }
-
-    func = SDL_CalculateBlendLineFunc(dst->format);
-    if (!func) {
-        SDL_SetError("SDL_BlendLines(): Unsupported surface format");
-        return -1;
-    }
-
-    for (i = 1; i < count; ++i) {
-        x1 = points[i-1].x;
-        y1 = points[i-1].y;
-        x2 = points[i].x;
-        y2 = points[i].y;
-
-        /* Perform clipping */
-        /* FIXME: We don't actually want to clip, as it may change line slope */
-        if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
-            continue;
-        }
-
-        /* Draw the end if it was clipped */
-        draw_end = (x2 != points[i].x || y2 != points[i].y);
-
-        func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end);
-    }
-    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
-        SDL_BlendPoint(dst, points[count-1].x, points[count-1].y,
-                       blendMode, r, g, b, a);
-    }
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_blendpoint.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,344 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_draw.h"
-
-static int
-SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
-                      Uint8 g, Uint8 b, Uint8 a)
-{
-    unsigned inva = 0xff - a;
-
-    switch (blendMode) {
-    case SDL_BLENDMODE_BLEND:
-        DRAW_SETPIXELXY_BLEND_RGB555(x, y);
-        break;
-    case SDL_BLENDMODE_ADD:
-        DRAW_SETPIXELXY_ADD_RGB555(x, y);
-        break;
-    case SDL_BLENDMODE_MOD:
-        DRAW_SETPIXELXY_MOD_RGB555(x, y);
-        break;
-    default:
-        DRAW_SETPIXELXY_RGB555(x, y);
-        break;
-    }
-    return 0;
-}
-
-static int
-SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
-                      Uint8 g, Uint8 b, Uint8 a)
-{
-    unsigned inva = 0xff - a;
-
-    switch (blendMode) {
-    case SDL_BLENDMODE_BLEND:
-        DRAW_SETPIXELXY_BLEND_RGB565(x, y);
-        break;
-    case SDL_BLENDMODE_ADD:
-        DRAW_SETPIXELXY_ADD_RGB565(x, y);
-        break;
-    case SDL_BLENDMODE_MOD:
-        DRAW_SETPIXELXY_MOD_RGB565(x, y);
-        break;
-    default:
-        DRAW_SETPIXELXY_RGB565(x, y);
-        break;
-    }
-    return 0;
-}
-
-static int
-SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
-                      Uint8 g, Uint8 b, Uint8 a)
-{
-    unsigned inva = 0xff - a;
-
-    switch (blendMode) {
-    case SDL_BLENDMODE_BLEND:
-        DRAW_SETPIXELXY_BLEND_RGB888(x, y);
-        break;
-    case SDL_BLENDMODE_ADD:
-        DRAW_SETPIXELXY_ADD_RGB888(x, y);
-        break;
-    case SDL_BLENDMODE_MOD:
-        DRAW_SETPIXELXY_MOD_RGB888(x, y);
-        break;
-    default:
-        DRAW_SETPIXELXY_RGB888(x, y);
-        break;
-    }
-    return 0;
-}
-
-static int
-SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
-                        Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    unsigned inva = 0xff - a;
-
-    switch (blendMode) {
-    case SDL_BLENDMODE_BLEND:
-        DRAW_SETPIXELXY_BLEND_ARGB8888(x, y);
-        break;
-    case SDL_BLENDMODE_ADD:
-        DRAW_SETPIXELXY_ADD_ARGB8888(x, y);
-        break;
-    case SDL_BLENDMODE_MOD:
-        DRAW_SETPIXELXY_MOD_ARGB8888(x, y);
-        break;
-    default:
-        DRAW_SETPIXELXY_ARGB8888(x, y);
-        break;
-    }
-    return 0;
-}
-
-static int
-SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
-                   Uint8 g, Uint8 b, Uint8 a)
-{
-    SDL_PixelFormat *fmt = dst->format;
-    unsigned inva = 0xff - a;
-
-    switch (fmt->BytesPerPixel) {
-    case 2:
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            DRAW_SETPIXELXY2_BLEND_RGB(x, y);
-            break;
-        case SDL_BLENDMODE_ADD:
-            DRAW_SETPIXELXY2_ADD_RGB(x, y);
-            break;
-        case SDL_BLENDMODE_MOD:
-            DRAW_SETPIXELXY2_MOD_RGB(x, y);
-            break;
-        default:
-            DRAW_SETPIXELXY2_RGB(x, y);
-            break;
-        }
-        return 0;
-    case 4:
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            DRAW_SETPIXELXY4_BLEND_RGB(x, y);
-            break;
-        case SDL_BLENDMODE_ADD:
-            DRAW_SETPIXELXY4_ADD_RGB(x, y);
-            break;
-        case SDL_BLENDMODE_MOD:
-            DRAW_SETPIXELXY4_MOD_RGB(x, y);
-            break;
-        default:
-            DRAW_SETPIXELXY4_RGB(x, y);
-            break;
-        }
-        return 0;
-    default:
-        SDL_Unsupported();
-        return -1;
-    }
-}
-
-static int
-SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
-                    Uint8 g, Uint8 b, Uint8 a)
-{
-    SDL_PixelFormat *fmt = dst->format;
-    unsigned inva = 0xff - a;
-
-    switch (fmt->BytesPerPixel) {
-    case 4:
-        switch (blendMode) {
-        case SDL_BLENDMODE_BLEND:
-            DRAW_SETPIXELXY4_BLEND_RGBA(x, y);
-            break;
-        case SDL_BLENDMODE_ADD:
-            DRAW_SETPIXELXY4_ADD_RGBA(x, y);
-            break;
-        case SDL_BLENDMODE_MOD:
-            DRAW_SETPIXELXY4_MOD_RGBA(x, y);
-            break;
-        default:
-            DRAW_SETPIXELXY4_RGBA(x, y);
-            break;
-        }
-        return 0;
-    default:
-        SDL_Unsupported();
-        return -1;
-    }
-}
-
-int
-SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
-               Uint8 g, Uint8 b, Uint8 a)
-{
-    if (!dst) {
-        SDL_SetError("Passed NULL destination surface");
-        return -1;
-    }
-
-    /* This function doesn't work on surfaces < 8 bpp */
-    if (dst->format->BitsPerPixel < 8) {
-        SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
-        return -1;
-    }
-
-    /* Perform clipping */
-    if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
-        x >= (dst->clip_rect.x + dst->clip_rect.w) ||
-        y >= (dst->clip_rect.y + dst->clip_rect.h)) {
-        return 0;
-    }
-
-    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
-        r = DRAW_MUL(r, a);
-        g = DRAW_MUL(g, a);
-        b = DRAW_MUL(b, a);
-    }
-
-    switch (dst->format->BitsPerPixel) {
-    case 15:
-        switch (dst->format->Rmask) {
-        case 0x7C00:
-            return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
-        }
-        break;
-    case 16:
-        switch (dst->format->Rmask) {
-        case 0xF800:
-            return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
-        }
-        break;
-    case 32:
-        switch (dst->format->Rmask) {
-        case 0x00FF0000:
-            if (!dst->format->Amask) {
-                return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b,
-                                             a);
-            } else {
-                return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b,
-                                               a);
-            }
-            break;
-        }
-        break;
-    default:
-        break;
-    }
-
-    if (!dst->format->Amask) {
-        return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
-    } else {
-        return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
-    }
-}
-
-int
-SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
-                SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    int minx, miny;
-    int maxx, maxy;
-    int i;
-    int x, y;
-    int (*func)(SDL_Surface * dst, int x, int y,
-                SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
-    int status = 0;
-
-    if (!dst) {
-        SDL_SetError("Passed NULL destination surface");
-        return -1;
-    }
-
-    /* This function doesn't work on surfaces < 8 bpp */
-    if (dst->format->BitsPerPixel < 8) {
-        SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
-        return (-1);
-    }
-
-    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
-        r = DRAW_MUL(r, a);
-        g = DRAW_MUL(g, a);
-        b = DRAW_MUL(b, a);
-    }
-
-    /* FIXME: Does this function pointer slow things down significantly? */
-    switch (dst->format->BitsPerPixel) {
-    case 15:
-        switch (dst->format->Rmask) {
-        case 0x7C00:
-            func = SDL_BlendPoint_RGB555;
-            break;
-        }
-        break;
-    case 16:
-        switch (dst->format->Rmask) {
-        case 0xF800:
-            func = SDL_BlendPoint_RGB565;
-            break;
-        }
-        break;
-    case 32:
-        switch (dst->format->Rmask) {
-        case 0x00FF0000:
-            if (!dst->format->Amask) {
-                func = SDL_BlendPoint_RGB888;
-            } else {
-                func = SDL_BlendPoint_ARGB8888;
-            }
-            break;
-        }
-        break;
-    default:
-        break;
-    }
-
-    if (!func) {
-        if (!dst->format->Amask) {
-            func = SDL_BlendPoint_RGB;
-        } else {
-            func = SDL_BlendPoint_RGBA;
-        }
-    }
-
-    minx = dst->clip_rect.x;
-    maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
-    miny = dst->clip_rect.y;
-    maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
-
-    for (i = 0; i < count; ++i) {
-        x = points[i].x;
-        y = points[i].y;
-
-        if (x < minx || x > maxx || y < miny || y > maxy) {
-            continue;
-        }
-        status = func(dst, x, y, blendMode, r, g, b, a);
-    }
-    return status;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_blendrect.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_video.h"
-
-
-int
-SDL_BlendRect(SDL_Surface * dst, const SDL_Rect * rect,
-              SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    SDL_Rect full_rect;
-    SDL_Point points[5];
-
-    if (!dst) {
-        SDL_SetError("Passed NULL destination surface");
-        return -1;
-    }
-
-    /* If 'rect' == NULL, then outline the whole surface */
-    if (!rect) {
-        full_rect.x = 0;
-        full_rect.y = 0;
-        full_rect.w = dst->w;
-        full_rect.h = dst->h;
-        rect = &full_rect;
-    }
-
-    points[0].x = rect->x;
-    points[0].y = rect->y;
-    points[1].x = rect->x+rect->w-1;
-    points[1].y = rect->y;
-    points[2].x = rect->x+rect->w-1;
-    points[2].y = rect->y+rect->h-1;
-    points[3].x = rect->x;
-    points[3].y = rect->y+rect->h-1;
-    points[4].x = rect->x;
-    points[4].y = rect->y;
-    return SDL_BlendLines(dst, points, 5, blendMode, r, g, b, a);
-}
-
-int
-SDL_BlendRects(SDL_Surface * dst, const SDL_Rect ** rects, int count,
-               SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    int i;
-
-    for (i = 0; i < count; ++i) {
-        if (SDL_BlendRect(dst, rects[i], blendMode, r, g, b, a) < 0) {
-            return -1;
-        }
-    }
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_blit.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_blit.c	Sun Feb 06 21:23:32 2011 -0800
@@ -183,7 +183,7 @@
         /* Check blend flags */
         flagcheck =
             (flags &
-             (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD));
+             (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD));
         if ((flagcheck & entries[i].flags) != flagcheck) {
             continue;
         }
--- a/src/video/SDL_blit.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_blit.h	Sun Feb 06 21:23:32 2011 -0800
@@ -47,15 +47,14 @@
 
 #include "SDL_cpuinfo.h"
 #include "SDL_endian.h"
-#include "SDL_video.h"
+#include "SDL_surface.h"
 
 /* SDL blit copy flags */
 #define SDL_COPY_MODULATE_COLOR     0x00000001
 #define SDL_COPY_MODULATE_ALPHA     0x00000002
-#define SDL_COPY_MASK               0x00000010
-#define SDL_COPY_BLEND              0x00000020
-#define SDL_COPY_ADD                0x00000040
-#define SDL_COPY_MOD                0x00000080
+#define SDL_COPY_BLEND              0x00000010
+#define SDL_COPY_ADD                0x00000020
+#define SDL_COPY_MOD                0x00000040
 #define SDL_COPY_COLORKEY           0x00000100
 #define SDL_COPY_NEAREST            0x00000200
 #define SDL_COPY_RLE_DESIRED        0x00001000
--- a/src/video/SDL_blit_auto.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_blit_auto.c	Sun Feb 06 21:23:32 2011 -0800
@@ -1,7 +1,7 @@
 /* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
 /*
     SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
+    Copyright (C) 1997-2011 Sam Lantinga
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public
@@ -92,14 +92,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -172,14 +165,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -334,14 +320,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -426,14 +405,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -529,14 +501,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -609,14 +574,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -771,14 +729,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -863,14 +814,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -966,14 +910,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -1046,14 +983,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -1208,14 +1138,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -1300,14 +1223,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -1403,14 +1319,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -1483,14 +1392,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -1645,14 +1547,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -1737,14 +1632,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -1835,14 +1723,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -1915,14 +1796,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -2077,14 +1951,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -2169,14 +2036,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -2272,14 +2132,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -2352,14 +2205,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -2514,14 +2360,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -2606,14 +2445,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -2709,14 +2541,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -2789,14 +2614,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -2951,14 +2769,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -3043,14 +2854,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -3146,14 +2950,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -3226,14 +3023,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -3388,14 +3178,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -3480,14 +3263,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -3578,14 +3354,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -3658,14 +3427,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -3820,14 +3582,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -3912,14 +3667,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -4015,14 +3763,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -4095,14 +3836,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -4257,14 +3991,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -4349,14 +4076,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -4452,14 +4172,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -4532,14 +4245,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -4694,14 +4400,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -4786,14 +4485,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -4889,14 +4581,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -4969,14 +4654,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -5131,14 +4809,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -5223,14 +4894,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -5326,14 +4990,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -5406,14 +5063,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -5568,14 +5218,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -5660,14 +5303,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -5763,14 +5399,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -5843,14 +5472,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -6005,14 +5627,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -6097,14 +5712,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -6200,14 +5808,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -6280,14 +5881,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -6442,14 +6036,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -6534,14 +6121,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -6637,14 +6217,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -6717,14 +6290,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -6879,14 +6445,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -6971,14 +6530,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -7074,14 +6626,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -7154,14 +6699,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -7316,14 +6854,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -7408,14 +6939,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -7511,14 +7035,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -7591,14 +7108,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -7753,14 +7263,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -7845,14 +7348,7 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
@@ -7881,131 +7377,131 @@
 
 SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale },
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate },
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend_Scale },
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate },
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend_Scale },
     { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate },
     { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend_Scale },
     { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate },
     { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale },
     { 0, 0, 0, 0, NULL }
 };
 
--- a/src/video/SDL_blit_auto.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_blit_auto.h	Sun Feb 06 21:23:32 2011 -0800
@@ -1,7 +1,7 @@
 /* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
 /*
     SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
+    Copyright (C) 1997-2011 Sam Lantinga
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public
--- a/src/video/SDL_blit_slow.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_blit_slow.c	Sun Feb 06 21:23:32 2011 -0800
@@ -117,22 +117,13 @@
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags &
-                    (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD |
-                     SDL_COPY_MOD)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD)) {
             case 0:
                 dstR = srcR;
                 dstG = srcG;
                 dstB = srcB;
                 dstA = srcA;
                 break;
-            case SDL_COPY_MASK:
-                if (srcA) {
-                    dstR = srcR;
-                    dstG = srcG;
-                    dstB = srcB;
-                }
-                break;
             case SDL_COPY_BLEND:
                 dstR = srcR + ((255 - srcA) * dstR) / 255;
                 dstG = srcG + ((255 - srcA) * dstG) / 255;
--- a/src/video/SDL_draw.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,576 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_blit.h"
-
-/* This code assumes that r, g, b, a are the source color,
- * and in the blend and add case, the RGB values are premultiplied by a.
- */
-
-#define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255)
-
-#define DRAW_FASTSETPIXEL(type) \
-    *pixel = (type) color
-
-#define DRAW_FASTSETPIXEL1 DRAW_FASTSETPIXEL(Uint8)
-#define DRAW_FASTSETPIXEL2 DRAW_FASTSETPIXEL(Uint16)
-#define DRAW_FASTSETPIXEL4 DRAW_FASTSETPIXEL(Uint32)
-
-#define DRAW_FASTSETPIXELXY(x, y, type, bpp, color) \
-    *(type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
-                                   + (x) * bpp) = (type) color
-
-#define DRAW_FASTSETPIXELXY1(x, y) DRAW_FASTSETPIXELXY(x, y, Uint8, 1, color)
-#define DRAW_FASTSETPIXELXY2(x, y) DRAW_FASTSETPIXELXY(x, y, Uint16, 2, color)
-#define DRAW_FASTSETPIXELXY4(x, y) DRAW_FASTSETPIXELXY(x, y, Uint32, 4, color)
-
-#define DRAW_SETPIXEL(setpixel) \
-do { \
-    unsigned sr = r, sg = g, sb = b, sa = a; \
-    setpixel; \
-} while (0)
-
-#define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \
-do { \
-    unsigned sr, sg, sb, sa; sa; \
-    getpixel; \
-    sr = DRAW_MUL(inva, sr) + r; \
-    sg = DRAW_MUL(inva, sg) + g; \
-    sb = DRAW_MUL(inva, sb) + b; \
-    setpixel; \
-} while (0)
-
-#define DRAW_SETPIXEL_ADD(getpixel, setpixel) \
-do { \
-    unsigned sr, sg, sb, sa; sa; \
-    getpixel; \
-    sr += r; if (sr > 0xff) sr = 0xff; \
-    sg += g; if (sg > 0xff) sg = 0xff; \
-    sb += b; if (sb > 0xff) sb = 0xff; \
-    setpixel; \
-} while (0)
-
-#define DRAW_SETPIXEL_MOD(getpixel, setpixel) \
-do { \
-    unsigned sr, sg, sb, sa; sa; \
-    getpixel; \
-    sr = DRAW_MUL(sr, r); \
-    sg = DRAW_MUL(sg, g); \
-    sb = DRAW_MUL(sb, b); \
-    setpixel; \
-} while (0)
-
-#define DRAW_SETPIXELXY(x, y, type, bpp, op) \
-do { \
-    type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
-                                                + (x) * bpp); \
-    op; \
-} while (0)
-
-/*
- * Define draw operators for RGB555
- */
-
-#define DRAW_SETPIXEL_RGB555 \
-    DRAW_SETPIXEL(RGB555_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXEL_BLEND_RGB555 \
-    DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
-                        RGB555_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXEL_ADD_RGB555 \
-    DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
-                      RGB555_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXEL_MOD_RGB555 \
-    DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
-                      RGB555_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXELXY_RGB555(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555)
-
-#define DRAW_SETPIXELXY_BLEND_RGB555(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB555)
-
-#define DRAW_SETPIXELXY_ADD_RGB555(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555)
-
-#define DRAW_SETPIXELXY_MOD_RGB555(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB555)
-
-/*
- * Define draw operators for RGB565
- */
-
-#define DRAW_SETPIXEL_RGB565 \
-    DRAW_SETPIXEL(RGB565_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXEL_BLEND_RGB565 \
-    DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
-                        RGB565_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXEL_ADD_RGB565 \
-    DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
-                      RGB565_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXEL_MOD_RGB565 \
-    DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
-                      RGB565_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXELXY_RGB565(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565)
-
-#define DRAW_SETPIXELXY_BLEND_RGB565(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB565)
-
-#define DRAW_SETPIXELXY_ADD_RGB565(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565)
-
-#define DRAW_SETPIXELXY_MOD_RGB565(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB565)
-
-/*
- * Define draw operators for RGB888
- */
-
-#define DRAW_SETPIXEL_RGB888 \
-    DRAW_SETPIXEL(RGB888_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXEL_BLEND_RGB888 \
-    DRAW_SETPIXEL_BLEND(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
-                        RGB888_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXEL_ADD_RGB888 \
-    DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
-                      RGB888_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXEL_MOD_RGB888 \
-    DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
-                      RGB888_FROM_RGB(*pixel, sr, sg, sb))
-
-#define DRAW_SETPIXELXY_RGB888(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888)
-
-#define DRAW_SETPIXELXY_BLEND_RGB888(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB888)
-
-#define DRAW_SETPIXELXY_ADD_RGB888(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888)
-
-#define DRAW_SETPIXELXY_MOD_RGB888(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888)
-
-/*
- * Define draw operators for ARGB8888
- */
-
-#define DRAW_SETPIXEL_ARGB8888 \
-    DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
-
-#define DRAW_SETPIXEL_BLEND_ARGB8888 \
-    DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
-                        ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
-
-#define DRAW_SETPIXEL_ADD_ARGB8888 \
-    DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
-                      ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
-
-#define DRAW_SETPIXEL_MOD_ARGB8888 \
-    DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
-                      ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
-
-#define DRAW_SETPIXELXY_ARGB8888(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888)
-
-#define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888)
-
-#define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888)
-
-#define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888)
-
-/*
- * Define draw operators for general RGB
- */
-
-#define DRAW_SETPIXEL_RGB \
-    DRAW_SETPIXEL(PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
-
-#define DRAW_SETPIXEL_BLEND_RGB \
-    DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
-                        PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
-
-#define DRAW_SETPIXEL_ADD_RGB \
-    DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
-                      PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
-
-#define DRAW_SETPIXEL_MOD_RGB \
-    DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
-                      PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
-
-#define DRAW_SETPIXELXY2_RGB(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB)
-
-#define DRAW_SETPIXELXY4_RGB(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB)
-
-#define DRAW_SETPIXELXY2_BLEND_RGB(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB)
-
-#define DRAW_SETPIXELXY4_BLEND_RGB(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB)
-
-#define DRAW_SETPIXELXY2_ADD_RGB(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB)
-
-#define DRAW_SETPIXELXY4_ADD_RGB(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB)
-
-#define DRAW_SETPIXELXY2_MOD_RGB(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB)
-
-#define DRAW_SETPIXELXY4_MOD_RGB(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB)
-
-
-/*
- * Define draw operators for general RGBA
- */
-
-#define DRAW_SETPIXEL_RGBA \
-    DRAW_SETPIXEL(PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
-
-#define DRAW_SETPIXEL_BLEND_RGBA \
-    DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
-                        PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
-
-#define DRAW_SETPIXEL_ADD_RGBA \
-    DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
-                      PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
-
-#define DRAW_SETPIXEL_MOD_RGBA \
-    DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
-                      PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
-
-#define DRAW_SETPIXELXY4_RGBA(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA)
-
-#define DRAW_SETPIXELXY4_BLEND_RGBA(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGBA)
-
-#define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA)
-
-#define DRAW_SETPIXELXY4_MOD_RGBA(x, y) \
-    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGBA)
-
-/*
- * Define line drawing macro
- */
-
-#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
-
-/* Horizontal line */
-#define HLINE(type, op, draw_end) \
-{ \
-    int length; \
-    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
-    type *pixel; \
-    if (x1 <= x2) { \
-        pixel = (type *)dst->pixels + y1 * pitch + x1; \
-        length = draw_end ? (x2-x1+1) : (x2-x1); \
-    } else { \
-        pixel = (type *)dst->pixels + y1 * pitch + x2; \
-        if (!draw_end) { \
-            ++pixel; \
-        } \
-        length = draw_end ? (x1-x2+1) : (x1-x2); \
-    } \
-    while (length--) { \
-        op; \
-        ++pixel; \
-    } \
-}
-
-/* Vertical line */
-#define VLINE(type, op, draw_end) \
-{ \
-    int length; \
-    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
-    type *pixel; \
-    if (y1 <= y2) { \
-        pixel = (type *)dst->pixels + y1 * pitch + x1; \
-        length = draw_end ? (y2-y1+1) : (y2-y1); \
-    } else { \
-        pixel = (type *)dst->pixels + y2 * pitch + x1; \
-        if (!draw_end) { \
-            pixel += pitch; \
-        } \
-        length = draw_end ? (y1-y2+1) : (y1-y2); \
-    } \
-    while (length--) { \
-        op; \
-        pixel += pitch; \
-    } \
-}
-
-/* Diagonal line */
-#define DLINE(type, op, draw_end) \
-{ \
-    int length; \
-    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
-    type *pixel; \
-    if (y1 <= y2) { \
-        pixel = (type *)dst->pixels + y1 * pitch + x1; \
-        if (x1 <= x2) { \
-            ++pitch; \
-        } else { \
-            --pitch; \
-        } \
-        length = (y2-y1); \
-    } else { \
-        pixel = (type *)dst->pixels + y2 * pitch + x2; \
-        if (x2 <= x1) { \
-            ++pitch; \
-        } else { \
-            --pitch; \
-        } \
-        if (!draw_end) { \
-            pixel += pitch; \
-        } \
-        length = (y1-y2); \
-    } \
-    if (draw_end) { \
-        ++length; \
-    } \
-    while (length--) { \
-        op; \
-        pixel += pitch; \
-    } \
-}
-
-/* Bresenham's line algorithm */
-#define BLINE(x1, y1, x2, y2, op, draw_end) \
-{ \
-    int i, deltax, deltay, numpixels; \
-    int d, dinc1, dinc2; \
-    int x, xinc1, xinc2; \
-    int y, yinc1, yinc2; \
- \
-    deltax = ABS(x2 - x1); \
-    deltay = ABS(y2 - y1); \
- \
-    if (deltax >= deltay) { \
-        numpixels = deltax + 1; \
-        d = (2 * deltay) - deltax; \
-        dinc1 = deltay * 2; \
-        dinc2 = (deltay - deltax) * 2; \
-        xinc1 = 1; \
-        xinc2 = 1; \
-        yinc1 = 0; \
-        yinc2 = 1; \
-    } else { \
-        numpixels = deltay + 1; \
-        d = (2 * deltax) - deltay; \
-        dinc1 = deltax * 2; \
-        dinc2 = (deltax - deltay) * 2; \
-        xinc1 = 0; \
-        xinc2 = 1; \
-        yinc1 = 1; \
-        yinc2 = 1; \
-    } \
- \
-    if (x1 > x2) { \
-        xinc1 = -xinc1; \
-        xinc2 = -xinc2; \
-    } \
-    if (y1 > y2) { \
-        yinc1 = -yinc1; \
-        yinc2 = -yinc2; \
-    } \
- \
-    x = x1; \
-    y = y1; \
- \
-    if (!draw_end) { \
-        --numpixels; \
-    } \
-    for (i = 0; i < numpixels; ++i) { \
-        op(x, y); \
-        if (d < 0) { \
-            d += dinc1; \
-            x += xinc1; \
-            y += yinc1; \
-        } else { \
-            d += dinc2; \
-            x += xinc2; \
-            y += yinc2; \
-        } \
-    } \
-}
-
-/* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */
-#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
-{ \
-    Uint16 ErrorAdj, ErrorAcc; \
-    Uint16 ErrorAccTemp, Weighting; \
-    int DeltaX, DeltaY, Temp, XDir; \
-    unsigned r, g, b, a, inva; \
- \
-    /* Draw the initial pixel, which is always exactly intersected by \
-       the line and so needs no weighting */ \
-    opaque_op(x1, y1); \
- \
-    /* Draw the final pixel, which is always exactly intersected by the line \
-       and so needs no weighting */ \
-    if (draw_end) { \
-        opaque_op(x2, y2); \
-    } \
- \
-    /* Make sure the line runs top to bottom */ \
-    if (y1 > y2) { \
-        Temp = y1; y1 = y2; y2 = Temp; \
-        Temp = x1; x1 = x2; x2 = Temp; \
-    } \
-    DeltaY = y2 - y1; \
- \
-    if ((DeltaX = x2 - x1) >= 0) { \
-        XDir = 1; \
-    } else { \
-        XDir = -1; \
-        DeltaX = -DeltaX; /* make DeltaX positive */ \
-    } \
- \
-    /* line is not horizontal, diagonal, or vertical */ \
-    ErrorAcc = 0;  /* initialize the line error accumulator to 0 */ \
- \
-    /* Is this an X-major or Y-major line? */ \
-    if (DeltaY > DeltaX) { \
-        /* Y-major line; calculate 16-bit fixed-point fractional part of a \
-          pixel that X advances each time Y advances 1 pixel, truncating the \
-          result so that we won't overrun the endpoint along the X axis */ \
-        ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; \
-        /* Draw all pixels other than the first and last */ \
-        while (--DeltaY) { \
-            ErrorAccTemp = ErrorAcc;   /* remember currrent accumulated error */ \
-            ErrorAcc += ErrorAdj;      /* calculate error for next pixel */ \
-            if (ErrorAcc <= ErrorAccTemp) { \
-                /* The error accumulator turned over, so advance the X coord */ \
-                x1 += XDir; \
-            } \
-            y1++; /* Y-major, so always advance Y */ \
-            /* The IntensityBits most significant bits of ErrorAcc give us the \
-             intensity weighting for this pixel, and the complement of the \
-             weighting for the paired pixel */ \
-            Weighting = ErrorAcc >> 8; \
-            { \
-                a = DRAW_MUL(_a, (Weighting ^ 255)); \
-                r = DRAW_MUL(_r, a); \
-                g = DRAW_MUL(_g, a); \
-                b = DRAW_MUL(_b, a); \
-                inva = (a ^ 0xFF); \
-                blend_op(x1, y1); \
-            } \
-            { \
-                a = DRAW_MUL(_a, Weighting); \
-                r = DRAW_MUL(_r, a); \
-                g = DRAW_MUL(_g, a); \
-                b = DRAW_MUL(_b, a); \
-                inva = (a ^ 0xFF); \
-                blend_op(x1 + XDir, y1); \
-            } \
-        } \
-    } else { \
-        /* X-major line; calculate 16-bit fixed-point fractional part of a \
-           pixel that Y advances each time X advances 1 pixel, truncating the \
-           result to avoid overrunning the endpoint along the X axis */ \
-        ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; \
-        /* Draw all pixels other than the first and last */ \
-        while (--DeltaX) { \
-            ErrorAccTemp = ErrorAcc;   /* remember currrent accumulated error */ \
-            ErrorAcc += ErrorAdj;      /* calculate error for next pixel */ \
-            if (ErrorAcc <= ErrorAccTemp) { \
-                /* The error accumulator turned over, so advance the Y coord */ \
-                y1++; \
-            } \
-            x1 += XDir; /* X-major, so always advance X */ \
-            /* The IntensityBits most significant bits of ErrorAcc give us the \
-              intensity weighting for this pixel, and the complement of the \
-              weighting for the paired pixel */ \
-            Weighting = ErrorAcc >> 8; \
-            { \
-                a = DRAW_MUL(_a, (Weighting ^ 255)); \
-                r = DRAW_MUL(_r, a); \
-                g = DRAW_MUL(_g, a); \
-                b = DRAW_MUL(_b, a); \
-                inva = (a ^ 0xFF); \
-                blend_op(x1, y1); \
-            } \
-            { \
-                a = DRAW_MUL(_a, Weighting); \
-                r = DRAW_MUL(_r, a); \
-                g = DRAW_MUL(_g, a); \
-                b = DRAW_MUL(_b, a); \
-                inva = (a ^ 0xFF); \
-                blend_op(x1, y1 + 1); \
-            } \
-        } \
-    } \
-}
-
-#ifdef AA_LINES
-#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
-            WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
-#else
-#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
-            BLINE(x1, y1, x2, y2, opaque_op, draw_end)
-#endif
-
-/*
- * Define fill rect macro
- */
-
-#define FILLRECT(type, op) \
-do { \
-    int width = rect->w; \
-    int height = rect->h; \
-    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
-    int skip = pitch - width; \
-    type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
-    while (height--) { \
-        { int n = (width+3)/4; \
-            switch (width & 3) { \
-            case 0: do {   op; pixel++; \
-            case 3:        op; pixel++; \
-            case 2:        op; pixel++; \
-            case 1:        op; pixel++; \
-                    } while ( --n > 0 ); \
-            } \
-        } \
-        pixel += skip; \
-    } \
-} while (0)
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_drawline.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,208 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_draw.h"
-
-static void
-SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
-              SDL_bool draw_end)
-{
-    if (y1 == y2) {
-        //HLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
-        int length;
-        int pitch = (dst->pitch / dst->format->BytesPerPixel);
-        Uint8 *pixel;
-        if (x1 <= x2) {
-            pixel = (Uint8 *)dst->pixels + y1 * pitch + x1;
-            length = draw_end ? (x2-x1+1) : (x2-x1);
-        } else {
-            pixel = (Uint8 *)dst->pixels + y1 * pitch + x2;
-            if (!draw_end) {
-                ++pixel;
-            }
-            length = draw_end ? (x1-x2+1) : (x1-x2);
-        }
-        SDL_memset(pixel, color, length);
-    } else if (x1 == x2) {
-        VLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
-    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
-        DLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
-    } else {
-        BLINE(x1, y1, x2, y2, DRAW_FASTSETPIXELXY1, draw_end);
-    }
-}
-
-static void
-SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
-              SDL_bool draw_end)
-{
-    if (y1 == y2) {
-        HLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
-    } else if (x1 == x2) {
-        VLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
-    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
-        DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
-    } else {
-        Uint8 _r, _g, _b, _a;
-        const SDL_PixelFormat * fmt = dst->format;
-        SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
-        if (fmt->Rmask == 0x7C00) {
-            AALINE(x1, y1, x2, y2,
-                   DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB555,
-                   draw_end);
-        } else if (fmt->Rmask == 0xF800) {
-            AALINE(x1, y1, x2, y2,
-                   DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB565,
-                   draw_end);
-        } else {
-            AALINE(x1, y1, x2, y2,
-                   DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY2_BLEND_RGB,
-                   draw_end);
-        }
-    }
-}
-
-static void
-SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
-              SDL_bool draw_end)
-{
-    if (y1 == y2) {
-        HLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
-    } else if (x1 == x2) {
-        VLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
-    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
-        DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
-    } else {
-        Uint8 _r, _g, _b, _a;
-        const SDL_PixelFormat * fmt = dst->format;
-        SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
-        if (fmt->Rmask == 0x00FF0000) {
-            if (!fmt->Amask) {
-                AALINE(x1, y1, x2, y2,
-                       DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_RGB888,
-                       draw_end);
-            } else {
-                AALINE(x1, y1, x2, y2,
-                       DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_ARGB8888,
-                       draw_end);
-            }
-        } else {
-            AALINE(x1, y1, x2, y2,
-                   DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY4_BLEND_RGB,
-                   draw_end);
-        }
-    }
-}
-
-typedef void (*DrawLineFunc) (SDL_Surface * dst,
-                              int x1, int y1, int x2, int y2,
-                              Uint32 color, SDL_bool draw_end);
-
-static DrawLineFunc
-SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt)
-{
-    switch (fmt->BytesPerPixel) {
-    case 1:
-        if (fmt->BitsPerPixel < 8) {
-            break;
-        }
-        return SDL_DrawLine1;
-    case 2:
-        return SDL_DrawLine2;
-    case 4:
-        return SDL_DrawLine4;
-    }
-    return NULL;
-}
-
-int
-SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
-{
-    DrawLineFunc func;
-
-    if (!dst) {
-        SDL_SetError("SDL_DrawLine(): Passed NULL destination surface");
-        return -1;
-    }
-
-    func = SDL_CalculateDrawLineFunc(dst->format);
-    if (!func) {
-        SDL_SetError("SDL_DrawLine(): Unsupported surface format");
-        return -1;
-    }
-
-    /* Perform clipping */
-    /* FIXME: We don't actually want to clip, as it may change line slope */
-    if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
-        return 0;
-    }
-
-    func(dst, x1, y1, x2, y2, color, SDL_TRUE);
-    return 0;
-}
-
-int
-SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
-              Uint32 color)
-{
-    int i;
-    int x1, y1;
-    int x2, y2;
-    SDL_bool draw_end;
-    DrawLineFunc func;
-
-    if (!dst) {
-        SDL_SetError("SDL_DrawLines(): Passed NULL destination surface");
-        return -1;
-    }
-
-    func = SDL_CalculateDrawLineFunc(dst->format);
-    if (!func) {
-        SDL_SetError("SDL_DrawLines(): Unsupported surface format");
-        return -1;
-    }
-
-    for (i = 1; i < count; ++i) {
-        x1 = points[i-1].x;
-        y1 = points[i-1].y;
-        x2 = points[i].x;
-        y2 = points[i].y;
-
-        /* Perform clipping */
-        /* FIXME: We don't actually want to clip, as it may change line slope */
-        if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
-            continue;
-        }
-
-        /* Draw the end if it was clipped */
-        draw_end = (x2 != points[i].x || y2 != points[i].y);
-
-        func(dst, x1, y1, x2, y2, color, draw_end);
-    }
-    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
-        SDL_DrawPoint(dst, points[count-1].x, points[count-1].y, color);
-    }
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_drawpoint.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_draw.h"
-
-
-int
-SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
-{
-    if (!dst) {
-        SDL_SetError("Passed NULL destination surface");
-        return -1;
-    }
-
-    /* This function doesn't work on surfaces < 8 bpp */
-    if (dst->format->BitsPerPixel < 8) {
-        SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
-        return -1;
-    }
-
-    /* Perform clipping */
-    if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
-        x >= (dst->clip_rect.x + dst->clip_rect.w) ||
-        y >= (dst->clip_rect.y + dst->clip_rect.h)) {
-        return 0;
-    }
-
-    switch (dst->format->BytesPerPixel) {
-    case 1:
-        DRAW_FASTSETPIXELXY1(x, y);
-        break;
-    case 2:
-        DRAW_FASTSETPIXELXY2(x, y);
-        break;
-    case 3:
-        SDL_Unsupported();
-        return -1;
-    case 4:
-        DRAW_FASTSETPIXELXY4(x, y);
-        break;
-    }
-    return 0;
-}
-
-int
-SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
-               Uint32 color)
-{
-    int minx, miny;
-    int maxx, maxy;
-    int i;
-    int x, y;
-
-    if (!dst) {
-        SDL_SetError("Passed NULL destination surface");
-        return -1;
-    }
-
-    /* This function doesn't work on surfaces < 8 bpp */
-    if (dst->format->BitsPerPixel < 8) {
-        SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
-        return -1;
-    }
-
-    minx = dst->clip_rect.x;
-    maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
-    miny = dst->clip_rect.y;
-    maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
-
-    for (i = 0; i < count; ++i) {
-        x = points[i].x;
-        y = points[i].y;
-
-        if (x < minx || x > maxx || y < miny || y > maxy) {
-            continue;
-        }
-
-        switch (dst->format->BytesPerPixel) {
-        case 1:
-            DRAW_FASTSETPIXELXY1(x, y);
-            break;
-        case 2:
-            DRAW_FASTSETPIXELXY2(x, y);
-            break;
-        case 3:
-            SDL_Unsupported();
-            return -1;
-        case 4:
-            DRAW_FASTSETPIXELXY4(x, y);
-            break;
-        }
-    }
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_drawrect.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_video.h"
-
-
-int
-SDL_DrawRect(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color)
-{
-    SDL_Rect full_rect;
-    SDL_Point points[5];
-
-    if (!dst) {
-        SDL_SetError("Passed NULL destination surface");
-        return -1;
-    }
-
-    /* If 'rect' == NULL, then outline the whole surface */
-    if (!rect) {
-        full_rect.x = 0;
-        full_rect.y = 0;
-        full_rect.w = dst->w;
-        full_rect.h = dst->h;
-        rect = &full_rect;
-    }
-
-    points[0].x = rect->x;
-    points[0].y = rect->y;
-    points[1].x = rect->x+rect->w-1;
-    points[1].y = rect->y;
-    points[2].x = rect->x+rect->w-1;
-    points[2].y = rect->y+rect->h-1;
-    points[3].x = rect->x;
-    points[3].y = rect->y+rect->h-1;
-    points[4].x = rect->x;
-    points[4].y = rect->y;
-    return SDL_DrawLines(dst, points, 5, color);
-}
-
-int
-SDL_DrawRects(SDL_Surface * dst, const SDL_Rect ** rects, int count,
-              Uint32 color)
-{
-    int i;
-
-    for (i = 0; i < count; ++i) {
-        if (SDL_DrawRect(dst, rects[i], color) < 0) {
-            return -1;
-        }
-    }
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_glesfuncs.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,229 +0,0 @@
-/* list of OpenGL ES functions sorted alphabetically
-   If you need to use a GLES function from the SDL video subsystem,
-   change it's entry from SDL_PROC_UNUSED to SDL_PROC and rebuild.
-*/
-#define SDL_PROC_UNUSED(ret,func,params)
-
-SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum func, GLclampf ref))
-SDL_PROC(void, glClearColor,
-         (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha))
-SDL_PROC_UNUSED(void, glClearDepthf, (GLclampf depth))
-SDL_PROC_UNUSED(void, glClipPlanef, (GLenum plane, const GLfloat * equation))
-SDL_PROC(void, glColor4f,
-         (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha))
-SDL_PROC_UNUSED(void, glDepthRangef, (GLclampf zNear, GLclampf zFar))
-SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glFrustumf,
-                (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top,
-                 GLfloat zNear, GLfloat zFar))
-SDL_PROC_UNUSED(void, glGetClipPlanef, (GLenum pname, GLfloat eqn[4]))
-SDL_PROC(void, glGetFloatv, (GLenum pname, GLfloat * params))
-SDL_PROC_UNUSED(void, glGetLightfv,
-                (GLenum light, GLenum pname, GLfloat * params))
-SDL_PROC_UNUSED(void, glGetMaterialfv,
-                (GLenum face, GLenum pname, GLfloat * params))
-SDL_PROC_UNUSED(void, glGetTexEnvfv,
-                (GLenum env, GLenum pname, GLfloat * params))
-SDL_PROC_UNUSED(void, glGetTexParameterfv,
-                (GLenum target, GLenum pname, GLfloat * params))
-SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glLightfv,
-                (GLenum light, GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glLineWidth, (GLfloat width))
-SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m))
-SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glMaterialfv,
-                (GLenum face, GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m))
-SDL_PROC_UNUSED(void, glMultiTexCoord4f,
-                (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q))
-SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz))
-SDL_PROC(void, glOrthof,
-         (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top,
-          GLfloat zNear, GLfloat zFar))
-SDL_PROC_UNUSED(void, glPointParameterf, (GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glPointParameterfv,
-                (GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glPointSize, (GLfloat size))
-SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units))
-SDL_PROC_UNUSED(void, glRotatef,
-                (GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
-SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z))
-SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glTexEnvfv,
-                (GLenum target, GLenum pname, const GLfloat * params))
-SDL_PROC(void, glTexParameterf, (GLenum target, GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glTexParameterfv,
-                (GLenum target, GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z))
-
-/* Available in both Common and Common-Lite profiles */
-SDL_PROC_UNUSED(void, glActiveTexture, (GLenum texture))
-SDL_PROC_UNUSED(void, glAlphaFuncx, (GLenum func, GLclampx ref))
-SDL_PROC_UNUSED(void, glBindBuffer, (GLenum target, GLuint buffer))
-SDL_PROC(void, glBindTexture, (GLenum target, GLuint texture))
-SDL_PROC(void, glBlendFunc, (GLenum sfactor, GLenum dfactor))
-SDL_PROC_UNUSED(void, glBufferData,
-                (GLenum target, GLsizeiptr size, const GLvoid * data,
-                 GLenum usage))
-SDL_PROC_UNUSED(void, glBufferSubData,
-                (GLenum target, GLintptr offset, GLsizeiptr size,
-                 const GLvoid * data))
-SDL_PROC(void, glClear, (GLbitfield mask))
-SDL_PROC_UNUSED(void, glClearColorx,
-                (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha))
-SDL_PROC_UNUSED(void, glClearDepthx, (GLclampx depth))
-SDL_PROC_UNUSED(void, glClearStencil, (GLint s))
-SDL_PROC_UNUSED(void, glClientActiveTexture, (GLenum texture))
-SDL_PROC_UNUSED(void, glClipPlanex, (GLenum plane, const GLfixed * equation))
-SDL_PROC_UNUSED(void, glColor4ub,
-                (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
-SDL_PROC_UNUSED(void, glColor4x,
-                (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha))
-SDL_PROC_UNUSED(void, glColorMask,
-                (GLboolean red, GLboolean green, GLboolean blue,
-                 GLboolean alpha))
-SDL_PROC(void, glColorPointer,
-         (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer))
-SDL_PROC_UNUSED(void, glCompressedTexImage2D,
-                (GLenum target, GLint level, GLenum internalformat,
-                 GLsizei width, GLsizei height, GLint border,
-                 GLsizei imageSize, const GLvoid * data))
-SDL_PROC_UNUSED(void, glCompressedTexSubImage2D,
-                (GLenum target, GLint level, GLint xoffset, GLint yoffset,
-                 GLsizei width, GLsizei height, GLenum format,
-                 GLsizei imageSize, const GLvoid * data))
-SDL_PROC_UNUSED(void, glCopyTexImage2D,
-                (GLenum target, GLint level, GLenum internalformat, GLint x,
-                 GLint y, GLsizei width, GLsizei height, GLint border))
-SDL_PROC_UNUSED(void, glCopyTexSubImage2D,
-                (GLenum target, GLint level, GLint xoffset, GLint yoffset,
-                 GLint x, GLint y, GLsizei width, GLsizei height))
-SDL_PROC_UNUSED(void, glCullFace, (GLenum mode))
-SDL_PROC_UNUSED(void, glDeleteBuffers, (GLsizei n, const GLuint * buffers))
-SDL_PROC_UNUSED(void, glDeleteTextures, (GLsizei n, const GLuint * textures))
-SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func))
-SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag))
-SDL_PROC_UNUSED(void, glDepthRangex, (GLclampx zNear, GLclampx zFar))
-SDL_PROC(void, glDisable, (GLenum cap))
-SDL_PROC(void, glDisableClientState, (GLenum array))
-SDL_PROC(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count))
-SDL_PROC_UNUSED(void, glDrawElements,
-                (GLenum mode, GLsizei count, GLenum type,
-                 const GLvoid * indices))
-SDL_PROC(void, glEnable, (GLenum cap))
-SDL_PROC(void, glEnableClientState, (GLenum array))
-SDL_PROC_UNUSED(void, glFinish, (void))
-SDL_PROC_UNUSED(void, glFlush, (void))
-SDL_PROC_UNUSED(void, glFogx, (GLenum pname, GLfixed param))
-SDL_PROC_UNUSED(void, glFogxv, (GLenum pname, const GLfixed * params))
-SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode))
-SDL_PROC_UNUSED(void, glFrustumx,
-                (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top,
-                 GLfixed zNear, GLfixed zFar))
-SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params))
-SDL_PROC_UNUSED(void, glGetBufferParameteriv,
-                (GLenum target, GLenum pname, GLint * params))
-SDL_PROC_UNUSED(void, glGetClipPlanex, (GLenum pname, GLfixed eqn[4]))
-SDL_PROC_UNUSED(void, glGenBuffers, (GLsizei n, GLuint * buffers))
-SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures))
-SDL_PROC(GLenum, glGetError, (void))
-SDL_PROC_UNUSED(void, glGetFixedv, (GLenum pname, GLfixed * params))
-SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params))
-SDL_PROC_UNUSED(void, glGetLightxv,
-                (GLenum light, GLenum pname, GLfixed * params))
-SDL_PROC_UNUSED(void, glGetMaterialxv,
-                (GLenum face, GLenum pname, GLfixed * params))
-SDL_PROC_UNUSED(void, glGetPointerv, (GLenum pname, void **params))
-SDL_PROC_UNUSED(const GLubyte *, glGetString, (GLenum name))
-SDL_PROC_UNUSED(void, glGetTexEnviv,
-                (GLenum env, GLenum pname, GLint * params))
-SDL_PROC_UNUSED(void, glGetTexEnvxv,
-                (GLenum env, GLenum pname, GLfixed * params))
-SDL_PROC_UNUSED(void, glGetTexParameteriv,
-                (GLenum target, GLenum pname, GLint * params))
-SDL_PROC_UNUSED(void, glGetTexParameterxv,
-                (GLenum target, GLenum pname, GLfixed * params))
-SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode))
-SDL_PROC_UNUSED(GLboolean, glIsBuffer, (GLuint buffer))
-SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap))
-SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture))
-SDL_PROC_UNUSED(void, glLightModelx, (GLenum pname, GLfixed param))
-SDL_PROC_UNUSED(void, glLightModelxv, (GLenum pname, const GLfixed * params))
-SDL_PROC_UNUSED(void, glLightx, (GLenum light, GLenum pname, GLfixed param))
-SDL_PROC_UNUSED(void, glLightxv,
-                (GLenum light, GLenum pname, const GLfixed * params))
-SDL_PROC_UNUSED(void, glLineWidthx, (GLfixed width))
-SDL_PROC(void, glLoadIdentity, (void))
-SDL_PROC_UNUSED(void, glLoadMatrixx, (const GLfixed * m))
-SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode))
-SDL_PROC_UNUSED(void, glMaterialx, (GLenum face, GLenum pname, GLfixed param))
-SDL_PROC_UNUSED(void, glMaterialxv,
-                (GLenum face, GLenum pname, const GLfixed * params))
-SDL_PROC(void, glMatrixMode, (GLenum mode))
-SDL_PROC_UNUSED(void, glMultMatrixx, (const GLfixed * m))
-SDL_PROC_UNUSED(void, glMultiTexCoord4x,
-                (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q))
-SDL_PROC_UNUSED(void, glNormal3x, (GLfixed nx, GLfixed ny, GLfixed nz))
-SDL_PROC_UNUSED(void, glNormalPointer,
-                (GLenum type, GLsizei stride, const GLvoid * pointer))
-SDL_PROC_UNUSED(void, glOrthox,
-                (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top,
-                 GLfixed zNear, GLfixed zFar))
-SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glPointParameterx, (GLenum pname, GLfixed param))
-SDL_PROC_UNUSED(void, glPointParameterxv,
-                (GLenum pname, const GLfixed * params))
-SDL_PROC_UNUSED(void, glPointSizex, (GLfixed size))
-SDL_PROC_UNUSED(void, glPolygonOffsetx, (GLfixed factor, GLfixed units))
-SDL_PROC_UNUSED(void, glPopMatrix, (void))
-SDL_PROC_UNUSED(void, glPushMatrix, (void))
-SDL_PROC_UNUSED(void, glReadPixels,
-                (GLint x, GLint y, GLsizei width, GLsizei height,
-                 GLenum format, GLenum type, GLvoid * pixels))
-SDL_PROC_UNUSED(void, glRotatex,
-                (GLfixed angle, GLfixed x, GLfixed y, GLfixed z))
-SDL_PROC_UNUSED(void, glSampleCoverage, (GLclampf value, GLboolean invert))
-SDL_PROC_UNUSED(void, glSampleCoveragex, (GLclampx value, GLboolean invert))
-SDL_PROC_UNUSED(void, glScalex, (GLfixed x, GLfixed y, GLfixed z))
-SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height))
-SDL_PROC_UNUSED(void, glShadeModel, (GLenum mode))
-SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask))
-SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask))
-SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass))
-SDL_PROC(void, glTexCoordPointer,
-         (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer))
-SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glTexEnvx, (GLenum target, GLenum pname, GLfixed param))
-SDL_PROC_UNUSED(void, glTexEnviv,
-                (GLenum target, GLenum pname, const GLint * params))
-SDL_PROC_UNUSED(void, glTexEnvxv,
-                (GLenum target, GLenum pname, const GLfixed * params))
-SDL_PROC(void, glTexImage2D,
-         (GLenum target, GLint level, GLint internalformat, GLsizei width,
-          GLsizei height, GLint border, GLenum format, GLenum type,
-          const GLvoid * pixels))
-SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glTexParameterx,
-                (GLenum target, GLenum pname, GLfixed param))
-SDL_PROC(void, glTexParameteriv,
-         (GLenum target, GLenum pname, const GLint * params))
-SDL_PROC_UNUSED(void, glTexParameterxv,
-                (GLenum target, GLenum pname, const GLfixed * params))
-SDL_PROC(void, glTexSubImage2D,
-         (GLenum target, GLint level, GLint xoffset, GLint yoffset,
-          GLsizei width, GLsizei height, GLenum format, GLenum type,
-          const GLvoid * pixels))
-SDL_PROC_UNUSED(void, glTranslatex, (GLfixed x, GLfixed y, GLfixed z))
-SDL_PROC(void, glVertexPointer,
-         (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer))
-SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height))
-
-/* extension functions used */
-SDL_PROC(void, glDrawTexiOES,
-         (GLint x, GLint y, GLint z, GLint width, GLint height))
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_glfuncs.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,455 +0,0 @@
-/* list of OpenGL functions sorted alphabetically
-   If you need to use a GL function from the SDL video subsystem,
-   change it's entry from SDL_PROC_UNUSED to SDL_PROC and rebuild.
-*/
-#define SDL_PROC_UNUSED(ret,func,params)
-SDL_PROC_UNUSED(void, glAccum, (GLenum, GLfloat))
-SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum, GLclampf))
-SDL_PROC_UNUSED(GLboolean, glAreTexturesResident,
-                (GLsizei, const GLuint *, GLboolean *))
-SDL_PROC_UNUSED(void, glArrayElement, (GLint))
-SDL_PROC(void, glBegin, (GLenum))
-SDL_PROC(void, glBindTexture, (GLenum, GLuint))
-SDL_PROC_UNUSED(void, glBitmap,
-                (GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat,
-                 const GLubyte *))
-SDL_PROC(void, glBlendFunc, (GLenum, GLenum))
-SDL_PROC_UNUSED(void, glCallList, (GLuint))
-SDL_PROC_UNUSED(void, glCallLists, (GLsizei, GLenum, const GLvoid *))
-SDL_PROC(void, glClear, (GLbitfield))
-SDL_PROC_UNUSED(void, glClearAccum, (GLfloat, GLfloat, GLfloat, GLfloat))
-SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
-SDL_PROC_UNUSED(void, glClearDepth, (GLclampd))
-SDL_PROC_UNUSED(void, glClearIndex, (GLfloat))
-SDL_PROC_UNUSED(void, glClearStencil, (GLint))
-SDL_PROC_UNUSED(void, glClipPlane, (GLenum, const GLdouble *))
-SDL_PROC_UNUSED(void, glColor3b, (GLbyte, GLbyte, GLbyte))
-SDL_PROC_UNUSED(void, glColor3bv, (const GLbyte *))
-SDL_PROC_UNUSED(void, glColor3d, (GLdouble, GLdouble, GLdouble))
-SDL_PROC_UNUSED(void, glColor3dv, (const GLdouble *))
-SDL_PROC_UNUSED(void, glColor3f, (GLfloat, GLfloat, GLfloat))
-SDL_PROC_UNUSED(void, glColor3fv, (const GLfloat *))
-SDL_PROC_UNUSED(void, glColor3i, (GLint, GLint, GLint))
-SDL_PROC_UNUSED(void, glColor3iv, (const GLint *))
-SDL_PROC_UNUSED(void, glColor3s, (GLshort, GLshort, GLshort))
-SDL_PROC_UNUSED(void, glColor3sv, (const GLshort *))
-SDL_PROC_UNUSED(void, glColor3ub, (GLubyte, GLubyte, GLubyte))
-SDL_PROC_UNUSED(void, glColor3ubv, (const GLubyte *))
-SDL_PROC_UNUSED(void, glColor3ui, (GLuint, GLuint, GLuint))
-SDL_PROC_UNUSED(void, glColor3uiv, (const GLuint *))
-SDL_PROC_UNUSED(void, glColor3us, (GLushort, GLushort, GLushort))
-SDL_PROC_UNUSED(void, glColor3usv, (const GLushort *))
-SDL_PROC_UNUSED(void, glColor4b, (GLbyte, GLbyte, GLbyte, GLbyte))
-SDL_PROC_UNUSED(void, glColor4bv, (const GLbyte *))
-SDL_PROC_UNUSED(void, glColor4d, (GLdouble, GLdouble, GLdouble, GLdouble))
-SDL_PROC_UNUSED(void, glColor4dv, (const GLdouble *))
-SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat))
-SDL_PROC_UNUSED(void, glColor4fv, (const GLfloat *))
-SDL_PROC_UNUSED(void, glColor4i, (GLint, GLint, GLint, GLint))
-SDL_PROC_UNUSED(void, glColor4iv, (const GLint *))
-SDL_PROC_UNUSED(void, glColor4s, (GLshort, GLshort, GLshort, GLshort))
-SDL_PROC_UNUSED(void, glColor4sv, (const GLshort *))
-SDL_PROC_UNUSED(void, glColor4ub,
-                (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
-SDL_PROC_UNUSED(void, glColor4ubv, (const GLubyte * v))
-SDL_PROC_UNUSED(void, glColor4ui,
-                (GLuint red, GLuint green, GLuint blue, GLuint alpha))
-SDL_PROC_UNUSED(void, glColor4uiv, (const GLuint * v))
-SDL_PROC_UNUSED(void, glColor4us,
-                (GLushort red, GLushort green, GLushort blue, GLushort alpha))
-SDL_PROC_UNUSED(void, glColor4usv, (const GLushort * v))
-SDL_PROC_UNUSED(void, glColorMask,
-                (GLboolean red, GLboolean green, GLboolean blue,
-                 GLboolean alpha))
-SDL_PROC_UNUSED(void, glColorMaterial, (GLenum face, GLenum mode))
-SDL_PROC_UNUSED(void, glColorPointer,
-                (GLint size, GLenum type, GLsizei stride,
-                 const GLvoid * pointer))
-SDL_PROC_UNUSED(void, glCopyPixels,
-                (GLint x, GLint y, GLsizei width, GLsizei height,
-                 GLenum type))
-SDL_PROC_UNUSED(void, glCopyTexImage1D,
-                (GLenum target, GLint level, GLenum internalFormat, GLint x,
-                 GLint y, GLsizei width, GLint border))
-SDL_PROC_UNUSED(void, glCopyTexImage2D,
-                (GLenum target, GLint level, GLenum internalFormat, GLint x,
-                 GLint y, GLsizei width, GLsizei height, GLint border))
-SDL_PROC_UNUSED(void, glCopyTexSubImage1D,
-                (GLenum target, GLint level, GLint xoffset, GLint x, GLint y,
-                 GLsizei width))
-SDL_PROC_UNUSED(void, glCopyTexSubImage2D,
-                (GLenum target, GLint level, GLint xoffset, GLint yoffset,
-                 GLint x, GLint y, GLsizei width, GLsizei height))
-SDL_PROC_UNUSED(void, glCullFace, (GLenum mode))
-SDL_PROC_UNUSED(void, glDeleteLists, (GLuint list, GLsizei range))
-SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint * textures))
-SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func))
-SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag))
-SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar))
-SDL_PROC(void, glDisable, (GLenum cap))
-SDL_PROC_UNUSED(void, glDisableClientState, (GLenum array))
-SDL_PROC_UNUSED(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count))
-SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode))
-SDL_PROC_UNUSED(void, glDrawElements,
-                (GLenum mode, GLsizei count, GLenum type,
-                 const GLvoid * indices))
-SDL_PROC(void, glDrawPixels,
-         (GLsizei width, GLsizei height, GLenum format, GLenum type,
-          const GLvoid * pixels))
-SDL_PROC_UNUSED(void, glEdgeFlag, (GLboolean flag))
-SDL_PROC_UNUSED(void, glEdgeFlagPointer,
-                (GLsizei stride, const GLvoid * pointer))
-SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag))
-SDL_PROC(void, glEnable, (GLenum cap))
-SDL_PROC_UNUSED(void, glEnableClientState, (GLenum array))
-SDL_PROC(void, glEnd, (void))
-SDL_PROC_UNUSED(void, glEndList, (void))
-SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u))
-SDL_PROC_UNUSED(void, glEvalCoord1dv, (const GLdouble * u))
-SDL_PROC_UNUSED(void, glEvalCoord1f, (GLfloat u))
-SDL_PROC_UNUSED(void, glEvalCoord1fv, (const GLfloat * u))
-SDL_PROC_UNUSED(void, glEvalCoord2d, (GLdouble u, GLdouble v))
-SDL_PROC_UNUSED(void, glEvalCoord2dv, (const GLdouble * u))
-SDL_PROC_UNUSED(void, glEvalCoord2f, (GLfloat u, GLfloat v))
-SDL_PROC_UNUSED(void, glEvalCoord2fv, (const GLfloat * u))
-SDL_PROC_UNUSED(void, glEvalMesh1, (GLenum mode, GLint i1, GLint i2))
-SDL_PROC_UNUSED(void, glEvalMesh2,
-                (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2))
-SDL_PROC_UNUSED(void, glEvalPoint1, (GLint i))
-SDL_PROC_UNUSED(void, glEvalPoint2, (GLint i, GLint j))
-SDL_PROC_UNUSED(void, glFeedbackBuffer,
-                (GLsizei size, GLenum type, GLfloat * buffer))
-SDL_PROC_UNUSED(void, glFinish, (void))
-SDL_PROC_UNUSED(void, glFlush, (void))
-SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glFogi, (GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glFogiv, (GLenum pname, const GLint * params))
-SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode))
-SDL_PROC_UNUSED(void, glFrustum,
-                (GLdouble left, GLdouble right, GLdouble bottom,
-                 GLdouble top, GLdouble zNear, GLdouble zFar))
-SDL_PROC_UNUSED(GLuint, glGenLists, (GLsizei range))
-SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures))
-SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params))
-SDL_PROC_UNUSED(void, glGetClipPlane, (GLenum plane, GLdouble * equation))
-SDL_PROC_UNUSED(void, glGetDoublev, (GLenum pname, GLdouble * params))
-SDL_PROC(GLenum, glGetError, (void))
-SDL_PROC_UNUSED(void, glGetFloatv, (GLenum pname, GLfloat * params))
-SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params))
-SDL_PROC_UNUSED(void, glGetLightfv,
-                (GLenum light, GLenum pname, GLfloat * params))
-SDL_PROC_UNUSED(void, glGetLightiv,
-                (GLenum light, GLenum pname, GLint * params))
-SDL_PROC_UNUSED(void, glGetMapdv, (GLenum target, GLenum query, GLdouble * v))
-SDL_PROC_UNUSED(void, glGetMapfv, (GLenum target, GLenum query, GLfloat * v))
-SDL_PROC_UNUSED(void, glGetMapiv, (GLenum target, GLenum query, GLint * v))
-SDL_PROC_UNUSED(void, glGetMaterialfv,
-                (GLenum face, GLenum pname, GLfloat * params))
-SDL_PROC_UNUSED(void, glGetMaterialiv,
-                (GLenum face, GLenum pname, GLint * params))
-SDL_PROC_UNUSED(void, glGetPixelMapfv, (GLenum map, GLfloat * values))
-SDL_PROC_UNUSED(void, glGetPixelMapuiv, (GLenum map, GLuint * values))
-SDL_PROC_UNUSED(void, glGetPixelMapusv, (GLenum map, GLushort * values))
-SDL_PROC_UNUSED(void, glGetPointerv, (GLenum pname, GLvoid * *params))
-SDL_PROC_UNUSED(void, glGetPolygonStipple, (GLubyte * mask))
-SDL_PROC(const GLubyte *, glGetString, (GLenum name))
-SDL_PROC_UNUSED(void, glGetTexEnvfv,
-                (GLenum target, GLenum pname, GLfloat * params))
-SDL_PROC_UNUSED(void, glGetTexEnviv,
-                (GLenum target, GLenum pname, GLint * params))
-SDL_PROC_UNUSED(void, glGetTexGendv,
-                (GLenum coord, GLenum pname, GLdouble * params))
-SDL_PROC_UNUSED(void, glGetTexGenfv,
-                (GLenum coord, GLenum pname, GLfloat * params))
-SDL_PROC_UNUSED(void, glGetTexGeniv,
-                (GLenum coord, GLenum pname, GLint * params))
-SDL_PROC_UNUSED(void, glGetTexImage,
-                (GLenum target, GLint level, GLenum format, GLenum type,
-                 GLvoid * pixels))
-SDL_PROC_UNUSED(void, glGetTexLevelParameterfv,
-                (GLenum target, GLint level, GLenum pname, GLfloat * params))
-SDL_PROC_UNUSED(void, glGetTexLevelParameteriv,
-                (GLenum target, GLint level, GLenum pname, GLint * params))
-SDL_PROC_UNUSED(void, glGetTexParameterfv,
-                (GLenum target, GLenum pname, GLfloat * params))
-SDL_PROC_UNUSED(void, glGetTexParameteriv,
-                (GLenum target, GLenum pname, GLint * params))
-SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode))
-SDL_PROC_UNUSED(void, glIndexMask, (GLuint mask))
-SDL_PROC_UNUSED(void, glIndexPointer,
-                (GLenum type, GLsizei stride, const GLvoid * pointer))
-SDL_PROC_UNUSED(void, glIndexd, (GLdouble c))
-SDL_PROC_UNUSED(void, glIndexdv, (const GLdouble * c))
-SDL_PROC_UNUSED(void, glIndexf, (GLfloat c))
-SDL_PROC_UNUSED(void, glIndexfv, (const GLfloat * c))
-SDL_PROC_UNUSED(void, glIndexi, (GLint c))
-SDL_PROC_UNUSED(void, glIndexiv, (const GLint * c))
-SDL_PROC_UNUSED(void, glIndexs, (GLshort c))
-SDL_PROC_UNUSED(void, glIndexsv, (const GLshort * c))
-SDL_PROC_UNUSED(void, glIndexub, (GLubyte c))
-SDL_PROC_UNUSED(void, glIndexubv, (const GLubyte * c))
-SDL_PROC_UNUSED(void, glInitNames, (void))
-SDL_PROC_UNUSED(void, glInterleavedArrays,
-                (GLenum format, GLsizei stride, const GLvoid * pointer))
-SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap))
-SDL_PROC_UNUSED(GLboolean, glIsList, (GLuint list))
-SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture))
-SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glLightModeli, (GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glLightModeliv, (GLenum pname, const GLint * params))
-SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glLightfv,
-                (GLenum light, GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glLighti, (GLenum light, GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glLightiv,
-                (GLenum light, GLenum pname, const GLint * params))
-SDL_PROC_UNUSED(void, glLineStipple, (GLint factor, GLushort pattern))
-SDL_PROC(void, glLineWidth, (GLfloat width))
-SDL_PROC_UNUSED(void, glListBase, (GLuint base))
-SDL_PROC(void, glLoadIdentity, (void))
-SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble * m))
-SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m))
-SDL_PROC_UNUSED(void, glLoadName, (GLuint name))
-SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode))
-SDL_PROC_UNUSED(void, glMap1d,
-                (GLenum target, GLdouble u1, GLdouble u2, GLint stride,
-                 GLint order, const GLdouble * points))
-SDL_PROC_UNUSED(void, glMap1f,
-                (GLenum target, GLfloat u1, GLfloat u2, GLint stride,
-                 GLint order, const GLfloat * points))
-SDL_PROC_UNUSED(void, glMap2d,
-                (GLenum target, GLdouble u1, GLdouble u2, GLint ustride,
-                 GLint uorder, GLdouble v1, GLdouble v2, GLint vstride,
-                 GLint vorder, const GLdouble * points))
-SDL_PROC_UNUSED(void, glMap2f,
-                (GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
-                 GLint uorder, GLfloat v1, GLfloat v2, GLint vstride,
-                 GLint vorder, const GLfloat * points))
-SDL_PROC_UNUSED(void, glMapGrid1d, (GLint un, GLdouble u1, GLdouble u2))
-SDL_PROC_UNUSED(void, glMapGrid1f, (GLint un, GLfloat u1, GLfloat u2))
-SDL_PROC_UNUSED(void, glMapGrid2d,
-                (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1,
-                 GLdouble v2))
-SDL_PROC_UNUSED(void, glMapGrid2f,
-                (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1,
-                 GLfloat v2))
-SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glMaterialfv,
-                (GLenum face, GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glMateriali, (GLenum face, GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glMaterialiv,
-                (GLenum face, GLenum pname, const GLint * params))
-SDL_PROC(void, glMatrixMode, (GLenum mode))
-SDL_PROC_UNUSED(void, glMultMatrixd, (const GLdouble * m))
-SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m))
-SDL_PROC_UNUSED(void, glNewList, (GLuint list, GLenum mode))
-SDL_PROC_UNUSED(void, glNormal3b, (GLbyte nx, GLbyte ny, GLbyte nz))
-SDL_PROC_UNUSED(void, glNormal3bv, (const GLbyte * v))
-SDL_PROC_UNUSED(void, glNormal3d, (GLdouble nx, GLdouble ny, GLdouble nz))
-SDL_PROC_UNUSED(void, glNormal3dv, (const GLdouble * v))
-SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz))
-SDL_PROC_UNUSED(void, glNormal3fv, (const GLfloat * v))
-SDL_PROC_UNUSED(void, glNormal3i, (GLint nx, GLint ny, GLint nz))
-SDL_PROC_UNUSED(void, glNormal3iv, (const GLint * v))
-SDL_PROC_UNUSED(void, glNormal3s, (GLshort nx, GLshort ny, GLshort nz))
-SDL_PROC_UNUSED(void, glNormal3sv, (const GLshort * v))
-SDL_PROC_UNUSED(void, glNormalPointer,
-                (GLenum type, GLsizei stride, const GLvoid * pointer))
-SDL_PROC(void, glOrtho,
-         (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
-          GLdouble zNear, GLdouble zFar))
-SDL_PROC_UNUSED(void, glPassThrough, (GLfloat token))
-SDL_PROC_UNUSED(void, glPixelMapfv,
-                (GLenum map, GLsizei mapsize, const GLfloat * values))
-SDL_PROC_UNUSED(void, glPixelMapuiv,
-                (GLenum map, GLsizei mapsize, const GLuint * values))
-SDL_PROC_UNUSED(void, glPixelMapusv,
-                (GLenum map, GLsizei mapsize, const GLushort * values))
-SDL_PROC_UNUSED(void, glPixelStoref, (GLenum pname, GLfloat param))
-SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glPixelTransferf, (GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glPixelTransferi, (GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glPixelZoom, (GLfloat xfactor, GLfloat yfactor))
-SDL_PROC(void, glPointSize, (GLfloat size))
-SDL_PROC_UNUSED(void, glPolygonMode, (GLenum face, GLenum mode))
-SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units))
-SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte * mask))
-SDL_PROC_UNUSED(void, glPopAttrib, (void))
-SDL_PROC_UNUSED(void, glPopClientAttrib, (void))
-SDL_PROC_UNUSED(void, glPopMatrix, (void))
-SDL_PROC_UNUSED(void, glPopName, (void))
-SDL_PROC_UNUSED(void, glPrioritizeTextures,
-                (GLsizei n, const GLuint * textures,
-                 const GLclampf * priorities))
-SDL_PROC_UNUSED(void, glPushAttrib, (GLbitfield mask))
-SDL_PROC_UNUSED(void, glPushClientAttrib, (GLbitfield mask))
-SDL_PROC_UNUSED(void, glPushMatrix, (void))
-SDL_PROC_UNUSED(void, glPushName, (GLuint name))
-SDL_PROC_UNUSED(void, glRasterPos2d, (GLdouble x, GLdouble y))
-SDL_PROC_UNUSED(void, glRasterPos2dv, (const GLdouble * v))
-SDL_PROC_UNUSED(void, glRasterPos2f, (GLfloat x, GLfloat y))
-SDL_PROC_UNUSED(void, glRasterPos2fv, (const GLfloat * v))
-SDL_PROC(void, glRasterPos2i, (GLint x, GLint y))
-SDL_PROC_UNUSED(void, glRasterPos2iv, (const GLint * v))
-SDL_PROC_UNUSED(void, glRasterPos2s, (GLshort x, GLshort y))
-SDL_PROC_UNUSED(void, glRasterPos2sv, (const GLshort * v))
-SDL_PROC_UNUSED(void, glRasterPos3d, (GLdouble x, GLdouble y, GLdouble z))
-SDL_PROC_UNUSED(void, glRasterPos3dv, (const GLdouble * v))
-SDL_PROC_UNUSED(void, glRasterPos3f, (GLfloat x, GLfloat y, GLfloat z))
-SDL_PROC_UNUSED(void, glRasterPos3fv, (const GLfloat * v))
-SDL_PROC_UNUSED(void, glRasterPos3i, (GLint x, GLint y, GLint z))
-SDL_PROC_UNUSED(void, glRasterPos3iv, (const GLint * v))
-SDL_PROC_UNUSED(void, glRasterPos3s, (GLshort x, GLshort y, GLshort z))
-SDL_PROC_UNUSED(void, glRasterPos3sv, (const GLshort * v))
-SDL_PROC_UNUSED(void, glRasterPos4d,
-                (GLdouble x, GLdouble y, GLdouble z, GLdouble w))
-SDL_PROC_UNUSED(void, glRasterPos4dv, (const GLdouble * v))
-SDL_PROC_UNUSED(void, glRasterPos4f,
-                (GLfloat x, GLfloat y, GLfloat z, GLfloat w))
-SDL_PROC_UNUSED(void, glRasterPos4fv, (const GLfloat * v))
-SDL_PROC_UNUSED(void, glRasterPos4i, (GLint x, GLint y, GLint z, GLint w))
-SDL_PROC_UNUSED(void, glRasterPos4iv, (const GLint * v))
-SDL_PROC_UNUSED(void, glRasterPos4s,
-                (GLshort x, GLshort y, GLshort z, GLshort w))
-SDL_PROC_UNUSED(void, glRasterPos4sv, (const GLshort * v))
-SDL_PROC(void, glReadBuffer, (GLenum mode))
-SDL_PROC(void, glReadPixels,
-         (GLint x, GLint y, GLsizei width, GLsizei height,
-          GLenum format, GLenum type, GLvoid * pixels))
-SDL_PROC_UNUSED(void, glRectd,
-                (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2))
-SDL_PROC_UNUSED(void, glRectdv, (const GLdouble * v1, const GLdouble * v2))
-SDL_PROC_UNUSED(void, glRectf,
-                (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2))
-SDL_PROC_UNUSED(void, glRectfv, (const GLfloat * v1, const GLfloat * v2))
-SDL_PROC(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2))
-SDL_PROC_UNUSED(void, glRectiv, (const GLint * v1, const GLint * v2))
-SDL_PROC_UNUSED(void, glRects,
-                (GLshort x1, GLshort y1, GLshort x2, GLshort y2))
-SDL_PROC_UNUSED(void, glRectsv, (const GLshort * v1, const GLshort * v2))
-SDL_PROC_UNUSED(GLint, glRenderMode, (GLenum mode))
-SDL_PROC_UNUSED(void, glRotated,
-                (GLdouble angle, GLdouble x, GLdouble y, GLdouble z))
-SDL_PROC_UNUSED(void, glRotatef,
-                (GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
-SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z))
-SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z))
-SDL_PROC_UNUSED(void, glScissor,
-                (GLint x, GLint y, GLsizei width, GLsizei height))
-SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint * buffer))
-SDL_PROC_UNUSED(void, glShadeModel, (GLenum mode))
-SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask))
-SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask))
-SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass))
-SDL_PROC_UNUSED(void, glTexCoord1d, (GLdouble s))
-SDL_PROC_UNUSED(void, glTexCoord1dv, (const GLdouble * v))
-SDL_PROC_UNUSED(void, glTexCoord1f, (GLfloat s))
-SDL_PROC_UNUSED(void, glTexCoord1fv, (const GLfloat * v))
-SDL_PROC_UNUSED(void, glTexCoord1i, (GLint s))
-SDL_PROC_UNUSED(void, glTexCoord1iv, (const GLint * v))
-SDL_PROC_UNUSED(void, glTexCoord1s, (GLshort s))
-SDL_PROC_UNUSED(void, glTexCoord1sv, (const GLshort * v))
-SDL_PROC_UNUSED(void, glTexCoord2d, (GLdouble s, GLdouble t))
-SDL_PROC_UNUSED(void, glTexCoord2dv, (const GLdouble * v))
-SDL_PROC(void, glTexCoord2f, (GLfloat s, GLfloat t))
-SDL_PROC_UNUSED(void, glTexCoord2fv, (const GLfloat * v))
-SDL_PROC_UNUSED(void, glTexCoord2i, (GLint s, GLint t))
-SDL_PROC_UNUSED(void, glTexCoord2iv, (const GLint * v))
-SDL_PROC_UNUSED(void, glTexCoord2s, (GLshort s, GLshort t))
-SDL_PROC_UNUSED(void, glTexCoord2sv, (const GLshort * v))
-SDL_PROC_UNUSED(void, glTexCoord3d, (GLdouble s, GLdouble t, GLdouble r))
-SDL_PROC_UNUSED(void, glTexCoord3dv, (const GLdouble * v))
-SDL_PROC_UNUSED(void, glTexCoord3f, (GLfloat s, GLfloat t, GLfloat r))
-SDL_PROC_UNUSED(void, glTexCoord3fv, (const GLfloat * v))
-SDL_PROC_UNUSED(void, glTexCoord3i, (GLint s, GLint t, GLint r))
-SDL_PROC_UNUSED(void, glTexCoord3iv, (const GLint * v))
-SDL_PROC_UNUSED(void, glTexCoord3s, (GLshort s, GLshort t, GLshort r))
-SDL_PROC_UNUSED(void, glTexCoord3sv, (const GLshort * v))
-SDL_PROC_UNUSED(void, glTexCoord4d,
-                (GLdouble s, GLdouble t, GLdouble r, GLdouble q))
-SDL_PROC_UNUSED(void, glTexCoord4dv, (const GLdouble * v))
-SDL_PROC_UNUSED(void, glTexCoord4f,
-                (GLfloat s, GLfloat t, GLfloat r, GLfloat q))
-SDL_PROC_UNUSED(void, glTexCoord4fv, (const GLfloat * v))
-SDL_PROC_UNUSED(void, glTexCoord4i, (GLint s, GLint t, GLint r, GLint q))
-SDL_PROC_UNUSED(void, glTexCoord4iv, (const GLint * v))
-SDL_PROC_UNUSED(void, glTexCoord4s,
-                (GLshort s, GLshort t, GLshort r, GLshort q))
-SDL_PROC_UNUSED(void, glTexCoord4sv, (const GLshort * v))
-SDL_PROC_UNUSED(void, glTexCoordPointer,
-                (GLint size, GLenum type, GLsizei stride,
-                 const GLvoid * pointer))
-SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glTexEnvfv,
-                (GLenum target, GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glTexEnviv,
-                (GLenum target, GLenum pname, const GLint * params))
-SDL_PROC_UNUSED(void, glTexGend, (GLenum coord, GLenum pname, GLdouble param))
-SDL_PROC_UNUSED(void, glTexGendv,
-                (GLenum coord, GLenum pname, const GLdouble * params))
-SDL_PROC_UNUSED(void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glTexGenfv,
-                (GLenum coord, GLenum pname, const GLfloat * params))
-SDL_PROC_UNUSED(void, glTexGeni, (GLenum coord, GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glTexGeniv,
-                (GLenum coord, GLenum pname, const GLint * params))
-SDL_PROC_UNUSED(void, glTexImage1D,
-                (GLenum target, GLint level, GLint internalformat,
-                 GLsizei width, GLint border, GLenum format, GLenum type,
-                 const GLvoid * pixels))
-SDL_PROC(void, glTexImage2D,
-         (GLenum target, GLint level, GLint internalformat, GLsizei width,
-          GLsizei height, GLint border, GLenum format, GLenum type,
-          const GLvoid * pixels))
-SDL_PROC_UNUSED(void, glTexParameterf,
-                (GLenum target, GLenum pname, GLfloat param))
-SDL_PROC_UNUSED(void, glTexParameterfv,
-                (GLenum target, GLenum pname, const GLfloat * params))
-SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param))
-SDL_PROC_UNUSED(void, glTexParameteriv,
-                (GLenum target, GLenum pname, const GLint * params))
-SDL_PROC_UNUSED(void, glTexSubImage1D,
-                (GLenum target, GLint level, GLint xoffset, GLsizei width,
-                 GLenum format, GLenum type, const GLvoid * pixels))
-SDL_PROC(void, glTexSubImage2D,
-         (GLenum target, GLint level, GLint xoffset, GLint yoffset,
-          GLsizei width, GLsizei height, GLenum format, GLenum type,
-          const GLvoid * pixels))
-SDL_PROC_UNUSED(void, glTranslated, (GLdouble x, GLdouble y, GLdouble z))
-SDL_PROC_UNUSED(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z))
-SDL_PROC_UNUSED(void, glVertex2d, (GLdouble x, GLdouble y))
-SDL_PROC_UNUSED(void, glVertex2dv, (const GLdouble * v))
-SDL_PROC(void, glVertex2f, (GLfloat x, GLfloat y))
-SDL_PROC_UNUSED(void, glVertex2fv, (const GLfloat * v))
-SDL_PROC_UNUSED(void, glVertex2i, (GLint x, GLint y))
-SDL_PROC_UNUSED(void, glVertex2iv, (const GLint * v))
-SDL_PROC_UNUSED(void, glVertex2s, (GLshort x, GLshort y))
-SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort * v))
-SDL_PROC_UNUSED(void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z))
-SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble * v))
-SDL_PROC_UNUSED(void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z))
-SDL_PROC_UNUSED(void, glVertex3fv, (const GLfloat * v))
-SDL_PROC_UNUSED(void, glVertex3i, (GLint x, GLint y, GLint z))
-SDL_PROC_UNUSED(void, glVertex3iv, (const GLint * v))
-SDL_PROC_UNUSED(void, glVertex3s, (GLshort x, GLshort y, GLshort z))
-SDL_PROC_UNUSED(void, glVertex3sv, (const GLshort * v))
-SDL_PROC_UNUSED(void, glVertex4d,
-                (GLdouble x, GLdouble y, GLdouble z, GLdouble w))
-SDL_PROC_UNUSED(void, glVertex4dv, (const GLdouble * v))
-SDL_PROC_UNUSED(void, glVertex4f,
-                (GLfloat x, GLfloat y, GLfloat z, GLfloat w))
-SDL_PROC_UNUSED(void, glVertex4fv, (const GLfloat * v))
-SDL_PROC_UNUSED(void, glVertex4i, (GLint x, GLint y, GLint z, GLint w))
-SDL_PROC_UNUSED(void, glVertex4iv, (const GLint * v))
-SDL_PROC_UNUSED(void, glVertex4s,
-                (GLshort x, GLshort y, GLshort z, GLshort w))
-SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v))
-SDL_PROC_UNUSED(void, glVertexPointer,
-                (GLint size, GLenum type, GLsizei stride,
-                 const GLvoid * pointer))
-SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height))
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_leaks.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_leaks.h	Sun Feb 06 21:23:32 2011 -0800
@@ -29,4 +29,5 @@
 #ifdef CHECK_LEAKS
 extern int surfaces_allocated;
 #endif
+
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_pixels.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_pixels.c	Sun Feb 06 21:23:32 2011 -0800
@@ -256,11 +256,11 @@
         }
         break;
     case 15:
-        switch (Rmask) {
-        case 0x001F:
+        if (Rmask == 0x7C00 && Bmask == 0x001F) {
+            return SDL_PIXELFORMAT_RGB555;
+        }
+        if (Rmask == 0x001F && Bmask == 0x7C00) {
             return SDL_PIXELFORMAT_BGR555;
-        case 0x7C00:
-            return SDL_PIXELFORMAT_RGB555;
         }
         break;
     case 16:
@@ -273,18 +273,24 @@
             return SDL_PIXELFORMAT_BGRA4444;
         case 0x000F:
             return SDL_PIXELFORMAT_ABGR4444;
+        case 0xF800:
+            if (Bmask == 0x001F) {
+                return SDL_PIXELFORMAT_RGB565;
+            }
+            break;
+        case 0x7C00:
+            if (Bmask == 0x001F) {
+                return SDL_PIXELFORMAT_RGB555;
+            }
+            break;
         case 0x001F:
-            if (Gmask == 0x07E0) {
+            if (Bmask == 0xF800) {
                 return SDL_PIXELFORMAT_BGR565;
             }
-            return SDL_PIXELFORMAT_ABGR1555;
-        case 0x7C00:
-            return SDL_PIXELFORMAT_ARGB1555;
-        case 0xF800:
-            if (Gmask == 0x07E0) {
-                return SDL_PIXELFORMAT_RGB565;
+            if (Bmask == 0x7C00) {
+                return SDL_PIXELFORMAT_BGR555;
             }
-            return SDL_PIXELFORMAT_RGBA5551;
+            break;
         }
         break;
     case 24:
--- a/src/video/SDL_pixels_c.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_pixels_c.h	Sun Feb 06 21:23:32 2011 -0800
@@ -47,4 +47,5 @@
 extern Uint8 SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b);
 extern void SDL_ApplyGamma(Uint16 * gamma, SDL_Color * colors,
                            SDL_Color * output, int ncolors);
+
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_rect.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_rect.c	Sun Feb 06 21:23:32 2011 -0800
@@ -21,8 +21,7 @@
 */
 #include "SDL_config.h"
 
-#include "SDL_video.h"
-#include "SDL_rect_c.h"
+#include "SDL_rect.h"
 
 SDL_bool
 SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B)
@@ -340,66 +339,4 @@
     return SDL_TRUE;
 }
 
-void
-SDL_AddDirtyRect(SDL_DirtyRectList * list, const SDL_Rect * rect)
-{
-    SDL_DirtyRect *dirty;
-
-    /* FIXME: At what point is this optimization too expensive? */
-    for (dirty = list->list; dirty; dirty = dirty->next) {
-        if (SDL_HasIntersection(&dirty->rect, rect)) {
-            SDL_UnionRect(&dirty->rect, rect, &dirty->rect);
-            return;
-        }
-    }
-
-    if (list->free) {
-        dirty = list->free;
-        list->free = dirty->next;
-    } else {
-        dirty = (SDL_DirtyRect *) SDL_malloc(sizeof(*dirty));
-        if (!dirty) {
-            return;
-        }
-    }
-    dirty->rect = *rect;
-    dirty->next = list->list;
-    list->list = dirty;
-}
-
-void
-SDL_ClearDirtyRects(SDL_DirtyRectList * list)
-{
-    SDL_DirtyRect *prev, *curr;
-
-    /* Skip to the end of the free list */
-    prev = NULL;
-    for (curr = list->free; curr; curr = curr->next) {
-        prev = curr;
-    }
-
-    /* Add the list entries to the end */
-    if (prev) {
-        prev->next = list->list;
-    } else {
-        list->free = list->list;
-    }
-    list->list = NULL;
-}
-
-void
-SDL_FreeDirtyRects(SDL_DirtyRectList * list)
-{
-    while (list->list) {
-        SDL_DirtyRect *elem = list->list;
-        list->list = elem->next;
-        SDL_free(elem);
-    }
-    while (list->free) {
-        SDL_DirtyRect *elem = list->free;
-        list->free = elem->next;
-        SDL_free(elem);
-    }
-}
-
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_rect_c.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-typedef struct SDL_DirtyRect
-{
-    SDL_Rect rect;
-    struct SDL_DirtyRect *next;
-} SDL_DirtyRect;
-
-typedef struct SDL_DirtyRectList
-{
-    SDL_DirtyRect *list;
-    SDL_DirtyRect *free;
-} SDL_DirtyRectList;
-
-extern void SDL_AddDirtyRect(SDL_DirtyRectList * list, const SDL_Rect * rect);
-extern void SDL_ClearDirtyRects(SDL_DirtyRectList * list);
-extern void SDL_FreeDirtyRects(SDL_DirtyRectList * list);
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_gl.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1564 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_OGL
-
-#include "SDL_video.h"
-#include "SDL_opengl.h"
-#include "SDL_sysvideo.h"
-#include "SDL_pixels_c.h"
-#include "SDL_rect_c.h"
-#include "SDL_yuv_sw_c.h"
-
-#ifdef __MACOSX__
-#include <OpenGL/OpenGL.h>
-#endif
-
-
-/* OpenGL renderer implementation */
-
-/* Details on optimizing the texture path on Mac OS X:
-   http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/chapter_10_section_2.html
-*/
-
-/* !!! FIXME: this should go in a higher level than the GL renderer. */
-static __inline__ int
-bytes_per_pixel(const Uint32 format)
-{
-    if (!SDL_ISPIXELFORMAT_FOURCC(format)) {
-        return SDL_BYTESPERPIXEL(format);
-    }
-
-    /* FOURCC format */
-    switch (format) {
-    case SDL_PIXELFORMAT_YV12:
-    case SDL_PIXELFORMAT_IYUV:
-    case SDL_PIXELFORMAT_YUY2:
-    case SDL_PIXELFORMAT_UYVY:
-    case SDL_PIXELFORMAT_YVYU:
-        return 2;
-    default:
-        return 1;               /* shouldn't ever hit this. */
-    }
-}
-
-
-static const float inv255f = 1.0f / 255.0f;
-
-static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags);
-static int GL_ActivateRenderer(SDL_Renderer * renderer);
-static int GL_DisplayModeChanged(SDL_Renderer * renderer);
-static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int GL_QueryTexturePixels(SDL_Renderer * renderer,
-                                 SDL_Texture * texture, void **pixels,
-                                 int *pitch);
-static int GL_SetTexturePalette(SDL_Renderer * renderer,
-                                SDL_Texture * texture,
-                                const SDL_Color * colors, int firstcolor,
-                                int ncolors);
-static int GL_GetTexturePalette(SDL_Renderer * renderer,
-                                SDL_Texture * texture, SDL_Color * colors,
-                                int firstcolor, int ncolors);
-static int GL_SetTextureColorMod(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
-static int GL_SetTextureAlphaMod(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
-static int GL_SetTextureBlendMode(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int GL_SetTextureScaleMode(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                            const SDL_Rect * rect, const void *pixels,
-                            int pitch);
-static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * rect, int markDirty, void **pixels,
-                          int *pitch);
-static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static void GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                            int numrects, const SDL_Rect * rects);
-static int GL_RenderClear(SDL_Renderer * renderer);
-static int GL_RenderDrawPoints(SDL_Renderer * renderer,
-                               const SDL_Point * points, int count);
-static int GL_RenderDrawLines(SDL_Renderer * renderer,
-                              const SDL_Point * points, int count);
-static int GL_RenderDrawRects(SDL_Renderer * renderer,
-                              const SDL_Rect ** rects, int count);
-static int GL_RenderFillRects(SDL_Renderer * renderer,
-                              const SDL_Rect ** rects, int count);
-static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
-static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                               Uint32 pixel_format, void * pixels, int pitch);
-static int GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                Uint32 pixel_format, const void * pixels, int pitch);
-static void GL_RenderPresent(SDL_Renderer * renderer);
-static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static void GL_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver GL_RenderDriver = {
-    GL_CreateRenderer,
-    {
-     "opengl",
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD |
-      SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
-     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
-      SDL_TEXTUREMODULATE_ALPHA),
-     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
-      SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
-     (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW),
-     15,
-     {
-      SDL_PIXELFORMAT_INDEX1LSB,
-      SDL_PIXELFORMAT_INDEX1MSB,
-      SDL_PIXELFORMAT_INDEX8,
-      SDL_PIXELFORMAT_RGB332,
-      SDL_PIXELFORMAT_RGB444,
-      SDL_PIXELFORMAT_RGB555,
-      SDL_PIXELFORMAT_ARGB4444,
-      SDL_PIXELFORMAT_ARGB1555,
-      SDL_PIXELFORMAT_RGB565,
-      SDL_PIXELFORMAT_RGB24,
-      SDL_PIXELFORMAT_BGR24,
-      SDL_PIXELFORMAT_RGB888,
-      SDL_PIXELFORMAT_BGR888,
-      SDL_PIXELFORMAT_ARGB8888,
-      SDL_PIXELFORMAT_ABGR8888,
-      SDL_PIXELFORMAT_ARGB2101010},
-     0,
-     0}
-};
-
-typedef struct
-{
-    SDL_GLContext context;
-    SDL_bool updateSize;
-    SDL_bool GL_ARB_texture_rectangle_supported;
-    SDL_bool GL_EXT_paletted_texture_supported;
-    SDL_bool GL_APPLE_ycbcr_422_supported;
-    SDL_bool GL_MESA_ycbcr_texture_supported;
-    SDL_bool GL_ARB_fragment_program_supported;
-    int blendMode;
-    int scaleMode;
-
-    /* OpenGL functions */
-#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
-#include "SDL_glfuncs.h"
-#undef SDL_PROC
-
-    PFNGLCOLORTABLEEXTPROC glColorTableEXT;
-    void (*glTextureRangeAPPLE) (GLenum target, GLsizei length,
-                                 const GLvoid * pointer);
-
-    PFNGLGETPROGRAMIVARBPROC glGetProgramivARB;
-    PFNGLGETPROGRAMSTRINGARBPROC glGetProgramStringARB;
-    PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB;
-    PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB;
-    PFNGLGENPROGRAMSARBPROC glGenProgramsARB;
-    PFNGLBINDPROGRAMARBPROC glBindProgramARB;
-    PFNGLPROGRAMSTRINGARBPROC glProgramStringARB;
-
-    /* (optional) fragment programs */
-    GLuint fragment_program_mask;
-    GLuint fragment_program_UYVY;
-} GL_RenderData;
-
-typedef struct
-{
-    GLuint texture;
-    GLuint shader;
-    GLenum type;
-    GLfloat texw;
-    GLfloat texh;
-    GLenum format;
-    GLenum formattype;
-    Uint8 *palette;
-    void *pixels;
-    int pitch;
-    SDL_DirtyRectList dirty;
-    int HACK_RYAN_FIXME;
-} GL_TextureData;
-
-
-static void
-GL_SetError(const char *prefix, GLenum result)
-{
-    const char *error;
-
-    switch (result) {
-    case GL_NO_ERROR:
-        error = "GL_NO_ERROR";
-        break;
-    case GL_INVALID_ENUM:
-        error = "GL_INVALID_ENUM";
-        break;
-    case GL_INVALID_VALUE:
-        error = "GL_INVALID_VALUE";
-        break;
-    case GL_INVALID_OPERATION:
-        error = "GL_INVALID_OPERATION";
-        break;
-    case GL_STACK_OVERFLOW:
-        error = "GL_STACK_OVERFLOW";
-        break;
-    case GL_STACK_UNDERFLOW:
-        error = "GL_STACK_UNDERFLOW";
-        break;
-    case GL_OUT_OF_MEMORY:
-        error = "GL_OUT_OF_MEMORY";
-        break;
-    case GL_TABLE_TOO_LARGE:
-        error = "GL_TABLE_TOO_LARGE";
-        break;
-    default:
-        error = "UNKNOWN";
-        break;
-    }
-    SDL_SetError("%s: %s", prefix, error);
-}
-
-static int
-GL_LoadFunctions(GL_RenderData * data)
-{
-#if defined(__QNXNTO__) && (_NTO_VERSION < 630)
-#define __SDL_NOGETPROCADDR__
-#endif
-#ifdef __SDL_NOGETPROCADDR__
-#define SDL_PROC(ret,func,params) data->func=func;
-#else
-#define SDL_PROC(ret,func,params) \
-    do { \
-        data->func = SDL_GL_GetProcAddress(#func); \
-        if ( ! data->func ) { \
-            SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \
-            return -1; \
-        } \
-    } while ( 0 );
-#endif /* __SDL_NOGETPROCADDR__ */
-
-#include "SDL_glfuncs.h"
-#undef SDL_PROC
-    return 0;
-}
-
-SDL_Renderer *
-GL_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_Renderer *renderer;
-    GL_RenderData *data;
-    GLint value;
-    int doublebuffer;
-
-    /* Render directly to the window, unless we're compositing */
-#ifndef __MACOSX__
-    if (flags & SDL_RENDERER_SINGLEBUFFER) {
-        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
-    }
-#endif
-    if (!(window->flags & SDL_WINDOW_OPENGL)) {
-        if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) {
-            return NULL;
-        }
-    }
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (GL_RenderData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        GL_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    renderer->ActivateRenderer = GL_ActivateRenderer;
-    renderer->DisplayModeChanged = GL_DisplayModeChanged;
-    renderer->CreateTexture = GL_CreateTexture;
-    renderer->QueryTexturePixels = GL_QueryTexturePixels;
-    renderer->SetTexturePalette = GL_SetTexturePalette;
-    renderer->GetTexturePalette = GL_GetTexturePalette;
-    renderer->SetTextureColorMod = GL_SetTextureColorMod;
-    renderer->SetTextureAlphaMod = GL_SetTextureAlphaMod;
-    renderer->SetTextureBlendMode = GL_SetTextureBlendMode;
-    renderer->SetTextureScaleMode = GL_SetTextureScaleMode;
-    renderer->UpdateTexture = GL_UpdateTexture;
-    renderer->LockTexture = GL_LockTexture;
-    renderer->UnlockTexture = GL_UnlockTexture;
-    renderer->DirtyTexture = GL_DirtyTexture;
-    renderer->RenderClear = GL_RenderClear;
-    renderer->RenderDrawPoints = GL_RenderDrawPoints;
-    renderer->RenderDrawLines = GL_RenderDrawLines;
-    renderer->RenderDrawRects = GL_RenderDrawRects;
-    renderer->RenderFillRects = GL_RenderFillRects;
-    renderer->RenderCopy = GL_RenderCopy;
-    renderer->RenderReadPixels = GL_RenderReadPixels;
-    renderer->RenderWritePixels = GL_RenderWritePixels;
-    renderer->RenderPresent = GL_RenderPresent;
-    renderer->DestroyTexture = GL_DestroyTexture;
-    renderer->DestroyRenderer = GL_DestroyRenderer;
-    renderer->info = GL_RenderDriver.info;
-    renderer->window = window;
-    renderer->driverdata = data;
-
-    renderer->info.flags =
-        (SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED);
-
-    if (GL_LoadFunctions(data) < 0) {
-        GL_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    data->context = SDL_GL_CreateContext(window);
-    if (!data->context) {
-        GL_DestroyRenderer(renderer);
-        return NULL;
-    }
-    if (SDL_GL_MakeCurrent(window, data->context) < 0) {
-        GL_DestroyRenderer(renderer);
-        return NULL;
-    }
-#ifdef __MACOSX__
-    /* Enable multi-threaded rendering */
-    /* Disabled until Ryan finishes his VBO/PBO code...
-       CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine);
-     */
-#endif
-
-    if (flags & SDL_RENDERER_PRESENTVSYNC) {
-        SDL_GL_SetSwapInterval(1);
-    } else {
-        SDL_GL_SetSwapInterval(0);
-    }
-    if (SDL_GL_GetSwapInterval() > 0) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
-    }
-
-    if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) {
-        if (!doublebuffer) {
-            renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
-        }
-    }
-
-    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
-    renderer->info.max_texture_width = value;
-    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
-    renderer->info.max_texture_height = value;
-
-    if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")
-        || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
-        data->GL_ARB_texture_rectangle_supported = SDL_TRUE;
-    }
-    if (SDL_GL_ExtensionSupported("GL_EXT_paletted_texture")) {
-        data->GL_EXT_paletted_texture_supported = SDL_TRUE;
-        data->glColorTableEXT =
-            (PFNGLCOLORTABLEEXTPROC) SDL_GL_GetProcAddress("glColorTableEXT");
-    } else {
-        /* Don't advertise support for 8-bit indexed texture format */
-        Uint32 i, j;
-        SDL_RendererInfo *info = &renderer->info;
-        for (i = 0, j = 0; i < info->num_texture_formats; ++i) {
-            if (info->texture_formats[i] != SDL_PIXELFORMAT_INDEX8) {
-                info->texture_formats[j++] = info->texture_formats[i];
-            }
-        }
-        --info->num_texture_formats;
-    }
-    if (SDL_GL_ExtensionSupported("GL_APPLE_ycbcr_422")) {
-        data->GL_APPLE_ycbcr_422_supported = SDL_TRUE;
-    }
-    if (SDL_GL_ExtensionSupported("GL_MESA_ycbcr_texture")) {
-        data->GL_MESA_ycbcr_texture_supported = SDL_TRUE;
-    }
-    if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) {
-        data->glTextureRangeAPPLE =
-            (void (*)(GLenum, GLsizei, const GLvoid *))
-            SDL_GL_GetProcAddress("glTextureRangeAPPLE");
-    }
-
-    /* we might use fragment programs for YUV data, etc. */
-    if (SDL_GL_ExtensionSupported("GL_ARB_fragment_program")) {
-        /* !!! FIXME: this doesn't check for errors. */
-        /* !!! FIXME: this should really reuse the glfuncs.h stuff. */
-        data->glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)
-            SDL_GL_GetProcAddress("glGetProgramivARB");
-        data->glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC)
-            SDL_GL_GetProcAddress("glGetProgramStringARB");
-        data->glProgramLocalParameter4fvARB =
-            (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)
-            SDL_GL_GetProcAddress("glProgramLocalParameter4fvARB");
-        data->glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)
-            SDL_GL_GetProcAddress("glDeleteProgramsARB");
-        data->glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)
-            SDL_GL_GetProcAddress("glGenProgramsARB");
-        data->glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)
-            SDL_GL_GetProcAddress("glBindProgramARB");
-        data->glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)
-            SDL_GL_GetProcAddress("glProgramStringARB");
-        data->GL_ARB_fragment_program_supported = SDL_TRUE;
-    }
-
-    /* Set up parameters for rendering */
-    data->blendMode = -1;
-    data->scaleMode = -1;
-    data->glDisable(GL_DEPTH_TEST);
-    data->glDisable(GL_CULL_FACE);
-    /* This ended up causing video discrepancies between OpenGL and Direct3D */
-    /*data->glEnable(GL_LINE_SMOOTH);*/
-    if (data->GL_ARB_texture_rectangle_supported) {
-        data->glEnable(GL_TEXTURE_RECTANGLE_ARB);
-    } else {
-        data->glEnable(GL_TEXTURE_2D);
-    }
-    data->updateSize = SDL_TRUE;
-
-    return renderer;
-}
-
-static int
-GL_ActivateRenderer(SDL_Renderer * renderer)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-
-    if (SDL_GL_MakeCurrent(window, data->context) < 0) {
-        return -1;
-    }
-    if (data->updateSize) {
-        data->glMatrixMode(GL_PROJECTION);
-        data->glLoadIdentity();
-        data->glMatrixMode(GL_MODELVIEW);
-        data->glLoadIdentity();
-        data->glViewport(0, 0, window->w, window->h);
-        data->glOrtho(0.0, (GLdouble) window->w,
-                      (GLdouble) window->h, 0.0, 0.0, 1.0);
-        data->updateSize = SDL_FALSE;
-    }
-    return 0;
-}
-
-static int
-GL_DisplayModeChanged(SDL_Renderer * renderer)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-
-    /* Rebind the context to the window area and update matrices */
-    data->updateSize = SDL_TRUE;
-    return GL_ActivateRenderer(renderer);
-}
-
-static __inline__ int
-power_of_2(int input)
-{
-    int value = 1;
-
-    while (value < input) {
-        value <<= 1;
-    }
-    return value;
-}
-
-
-//#define DEBUG_PROGRAM_COMPILE 1
-
-static void
-set_shader_error(GL_RenderData * data, const char *prefix)
-{
-    GLint pos = 0;
-    const GLubyte *errstr;
-    data->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
-    errstr = data->glGetString(GL_PROGRAM_ERROR_STRING_ARB);
-    SDL_SetError("%s: shader compile error at position %d: %s",
-           prefix, (int) pos, (const char *) errstr);
-}
-
-static GLuint
-compile_shader(GL_RenderData * data, GLenum shader_type, const char *_code)
-{
-    const int have_texture_rects = data->GL_ARB_texture_rectangle_supported;
-    const char *replacement = have_texture_rects ? "RECT" : "2D";
-    const size_t replacementlen = SDL_strlen(replacement);
-    const char *token = "%TEXTURETARGET%";
-    const size_t tokenlen = SDL_strlen(token);
-    char *code = NULL;
-    char *ptr = NULL;
-    GLuint program = 0;
-
-    /*
-     * The TEX instruction needs a different target depending on what we use.
-     *  To handle this, we use "%TEXTURETARGET%" and replace the string before
-     *  compiling the shader.
-     */
-    code = SDL_strdup(_code);
-    if (code == NULL)
-        return 0;
-
-    for (ptr = SDL_strstr(code, token); ptr; ptr = SDL_strstr(ptr + 1, token)) {
-        SDL_memcpy(ptr, replacement, replacementlen);
-        SDL_memmove(ptr + replacementlen, ptr + tokenlen,
-                    SDL_strlen(ptr + tokenlen) + 1);
-    }
-
-#if DEBUG_PROGRAM_COMPILE
-    printf("compiling shader:\n%s\n\n", code);
-#endif
-
-    data->glGetError();         /* flush any existing error state. */
-    data->glGenProgramsARB(1, &program);
-    data->glBindProgramARB(shader_type, program);
-    data->glProgramStringARB(shader_type, GL_PROGRAM_FORMAT_ASCII_ARB,
-                             (GLsizei)SDL_strlen(code), code);
-
-    SDL_free(code);
-
-    if (data->glGetError() == GL_INVALID_OPERATION) {
-#if DEBUG_PROGRAM_COMPILE
-        GLint pos = 0;
-        const GLubyte *errstr;
-        data->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
-        errstr = data->glGetString(GL_PROGRAM_ERROR_STRING_ARB);
-        printf("program compile error at position %d: %s\n\n",
-               (int) pos, (const char *) errstr);
-#endif
-        data->glBindProgramARB(shader_type, 0);
-        data->glDeleteProgramsARB(1, &program);
-        return 0;
-    }
-
-    return program;
-}
-
-
-/*
- * Fragment program that implements mask semantics
- */
-static const char *fragment_program_mask_source_code = "!!ARBfp1.0\n"
-"OUTPUT output = result.color;\n"
-"TEMP value;\n"
-"TEX value, fragment.texcoord[0], texture[0], %TEXTURETARGET%;\n"
-"MUL value, fragment.color, value;\n"
-"SGE value.a, value.a, 0.001;\n"
-"MOV output, value;\n"
-"END";
-
-/*
- * Fragment program that renders from UYVY textures.
- * The UYVY to RGB equasion is:
- *   R = 1.164(Y-16) + 1.596(Cr-128)
- *   G = 1.164(Y-16) - 0.813(Cr-128) - 0.391(Cb-128)
- *   B = 1.164(Y-16) + 2.018(Cb-128)
- * Byte layout is Cb, Y1, Cr, Y2, stored in the R, G, B, A channels.
- * 4 bytes == 2 pixels: Y1/Cb/Cr, Y2/Cb/Cr
- *
- * !!! FIXME: this ignores blendmodes, etc.
- * !!! FIXME: this could be more efficient...use a dot product for green, etc.
- */
-static const char *fragment_program_UYVY_source_code = "!!ARBfp1.0\n"
-    /* outputs... */
-    "OUTPUT outcolor = result.color;\n"
-    /* scratch registers... */
-    "TEMP uyvy;\n" "TEMP luminance;\n" "TEMP work;\n"
-    /* Halve the coordinates to grab the correct 32 bits for the fragment. */
-    "MUL work, fragment.texcoord, { 0.5, 1.0, 1.0, 1.0 };\n"
-    /* Sample the YUV texture. Cb, Y1, Cr, Y2, are stored in x, y, z, w. */
-    "TEX uyvy, work, texture[0], %TEXTURETARGET%;\n"
-    /* Do subtractions (128/255, 16/255, 128/255, 16/255) */
-    "SUB uyvy, uyvy, { 0.501960784313726, 0.06274509803922, 0.501960784313726, 0.06274509803922 };\n"
-    /* Choose the luminance component by texcoord. */
-    /* !!! FIXME: laziness wins out for now... just average Y1 and Y2. */
-    "ADD luminance, uyvy.yyyy, uyvy.wwww;\n"
-    "MUL luminance, luminance, { 0.5, 0.5, 0.5, 0.5 };\n"
-    /* Multiply luminance by its magic value. */
-    "MUL luminance, luminance, { 1.164, 1.164, 1.164, 1.164 };\n"
-    /* uyvy.xyzw becomes Cr/Cr/Cb/Cb, with multiplications. */
-    "MUL uyvy, uyvy.zzxx, { 1.596, -0.813, 2.018, -0.391 };\n"
-    /* Add luminance to Cr and Cb, store to RGB channels. */
-    "ADD work.rgb, luminance, uyvy;\n"
-    /* Do final addition for Green channel.  (!!! FIXME: this should be a DPH?) */
-    "ADD work.g, work.g, uyvy.w;\n"
-    /* Make sure alpha channel is fully opaque.  (!!! FIXME: blend modes!) */
-    "MOV work.a, { 1.0 };\n"
-    /* Store out the final fragment color... */
-    "MOV outcolor, work;\n"
-    /* ...and we're done! */
-    "END\n";
-
-static __inline__ SDL_bool
-convert_format(GL_RenderData *renderdata, Uint32 pixel_format,
-               GLint* internalFormat, GLenum* format, GLenum* type)
-{
-    switch (pixel_format) {
-    case SDL_PIXELFORMAT_INDEX1LSB:
-    case SDL_PIXELFORMAT_INDEX1MSB:
-        *internalFormat = GL_RGB;
-        *format = GL_COLOR_INDEX;
-        *type = GL_BITMAP;
-        break;
-    case SDL_PIXELFORMAT_INDEX8:
-        if (!renderdata->GL_EXT_paletted_texture_supported) {
-            return SDL_FALSE;
-        }
-        *internalFormat = GL_COLOR_INDEX8_EXT;
-        *format = GL_COLOR_INDEX;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_RGB332:
-        *internalFormat = GL_R3_G3_B2;
-        *format = GL_RGB;
-        *type = GL_UNSIGNED_BYTE_3_3_2;
-        break;
-    case SDL_PIXELFORMAT_RGB444:
-        *internalFormat = GL_RGB4;
-        *format = GL_RGB;
-        *type = GL_UNSIGNED_SHORT_4_4_4_4;
-        break;
-    case SDL_PIXELFORMAT_RGB555:
-        *internalFormat = GL_RGB5;
-        *format = GL_RGB;
-        *type = GL_UNSIGNED_SHORT_5_5_5_1;
-        break;
-    case SDL_PIXELFORMAT_ARGB4444:
-        *internalFormat = GL_RGBA4;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
-        break;
-    case SDL_PIXELFORMAT_ARGB1555:
-        *internalFormat = GL_RGB5_A1;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
-        break;
-    case SDL_PIXELFORMAT_RGB565:
-        *internalFormat = GL_RGB8;
-        *format = GL_RGB;
-        *type = GL_UNSIGNED_SHORT_5_6_5;
-        break;
-    case SDL_PIXELFORMAT_RGB24:
-        *internalFormat = GL_RGB8;
-        *format = GL_RGB;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_RGB888:
-        *internalFormat = GL_RGB8;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_BGR24:
-        *internalFormat = GL_RGB8;
-        *format = GL_BGR;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_BGR888:
-        *internalFormat = GL_RGB8;
-        *format = GL_RGBA;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_ARGB8888:
-#ifdef __MACOSX__
-        *internalFormat = GL_RGBA;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_INT_8_8_8_8_REV;
-#else
-        *internalFormat = GL_RGBA8;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_BYTE;
-#endif
-        break;
-    case SDL_PIXELFORMAT_ABGR8888:
-        *internalFormat = GL_RGBA8;
-        *format = GL_RGBA;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_ARGB2101010:
-        *internalFormat = GL_RGB10_A2;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_INT_2_10_10_10_REV;
-        break;
-    case SDL_PIXELFORMAT_UYVY:
-        if (renderdata->GL_APPLE_ycbcr_422_supported) {
-            *internalFormat = GL_RGB;
-            *format = GL_YCBCR_422_APPLE;
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-            *type = GL_UNSIGNED_SHORT_8_8_APPLE;
-#else
-            *type = GL_UNSIGNED_SHORT_8_8_REV_APPLE;
-#endif
-        } else if (renderdata->GL_MESA_ycbcr_texture_supported) {
-            *internalFormat = GL_YCBCR_MESA;
-            *format = GL_YCBCR_MESA;
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-            *type = GL_UNSIGNED_SHORT_8_8_MESA;
-#else
-            *type = GL_UNSIGNED_SHORT_8_8_REV_MESA;
-#endif
-        } else if (renderdata->GL_ARB_fragment_program_supported) {
-            *internalFormat = GL_RGBA;
-            *format = GL_RGBA;
-            *type = GL_UNSIGNED_BYTE;
-        } else {
-            return SDL_FALSE;
-        }
-        break;
-    case SDL_PIXELFORMAT_YUY2:
-        if (renderdata->GL_APPLE_ycbcr_422_supported) {
-            *internalFormat = GL_RGB;
-            *format = GL_YCBCR_422_APPLE;
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-            *type = GL_UNSIGNED_SHORT_8_8_REV_APPLE;
-#else
-            *type = GL_UNSIGNED_SHORT_8_8_APPLE;
-#endif
-        } else if (renderdata->GL_MESA_ycbcr_texture_supported) {
-            *internalFormat = GL_YCBCR_MESA;
-            *format = GL_YCBCR_MESA;
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-            *type = GL_UNSIGNED_SHORT_8_8_REV_MESA;
-#else
-            *type = GL_UNSIGNED_SHORT_8_8_MESA;
-#endif
-        } else {
-            return SDL_FALSE;
-        }
-        break;
-    default:
-        return SDL_FALSE;
-    }
-    return SDL_TRUE;
-}
-
-static int
-GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
-    GL_TextureData *data;
-    GLint internalFormat;
-    GLenum format, type;
-    int texture_w, texture_h;
-    GLuint shader = 0;
-    GLenum result;
-
-    if (!convert_format(renderdata, texture->format, &internalFormat,
-                        &format, &type)) {
-        SDL_SetError("Texture format %s not supported by OpenGL",
-                     SDL_GetPixelFormatName(texture->format));
-        return -1;
-    }
-    if (texture->format == SDL_PIXELFORMAT_UYVY &&
-        !renderdata->GL_APPLE_ycbcr_422_supported &&
-        !renderdata->GL_MESA_ycbcr_texture_supported &&
-        renderdata->GL_ARB_fragment_program_supported) {
-        if (renderdata->fragment_program_UYVY == 0) {
-            renderdata->fragment_program_UYVY =
-                compile_shader(renderdata, GL_FRAGMENT_PROGRAM_ARB,
-                               fragment_program_UYVY_source_code);
-            if (renderdata->fragment_program_UYVY == 0) {
-                set_shader_error(renderdata, "UYVY");
-                return -1;
-            }
-        }
-        shader = renderdata->fragment_program_UYVY;
-    }
-
-    data = (GL_TextureData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    data->shader = shader;
-
-    if (texture->format == SDL_PIXELFORMAT_INDEX8) {
-        data->palette = (Uint8 *) SDL_malloc(3 * 256 * sizeof(Uint8));
-        if (!data->palette) {
-            SDL_OutOfMemory();
-            SDL_free(data);
-            return -1;
-        }
-        SDL_memset(data->palette, 0xFF, 3 * 256 * sizeof(Uint8));
-    }
-
-    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
-        data->pitch = texture->w * bytes_per_pixel(texture->format);
-        data->pixels = SDL_malloc(texture->h * data->pitch);
-        if (!data->pixels) {
-            SDL_OutOfMemory();
-            SDL_free(data);
-            return -1;
-        }
-    }
-
-    texture->driverdata = data;
-
-    renderdata->glGetError();
-    renderdata->glGenTextures(1, &data->texture);
-    if (renderdata->GL_ARB_texture_rectangle_supported) {
-        data->type = GL_TEXTURE_RECTANGLE_ARB;
-        texture_w = texture->w;
-        texture_h = texture->h;
-        data->texw = (GLfloat) texture_w;
-        data->texh = (GLfloat) texture_h;
-    } else {
-        data->type = GL_TEXTURE_2D;
-        texture_w = power_of_2(texture->w);
-        texture_h = power_of_2(texture->h);
-        data->texw = (GLfloat) (texture->w) / texture_w;
-        data->texh = (GLfloat) texture->h / texture_h;
-    }
-
-    /* YUV formats use RGBA but are really two bytes per pixel */
-    if (internalFormat == GL_RGBA && bytes_per_pixel(texture->format) < 4) {
-        texture_w /= 2;
-        if (data->type == GL_TEXTURE_2D) {
-            data->texw *= 2.0f;
-        }
-        data->HACK_RYAN_FIXME = 2;
-    } else {
-        data->HACK_RYAN_FIXME = 1;
-    }
-
-    data->format = format;
-    data->formattype = type;
-    renderdata->glEnable(data->type);
-    renderdata->glBindTexture(data->type, data->texture);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
-                                GL_NEAREST);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
-                                GL_NEAREST);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
-                                GL_CLAMP_TO_EDGE);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
-                                GL_CLAMP_TO_EDGE);
-#ifdef __MACOSX__
-#ifndef GL_TEXTURE_STORAGE_HINT_APPLE
-#define GL_TEXTURE_STORAGE_HINT_APPLE       0x85BC
-#endif
-#ifndef STORAGE_CACHED_APPLE
-#define STORAGE_CACHED_APPLE                0x85BE
-#endif
-#ifndef STORAGE_SHARED_APPLE
-#define STORAGE_SHARED_APPLE                0x85BF
-#endif
-    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
-        renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
-                                    GL_STORAGE_SHARED_APPLE);
-    } else {
-        renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
-                                    GL_STORAGE_CACHED_APPLE);
-    }
-/* This causes a crash in testoverlay for some reason.  Apple bug? */
-#if 0
-    if (texture->access == SDL_TEXTUREACCESS_STREAMING
-        && texture->format == SDL_PIXELFORMAT_ARGB8888) {
-        /*
-           if (renderdata->glTextureRangeAPPLE) {
-           renderdata->glTextureRangeAPPLE(data->type,
-           texture->h * data->pitch,
-           data->pixels);
-           }
-         */
-        renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
-        renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
-                                 texture_h, 0, format, type, data->pixels);
-    } else
-#endif
-#endif
-    {
-        renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
-                                 texture_h, 0, format, type, NULL);
-    }
-    renderdata->glDisable(data->type);
-    result = renderdata->glGetError();
-    if (result != GL_NO_ERROR) {
-        GL_SetError("glTexImage2D()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GL_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                      void **pixels, int *pitch)
-{
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-
-    *pixels = data->pixels;
-    *pitch = data->pitch;
-    return 0;
-}
-
-static int
-GL_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                     const SDL_Color * colors, int firstcolor, int ncolors)
-{
-    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-    Uint8 *palette;
-
-    if (!data->palette) {
-        SDL_SetError("Texture doesn't have a palette");
-        return -1;
-    }
-    palette = data->palette + firstcolor * 3;
-    while (ncolors--) {
-        *palette++ = colors->r;
-        *palette++ = colors->g;
-        *palette++ = colors->b;
-        ++colors;
-    }
-    renderdata->glEnable(data->type);
-    renderdata->glBindTexture(data->type, data->texture);
-    renderdata->glColorTableEXT(data->type, GL_RGB8, 256, GL_RGB,
-                                GL_UNSIGNED_BYTE, data->palette);
-    return 0;
-}
-
-static int
-GL_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                     SDL_Color * colors, int firstcolor, int ncolors)
-{
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-    Uint8 *palette;
-
-    if (!data->palette) {
-        SDL_SetError("Texture doesn't have a palette");
-        return -1;
-    }
-    palette = data->palette + firstcolor * 3;
-    while (ncolors--) {
-        colors->r = *palette++;
-        colors->g = *palette++;
-        colors->b = *palette++;
-        colors->unused = SDL_ALPHA_OPAQUE;
-        ++colors;
-    }
-    return 0;
-}
-
-static void
-SetupTextureUpdate(GL_RenderData * renderdata, SDL_Texture * texture,
-                   int pitch)
-{
-    if (texture->format == SDL_PIXELFORMAT_INDEX1LSB) {
-        renderdata->glPixelStorei(GL_UNPACK_LSB_FIRST, 1);
-    } else if (texture->format == SDL_PIXELFORMAT_INDEX1MSB) {
-        renderdata->glPixelStorei(GL_UNPACK_LSB_FIRST, 0);
-    }
-    renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH,
-                              (pitch / bytes_per_pixel(texture->format)) /
-                              ((GL_TextureData *) texture->driverdata)->
-                              HACK_RYAN_FIXME);
-}
-
-static int
-GL_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    return 0;
-}
-
-static int
-GL_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    return 0;
-}
-
-static int
-GL_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    switch (texture->blendMode) {
-    case SDL_BLENDMODE_NONE:
-    case SDL_BLENDMODE_MASK:
-    case SDL_BLENDMODE_BLEND:
-    case SDL_BLENDMODE_ADD:
-    case SDL_BLENDMODE_MOD:
-        return 0;
-    default:
-        SDL_Unsupported();
-        texture->blendMode = SDL_BLENDMODE_NONE;
-        return -1;
-    }
-}
-
-static int
-GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    switch (texture->scaleMode) {
-    case SDL_SCALEMODE_NONE:
-    case SDL_SCALEMODE_FAST:
-    case SDL_SCALEMODE_SLOW:
-        return 0;
-    case SDL_SCALEMODE_BEST:
-        SDL_Unsupported();
-        texture->scaleMode = SDL_SCALEMODE_SLOW;
-        return -1;
-    default:
-        SDL_Unsupported();
-        texture->scaleMode = SDL_SCALEMODE_NONE;
-        return -1;
-    }
-}
-
-static int
-GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                 const SDL_Rect * rect, const void *pixels, int pitch)
-{
-    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-    GLenum result;
-
-    renderdata->glGetError();
-    SetupTextureUpdate(renderdata, texture, pitch);
-    renderdata->glEnable(data->type);
-    renderdata->glBindTexture(data->type, data->texture);
-    renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
-                                rect->h, data->format, data->formattype,
-                                pixels);
-    renderdata->glDisable(data->type);
-    result = renderdata->glGetError();
-    if (result != GL_NO_ERROR) {
-        GL_SetError("glTexSubImage2D()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-               const SDL_Rect * rect, int markDirty, void **pixels,
-               int *pitch)
-{
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-
-    if (markDirty) {
-        SDL_AddDirtyRect(&data->dirty, rect);
-    }
-
-    *pixels =
-        (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
-                  rect->x * bytes_per_pixel(texture->format));
-    *pitch = data->pitch;
-    return 0;
-}
-
-static void
-GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-}
-
-static void
-GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
-                const SDL_Rect * rects)
-{
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-    int i;
-
-    for (i = 0; i < numrects; ++i) {
-        SDL_AddDirtyRect(&data->dirty, &rects[i]);
-    }
-}
-
-static void
-GL_SetBlendMode(GL_RenderData * data, int blendMode, int isprimitive)
-{
-    if (blendMode != data->blendMode) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_NONE:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-            data->glDisable(GL_BLEND);
-            break;
-        case SDL_BLENDMODE_MASK:
-            if (isprimitive) {
-                /* The same as SDL_BLENDMODE_NONE */
-                blendMode = SDL_BLENDMODE_NONE;
-                data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-                data->glDisable(GL_BLEND);
-            } else {
-                data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-                data->glEnable(GL_BLEND);
-                data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-            }
-            break;
-        case SDL_BLENDMODE_BLEND:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-            data->glEnable(GL_BLEND);
-            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-            break;
-        case SDL_BLENDMODE_ADD:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-            data->glEnable(GL_BLEND);
-            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-            break;
-        case SDL_BLENDMODE_MOD:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-            data->glEnable(GL_BLEND);
-            data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
-            break;
-        }
-        data->blendMode = blendMode;
-    }
-}
-
-static int
-GL_RenderClear(SDL_Renderer * renderer)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-
-    data->glClearColor((GLfloat) renderer->r * inv255f,
-                       (GLfloat) renderer->g * inv255f,
-                       (GLfloat) renderer->b * inv255f,
-                       (GLfloat) renderer->a * inv255f);
-
-    data->glClear(GL_COLOR_BUFFER_BIT);
-
-    return 0;
-}
-
-static int
-GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
-                    int count)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    int i;
-
-    GL_SetBlendMode(data, renderer->blendMode, 1);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    data->glBegin(GL_POINTS);
-    for (i = 0; i < count; ++i) {
-        data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
-    }
-    data->glEnd();
-
-    return 0;
-}
-
-static int
-GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
-                   int count)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    int i;
-
-    GL_SetBlendMode(data, renderer->blendMode, 1);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    if (count > 2 && 
-        points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
-        data->glBegin(GL_LINE_LOOP);
-        /* GL_LINE_LOOP takes care of the final segment */
-        --count;
-        for (i = 0; i < count; ++i) {
-            data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
-        }
-        data->glEnd();
-    } else {
-#if defined(__APPLE__) || defined(__WIN32__)
-#else
-        int x1, y1, x2, y2;
-#endif
-
-        data->glBegin(GL_LINE_STRIP);
-        for (i = 0; i < count; ++i) {
-            data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
-        }
-        data->glEnd();
-
-        /* The line is half open, so we need one more point to complete it.
-         * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html
-         * If we have to, we can use vertical line and horizontal line textures
-         * for vertical and horizontal lines, and then create custom textures
-         * for diagonal lines and software render those.  It's terrible, but at
-         * least it would be pixel perfect.
-         */
-        data->glBegin(GL_POINTS);
-#if defined(__APPLE__) || defined(__WIN32__)
-        /* Mac OS X and Windows seem to always leave the second point open */
-        data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y);
-#else
-        /* Linux seems to leave the right-most or bottom-most point open */
-        x1 = points[0].x;
-        y1 = points[0].y;
-        x2 = points[count-1].x;
-        y2 = points[count-1].y;
-
-        if (x1 > x2) {
-            data->glVertex2f(0.5f + x1, 0.5f + y1);
-        } else if (x2 > x1) {
-            data->glVertex2f(0.5f + x2, 0.5f + y2);
-        } else if (y1 > y2) {
-            data->glVertex2f(0.5f + x1, 0.5f + y1);
-        } else if (y2 > y1) {
-            data->glVertex2f(0.5f + x2, 0.5f + y2);
-        }
-#endif
-        data->glEnd();
-    }
-
-    return 0;
-}
-
-static int
-GL_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    int i, x, y;
-
-    GL_SetBlendMode(data, renderer->blendMode, 1);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    data->glBegin(GL_LINE_LOOP);
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect *rect = rects[i];
-
-        x = rect->x;
-        y = rect->y;
-        data->glVertex2f(0.5f + x, 0.5f + y);
-
-        x = rect->x+rect->w-1;
-        y = rect->y;
-        data->glVertex2f(0.5f + x, 0.5f + y);
-
-        x = rect->x+rect->w-1;
-        y = rect->y+rect->h-1;
-        data->glVertex2f(0.5f + x, 0.5f + y);
-
-        x = rect->x;
-        y = rect->y+rect->h-1;
-        data->glVertex2f(0.5f + x, 0.5f + y);
-    }
-    data->glEnd();
-
-    return 0;
-}
-
-static int
-GL_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    int i;
-
-    GL_SetBlendMode(data, renderer->blendMode, 1);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect *rect = rects[i];
-
-        data->glRecti(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
-    }
-
-    return 0;
-}
-
-static int
-GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
-    GLuint shader = 0;
-    int minx, miny, maxx, maxy;
-    GLfloat minu, maxu, minv, maxv;
-
-    if (texturedata->dirty.list) {
-        SDL_DirtyRect *dirty;
-        void *pixels;
-        int bpp = bytes_per_pixel(texture->format);
-        int pitch = texturedata->pitch;
-
-        SetupTextureUpdate(data, texture, pitch);
-        data->glEnable(texturedata->type);
-        data->glBindTexture(texturedata->type, texturedata->texture);
-        for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
-            SDL_Rect *rect = &dirty->rect;
-            pixels =
-                (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch +
-                          rect->x * bpp);
-            data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
-                                  rect->w / texturedata->HACK_RYAN_FIXME,
-                                  rect->h, texturedata->format,
-                                  texturedata->formattype, pixels);
-        }
-        SDL_ClearDirtyRects(&texturedata->dirty);
-    }
-
-    minx = dstrect->x;
-    miny = dstrect->y;
-    maxx = dstrect->x + dstrect->w;
-    maxy = dstrect->y + dstrect->h;
-
-    minu = (GLfloat) srcrect->x / texture->w;
-    minu *= texturedata->texw;
-    maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
-    maxu *= texturedata->texw;
-    minv = (GLfloat) srcrect->y / texture->h;
-    minv *= texturedata->texh;
-    maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
-    maxv *= texturedata->texh;
-
-    data->glEnable(texturedata->type);
-    data->glBindTexture(texturedata->type, texturedata->texture);
-
-    if (texture->modMode) {
-        data->glColor4f((GLfloat) texture->r * inv255f,
-                        (GLfloat) texture->g * inv255f,
-                        (GLfloat) texture->b * inv255f,
-                        (GLfloat) texture->a * inv255f);
-    } else {
-        data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-    }
-
-    GL_SetBlendMode(data, texture->blendMode, 0);
-
-    /* Set up the shader for the copy, we have a special one for MASK */
-    shader = texturedata->shader;
-    if (texture->blendMode == SDL_BLENDMODE_MASK && !shader) {
-        if (data->fragment_program_mask == 0) {
-            data->fragment_program_mask =
-                compile_shader(data, GL_FRAGMENT_PROGRAM_ARB,
-                               fragment_program_mask_source_code);
-            if (data->fragment_program_mask == 0) {
-                /* That's okay, we'll just miss some of the blend semantics */
-                data->fragment_program_mask = ~0;
-            }
-        }
-        if (data->fragment_program_mask != ~0) {
-            shader = data->fragment_program_mask;
-        }
-    }
-
-    if (texture->scaleMode != data->scaleMode) {
-        switch (texture->scaleMode) {
-        case SDL_SCALEMODE_NONE:
-        case SDL_SCALEMODE_FAST:
-            data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
-                                  GL_NEAREST);
-            data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
-                                  GL_NEAREST);
-            break;
-        case SDL_SCALEMODE_SLOW:
-        case SDL_SCALEMODE_BEST:
-            data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
-                                  GL_LINEAR);
-            data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
-                                  GL_LINEAR);
-            break;
-        }
-        data->scaleMode = texture->scaleMode;
-    }
-
-    if (shader) {
-        data->glEnable(GL_FRAGMENT_PROGRAM_ARB);
-        data->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader);
-    }
-
-    data->glBegin(GL_TRIANGLE_STRIP);
-    data->glTexCoord2f(minu, minv);
-    data->glVertex2f((GLfloat) minx, (GLfloat) miny);
-    data->glTexCoord2f(maxu, minv);
-    data->glVertex2f((GLfloat) maxx, (GLfloat) miny);
-    data->glTexCoord2f(minu, maxv);
-    data->glVertex2f((GLfloat) minx, (GLfloat) maxy);
-    data->glTexCoord2f(maxu, maxv);
-    data->glVertex2f((GLfloat) maxx, (GLfloat) maxy);
-    data->glEnd();
-
-    if (shader) {
-        data->glDisable(GL_FRAGMENT_PROGRAM_ARB);
-    }
-
-    data->glDisable(texturedata->type);
-
-    return 0;
-}
-
-static int
-GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                    Uint32 pixel_format, void * pixels, int pitch)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    GLint internalFormat;
-    GLenum format, type;
-    Uint8 *src, *dst, *tmp;
-    int length, rows;
-
-    if (!convert_format(data, pixel_format, &internalFormat, &format, &type)) {
-        /* FIXME: Do a temp copy to a format that is supported */
-        SDL_SetError("Unsupported pixel format");
-        return -1;
-    }
-
-    if (pixel_format == SDL_PIXELFORMAT_INDEX1LSB) {
-        data->glPixelStorei(GL_PACK_LSB_FIRST, 1);
-    } else if (pixel_format == SDL_PIXELFORMAT_INDEX1MSB) {
-        data->glPixelStorei(GL_PACK_LSB_FIRST, 0);
-    }
-    data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
-    data->glPixelStorei(GL_PACK_ROW_LENGTH,
-                        (pitch / bytes_per_pixel(pixel_format)));
-
-    data->glReadPixels(rect->x, (window->h-rect->y)-rect->h, rect->w, rect->h,
-                       format, type, pixels);
-
-    /* Flip the rows to be top-down */
-    length = rect->w * bytes_per_pixel(pixel_format);
-    src = (Uint8*)pixels + (rect->h-1)*pitch;
-    dst = (Uint8*)pixels;
-    tmp = SDL_stack_alloc(Uint8, length);
-    rows = rect->h / 2;
-    while (rows--) {
-        SDL_memcpy(tmp, dst, length);
-        SDL_memcpy(dst, src, length);
-        SDL_memcpy(src, tmp, length);
-        dst += pitch;
-        src -= pitch;
-    }
-    SDL_stack_free(tmp);
-
-    return 0;
-}
-
-static int
-GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                     Uint32 pixel_format, const void * pixels, int pitch)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    GLint internalFormat;
-    GLenum format, type;
-    Uint8 *src, *dst, *tmp;
-    int length, rows;
-
-    if (!convert_format(data, pixel_format, &internalFormat, &format, &type)) {
-        /* FIXME: Do a temp copy to a format that is supported */
-        SDL_SetError("Unsupported pixel format");
-        return -1;
-    }
-
-    if (pixel_format == SDL_PIXELFORMAT_INDEX1LSB) {
-        data->glPixelStorei(GL_UNPACK_LSB_FIRST, 1);
-    } else if (pixel_format == SDL_PIXELFORMAT_INDEX1MSB) {
-        data->glPixelStorei(GL_UNPACK_LSB_FIRST, 0);
-    }
-    data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    data->glPixelStorei(GL_UNPACK_ROW_LENGTH,
-                        (pitch / bytes_per_pixel(pixel_format)));
-
-    /* Flip the rows to be bottom-up */
-    length = rect->h * rect->w * pitch;
-    tmp = SDL_stack_alloc(Uint8, length);
-    src = (Uint8*)pixels + (rect->h-1)*pitch;
-    dst = (Uint8*)tmp;
-    rows = rect->h;
-    while (rows--) {
-        SDL_memcpy(dst, src, pitch);
-        dst += pitch;
-        src -= pitch;
-    }
-
-    data->glRasterPos2i(rect->x, (window->h-rect->y));
-    data->glDrawPixels(rect->w, rect->h, format, type, tmp);
-    SDL_stack_free(tmp);
-
-    return 0;
-}
-
-static void
-GL_RenderPresent(SDL_Renderer * renderer)
-{
-    SDL_GL_SwapWindow(renderer->window);
-}
-
-static void
-GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-
-    if (!data) {
-        return;
-    }
-    if (data->texture) {
-        renderdata->glDeleteTextures(1, &data->texture);
-    }
-    if (data->palette) {
-        SDL_free(data->palette);
-    }
-    if (data->pixels) {
-        SDL_free(data->pixels);
-    }
-    SDL_FreeDirtyRects(&data->dirty);
-    SDL_free(data);
-    texture->driverdata = NULL;
-}
-
-static void
-GL_DestroyRenderer(SDL_Renderer * renderer)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-
-    if (data) {
-        if (data->context) {
-            if (data->GL_ARB_fragment_program_supported) {
-                data->glDisable(GL_FRAGMENT_PROGRAM_ARB);
-                data->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
-                if (data->fragment_program_mask &&
-                    data->fragment_program_mask != ~0) {
-                    data->glDeleteProgramsARB(1,
-                                              &data->fragment_program_mask);
-                }
-                if (data->fragment_program_UYVY &&
-                    data->fragment_program_UYVY != ~0) {
-                    data->glDeleteProgramsARB(1,
-                                              &data->fragment_program_UYVY);
-                }
-            }
-
-            /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */
-            SDL_GL_DeleteContext(data->context);
-        }
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-#endif /* SDL_VIDEO_RENDER_OGL */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_gl.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* OpenGL renderer implementation */
-
-extern SDL_RenderDriver GL_RenderDriver;
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_gles.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,998 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_OGL_ES
-
-#include "SDL_video.h"
-#include "SDL_opengles.h"
-#include "SDL_sysvideo.h"
-#include "SDL_pixels_c.h"
-#include "SDL_rect_c.h"
-#include "SDL_yuv_sw_c.h"
-
-#if defined(__QNXNTO__)
-/* Include QNX system header to check QNX version later */
-#include <sys/neutrino.h>
-#endif /* __QNXNTO__ */
-
-#if defined(SDL_VIDEO_DRIVER_QNXGF)  ||  \
-    defined(SDL_VIDEO_DRIVER_PHOTON) ||  \
-    defined(SDL_VIDEO_DRIVER_PANDORA)
-
-/* Empty function stub to get OpenGL ES 1.x support without  */
-/* OpenGL ES extension GL_OES_draw_texture supported         */
-GL_API void GL_APIENTRY
-glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
-{
-    return;
-}
-
-#endif /* QNXGF || PHOTON || PANDORA */
-
-/* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */
-
-static const float inv255f = 1.0f / 255.0f;
-
-static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags);
-static int GLES_ActivateRenderer(SDL_Renderer * renderer);
-static int GLES_DisplayModeChanged(SDL_Renderer * renderer);
-static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int GLES_QueryTexturePixels(SDL_Renderer * renderer,
-                                   SDL_Texture * texture, void **pixels,
-                                   int *pitch);
-static int GLES_SetTexturePalette(SDL_Renderer * renderer,
-                                  SDL_Texture * texture,
-                                  const SDL_Color * colors, int firstcolor,
-                                  int ncolors);
-static int GLES_GetTexturePalette(SDL_Renderer * renderer,
-                                  SDL_Texture * texture, SDL_Color * colors,
-                                  int firstcolor, int ncolors);
-static int GLES_SetTextureColorMod(SDL_Renderer * renderer,
-                                   SDL_Texture * texture);
-static int GLES_SetTextureAlphaMod(SDL_Renderer * renderer,
-                                   SDL_Texture * texture);
-static int GLES_SetTextureBlendMode(SDL_Renderer * renderer,
-                                    SDL_Texture * texture);
-static int GLES_SetTextureScaleMode(SDL_Renderer * renderer,
-                                    SDL_Texture * texture);
-static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                              const SDL_Rect * rect, const void *pixels,
-                              int pitch);
-static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                            const SDL_Rect * rect, int markDirty,
-                            void **pixels, int *pitch);
-static void GLES_UnlockTexture(SDL_Renderer * renderer,
-                               SDL_Texture * texture);
-static void GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                              int numrects, const SDL_Rect * rects);
-static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
-                                 const SDL_Point * points, int count);
-static int GLES_RenderDrawLines(SDL_Renderer * renderer,
-                                const SDL_Point * points, int count);
-static int GLES_RenderDrawRects(SDL_Renderer * renderer,
-                                const SDL_Rect ** rects, int count);
-static int GLES_RenderFillRects(SDL_Renderer * renderer,
-                                const SDL_Rect ** rects, int count);
-static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                           const SDL_Rect * srcrect,
-                           const SDL_Rect * dstrect);
-static void GLES_RenderPresent(SDL_Renderer * renderer);
-static void GLES_DestroyTexture(SDL_Renderer * renderer,
-                                SDL_Texture * texture);
-static void GLES_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver GL_ES_RenderDriver = {
-    GLES_CreateRenderer,
-    {
-     "opengl_es",
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD |
-      SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
-     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
-      SDL_TEXTUREMODULATE_ALPHA),
-     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
-      SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
-     (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW), 6,
-     {
-      /* OpenGL ES 1.x supported formats list */
-      SDL_PIXELFORMAT_RGBA4444,
-      SDL_PIXELFORMAT_RGBA5551,
-      SDL_PIXELFORMAT_RGB565,
-      SDL_PIXELFORMAT_RGB24,
-      SDL_PIXELFORMAT_BGR888,
-      SDL_PIXELFORMAT_ABGR8888},
-     0,
-     0}
-};
-
-typedef struct
-{
-    SDL_GLContext context;
-    SDL_bool updateSize;
-    int blendMode;
-
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-
-    SDL_bool useDrawTexture;
-    SDL_bool GL_OES_draw_texture_supported;
-
-    /* OpenGL ES functions */
-#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
-#include "SDL_glesfuncs.h"
-#undef SDL_PROC
-
-} GLES_RenderData;
-
-typedef struct
-{
-    GLuint texture;
-    GLenum type;
-    GLfloat texw;
-    GLfloat texh;
-    GLenum format;
-    GLenum formattype;
-    void *pixels;
-    int pitch;
-    SDL_DirtyRectList dirty;
-} GLES_TextureData;
-
-static void
-GLES_SetError(const char *prefix, GLenum result)
-{
-    const char *error;
-
-    switch (result) {
-    case GL_NO_ERROR:
-        error = "GL_NO_ERROR";
-        break;
-    case GL_INVALID_ENUM:
-        error = "GL_INVALID_ENUM";
-        break;
-    case GL_INVALID_VALUE:
-        error = "GL_INVALID_VALUE";
-        break;
-    case GL_INVALID_OPERATION:
-        error = "GL_INVALID_OPERATION";
-        break;
-    case GL_STACK_OVERFLOW:
-        error = "GL_STACK_OVERFLOW";
-        break;
-    case GL_STACK_UNDERFLOW:
-        error = "GL_STACK_UNDERFLOW";
-        break;
-    case GL_OUT_OF_MEMORY:
-        error = "GL_OUT_OF_MEMORY";
-        break;
-    default:
-        error = "UNKNOWN";
-        break;
-    }
-    SDL_SetError("%s: %s", prefix, error);
-}
-
-static int
-GLES_LoadFunctions(GLES_RenderData * data)
-{
-
-#define SDL_PROC(ret,func,params) \
-    data->func = func;
-#include "SDL_glesfuncs.h"
-#undef SDL_PROC
-
-    return 0;
-}
-
-SDL_Renderer *
-GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-
-    SDL_Renderer *renderer;
-    GLES_RenderData *data;
-    GLint value;
-    int doublebuffer;
-
-    if (!(window->flags & SDL_WINDOW_OPENGL)) {
-        if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) {
-            return NULL;
-        }
-    }
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        GLES_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    renderer->ActivateRenderer = GLES_ActivateRenderer;
-    renderer->DisplayModeChanged = GLES_DisplayModeChanged;
-    renderer->CreateTexture = GLES_CreateTexture;
-    renderer->QueryTexturePixels = GLES_QueryTexturePixels;
-    renderer->SetTexturePalette = GLES_SetTexturePalette;
-    renderer->GetTexturePalette = GLES_GetTexturePalette;
-    renderer->SetTextureColorMod = GLES_SetTextureColorMod;
-    renderer->SetTextureAlphaMod = GLES_SetTextureAlphaMod;
-    renderer->SetTextureBlendMode = GLES_SetTextureBlendMode;
-    renderer->SetTextureScaleMode = GLES_SetTextureScaleMode;
-    renderer->UpdateTexture = GLES_UpdateTexture;
-    renderer->LockTexture = GLES_LockTexture;
-    renderer->UnlockTexture = GLES_UnlockTexture;
-    renderer->DirtyTexture = GLES_DirtyTexture;
-    renderer->RenderDrawPoints = GLES_RenderDrawPoints;
-    renderer->RenderDrawLines = GLES_RenderDrawLines;
-    renderer->RenderDrawRects = GLES_RenderDrawRects;
-    renderer->RenderFillRects = GLES_RenderFillRects;
-    renderer->RenderCopy = GLES_RenderCopy;
-    renderer->RenderPresent = GLES_RenderPresent;
-    renderer->DestroyTexture = GLES_DestroyTexture;
-    renderer->DestroyRenderer = GLES_DestroyRenderer;
-    renderer->info = GL_ES_RenderDriver.info;
-    renderer->window = window;
-    renderer->driverdata = data;
-
-    renderer->info.flags =
-        (SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED);
-
-#if defined(__QNXNTO__)
-#if _NTO_VERSION<=641
-    /* QNX's OpenGL ES implementation is broken regarding             */
-    /* packed textures support, affected versions 6.3.2, 6.4.0, 6.4.1 */
-    renderer->info.num_texture_formats = 2;
-    renderer->info.texture_formats[0] = SDL_PIXELFORMAT_ABGR8888;
-    renderer->info.texture_formats[1] = SDL_PIXELFORMAT_BGR24;
-#endif /* _NTO_VERSION */
-#endif /* __QNXNTO__ */
-
-    if (GLES_LoadFunctions(data) < 0) {
-        GLES_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    data->context = SDL_GL_CreateContext(window);
-    if (!data->context) {
-        GLES_DestroyRenderer(renderer);
-        return NULL;
-    }
-    if (SDL_GL_MakeCurrent(window, data->context) < 0) {
-        GLES_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    if (flags & SDL_RENDERER_PRESENTVSYNC) {
-        SDL_GL_SetSwapInterval(1);
-    } else {
-        SDL_GL_SetSwapInterval(0);
-    }
-    if (SDL_GL_GetSwapInterval() > 0) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
-    }
-
-    if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) {
-        if (!doublebuffer) {
-            renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
-        }
-    }
-#if SDL_VIDEO_DRIVER_PANDORA
-    data->GL_OES_draw_texture_supported = SDL_FALSE;
-    data->useDrawTexture = SDL_FALSE;
-#else
-    if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) {
-        data->GL_OES_draw_texture_supported = SDL_TRUE;
-        data->useDrawTexture = SDL_TRUE;
-    } else {
-        data->GL_OES_draw_texture_supported = SDL_FALSE;
-        data->useDrawTexture = SDL_FALSE;
-    }
-#endif
-
-    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
-    renderer->info.max_texture_width = value;
-    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
-    renderer->info.max_texture_height = value;
-
-    /* Set up parameters for rendering */
-    data->blendMode = -1;
-    data->glDisable(GL_DEPTH_TEST);
-    data->glDisable(GL_CULL_FACE);
-    data->updateSize = SDL_TRUE;
-
-    data->glEnableClientState(GL_VERTEX_ARRAY);
-    data->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-    
-    return renderer;
-}
-
-static int
-GLES_ActivateRenderer(SDL_Renderer * renderer)
-{
-
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-
-    if (SDL_GL_MakeCurrent(window, data->context) < 0) {
-        return -1;
-    }
-    if (data->updateSize) {
-        data->glMatrixMode(GL_PROJECTION);
-        data->glLoadIdentity();
-        data->glMatrixMode(GL_MODELVIEW);
-        data->glLoadIdentity();
-        data->glViewport(0, 0, window->w, window->h);
-        data->glOrthof(0.0, (GLfloat) window->w, (GLfloat) window->h, 0.0,
-                       0.0, 1.0);
-        data->updateSize = SDL_FALSE;
-    }
-    return 0;
-}
-
-static int
-GLES_DisplayModeChanged(SDL_Renderer * renderer)
-{
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-
-    data->updateSize = SDL_TRUE;
-    return 0;
-}
-
-static __inline__ int
-power_of_2(int input)
-{
-    int value = 1;
-
-    while (value < input) {
-        value <<= 1;
-    }
-    return value;
-}
-
-static int
-GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
-    GLES_TextureData *data;
-    GLint internalFormat;
-    GLenum format, type;
-    int texture_w, texture_h;
-    GLenum result;
-
-    switch (texture->format) {
-    case SDL_PIXELFORMAT_RGB24:
-        internalFormat = GL_RGB;
-        format = GL_RGB;
-        type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_BGR888:
-    case SDL_PIXELFORMAT_ABGR8888:
-        internalFormat = GL_RGBA;
-        format = GL_RGBA;
-        type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_RGB565:
-        internalFormat = GL_RGB;
-        format = GL_RGB;
-        type = GL_UNSIGNED_SHORT_5_6_5;
-        break;
-    case SDL_PIXELFORMAT_RGBA5551:
-        internalFormat = GL_RGBA;
-        format = GL_RGBA;
-        type = GL_UNSIGNED_SHORT_5_5_5_1;
-        break;
-    case SDL_PIXELFORMAT_RGBA4444:
-        internalFormat = GL_RGBA;
-        format = GL_RGBA;
-        type = GL_UNSIGNED_SHORT_4_4_4_4;
-        break;
-    default:
-        SDL_SetError("Texture format %s not supported by OpenGL ES",
-                     SDL_GetPixelFormatName(texture->format));
-        return -1;
-    }
-
-    data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
-        data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
-        data->pixels = SDL_malloc(texture->h * data->pitch);
-        if (!data->pixels) {
-            SDL_OutOfMemory();
-            SDL_free(data);
-            return -1;
-        }
-    }
-
-    texture->driverdata = data;
-
-    renderdata->glGetError();
-    renderdata->glEnable(GL_TEXTURE_2D);
-    renderdata->glGenTextures(1, &data->texture);
-
-    data->type = GL_TEXTURE_2D;
-    /* no NPOV textures allowed in OpenGL ES (yet) */
-    texture_w = power_of_2(texture->w);
-    texture_h = power_of_2(texture->h);
-    data->texw = (GLfloat) texture->w / texture_w;
-    data->texh = (GLfloat) texture->h / texture_h;
-
-    data->format = format;
-    data->formattype = type;
-    renderdata->glBindTexture(data->type, data->texture);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
-                                GL_NEAREST);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
-                                GL_NEAREST);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
-                                GL_CLAMP_TO_EDGE);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
-                                GL_CLAMP_TO_EDGE);
-
-    renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
-                             texture_h, 0, format, type, NULL);
-    renderdata->glDisable(GL_TEXTURE_2D);
-
-    result = renderdata->glGetError();
-    if (result != GL_NO_ERROR) {
-        GLES_SetError("glTexImage2D()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GLES_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                        void **pixels, int *pitch)
-{
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-
-    *pixels = data->pixels;
-    *pitch = data->pitch;
-    return 0;
-}
-
-static int
-GLES_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                       const SDL_Color * colors, int firstcolor, int ncolors)
-{
-    SDL_SetError("OpenGL ES does not support paletted textures");
-    return -1;
-}
-
-static int
-GLES_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                       SDL_Color * colors, int firstcolor, int ncolors)
-{
-    SDL_SetError("OpenGL ES does not support paletted textures");
-    return -1;
-}
-
-static void
-SetupTextureUpdate(GLES_RenderData * renderdata, SDL_Texture * texture,
-                   int pitch)
-{
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-    renderdata->glBindTexture(data->type, data->texture);
-    renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-}
-
-static int
-GLES_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    return 0;
-}
-
-static int
-GLES_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    return 0;
-}
-
-static int
-GLES_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    switch (texture->blendMode) {
-    case SDL_BLENDMODE_NONE:
-    case SDL_BLENDMODE_MASK:
-    case SDL_BLENDMODE_BLEND:
-    case SDL_BLENDMODE_ADD:
-    case SDL_BLENDMODE_MOD:
-        return 0;
-    default:
-        SDL_Unsupported();
-        texture->blendMode = SDL_BLENDMODE_NONE;
-        return -1;
-    }
-}
-
-static int
-GLES_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    switch (texture->scaleMode) {
-    case SDL_SCALEMODE_NONE:
-    case SDL_SCALEMODE_FAST:
-    case SDL_SCALEMODE_SLOW:
-        return 0;
-    case SDL_SCALEMODE_BEST:
-        SDL_Unsupported();
-        texture->scaleMode = SDL_SCALEMODE_SLOW;
-        return -1;
-    default:
-        SDL_Unsupported();
-        texture->scaleMode = SDL_SCALEMODE_NONE;
-        return -1;
-    }
-}
-
-static int
-GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                   const SDL_Rect * rect, const void *pixels, int pitch)
-{
-    GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-    GLenum result;
-    int bpp = SDL_BYTESPERPIXEL(texture->format);
-    void * temp_buffer;
-    void * temp_ptr;
-    int i;
-
-    renderdata->glGetError();
-    renderdata->glEnable(data->type);
-    SetupTextureUpdate(renderdata, texture, pitch);
-
-    if( rect->w * bpp == pitch ) {
-         temp_buffer = (void *)pixels; /* No need to reformat */
-    } else {
-         /* Reformatting of mem area required */
-         temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
-         temp_ptr = temp_buffer;
-         for (i = 0; i < rect->h; i++) {
-             SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
-             temp_ptr += rect->w * bpp;
-             pixels += pitch;
-         }
-    }
-
-    renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
-                                rect->h, data->format, data->formattype,
-                                temp_buffer);
-
-    if( temp_buffer != pixels ) {
-        SDL_free(temp_buffer);
-    }
-
-    renderdata->glDisable(data->type);
-    result = renderdata->glGetError();
-    if (result != GL_NO_ERROR) {
-        GLES_SetError("glTexSubImage2D()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                 const SDL_Rect * rect, int markDirty, void **pixels,
-                 int *pitch)
-{
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-
-    if (markDirty) {
-        SDL_AddDirtyRect(&data->dirty, rect);
-    }
-
-    *pixels =
-        (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
-                  rect->x * SDL_BYTESPERPIXEL(texture->format));
-    *pitch = data->pitch;
-    return 0;
-}
-
-static void
-GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-}
-
-static void
-GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                  int numrects, const SDL_Rect * rects)
-{
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-    int i;
-
-    for (i = 0; i < numrects; ++i) {
-        SDL_AddDirtyRect(&data->dirty, &rects[i]);
-    }
-}
-
-static void
-GLES_SetBlendMode(GLES_RenderData * data, int blendMode, int isprimitive)
-{
-    if (blendMode != data->blendMode) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_NONE:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-            data->glDisable(GL_BLEND);
-            break;
-        case SDL_BLENDMODE_MASK:
-            if (isprimitive) {
-                data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-                data->glDisable(GL_BLEND);
-                /* The same as SDL_BLENDMODE_NONE */
-                blendMode = SDL_BLENDMODE_NONE;
-                break;
-            }
-            /* fall through */
-        case SDL_BLENDMODE_BLEND:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-            data->glEnable(GL_BLEND);
-            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-            break;
-        case SDL_BLENDMODE_ADD:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-            data->glEnable(GL_BLEND);
-            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-            break;
-        case SDL_BLENDMODE_MOD:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-            data->glEnable(GL_BLEND);
-            data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
-            break;
-        }
-        data->blendMode = blendMode;
-    }
-}
-
-static int
-GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
-                      int count)
-{
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    int i;
-    GLshort *vertices;
-
-    GLES_SetBlendMode(data, renderer->blendMode, 1);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    vertices = SDL_stack_alloc(GLshort, count*2);
-    for (i = 0; i < count; ++i) {
-        vertices[2*i+0] = (GLshort)points[i].x;
-        vertices[2*i+1] = (GLshort)points[i].y;
-    }
-    data->glVertexPointer(2, GL_SHORT, 0, vertices);
-    data->glDrawArrays(GL_POINTS, 0, count);
-    SDL_stack_free(vertices);
-
-    return 0;
-}
-
-static int
-GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
-                     int count)
-{
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    int i;
-    GLshort *vertices;
-
-    GLES_SetBlendMode(data, renderer->blendMode, 1);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    vertices = SDL_stack_alloc(GLshort, count*2);
-    for (i = 0; i < count; ++i) {
-        vertices[2*i+0] = (GLshort)points[i].x;
-        vertices[2*i+1] = (GLshort)points[i].y;
-    }
-    data->glVertexPointer(2, GL_SHORT, 0, vertices);
-    if (count > 2 && 
-        points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
-        /* GL_LINE_LOOP takes care of the final segment */
-        --count;
-        data->glDrawArrays(GL_LINE_LOOP, 0, count);
-    } else {
-        data->glDrawArrays(GL_LINE_STRIP, 0, count);
-    }
-    SDL_stack_free(vertices);
-
-    return 0;
-}
-
-static int
-GLES_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                     int count)
-{
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    int i;
-
-    GLES_SetBlendMode(data, renderer->blendMode, 1);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect *rect = rects[i];
-        GLshort minx = rect->x;
-        GLshort maxx = rect->x + rect->w;
-        GLshort miny = rect->y;
-        GLshort maxy = rect->y + rect->h;
-        GLshort vertices[8];
-        vertices[0] = minx;
-        vertices[1] = miny;
-        vertices[2] = maxx;
-        vertices[3] = miny;
-        vertices[4] = minx;
-        vertices[5] = maxy;
-        vertices[6] = maxx;
-        vertices[7] = maxy;
-
-        data->glVertexPointer(2, GL_SHORT, 0, vertices);
-        data->glDrawArrays(GL_LINE_LOOP, 0, 4);
-    }
-
-    return 0;
-}
-
-static int
-GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                     int count)
-{
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    int i;
-
-    GLES_SetBlendMode(data, renderer->blendMode, 1);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect *rect = rects[i];
-        GLshort minx = rect->x;
-        GLshort maxx = rect->x + rect->w;
-        GLshort miny = rect->y;
-        GLshort maxy = rect->y + rect->h;
-        GLshort vertices[8];
-        vertices[0] = minx;
-        vertices[1] = miny;
-        vertices[2] = maxx;
-        vertices[3] = miny;
-        vertices[4] = minx;
-        vertices[5] = maxy;
-        vertices[6] = maxx;
-        vertices[7] = maxy;
-
-        data->glVertexPointer(2, GL_SHORT, 0, vertices);
-        data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-    }
-
-    return 0;
-}
-
-static int
-GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
-    int minx, miny, maxx, maxy;
-    GLfloat minu, maxu, minv, maxv;
-    int i;
-    void *temp_buffer;          /* used for reformatting dirty rect pixels */
-    void *temp_ptr;
-
-    data->glEnable(GL_TEXTURE_2D);
-
-    if (texturedata->dirty.list) {
-        SDL_DirtyRect *dirty;
-        void *pixels;
-        int bpp = SDL_BYTESPERPIXEL(texture->format);
-        int pitch = texturedata->pitch;
-
-        SetupTextureUpdate(data, texture, pitch);
-
-        data->glBindTexture(texturedata->type, texturedata->texture);
-        for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
-            SDL_Rect *rect = &dirty->rect;
-            pixels =
-                (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch +
-                          rect->x * bpp);
-            /*      There is no GL_UNPACK_ROW_LENGTH in OpenGLES 
-               we must do this reformatting ourselves(!)
-
-               maybe it'd be a good idea to keep a temp buffer around
-               for this purpose rather than allocating it each time
-             */
-            if( rect->x == 0 && rect->w * bpp == pitch ) {
-                temp_buffer = pixels; /* Updating whole texture, no need to reformat */
-            } else {
-                temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
-                temp_ptr = temp_buffer;
-                for (i = 0; i < rect->h; i++) {
-                    SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
-                    temp_ptr += rect->w * bpp;
-                    pixels += pitch;
-                }
-            }
-
-            data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
-                                  rect->w, rect->h, texturedata->format,
-                                  texturedata->formattype, temp_buffer);
-
-            if( temp_buffer != pixels ) {
-                SDL_free(temp_buffer);
-            }
-        }
-        SDL_ClearDirtyRects(&texturedata->dirty);
-    }
-
-    data->glBindTexture(texturedata->type, texturedata->texture);
-
-    if (texture->modMode) {
-        data->glColor4f((GLfloat) texture->r * inv255f,
-                        (GLfloat) texture->g * inv255f,
-                        (GLfloat) texture->b * inv255f,
-                        (GLfloat) texture->a * inv255f);
-    } else {
-        data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-    }
-
-    GLES_SetBlendMode(data, texture->blendMode, 0);
-
-    switch (texture->scaleMode) {
-    case SDL_SCALEMODE_NONE:
-    case SDL_SCALEMODE_FAST:
-        data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
-                              GL_NEAREST);
-        data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
-                              GL_NEAREST);
-        break;
-    case SDL_SCALEMODE_SLOW:
-    case SDL_SCALEMODE_BEST:
-        data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
-                              GL_LINEAR);
-        data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
-                              GL_LINEAR);
-        break;
-    }
-
-    if (data->GL_OES_draw_texture_supported && data->useDrawTexture) {
-        /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */
-        SDL_Window *window = renderer->window;
-        GLint cropRect[4];
-        cropRect[0] = srcrect->x;
-        cropRect[1] = srcrect->y + srcrect->h;
-        cropRect[2] = srcrect->w;
-        cropRect[3] = -srcrect->h;
-        data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
-                               cropRect);
-        data->glDrawTexiOES(dstrect->x, window->h - dstrect->y - dstrect->h,
-                            0, dstrect->w, dstrect->h);
-    } else {
-
-        minx = dstrect->x;
-        miny = dstrect->y;
-        maxx = dstrect->x + dstrect->w;
-        maxy = dstrect->y + dstrect->h;
-
-        minu = (GLfloat) srcrect->x / texture->w;
-        minu *= texturedata->texw;
-        maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
-        maxu *= texturedata->texw;
-        minv = (GLfloat) srcrect->y / texture->h;
-        minv *= texturedata->texh;
-        maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
-        maxv *= texturedata->texh;
-
-        GLshort vertices[8];
-        GLfloat texCoords[8];
-
-        vertices[0] = minx;
-        vertices[1] = miny;
-        vertices[2] = maxx;
-        vertices[3] = miny;
-        vertices[4] = minx;
-        vertices[5] = maxy;
-        vertices[6] = maxx;
-        vertices[7] = maxy;
-
-        texCoords[0] = minu;
-        texCoords[1] = minv;
-        texCoords[2] = maxu;
-        texCoords[3] = minv;
-        texCoords[4] = minu;
-        texCoords[5] = maxv;
-        texCoords[6] = maxu;
-        texCoords[7] = maxv;
-
-        data->glVertexPointer(2, GL_SHORT, 0, vertices);
-        data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
-        data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-    }
-
-    data->glDisable(GL_TEXTURE_2D);
-
-    return 0;
-}
-
-static void
-GLES_RenderPresent(SDL_Renderer * renderer)
-{
-    SDL_GL_SwapWindow(renderer->window);
-}
-
-static void
-GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-
-    if (!data) {
-        return;
-    }
-    if (data->texture) {
-        glDeleteTextures(1, &data->texture);
-    }
-    if (data->pixels) {
-        SDL_free(data->pixels);
-    }
-    SDL_FreeDirtyRects(&data->dirty);
-    SDL_free(data);
-    texture->driverdata = NULL;
-}
-
-static void
-GLES_DestroyRenderer(SDL_Renderer * renderer)
-{
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-
-    if (data) {
-        if (data->context) {
-            SDL_GL_DeleteContext(data->context);
-        }
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-#endif /* SDL_VIDEO_RENDER_OGL_ES */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_gles.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* OpenGL renderer implementation */
-
-extern SDL_RenderDriver GL_ES_RenderDriver;
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_sw.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,958 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_video.h"
-#include "SDL_sysvideo.h"
-#include "SDL_pixels_c.h"
-#include "SDL_rect_c.h"
-#include "SDL_yuv_sw_c.h"
-#include "SDL_renderer_sw.h"
-
-
-/* SDL surface based renderer implementation */
-
-static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags);
-static int SW_ActivateRenderer(SDL_Renderer * renderer);
-static int SW_DisplayModeChanged(SDL_Renderer * renderer);
-static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int SW_QueryTexturePixels(SDL_Renderer * renderer,
-                                 SDL_Texture * texture, void **pixels,
-                                 int *pitch);
-static int SW_SetTexturePalette(SDL_Renderer * renderer,
-                                SDL_Texture * texture,
-                                const SDL_Color * colors, int firstcolor,
-                                int ncolors);
-static int SW_GetTexturePalette(SDL_Renderer * renderer,
-                                SDL_Texture * texture, SDL_Color * colors,
-                                int firstcolor, int ncolors);
-static int SW_SetTextureColorMod(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
-static int SW_SetTextureAlphaMod(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
-static int SW_SetTextureBlendMode(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int SW_SetTextureScaleMode(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                            const SDL_Rect * rect, const void *pixels,
-                            int pitch);
-static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * rect, int markDirty, void **pixels,
-                          int *pitch);
-static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int SW_RenderDrawPoints(SDL_Renderer * renderer,
-                               const SDL_Point * points, int count);
-static int SW_RenderDrawLines(SDL_Renderer * renderer,
-                              const SDL_Point * points, int count);
-static int SW_RenderDrawRects(SDL_Renderer * renderer,
-                              const SDL_Rect ** rects, int count);
-static int SW_RenderFillRects(SDL_Renderer * renderer,
-                              const SDL_Rect ** rects, int count);
-static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
-static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                               Uint32 format, void * pixels, int pitch);
-static int SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                Uint32 format, const void * pixels, int pitch);
-static void SW_RenderPresent(SDL_Renderer * renderer);
-static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static void SW_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver SW_RenderDriver = {
-    SW_CreateRenderer,
-    {
-     "software",
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
-      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
-      SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC),
-     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
-      SDL_TEXTUREMODULATE_ALPHA),
-     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
-      SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
-     (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST),
-     14,
-     {
-      SDL_PIXELFORMAT_INDEX8,
-      SDL_PIXELFORMAT_RGB555,
-      SDL_PIXELFORMAT_RGB565,
-      SDL_PIXELFORMAT_RGB888,
-      SDL_PIXELFORMAT_BGR888,
-      SDL_PIXELFORMAT_ARGB8888,
-      SDL_PIXELFORMAT_RGBA8888,
-      SDL_PIXELFORMAT_ABGR8888,
-      SDL_PIXELFORMAT_BGRA8888,
-      SDL_PIXELFORMAT_YV12,
-      SDL_PIXELFORMAT_IYUV,
-      SDL_PIXELFORMAT_YUY2,
-      SDL_PIXELFORMAT_UYVY,
-      SDL_PIXELFORMAT_YVYU},
-     0,
-     0}
-};
-
-typedef struct
-{
-    Uint32 format;
-    SDL_bool updateSize;
-    int current_texture;
-    SDL_Texture *texture[3];
-    SDL_Surface surface;
-    SDL_Renderer *renderer;
-    SDL_DirtyRectList dirty;
-} SW_RenderData;
-
-static SDL_Texture *
-CreateTexture(SDL_Renderer * renderer, Uint32 format, int w, int h)
-{
-    SDL_Texture *texture;
-
-    texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
-    if (!texture) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    texture->format = format;
-    texture->access = SDL_TEXTUREACCESS_STREAMING;
-    texture->w = w;
-    texture->h = h;
-    texture->renderer = renderer;
-
-    if (renderer->CreateTexture(renderer, texture) < 0) {
-        SDL_free(texture);
-        return NULL;
-    }
-    return texture;
-}
-
-static void
-DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    renderer->DestroyTexture(renderer, texture);
-    SDL_free(texture);
-}
-
-static int
-DisplayPaletteChanged(void *userdata, SDL_Palette * palette)
-{
-    SW_RenderData *data = (SW_RenderData *) userdata;
-    int i;
-
-    for (i = 0; i < SDL_arraysize(data->texture); ++i) {
-        if (data->texture[i] && data->renderer->SetTexturePalette) {
-            data->renderer->SetTexturePalette(data->renderer,
-                                              data->texture[i],
-                                              palette->colors, 0,
-                                              palette->ncolors);
-        }
-    }
-    return 0;
-}
-
-void
-Setup_SoftwareRenderer(SDL_Renderer * renderer)
-{
-    renderer->CreateTexture = SW_CreateTexture;
-    renderer->QueryTexturePixels = SW_QueryTexturePixels;
-    renderer->SetTexturePalette = SW_SetTexturePalette;
-    renderer->GetTexturePalette = SW_GetTexturePalette;
-    renderer->SetTextureColorMod = SW_SetTextureColorMod;
-    renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod;
-    renderer->SetTextureBlendMode = SW_SetTextureBlendMode;
-    renderer->SetTextureScaleMode = SW_SetTextureScaleMode;
-    renderer->UpdateTexture = SW_UpdateTexture;
-    renderer->LockTexture = SW_LockTexture;
-    renderer->UnlockTexture = SW_UnlockTexture;
-    renderer->DestroyTexture = SW_DestroyTexture;
-
-    renderer->info.mod_modes = SW_RenderDriver.info.mod_modes;
-    renderer->info.blend_modes = SW_RenderDriver.info.blend_modes;
-    renderer->info.scale_modes = SW_RenderDriver.info.scale_modes;
-    renderer->info.num_texture_formats =
-        SW_RenderDriver.info.num_texture_formats;
-    SDL_memcpy(renderer->info.texture_formats,
-               SW_RenderDriver.info.texture_formats,
-               sizeof(renderer->info.texture_formats));;
-    renderer->info.max_texture_width = SW_RenderDriver.info.max_texture_width;
-    renderer->info.max_texture_height =
-        SW_RenderDriver.info.max_texture_height;
-}
-
-SDL_Renderer *
-SW_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_VideoDisplay *display = window->display;
-    SDL_DisplayMode *displayMode = &display->current_mode;
-    SDL_Renderer *renderer;
-    SW_RenderData *data;
-    int i, n;
-    int bpp;
-    Uint32 Rmask, Gmask, Bmask, Amask;
-    Uint32 renderer_flags;
-    const char *desired_driver;
-
-    if (!SDL_PixelFormatEnumToMasks
-        (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-        SDL_SetError("Unknown display format");
-        return NULL;
-    }
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        SW_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-    renderer->ActivateRenderer = SW_ActivateRenderer;
-    renderer->DisplayModeChanged = SW_DisplayModeChanged;
-
-    renderer->RenderDrawPoints = SW_RenderDrawPoints;
-    renderer->RenderDrawLines = SW_RenderDrawLines;
-    renderer->RenderDrawRects = SW_RenderDrawRects;
-    renderer->RenderFillRects = SW_RenderFillRects;
-    renderer->RenderCopy = SW_RenderCopy;
-    renderer->RenderReadPixels = SW_RenderReadPixels;
-    renderer->RenderWritePixels = SW_RenderWritePixels;
-    renderer->RenderPresent = SW_RenderPresent;
-    renderer->DestroyRenderer = SW_DestroyRenderer;
-    renderer->info.name = SW_RenderDriver.info.name;
-    renderer->info.flags = 0;
-    renderer->window = window;
-    renderer->driverdata = data;
-    Setup_SoftwareRenderer(renderer);
-
-    if (flags & SDL_RENDERER_PRESENTFLIP2) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
-        n = 2;
-    } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
-        n = 3;
-    } else {
-        renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
-        n = 1;
-    }
-    data->format = displayMode->format;
-
-    /* Find a render driver that we can use to display data */
-    renderer_flags = (SDL_RENDERER_SINGLEBUFFER |
-                      SDL_RENDERER_PRESENTDISCARD);
-    if (flags & SDL_RENDERER_PRESENTVSYNC) {
-        renderer_flags |= SDL_RENDERER_PRESENTVSYNC;
-    }
-    desired_driver = SDL_getenv("SDL_VIDEO_RENDERER_SWDRIVER");
-    for (i = 0; i < display->num_render_drivers; ++i) {
-        SDL_RenderDriver *driver = &display->render_drivers[i];
-        if (driver->info.name == SW_RenderDriver.info.name) {
-            continue;
-        }
-        if (desired_driver
-            && SDL_strcasecmp(desired_driver, driver->info.name) != 0) {
-            continue;
-        }
-        data->renderer = driver->CreateRenderer(window, renderer_flags);
-        if (data->renderer) {
-            break;
-        }
-    }
-    if (i == display->num_render_drivers) {
-        SW_DestroyRenderer(renderer);
-        SDL_SetError("Couldn't find display render driver");
-        return NULL;
-    }
-    if (data->renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
-    }
-
-    /* Create the textures we'll use for display */
-    for (i = 0; i < n; ++i) {
-        data->texture[i] =
-            CreateTexture(data->renderer, data->format, window->w, window->h);
-        if (!data->texture[i]) {
-            SW_DestroyRenderer(renderer);
-            return NULL;
-        }
-    }
-    data->current_texture = 0;
-
-    /* Create a surface we'll use for rendering */
-    data->surface.flags = SDL_PREALLOC;
-    data->surface.format = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
-    if (!data->surface.format) {
-        SW_DestroyRenderer(renderer);
-        return NULL;
-    }
-    SDL_SetSurfacePalette(&data->surface, display->palette);
-
-    /* Set up a palette watch on the display palette */
-    if (display->palette) {
-        SDL_AddPaletteWatch(display->palette, DisplayPaletteChanged, data);
-    }
-
-    return renderer;
-}
-
-static int
-SW_ActivateRenderer(SDL_Renderer * renderer)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    int i, n;
-
-    if (data->renderer && data->renderer->ActivateRenderer) {
-        if (data->renderer->ActivateRenderer(data->renderer) < 0) {
-            return -1;
-        }
-    }
-    if (data->updateSize) {
-        /* Recreate the textures for the new window size */
-        if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
-            n = 2;
-        } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
-            n = 3;
-        } else {
-            n = 1;
-        }
-        for (i = 0; i < n; ++i) {
-            if (data->texture[i]) {
-                DestroyTexture(data->renderer, data->texture[i]);
-                data->texture[i] = 0;
-            }
-        }
-        for (i = 0; i < n; ++i) {
-            data->texture[i] =
-                CreateTexture(data->renderer, data->format, window->w,
-                              window->h);
-            if (!data->texture[i]) {
-                return -1;
-            }
-        }
-        data->updateSize = SDL_FALSE;
-    }
-    return 0;
-}
-
-static int
-SW_DisplayModeChanged(SDL_Renderer * renderer)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-
-    if (data->renderer && data->renderer->DisplayModeChanged) {
-        if (data->renderer->DisplayModeChanged(data->renderer) < 0) {
-            return -1;
-        }
-    }
-    /* Rebind the context to the window area */
-    data->updateSize = SDL_TRUE;
-    return SW_ActivateRenderer(renderer);
-}
-
-static int
-SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        texture->driverdata =
-            SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
-    } else {
-        int bpp;
-        Uint32 Rmask, Gmask, Bmask, Amask;
-
-        if (!SDL_PixelFormatEnumToMasks
-            (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-            SDL_SetError("Unknown texture format");
-            return -1;
-        }
-
-        texture->driverdata =
-            SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask,
-                                 Bmask, Amask);
-        SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g,
-                               texture->b);
-        SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a);
-        SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
-        SDL_SetSurfaceScaleMode(texture->driverdata, texture->scaleMode);
-
-        if (texture->access == SDL_TEXTUREACCESS_STATIC) {
-            SDL_SetSurfaceRLE(texture->driverdata, 1);
-        }
-    }
-
-    if (!texture->driverdata) {
-        return -1;
-    }
-    return 0;
-}
-
-static int
-SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                      void **pixels, int *pitch)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        return SDL_SW_QueryYUVTexturePixels((SDL_SW_YUVTexture *)
-                                            texture->driverdata, pixels,
-                                            pitch);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-
-        *pixels = surface->pixels;
-        *pitch = surface->pitch;
-        return 0;
-    }
-}
-
-static int
-SW_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                     const SDL_Color * colors, int firstcolor, int ncolors)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        SDL_SetError("YUV textures don't have a palette");
-        return -1;
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-
-        return SDL_SetPaletteColors(surface->format->palette, colors,
-                                    firstcolor, ncolors);
-    }
-}
-
-static int
-SW_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                     SDL_Color * colors, int firstcolor, int ncolors)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        SDL_SetError("YUV textures don't have a palette");
-        return -1;
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-
-        SDL_memcpy(colors, &surface->format->palette->colors[firstcolor],
-                   ncolors * sizeof(*colors));
-        return 0;
-    }
-}
-
-static int
-SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-    return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
-                                  texture->b);
-}
-
-static int
-SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-    return SDL_SetSurfaceAlphaMod(surface, texture->a);
-}
-
-static int
-SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-    return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
-}
-
-static int
-SW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-    return SDL_SetSurfaceScaleMode(surface, texture->scaleMode);
-}
-
-static int
-SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                 const SDL_Rect * rect, const void *pixels, int pitch)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        return SDL_SW_UpdateYUVTexture((SDL_SW_YUVTexture *)
-                                       texture->driverdata, rect, pixels,
-                                       pitch);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-        Uint8 *src, *dst;
-        int row;
-        size_t length;
-
-        src = (Uint8 *) pixels;
-        dst =
-            (Uint8 *) surface->pixels + rect->y * surface->pitch +
-            rect->x * surface->format->BytesPerPixel;
-        length = rect->w * surface->format->BytesPerPixel;
-        for (row = 0; row < rect->h; ++row) {
-            SDL_memcpy(dst, src, length);
-            src += pitch;
-            dst += surface->pitch;
-        }
-        return 0;
-    }
-}
-
-static int
-SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-               const SDL_Rect * rect, int markDirty, void **pixels,
-               int *pitch)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        return SDL_SW_LockYUVTexture((SDL_SW_YUVTexture *)
-                                     texture->driverdata, rect, markDirty,
-                                     pixels, pitch);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-
-        *pixels =
-            (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
-                      rect->x * surface->format->BytesPerPixel);
-        *pitch = surface->pitch;
-        return 0;
-    }
-}
-
-static void
-SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        SDL_SW_UnlockYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
-    }
-}
-
-static int
-SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
-                    int count)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Texture *texture = data->texture[data->current_texture];
-    SDL_Rect rect;
-    int i;
-    int x, y;
-    int status = 0;
-
-    /* Get the smallest rectangle that contains everything */
-    rect.x = 0;
-    rect.y = 0;
-    rect.w = texture->w;
-    rect.h = texture->h;
-    if (!SDL_EnclosePoints(points, count, &rect, &rect)) {
-        /* Nothing to draw */
-        return 0;
-    }
-
-    if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
-        SDL_AddDirtyRect(&data->dirty, &rect);
-    }
-
-    if (data->renderer->LockTexture(data->renderer, texture, &rect, 1,
-                                    &data->surface.pixels,
-                                    &data->surface.pitch) < 0) {
-        return -1;
-    }
-
-    data->surface.clip_rect.w = data->surface.w = rect.w;
-    data->surface.clip_rect.h = data->surface.h = rect.h;
-
-    /* Draw the points! */
-    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
-        renderer->blendMode == SDL_BLENDMODE_MASK) {
-        Uint32 color = SDL_MapRGBA(data->surface.format,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-
-        for (i = 0; i < count; ++i) {
-            x = points[i].x - rect.x;
-            y = points[i].y - rect.y;
-
-            status = SDL_DrawPoint(&data->surface, x, y, color);
-        }
-    } else {
-        for (i = 0; i < count; ++i) {
-            x = points[i].x - rect.x;
-            y = points[i].y - rect.y;
-
-            status = SDL_BlendPoint(&data->surface, x, y,
-                                    renderer->blendMode,
-                                    renderer->r, renderer->g, renderer->b,
-                                    renderer->a);
-        }
-    }
-
-    data->renderer->UnlockTexture(data->renderer, texture);
-
-    return status;
-}
-
-static int
-SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
-                   int count)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Texture *texture = data->texture[data->current_texture];
-    SDL_Rect clip, rect;
-    int i;
-    int x1, y1, x2, y2;
-    int status = 0;
-
-    /* Get the smallest rectangle that contains everything */
-    clip.x = 0;
-    clip.y = 0;
-    clip.w = texture->w;
-    clip.h = texture->h;
-    SDL_EnclosePoints(points, count, NULL, &rect);
-    if (!SDL_IntersectRect(&rect, &clip, &rect)) {
-        /* Nothing to draw */
-        return 0;
-    }
-
-    if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
-        SDL_AddDirtyRect(&data->dirty, &rect);
-    }
-
-    if (data->renderer->LockTexture(data->renderer, texture, &rect, 1,
-                                    &data->surface.pixels,
-                                    &data->surface.pitch) < 0) {
-        return -1;
-    }
-
-    data->surface.clip_rect.w = data->surface.w = rect.w;
-    data->surface.clip_rect.h = data->surface.h = rect.h;
-
-    /* Draw the points! */
-    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
-        renderer->blendMode == SDL_BLENDMODE_MASK) {
-        Uint32 color = SDL_MapRGBA(data->surface.format,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-
-        for (i = 1; i < count; ++i) {
-            x1 = points[i-1].x - rect.x;
-            y1 = points[i-1].y - rect.y;
-            x2 = points[i].x - rect.x;
-            y2 = points[i].y - rect.y;
-
-            status = SDL_DrawLine(&data->surface, x1, y1, x2, y2, color);
-        }
-    } else {
-        for (i = 1; i < count; ++i) {
-            x1 = points[i-1].x - rect.x;
-            y1 = points[i-1].y - rect.y;
-            x2 = points[i].x - rect.x;
-            y2 = points[i].y - rect.y;
-
-            status = SDL_BlendLine(&data->surface, x1, y1, x2, y2,
-                                   renderer->blendMode,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-        }
-    }
-
-    data->renderer->UnlockTexture(data->renderer, texture);
-
-    return status;
-}
-
-static int
-SW_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                   int count)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Texture *texture = data->texture[data->current_texture];
-    SDL_Rect clip, rect;
-    Uint32 color = 0;
-    int i;
-    int status = 0;
-
-    clip.x = 0;
-    clip.y = 0;
-    clip.w = texture->w;
-    clip.h = texture->h;
-
-    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
-        renderer->blendMode == SDL_BLENDMODE_MASK) {
-        color = SDL_MapRGBA(data->surface.format,
-                            renderer->r, renderer->g, renderer->b,
-                            renderer->a);
-    }
-
-    for (i = 0; i < count; ++i) {
-        /* FIXME: We don't want to draw clipped edges */
-        if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
-            /* Nothing to draw */
-            continue;
-        }
-
-        if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
-            SDL_AddDirtyRect(&data->dirty, &rect);
-        }
-
-        if (data->renderer->LockTexture(data->renderer, texture, &rect, 1,
-                                        &data->surface.pixels,
-                                        &data->surface.pitch) < 0) {
-            return -1;
-        }
-
-        data->surface.clip_rect.w = data->surface.w = rect.w;
-        data->surface.clip_rect.h = data->surface.h = rect.h;
-
-        if (renderer->blendMode == SDL_BLENDMODE_NONE ||
-            renderer->blendMode == SDL_BLENDMODE_MASK) {
-            status = SDL_DrawRect(&data->surface, NULL, color);
-        } else {
-            status = SDL_BlendRect(&data->surface, NULL,
-                                   renderer->blendMode,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-        }
-
-        data->renderer->UnlockTexture(data->renderer, texture);
-    }
-    return status;
-}
-
-static int
-SW_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                   int count)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Texture *texture = data->texture[data->current_texture];
-    SDL_Rect clip, rect;
-    Uint32 color = 0;
-    int i;
-    int status = 0;
-
-    clip.x = 0;
-    clip.y = 0;
-    clip.w = texture->w;
-    clip.h = texture->h;
-
-    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
-        renderer->blendMode == SDL_BLENDMODE_MASK) {
-        color = SDL_MapRGBA(data->surface.format,
-                            renderer->r, renderer->g, renderer->b,
-                            renderer->a);
-    }
-
-    for (i = 0; i < count; ++i) {
-        if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
-            /* Nothing to draw */
-            continue;
-        }
-
-        if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
-            SDL_AddDirtyRect(&data->dirty, &rect);
-        }
-
-        if (data->renderer->LockTexture(data->renderer, texture, &rect, 1,
-                                        &data->surface.pixels,
-                                        &data->surface.pitch) < 0) {
-            return -1;
-        }
-
-        data->surface.clip_rect.w = data->surface.w = rect.w;
-        data->surface.clip_rect.h = data->surface.h = rect.h;
-
-        if (renderer->blendMode == SDL_BLENDMODE_NONE ||
-            renderer->blendMode == SDL_BLENDMODE_MASK) {
-            status = SDL_FillRect(&data->surface, NULL, color);
-        } else {
-            status = SDL_BlendFillRect(&data->surface, NULL,
-                                       renderer->blendMode,
-                                       renderer->r, renderer->g, renderer->b,
-                                       renderer->a);
-        }
-
-        data->renderer->UnlockTexture(data->renderer, texture);
-    }
-    return status;
-}
-
-static int
-SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    int status;
-
-    if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
-        SDL_AddDirtyRect(&data->dirty, dstrect);
-    }
-
-    if (data->renderer->LockTexture(data->renderer,
-                                    data->texture[data->current_texture],
-                                    dstrect, 1, &data->surface.pixels,
-                                    &data->surface.pitch) < 0) {
-        return -1;
-    }
-
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        status =
-            SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
-                                srcrect, data->format, dstrect->w, dstrect->h,
-                                data->surface.pixels, data->surface.pitch);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-        SDL_Rect real_srcrect = *srcrect;
-        SDL_Rect real_dstrect;
-
-        data->surface.w = dstrect->w;
-        data->surface.h = dstrect->h;
-        data->surface.clip_rect.w = dstrect->w;
-        data->surface.clip_rect.h = dstrect->h;
-        real_dstrect = data->surface.clip_rect;
-
-        status =
-            SDL_LowerBlit(surface, &real_srcrect, &data->surface,
-                          &real_dstrect);
-    }
-    data->renderer->UnlockTexture(data->renderer,
-                                  data->texture[data->current_texture]);
-    return status;
-}
-
-static int
-SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                    Uint32 format, void * pixels, int pitch)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-
-    if (data->renderer->LockTexture(data->renderer,
-                                    data->texture[data->current_texture],
-                                    rect, 0, &data->surface.pixels,
-                                    &data->surface.pitch) < 0) {
-        return -1;
-    }
-
-    SDL_ConvertPixels(rect->w, rect->h,
-                      data->format, data->surface.pixels, data->surface.pitch,
-                      format, pixels, pitch);
-
-    data->renderer->UnlockTexture(data->renderer,
-                                  data->texture[data->current_texture]);
-    return 0;
-}
-
-static int
-SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                     Uint32 format, const void * pixels, int pitch)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-
-    if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
-        SDL_AddDirtyRect(&data->dirty, rect);
-    }
-
-    if (data->renderer->LockTexture(data->renderer,
-                                    data->texture[data->current_texture],
-                                    rect, 1, &data->surface.pixels,
-                                    &data->surface.pitch) < 0) {
-        return -1;
-    }
-
-    SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch,
-                      data->format, data->surface.pixels, data->surface.pitch);
-
-    data->renderer->UnlockTexture(data->renderer,
-                                  data->texture[data->current_texture]);
-    return 0;
-}
-
-static void
-SW_RenderPresent(SDL_Renderer * renderer)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Texture *texture = data->texture[data->current_texture];
-
-    /* Send the data to the display */
-    if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
-        SDL_DirtyRect *dirty;
-        for (dirty = data->dirty.list; dirty; dirty = dirty->next) {
-            data->renderer->RenderCopy(data->renderer, texture, &dirty->rect,
-                                       &dirty->rect);
-        }
-        SDL_ClearDirtyRects(&data->dirty);
-    } else {
-        SDL_Rect rect;
-        rect.x = 0;
-        rect.y = 0;
-        rect.w = texture->w;
-        rect.h = texture->h;
-        data->renderer->RenderCopy(data->renderer, texture, &rect, &rect);
-    }
-    data->renderer->RenderPresent(data->renderer);
-
-    /* Update the flipping chain, if any */
-    if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
-        data->current_texture = (data->current_texture + 1) % 2;
-    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
-        data->current_texture = (data->current_texture + 1) % 3;
-    }
-}
-
-static void
-SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        SDL_SW_DestroyYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-
-        SDL_FreeSurface(surface);
-    }
-}
-
-static void
-SW_DestroyRenderer(SDL_Renderer * renderer)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    int i;
-
-    if (data) {
-        for (i = 0; i < SDL_arraysize(data->texture); ++i) {
-            if (data->texture[i]) {
-                DestroyTexture(data->renderer, data->texture[i]);
-            }
-        }
-        if (data->surface.format) {
-            SDL_SetSurfacePalette(&data->surface, NULL);
-            SDL_FreeFormat(data->surface.format);
-        }
-        if (display->palette) {
-            SDL_DelPaletteWatch(display->palette, DisplayPaletteChanged,
-                                data);
-        }
-        if (data->renderer) {
-            data->renderer->DestroyRenderer(data->renderer);
-        }
-        SDL_FreeDirtyRects(&data->dirty);
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_sw.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* SDL surface based renderer implementation */
-
-extern SDL_RenderDriver SW_RenderDriver;
-
-/* Set up SDL_Surface texture functions for a renderer */
-void Setup_SoftwareRenderer(SDL_Renderer * renderer);
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_surface.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_surface.c	Sun Feb 06 21:23:32 2011 -0800
@@ -449,13 +449,10 @@
     status = 0;
     flags = surface->map->info.flags;
     surface->map->info.flags &=
-        ~(SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD);
+        ~(SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD);
     switch (blendMode) {
     case SDL_BLENDMODE_NONE:
         break;
-    case SDL_BLENDMODE_MASK:
-        surface->map->info.flags |= SDL_COPY_MASK;
-        break;
     case SDL_BLENDMODE_BLEND:
         surface->map->info.flags |= SDL_COPY_BLEND;
         break;
@@ -497,11 +494,7 @@
     }
 
     switch (surface->map->
-            info.flags & (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD |
-                          SDL_COPY_MOD)) {
-    case SDL_COPY_MASK:
-        *blendMode = SDL_BLENDMODE_MASK;
-        break;
+            info.flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD)) {
     case SDL_COPY_BLEND:
         *blendMode = SDL_BLENDMODE_BLEND;
         break;
@@ -518,64 +511,6 @@
     return 0;
 }
 
-int
-SDL_SetSurfaceScaleMode(SDL_Surface * surface, SDL_ScaleMode scaleMode)
-{
-    int flags, status;
-
-    if (!surface) {
-        return -1;
-    }
-
-    status = 0;
-    flags = surface->map->info.flags;
-    surface->map->info.flags &= ~(SDL_COPY_NEAREST);
-    switch (scaleMode) {
-    case SDL_SCALEMODE_NONE:
-        break;
-    case SDL_SCALEMODE_FAST:
-        surface->map->info.flags |= SDL_COPY_NEAREST;
-        break;
-    case SDL_SCALEMODE_SLOW:
-    case SDL_SCALEMODE_BEST:
-        SDL_Unsupported();
-        surface->map->info.flags |= SDL_COPY_NEAREST;
-        status = -1;
-        break;
-    default:
-        SDL_Unsupported();
-        status = -1;
-        break;
-    }
-
-    if (surface->map->info.flags != flags) {
-        SDL_InvalidateMap(surface->map);
-    }
-    return status;
-}
-
-int
-SDL_GetSurfaceScaleMode(SDL_Surface * surface, SDL_ScaleMode *scaleMode)
-{
-    if (!surface) {
-        return -1;
-    }
-
-    if (!scaleMode) {
-        return 0;
-    }
-
-    switch (surface->map->info.flags & SDL_COPY_NEAREST) {
-    case SDL_COPY_NEAREST:
-        *scaleMode = SDL_SCALEMODE_FAST;
-        break;
-    default:
-        *scaleMode = SDL_SCALEMODE_NONE;
-        break;
-    }
-    return 0;
-}
-
 SDL_bool
 SDL_SetClipRect(SDL_Surface * surface, const SDL_Rect * rect)
 {
--- a/src/video/SDL_sysvideo.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_sysvideo.h	Sun Feb 06 21:23:32 2011 -0800
@@ -24,117 +24,15 @@
 #ifndef _SDL_sysvideo_h
 #define _SDL_sysvideo_h
 
-#include "SDL_mouse.h"
-#include "SDL_keysym.h"
 #include "SDL_shape.h"
 
 /* The SDL video driver */
 
-typedef struct SDL_Renderer SDL_Renderer;
-typedef struct SDL_RenderDriver SDL_RenderDriver;
 typedef struct SDL_WindowShaper SDL_WindowShaper;
 typedef struct SDL_ShapeDriver SDL_ShapeDriver;
 typedef struct SDL_VideoDisplay SDL_VideoDisplay;
 typedef struct SDL_VideoDevice SDL_VideoDevice;
 
-/* Define the SDL texture structure */
-struct SDL_Texture
-{
-    const void *magic;
-    Uint32 format;              /**< The pixel format of the texture */
-    int access;                 /**< SDL_TextureAccess */
-    int w;                      /**< The width of the texture */
-    int h;                      /**< The height of the texture */
-    int modMode;                /**< The texture modulation mode */
-    SDL_BlendMode blendMode;    /**< The texture blend mode */
-    SDL_ScaleMode scaleMode;    /**< The texture scale mode */
-    Uint8 r, g, b, a;           /**< Texture modulation values */
-
-    SDL_Renderer *renderer;
-
-    void *driverdata;           /**< Driver specific texture representation */
-
-    SDL_Texture *prev;
-    SDL_Texture *next;
-};
-
-/* Define the SDL renderer structure */
-struct SDL_Renderer
-{
-    int (*ActivateRenderer) (SDL_Renderer * renderer);
-    int (*DisplayModeChanged) (SDL_Renderer * renderer);
-    int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
-    int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
-                               void **pixels, int *pitch);
-    int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
-                              const SDL_Color * colors, int firstcolor,
-                              int ncolors);
-    int (*GetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
-                              SDL_Color * colors, int firstcolor,
-                              int ncolors);
-    int (*SetTextureColorMod) (SDL_Renderer * renderer,
-                               SDL_Texture * texture);
-    int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
-                               SDL_Texture * texture);
-    int (*SetTextureBlendMode) (SDL_Renderer * renderer,
-                                SDL_Texture * texture);
-    int (*SetTextureScaleMode) (SDL_Renderer * renderer,
-                                SDL_Texture * texture);
-    int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * rect, const void *pixels,
-                          int pitch);
-    int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
-                        const SDL_Rect * rect, int markDirty, void **pixels,
-                        int *pitch);
-    void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
-    void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
-                          int numrects, const SDL_Rect * rects);
-    int (*SetDrawColor) (SDL_Renderer * renderer);
-    int (*SetDrawBlendMode) (SDL_Renderer * renderer);
-    int (*RenderClear) (SDL_Renderer * renderer);
-    int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
-                             int count);
-    int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
-                            int count);
-    int (*RenderDrawRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
-                            int count);
-    int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
-                            int count);
-    int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
-                       const SDL_Rect * srcrect, const SDL_Rect * dstrect);
-    int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
-                             Uint32 format, void * pixels, int pitch);
-    int (*RenderWritePixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
-                              Uint32 format, const void * pixels, int pitch);
-    void (*RenderPresent) (SDL_Renderer * renderer);
-    void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
-
-    void (*DestroyRenderer) (SDL_Renderer * renderer);
-
-    /* The current renderer info */
-    SDL_RendererInfo info;
-
-    /* The window associated with the renderer */
-    SDL_Window *window;
-
-    /* The list of textures */
-    SDL_Texture *textures;
-
-    Uint8 r, g, b, a;                   /**< Color for drawing operations values */
-    SDL_BlendMode blendMode;            /**< The drawing blend mode */
-
-    void *driverdata;
-};
-
-/* Define the SDL render driver structure */
-struct SDL_RenderDriver
-{
-    SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
-
-    /* Info about the renderer capabilities */
-    SDL_RendererInfo info;
-};
-
 /* Define the SDL window-shaper structure */
 struct SDL_WindowShaper
 {   
@@ -161,6 +59,13 @@
     int (*ResizeWindowShape)(SDL_Window *window);
 };
 
+typedef struct SDL_WindowUserData
+{
+    char *name;
+    void *data;
+    struct SDL_WindowUserData *next;
+} SDL_WindowUserData;
+
 /* Define the SDL window structure, corresponding to toplevel windows */
 struct SDL_Window
 {
@@ -172,13 +77,16 @@
     Uint32 flags;
 
     SDL_VideoDisplay *display;
-    SDL_Renderer *renderer;
 
     SDL_DisplayMode fullscreen_mode;
     
+    SDL_Surface *surface;
+    SDL_bool surface_valid;
+
     SDL_WindowShaper *shaper;
 
-    void *userdata;
+    SDL_WindowUserData *data;
+
     void *driverdata;
 
     SDL_Window *prev;
@@ -201,19 +109,13 @@
     SDL_DisplayMode desktop_mode;
     SDL_DisplayMode current_mode;
     SDL_bool updating_fullscreen;
-    SDL_Palette *palette;
 
     Uint16 *gamma;
     Uint16 *saved_gamma;        /* (just offset into gamma) */
 
-    int num_render_drivers;
-    SDL_RenderDriver *render_drivers;
-
     SDL_Window *windows;
     SDL_Window *fullscreen_window;
 
-    SDL_Renderer *current_renderer;
-
     SDL_VideoDevice *device;
 
     void *driverdata;
@@ -267,12 +169,6 @@
      */
     int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
 
-    /* Set the color entries of the display palette */
-    int (*SetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
-
-    /* Get the color entries of the display palette */
-    int (*GetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
-
     /* Set the gamma ramp */
     int (*SetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
 
@@ -297,7 +193,10 @@
     void (*RestoreWindow) (_THIS, SDL_Window * window);
     void (*SetWindowGrab) (_THIS, SDL_Window * window);
     void (*DestroyWindow) (_THIS, SDL_Window * window);
-    
+    int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
+    int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, int numrects, SDL_Rect * rects);
+    void (*DestroyWindowFramebuffer) (_THIS, SDL_Window * window);
+
     /* * * */
     /*
      * Shaped-window functions
@@ -348,7 +247,6 @@
     SDL_VideoDisplay *displays;
     int current_display;
     Uint8 window_magic;
-    Uint8 texture_magic;
     Uint32 next_object_id;
     char * clipboard_text;
 
@@ -417,33 +315,23 @@
 #if SDL_VIDEO_DRIVER_BWINDOW
 extern VideoBootStrap BWINDOW_bootstrap;
 #endif
-#if SDL_VIDEO_DRIVER_PHOTON
-extern VideoBootStrap photon_bootstrap;
+#if SDL_VIDEO_DRIVER_PANDORA
+extern VideoBootStrap PND_bootstrap;
 #endif
-#if SDL_VIDEO_DRIVER_QNXGF
-extern VideoBootStrap qnxgf_bootstrap;
-#endif
-#if SDL_VIDEO_DRIVER_EPOC
-extern VideoBootStrap EPOC_bootstrap;
+#if SDL_VIDEO_DRIVER_NDS
+extern VideoBootStrap NDS_bootstrap;
 #endif
 #if SDL_VIDEO_DRIVER_UIKIT
 extern VideoBootStrap UIKIT_bootstrap;
 #endif
+#if SDL_VIDEO_DRIVER_ANDROID
+extern VideoBootStrap Android_bootstrap;
+#endif
 #if SDL_VIDEO_DRIVER_DUMMY
 extern VideoBootStrap DUMMY_bootstrap;
 #endif
-#if SDL_VIDEO_DRIVER_NDS
-extern VideoBootStrap NDS_bootstrap;
-#endif
-#if SDL_VIDEO_DRIVER_PANDORA
-extern VideoBootStrap PND_bootstrap;
-#endif
-#if SDL_VIDEO_DRIVER_ANDROID
-extern VideoBootStrap Android_bootstrap;
-#endif
 
 #define SDL_CurrentDisplay	(&_this->displays[_this->current_display])
-#define SDL_CurrentRenderer	(SDL_CurrentDisplay->current_renderer)
 
 extern SDL_VideoDevice *SDL_GetVideoDevice(void);
 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
@@ -455,11 +343,8 @@
 extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
 extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
 extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode);
-extern int SDL_SetPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors);
-extern int SDL_GetPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors);
 extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue);
 extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue);
-extern void SDL_AddRenderDriver(SDL_VideoDisplay *display, const SDL_RenderDriver * driver);
 
 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
 
--- a/src/video/SDL_video.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/SDL_video.c	Sun Feb 06 21:23:32 2011 -0800
@@ -28,23 +28,19 @@
 #include "SDL_sysvideo.h"
 #include "SDL_blit.h"
 #include "SDL_pixels_c.h"
-#include "SDL_renderer_gl.h"
-#include "SDL_renderer_gles.h"
-#include "SDL_renderer_sw.h"
 #include "../events/SDL_events_c.h"
 
-#if SDL_VIDEO_DRIVER_WINDOWS
-#include "windows/SDL_windowsvideo.h"
-extern void IME_Present(SDL_VideoData *videodata);
-#endif
+#if SDL_VIDEO_OPENGL
+#include "SDL_opengl.h"
+#endif /* SDL_VIDEO_OPENGL */
 
 #if SDL_VIDEO_OPENGL_ES
 #include "SDL_opengles.h"
 #endif /* SDL_VIDEO_OPENGL_ES */
 
-#if SDL_VIDEO_OPENGL
-#include "SDL_opengl.h"
-#endif /* SDL_VIDEO_OPENGL */
+#if SDL_VIDEO_OPENGL_ES2
+#include "SDL_opengles2.h"
+#endif /* SDL_VIDEO_OPENGL_ES2 */
 
 #include "SDL_syswm.h"
 
@@ -70,14 +66,8 @@
 #if SDL_VIDEO_DRIVER_BWINDOW
     &BWINDOW_bootstrap,
 #endif
-#if SDL_VIDEO_DRIVER_PHOTON
-    &photon_bootstrap,
-#endif
-#if SDL_VIDEO_DRIVER_QNXGF
-    &qnxgf_bootstrap,
-#endif
-#if SDL_VIDEO_DRIVER_EPOC
-    &EPOC_bootstrap,
+#if SDL_VIDEO_DRIVER_PANDORA
+    &PND_bootstrap,
 #endif
 #if SDL_VIDEO_DRIVER_NDS
     &NDS_bootstrap,
@@ -85,15 +75,12 @@
 #if SDL_VIDEO_DRIVER_UIKIT
     &UIKIT_bootstrap,
 #endif
+#if SDL_VIDEO_DRIVER_ANDROID
+    &Android_bootstrap,
+#endif
 #if SDL_VIDEO_DRIVER_DUMMY
     &DUMMY_bootstrap,
 #endif
-#if SDL_VIDEO_DRIVER_PANDORA
-    &PND_bootstrap,
-#endif
-#if SDL_VIDEO_DRIVER_ANDROID
-    &Android_bootstrap,
-#endif
     NULL
 };
 
@@ -109,18 +96,269 @@
         return retval; \
     }
 
-#define CHECK_TEXTURE_MAGIC(texture, retval) \
-    if (!_this) { \
-        SDL_UninitializedVideo(); \
-        return retval; \
-    } \
-    if (!texture || texture->magic != &_this->texture_magic) { \
-        SDL_SetError("Invalid texture"); \
-        return retval; \
+/* Various local functions */
+static void SDL_UpdateWindowGrab(SDL_Window * window);
+
+/* Support for framebuffer emulation using an accelerated renderer */
+
+#define SDL_WINDOWTEXTUREDATA   "_SDL_WindowTextureData"
+
+typedef struct {
+    SDL_Renderer *renderer;
+    SDL_Texture *texture;
+    void *pixels;
+    int pitch;
+    int bytes_per_pixel;
+} SDL_WindowTextureData;
+
+static SDL_bool
+ShouldUseTextureFramebuffer()
+{
+    const char *hint;
+
+    /* If there's no native framebuffer support then there's no option */
+    if (!_this->CreateWindowFramebuffer) {
+        return SDL_TRUE;
+    }
+
+    /* If the user has specified a software renderer we can't use a
+       texture framebuffer, or renderer creation will go recursive.
+     */
+    hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
+    if (hint && SDL_strcasecmp(hint, "software") == 0) {
+        return SDL_FALSE;
+    }
+
+    /* See if the user or application wants a specific behavior */
+    hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
+    if (hint) {
+        if (*hint == '0') {
+            return SDL_FALSE;
+        } else {
+            return SDL_TRUE;
+        }
+    }
+
+    /* Each platform has different performance characteristics */
+#if defined(__WIN32__)
+    /* GDI BitBlt() is way faster than Direct3D dynamic textures right now.
+     */
+    return SDL_FALSE;
+
+#elif defined(__MACOSX__)
+    /* Mac OS X uses OpenGL as the native fast path */
+    return SDL_TRUE;
+
+#elif defined(__LINUX__)
+    /* Properly configured OpenGL drivers are faster than MIT-SHM */
+#if SDL_VIDEO_OPENGL
+    /* Ugh, find a way to cache this value! */
+    {
+        SDL_Window *window;
+        SDL_GLContext context;
+        SDL_bool hasAcceleratedOpenGL = SDL_FALSE;
+
+        window = SDL_CreateWindow("OpenGL test", -32, -32, 32, 32, SDL_WINDOW_OPENGL);
+        if (window) {
+            context = SDL_GL_CreateContext(window);
+            if (context) {
+                const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
+                const char *vendor = NULL;
+
+                glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
+                if (glGetStringFunc) {
+                    vendor = (const char *) glGetStringFunc(GL_VENDOR);
+                }
+                /* Add more vendors here at will... */
+                if (vendor &&
+                    (SDL_strstr(vendor, "ATI Technologies") ||
+                     SDL_strstr(vendor, "NVIDIA"))) {
+                    hasAcceleratedOpenGL = SDL_TRUE;
+                }
+                SDL_GL_DeleteContext(context);
+            }
+            SDL_DestroyWindow(window);
+        }
+        return hasAcceleratedOpenGL;
+    }
+#else
+    return SDL_FALSE;
+#endif
+
+#else
+    /* Play it safe, assume that if there is a framebuffer driver that it's
+       optimized for the current platform.
+    */
+    return SDL_FALSE;
+#endif
+}
+
+static int
+SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
+{
+    SDL_WindowTextureData *data;
+    SDL_Renderer *renderer;
+    SDL_RendererInfo info;
+    Uint32 i;
+
+    data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
+    if (!data) {
+        data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data));
+        if (!data) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, data);
     }
 
-/* Various local functions */
-static void SDL_UpdateWindowGrab(SDL_Window * window);
+    renderer = data->renderer;
+    if (!renderer) {
+        SDL_RendererInfo info;
+        int i;
+        const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
+
+        /* Check to see if there's a specific driver requested */
+        if (hint && *hint != '0' && *hint != '1' &&
+            SDL_strcasecmp(hint, "software") != 0) {
+            for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
+                SDL_GetRenderDriverInfo(i, &info);
+                if (SDL_strcasecmp(info.name, hint) == 0) {
+                    renderer = SDL_CreateRenderer(window, i, 0);
+                    break;
+                }
+            }
+        }
+
+        if (!renderer) {
+            for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
+                SDL_GetRenderDriverInfo(i, &info);
+                if (SDL_strcmp(info.name, "software") != 0) {
+                    renderer = SDL_CreateRenderer(window, i, 0);
+                    if (renderer) {
+                        break;
+                    }
+                }
+            }
+        }
+        if (!renderer) {
+            return -1;
+        }
+        data->renderer = renderer;
+    }
+
+    /* Free any old texture and pixel data */
+    if (data->texture) {
+        SDL_DestroyTexture(data->texture);
+        data->texture = NULL;
+    }
+    if (data->pixels) {
+        SDL_free(data->pixels);
+        data->pixels = NULL;
+    }
+
+    if (SDL_GetRendererInfo(renderer, &info) < 0) {
+        return -1;
+    }
+
+    /* Find the first format without an alpha channel */
+    *format = info.texture_formats[0];
+    for (i = 0; i < info.num_texture_formats; ++i) {
+        if (!SDL_ISPIXELFORMAT_ALPHA(info.texture_formats[i])) {
+            *format = info.texture_formats[i];
+            break;
+        }
+    }
+
+    data->texture = SDL_CreateTexture(renderer, *format,
+                                      SDL_TEXTUREACCESS_STREAMING,
+                                      window->w, window->h);
+    if (!data->texture) {
+        return -1;
+    }
+
+    /* Create framebuffer data */
+    data->bytes_per_pixel = SDL_BYTESPERPIXEL(*format);
+    data->pitch = (((window->w * data->bytes_per_pixel) + 3) & ~3);
+    data->pixels = SDL_malloc(window->h * data->pitch);
+    if (!data->pixels) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+
+    *pixels = data->pixels;
+    *pitch = data->pitch;
+    return 0;
+}
+
+static int
+SDL_UpdateWindowTexture(_THIS, SDL_Window * window, int numrects, SDL_Rect * rects)
+{
+    SDL_WindowTextureData *data;
+#ifdef UPDATE_TEXTURE_SUBRECTS
+    void *src, *dst;
+    int src_pitch;
+    int dst_pitch;
+    int i, row, length;
+#endif
+
+    data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
+    if (!data || !data->texture) {
+        SDL_SetError("No window texture data");
+        return -1;
+    }
+
+#ifdef UPDATE_TEXTURE_SUBRECTS
+    src_pitch = data->pitch;
+    for (i = 0; i < numrects; ++i) {
+        src = (void *)((Uint8 *)data->pixels +
+                        rects[i].y * src_pitch +
+                        rects[i].x * data->bytes_per_pixel);
+        if (SDL_LockTexture(data->texture, &rects[i], &dst, &dst_pitch) < 0) {
+            return -1;
+        }
+        length = rects[i].w * data->bytes_per_pixel;
+        for (row = rects[i].h; row--; ) {
+            SDL_memcpy(dst, src, length);
+            src = (Uint8*)src + src_pitch;
+            dst = (Uint8*)dst + dst_pitch;
+        }
+        SDL_UnlockTexture(data->texture);
+    }
+#else
+    if (SDL_UpdateTexture(data->texture, NULL, data->pixels, data->pitch) < 0) {
+        return -1;
+    }
+#endif
+
+    if (SDL_RenderCopy(data->renderer, data->texture, NULL, NULL) < 0) {
+        return -1;
+    }
+
+    SDL_RenderPresent(data->renderer);
+    return 0;
+}
+
+static void
+SDL_DestroyWindowTexture(_THIS, SDL_Window * window)
+{
+    SDL_WindowTextureData *data;
+
+    data = SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, NULL);
+    if (!data) {
+        return;
+    }
+    if (data->texture) {
+        SDL_DestroyTexture(data->texture);
+    }
+    if (data->renderer) {
+        SDL_DestroyRenderer(data->renderer);
+    }
+    if (data->pixels) {
+        SDL_free(data->pixels);
+    }
+    SDL_free(data);
+}
+
 
 static int
 cmpmodes(const void *A, const void *B)
@@ -247,34 +485,35 @@
     _this->gl_config.multisamplesamples = 0;
     _this->gl_config.retained_backing = 1;
     _this->gl_config.accelerated = -1;  /* accelerated or not, both are fine */
+#if SDL_VIDEO_OPENGL
     _this->gl_config.major_version = 2;
     _this->gl_config.minor_version = 1;
+#elif SDL_VIDEO_OPENGL_ES2
+    _this->gl_config.major_version = 2;
+    _this->gl_config.minor_version = 0;
+#elif SDL_VIDEO_OPENGL_ES
+    _this->gl_config.major_version = 1;
+    _this->gl_config.minor_version = 1;
+#endif
 
     /* Initialize the video subsystem */
     if (_this->VideoInit(_this) < 0) {
         SDL_VideoQuit();
         return -1;
     }
+
     /* Make sure some displays were added */
     if (_this->num_displays == 0) {
         SDL_SetError("The video driver did not add any displays");
         SDL_VideoQuit();
         return (-1);
     }
-    /* The software renderer is always available */
-    for (i = 0; i < _this->num_displays; ++i) {
-        SDL_VideoDisplay *display = &_this->displays[i];
-        if (_this->GL_CreateContext) {
-#if SDL_VIDEO_RENDER_OGL
-            SDL_AddRenderDriver(display, &GL_RenderDriver);
-#endif
-#if SDL_VIDEO_RENDER_OGL_ES
-            SDL_AddRenderDriver(display, &GL_ES_RenderDriver);
-#endif
-        }
-        if (display->num_render_drivers > 0) {
-            SDL_AddRenderDriver(display, &SW_RenderDriver);
-        }
+
+    /* Add the renderer framebuffer emulation if desired */
+    if (ShouldUseTextureFramebuffer()) {
+        _this->CreateWindowFramebuffer = SDL_CreateWindowTexture;
+        _this->UpdateWindowFramebuffer = SDL_UpdateWindowTexture;
+        _this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture;
     }
 
     /* We're ready to go! */
@@ -639,7 +878,6 @@
 {
     SDL_DisplayMode display_mode;
     SDL_DisplayMode current_mode;
-    int ncolors;
 
     if (mode) {
         display_mode = *mode;
@@ -683,29 +921,6 @@
         return -1;
     }
     display->current_mode = display_mode;
-
-    /* Set up a palette, if necessary */
-    if (SDL_ISPIXELFORMAT_INDEXED(display_mode.format)) {
-        ncolors = (1 << SDL_BITSPERPIXEL(display_mode.format));
-    } else {
-        ncolors = 0;
-    }
-    if ((!ncolors && display->palette) || (ncolors && !display->palette)
-        || (ncolors && ncolors != display->palette->ncolors)) {
-        if (display->palette) {
-            SDL_FreePalette(display->palette);
-            display->palette = NULL;
-        }
-        if (ncolors) {
-            display->palette = SDL_AllocPalette(ncolors);
-            if (!display->palette) {
-                return -1;
-            }
-            SDL_DitherColors(display->palette->colors,
-                             SDL_BITSPERPIXEL(display_mode.format));
-        }
-    }
-
     return 0;
 }
 
@@ -750,6 +965,14 @@
     return 0;
 }
 
+Uint32
+SDL_GetWindowPixelFormat(SDL_Window * window)
+{
+    SDL_VideoDisplay *display = window->display;
+    SDL_DisplayMode *displayMode = &display->current_mode;
+    return displayMode->format;
+}
+
 static void
 SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt)
 {
@@ -807,66 +1030,6 @@
     display->fullscreen_window = NULL;
 }
 
-int
-SDL_SetPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors)
-{
-    SDL_Palette *palette;
-    int status = 0;
-
-    palette = display->palette;
-    if (!palette) {
-        SDL_SetError("Display mode does not have a palette");
-        return -1;
-    }
-    status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors);
-
-    if (_this->SetDisplayPalette) {
-        if (_this->SetDisplayPalette(_this, display, palette) < 0) {
-            status = -1;
-        }
-    }
-    return status;
-}
-
-int
-SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors)
-{
-    if (!_this) {
-        SDL_UninitializedVideo();
-        return -1;
-    }
-    return SDL_SetPaletteForDisplay(SDL_CurrentDisplay, colors, firstcolor, ncolors);
-}
-
-int
-SDL_GetPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors)
-{
-    SDL_Palette *palette;
-
-    palette = display->palette;
-    if (!palette || !palette->ncolors) {
-        SDL_SetError("Display mode does not have a palette");
-        return -1;
-    }
-    if (firstcolor < 0 || (firstcolor + ncolors) > palette->ncolors) {
-        SDL_SetError("Palette indices are out of range");
-        return -1;
-    }
-    SDL_memcpy(colors, &palette->colors[firstcolor],
-               ncolors * sizeof(*colors));
-    return 0;
-}
-
-int
-SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors)
-{
-    if (!_this) {
-        SDL_UninitializedVideo();
-        return -1;
-    }
-    return SDL_GetPaletteForDisplay(SDL_CurrentDisplay, colors, firstcolor, ncolors);
-}
-
 SDL_Window *
 SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
 {
@@ -1023,33 +1186,6 @@
     return 0;
 }
 
-static __inline__ SDL_Renderer *
-SDL_GetCurrentRenderer(SDL_bool create)
-{
-    if (!_this) {
-        SDL_UninitializedVideo();
-        return NULL;
-    }
-    if (!SDL_CurrentRenderer) {
-        SDL_Window *window = NULL;
-
-        if (!create) {
-            SDL_SetError("Use SDL_CreateRenderer() to create a renderer");
-            return NULL;
-        }
-
-        /* Get the first window on the first display */
-        if (_this->num_displays > 0) {
-            window = _this->displays[0].windows;
-        }
-
-        if (SDL_CreateRenderer(window, -1, 0) < 0) {
-            return NULL;
-        }
-    }
-    return SDL_CurrentRenderer;
-}
-
 Uint32
 SDL_GetWindowID(SDL_Window * window)
 {
@@ -1127,20 +1263,60 @@
     }
 }
 
-void
-SDL_SetWindowData(SDL_Window * window, void *userdata)
+void*
+SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata)
 {
-    CHECK_WINDOW_MAGIC(window, );
+    SDL_WindowUserData *prev, *data;
+
+    CHECK_WINDOW_MAGIC(window, NULL);
+
+    /* See if the named data already exists */
+    prev = NULL;
+    for (data = window->data; data; prev = data, data = data->next) {
+        if (SDL_strcmp(data->name, name) == 0) {
+            void *last_value = data->data;
 
-    window->userdata = userdata;
+            if (userdata) {
+                /* Set the new value */
+                data->data = userdata;
+            } else {
+                /* Delete this value */
+                if (prev) {
+                    prev->next = data->next;
+                } else {
+                    window->data = data->next;
+                }
+                SDL_free(data->name);
+                SDL_free(data);
+            }
+            return last_value;
+        }
+    }
+
+    /* Add new data to the window */
+    if (userdata) {
+        data = (SDL_WindowUserData *)SDL_malloc(sizeof(*data));
+        data->name = SDL_strdup(name);
+        data->data = userdata;
+        data->next = window->data;
+        window->data = data;
+    }
+    return NULL;
 }
 
 void *
-SDL_GetWindowData(SDL_Window * window)
+SDL_GetWindowData(SDL_Window * window, const char *name)
 {
+    SDL_WindowUserData *data;
+
     CHECK_WINDOW_MAGIC(window, NULL);
 
-    return window->userdata;
+    for (data = window->data; data; data = data->next) {
+        if (SDL_strcmp(data->name, name) == 0) {
+            return data->data;
+        }
+    }
+    return NULL;
 }
 
 void
@@ -1184,7 +1360,7 @@
     if (_this->SetWindowSize) {
         _this->SetWindowSize(_this, window);
     }
-    SDL_OnWindowResized(window);
+    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, w, h);
 }
 
 void
@@ -1321,6 +1497,77 @@
     return 0;
 }
 
+static SDL_Surface *
+SDL_CreateWindowFramebuffer(SDL_Window * window)
+{
+    Uint32 format;
+    void *pixels;
+    int pitch;
+    int bpp;
+    Uint32 Rmask, Gmask, Bmask, Amask;
+
+    if (!_this->CreateWindowFramebuffer || !_this->UpdateWindowFramebuffer) {
+        return NULL;
+    }
+
+    if (_this->CreateWindowFramebuffer(_this, window, &format, &pixels, &pitch) < 0) {
+        return NULL;
+    }
+
+    if (!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
+        return NULL;
+    }
+
+    return SDL_CreateRGBSurfaceFrom(pixels, window->w, window->h, bpp, pitch, Rmask, Gmask, Bmask, Amask);
+}
+
+SDL_Surface *
+SDL_GetWindowSurface(SDL_Window * window)
+{
+    CHECK_WINDOW_MAGIC(window, NULL);
+
+    if (!window->surface_valid) {
+        if (window->surface) {
+            window->surface->refcount = 0;
+            SDL_FreeSurface(window->surface);
+        }
+        window->surface = SDL_CreateWindowFramebuffer(window);
+        if (window->surface) {
+            window->surface_valid = SDL_TRUE;
+            window->surface->refcount = 0x7FFFFFF;
+        }
+    }
+    return window->surface;
+}
+
+int
+SDL_UpdateWindowSurface(SDL_Window * window)
+{
+    SDL_Rect full_rect;
+
+    CHECK_WINDOW_MAGIC(window, -1);
+
+    full_rect.x = 0;
+    full_rect.y = 0;
+    full_rect.w = window->w;
+    full_rect.h = window->h;
+    return SDL_UpdateWindowSurfaceRects(window, 1, &full_rect);
+}
+
+int
+SDL_UpdateWindowSurfaceRects(SDL_Window * window,
+                             int numrects, SDL_Rect * rects)
+{
+    CHECK_WINDOW_MAGIC(window, -1);
+
+    if (!window->surface_valid) {
+        SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");
+        return -1;
+    }
+
+    return _this->UpdateWindowFramebuffer(_this, window, numrects, rects);
+}
+
 void
 SDL_SetWindowGrab(SDL_Window * window, int mode)
 {
@@ -1369,11 +1616,7 @@
 void
 SDL_OnWindowResized(SDL_Window * window)
 {
-    SDL_Renderer *renderer = window->renderer;
-
-    if (renderer && renderer->DisplayModeChanged) {
-        renderer->DisplayModeChanged(renderer);
-    }
+    window->surface_valid = SDL_FALSE;
 }
 
 void
@@ -1448,16 +1691,16 @@
 
     CHECK_WINDOW_MAGIC(window, );
 
-    if (window->title) {
-        SDL_free(window->title);
-    }
-    if (window->renderer) {
-        SDL_DestroyRenderer(window);
-    }
-
     /* Restore video mode, etc. */
     SDL_UpdateFullscreenMode(window, SDL_FALSE);
 
+    if (window->surface) {
+        window->surface->refcount = 0;
+        SDL_FreeSurface(window->surface);
+    }
+    if (_this->DestroyWindowFramebuffer) {
+        _this->DestroyWindowFramebuffer(_this, window);
+    }
     if (_this->DestroyWindow) {
         _this->DestroyWindow(_this, window);
     }
@@ -1468,6 +1711,18 @@
     /* Now invalidate magic */
     window->magic = NULL;
 
+    /* Free memory associated with the window */
+    if (window->title) {
+        SDL_free(window->title);
+    }
+    while (window->data) {
+        SDL_WindowUserData *data = window->data;
+
+        window->data = data->next;
+        SDL_free(data->name);
+        SDL_free(data);
+    }
+
     /* Unlink the window from the list */
     display = window->display;
     if (window->next) {
@@ -1482,1277 +1737,6 @@
     SDL_free(window);
 }
 
-void
-SDL_AddRenderDriver(SDL_VideoDisplay * display, const SDL_RenderDriver * driver)
-{
-    SDL_RenderDriver *render_drivers;
-
-    render_drivers =
-        SDL_realloc(display->render_drivers,
-                    (display->num_render_drivers +
-                     1) * sizeof(*render_drivers));
-    if (render_drivers) {
-        render_drivers[display->num_render_drivers] = *driver;
-        display->render_drivers = render_drivers;
-        display->num_render_drivers++;
-    }
-}
-
-int
-SDL_GetNumRenderDrivers(void)
-{
-    if (_this) {
-        return SDL_CurrentDisplay->num_render_drivers;
-    }
-    return 0;
-}
-
-int
-SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
-{
-    if (!_this) {
-        SDL_UninitializedVideo();
-        return -1;
-    }
-    if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
-        SDL_SetError("index must be in the range of 0 - %d",
-                     SDL_GetNumRenderDrivers() - 1);
-        return -1;
-    }
-    *info = SDL_CurrentDisplay->render_drivers[index].info;
-    return 0;
-}
-
-int
-SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
-{
-    CHECK_WINDOW_MAGIC(window, -1);
-
-    /* Free any existing renderer */
-    SDL_DestroyRenderer(window);
-
-    if (index < 0) {
-        char *override = SDL_getenv("SDL_VIDEO_RENDERER");
-        int n = SDL_GetNumRenderDrivers();
-
-#if SDL_VIDEO_RENDER_OGL
-        if (!override && (window->flags & SDL_WINDOW_OPENGL)) {
-            override = "opengl";
-        }
-#endif /* SDL_VIDEO_RENDER_OGL */
-#if SDL_VIDEO_RENDER_OGL_ES
-        if (!override && (window->flags & SDL_WINDOW_OPENGL)) {
-            override = "opengl_es";
-        }
-#endif /* SDL_VIDEO_RENDER_OGL_ES */
-        if (override) {
-            for (index = 0; index < n; ++index) {
-                SDL_RenderDriver *driver =
-                    &SDL_CurrentDisplay->render_drivers[index];
-
-                if (SDL_strcasecmp(override, driver->info.name) == 0) {
-                    /* Create a new renderer instance */
-                    window->renderer = driver->CreateRenderer(window, flags);
-                    break;
-                }
-            }
-        } else {
-            for (index = 0; index < n; ++index) {
-                SDL_RenderDriver *driver =
-                    &SDL_CurrentDisplay->render_drivers[index];
-
-                if ((driver->info.flags & flags) == flags) {
-                    /* Create a new renderer instance */
-                    window->renderer = driver->CreateRenderer(window, flags);
-                    if (window->renderer) {
-                        /* Yay, we got one! */
-                        break;
-                    }
-                }
-            }
-        }
-        if (index == n) {
-            SDL_SetError("Couldn't find matching render driver");
-            return -1;
-        }
-    } else {
-        if (index >= SDL_GetNumRenderDrivers()) {
-            SDL_SetError("index must be -1 or in the range of 0 - %d",
-                         SDL_GetNumRenderDrivers() - 1);
-            return -1;
-        }
-        /* Create a new renderer instance */
-        window->renderer = SDL_CurrentDisplay->render_drivers[index].CreateRenderer(window, flags);
-    }
-
-    if (window->renderer == NULL) {
-        /* Assuming renderer set its error */
-        return -1;
-    }
-
-    SDL_SelectRenderer(window);
-
-    return 0;
-}
-
-int
-SDL_SelectRenderer(SDL_Window * window)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_WINDOW_MAGIC(window, -1);
-
-    renderer = window->renderer;
-    if (!renderer) {
-        SDL_SetError("Use SDL_CreateRenderer() to create a renderer");
-        return -1;
-    }
-    if (renderer->ActivateRenderer) {
-        if (renderer->ActivateRenderer(renderer) < 0) {
-            return -1;
-        }
-    }
-    SDL_CurrentDisplay->current_renderer = renderer;
-    return 0;
-}
-
-int
-SDL_GetRendererInfo(SDL_RendererInfo * info)
-{
-    SDL_Renderer *renderer = SDL_GetCurrentRenderer(SDL_FALSE);
-    if (!renderer) {
-        return -1;
-    }
-    *info = renderer->info;
-    return 0;
-}
-
-SDL_Texture *
-SDL_CreateTexture(Uint32 format, int access, int w, int h)
-{
-    SDL_Renderer *renderer;
-    SDL_Texture *texture;
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return 0;
-    }
-    if (!renderer->CreateTexture) {
-        SDL_Unsupported();
-        return 0;
-    }
-    if (w <= 0 || h <= 0) {
-        SDL_SetError("Texture dimensions can't be 0");
-        return 0;
-    }
-    texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
-    if (!texture) {
-        SDL_OutOfMemory();
-        return 0;
-    }
-    texture->magic = &_this->texture_magic;
-    texture->format = format;
-    texture->access = access;
-    texture->w = w;
-    texture->h = h;
-    texture->r = 255;
-    texture->g = 255;
-    texture->b = 255;
-    texture->a = 255;
-    texture->renderer = renderer;
-    texture->next = renderer->textures;
-    if (renderer->textures) {
-        renderer->textures->prev = texture;
-    }
-    renderer->textures = texture;
-
-    if (renderer->CreateTexture(renderer, texture) < 0) {
-        SDL_DestroyTexture(texture);
-        return 0;
-    }
-    return texture;
-}
-
-SDL_Texture *
-SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
-{
-    SDL_Texture *texture;
-    Uint32 requested_format = format;
-    SDL_PixelFormat *fmt;
-    SDL_Renderer *renderer;
-    int bpp;
-    Uint32 Rmask, Gmask, Bmask, Amask;
-
-    if (!surface) {
-        SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface");
-        return 0;
-    }
-    fmt = surface->format;
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return 0;
-    }
-
-    if (format) {
-        if (!SDL_PixelFormatEnumToMasks
-            (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-            SDL_SetError("Unknown pixel format");
-            return 0;
-        }
-    } else {
-        if (surface->format->Amask
-            || !(surface->map->info.flags &
-                 (SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) {
-            Uint32 it;
-            int pfmt;
-
-            /* Pixel formats, sorted by best first */
-            static const Uint32 sdl_pformats[] = {
-                SDL_PIXELFORMAT_ARGB8888,
-                SDL_PIXELFORMAT_RGBA8888,
-                SDL_PIXELFORMAT_ABGR8888,
-                SDL_PIXELFORMAT_BGRA8888,
-                SDL_PIXELFORMAT_RGB888,
-                SDL_PIXELFORMAT_BGR888,
-                SDL_PIXELFORMAT_RGB24,
-                SDL_PIXELFORMAT_BGR24,
-                SDL_PIXELFORMAT_RGB565,
-                SDL_PIXELFORMAT_BGR565,
-                SDL_PIXELFORMAT_ARGB1555,
-                SDL_PIXELFORMAT_RGBA5551,
-                SDL_PIXELFORMAT_ABGR1555,
-                SDL_PIXELFORMAT_BGRA5551,
-                SDL_PIXELFORMAT_RGB555,
-                SDL_PIXELFORMAT_BGR555,
-                SDL_PIXELFORMAT_ARGB4444,
-                SDL_PIXELFORMAT_RGBA4444,
-                SDL_PIXELFORMAT_ABGR4444,
-                SDL_PIXELFORMAT_BGRA4444,
-                SDL_PIXELFORMAT_RGB444,
-                SDL_PIXELFORMAT_ARGB2101010,
-                SDL_PIXELFORMAT_INDEX8,
-                SDL_PIXELFORMAT_INDEX4LSB,
-                SDL_PIXELFORMAT_INDEX4MSB,
-                SDL_PIXELFORMAT_RGB332,
-                SDL_PIXELFORMAT_INDEX1LSB,
-                SDL_PIXELFORMAT_INDEX1MSB,
-                SDL_PIXELFORMAT_UNKNOWN
-            };
-
-            bpp = fmt->BitsPerPixel;
-            Rmask = fmt->Rmask;
-            Gmask = fmt->Gmask;
-            Bmask = fmt->Bmask;
-            Amask = fmt->Amask;
-
-            format =
-                SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
-            if (!format) {
-                SDL_SetError("Unknown pixel format");
-                return 0;
-            }
-
-            /* Search requested format in the supported texture */
-            /* formats by current renderer                      */
-            for (it = 0; it < renderer->info.num_texture_formats; it++) {
-                if (renderer->info.texture_formats[it] == format) {
-                    break;
-                }
-            }
-
-            /* If requested format can't be found, search any best */
-            /* format which renderer provides                      */
-            if (it == renderer->info.num_texture_formats) {
-                pfmt = 0;
-                for (;;) {
-                    if (sdl_pformats[pfmt] == SDL_PIXELFORMAT_UNKNOWN) {
-                        break;
-                    }
-
-                    for (it = 0; it < renderer->info.num_texture_formats;
-                         it++) {
-                        if (renderer->info.texture_formats[it] ==
-                            sdl_pformats[pfmt]) {
-                            break;
-                        }
-                    }
-
-                    if (it != renderer->info.num_texture_formats) {
-                        /* The best format has been found */
-                        break;
-                    }
-                    pfmt++;
-                }
-
-                /* If any format can't be found, then return an error */
-                if (it == renderer->info.num_texture_formats) {
-                    SDL_SetError
-                        ("Any of the supported pixel formats can't be found");
-                    return 0;
-                }
-
-                /* Convert found pixel format back to color masks */
-                if (SDL_PixelFormatEnumToMasks
-                    (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask,
-                     &Bmask, &Amask) != SDL_TRUE) {
-                    SDL_SetError("Unknown pixel format");
-                    return 0;
-                }
-            }
-        } else {
-            /* Need a format with alpha */
-            Uint32 it;
-            int apfmt;
-
-            /* Pixel formats with alpha, sorted by best first */
-            static const Uint32 sdl_alpha_pformats[] = {
-                SDL_PIXELFORMAT_ARGB8888,
-                SDL_PIXELFORMAT_RGBA8888,
-                SDL_PIXELFORMAT_ABGR8888,
-                SDL_PIXELFORMAT_BGRA8888,
-                SDL_PIXELFORMAT_ARGB1555,
-                SDL_PIXELFORMAT_RGBA5551,
-                SDL_PIXELFORMAT_ABGR1555,
-                SDL_PIXELFORMAT_BGRA5551,
-                SDL_PIXELFORMAT_ARGB4444,
-                SDL_PIXELFORMAT_RGBA4444,
-                SDL_PIXELFORMAT_ABGR4444,
-                SDL_PIXELFORMAT_BGRA4444,
-                SDL_PIXELFORMAT_ARGB2101010,
-                SDL_PIXELFORMAT_UNKNOWN
-            };
-
-            if (surface->format->Amask) {
-                /* If surface already has alpha, then try an original */
-                /* surface format first                               */
-                bpp = fmt->BitsPerPixel;
-                Rmask = fmt->Rmask;
-                Gmask = fmt->Gmask;
-                Bmask = fmt->Bmask;
-                Amask = fmt->Amask;
-            } else {
-                bpp = 32;
-                Rmask = 0x00FF0000;
-                Gmask = 0x0000FF00;
-                Bmask = 0x000000FF;
-                Amask = 0xFF000000;
-            }
-
-            format =
-                SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
-            if (!format) {
-                SDL_SetError("Unknown pixel format");
-                return 0;
-            }
-
-            /* Search this format in the supported texture formats */
-            /* by current renderer                                 */
-            for (it = 0; it < renderer->info.num_texture_formats; it++) {
-                if (renderer->info.texture_formats[it] == format) {
-                    break;
-                }
-            }
-
-            /* If this format can't be found, search any best       */
-            /* compatible format with alpha which renderer provides */
-            if (it == renderer->info.num_texture_formats) {
-                apfmt = 0;
-                for (;;) {
-                    if (sdl_alpha_pformats[apfmt] == SDL_PIXELFORMAT_UNKNOWN) {
-                        break;
-                    }
-
-                    for (it = 0; it < renderer->info.num_texture_formats;
-                         it++) {
-                        if (renderer->info.texture_formats[it] ==
-                            sdl_alpha_pformats[apfmt]) {
-                            break;
-                        }
-                    }
-
-                    if (it != renderer->info.num_texture_formats) {
-                        /* Compatible format has been found */
-                        break;
-                    }
-                    apfmt++;
-                }
-
-                /* If compatible format can't be found, then return an error */
-                if (it == renderer->info.num_texture_formats) {
-                    SDL_SetError("Compatible pixel format can't be found");
-                    return 0;
-                }
-
-                /* Convert found pixel format back to color masks */
-                if (SDL_PixelFormatEnumToMasks
-                    (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask,
-                     &Bmask, &Amask) != SDL_TRUE) {
-                    SDL_SetError("Unknown pixel format");
-                    return 0;
-                }
-            }
-        }
-
-        format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
-        if (!format) {
-            SDL_SetError("Unknown pixel format");
-            return 0;
-        }
-    }
-
-    texture =
-        SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w,
-                          surface->h);
-    if (!texture && !requested_format) {
-        SDL_DisplayMode desktop_mode;
-        SDL_GetDesktopDisplayMode(&desktop_mode);
-        format = desktop_mode.format;
-        texture =
-            SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w,
-                              surface->h);
-    }
-    if (!texture) {
-        return 0;
-    }
-    if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask
-        && Bmask == fmt->Bmask && Amask == fmt->Amask) {
-        if (SDL_MUSTLOCK(surface)) {
-            SDL_LockSurface(surface);
-            SDL_UpdateTexture(texture, NULL, surface->pixels,
-                              surface->pitch);
-            SDL_UnlockSurface(surface);
-        } else {
-            SDL_UpdateTexture(texture, NULL, surface->pixels,
-                              surface->pitch);
-        }
-    } else {
-        SDL_PixelFormat dst_fmt;
-        SDL_Surface *dst = NULL;
-
-        /* Set up a destination surface for the texture update */
-        SDL_InitFormat(&dst_fmt, bpp, Rmask, Gmask, Bmask, Amask);
-        if (SDL_ISPIXELFORMAT_INDEXED(format)) {
-            dst_fmt.palette =
-                SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
-            if (dst_fmt.palette) {
-                /*
-                 * FIXME: Should we try to copy
-                 * fmt->palette?
-                 */
-                SDL_DitherColors(dst_fmt.palette->colors,
-                                 SDL_BITSPERPIXEL(format));
-            }
-        }
-        dst = SDL_ConvertSurface(surface, &dst_fmt, 0);
-        if (dst) {
-            SDL_UpdateTexture(texture, NULL, dst->pixels, dst->pitch);
-            SDL_FreeSurface(dst);
-        }
-        if (dst_fmt.palette) {
-            SDL_FreePalette(dst_fmt.palette);
-        }
-        if (!dst) {
-            SDL_DestroyTexture(texture);
-            return 0;
-        }
-    }
-
-    {
-        Uint8 r, g, b, a;
-        SDL_BlendMode blendMode;
-        SDL_ScaleMode scaleMode;
-
-        SDL_GetSurfaceColorMod(surface, &r, &g, &b);
-        SDL_SetTextureColorMod(texture, r, g, b);
-
-        SDL_GetSurfaceAlphaMod(surface, &a);
-        SDL_SetTextureAlphaMod(texture, a);
-
-        if (surface->map->info.flags & SDL_COPY_COLORKEY) {
-            /* We converted to a texture with alpha format */
-            SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
-        } else {
-            SDL_GetSurfaceBlendMode(surface, &blendMode);
-            SDL_SetTextureBlendMode(texture, blendMode);
-        }
-
-        SDL_GetSurfaceScaleMode(surface, &scaleMode);
-        SDL_SetTextureScaleMode(texture, scaleMode);
-    }
-
-    if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) {
-        SDL_SetTexturePalette(texture, fmt->palette->colors, 0,
-                              fmt->palette->ncolors);
-    }
-    return texture;
-}
-
-int
-SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access,
-                 int *w, int *h)
-{
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    if (format) {
-        *format = texture->format;
-    }
-    if (access) {
-        *access = texture->access;
-    }
-    if (w) {
-        *w = texture->w;
-    }
-    if (h) {
-        *h = texture->h;
-    }
-    return 0;
-}
-
-int
-SDL_QueryTexturePixels(SDL_Texture * texture, void **pixels, int *pitch)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (!renderer->QueryTexturePixels) {
-        SDL_Unsupported();
-        return -1;
-    }
-    return renderer->QueryTexturePixels(renderer, texture, pixels, pitch);
-}
-
-int
-SDL_SetTexturePalette(SDL_Texture * texture, const SDL_Color * colors,
-                      int firstcolor, int ncolors)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (!renderer->SetTexturePalette) {
-        SDL_Unsupported();
-        return -1;
-    }
-    return renderer->SetTexturePalette(renderer, texture, colors, firstcolor,
-                                       ncolors);
-}
-
-int
-SDL_GetTexturePalette(SDL_Texture * texture, SDL_Color * colors,
-                      int firstcolor, int ncolors)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (!renderer->GetTexturePalette) {
-        SDL_Unsupported();
-        return -1;
-    }
-    return renderer->GetTexturePalette(renderer, texture, colors, firstcolor,
-                                       ncolors);
-}
-
-int
-SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (!renderer->SetTextureColorMod) {
-        SDL_Unsupported();
-        return -1;
-    }
-    if (r < 255 || g < 255 || b < 255) {
-        texture->modMode |= SDL_TEXTUREMODULATE_COLOR;
-    } else {
-        texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
-    }
-    texture->r = r;
-    texture->g = g;
-    texture->b = b;
-    return renderer->SetTextureColorMod(renderer, texture);
-}
-
-int
-SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g,
-                       Uint8 * b)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (r) {
-        *r = texture->r;
-    }
-    if (g) {
-        *g = texture->g;
-    }
-    if (b) {
-        *b = texture->b;
-    }
-    return 0;
-}
-
-int
-SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (!renderer->SetTextureAlphaMod) {
-        SDL_Unsupported();
-        return -1;
-    }
-    if (alpha < 255) {
-        texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
-    } else {
-        texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
-    }
-    texture->a = alpha;
-    return renderer->SetTextureAlphaMod(renderer, texture);
-}
-
-int
-SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha)
-{
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    if (alpha) {
-        *alpha = texture->a;
-    }
-    return 0;
-}
-
-int
-SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (!renderer->SetTextureBlendMode) {
-        SDL_Unsupported();
-        return -1;
-    }
-    texture->blendMode = blendMode;
-    return renderer->SetTextureBlendMode(renderer, texture);
-}
-
-int
-SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode)
-{
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    if (blendMode) {
-        *blendMode = texture->blendMode;
-    }
-    return 0;
-}
-
-int
-SDL_SetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode scaleMode)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (!renderer->SetTextureScaleMode) {
-        SDL_Unsupported();
-        return -1;
-    }
-    texture->scaleMode = scaleMode;
-    return renderer->SetTextureScaleMode(renderer, texture);
-}
-
-int
-SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode)
-{
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    if (scaleMode) {
-        *scaleMode = texture->scaleMode;
-    }
-    return 0;
-}
-
-int
-SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect,
-                  const void *pixels, int pitch)
-{
-    SDL_Renderer *renderer;
-    SDL_Rect full_rect;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (!renderer->UpdateTexture) {
-        SDL_Unsupported();
-        return -1;
-    }
-    if (!rect) {
-        full_rect.x = 0;
-        full_rect.y = 0;
-        full_rect.w = texture->w;
-        full_rect.h = texture->h;
-        rect = &full_rect;
-    }
-    return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
-}
-
-int
-SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, int markDirty,
-                void **pixels, int *pitch)
-{
-    SDL_Renderer *renderer;
-    SDL_Rect full_rect;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
-        SDL_SetError("SDL_LockTexture(): texture must be streaming");
-        return -1;
-    }
-    renderer = texture->renderer;
-    if (!renderer->LockTexture) {
-        SDL_Unsupported();
-        return -1;
-    }
-    if (!rect) {
-        full_rect.x = 0;
-        full_rect.y = 0;
-        full_rect.w = texture->w;
-        full_rect.h = texture->h;
-        rect = &full_rect;
-    }
-    return renderer->LockTexture(renderer, texture, rect, markDirty, pixels,
-                                 pitch);
-}
-
-void
-SDL_UnlockTexture(SDL_Texture * texture)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, );
-
-    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
-        return;
-    }
-    renderer = texture->renderer;
-    if (!renderer->UnlockTexture) {
-        return;
-    }
-    renderer->UnlockTexture(renderer, texture);
-}
-
-void
-SDL_DirtyTexture(SDL_Texture * texture, int numrects,
-                 const SDL_Rect * rects)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, );
-
-    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
-        return;
-    }
-    renderer = texture->renderer;
-    if (!renderer->DirtyTexture) {
-        return;
-    }
-    renderer->DirtyTexture(renderer, texture, numrects, rects);
-}
-
-int
-SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    SDL_Renderer *renderer;
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    renderer->r = r;
-    renderer->g = g;
-    renderer->b = b;
-    renderer->a = a;
-    if (renderer->SetDrawColor) {
-        return renderer->SetDrawColor(renderer);
-    } else {
-        return 0;
-    }
-}
-
-int
-SDL_GetRenderDrawColor(Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a)
-{
-    SDL_Renderer *renderer;
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    if (r) {
-        *r = renderer->r;
-    }
-    if (g) {
-        *g = renderer->g;
-    }
-    if (b) {
-        *b = renderer->b;
-    }
-    if (a) {
-        *a = renderer->a;
-    }
-    return 0;
-}
-
-int
-SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode)
-{
-    SDL_Renderer *renderer;
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    renderer->blendMode = blendMode;
-    if (renderer->SetDrawBlendMode) {
-        return renderer->SetDrawBlendMode(renderer);
-    } else {
-        return 0;
-    }
-}
-
-int
-SDL_GetRenderDrawBlendMode(SDL_BlendMode *blendMode)
-{
-    SDL_Renderer *renderer;
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    *blendMode = renderer->blendMode;
-    return 0;
-}
-
-int
-SDL_RenderClear()
-{
-    SDL_Renderer *renderer;
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    if (!renderer->RenderClear) {
-        SDL_BlendMode blendMode = renderer->blendMode;
-        int status;
-
-        if (blendMode >= SDL_BLENDMODE_BLEND) {
-            SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
-        }
-
-        status = SDL_RenderFillRect(NULL);
-
-        if (blendMode >= SDL_BLENDMODE_BLEND) {
-            SDL_SetRenderDrawBlendMode(blendMode);
-        }
-        return status;
-    }
-    return renderer->RenderClear(renderer);
-}
-
-int
-SDL_RenderDrawPoint(int x, int y)
-{
-    SDL_Point point;
-
-    point.x = x;
-    point.y = y;
-    return SDL_RenderDrawPoints(&point, 1);
-}
-
-int
-SDL_RenderDrawPoints(const SDL_Point * points, int count)
-{
-    SDL_Renderer *renderer;
-
-    if (!points) {
-        SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
-        return -1;
-    }
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    if (!renderer->RenderDrawPoints) {
-        SDL_Unsupported();
-        return -1;
-    }
-    if (count < 1) {
-        return 0;
-    }
-    return renderer->RenderDrawPoints(renderer, points, count);
-}
-
-int
-SDL_RenderDrawLine(int x1, int y1, int x2, int y2)
-{
-    SDL_Point points[2];
-
-    points[0].x = x1;
-    points[0].y = y1;
-    points[1].x = x2;
-    points[1].y = y2;
-    return SDL_RenderDrawLines(points, 2);
-}
-
-int
-SDL_RenderDrawLines(const SDL_Point * points, int count)
-{
-    SDL_Renderer *renderer;
-
-    if (!points) {
-        SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
-        return -1;
-    }
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    if (!renderer->RenderDrawLines) {
-        SDL_Unsupported();
-        return -1;
-    }
-    if (count < 2) {
-        return 0;
-    }
-    return renderer->RenderDrawLines(renderer, points, count);
-}
-
-int
-SDL_RenderDrawRect(const SDL_Rect * rect)
-{
-    return SDL_RenderDrawRects(&rect, 1);
-}
-
-int
-SDL_RenderDrawRects(const SDL_Rect ** rects, int count)
-{
-    SDL_Renderer *renderer;
-    int i;
-
-    if (!rects) {
-        SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
-        return -1;
-    }
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    if (!renderer->RenderDrawRects) {
-        SDL_Unsupported();
-        return -1;
-    }
-    if (count < 1) {
-        return 0;
-    }
-    /* Check for NULL rect, which means fill entire window */
-    for (i = 0; i < count; ++i) {
-        if (rects[i] == NULL) {
-            SDL_Window *window = renderer->window;
-            SDL_Rect full_rect;
-            const SDL_Rect *rect;
-
-            full_rect.x = 0;
-            full_rect.y = 0;
-            full_rect.w = window->w;
-            full_rect.h = window->h;
-            rect = &full_rect;
-            return renderer->RenderDrawRects(renderer, &rect, 1);
-        }
-    }
-    return renderer->RenderDrawRects(renderer, rects, count);
-}
-
-int
-SDL_RenderFillRect(const SDL_Rect * rect)
-{
-    return SDL_RenderFillRects(&rect, 1);
-}
-
-int
-SDL_RenderFillRects(const SDL_Rect ** rects, int count)
-{
-    SDL_Renderer *renderer;
-    int i;
-
-    if (!rects) {
-        SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
-        return -1;
-    }
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    if (!renderer->RenderFillRects) {
-        SDL_Unsupported();
-        return -1;
-    }
-    if (count < 1) {
-        return 0;
-    }
-    /* Check for NULL rect, which means fill entire window */
-    for (i = 0; i < count; ++i) {
-        if (rects[i] == NULL) {
-            SDL_Window *window = renderer->window;
-            SDL_Rect full_rect;
-            const SDL_Rect *rect;
-
-            full_rect.x = 0;
-            full_rect.y = 0;
-            full_rect.w = window->w;
-            full_rect.h = window->h;
-            rect = &full_rect;
-            return renderer->RenderFillRects(renderer, &rect, 1);
-        }
-    }
-    return renderer->RenderFillRects(renderer, rects, count);
-}
-
-int
-SDL_RenderCopy(SDL_Texture * texture, const SDL_Rect * srcrect,
-               const SDL_Rect * dstrect)
-{
-    SDL_Renderer *renderer;
-    SDL_Window *window;
-    SDL_Rect real_srcrect;
-    SDL_Rect real_dstrect;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    if (texture->renderer != renderer) {
-        SDL_SetError("Texture was not created with this renderer");
-        return -1;
-    }
-    if (!renderer->RenderCopy) {
-        SDL_Unsupported();
-        return -1;
-    }
-    window = renderer->window;
-
-    real_srcrect.x = 0;
-    real_srcrect.y = 0;
-    real_srcrect.w = texture->w;
-    real_srcrect.h = texture->h;
-    if (srcrect) {
-        if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
-            return 0;
-        }
-    }
-
-    real_dstrect.x = 0;
-    real_dstrect.y = 0;
-    real_dstrect.w = window->w;
-    real_dstrect.h = window->h;
-    if (dstrect) {
-        if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) {
-            return 0;
-        }
-        /* Clip srcrect by the same amount as dstrect was clipped */
-        if (dstrect->w != real_dstrect.w) {
-            int deltax = (real_dstrect.x - dstrect->x);
-            int deltaw = (real_dstrect.w - dstrect->w);
-            real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w;
-            real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w;
-        }
-        if (dstrect->h != real_dstrect.h) {
-            int deltay = (real_dstrect.y - dstrect->y);
-            int deltah = (real_dstrect.h - dstrect->h);
-            real_srcrect.y += (deltay * real_srcrect.h) / dstrect->h;
-            real_srcrect.h += (deltah * real_srcrect.h) / dstrect->h;
-        }
-    }
-
-    return renderer->RenderCopy(renderer, texture, &real_srcrect,
-                                &real_dstrect);
-}
-
-int
-SDL_RenderReadPixels(const SDL_Rect * rect, Uint32 format,
-                     void * pixels, int pitch)
-{
-    SDL_Renderer *renderer;
-    SDL_Window *window;
-    SDL_Rect real_rect;
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    if (!renderer->RenderReadPixels) {
-        SDL_Unsupported();
-        return -1;
-    }
-    window = renderer->window;
-
-    if (!format) {
-        format = window->display->current_mode.format;
-    }
-
-    real_rect.x = 0;
-    real_rect.y = 0;
-    real_rect.w = window->w;
-    real_rect.h = window->h;
-    if (rect) {
-        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
-            return 0;
-        }
-        if (real_rect.y > rect->y) {
-            pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
-        }
-        if (real_rect.x > rect->x) {
-            Uint32 format = SDL_CurrentDisplay->current_mode.format;
-            int bpp = SDL_BYTESPERPIXEL(format);
-            pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
-        }
-    }
-
-    return renderer->RenderReadPixels(renderer, &real_rect,
-                                      format, pixels, pitch);
-}
-
-int
-SDL_RenderWritePixels(const SDL_Rect * rect, Uint32 format,
-                      const void * pixels, int pitch)
-{
-    SDL_Renderer *renderer;
-    SDL_Window *window;
-    SDL_Rect real_rect;
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer) {
-        return -1;
-    }
-    if (!renderer->RenderWritePixels) {
-        SDL_Unsupported();
-        return -1;
-    }
-    window = renderer->window;
-
-    if (!format) {
-        format = window->display->current_mode.format;
-    }
-
-    real_rect.x = 0;
-    real_rect.y = 0;
-    real_rect.w = window->w;
-    real_rect.h = window->h;
-    if (rect) {
-        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
-            return 0;
-        }
-        if (real_rect.y > rect->y) {
-            pixels = (const Uint8 *)pixels + pitch * (real_rect.y - rect->y);
-        }
-        if (real_rect.x > rect->x) {
-            Uint32 format = SDL_CurrentDisplay->current_mode.format;
-            int bpp = SDL_BYTESPERPIXEL(format);
-            pixels = (const Uint8 *)pixels + bpp * (real_rect.x - rect->x);
-        }
-    }
-
-    return renderer->RenderWritePixels(renderer, &real_rect,
-                                       format, pixels, pitch);
-}
-
-void
-SDL_RenderPresent(void)
-{
-    SDL_Renderer *renderer;
-
-    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
-    if (!renderer || !renderer->RenderPresent) {
-        return;
-    }
-#if SDL_VIDEO_DRIVER_WINDOWS
-    IME_Present((SDL_VideoData *)_this->driverdata);
-#endif
-    renderer->RenderPresent(renderer);
-}
-
-void
-SDL_DestroyTexture(SDL_Texture * texture)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, );
-    texture->magic = NULL;
-
-    renderer = texture->renderer;
-    if (texture->next) {
-        texture->next->prev = texture->prev;
-    }
-    if (texture->prev) {
-        texture->prev->next = texture->next;
-    } else {
-        renderer->textures = texture->next;
-    }
-
-    renderer->DestroyTexture(renderer, texture);
-    SDL_free(texture);
-}
-
-void
-SDL_DestroyRenderer(SDL_Window * window)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_WINDOW_MAGIC(window, );
-
-    renderer = window->renderer;
-    if (!renderer) {
-        return;
-    }
-
-    /* Free existing textures for this renderer */
-    while (renderer->textures) {
-        SDL_DestroyTexture(renderer->textures);
-    }
-
-    /* Free the renderer instance */
-    renderer->DestroyRenderer(renderer);
-
-    /* Clear references */
-    window->renderer = NULL;
-    if (SDL_CurrentDisplay->current_renderer == renderer) {
-        SDL_CurrentDisplay->current_renderer = NULL;
-    }
-}
-
 SDL_bool
 SDL_IsScreenSaverEnabled()
 {
@@ -2815,11 +1799,6 @@
         while (display->windows) {
             SDL_DestroyWindow(display->windows);
         }
-        if (display->render_drivers) {
-            SDL_free(display->render_drivers);
-            display->render_drivers = NULL;
-        }
-        display->num_render_drivers = 0;
     }
     _this->VideoQuit(_this);
 
@@ -2839,10 +1818,6 @@
             SDL_free(display->desktop_mode.driverdata);
             display->desktop_mode.driverdata = NULL;
         }
-        if (display->palette) {
-            SDL_FreePalette(display->palette);
-            display->palette = NULL;
-        }
         if (display->gamma) {
             SDL_free(display->gamma);
             display->gamma = NULL;
@@ -2934,7 +1909,7 @@
 SDL_bool
 SDL_GL_ExtensionSupported(const char *extension)
 {
-#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES
+#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
     const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
     const char *extensions;
     const char *start;
@@ -2988,7 +1963,7 @@
 int
 SDL_GL_SetAttribute(SDL_GLattr attr, int value)
 {
-#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES
+#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
     int retval;
 
     if (!_this) {
@@ -3069,7 +2044,7 @@
 int
 SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
 {
-#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES
+#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
     void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
     GLenum(APIENTRY * glGetErrorFunc) (void);
     GLenum attrib = 0;
@@ -3089,9 +2064,6 @@
     *value = 0;
 
     switch (attr) {
-    case SDL_GL_RETAINED_BACKING:
-        *value = _this->gl_config.retained_backing;
-        return 0;
     case SDL_GL_RED_SIZE:
         attrib = GL_RED_BITS;
         break;
@@ -3105,7 +2077,7 @@
         attrib = GL_ALPHA_BITS;
         break;
     case SDL_GL_DOUBLEBUFFER:
-#ifndef SDL_VIDEO_OPENGL_ES
+#if SDL_VIDEO_OPENGL
         attrib = GL_DOUBLEBUFFER;
         break;
 #else
@@ -3121,7 +2093,7 @@
     case SDL_GL_STENCIL_SIZE:
         attrib = GL_STENCIL_BITS;
         break;
-#ifndef SDL_VIDEO_OPENGL_ES
+#if SDL_VIDEO_OPENGL
     case SDL_GL_ACCUM_RED_SIZE:
         attrib = GL_ACCUM_RED_BITS;
         break;
@@ -3148,14 +2120,14 @@
         return 0;
 #endif
     case SDL_GL_MULTISAMPLEBUFFERS:
-#ifndef SDL_VIDEO_OPENGL_ES
+#if SDL_VIDEO_OPENGL
         attrib = GL_SAMPLE_BUFFERS_ARB;
 #else
         attrib = GL_SAMPLE_BUFFERS;
 #endif
         break;
     case SDL_GL_MULTISAMPLESAMPLES:
-#ifndef SDL_VIDEO_OPENGL_ES
+#if SDL_VIDEO_OPENGL
         attrib = GL_SAMPLES_ARB;
 #else
         attrib = GL_SAMPLES;
@@ -3188,6 +2160,21 @@
             *value = (_this->gl_config.accelerated != 0);
             return 0;
         }
+    case SDL_GL_RETAINED_BACKING:
+        {
+            *value = _this->gl_config.retained_backing;
+            return 0;
+        }
+    case SDL_GL_CONTEXT_MAJOR_VERSION:
+        {
+            *value = _this->gl_config.major_version;
+            return 0;
+        }
+    case SDL_GL_CONTEXT_MINOR_VERSION:
+        {
+            *value = _this->gl_config.minor_version;
+            return 0;
+        }
     default:
         SDL_SetError("Unknown OpenGL attribute");
         return -1;
--- a/src/video/SDL_yuv_mmx.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,432 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
-
-#include "SDL_stdinc.h"
-
-#include "mmx.h"
-
-/* *INDENT-OFF* */
-
-static mmx_t MMX_0080w    = { .ud = {0x00800080, 0x00800080} };
-static mmx_t MMX_00FFw    = { .ud = {0x00ff00ff, 0x00ff00ff} };
-static mmx_t MMX_FF00w    = { .ud = {0xff00ff00, 0xff00ff00} };
-
-static mmx_t MMX_Ycoeff   = { .uw = {0x004a, 0x004a, 0x004a, 0x004a} };
-
-static mmx_t MMX_UbluRGB  = { .uw = {0x0072, 0x0072, 0x0072, 0x0072} };
-static mmx_t MMX_VredRGB  = { .uw = {0x0059, 0x0059, 0x0059, 0x0059} };
-static mmx_t MMX_UgrnRGB  = { .uw = {0xffea, 0xffea, 0xffea, 0xffea} };
-static mmx_t MMX_VgrnRGB  = { .uw = {0xffd2, 0xffd2, 0xffd2, 0xffd2} };
-
-static mmx_t MMX_Ublu5x5  = { .uw = {0x0081, 0x0081, 0x0081, 0x0081} };
-static mmx_t MMX_Vred5x5  = { .uw = {0x0066, 0x0066, 0x0066, 0x0066} };
-static mmx_t MMX_Ugrn565  = { .uw = {0xffe8, 0xffe8, 0xffe8, 0xffe8} };
-static mmx_t MMX_Vgrn565  = { .uw = {0xffcd, 0xffcd, 0xffcd, 0xffcd} };
-
-static mmx_t MMX_red565   = { .uw = {0xf800, 0xf800, 0xf800, 0xf800} };
-static mmx_t MMX_grn565   = { .uw = {0x07e0, 0x07e0, 0x07e0, 0x07e0} };
-
-/**
-   This MMX assembler is my first assembler/MMX program ever.
-   Thus it maybe buggy.
-   Send patches to:
-   mvogt@rhrk.uni-kl.de
-
-   After it worked fine I have "obfuscated" the code a bit to have
-   more parallism in the MMX units. This means I moved
-   initilisation around and delayed other instruction.
-   Performance measurement did not show that this brought any advantage
-   but in theory it _should_ be faster this way.
-
-   The overall performanve gain to the C based dither was 30%-40%.
-   The MMX routine calculates 256bit=8RGB values in each cycle
-   (4 for row1 & 4 for row2)
-
-   The red/green/blue.. coefficents are taken from the mpeg_play 
-   player. They look nice, but I dont know if you can have
-   better values, to avoid integer rounding errors.
-   
-
-   IMPORTANT:
-   ==========
-
-   It is a requirement that the cr/cb/lum are 8 byte aligned and
-   the out are 16byte aligned or you will/may get segfaults
-
-*/
-
-void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
-                              unsigned char *lum, unsigned char *cr,
-                              unsigned char *cb, unsigned char *out,
-                              int rows, int cols, int mod )
-{
-    Uint32 *row1;
-    Uint32 *row2;
-
-    unsigned char* y = lum +cols*rows;    // Pointer to the end
-    int x = 0;
-    row1 = (Uint32 *)out;                 // 32 bit target
-    row2 = (Uint32 *)out+cols+mod;        // start of second row
-    mod = (mod+cols+mod)*4;               // increment for row1 in byte
-
-    __asm__ __volatile__ (
-        // tap dance to workaround the inability to use %%ebx at will...
-        //  move one thing to the stack...
-        "pushl $0\n"  // save a slot on the stack.
-        "pushl %%ebx\n"  // save %%ebx.
-        "movl %0, %%ebx\n"  // put the thing in ebx.
-        "movl %%ebx,4(%%esp)\n"  // put the thing in the stack slot.
-        "popl %%ebx\n"  // get back %%ebx (the PIC register).
-
-        ".align 8\n"
-        "1:\n"
-
-        // create Cr (result in mm1)
-        "pushl %%ebx\n"
-        "movl 4(%%esp),%%ebx\n"
-        "movd (%%ebx),%%mm1\n"   //         0  0  0  0  v3 v2 v1 v0
-        "popl %%ebx\n"
-        "pxor %%mm7,%%mm7\n"      //         00 00 00 00 00 00 00 00
-        "movd (%2), %%mm2\n"           //    0  0  0  0 l3 l2 l1 l0
-        "punpcklbw %%mm7,%%mm1\n" //         0  v3 0  v2 00 v1 00 v0
-        "punpckldq %%mm1,%%mm1\n" //         00 v1 00 v0 00 v1 00 v0
-        "psubw %9,%%mm1\n"        // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0
-
-        // create Cr_g (result in mm0)
-        "movq %%mm1,%%mm0\n"           // r1 r1 r0 r0 r1 r1 r0 r0
-        "pmullw %10,%%mm0\n"           // red*-46dec=0.7136*64
-        "pmullw %11,%%mm1\n"           // red*89dec=1.4013*64
-        "psraw  $6, %%mm0\n"           // red=red/64
-        "psraw  $6, %%mm1\n"           // red=red/64
-
-        // create L1 L2 (result in mm2,mm4)
-        // L2=lum+cols
-        "movq (%2,%4),%%mm3\n"         //    0  0  0  0 L3 L2 L1 L0
-        "punpckldq %%mm3,%%mm2\n"      //   L3 L2 L1 L0 l3 l2 l1 l0
-        "movq %%mm2,%%mm4\n"           //   L3 L2 L1 L0 l3 l2 l1 l0
-        "pand %12,%%mm2\n"             //   L3 0  L1  0 l3  0 l1  0
-        "pand %13,%%mm4\n"             //   0  L2  0 L0  0 l2  0 l0
-        "psrlw $8,%%mm2\n"             //   0  L3  0 L1  0 l3  0 l1
-
-        // create R (result in mm6)
-        "movq %%mm2,%%mm5\n"           //   0 L3  0 L1  0 l3  0 l1
-        "movq %%mm4,%%mm6\n"           //   0 L2  0 L0  0 l2  0 l0
-        "paddsw  %%mm1, %%mm5\n"       // lum1+red:x R3 x R1 x r3 x r1
-        "paddsw  %%mm1, %%mm6\n"       // lum1+red:x R2 x R0 x r2 x r0
-        "packuswb %%mm5,%%mm5\n"       //  R3 R1 r3 r1 R3 R1 r3 r1
-        "packuswb %%mm6,%%mm6\n"       //  R2 R0 r2 r0 R2 R0 r2 r0
-        "pxor %%mm7,%%mm7\n"      //         00 00 00 00 00 00 00 00
-        "punpcklbw %%mm5,%%mm6\n"      //  R3 R2 R1 R0 r3 r2 r1 r0
-
-        // create Cb (result in mm1)
-        "movd (%1), %%mm1\n"      //         0  0  0  0  u3 u2 u1 u0
-        "punpcklbw %%mm7,%%mm1\n" //         0  u3 0  u2 00 u1 00 u0
-        "punpckldq %%mm1,%%mm1\n" //         00 u1 00 u0 00 u1 00 u0
-        "psubw %9,%%mm1\n"        // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0
-
-        // create Cb_g (result in mm5)
-        "movq %%mm1,%%mm5\n"            // u1 u1 u0 u0 u1 u1 u0 u0
-        "pmullw %14,%%mm5\n"            // blue*-109dec=1.7129*64
-        "pmullw %15,%%mm1\n"            // blue*114dec=1.78125*64
-        "psraw  $6, %%mm5\n"            // blue=red/64
-        "psraw  $6, %%mm1\n"            // blue=blue/64
-
-        // create G (result in mm7)
-        "movq %%mm2,%%mm3\n"      //   0  L3  0 L1  0 l3  0 l1
-        "movq %%mm4,%%mm7\n"      //   0  L2  0 L0  0 l2  0 l1
-        "paddsw  %%mm5, %%mm3\n"  // lum1+Cb_g:x G3t x G1t x g3t x g1t
-        "paddsw  %%mm5, %%mm7\n"  // lum1+Cb_g:x G2t x G0t x g2t x g0t
-        "paddsw  %%mm0, %%mm3\n"  // lum1+Cr_g:x G3  x G1  x g3  x g1
-        "paddsw  %%mm0, %%mm7\n"  // lum1+blue:x G2  x G0  x g2  x g0
-        "packuswb %%mm3,%%mm3\n"  // G3 G1 g3 g1 G3 G1 g3 g1
-        "packuswb %%mm7,%%mm7\n"  // G2 G0 g2 g0 G2 G0 g2 g0
-        "punpcklbw %%mm3,%%mm7\n" // G3 G2 G1 G0 g3 g2 g1 g0
-
-        // create B (result in mm5)
-        "movq %%mm2,%%mm3\n"         //   0  L3  0 L1  0 l3  0 l1
-        "movq %%mm4,%%mm5\n"         //   0  L2  0 L0  0 l2  0 l1
-        "paddsw  %%mm1, %%mm3\n"     // lum1+blue:x B3 x B1 x b3 x b1
-        "paddsw  %%mm1, %%mm5\n"     // lum1+blue:x B2 x B0 x b2 x b0
-        "packuswb %%mm3,%%mm3\n"     // B3 B1 b3 b1 B3 B1 b3 b1
-        "packuswb %%mm5,%%mm5\n"     // B2 B0 b2 b0 B2 B0 b2 b0
-        "punpcklbw %%mm3,%%mm5\n"    // B3 B2 B1 B0 b3 b2 b1 b0
-
-        // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb)
-
-        "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
-        "pxor %%mm4,%%mm4\n"           //  0  0  0  0  0  0  0  0
-        "movq %%mm6,%%mm1\n"           // R3 R2 R1 R0 r3 r2 r1 r0
-        "movq %%mm5,%%mm3\n"           // B3 B2 B1 B0 b3 b2 b1 b0
-
-        // process lower lum
-        "punpcklbw %%mm4,%%mm1\n"      //  0 r3  0 r2  0 r1  0 r0
-        "punpcklbw %%mm4,%%mm3\n"      //  0 b3  0 b2  0 b1  0 b0
-        "movq %%mm1,%%mm2\n"           //  0 r3  0 r2  0 r1  0 r0
-        "movq %%mm3,%%mm0\n"           //  0 b3  0 b2  0 b1  0 b0
-        "punpcklwd %%mm1,%%mm3\n"      //  0 r1  0 b1  0 r0  0 b0
-        "punpckhwd %%mm2,%%mm0\n"      //  0 r3  0 b3  0 r2  0 b2
-
-        "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
-        "movq %%mm7,%%mm1\n"           // G3 G2 G1 G0 g3 g2 g1 g0
-        "punpcklbw %%mm1,%%mm2\n"      // g3  0 g2  0 g1  0 g0  0
-        "punpcklwd %%mm4,%%mm2\n"      //  0  0 g1  0  0  0 g0  0
-        "por %%mm3, %%mm2\n"          //  0 r1 g1 b1  0 r0 g0 b0
-        "movq %%mm2,(%3)\n"          // wrote out ! row1
-
-        "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
-        "punpcklbw %%mm1,%%mm4\n"      // g3  0 g2  0 g1  0 g0  0
-        "punpckhwd %%mm2,%%mm4\n"      //  0  0 g3  0  0  0 g2  0
-        "por %%mm0, %%mm4\n"          //  0 r3 g3 b3  0 r2 g2 b2
-        "movq %%mm4,8(%3)\n"         // wrote out ! row1
-
-        // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb)
-        // this can be done "destructive"
-        "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
-        "punpckhbw %%mm2,%%mm6\n"      //  0 R3  0 R2  0 R1  0 R0
-        "punpckhbw %%mm1,%%mm5\n"      // G3 B3 G2 B2 G1 B1 G0 B0
-        "movq %%mm5,%%mm1\n"           // G3 B3 G2 B2 G1 B1 G0 B0
-        "punpcklwd %%mm6,%%mm1\n"      //  0 R1 G1 B1  0 R0 G0 B0
-        "movq %%mm1,(%5)\n"          // wrote out ! row2
-        "punpckhwd %%mm6,%%mm5\n"      //  0 R3 G3 B3  0 R2 G2 B2
-        "movq %%mm5,8(%5)\n"         // wrote out ! row2
-
-        "addl $4,%2\n"            // lum+4
-        "leal 16(%3),%3\n"        // row1+16
-        "leal 16(%5),%5\n"        // row2+16
-        "addl $2,(%%esp)\n"        // cr+2
-        "addl $2,%1\n"           // cb+2
-
-        "addl $4,%6\n"            // x+4
-        "cmpl %4,%6\n"
-
-        "jl 1b\n"
-        "addl %4,%2\n" // lum += cols
-        "addl %8,%3\n" // row1+= mod
-        "addl %8,%5\n" // row2+= mod
-        "movl $0,%6\n" // x=0
-        "cmpl %7,%2\n"
-        "jl 1b\n"
-
-        "addl $4,%%esp\n"  // get rid of the stack slot we reserved.
-        "emms\n"  // reset MMX registers.
-        :
-        : "m" (cr), "r"(cb),"r"(lum),
-          "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
-          "m"(MMX_0080w),"m"(MMX_VgrnRGB),"m"(MMX_VredRGB),
-          "m"(MMX_FF00w),"m"(MMX_00FFw),"m"(MMX_UgrnRGB),
-          "m"(MMX_UbluRGB)
-    );
-}
-
-void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
-                             unsigned char *lum, unsigned char *cr,
-                             unsigned char *cb, unsigned char *out,
-                             int rows, int cols, int mod )
-{
-    Uint16 *row1;
-    Uint16 *row2;
-
-    unsigned char* y = lum +cols*rows;    /* Pointer to the end */
-    int x = 0;
-    row1 = (Uint16 *)out;                 /* 16 bit target */
-    row2 = (Uint16 *)out+cols+mod;        /* start of second row  */
-    mod = (mod+cols+mod)*2;               /* increment for row1 in byte */
-
-    __asm__ __volatile__(
-        // tap dance to workaround the inability to use %%ebx at will...
-        //  move one thing to the stack...
-        "pushl $0\n"  // save a slot on the stack.
-        "pushl %%ebx\n"  // save %%ebx.
-        "movl %0, %%ebx\n"  // put the thing in ebx.
-        "movl %%ebx, 4(%%esp)\n"  // put the thing in the stack slot.
-        "popl %%ebx\n"  // get back %%ebx (the PIC register).
-
-        ".align 8\n"
-        "1:\n"
-
-        "movd           (%1),                   %%mm0\n" // 4 Cb         0  0  0  0 u3 u2 u1 u0
-        "pxor           %%mm7,                  %%mm7\n"
-        "pushl %%ebx\n"
-        "movl 4(%%esp), %%ebx\n"
-        "movd (%%ebx), %%mm1\n"   // 4 Cr                0  0  0  0 v3 v2 v1 v0
-        "popl %%ebx\n"
-
-        "punpcklbw      %%mm7,                  %%mm0\n" // 4 W cb   0 u3  0 u2  0 u1  0 u0
-        "punpcklbw      %%mm7,                  %%mm1\n" // 4 W cr   0 v3  0 v2  0 v1  0 v0
-        "psubw          %9,                     %%mm0\n"
-        "psubw          %9,                     %%mm1\n"
-        "movq           %%mm0,                  %%mm2\n" // Cb                   0 u3  0 u2  0 u1  0 u0
-        "movq           %%mm1,                  %%mm3\n" // Cr
-        "pmullw         %10,                    %%mm2\n" // Cb2green 0 R3  0 R2  0 R1  0 R0
-        "movq           (%2),                   %%mm6\n" // L1      l7 L6 L5 L4 L3 L2 L1 L0
-        "pmullw         %11,                    %%mm0\n" // Cb2blue
-        "pand           %12,                    %%mm6\n" // L1      00 L6 00 L4 00 L2 00 L0
-        "pmullw         %13,                    %%mm3\n" // Cr2green
-        "movq           (%2),                   %%mm7\n" // L2
-        "pmullw         %14,                    %%mm1\n" // Cr2red
-        "psrlw          $8,                     %%mm7\n"        // L2           00 L7 00 L5 00 L3 00 L1
-        "pmullw         %15,                    %%mm6\n" // lum1
-        "paddw          %%mm3,                  %%mm2\n" // Cb2green + Cr2green == green
-        "pmullw         %15,                    %%mm7\n" // lum2
-
-        "movq           %%mm6,                  %%mm4\n" // lum1
-        "paddw          %%mm0,                  %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0
-        "movq           %%mm4,                  %%mm5\n" // lum1
-        "paddw          %%mm1,                  %%mm4\n" // lum1 +red  00 R6 00 R4 00 R2 00 R0
-        "paddw          %%mm2,                  %%mm5\n" // lum1 +green 00 G6 00 G4 00 G2 00 G0
-        "psraw          $6,                     %%mm4\n" // R1 0 .. 64
-        "movq           %%mm7,                  %%mm3\n" // lum2                       00 L7 00 L5 00 L3 00 L1
-        "psraw          $6,                     %%mm5\n" // G1  - .. +
-        "paddw          %%mm0,                  %%mm7\n" // Lum2 +blue 00 B7 00 B5 00 B3 00 B1
-        "psraw          $6,                     %%mm6\n" // B1         0 .. 64
-        "packuswb       %%mm4,                  %%mm4\n" // R1 R1
-        "packuswb       %%mm5,                  %%mm5\n" // G1 G1
-        "packuswb       %%mm6,                  %%mm6\n" // B1 B1
-        "punpcklbw      %%mm4,                  %%mm4\n"
-        "punpcklbw      %%mm5,                  %%mm5\n"
-
-        "pand           %16,                    %%mm4\n"
-        "psllw          $3,                     %%mm5\n" // GREEN       1
-        "punpcklbw      %%mm6,                  %%mm6\n"
-        "pand           %17,                    %%mm5\n"
-        "pand           %16,                    %%mm6\n"
-        "por            %%mm5,                  %%mm4\n" //
-        "psrlw          $11,                    %%mm6\n" // BLUE        1
-        "movq           %%mm3,                  %%mm5\n" // lum2
-        "paddw          %%mm1,                  %%mm3\n" // lum2 +red      00 R7 00 R5 00 R3 00 R1
-        "paddw          %%mm2,                  %%mm5\n" // lum2 +green 00 G7 00 G5 00 G3 00 G1
-        "psraw          $6,                     %%mm3\n" // R2
-        "por            %%mm6,                  %%mm4\n" // MM4
-        "psraw          $6,                     %%mm5\n" // G2
-        "movq           (%2, %4),               %%mm6\n" // L3 load lum2
-        "psraw          $6,                     %%mm7\n"
-        "packuswb       %%mm3,                  %%mm3\n"
-        "packuswb       %%mm5,                  %%mm5\n"
-        "packuswb       %%mm7,                  %%mm7\n"
-        "pand           %12,                    %%mm6\n" // L3
-        "punpcklbw      %%mm3,                  %%mm3\n"
-        "punpcklbw      %%mm5,                  %%mm5\n"
-        "pmullw         %15,                    %%mm6\n" // lum3
-        "punpcklbw      %%mm7,                  %%mm7\n"
-        "psllw          $3,                     %%mm5\n" // GREEN 2
-        "pand           %16,                    %%mm7\n"
-        "pand           %16,                    %%mm3\n"
-        "psrlw          $11,                    %%mm7\n" // BLUE  2
-        "pand           %17,                    %%mm5\n"
-        "por            %%mm7,                  %%mm3\n"
-        "movq           (%2,%4),                %%mm7\n" // L4 load lum2
-        "por            %%mm5,                  %%mm3\n" //
-        "psrlw          $8,                     %%mm7\n" // L4
-        "movq           %%mm4,                  %%mm5\n"
-        "punpcklwd      %%mm3,                  %%mm4\n"
-        "pmullw         %15,                    %%mm7\n" // lum4
-        "punpckhwd      %%mm3,                  %%mm5\n"
-
-        "movq           %%mm4,                  (%3)\n"  // write row1
-        "movq           %%mm5,                  8(%3)\n" // write row1
-
-        "movq           %%mm6,                  %%mm4\n" // Lum3
-        "paddw          %%mm0,                  %%mm6\n" // Lum3 +blue
-
-        "movq           %%mm4,                  %%mm5\n" // Lum3
-        "paddw          %%mm1,                  %%mm4\n" // Lum3 +red
-        "paddw          %%mm2,                  %%mm5\n" // Lum3 +green
-        "psraw          $6,                     %%mm4\n"
-        "movq           %%mm7,                  %%mm3\n" // Lum4
-        "psraw          $6,                     %%mm5\n"
-        "paddw          %%mm0,                  %%mm7\n" // Lum4 +blue
-        "psraw          $6,                     %%mm6\n" // Lum3 +blue
-        "movq           %%mm3,                  %%mm0\n" // Lum4
-        "packuswb       %%mm4,                  %%mm4\n"
-        "paddw          %%mm1,                  %%mm3\n" // Lum4 +red
-        "packuswb       %%mm5,                  %%mm5\n"
-        "paddw          %%mm2,                  %%mm0\n" // Lum4 +green
-        "packuswb       %%mm6,                  %%mm6\n"
-        "punpcklbw      %%mm4,                  %%mm4\n"
-        "punpcklbw      %%mm5,                  %%mm5\n"
-        "punpcklbw      %%mm6,                  %%mm6\n"
-        "psllw          $3,                     %%mm5\n" // GREEN 3
-        "pand           %16,                    %%mm4\n"
-        "psraw          $6,                     %%mm3\n" // psr 6
-        "psraw          $6,                     %%mm0\n"
-        "pand           %16,                    %%mm6\n" // BLUE
-        "pand           %17,                    %%mm5\n"
-        "psrlw          $11,                    %%mm6\n" // BLUE  3
-        "por            %%mm5,                  %%mm4\n"
-        "psraw          $6,                     %%mm7\n"
-        "por            %%mm6,                  %%mm4\n"
-        "packuswb       %%mm3,                  %%mm3\n"
-        "packuswb       %%mm0,                  %%mm0\n"
-        "packuswb       %%mm7,                  %%mm7\n"
-        "punpcklbw      %%mm3,                  %%mm3\n"
-        "punpcklbw      %%mm0,                  %%mm0\n"
-        "punpcklbw      %%mm7,                  %%mm7\n"
-        "pand           %16,                    %%mm3\n"
-        "pand           %16,                    %%mm7\n" // BLUE
-        "psllw          $3,                     %%mm0\n" // GREEN 4
-        "psrlw          $11,                    %%mm7\n"
-        "pand           %17,                    %%mm0\n"
-        "por            %%mm7,                  %%mm3\n"
-        "por            %%mm0,                  %%mm3\n"
-
-        "movq           %%mm4,                  %%mm5\n"
-
-        "punpcklwd      %%mm3,                  %%mm4\n"
-        "punpckhwd      %%mm3,                  %%mm5\n"
-
-        "movq           %%mm4,                  (%5)\n"
-        "movq           %%mm5,                  8(%5)\n"
-
-        "addl           $8,                     %6\n"
-        "addl           $8,                     %2\n"
-        "addl           $4,                     (%%esp)\n"
-        "addl           $4,                     %1\n"
-        "cmpl           %4,                     %6\n"
-        "leal           16(%3),                 %3\n"
-        "leal           16(%5),%5\n" // row2+16
-
-        "jl             1b\n"
-        "addl           %4,     %2\n" // lum += cols
-        "addl           %8,     %3\n" // row1+= mod
-        "addl           %8,     %5\n" // row2+= mod
-        "movl           $0,     %6\n" // x=0
-        "cmpl           %7,     %2\n"
-        "jl             1b\n"
-        "addl $4, %%esp\n"  // get rid of the stack slot we reserved.
-        "emms\n"
-        :
-        : "m" (cr), "r"(cb),"r"(lum),
-          "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
-          "m"(MMX_0080w),"m"(MMX_Ugrn565),"m"(MMX_Ublu5x5),
-          "m"(MMX_00FFw),"m"(MMX_Vgrn565),"m"(MMX_Vred5x5),
-          "m"(MMX_Ycoeff),"m"(MMX_red565),"m"(MMX_grn565)
-    );
-}
-
-/* *INDENT-ON* */
-
-#endif /* GCC3 i386 inline assembly */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_yuv_sw.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1322 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* This is the software implementation of the YUV texture support */
-
-/* This code was derived from code carrying the following copyright notices:
-
- * Copyright (c) 1995 The Regents of the University of California.
- * All rights reserved.
- * 
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice and the following
- * two paragraphs appear in all copies of this software.
- * 
- * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
- * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
- * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
- * Copyright (c) 1995 Erik Corry
- * All rights reserved.
- * 
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice and the following
- * two paragraphs appear in all copies of this software.
- * 
- * IN NO EVENT SHALL ERIK CORRY BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
- * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
- * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ERIK CORRY HAS BEEN ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * ERIK CORRY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
- * BASIS, AND ERIK CORRY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
- * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
- * Portions of this software Copyright (c) 1995 Brown University.
- * All rights reserved.
- * 
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement
- * is hereby granted, provided that the above copyright notice and the
- * following two paragraphs appear in all copies of this software.
- * 
- * IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
- * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF BROWN
- * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * BROWN UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
- * BASIS, AND BROWN UNIVERSITY HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
- * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- */
-
-#include "SDL_video.h"
-#include "SDL_cpuinfo.h"
-#include "SDL_yuv_sw_c.h"
-
-
-/* The colorspace conversion functions */
-
-#if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
-extern void Color565DitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix,
-                                    unsigned char *lum, unsigned char *cr,
-                                    unsigned char *cb, unsigned char *out,
-                                    int rows, int cols, int mod);
-extern void ColorRGBDitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix,
-                                    unsigned char *lum, unsigned char *cr,
-                                    unsigned char *cb, unsigned char *out,
-                                    int rows, int cols, int mod);
-#endif
-
-static void
-Color16DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned short *row1;
-    unsigned short *row2;
-    unsigned char *lum2;
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-
-    row1 = (unsigned short *) out;
-    row2 = row1 + cols + mod;
-    lum2 = lum + cols;
-
-    mod += cols + mod;
-
-    y = rows / 2;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            ++cr;
-            ++cb;
-
-            L = *lum++;
-            *row1++ = (unsigned short) (rgb_2_pix[L + cr_r] |
-                                        rgb_2_pix[L + crb_g] |
-                                        rgb_2_pix[L + cb_b]);
-
-            L = *lum++;
-            *row1++ = (unsigned short) (rgb_2_pix[L + cr_r] |
-                                        rgb_2_pix[L + crb_g] |
-                                        rgb_2_pix[L + cb_b]);
-
-
-            /* Now, do second row.  */
-
-            L = *lum2++;
-            *row2++ = (unsigned short) (rgb_2_pix[L + cr_r] |
-                                        rgb_2_pix[L + crb_g] |
-                                        rgb_2_pix[L + cb_b]);
-
-            L = *lum2++;
-            *row2++ = (unsigned short) (rgb_2_pix[L + cr_r] |
-                                        rgb_2_pix[L + crb_g] |
-                                        rgb_2_pix[L + cb_b]);
-        }
-
-        /*
-         * These values are at the start of the next line, (due
-         * to the ++'s above),but they need to be at the start
-         * of the line after that.
-         */
-        lum += cols;
-        lum2 += cols;
-        row1 += mod;
-        row2 += mod;
-    }
-}
-
-static void
-Color24DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned int value;
-    unsigned char *row1;
-    unsigned char *row2;
-    unsigned char *lum2;
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-
-    row1 = out;
-    row2 = row1 + cols * 3 + mod * 3;
-    lum2 = lum + cols;
-
-    mod += cols + mod;
-    mod *= 3;
-
-    y = rows / 2;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            ++cr;
-            ++cb;
-
-            L = *lum++;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            *row1++ = (value) & 0xFF;
-            *row1++ = (value >> 8) & 0xFF;
-            *row1++ = (value >> 16) & 0xFF;
-
-            L = *lum++;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            *row1++ = (value) & 0xFF;
-            *row1++ = (value >> 8) & 0xFF;
-            *row1++ = (value >> 16) & 0xFF;
-
-
-            /* Now, do second row.  */
-
-            L = *lum2++;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            *row2++ = (value) & 0xFF;
-            *row2++ = (value >> 8) & 0xFF;
-            *row2++ = (value >> 16) & 0xFF;
-
-            L = *lum2++;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            *row2++ = (value) & 0xFF;
-            *row2++ = (value >> 8) & 0xFF;
-            *row2++ = (value >> 16) & 0xFF;
-        }
-
-        /*
-         * These values are at the start of the next line, (due
-         * to the ++'s above),but they need to be at the start
-         * of the line after that.
-         */
-        lum += cols;
-        lum2 += cols;
-        row1 += mod;
-        row2 += mod;
-    }
-}
-
-static void
-Color32DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned int *row1;
-    unsigned int *row2;
-    unsigned char *lum2;
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-
-    row1 = (unsigned int *) out;
-    row2 = row1 + cols + mod;
-    lum2 = lum + cols;
-
-    mod += cols + mod;
-
-    y = rows / 2;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            ++cr;
-            ++cb;
-
-            L = *lum++;
-            *row1++ = (rgb_2_pix[L + cr_r] |
-                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-
-            L = *lum++;
-            *row1++ = (rgb_2_pix[L + cr_r] |
-                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-
-
-            /* Now, do second row.  */
-
-            L = *lum2++;
-            *row2++ = (rgb_2_pix[L + cr_r] |
-                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-
-            L = *lum2++;
-            *row2++ = (rgb_2_pix[L + cr_r] |
-                       rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-        }
-
-        /*
-         * These values are at the start of the next line, (due
-         * to the ++'s above),but they need to be at the start
-         * of the line after that.
-         */
-        lum += cols;
-        lum2 += cols;
-        row1 += mod;
-        row2 += mod;
-    }
-}
-
-/*
- * In this function I make use of a nasty trick. The tables have the lower
- * 16 bits replicated in the upper 16. This means I can write ints and get
- * the horisontal doubling for free (almost).
- */
-static void
-Color16DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned int *row1 = (unsigned int *) out;
-    const int next_row = cols + (mod / 2);
-    unsigned int *row2 = row1 + 2 * next_row;
-    unsigned char *lum2;
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-
-    lum2 = lum + cols;
-
-    mod = (next_row * 3) + (mod / 2);
-
-    y = rows / 2;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            ++cr;
-            ++cb;
-
-            L = *lum++;
-            row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] |
-                                        rgb_2_pix[L + crb_g] |
-                                        rgb_2_pix[L + cb_b]);
-            row1++;
-
-            L = *lum++;
-            row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] |
-                                        rgb_2_pix[L + crb_g] |
-                                        rgb_2_pix[L + cb_b]);
-            row1++;
-
-
-            /* Now, do second row. */
-
-            L = *lum2++;
-            row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] |
-                                        rgb_2_pix[L + crb_g] |
-                                        rgb_2_pix[L + cb_b]);
-            row2++;
-
-            L = *lum2++;
-            row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] |
-                                        rgb_2_pix[L + crb_g] |
-                                        rgb_2_pix[L + cb_b]);
-            row2++;
-        }
-
-        /*
-         * These values are at the start of the next line, (due
-         * to the ++'s above),but they need to be at the start
-         * of the line after that.
-         */
-        lum += cols;
-        lum2 += cols;
-        row1 += mod;
-        row2 += mod;
-    }
-}
-
-static void
-Color24DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned int value;
-    unsigned char *row1 = out;
-    const int next_row = (cols * 2 + mod) * 3;
-    unsigned char *row2 = row1 + 2 * next_row;
-    unsigned char *lum2;
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-
-    lum2 = lum + cols;
-
-    mod = next_row * 3 + mod * 3;
-
-    y = rows / 2;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            ++cr;
-            ++cb;
-
-            L = *lum++;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] =
-                row1[next_row + 3 + 0] = (value) & 0xFF;
-            row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] =
-                row1[next_row + 3 + 1] = (value >> 8) & 0xFF;
-            row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] =
-                row1[next_row + 3 + 2] = (value >> 16) & 0xFF;
-            row1 += 2 * 3;
-
-            L = *lum++;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] =
-                row1[next_row + 3 + 0] = (value) & 0xFF;
-            row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] =
-                row1[next_row + 3 + 1] = (value >> 8) & 0xFF;
-            row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] =
-                row1[next_row + 3 + 2] = (value >> 16) & 0xFF;
-            row1 += 2 * 3;
-
-
-            /* Now, do second row. */
-
-            L = *lum2++;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] =
-                row2[next_row + 3 + 0] = (value) & 0xFF;
-            row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] =
-                row2[next_row + 3 + 1] = (value >> 8) & 0xFF;
-            row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] =
-                row2[next_row + 3 + 2] = (value >> 16) & 0xFF;
-            row2 += 2 * 3;
-
-            L = *lum2++;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] =
-                row2[next_row + 3 + 0] = (value) & 0xFF;
-            row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] =
-                row2[next_row + 3 + 1] = (value >> 8) & 0xFF;
-            row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] =
-                row2[next_row + 3 + 2] = (value >> 16) & 0xFF;
-            row2 += 2 * 3;
-        }
-
-        /*
-         * These values are at the start of the next line, (due
-         * to the ++'s above),but they need to be at the start
-         * of the line after that.
-         */
-        lum += cols;
-        lum2 += cols;
-        row1 += mod;
-        row2 += mod;
-    }
-}
-
-static void
-Color32DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned int *row1 = (unsigned int *) out;
-    const int next_row = cols * 2 + mod;
-    unsigned int *row2 = row1 + 2 * next_row;
-    unsigned char *lum2;
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-
-    lum2 = lum + cols;
-
-    mod = (next_row * 3) + mod;
-
-    y = rows / 2;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            ++cr;
-            ++cb;
-
-            L = *lum++;
-            row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] =
-                (rgb_2_pix[L + cr_r] |
-                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row1 += 2;
-
-            L = *lum++;
-            row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] =
-                (rgb_2_pix[L + cr_r] |
-                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row1 += 2;
-
-
-            /* Now, do second row. */
-
-            L = *lum2++;
-            row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] =
-                (rgb_2_pix[L + cr_r] |
-                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row2 += 2;
-
-            L = *lum2++;
-            row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] =
-                (rgb_2_pix[L + cr_r] |
-                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row2 += 2;
-        }
-
-        /*
-         * These values are at the start of the next line, (due
-         * to the ++'s above),but they need to be at the start
-         * of the line after that.
-         */
-        lum += cols;
-        lum2 += cols;
-        row1 += mod;
-        row2 += mod;
-    }
-}
-
-static void
-Color16DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned short *row;
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-
-    row = (unsigned short *) out;
-
-    y = rows;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            cr += 4;
-            cb += 4;
-
-            L = *lum;
-            lum += 2;
-            *row++ = (unsigned short) (rgb_2_pix[L + cr_r] |
-                                       rgb_2_pix[L + crb_g] |
-                                       rgb_2_pix[L + cb_b]);
-
-            L = *lum;
-            lum += 2;
-            *row++ = (unsigned short) (rgb_2_pix[L + cr_r] |
-                                       rgb_2_pix[L + crb_g] |
-                                       rgb_2_pix[L + cb_b]);
-
-        }
-
-        row += mod;
-    }
-}
-
-static void
-Color24DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned int value;
-    unsigned char *row;
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-
-    row = (unsigned char *) out;
-    mod *= 3;
-    y = rows;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            cr += 4;
-            cb += 4;
-
-            L = *lum;
-            lum += 2;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            *row++ = (value) & 0xFF;
-            *row++ = (value >> 8) & 0xFF;
-            *row++ = (value >> 16) & 0xFF;
-
-            L = *lum;
-            lum += 2;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            *row++ = (value) & 0xFF;
-            *row++ = (value >> 8) & 0xFF;
-            *row++ = (value >> 16) & 0xFF;
-
-        }
-        row += mod;
-    }
-}
-
-static void
-Color32DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned int *row;
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-
-    row = (unsigned int *) out;
-    y = rows;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            cr += 4;
-            cb += 4;
-
-            L = *lum;
-            lum += 2;
-            *row++ = (rgb_2_pix[L + cr_r] |
-                      rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-
-            L = *lum;
-            lum += 2;
-            *row++ = (rgb_2_pix[L + cr_r] |
-                      rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-
-
-        }
-        row += mod;
-    }
-}
-
-/*
- * In this function I make use of a nasty trick. The tables have the lower
- * 16 bits replicated in the upper 16. This means I can write ints and get
- * the horisontal doubling for free (almost).
- */
-static void
-Color16DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned int *row = (unsigned int *) out;
-    const int next_row = cols + (mod / 2);
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-
-    y = rows;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            cr += 4;
-            cb += 4;
-
-            L = *lum;
-            lum += 2;
-            row[0] = row[next_row] = (rgb_2_pix[L + cr_r] |
-                                      rgb_2_pix[L + crb_g] |
-                                      rgb_2_pix[L + cb_b]);
-            row++;
-
-            L = *lum;
-            lum += 2;
-            row[0] = row[next_row] = (rgb_2_pix[L + cr_r] |
-                                      rgb_2_pix[L + crb_g] |
-                                      rgb_2_pix[L + cb_b]);
-            row++;
-
-        }
-        row += next_row;
-    }
-}
-
-static void
-Color24DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned int value;
-    unsigned char *row = out;
-    const int next_row = (cols * 2 + mod) * 3;
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-    y = rows;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            cr += 4;
-            cb += 4;
-
-            L = *lum;
-            lum += 2;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row[0 + 0] = row[3 + 0] = row[next_row + 0] =
-                row[next_row + 3 + 0] = (value) & 0xFF;
-            row[0 + 1] = row[3 + 1] = row[next_row + 1] =
-                row[next_row + 3 + 1] = (value >> 8) & 0xFF;
-            row[0 + 2] = row[3 + 2] = row[next_row + 2] =
-                row[next_row + 3 + 2] = (value >> 16) & 0xFF;
-            row += 2 * 3;
-
-            L = *lum;
-            lum += 2;
-            value = (rgb_2_pix[L + cr_r] |
-                     rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row[0 + 0] = row[3 + 0] = row[next_row + 0] =
-                row[next_row + 3 + 0] = (value) & 0xFF;
-            row[0 + 1] = row[3 + 1] = row[next_row + 1] =
-                row[next_row + 3 + 1] = (value >> 8) & 0xFF;
-            row[0 + 2] = row[3 + 2] = row[next_row + 2] =
-                row[next_row + 3 + 2] = (value >> 16) & 0xFF;
-            row += 2 * 3;
-
-        }
-        row += next_row;
-    }
-}
-
-static void
-Color32DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod)
-{
-    unsigned int *row = (unsigned int *) out;
-    const int next_row = cols * 2 + mod;
-    int x, y;
-    int cr_r;
-    int crb_g;
-    int cb_b;
-    int cols_2 = cols / 2;
-    mod += mod;
-    y = rows;
-    while (y--) {
-        x = cols_2;
-        while (x--) {
-            register int L;
-
-            cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
-            crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
-                + colortab[*cb + 2 * 256];
-            cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
-            cr += 4;
-            cb += 4;
-
-            L = *lum;
-            lum += 2;
-            row[0] = row[1] = row[next_row] = row[next_row + 1] =
-                (rgb_2_pix[L + cr_r] |
-                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row += 2;
-
-            L = *lum;
-            lum += 2;
-            row[0] = row[1] = row[next_row] = row[next_row + 1] =
-                (rgb_2_pix[L + cr_r] |
-                 rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-            row += 2;
-
-
-        }
-
-        row += next_row;
-    }
-}
-
-/*
- * How many 1 bits are there in the Uint32.
- * Low performance, do not call often.
- */
-static int
-number_of_bits_set(Uint32 a)
-{
-    if (!a)
-        return 0;
-    if (a & 1)
-        return 1 + number_of_bits_set(a >> 1);
-    return (number_of_bits_set(a >> 1));
-}
-
-/*
- * How many 0 bits are there at least significant end of Uint32.
- * Low performance, do not call often.
- */
-static int
-free_bits_at_bottom(Uint32 a)
-{
-    /* assume char is 8 bits */
-    if (!a)
-        return sizeof(Uint32) * 8;
-    if (((Sint32) a) & 1l)
-        return 0;
-    return 1 + free_bits_at_bottom(a >> 1);
-}
-
-static int
-SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format)
-{
-    Uint32 *r_2_pix_alloc;
-    Uint32 *g_2_pix_alloc;
-    Uint32 *b_2_pix_alloc;
-    int i;
-    int bpp;
-    Uint32 Rmask, Gmask, Bmask, Amask;
-
-    if (!SDL_PixelFormatEnumToMasks
-        (target_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask) || bpp < 15) {
-        SDL_SetError("Unsupported YUV destination format");
-        return -1;
-    }
-
-    swdata->target_format = target_format;
-    r_2_pix_alloc = &swdata->rgb_2_pix[0 * 768];
-    g_2_pix_alloc = &swdata->rgb_2_pix[1 * 768];
-    b_2_pix_alloc = &swdata->rgb_2_pix[2 * 768];
-
-    /* 
-     * Set up entries 0-255 in rgb-to-pixel value tables.
-     */
-    for (i = 0; i < 256; ++i) {
-        r_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Rmask));
-        r_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Rmask);
-        r_2_pix_alloc[i + 256] |= Amask;
-        g_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Gmask));
-        g_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Gmask);
-        g_2_pix_alloc[i + 256] |= Amask;
-        b_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Bmask));
-        b_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Bmask);
-        b_2_pix_alloc[i + 256] |= Amask;
-    }
-
-    /*
-     * If we have 16-bit output depth, then we double the value
-     * in the top word. This means that we can write out both
-     * pixels in the pixel doubling mode with one op. It is 
-     * harmless in the normal case as storing a 32-bit value
-     * through a short pointer will lose the top bits anyway.
-     */
-    if (SDL_BYTESPERPIXEL(target_format) == 2) {
-        for (i = 0; i < 256; ++i) {
-            r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 16;
-            g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 16;
-            b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 16;
-        }
-    }
-
-    /*
-     * Spread out the values we have to the rest of the array so that
-     * we do not need to check for overflow.
-     */
-    for (i = 0; i < 256; ++i) {
-        r_2_pix_alloc[i] = r_2_pix_alloc[256];
-        r_2_pix_alloc[i + 512] = r_2_pix_alloc[511];
-        g_2_pix_alloc[i] = g_2_pix_alloc[256];
-        g_2_pix_alloc[i + 512] = g_2_pix_alloc[511];
-        b_2_pix_alloc[i] = b_2_pix_alloc[256];
-        b_2_pix_alloc[i + 512] = b_2_pix_alloc[511];
-    }
-
-    /* You have chosen wisely... */
-    switch (swdata->format) {
-    case SDL_PIXELFORMAT_YV12:
-    case SDL_PIXELFORMAT_IYUV:
-        if (SDL_BYTESPERPIXEL(target_format) == 2) {
-#if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
-            /* inline assembly functions */
-            if (SDL_HasMMX() && (Rmask == 0xF800) &&
-                (Gmask == 0x07E0) && (Bmask == 0x001F)
-                && (swdata->w & 15) == 0) {
-/*printf("Using MMX 16-bit 565 dither\n");*/
-                swdata->Display1X = Color565DitherYV12MMX1X;
-            } else {
-/*printf("Using C 16-bit dither\n");*/
-                swdata->Display1X = Color16DitherYV12Mod1X;
-            }
-#else
-            swdata->Display1X = Color16DitherYV12Mod1X;
-#endif
-            swdata->Display2X = Color16DitherYV12Mod2X;
-        }
-        if (SDL_BYTESPERPIXEL(target_format) == 3) {
-            swdata->Display1X = Color24DitherYV12Mod1X;
-            swdata->Display2X = Color24DitherYV12Mod2X;
-        }
-        if (SDL_BYTESPERPIXEL(target_format) == 4) {
-#if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
-            /* inline assembly functions */
-            if (SDL_HasMMX() && (Rmask == 0x00FF0000) &&
-                (Gmask == 0x0000FF00) &&
-                (Bmask == 0x000000FF) && (swdata->w & 15) == 0) {
-/*printf("Using MMX 32-bit dither\n");*/
-                swdata->Display1X = ColorRGBDitherYV12MMX1X;
-            } else {
-/*printf("Using C 32-bit dither\n");*/
-                swdata->Display1X = Color32DitherYV12Mod1X;
-            }
-#else
-            swdata->Display1X = Color32DitherYV12Mod1X;
-#endif
-            swdata->Display2X = Color32DitherYV12Mod2X;
-        }
-        break;
-    case SDL_PIXELFORMAT_YUY2:
-    case SDL_PIXELFORMAT_UYVY:
-    case SDL_PIXELFORMAT_YVYU:
-        if (SDL_BYTESPERPIXEL(target_format) == 2) {
-            swdata->Display1X = Color16DitherYUY2Mod1X;
-            swdata->Display2X = Color16DitherYUY2Mod2X;
-        }
-        if (SDL_BYTESPERPIXEL(target_format) == 3) {
-            swdata->Display1X = Color24DitherYUY2Mod1X;
-            swdata->Display2X = Color24DitherYUY2Mod2X;
-        }
-        if (SDL_BYTESPERPIXEL(target_format) == 4) {
-            swdata->Display1X = Color32DitherYUY2Mod1X;
-            swdata->Display2X = Color32DitherYUY2Mod2X;
-        }
-        break;
-    default:
-        /* We should never get here (caught above) */
-        break;
-    }
-
-    if (swdata->display) {
-        SDL_FreeSurface(swdata->display);
-        swdata->display = NULL;
-    }
-    return 0;
-}
-
-SDL_SW_YUVTexture *
-SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
-{
-    SDL_SW_YUVTexture *swdata;
-    int *Cr_r_tab;
-    int *Cr_g_tab;
-    int *Cb_g_tab;
-    int *Cb_b_tab;
-    int i;
-    int CR, CB;
-
-    swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata));
-    if (!swdata) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    switch (format) {
-    case SDL_PIXELFORMAT_YV12:
-    case SDL_PIXELFORMAT_IYUV:
-    case SDL_PIXELFORMAT_YUY2:
-    case SDL_PIXELFORMAT_UYVY:
-    case SDL_PIXELFORMAT_YVYU:
-        break;
-    default:
-        SDL_SetError("Unsupported YUV format");
-        return NULL;
-    }
-
-    swdata->format = format;
-    swdata->target_format = SDL_PIXELFORMAT_UNKNOWN;
-    swdata->w = w;
-    swdata->h = h;
-    swdata->pixels = (Uint8 *) SDL_malloc(w * h * 2);
-    swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int));
-    swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32));
-    if (!swdata->pixels || !swdata->colortab || !swdata->rgb_2_pix) {
-        SDL_OutOfMemory();
-        SDL_SW_DestroyYUVTexture(swdata);
-        return NULL;
-    }
-
-    /* Generate the tables for the display surface */
-    Cr_r_tab = &swdata->colortab[0 * 256];
-    Cr_g_tab = &swdata->colortab[1 * 256];
-    Cb_g_tab = &swdata->colortab[2 * 256];
-    Cb_b_tab = &swdata->colortab[3 * 256];
-    for (i = 0; i < 256; i++) {
-        /* Gamma correction (luminescence table) and chroma correction
-           would be done here.  See the Berkeley mpeg_play sources.
-         */
-        CB = CR = (i - 128);
-        Cr_r_tab[i] = (int) ((0.419 / 0.299) * CR);
-        Cr_g_tab[i] = (int) (-(0.299 / 0.419) * CR);
-        Cb_g_tab[i] = (int) (-(0.114 / 0.331) * CB);
-        Cb_b_tab[i] = (int) ((0.587 / 0.331) * CB);
-    }
-
-    /* Find the pitch and offset values for the overlay */
-    switch (format) {
-    case SDL_PIXELFORMAT_YV12:
-    case SDL_PIXELFORMAT_IYUV:
-        swdata->pitches[0] = w;
-        swdata->pitches[1] = swdata->pitches[0] / 2;
-        swdata->pitches[2] = swdata->pitches[0] / 2;
-        swdata->planes[0] = swdata->pixels;
-        swdata->planes[1] = swdata->planes[0] + swdata->pitches[0] * h;
-        swdata->planes[2] = swdata->planes[1] + swdata->pitches[1] * h / 2;
-        break;
-    case SDL_PIXELFORMAT_YUY2:
-    case SDL_PIXELFORMAT_UYVY:
-    case SDL_PIXELFORMAT_YVYU:
-        swdata->pitches[0] = w * 2;
-        swdata->planes[0] = swdata->pixels;
-        break;
-    default:
-        /* We should never get here (caught above) */
-        break;
-    }
-
-    /* We're all done.. */
-    return (swdata);
-}
-
-int
-SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels,
-                             int *pitch)
-{
-    *pixels = swdata->planes[0];
-    *pitch = swdata->pitches[0];
-    return 0;
-}
-
-int
-SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
-                        const void *pixels, int pitch)
-{
-    switch (swdata->format) {
-    case SDL_PIXELFORMAT_YV12:
-    case SDL_PIXELFORMAT_IYUV:
-        if (rect
-            && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w
-                || rect->h != swdata->h)) {
-            SDL_SetError
-                ("YV12 and IYUV textures only support full surface updates");
-            return -1;
-        }
-        SDL_memcpy(swdata->pixels, pixels, swdata->h * swdata->w * 2);
-        break;
-    case SDL_PIXELFORMAT_YUY2:
-    case SDL_PIXELFORMAT_UYVY:
-    case SDL_PIXELFORMAT_YVYU:
-        {
-            Uint8 *src, *dst;
-            int row;
-            size_t length;
-
-            src = (Uint8 *) pixels;
-            dst =
-                swdata->planes[0] + rect->y * swdata->pitches[0] +
-                rect->x * 2;
-            length = rect->w * 2;
-            for (row = 0; row < rect->h; ++row) {
-                SDL_memcpy(dst, src, length);
-                src += pitch;
-                dst += swdata->pitches[0];
-            }
-        }
-        break;
-    }
-    return 0;
-}
-
-int
-SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
-                      int markDirty, void **pixels, int *pitch)
-{
-    switch (swdata->format) {
-    case SDL_PIXELFORMAT_YV12:
-    case SDL_PIXELFORMAT_IYUV:
-        if (rect
-            && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w
-                || rect->h != swdata->h)) {
-            SDL_SetError
-                ("YV12 and IYUV textures only support full surface locks");
-            return -1;
-        }
-        break;
-    }
-
-    *pixels = swdata->planes[0] + rect->y * swdata->pitches[0] + rect->x * 2;
-    *pitch = swdata->pitches[0];
-    return 0;
-}
-
-void
-SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata)
-{
-}
-
-int
-SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
-                    Uint32 target_format, int w, int h, void *pixels,
-                    int pitch)
-{
-    int stretch;
-    int scale_2x;
-    Uint8 *lum, *Cr, *Cb;
-    int mod;
-
-    /* Make sure we're set up to display in the desired format */
-    if (target_format != swdata->target_format) {
-        if (SDL_SW_SetupYUVDisplay(swdata, target_format) < 0) {
-            return -1;
-        }
-    }
-
-    stretch = 0;
-    scale_2x = 0;
-    if (srcrect->x || srcrect->y || srcrect->w < swdata->w
-        || srcrect->h < swdata->h) {
-        /* The source rectangle has been clipped.
-           Using a scratch surface is easier than adding clipped
-           source support to all the blitters, plus that would
-           slow them down in the general unclipped case.
-         */
-        stretch = 1;
-    } else if ((srcrect->w != w) || (srcrect->h != h)) {
-        if ((w == 2 * srcrect->w) && (h == 2 * srcrect->h)) {
-            scale_2x = 1;
-        } else {
-            stretch = 1;
-        }
-    }
-    if (stretch) {
-        int bpp;
-        Uint32 Rmask, Gmask, Bmask, Amask;
-
-        if (swdata->display) {
-            swdata->display->w = w;
-            swdata->display->h = h;
-            swdata->display->pixels = pixels;
-            swdata->display->pitch = pitch;
-        } else {
-            /* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */
-            SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask,
-                                       &Bmask, &Amask);
-            swdata->display =
-                SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask,
-                                         Gmask, Bmask, Amask);
-            if (!swdata->display) {
-                return (-1);
-            }
-        }
-        if (!swdata->stretch) {
-            /* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */
-            SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask,
-                                       &Bmask, &Amask);
-            swdata->stretch =
-                SDL_CreateRGBSurface(0, swdata->w, swdata->h, bpp, Rmask,
-                                     Gmask, Bmask, Amask);
-            if (!swdata->stretch) {
-                return (-1);
-            }
-        }
-        pixels = swdata->stretch->pixels;
-        pitch = swdata->stretch->pitch;
-    }
-    switch (swdata->format) {
-    case SDL_PIXELFORMAT_YV12:
-        lum = swdata->planes[0];
-        Cr = swdata->planes[1];
-        Cb = swdata->planes[2];
-        break;
-    case SDL_PIXELFORMAT_IYUV:
-        lum = swdata->planes[0];
-        Cr = swdata->planes[2];
-        Cb = swdata->planes[1];
-        break;
-    case SDL_PIXELFORMAT_YUY2:
-        lum = swdata->planes[0];
-        Cr = lum + 3;
-        Cb = lum + 1;
-        break;
-    case SDL_PIXELFORMAT_UYVY:
-        lum = swdata->planes[0] + 1;
-        Cr = lum + 1;
-        Cb = lum - 1;
-        break;
-    case SDL_PIXELFORMAT_YVYU:
-        lum = swdata->planes[0];
-        Cr = lum + 1;
-        Cb = lum + 3;
-        break;
-    default:
-        SDL_SetError("Unsupported YUV format in copy");
-        return (-1);
-    }
-    mod = (pitch / SDL_BYTESPERPIXEL(target_format));
-
-    if (scale_2x) {
-        mod -= (swdata->w * 2);
-        swdata->Display2X(swdata->colortab, swdata->rgb_2_pix,
-                          lum, Cr, Cb, pixels, swdata->h, swdata->w, mod);
-    } else {
-        mod -= swdata->w;
-        swdata->Display1X(swdata->colortab, swdata->rgb_2_pix,
-                          lum, Cr, Cb, pixels, swdata->h, swdata->w, mod);
-    }
-    if (stretch) {
-        SDL_Rect rect = *srcrect;
-        SDL_SoftStretch(swdata->stretch, &rect, swdata->display, NULL);
-    }
-    return 0;
-}
-
-void
-SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata)
-{
-    if (swdata) {
-        if (swdata->pixels) {
-            SDL_free(swdata->pixels);
-        }
-        if (swdata->colortab) {
-            SDL_free(swdata->colortab);
-        }
-        if (swdata->rgb_2_pix) {
-            SDL_free(swdata->rgb_2_pix);
-        }
-        if (swdata->stretch) {
-            SDL_FreeSurface(swdata->stretch);
-        }
-        if (swdata->display) {
-            SDL_FreeSurface(swdata->display);
-        }
-        SDL_free(swdata);
-    }
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_yuv_sw_c.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_video.h"
-#include "SDL_sysvideo.h"
-
-/* This is the software implementation of the YUV texture support */
-
-struct SDL_SW_YUVTexture
-{
-    Uint32 format;
-    Uint32 target_format;
-    int w, h;
-    Uint8 *pixels;
-    int *colortab;
-    Uint32 *rgb_2_pix;
-    void (*Display1X) (int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod);
-    void (*Display2X) (int *colortab, Uint32 * rgb_2_pix,
-                       unsigned char *lum, unsigned char *cr,
-                       unsigned char *cb, unsigned char *out,
-                       int rows, int cols, int mod);
-
-    /* These are just so we don't have to allocate them separately */
-    Uint16 pitches[3];
-    Uint8 *planes[3];
-
-    /* This is a temporary surface in case we have to stretch copy */
-    SDL_Surface *stretch;
-    SDL_Surface *display;
-};
-
-typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture;
-
-SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h);
-int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels,
-                                 int *pitch);
-int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
-                            const void *pixels, int pitch);
-int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
-                          int markDirty, void **pixels, int *pitch);
-void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata);
-int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
-                        Uint32 target_format, int w, int h, void *pixels,
-                        int pitch);
-void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata);
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/Xext/XmuStdCmap/AllCmap.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/* $Xorg: AllCmap.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
-
-/* 
- 
-Copyright 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/Xmu/AllCmap.c,v 1.7 2001/01/17 19:42:53 dawes Exp $ */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/Xutil.h>
-#include "../extensions/StdCmap.h"
-
-static XVisualInfo *getDeepestVisual(int, XVisualInfo *, int);
-
-/*
- * To create all of the appropriate standard colormaps for every visual of
- * every screen on a given display, use XmuAllStandardColormaps.
- *
- * Define and retain as permanent resources all standard colormaps which are
- * meaningful for the visuals of each screen of the display.  Return 0 on
- * failure, non-zero on success.  If the property of any standard colormap 
- * is already defined, redefine it.
- *
- * This interface is intended to be used by window managers or a client
- * upon start-up of a session.
- *
- * The standard colormaps of a screen are defined by properties associated
- * with the screen's root window.  Each screen has exactly one root window.
- * The property names of standard colormaps are predefined, and each property
- * name may describe at most one colormap.
- * 
- * The standard colormaps are
- *		RGB_BEST_MAP
- *		RGB_RED_MAP
- *		RGB_GREEN_MAP
- *		RGB_BLUE_MAP
- *		RGB_DEFAULT_MAP
- *		RGB_GRAY_MAP
- *
- * Therefore a screen may have at most 6 standard colormap properties defined.
- *
- * A standard colormap is associated with a particular visual of the screen.
- * A screen may have multiple visuals defined, including visuals of the same
- * class at different depths.  Note that a visual id might be repeated for
- * more than one depth, so the visual id and the depth of a visual identify
- * the visual.  The characteristics of the visual will determine which
- * standard colormaps are meaningful under that visual, and will determine
- * how the standard colormap is defined.  Because a standard colormap is
- * associated with a specific visual, there must be a method of determining
- * which visuals take precedence in defining standard colormaps.
- * 
- * The method used here is: for the visual of greatest depth, define all 
- * standard colormaps meaningful to that visual class, according to this
- * order of (descending) precedence:
- *	1. DirectColor
- *	2. PseudoColor
- *	3. TrueColor and GrayScale
- *	4. StaticColor and StaticGray
- *
- * Allows partial success by screenful.  For example, if a map on screen 1
- * fails, the maps on screen 0, created earlier, will remain.  However,
- * none on screen 1 will remain.  If a map on 0 fails, none will remain.
- *
- * See the comments under XmuVisualStandardColormaps() for notes on which
- * standard colormaps are meaningful under these classes of visuals.
- */
-
-Status
-XmuAllStandardColormaps(Display * dpy)
-{
-    int nvisuals, scr;
-    Status status;
-    long vinfo_mask;
-    XVisualInfo template, *vinfo, *v1, *v2;
-
-    status = 0;
-    /* for each screen, determine all visuals of this server */
-    for (scr = 0; scr < ScreenCount(dpy); scr++) {
-        template.screen = scr;
-        vinfo_mask = VisualScreenMask;
-        vinfo = XGetVisualInfo(dpy, vinfo_mask, &template, &nvisuals);
-        if (vinfo == NULL)      /* unexpected: a screen with no visuals */
-            continue;
-
-        v1 = getDeepestVisual(DirectColor, vinfo, nvisuals);
-        v2 = getDeepestVisual(PseudoColor, vinfo, nvisuals);
-
-        if (v2 &&
-            (!v1 || (v2->colormap_size >=
-                     ((v1->red_mask | v1->green_mask | v1->blue_mask) + 1))))
-            status = XmuVisualStandardColormaps(dpy, scr, v2->visualid,
-                                                (unsigned) v2->depth, 1, 1);
-        else if (v1)
-            status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
-                                                (unsigned) v1->depth, 1, 1);
-
-        else {
-            if (((v1 = getDeepestVisual(TrueColor, vinfo, nvisuals)) != NULL)
-                || ((v1 = getDeepestVisual(StaticColor, vinfo, nvisuals)) !=
-                    NULL))
-                status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
-                                                    (unsigned) v1->depth, 1,
-                                                    1);
-            if (status
-                &&
-                (((v1 = getDeepestVisual(GrayScale, vinfo, nvisuals)) != NULL)
-                 || ((v1 = getDeepestVisual(StaticGray, vinfo, nvisuals)) !=
-                     NULL)))
-                status =
-                    XmuVisualStandardColormaps(dpy, scr, v1->visualid,
-                                               (unsigned) v1->depth, 1, 1);
-        }
-        XFree((char *) vinfo);
-        if (!status)
-            break;
-    }
-    return status;
-}
-
-static XVisualInfo *
-getDeepestVisual(int visual_class, XVisualInfo * vinfo, int nvisuals)
-{
-    register int i;
-    register int maxdepth = 0;
-    XVisualInfo *v = NULL;
-
-    for (i = 0; i < nvisuals; i++, vinfo++)
-        if (vinfo->class == visual_class && vinfo->depth > maxdepth) {
-            maxdepth = vinfo->depth;
-            v = vinfo;
-        }
-    return (v);
-}
--- a/src/video/Xext/XmuStdCmap/CmapAlloc.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,337 +0,0 @@
-/* $Xorg: CmapAlloc.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
-
-/* 
-
-Copyright 1989, 1994, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/Xmu/CmapAlloc.c,v 1.6 2001/01/17 19:42:53 dawes Exp $ */
-
-/*
- * Author:  Donna Converse, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/Xutil.h>
-#include "../extensions/StdCmap.h"
-#include <stdio.h>
-
-#define lowbit(x) ((x) & (~(x) + 1))
-
-/*
- * Prototypes
- */
-static void best_allocation(XVisualInfo *, unsigned long *, unsigned long *,
-                            unsigned long *);
-static int default_allocation(XVisualInfo *, unsigned long *,
-                              unsigned long *, unsigned long *);
-static void gray_allocation(int, unsigned long *, unsigned long *,
-                            unsigned long *);
-static int icbrt(int);
-static int icbrt_with_bits(int, int);
-static int icbrt_with_guess(int, int);
-
-/* To determine the best allocation of reds, greens, and blues in a 
- * standard colormap, use XmuGetColormapAllocation.
- * 	vinfo		specifies visual information for a chosen visual
- *	property	specifies one of the standard colormap property names
- * 	red_max		returns maximum red value 
- *      green_max	returns maximum green value
- * 	blue_max	returns maximum blue value
- *
- * XmuGetColormapAllocation returns 0 on failure, non-zero on success.
- * It is assumed that the visual is appropriate for the colormap property.
- */
-
-Status
-XmuGetColormapAllocation(XVisualInfo * vinfo, Atom property,
-                         unsigned long *red_max,
-                         unsigned long *green_max, unsigned long *blue_max)
-{
-    Status status = 1;
-
-    if (vinfo->colormap_size <= 2)
-        return 0;
-
-    switch (property) {
-    case XA_RGB_DEFAULT_MAP:
-        status = default_allocation(vinfo, red_max, green_max, blue_max);
-        break;
-    case XA_RGB_BEST_MAP:
-        best_allocation(vinfo, red_max, green_max, blue_max);
-        break;
-    case XA_RGB_GRAY_MAP:
-        gray_allocation(vinfo->colormap_size, red_max, green_max, blue_max);
-        break;
-    case XA_RGB_RED_MAP:
-        *red_max = vinfo->colormap_size - 1;
-        *green_max = *blue_max = 0;
-        break;
-    case XA_RGB_GREEN_MAP:
-        *green_max = vinfo->colormap_size - 1;
-        *red_max = *blue_max = 0;
-        break;
-    case XA_RGB_BLUE_MAP:
-        *blue_max = vinfo->colormap_size - 1;
-        *red_max = *green_max = 0;
-        break;
-    default:
-        status = 0;
-    }
-    return status;
-}
-
-/****************************************************************************/
-/* Determine the appropriate color allocations of a gray scale.
- *
- * Keith Packard, MIT X Consortium
- */
-
-static void
-gray_allocation(int n, unsigned long *red_max, unsigned long *green_max,
-                unsigned long *blue_max)
-{
-    *red_max = (n * 30) / 100;
-    *green_max = (n * 59) / 100;
-    *blue_max = (n * 11) / 100;
-    *green_max += ((n - 1) - (*red_max + *green_max + *blue_max));
-}
-
-/****************************************************************************/
-/* Determine an appropriate color allocation for the RGB_DEFAULT_MAP.
- * If a map has less than a minimum number of definable entries, we do not
- * produce an allocation for an RGB_DEFAULT_MAP.  
- *
- * For 16 planes, the default colormap will have 27 each RGB; for 12 planes,
- * 12 each.  For 8 planes, let n = the number of colormap entries, which may
- * be 256 or 254.  Then, maximum red value = floor(cube_root(n - 125)) - 1.
- * Maximum green and maximum blue values are identical to maximum red.
- * This leaves at least 125 cells which clients can allocate.
- *
- * Return 0 if an allocation has been determined, non-zero otherwise.
- */
-
-static int
-default_allocation(XVisualInfo * vinfo, unsigned long *red,
-                   unsigned long *green, unsigned long *blue)
-{
-    int ngrays;                 /* number of gray cells */
-
-    switch (vinfo->class) {
-    case PseudoColor:
-
-        if (vinfo->colormap_size > 65000)
-            /* intended for displays with 16 planes */
-            *red = *green = *blue = (unsigned long) 27;
-        else if (vinfo->colormap_size > 4000)
-            /* intended for displays with 12 planes */
-            *red = *green = *blue = (unsigned long) 12;
-        else if (vinfo->colormap_size < 250)
-            return 0;
-        else
-            /* intended for displays with 8 planes */
-            *red = *green = *blue = (unsigned long)
-                (icbrt(vinfo->colormap_size - 125) - 1);
-        break;
-
-    case DirectColor:
-
-        if (vinfo->colormap_size < 10)
-            return 0;
-        *red = *green = *blue = vinfo->colormap_size / 2 - 1;
-        break;
-
-    case TrueColor:
-
-        *red = vinfo->red_mask / lowbit(vinfo->red_mask);
-        *green = vinfo->green_mask / lowbit(vinfo->green_mask);
-        *blue = vinfo->blue_mask / lowbit(vinfo->blue_mask);
-        break;
-
-    case GrayScale:
-
-        if (vinfo->colormap_size > 65000)
-            ngrays = 4096;
-        else if (vinfo->colormap_size > 4000)
-            ngrays = 512;
-        else if (vinfo->colormap_size < 250)
-            return 0;
-        else
-            ngrays = 12;
-        gray_allocation(ngrays, red, green, blue);
-        break;
-
-    default:
-        return 0;
-    }
-    return 1;
-}
-
-/****************************************************************************/
-/* Determine an appropriate color allocation for the RGB_BEST_MAP.
- *
- * For a DirectColor or TrueColor visual, the allocation is determined
- * by the red_mask, green_mask, and blue_mask members of the visual info.
- *
- * Otherwise, if the colormap size is an integral power of 2, determine
- * the allocation according to the number of bits given to each color,
- * with green getting more than red, and red more than blue, if there
- * are to be inequities in the distribution.  If the colormap size is
- * not an integral power of 2, let n = the number of colormap entries.
- * Then maximum red value = floor(cube_root(n)) - 1;
- * 	maximum blue value = floor(cube_root(n)) - 1;
- *	maximum green value = n / ((# red values) * (# blue values)) - 1;
- * Which, on a GPX, allows for 252 entries in the best map, out of 254
- * defineable colormap entries.
- */
-
-static void
-best_allocation(XVisualInfo * vinfo, unsigned long *red, unsigned long *green,
-                unsigned long *blue)
-{
-
-    if (vinfo->class == DirectColor || vinfo->class == TrueColor) {
-        *red = vinfo->red_mask;
-        while ((*red & 01) == 0)
-            *red >>= 1;
-        *green = vinfo->green_mask;
-        while ((*green & 01) == 0)
-            *green >>= 1;
-        *blue = vinfo->blue_mask;
-        while ((*blue & 01) == 0)
-            *blue >>= 1;
-    } else {
-        register int bits, n;
-
-        /* Determine n such that n is the least integral power of 2 which is
-         * greater than or equal to the number of entries in the colormap.
-         */
-        n = 1;
-        bits = 0;
-        while (vinfo->colormap_size > n) {
-            n = n << 1;
-            bits++;
-        }
-
-        /* If the number of entries in the colormap is a power of 2, determine
-         * the allocation by "dealing" the bits, first to green, then red, then
-         * blue.  If not, find the maximum integral red, green, and blue values
-         * which, when multiplied together, do not exceed the number of 
-
-         * colormap entries.
-         */
-        if (n == vinfo->colormap_size) {
-            register int r, g, b;
-            b = bits / 3;
-            g = b + ((bits % 3) ? 1 : 0);
-            r = b + (((bits % 3) == 2) ? 1 : 0);
-            *red = 1 << r;
-            *green = 1 << g;
-            *blue = 1 << b;
-        } else {
-            *red = icbrt_with_bits(vinfo->colormap_size, bits);
-            *blue = *red;
-            *green = (vinfo->colormap_size / ((*red) * (*blue)));
-        }
-        (*red)--;
-        (*green)--;
-        (*blue)--;
-    }
-    return;
-}
-
-/*
- * integer cube roots by Newton's method
- *
- * Stephen Gildea, MIT X Consortium, July 1991
- */
-
-static int
-icbrt(int a)
-{
-    register int bits = 0;
-    register unsigned n = a;
-
-    while (n) {
-        bits++;
-        n >>= 1;
-    }
-    return icbrt_with_bits(a, bits);
-}
-
-
-static int
-icbrt_with_bits(int a, int bits)
-     /* bits - log 2 of a */
-{
-    return icbrt_with_guess(a, a >> 2 * bits / 3);
-}
-
-#ifdef _X_ROOT_STATS
-int icbrt_loopcount;
-#endif
-
-/* Newton's Method:  x_n+1 = x_n - ( f(x_n) / f'(x_n) ) */
-
-/* for cube roots, x^3 - a = 0,  x_new = x - 1/3 (x - a/x^2) */
-
-/*
- * Quick and dirty cube roots.  Nothing fancy here, just Newton's method.
- * Only works for positive integers (since that's all we need).
- * We actually return floor(cbrt(a)) because that's what we need here, too.
- */
-
-static int
-icbrt_with_guess(int a, int guess)
-{
-    register int delta;
-
-#ifdef _X_ROOT_STATS
-    icbrt_loopcount = 0;
-#endif
-    if (a <= 0)
-        return 0;
-    if (guess < 1)
-        guess = 1;
-
-    do {
-#ifdef _X_ROOT_STATS
-        icbrt_loopcount++;
-#endif
-        delta = (guess - a / (guess * guess)) / 3;
-#ifdef DEBUG
-        printf("pass %d: guess=%d, delta=%d\n", icbrt_loopcount, guess,
-               delta);
-#endif
-        guess -= delta;
-    } while (delta != 0);
-
-    if (guess * guess * guess > a)
-        guess--;
-
-    return guess;
-}
--- a/src/video/Xext/XmuStdCmap/CrCmap.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,531 +0,0 @@
-/* $Xorg: CrCmap.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
-
-/* 
-
-Copyright 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/Xmu/CrCmap.c,v 3.6 2001/01/17 19:42:53 dawes Exp $ */
-
-/*
- * Author:  Donna Converse, MIT X Consortium
- */
-
-/*
- * CreateCmap.c - given a standard colormap description, make the map.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include "../extensions/StdCmap.h"
-
-/*
- * Prototypes
- */
-/* allocate entire map Read Only */
-static int ROmap(Display *, Colormap, unsigned long[], int, int);
-
-/* allocate a cell, prefer Read Only */
-static Status ROorRWcell(Display *, Colormap, unsigned long[], int,
-                         XColor *, unsigned long);
-
-/* allocate a cell Read Write */
-static Status RWcell(Display *, Colormap, XColor *, XColor *,
-                     unsigned long *);
-
-/* for quicksort */
-static int compare(_Xconst void *, _Xconst void *);
-
-/* find contiguous sequence of cells */
-static Status contiguous(unsigned long[], int, int, unsigned long, int *,
-                         int *);
-
-/* frees resources before quitting */
-static void free_cells(Display *, Colormap, unsigned long[], int, int);
-
-/* create a map in a RO visual type */
-static Status readonly_map(Display *, XVisualInfo *, XStandardColormap *);
-
-/* create a map in a RW visual type */
-static Status readwrite_map(Display *, XVisualInfo *, XStandardColormap *);
-
-#define lowbit(x) ((x) & (~(x) + 1))
-#define TRUEMATCH(mult,max,mask) \
-    (colormap->max * colormap->mult <= vinfo->mask && \
-     lowbit(vinfo->mask) == colormap->mult)
-
-/*
- * To create any one colormap which is described by an XStandardColormap
- * structure, use XmuCreateColormap().
- *
- * Return 0 on failure, non-zero on success.
- * Resources created by this function are not made permanent.
- * No argument error checking is provided.  Use at your own risk.
- *
- * All colormaps are created with read only allocations, with the exception
- * of read only allocations of colors in the default map or otherwise
- * which fail to return the expected pixel value, and these are individually 
- * defined as read/write allocations.  This is done so that all the cells
- * defined in the default map are contiguous, for use in image processing.
- * This typically happens with White and Black in the default map.
- *
- * Colormaps of static visuals are considered to be successfully created if
- * the map of the static visual matches the definition given in the
- * standard colormap structure.
- */
-
-Status
-XmuCreateColormap(Display * dpy, XStandardColormap * colormap)
-     /* dpy      - specifies the connection under which the map is created
-      * colormap - specifies the map to be created, and returns, particularly
-      *            if the map is created as a subset of the default colormap
-      *            of the screen, the base_pixel of the map.
-      */
-{
-    XVisualInfo vinfo_template; /* template visual information */
-    XVisualInfo *vinfo;         /* matching visual information */
-    XVisualInfo *vpointer;      /* for freeing the entire list */
-    long vinfo_mask;            /* specifies the visual mask value */
-    int n;                      /* number of matching visuals */
-    int status;
-
-    vinfo_template.visualid = colormap->visualid;
-    vinfo_mask = VisualIDMask;
-    if ((vinfo =
-         XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
-        return 0;
-
-    /* A visual id may be valid on multiple screens.  Also, there may 
-     * be multiple visuals with identical visual ids at different depths.  
-     * If the colormap is the Default Colormap, use the Default Visual.
-     * Otherwise, arbitrarily, use the deepest visual.
-     */
-    vpointer = vinfo;
-    if (n > 1) {
-        register int i;
-        register int screen_number;
-        Bool def_cmap;
-
-        def_cmap = False;
-        for (screen_number = ScreenCount(dpy); --screen_number >= 0;)
-            if (colormap->colormap == DefaultColormap(dpy, screen_number)) {
-                def_cmap = True;
-                break;
-            }
-
-        if (def_cmap) {
-            for (i = 0; i < n; i++, vinfo++) {
-                if (vinfo->visual == DefaultVisual(dpy, screen_number))
-                    break;
-            }
-        } else {
-            int maxdepth = 0;
-            XVisualInfo *v = NULL;
-
-            for (i = 0; i < n; i++, vinfo++)
-                if (vinfo->depth > maxdepth) {
-                    maxdepth = vinfo->depth;
-                    v = vinfo;
-                }
-            vinfo = v;
-        }
-    }
-
-    if (vinfo->class == PseudoColor || vinfo->class == DirectColor ||
-        vinfo->class == GrayScale)
-        status = readwrite_map(dpy, vinfo, colormap);
-    else if (vinfo->class == TrueColor)
-        status = TRUEMATCH(red_mult, red_max, red_mask) &&
-            TRUEMATCH(green_mult, green_max, green_mask) &&
-            TRUEMATCH(blue_mult, blue_max, blue_mask);
-    else
-        status = readonly_map(dpy, vinfo, colormap);
-
-    XFree((char *) vpointer);
-    return status;
-}
-
-/****************************************************************************/
-static Status
-readwrite_map(Display * dpy, XVisualInfo * vinfo,
-              XStandardColormap * colormap)
-{
-    register unsigned long i, n;        /* index counters */
-    unsigned long ncolors;      /* number of colors to be defined */
-    int npixels;                /* number of pixels allocated R/W */
-    int first_index;            /* first index of pixels to use */
-    int remainder;              /* first index of remainder */
-    XColor color;               /* the definition of a color */
-    unsigned long *pixels;      /* array of colormap pixels */
-    unsigned long delta;
-
-
-    /* Determine ncolors, the number of colors to be defined.
-     * Insure that 1 < ncolors <= the colormap size.
-     */
-    if (vinfo->class == DirectColor) {
-        ncolors = colormap->red_max;
-        if (colormap->green_max > ncolors)
-            ncolors = colormap->green_max;
-        if (colormap->blue_max > ncolors)
-            ncolors = colormap->blue_max;
-        ncolors++;
-        delta = lowbit(vinfo->red_mask) +
-            lowbit(vinfo->green_mask) + lowbit(vinfo->blue_mask);
-    } else {
-        ncolors = colormap->red_max * colormap->red_mult +
-            colormap->green_max * colormap->green_mult +
-            colormap->blue_max * colormap->blue_mult + 1;
-        delta = 1;
-    }
-    if (ncolors <= 1 || (int) ncolors > vinfo->colormap_size)
-        return 0;
-
-    /* Allocate Read/Write as much of the colormap as we can possibly get.
-     * Then insure that the pixels we were allocated are given in 
-     * monotonically increasing order, using a quicksort.  Next, insure
-     * that our allocation includes a subset of contiguous pixels at least
-     * as long as the number of colors to be defined.  Now we know that 
-     * these conditions are met:
-     *  1) There are no free cells in the colormap.
-     *  2) We have a contiguous sequence of pixels, monotonically 
-     *     increasing, of length >= the number of colors requested.
-     *
-     * One cell at a time, we will free, compute the next color value, 
-     * then allocate read only.  This takes a long time.
-     * This is done to insure that cells are allocated read only in the
-     * contiguous order which we prefer.  If the server has a choice of
-     * cells to grant to an allocation request, the server may give us any
-     * cell, so that is why we do these slow gymnastics.
-     */
-
-    if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size,
-                                           sizeof(unsigned long))) == NULL)
-        return 0;
-
-    if ((npixels = ROmap(dpy, colormap->colormap, pixels,
-                         vinfo->colormap_size, ncolors)) == 0) {
-        free((char *) pixels);
-        return 0;
-    }
-
-    qsort((char *) pixels, npixels, sizeof(unsigned long), compare);
-
-    if (!contiguous
-        (pixels, npixels, ncolors, delta, &first_index, &remainder)) {
-        /* can't find enough contiguous cells, give up */
-        XFreeColors(dpy, colormap->colormap, pixels, npixels,
-                    (unsigned long) 0);
-        free((char *) pixels);
-        return 0;
-    }
-    colormap->base_pixel = pixels[first_index];
-
-    /* construct a gray map */
-    if (colormap->red_mult == 1 && colormap->green_mult == 1 &&
-        colormap->blue_mult == 1)
-        for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) {
-            color.pixel = n;
-            color.blue = color.green = color.red =
-                (unsigned short) ((i * 65535) / (colormap->red_max +
-                                                 colormap->green_max +
-                                                 colormap->blue_max));
-
-            if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
-                            first_index + i))
-                return 0;
-        }
-
-    /* construct a red ramp map */
-    else if (colormap->green_max == 0 && colormap->blue_max == 0)
-        for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) {
-            color.pixel = n;
-            color.red = (unsigned short) ((i * 65535) / colormap->red_max);
-            color.green = color.blue = 0;
-
-            if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
-                            first_index + i))
-                return 0;
-        }
-
-    /* construct a green ramp map */
-    else if (colormap->red_max == 0 && colormap->blue_max == 0)
-        for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) {
-            color.pixel = n;
-            color.green =
-                (unsigned short) ((i * 65535) / colormap->green_max);
-            color.red = color.blue = 0;
-
-            if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
-                            first_index + i))
-                return 0;
-        }
-
-    /* construct a blue ramp map */
-    else if (colormap->red_max == 0 && colormap->green_max == 0)
-        for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) {
-            color.pixel = n;
-            color.blue = (unsigned short) ((i * 65535) / colormap->blue_max);
-            color.red = color.green = 0;
-
-            if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
-                            first_index + i))
-                return 0;
-        }
-
-    /* construct a standard red green blue cube map */
-    else {
-#define calc(max,mult) (((n / colormap->mult) % \
-			 (colormap->max + 1)) * 65535) / colormap->max
-
-        for (n = 0, i = 0; i < ncolors; i++, n += delta) {
-            color.pixel = n + colormap->base_pixel;
-            color.red = calc(red_max, red_mult);
-            color.green = calc(green_max, green_mult);
-            color.blue = calc(blue_max, blue_mult);
-            if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
-                            first_index + i))
-                return 0;
-        }
-#undef calc
-    }
-    /* We have a read-only map defined.  Now free unused cells,
-     * first those occuring before the contiguous sequence begins,
-     * then any following the contiguous sequence.
-     */
-
-    if (first_index)
-        XFreeColors(dpy, colormap->colormap, pixels, first_index,
-                    (unsigned long) 0);
-    if (remainder)
-        XFreeColors(dpy, colormap->colormap,
-                    &(pixels[first_index + ncolors]), remainder,
-                    (unsigned long) 0);
-
-    free((char *) pixels);
-    return 1;
-}
-
-
-/****************************************************************************/
-static int
-ROmap(Display * dpy, Colormap cmap, unsigned long pixels[], int m, int n)
-     /*
-      * dpy     - the X server connection
-      * cmap    - specifies colormap ID
-      * pixels  - returns pixel allocations
-      * m       - specifies colormap size
-      * n       - specifies number of colors
-      */
-{
-    register int p;
-
-    /* first try to allocate the entire colormap */
-    if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
-                         (unsigned) 0, pixels, (unsigned) m))
-        return m;
-
-    /* Allocate all available cells in the colormap, using a binary
-     * algorithm to discover how many cells we can allocate in the colormap.
-     */
-    m--;
-    while (n <= m) {
-        p = n + ((m - n + 1) / 2);
-        if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
-                             (unsigned) 0, pixels, (unsigned) p)) {
-            if (p == m)
-                return p;
-            else {
-                XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
-                n = p;
-            }
-        } else
-            m = p - 1;
-    }
-    return 0;
-}
-
-
-/****************************************************************************/
-static Status
-contiguous(unsigned long pixels[], int npixels, int ncolors,
-           unsigned long delta, int *first, int *rem)
-     /* pixels  - specifies allocated pixels
-      * npixels - specifies count of alloc'd pixels
-      * ncolors - specifies needed sequence length
-      * delta   - between pixels
-      * first   - returns first index of sequence
-      * rem     - returns first index after sequence, or 0, if none follow
-      */
-{
-    register int i = 1;         /* walking index into the pixel array */
-    register int count = 1;     /* length of sequence discovered so far */
-
-    *first = 0;
-    if (npixels == ncolors) {
-        *rem = 0;
-        return 1;
-    }
-    *rem = npixels - 1;
-    while (count < ncolors && ncolors - count <= *rem) {
-        if (pixels[i - 1] + delta == pixels[i])
-            count++;
-        else {
-            count = 1;
-            *first = i;
-        }
-        i++;
-        (*rem)--;
-    }
-    if (count != ncolors)
-        return 0;
-    return 1;
-}
-
-
-/****************************************************************************/
-static Status
-ROorRWcell(Display * dpy, Colormap cmap, unsigned long pixels[],
-           int npixels, XColor * color, unsigned long p)
-{
-    unsigned long pixel;
-    XColor request;
-
-    /* Free the read/write allocation of one cell in the colormap.
-     * Request a read only allocation of one cell in the colormap.
-     * If the read only allocation cannot be granted, give up, because
-     * there must be no free cells in the colormap.
-     * If the read only allocation is granted, but gives us a cell which
-     * is not the one that we just freed, it is probably the case that
-     * we are trying allocate White or Black or some other color which
-     * already has a read-only allocation in the map.  So we try to 
-     * allocate the previously freed cell with a read/write allocation,
-     * because we want contiguous cells for image processing algorithms.
-     */
-
-    pixel = color->pixel;
-    request.red = color->red;
-    request.green = color->green;
-    request.blue = color->blue;
-
-    XFreeColors(dpy, cmap, &pixel, 1, (unsigned long) 0);
-    if (!XAllocColor(dpy, cmap, color)
-        || (color->pixel != pixel &&
-            (!RWcell(dpy, cmap, color, &request, &pixel)))) {
-        free_cells(dpy, cmap, pixels, npixels, (int) p);
-        return 0;
-    }
-    return 1;
-}
-
-
-/****************************************************************************/
-static void
-free_cells(Display * dpy, Colormap cmap, unsigned long pixels[],
-           int npixels, int p)
-     /*
-      * pixels  - to be freed
-      * npixels - original number allocated
-      */
-{
-    /* One of the npixels allocated has already been freed.
-     * p is the index of the freed pixel.
-     * First free the pixels preceeding p, and there are p of them;
-     * then free the pixels following p, there are npixels - p - 1 of them.
-     */
-    XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
-    XFreeColors(dpy, cmap, &(pixels[p + 1]), npixels - p - 1,
-                (unsigned long) 0);
-    free((char *) pixels);
-}
-
-
-/****************************************************************************/
-static Status
-RWcell(Display * dpy, Colormap cmap, XColor * color, XColor * request,
-       unsigned long *pixel)
-{
-    unsigned long n = *pixel;
-
-    XFreeColors(dpy, cmap, &(color->pixel), 1, (unsigned long) 0);
-    if (!XAllocColorCells(dpy, cmap, (Bool) 0, (unsigned long *) NULL,
-                          (unsigned) 0, pixel, (unsigned) 1))
-        return 0;
-    if (*pixel != n) {
-        XFreeColors(dpy, cmap, pixel, 1, (unsigned long) 0);
-        return 0;
-    }
-    color->pixel = *pixel;
-    color->flags = DoRed | DoGreen | DoBlue;
-    color->red = request->red;
-    color->green = request->green;
-    color->blue = request->blue;
-    XStoreColors(dpy, cmap, color, 1);
-    return 1;
-}
-
-
-/****************************************************************************/
-static int
-compare(_Xconst void *e1, _Xconst void *e2)
-{
-    return ((int) (*(long *) e1 - *(long *) e2));
-}
-
-
-/****************************************************************************/
-static Status
-readonly_map(Display * dpy, XVisualInfo * vinfo, XStandardColormap * colormap)
-{
-    int i, last_pixel;
-    XColor color;
-
-    last_pixel = (colormap->red_max + 1) * (colormap->green_max + 1) *
-        (colormap->blue_max + 1) + colormap->base_pixel - 1;
-
-    for (i = colormap->base_pixel; i <= last_pixel; i++) {
-
-        color.pixel = (unsigned long) i;
-        color.red = (unsigned short)
-            (((i / colormap->red_mult) * 65535) / colormap->red_max);
-
-        if (vinfo->class == StaticColor) {
-            color.green = (unsigned short)
-                ((((i / colormap->green_mult) % (colormap->green_max + 1)) *
-                  65535) / colormap->green_max);
-            color.blue = (unsigned short)
-                (((i % colormap->green_mult) * 65535) / colormap->blue_max);
-        } else                  /* vinfo->class == GrayScale, old style allocation XXX */
-            color.green = color.blue = color.red;
-
-        XAllocColor(dpy, colormap->colormap, &color);
-        if (color.pixel != (unsigned long) i)
-            return 0;
-    }
-    return 1;
-}
--- a/src/video/Xext/XmuStdCmap/DelCmap.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/* $Xorg: DelCmap.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
-
-/* 
- 
-Copyright 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/Xmu/DelCmap.c,v 1.6 2001/01/17 19:42:54 dawes Exp $ */
-
-/*
- * Author:  Donna Converse, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include "../extensions/StdCmap.h"
-
-/* To remove any standard colormap property, use XmuDeleteStandardColormap().
- * XmuDeleteStandardColormap() will remove the specified property from the
- * specified screen, releasing any resources used by the colormap(s) of the
- * property if possible.
- */
-
-void
-XmuDeleteStandardColormap(Display * dpy, int screen, Atom property)
-     /* dpy;            - specifies the X server to connect to
-      * screen          - specifies the screen of the display
-      * property        - specifies the standard colormap property
-      */
-{
-    XStandardColormap *stdcmaps, *s;
-    int count = 0;
-
-    if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count,
-                         property)) {
-        for (s = stdcmaps; count > 0; count--, s++) {
-            if ((s->killid == ReleaseByFreeingColormap) &&
-                (s->colormap != None) &&
-                (s->colormap != DefaultColormap(dpy, screen)))
-                XFreeColormap(dpy, s->colormap);
-            else if (s->killid != None)
-                XKillClient(dpy, s->killid);
-        }
-        XDeleteProperty(dpy, RootWindow(dpy, screen), property);
-        XFree((char *) stdcmaps);
-        XSync(dpy, False);
-    }
-}
--- a/src/video/Xext/XmuStdCmap/Distinct.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/* $Xorg: Distinct.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
-
-/*
-
-Copyright 1990, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/Xmu/Distinct.c,v 3.5 2001/07/25 15:04:50 dawes Exp $ */
-
-/*
- * Author:  Keith Packard, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xlib.h>
-#include <stdlib.h>
-#include <X11/Xutil.h>
-#include "../extensions/StdCmap.h"
-
-/*
- * Distinguishable colors routine.  Determines if two colors are
- * distinguishable or not.  Somewhat arbitrary meaning.
- */
-
-#define MIN_DISTINGUISH	10000.0
-
-Bool
-XmuDistinguishableColors(XColor * colors, int count)
-{
-    double deltaRed, deltaGreen, deltaBlue;
-    double dist;
-    int i, j;
-
-    for (i = 0; i < count - 1; i++)
-        for (j = i + 1; j < count; j++) {
-            deltaRed = (double) colors[i].red - (double) colors[j].red;
-            deltaGreen = (double) colors[i].green - (double) colors[j].green;
-            deltaBlue = (double) colors[i].blue - (double) colors[j].blue;
-            dist = deltaRed * deltaRed +
-                deltaGreen * deltaGreen + deltaBlue * deltaBlue;
-            if (dist <= MIN_DISTINGUISH * MIN_DISTINGUISH)
-                return False;
-        }
-    return True;
-}
-
-Bool
-XmuDistinguishablePixels(Display * dpy, Colormap cmap,
-                         unsigned long *pixels, int count)
-{
-    XColor *defs;
-    int i, j;
-    Bool ret;
-
-    for (i = 0; i < count - 1; i++)
-        for (j = i + 1; j < count; j++)
-            if (pixels[i] == pixels[j])
-                return False;
-    defs = (XColor *) malloc(count * sizeof(XColor));
-    if (!defs)
-        return False;
-    for (i = 0; i < count; i++)
-        defs[i].pixel = pixels[i];
-    XQueryColors(dpy, cmap, defs, count);
-    ret = XmuDistinguishableColors(defs, count);
-    free((char *) defs);
-    return ret;
-}
--- a/src/video/Xext/XmuStdCmap/LookupCmap.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,323 +0,0 @@
-/* $Xorg: LookupCmap.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
-
-/* 
- 
-Copyright 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/Xmu/LookupCmap.c,v 1.7 2001/07/25 15:04:50 dawes Exp $ */
-
-/*
- * Author:  Donna Converse, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/Xutil.h>
-#include "../extensions/StdCmap.h"
-#include <stdlib.h>
-
-/*
- * Prototypes
- */
-static Status lookup(Display *, int, VisualID, Atom, XStandardColormap *,
-                     Bool);
-
-/*
- * To create a standard colormap if one does not currently exist, or
- * replace the currently existing standard colormap, use 
- * XmuLookupStandardColormap().
- *
- * Given a screen, a visual, and a property, XmuLookupStandardColormap()
- * will determine the best allocation for the property under the specified
- * visual, and determine the whether to create a new colormap or to use
- * the default colormap of the screen.  It will call XmuStandardColormap()
- * to create the standard colormap.
- *
- * If replace is true, any previous definition of the property will be 
- * replaced.  If retain is true, the property and the colormap will be
- * made permanent for the duration of the server session.  However,
- * pre-existing property definitions which are not replaced cannot be made
- * permanent by a call to XmuLookupStandardColormap(); a request to retain 
- * resources pertains to newly created resources.
- *
- * Returns 0 on failure, non-zero on success.  A request to create a 
- * standard colormap upon a visual which cannot support such a map is
- * considered a failure.  An example of this would be requesting any
- * standard colormap property on a monochrome visual, or, requesting an
- * RGB_BEST_MAP on a display whose colormap size is 16.
- */
-
-Status
-XmuLookupStandardColormap(Display * dpy, int screen, VisualID visualid,
-                          unsigned int depth, Atom property,
-                          Bool replace, Bool retain)
-     /*
-      * dpy             - specifies X server connection
-      * screen          - specifies screen of display
-      * visualid        - specifies the visual type
-      * depth           - specifies  the visual type
-      * property        - a standard colormap property
-      * replace         - specifies whether to replace
-      * retain          - specifies whether to retain
-      */
-{
-    Display *odpy;              /* original display connection */
-    XStandardColormap *colormap;
-    XVisualInfo vinfo_template, *vinfo; /* visual */
-    long vinfo_mask;
-    unsigned long r_max, g_max, b_max;  /* allocation */
-    int count;
-    Colormap cmap;              /* colormap ID */
-    Status status = 0;
-
-
-    /* Match the requested visual */
-
-    vinfo_template.visualid = visualid;
-    vinfo_template.screen = screen;
-    vinfo_template.depth = depth;
-    vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
-    if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &count)) ==
-        NULL)
-        return 0;
-
-    /* Monochrome visuals have no standard maps */
-
-    if (vinfo->colormap_size <= 2) {
-        XFree((char *) vinfo);
-        return 0;
-    }
-
-    /* If the requested property already exists on this screen, and, 
-     * if the replace flag has not been set to true, return success.
-     * lookup() will remove a pre-existing map if replace is true.
-     */
-
-    if (lookup(dpy, screen, visualid, property, (XStandardColormap *) NULL,
-               replace) && !replace) {
-        XFree((char *) vinfo);
-        return 1;
-    }
-
-    /* Determine the best allocation for this property under the requested
-     * visualid and depth, and determine whether or not to use the default
-     * colormap of the screen.
-     */
-
-    if (!XmuGetColormapAllocation(vinfo, property, &r_max, &g_max, &b_max)) {
-        XFree((char *) vinfo);
-        return 0;
-    }
-
-    cmap = (property == XA_RGB_DEFAULT_MAP &&
-            visualid == XVisualIDFromVisual(DefaultVisual(dpy, screen)))
-        ? DefaultColormap(dpy, screen) : None;
-
-    /* If retaining resources, open a new connection to the same server */
-
-    if (retain) {
-        odpy = dpy;
-        if ((dpy = XOpenDisplay(XDisplayString(odpy))) == NULL) {
-            XFree((char *) vinfo);
-            return 0;
-        }
-    }
-
-    /* Create the standard colormap */
-
-    colormap = XmuStandardColormap(dpy, screen, visualid, depth, property,
-                                   cmap, r_max, g_max, b_max);
-
-    /* Set the standard colormap property */
-
-    if (colormap) {
-        XGrabServer(dpy);
-
-        if (lookup(dpy, screen, visualid, property, colormap, replace) &&
-            !replace) {
-            /* Someone has defined the property since we last looked.
-             * Since we will not replace it, release our own resources.
-             * If this is the default map, our allocations will be freed 
-             * when this connection closes.
-             */
-            if (colormap->killid == ReleaseByFreeingColormap)
-                XFreeColormap(dpy, colormap->colormap);
-        } else if (retain) {
-            XSetCloseDownMode(dpy, RetainPermanent);
-        }
-        XUngrabServer(dpy);
-        XFree((char *) colormap);
-        status = 1;
-    }
-
-    if (retain)
-        XCloseDisplay(dpy);
-    XFree((char *) vinfo);
-    return status;
-}
-
-/***************************************************************************/
-
-/* Lookup a standard colormap property.  If the property is RGB_DEFAULT_MAP,
- * the visualid is used to determine whether the indicated standard colormap
- * exists.  If the map exists and replace is true, delete the resources used
- * by the map and remove the property.  Return true if the map exists,
- * or did exist and was deleted; return false if the map was not found.
- *
- * Note that this is not the way that a Status return is normally used.
- *
- * If new is not NULL, new points to an XStandardColormap structure which
- * describes a standard colormap of the specified property.  It will be made
- * a standard colormap of the screen if none already exists, or if replace 
- * is true.
- */
-
-static Status
-lookup(Display * dpy, int screen, VisualID visualid, Atom property,
-       XStandardColormap * cnew, Bool replace)
-     /*
-      * dpy             - specifies display connection
-      * screen          - specifies screen number
-      * visualid        - specifies visualid for std map
-      * property        - specifies colormap property name
-      * cnew            - specifies a standard colormap
-      * replace         - specifies whether to replace
-      */
-{
-    register int i;
-    int count;
-    XStandardColormap *stdcmaps, *s;
-    Window win = RootWindow(dpy, screen);
-
-    /* The property does not already exist */
-
-    if (!XGetRGBColormaps(dpy, win, &stdcmaps, &count, property)) {
-        if (cnew)
-            XSetRGBColormaps(dpy, win, cnew, 1, property);
-        return 0;
-    }
-
-    /* The property exists and is not describing the RGB_DEFAULT_MAP */
-
-    if (property != XA_RGB_DEFAULT_MAP) {
-        if (replace) {
-            XmuDeleteStandardColormap(dpy, screen, property);
-            if (cnew)
-                XSetRGBColormaps(dpy, win, cnew, 1, property);
-        }
-        XFree((char *) stdcmaps);
-        return 1;
-    }
-
-    /* The property exists and is RGB_DEFAULT_MAP */
-
-    for (i = 0, s = stdcmaps; (i < count) && (s->visualid != visualid);
-         i++, s++);
-
-    /* No RGB_DEFAULT_MAP property matches the given visualid */
-
-    if (i == count) {
-        if (cnew) {
-            XStandardColormap *m, *maps;
-
-            s = (XStandardColormap *) malloc((unsigned) ((count + 1) * sizeof
-                                                         (XStandardColormap)));
-
-            for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) {
-                m->colormap = maps->colormap;
-                m->red_max = maps->red_max;
-                m->red_mult = maps->red_mult;
-                m->green_max = maps->green_max;
-                m->green_mult = maps->green_mult;
-                m->blue_max = maps->blue_max;
-                m->blue_mult = maps->blue_mult;
-                m->base_pixel = maps->base_pixel;
-                m->visualid = maps->visualid;
-                m->killid = maps->killid;
-            }
-            m->colormap = cnew->colormap;
-            m->red_max = cnew->red_max;
-            m->red_mult = cnew->red_mult;
-            m->green_max = cnew->green_max;
-            m->green_mult = cnew->green_mult;
-            m->blue_max = cnew->blue_max;
-            m->blue_mult = cnew->blue_mult;
-            m->base_pixel = cnew->base_pixel;
-            m->visualid = cnew->visualid;
-            m->killid = cnew->killid;
-
-            XSetRGBColormaps(dpy, win, s, ++count, property);
-            free((char *) s);
-        }
-        XFree((char *) stdcmaps);
-        return 0;
-    }
-
-    /* Found an RGB_DEFAULT_MAP property with a matching visualid */
-
-    if (replace) {
-        /* Free old resources first - we may need them, particularly in 
-         * the default colormap of the screen.  However, because of this,
-         * it is possible that we will destroy the old resource and fail 
-         * to create a new one if XmuStandardColormap() fails.
-         */
-
-        if (count == 1) {
-            XmuDeleteStandardColormap(dpy, screen, property);
-            if (cnew)
-                XSetRGBColormaps(dpy, win, cnew, 1, property);
-        } else {
-            XStandardColormap *map;
-
-            /* s still points to the matching standard colormap */
-
-            if (s->killid == ReleaseByFreeingColormap) {
-                if ((s->colormap != None) &&
-                    (s->colormap != DefaultColormap(dpy, screen)))
-                    XFreeColormap(dpy, s->colormap);
-            } else if (s->killid != None)
-                XKillClient(dpy, s->killid);
-
-            map = (cnew) ? cnew : stdcmaps + --count;
-
-            s->colormap = map->colormap;
-            s->red_max = map->red_max;
-            s->red_mult = map->red_mult;
-            s->green_max = map->green_max;
-            s->green_mult = map->green_mult;
-            s->blue_max = map->blue_max;
-            s->blue_mult = map->blue_mult;
-            s->visualid = map->visualid;
-            s->killid = map->killid;
-
-            XSetRGBColormaps(dpy, win, stdcmaps, count, property);
-        }
-    }
-    XFree((char *) stdcmaps);
-    return 1;
-}
--- a/src/video/Xext/XmuStdCmap/StdCmap.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,236 +0,0 @@
-/* $Xorg: StdCmap.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
-
-/* 
-
-Copyright 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/Xmu/StdCmap.c,v 1.5 2001/01/17 19:42:56 dawes Exp $ */
-
-/*
- * Author:  Donna Converse, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/Xutil.h>
-#include "../extensions/StdCmap.h"
-
-#define lowbit(x) ((x) & (~(x) + 1))
-
-/*
- * Prototypes
- */
-/* argument restrictions */
-static Status valid_args(XVisualInfo *, unsigned long, unsigned long,
-                         unsigned long, Atom);
-
-/*
- * To create any one standard colormap, use XmuStandardColormap().
- *
- * Create a standard colormap for the given screen, visualid, and visual
- * depth, with the given red, green, and blue maximum values, with the
- * given standard property name.  Return a pointer to an XStandardColormap
- * structure which describes the newly created colormap, upon success.
- * Upon failure, return NULL.
- * 
- * XmuStandardColormap() calls XmuCreateColormap() to create the map.
- *
- * Resources created by this function are not made permanent; that is the
- * caller's responsibility.
- */
-
-XStandardColormap *
-XmuStandardColormap(Display * dpy, int screen, VisualID visualid,
-                    unsigned int depth, Atom property, Colormap cmap,
-                    unsigned long red_max, unsigned long green_max,
-                    unsigned long blue_max)
-     /*
-      * dpy                             - specifies X server connection
-      * screen                          - specifies display screen
-      * visualid                        - identifies the visual type
-      * depth                           - identifies the visual type
-      * property                        - a standard colormap property
-      * cmap                            - specifies colormap ID or None
-      * red_max, green_max, blue_max    - allocations
-      */
-{
-    XStandardColormap *stdcmap;
-    Status status;
-    XVisualInfo vinfo_template, *vinfo;
-    long vinfo_mask;
-    int n;
-
-    /* Match the required visual information to an actual visual */
-    vinfo_template.visualid = visualid;
-    vinfo_template.screen = screen;
-    vinfo_template.depth = depth;
-    vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
-    if ((vinfo =
-         XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
-        return 0;
-
-    /* Check the validity of the combination of visual characteristics,
-     * allocation, and colormap property.  Create an XStandardColormap
-     * structure.
-     */
-
-    if (!valid_args(vinfo, red_max, green_max, blue_max, property)
-        || ((stdcmap = XAllocStandardColormap()) == NULL)) {
-        XFree((char *) vinfo);
-        return 0;
-    }
-
-    /* Fill in the XStandardColormap structure */
-
-    if (cmap == DefaultColormap(dpy, screen)) {
-        /* Allocating out of the default map, cannot use XFreeColormap() */
-        Window win = XCreateWindow(dpy, RootWindow(dpy, screen), 1, 1, 1, 1,
-                                   0, 0, InputOnly, vinfo->visual,
-                                   (unsigned long) 0,
-                                   (XSetWindowAttributes *) NULL);
-        stdcmap->killid = (XID) XCreatePixmap(dpy, win, 1, 1, depth);
-        XDestroyWindow(dpy, win);
-        stdcmap->colormap = cmap;
-    } else {
-        stdcmap->killid = ReleaseByFreeingColormap;
-        stdcmap->colormap = XCreateColormap(dpy, RootWindow(dpy, screen),
-                                            vinfo->visual, AllocNone);
-    }
-    stdcmap->red_max = red_max;
-    stdcmap->green_max = green_max;
-    stdcmap->blue_max = blue_max;
-    if (property == XA_RGB_GRAY_MAP)
-        stdcmap->red_mult = stdcmap->green_mult = stdcmap->blue_mult = 1;
-    else if (vinfo->class == TrueColor || vinfo->class == DirectColor) {
-        stdcmap->red_mult = lowbit(vinfo->red_mask);
-        stdcmap->green_mult = lowbit(vinfo->green_mask);
-        stdcmap->blue_mult = lowbit(vinfo->blue_mask);
-    } else {
-        stdcmap->red_mult = (red_max > 0)
-            ? (green_max + 1) * (blue_max + 1) : 0;
-        stdcmap->green_mult = (green_max > 0) ? blue_max + 1 : 0;
-        stdcmap->blue_mult = (blue_max > 0) ? 1 : 0;
-    }
-    stdcmap->base_pixel = 0;    /* base pixel may change */
-    stdcmap->visualid = vinfo->visualid;
-
-    /* Make the colormap */
-
-    status = XmuCreateColormap(dpy, stdcmap);
-
-    /* Clean up */
-
-    XFree((char *) vinfo);
-    if (!status) {
-
-        /* Free the colormap or the pixmap, if we created one */
-        if (stdcmap->killid == ReleaseByFreeingColormap)
-            XFreeColormap(dpy, stdcmap->colormap);
-        else if (stdcmap->killid != None)
-            XFreePixmap(dpy, stdcmap->killid);
-
-        XFree((char *) stdcmap);
-        return (XStandardColormap *) NULL;
-    }
-    return stdcmap;
-}
-
-/****************************************************************************/
-static Status
-valid_args(XVisualInfo * vinfo, unsigned long red_max,
-           unsigned long green_max, unsigned long blue_max, Atom property)
-     /*
-      * vinfo                           - specifies visual
-      * red_max, green_max, blue_max    - specifies alloc
-      * property                        - specifies property name
-      */
-{
-    unsigned long ncolors;      /* number of colors requested */
-
-    /* Determine that the number of colors requested is <= map size */
-
-    if ((vinfo->class == DirectColor) || (vinfo->class == TrueColor)) {
-        unsigned long mask;
-
-        mask = vinfo->red_mask;
-        while (!(mask & 1))
-            mask >>= 1;
-        if (red_max > mask)
-            return 0;
-        mask = vinfo->green_mask;
-        while (!(mask & 1))
-            mask >>= 1;
-        if (green_max > mask)
-            return 0;
-        mask = vinfo->blue_mask;
-        while (!(mask & 1))
-            mask >>= 1;
-        if (blue_max > mask)
-            return 0;
-    } else if (property == XA_RGB_GRAY_MAP) {
-        ncolors = red_max + green_max + blue_max + 1;
-        if (ncolors > vinfo->colormap_size)
-            return 0;
-    } else {
-        ncolors = (red_max + 1) * (green_max + 1) * (blue_max + 1);
-        if (ncolors > vinfo->colormap_size)
-            return 0;
-    }
-
-    /* Determine that the allocation and visual make sense for the property */
-
-    switch (property) {
-    case XA_RGB_DEFAULT_MAP:
-        if (red_max == 0 || green_max == 0 || blue_max == 0)
-            return 0;
-        break;
-    case XA_RGB_RED_MAP:
-        if (red_max == 0)
-            return 0;
-        break;
-    case XA_RGB_GREEN_MAP:
-        if (green_max == 0)
-            return 0;
-        break;
-    case XA_RGB_BLUE_MAP:
-        if (blue_max == 0)
-            return 0;
-        break;
-    case XA_RGB_BEST_MAP:
-        if (red_max == 0 || green_max == 0 || blue_max == 0)
-            return 0;
-        break;
-    case XA_RGB_GRAY_MAP:
-        if (red_max == 0 || blue_max == 0 || green_max == 0)
-            return 0;
-        break;
-    default:
-        return 0;
-    }
-    return 1;
-}
--- a/src/video/Xext/XmuStdCmap/VisCmap.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,184 +0,0 @@
-/* $Xorg: VisCmap.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
-
-/* 
-
-Copyright 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/Xmu/VisCmap.c,v 1.6 2001/01/17 19:42:57 dawes Exp $ */
-
-/*
- * Author:  Donna Converse, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <math.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/Xutil.h>
-#include "../extensions/StdCmap.h"
-
-/*
- * To create all of the appropriate standard colormaps for a given visual on
- * a given screen, use XmuVisualStandardColormaps.
- * 
- * Define all appropriate standard colormap properties for the given visual.
- * If replace is true, any previous definition will be removed.
- * If retain is true, new properties will be retained for the duration of
- * the server session.  Return 0 on failure, non-zero on success.
- * On failure, no new properties will be defined, and, old ones may have
- * been removed if replace was True.
- *
- * Not all standard colormaps are meaningful to all visual classes.  This
- * routine will check and define the following properties for the following
- * classes, provided that the size of the colormap is not too small.
- *
- *	DirectColor and PseudoColor
- *	    RGB_DEFAULT_MAP
- *	    RGB_BEST_MAP
- *	    RGB_RED_MAP
- *	    RGB_GREEN_MAP
- * 	    RGB_BLUE_MAP
- *          RGB_GRAY_MAP
- *
- *	TrueColor and StaticColor
- *	    RGB_BEST_MAP
- *
- *	GrayScale and StaticGray
- *	    RGB_GRAY_MAP
- */
-
-Status
-XmuVisualStandardColormaps(Display * dpy, int screen, VisualID visualid,
-                           unsigned int depth, Bool replace, Bool retain)
-     /*
-      * dpy                     - specifies server connection
-      * screen                  - specifies screen number
-      * visualid                - specifies the visual
-      * depth                   - specifies the visual
-      * replace specifies       - whether to replace
-      * retain                  - specifies whether to retain
-      */
-{
-    Status status;
-    int n;
-    long vinfo_mask;
-    XVisualInfo vinfo_template, *vinfo;
-
-    status = 0;
-    vinfo_template.screen = screen;
-    vinfo_template.visualid = visualid;
-    vinfo_template.depth = depth;
-    vinfo_mask = VisualScreenMask | VisualIDMask | VisualDepthMask;
-    if ((vinfo =
-         XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
-        return 0;
-
-    if (vinfo->colormap_size <= 2) {
-        /* Monochrome visuals have no standard maps; considered successful */
-        XFree((char *) vinfo);
-        return 1;
-    }
-
-    switch (vinfo->class) {
-    case PseudoColor:
-    case DirectColor:
-        status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
-                                           XA_RGB_DEFAULT_MAP, replace,
-                                           retain);
-        if (!status)
-            break;
-
-        status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
-                                           XA_RGB_GRAY_MAP, replace, retain);
-        if (!status) {
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
-            break;
-        }
-
-        status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
-                                           XA_RGB_RED_MAP, replace, retain);
-        if (!status) {
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
-            break;
-        }
-
-        status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
-                                           XA_RGB_GREEN_MAP, replace, retain);
-        if (!status) {
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
-            break;
-        }
-
-        status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
-                                           XA_RGB_BLUE_MAP, replace, retain);
-        if (!status) {
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP);
-            break;
-        }
-        /* fall through */
-
-    case StaticColor:
-    case TrueColor:
-
-        status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
-                                           XA_RGB_BEST_MAP, replace, retain);
-        if (!status && (vinfo->class == PseudoColor ||
-                        vinfo->class == DirectColor)) {
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP);
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_BLUE_MAP);
-        }
-        break;
-        /* the end for PseudoColor, DirectColor, StaticColor, and TrueColor */
-
-    case GrayScale:
-        status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
-                                           XA_RGB_DEFAULT_MAP, replace,
-                                           retain);
-        if (!status)
-            break;
-     /*FALLTHROUGH*/ case StaticGray:
-
-        status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
-                                           XA_RGB_GRAY_MAP, replace, retain);
-        if (!status && vinfo->class == GrayScale) {
-            XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
-            break;
-        }
-    }
-
-    XFree((char *) vinfo);
-    return status;
-}
--- a/src/video/Xext/extensions/StdCmap.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/* $Xorg: StdCmap.h,v 1.5 2001/02/09 02:03:53 xorgcvs Exp $ */
-
-/*
- 
-Copyright 1988, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/Xmu/StdCmap.h,v 1.8 2001/01/23 17:38:14 keithp Exp $ */
-
-/*
- * The interfaces described by this header file are for miscellaneous utilities
- * and are not part of the Xlib standard.
- */
-
-#ifndef _XMU_STDCMAP_H_
-#define _XMU_STDCMAP_H_
-
-#include <X11/Xfuncproto.h>
-#include "SDL_name.h"
-
-_XFUNCPROTOBEGIN extern Status XmuAllStandardColormaps(Display * dpy);
-
-extern Status XmuCreateColormap(Display * dpy, XStandardColormap * colormap);
-
-extern void XmuDeleteStandardColormap
-    (Display * dpy, int screen, Atom property);
-
-extern Status XmuGetColormapAllocation
-    (XVisualInfo * vinfo,
-     Atom property,
-     unsigned long *red_max_return,
-     unsigned long *green_max_return, unsigned long *blue_max_return);
-
-extern Status XmuLookupStandardColormap
-    (Display * dpy,
-     int screen,
-     VisualID visualid,
-     unsigned int depth, Atom property, Bool replace, Bool retain);
-
-extern XStandardColormap *XmuStandardColormap
-    (Display * dpy,
-     int screen,
-     VisualID visualid,
-     unsigned int depth,
-     Atom property,
-     Colormap cmap,
-     unsigned long red_max, unsigned long green_max, unsigned long blue_max);
-
-extern Status XmuVisualStandardColormaps
-    (Display * dpy,
-     int screen,
-     VisualID visualid, unsigned int depth, Bool replace, Bool retain);
-
-extern Bool XmuDistinguishableColors(XColor * colors, int count);
-
-extern Bool XmuDistinguishablePixels
-    (Display * dpy, Colormap cmap, unsigned long *pixels, int count);
-
-_XFUNCPROTOEND
-#endif /* _XMU_STDCMAP_H_ */
--- a/src/video/android/SDL_androidgl.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/android/SDL_androidgl.c	Sun Feb 06 21:23:32 2011 -0800
@@ -56,7 +56,7 @@
 Android_GL_CreateContext(_THIS, SDL_Window * window)
 {
     Android_JNI_CreateContext();
-    return 1;
+    return (SDL_GLContext)1;
 }
 
 int
--- a/src/video/cocoa/SDL_cocoamodes.m	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/cocoa/SDL_cocoamodes.m	Sun Feb 06 21:23:32 2011 -0800
@@ -117,8 +117,8 @@
     mode->format = SDL_PIXELFORMAT_UNKNOWN;
     switch (bpp) {
     case 8:
-        mode->format = SDL_PIXELFORMAT_INDEX8;
-        break;
+        /* We don't support palettized modes now */
+        return SDL_FALSE;
     case 16:
         mode->format = SDL_PIXELFORMAT_ARGB1555;
         break;
--- a/src/video/directfb/SDL_DirectFB_WM.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_WM.c	Sun Feb 06 21:23:32 2011 -0800
@@ -18,14 +18,13 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
-
-//#include "SDL_syswm.h"
-//#include "../SDL_sysvideo.h"
-//#include "../../events/SDL_keyboard_c.h"
 
 #include "SDL_DirectFB_video.h"
+#include "SDL_DirectFB_window.h"
 
 #include "../../events/SDL_windowevents_c.h"
 
@@ -127,6 +126,11 @@
     if (!windata->is_managed || (window->flags & SDL_WINDOW_FULLSCREEN))
         return;
 
+    SDL_DFB_CHECK(s->SetSrcBlendFunction(s, DSBF_ONE));
+    SDL_DFB_CHECK(s->SetDstBlendFunction(s, DSBF_ZERO));
+    SDL_DFB_CHECK(s->SetDrawingFlags(s, DSDRAW_NOFX));
+    SDL_DFB_CHECK(s->SetBlittingFlags(s, DSBLIT_NOFX));
+
 	LoadFont(_this, window);
     //s->SetDrawingFlags(s, DSDRAW_BLEND);
     s->SetColor(s, COLOR_EXPAND(t->frame_color));
@@ -181,8 +185,10 @@
 DirectFB_WM_GetClientSize(_THIS, SDL_Window * window, int *cw, int *ch)
 {
     SDL_DFB_WINDOWDATA(window);
+	IDirectFBWindow *dfbwin = windata->dfbwin;
 
-    SDL_DFB_CHECK(windata->window->GetSize(windata->window, cw, ch));
+    SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, cw, ch));
+    dfbwin->GetSize(dfbwin, cw, ch);
     *cw -= windata->theme.left_size + windata->theme.right_size;
     *ch -=
         windata->theme.top_size + windata->theme.caption_size +
@@ -197,6 +203,9 @@
 
     if (!windata->is_managed)
         windata->theme = theme_none;
+    else if (flags & SDL_WINDOW_BORDERLESS)
+    	//desc.caps |= DWCAPS_NODECORATION;)
+    	windata->theme = theme_none;
     else if (flags & SDL_WINDOW_FULLSCREEN) {
         windata->theme = theme_none;
     } else if (flags & SDL_WINDOW_MAXIMIZED) {
@@ -220,37 +229,6 @@
         windata->theme.caption_size + windata->theme.bottom_size;
 }
 
-void
-DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window)
-{
-    SDL_DFB_WINDOWDATA(window);
-    SDL_VideoDisplay *display = window->display;
-
-    SDL_DFB_CHECK(windata->window->GetPosition(windata->window,
-                                 &windata->restore.x, &windata->restore.y));
-    SDL_DFB_CHECK(windata->window->GetSize(windata->window, &windata->restore.w,
-                             &windata->restore.h));
-
-    DirectFB_WM_AdjustWindowLayout(window, window->flags | SDL_WINDOW_MAXIMIZED, display->current_mode.w, display->current_mode.h) ;
-
-    SDL_DFB_CHECK(windata->window->MoveTo(windata->window, 0, 0));
-    SDL_DFB_CHECK(windata->window->Resize(windata->window,
-                            display->current_mode.w, display->current_mode.h));
-}
-
-void
-DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window)
-{
-    SDL_DFB_WINDOWDATA(window);
-
-    DirectFB_WM_AdjustWindowLayout(window, window->flags & ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED), 
-    	windata->restore.w, windata->restore.h);
-
-    SDL_DFB_CHECK(windata->window->Resize(windata->window, windata->restore.w,
-                            windata->restore.h));
-    SDL_DFB_CHECK(windata->window->MoveTo(windata->window, windata->restore.x,
-                            windata->restore.y));
-}
 
 enum
 {
@@ -307,20 +285,20 @@
     return pos;
 }
 
-static int wm_grab;
-static int wm_lastx;
-static int wm_lasty;
-
 int
 DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
 {
     SDL_DFB_DEVICEDATA(_this);
     SDL_DFB_WINDOWDATA(window);
 	DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL);
+	IDirectFBWindow *dfbwin = windata->dfbwin;
+    DFBWindowOptions wopts;
 
     if (!windata->is_managed)
         return 0;
 
+    SDL_DFB_CHECK(dfbwin->GetOptions(dfbwin, &wopts));
+
     switch (evt->type) {
     case DWET_BUTTONDOWN:
         if (evt->buttons & DIBM_LEFT) {
@@ -329,59 +307,99 @@
             case WM_POS_NONE:
                 return 0;
             case WM_POS_CLOSE:
-		        wm_grab = WM_POS_NONE;
+		        windata->wm_grab = WM_POS_NONE;
                 SDL_SendWindowEvent(window, SDL_WINDOWEVENT_CLOSE, 0,
                                     0);
                 return 1;
             case WM_POS_MAX:
-		        wm_grab = WM_POS_NONE;
-                if (window->flags & SDL_WINDOW_MAXIMIZED) {
-                	SDL_RestoreWindow(window);
-                } else {
-                    SDL_MaximizeWindow(window);
-                }
+		        windata->wm_grab = WM_POS_NONE;
+				if (window->flags & SDL_WINDOW_MAXIMIZED) {
+					SDL_RestoreWindow(window);
+				} else {
+					SDL_MaximizeWindow(window);
+				}
                 return 1;
             case WM_POS_CAPTION:
-                DirectFB_RaiseWindow(_this, window);
+            	if (!(wopts & DWOP_KEEP_STACKING)) {
+	                DirectFB_RaiseWindow(_this, window);
+	            }
+            	if (window->flags & SDL_WINDOW_MAXIMIZED)
+            		return 1;
                 /* fall through */
             default:
-                wm_grab = pos;
+                windata->wm_grab = pos;
                 if (gwindata != NULL)
-	                SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window));
-                SDL_DFB_CHECK(windata->window->GrabPointer(windata->window));
-                wm_lastx = evt->cx;
-                wm_lasty = evt->cy;
+	                SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin));
+                SDL_DFB_CHECK(dfbwin->GrabPointer(dfbwin));
+                windata->wm_lastx = evt->cx;
+                windata->wm_lasty = evt->cy;
             }
         }
         return 1;
     case DWET_BUTTONUP:
+        if (!windata->wm_grab)
+            return 0;
+        if (!(evt->buttons & DIBM_LEFT)) {
+            if (windata->wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) {
+                int dx = evt->cx - windata->wm_lastx;
+                int dy = evt->cy - windata->wm_lasty;
+
+            	if (!(wopts & DWOP_KEEP_SIZE)) {
+                    int cw, ch;
+			        if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM)
+			        	dx = 0;
+			        else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT)
+			        	dy = 0;
+		            SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch));
+
+		            /* necessary to trigger an event - ugly*/
+					SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL));
+		            SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx + 1, ch + dy));
+					SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL));
+
+		            SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy));
+            	}
+            }
+            SDL_DFB_CHECK(dfbwin->UngrabPointer(dfbwin));
+            if (gwindata != NULL)
+                SDL_DFB_CHECK(gwindata->dfbwin->GrabPointer(gwindata->dfbwin));
+            windata->wm_grab = WM_POS_NONE;
+            return 1;
+        }
         break;
     case DWET_MOTION:
-        if (!wm_grab)
+        if (!windata->wm_grab)
             return 0;
         if (evt->buttons & DIBM_LEFT) {
-            int dx = evt->cx - wm_lastx;
-            int dy = evt->cy - wm_lasty;
-            int cw, ch;
+        	int dx = evt->cx - windata->wm_lastx;
+            int dy = evt->cy - windata->wm_lasty;
+
+            if (windata->wm_grab & WM_POS_CAPTION) {
+            	if (!(wopts & DWOP_KEEP_POSITION))
+	                SDL_DFB_CHECK(dfbwin->Move(dfbwin, dx, dy));
+            }
+            if (windata->wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) {
+				if (!(wopts & DWOP_KEEP_SIZE)) {
+					int cw, ch;
+
+					/* Make sure all events are disabled for this operation ! */
+					SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL));
 
-            if (wm_grab & WM_POS_CAPTION)
-                SDL_DFB_CHECK(windata->window->Move(windata->window, dx, dy));
-	        if (wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) {
-	            if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM)
-	            	dx = 0;
-	            else if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT)
-	            	dy = 0;
-                SDL_DFB_CHECK(windata->window->GetSize(windata->window, &cw, &ch));
-                SDL_DFB_CHECK(windata->window->Resize(windata->window, cw + dx, ch + dy));
+					if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM)
+						dx = 0;
+					else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT)
+						dy = 0;
+
+					SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch));
+					SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy));
+
+					SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL));
+				}
             }
-            wm_lastx = evt->cx;
-            wm_lasty = evt->cy;
-            return 1;
+			windata->wm_lastx = evt->cx;
+			windata->wm_lasty = evt->cy;
+			return 1;
         }
-        SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
-        if (gwindata != NULL)
-            SDL_DFB_CHECK(gwindata->window->GrabPointer(gwindata->window));
-        wm_grab = WM_POS_NONE;
         break;
     case DWET_KEYDOWN:
         break;
@@ -392,3 +410,4 @@
     }
     return 0;
 }
+
--- a/src/video/directfb/SDL_DirectFB_WM.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_WM.h	Sun Feb 06 21:23:32 2011 -0800
@@ -18,12 +18,16 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
 
 #ifndef _SDL_directfb_wm_h
 #define _SDL_directfb_wm_h
 
+#include "SDL_DirectFB_video.h"
+
 typedef struct _DFB_Theme DFB_Theme;
 struct _DFB_Theme
 {
@@ -42,8 +46,6 @@
 };
 
 extern void DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h);
-extern void DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window);
-extern void DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window);
 extern void DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window);
 
 extern int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window,
--- a/src/video/directfb/SDL_DirectFB_dyn.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_dyn.c	Sun Feb 06 21:23:32 2011 -0800
@@ -18,7 +18,11 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
+
 #include "SDL_config.h"
 
 #include "SDL_DirectFB_video.h"
@@ -41,6 +45,7 @@
 #define DFB_SYM(ret, name, args, al, func) ret name args { func SDL_DirectFB_Symbols.name al  ; }
 DFB_SYMS
 #undef DFB_SYM
+
 static void *handle = NULL;
 
 int
@@ -55,7 +60,7 @@
 #define DFB_SYM(ret, name, args, al, func) if (!(SDL_DirectFB_Symbols.name = SDL_LoadFunction(handle, # name))) retval = 0;
             DFB_SYMS
 #undef DFB_SYM
-                if (!
+            if (!
                     (SDL_DirectFB_Symbols.directfb_major_version =
                      SDL_LoadFunction(handle, "directfb_major_version")))
                 retval = 0;
--- a/src/video/directfb/SDL_DirectFB_dyn.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_dyn.h	Sun Feb 06 21:23:32 2011 -0800
@@ -18,6 +18,9 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
 
 #ifndef _SDL_DirectFB_dyn_h
@@ -33,7 +36,6 @@
 	DFB_SYM(DFBResult, DirectFBCreate, (IDirectFB **interface), (interface), return) \
 	DFB_SYM(const char *, DirectFBCheckVersion, (unsigned int required_major, unsigned int required_minor, unsigned int required_micro), \
 				(required_major, required_minor, required_micro), return)
-// #define SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "/usr/lib/libdirectfb-1.2.so.0"
 
 int SDL_DirectFB_LoadLibrary(void);
 void SDL_DirectFB_UnLoadLibrary(void);
--- a/src/video/directfb/SDL_DirectFB_events.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_events.c	Sun Feb 06 21:23:32 2011 -0800
@@ -18,17 +18,26 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
 
 /* Handle the event stream, converting DirectFB input events into SDL events */
 
-#include <directfb.h>
+#include "SDL_DirectFB_video.h"
+#include "SDL_DirectFB_window.h"
+#include "SDL_DirectFB_modes.h"
+
+#include "SDL_syswm.h"
 
-#include "../SDL_sysvideo.h"
+#include "../../events/SDL_mouse_c.h"
+#include "../../events/SDL_keyboard_c.h"
+#include "../../events/SDL_windowevents_c.h"
 #include "../../events/SDL_events_c.h"
-#include "../../events/SDL_keyboard_c.h"
 #include "../../events/scancodes_linux.h"
+#include "../../events/scancodes_xfree86.h"
+
 #include "SDL_DirectFB_events.h"
 
 #if USE_MULTI_API
@@ -52,36 +61,36 @@
 };
 
 /* The translation tables from a DirectFB keycode to a SDL keysym */
-static SDLKey oskeymap[256];
+static SDL_ScanCode oskeymap[256];
 
 
 static SDL_KeySym *DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt,
                                          SDL_KeySym * keysym);
-static SDL_KeySym *DirectFB_TranslateKeyInputEvent(_THIS, int index,
-                                                   DFBInputEvent * evt,
+static SDL_KeySym *DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt,
                                                    SDL_KeySym * keysym);
 
-static void DirectFB_InitOSKeymap(_THIS, SDLKey * keypmap, int numkeys);
+static void DirectFB_InitOSKeymap(_THIS, SDL_ScanCode * keypmap, int numkeys);
 static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button);
 
-static void
-DirectFB_SetContext(_THIS, SDL_Window *window)
+static void UnicodeToUtf8( Uint16 w , char *utf8buf)
 {
-#if (DFB_VERSION_ATLEAST(1,0,0))
-    /* FIXME: does not work on 1.0/1.2 with radeon driver
-     *        the approach did work with the matrox driver
-     *        This has simply no effect.
-     */
-
-    SDL_VideoDisplay *display = window->display;
-    DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
-
-	/* FIXME: should we handle the error */
-    if (dispdata->vidIDinuse)
-        SDL_DFB_CHECK(dispdata->vidlayer->SwitchContext(dispdata->vidlayer,
-                                                           DFB_TRUE));
-#endif
-
+        unsigned char *utf8s = (unsigned char *) utf8buf;
+        
+    if ( w < 0x0080 ) {
+        utf8s[0] = ( unsigned char ) w;
+        utf8s[1] = 0;
+    }
+    else if ( w < 0x0800 ) {
+        utf8s[0] = 0xc0 | (( w ) >> 6 );
+        utf8s[1] = 0x80 | (( w ) & 0x3f );
+        utf8s[2] = 0;  
+    }
+    else {
+        utf8s[0] = 0xe0 | (( w ) >> 12 );
+        utf8s[1] = 0x80 | (( ( w ) >> 6 ) & 0x3f );
+        utf8s[2] = 0x80 | (( w ) & 0x3f );
+        utf8s[3] = 0;
+    }    
 }
 
 static void
@@ -163,21 +172,21 @@
 }
 
 static void
-ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags,
-                   DFBWindowEvent * evt)
+ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt)
 {
     SDL_DFB_DEVICEDATA(_this);
+    SDL_DFB_WINDOWDATA(sdlwin);
     SDL_KeySym keysym;
-    char text[5];
+    char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
 
     if (evt->clazz == DFEC_WINDOW) {
         switch (evt->type) {
         case DWET_BUTTONDOWN:
-            if (ClientXY(p, &evt->x, &evt->y)) {
+            if (ClientXY(windata, &evt->x, &evt->y)) {
                 if (!devdata->use_linux_input) {
-                    SDL_SendMouseMotion_ex(p->sdl_window, devdata->mouse_id[0], 0, evt->x,
+                    SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0, evt->x,
                                         evt->y, 0);
-                    SDL_SendMouseButton_ex(p->sdl_window, devdata->mouse_id[0],
+                    SDL_SendMouseButton_ex(sdlwin, devdata->mouse_id[0],
                                         SDL_PRESSED,
                                         DirectFB_TranslateButton
                                         (evt->button));
@@ -187,11 +196,11 @@
             }
             break;
         case DWET_BUTTONUP:
-            if (ClientXY(p, &evt->x, &evt->y)) {
+            if (ClientXY(windata, &evt->x, &evt->y)) {
                 if (!devdata->use_linux_input) {
-                    SDL_SendMouseMotion_ex(p->sdl_window, devdata->mouse_id[0], 0, evt->x,
+                    SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0, evt->x,
                                         evt->y, 0);
-                    SDL_SendMouseButton_ex(p->sdl_window, devdata->mouse_id[0],
+                    SDL_SendMouseButton_ex(sdlwin, devdata->mouse_id[0],
                                         SDL_RELEASED,
                                         DirectFB_TranslateButton
                                         (evt->button));
@@ -201,11 +210,10 @@
             }
             break;
         case DWET_MOTION:
-            if (ClientXY(p, &evt->x, &evt->y)) {
-                SDL_Window *window = p->sdl_window;
+            if (ClientXY(windata, &evt->x, &evt->y)) {
                 if (!devdata->use_linux_input) {
-                    if (!(flags & SDL_WINDOW_INPUT_GRABBED))
-                        SDL_SendMouseMotion_ex(p->sdl_window, devdata->mouse_id[0], 0,
+                    if (!(sdlwin->flags & SDL_WINDOW_INPUT_GRABBED))
+                        SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0,
                                             evt->x, evt->y, 0);
                 } else {
                     /* relative movements are not exact! 
@@ -217,18 +225,19 @@
                         cnt = 0;
                     }
                 }
-                if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS))
-                    SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_ENTER, 0,
+                if (!(sdlwin->flags & SDL_WINDOW_MOUSE_FOCUS))
+                    SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_ENTER, 0,
                                         0);
             }
             break;
         case DWET_KEYDOWN:
             if (!devdata->use_linux_input) {
                 DirectFB_TranslateKey(_this, evt, &keysym);
+                //printf("Scancode %d  %d %d\n", keysym.scancode, evt->key_code, evt->key_id);
                 SDL_SendKeyboardKey_ex(0, SDL_PRESSED, keysym.scancode);
                 if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
-                    SDL_memcpy(text, &keysym.unicode, 4);
-                    text[4] = 0;
+	                SDL_zero(text);
+                    UnicodeToUtf8(keysym.unicode, text);
                     if (*text) {
                         SDL_SendKeyboardText_ex(0, text);
                     }
@@ -242,49 +251,49 @@
             }
             break;
         case DWET_POSITION:
-            if (ClientXY(p, &evt->x, &evt->y)) {
-                SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_MOVED,
+            if (ClientXY(windata, &evt->x, &evt->y)) {
+                SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_MOVED,
                                     evt->x, evt->y);
             }
             break;
         case DWET_POSITION_SIZE:
-            if (ClientXY(p, &evt->x, &evt->y)) {
-                SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_MOVED,
+            if (ClientXY(windata, &evt->x, &evt->y)) {
+                SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_MOVED,
                                     evt->x, evt->y);
             }
             /* fall throught */
         case DWET_SIZE:
             // FIXME: what about < 0
-            evt->w -= (p->theme.right_size + p->theme.left_size);
+            evt->w -= (windata->theme.right_size + windata->theme.left_size);
             evt->h -=
-                (p->theme.top_size + p->theme.bottom_size +
-                 p->theme.caption_size);
-            SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_RESIZED,
+                (windata->theme.top_size + windata->theme.bottom_size +
+                 windata->theme.caption_size);
+            SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_RESIZED,
                                 evt->w, evt->h);
             break;
         case DWET_CLOSE:
-            SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_CLOSE, 0, 0);
+            SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_CLOSE, 0, 0);
             break;
         case DWET_GOTFOCUS:
-            DirectFB_SetContext(_this, p->sdl_window);
-            FocusAllKeyboards(_this, p->sdl_window);
-            SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_FOCUS_GAINED,
+            DirectFB_SetContext(_this, sdlwin);
+            FocusAllKeyboards(_this, sdlwin);
+            SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_FOCUS_GAINED,
                                 0, 0);
             break;
         case DWET_LOSTFOCUS:
-            SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
+            SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
             FocusAllKeyboards(_this, 0);
             break;
         case DWET_ENTER:
             /* SDL_DirectFB_ReshowCursor(_this, 0); */
-            FocusAllMice(_this, p->sdl_window);
+            FocusAllMice(_this, sdlwin);
             // FIXME: when do we really enter ?
-            if (ClientXY(p, &evt->x, &evt->y))
+            if (ClientXY(windata, &evt->x, &evt->y))
                 MotionAllMice(_this, evt->x, evt->y);
-            SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_ENTER, 0, 0);
+            SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_ENTER, 0, 0);
             break;
         case DWET_LEAVE:
-            SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_LEAVE, 0, 0);
+            SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_LEAVE, 0, 0);
             FocusAllMice(_this, 0);
             /* SDL_DirectFB_ReshowCursor(_this, 1); */
             break;
@@ -301,7 +310,7 @@
     SDL_DFB_DEVICEDATA(_this);
     SDL_KeySym keysym;
     int kbd_idx;
-    char text[5];
+    char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
 
     if (!devdata->use_linux_input) {
         if (ievt->type == DIET_AXISMOTION) {
@@ -336,7 +345,7 @@
                             (DFB_WindowData *) window->driverdata;
                         int x, y;
 
-                        windata->window->GetPosition(windata->window, &x, &y);
+                        windata->dfbwin->GetPosition(windata->dfbwin, &x, &y);
                         SDL_SendMouseMotion_ex(window, ievt->device_id, 0,
                                             last_x - (x +
                                                       windata->client.x),
@@ -358,11 +367,12 @@
             break;
         case DIET_KEYPRESS:
             kbd_idx = KbdIndex(_this, ievt->device_id);
-            DirectFB_TranslateKeyInputEvent(_this, kbd_idx, ievt, &keysym);
+            DirectFB_TranslateKeyInputEvent(_this, ievt, &keysym);
+            //printf("Scancode %d  %d %d\n", keysym.scancode, evt->key_code, evt->key_id);
             SDL_SendKeyboardKey_ex(kbd_idx, SDL_PRESSED, keysym.scancode);
             if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
-                SDL_memcpy(text, &keysym.unicode, 4);
-                text[4] = 0;
+                SDL_zero(text);
+                UnicodeToUtf8(keysym.unicode, text);
                 if (*text) {
                     SDL_SendKeyboardText_ex(kbd_idx, text);
                 }
@@ -370,7 +380,7 @@
             break;
         case DIET_KEYRELEASE:
             kbd_idx = KbdIndex(_this, ievt->device_id);
-            DirectFB_TranslateKeyInputEvent(_this, kbd_idx, ievt, &keysym);
+            DirectFB_TranslateKeyInputEvent(_this, ievt, &keysym);
             SDL_SendKeyboardKey_ex(kbd_idx, SDL_RELEASED, keysym.scancode);
             break;
         case DIET_BUTTONPRESS:
@@ -399,29 +409,46 @@
 DirectFB_PumpEventsWindow(_THIS)
 {
     SDL_DFB_DEVICEDATA(_this);
-    DFB_WindowData *p;
     DFBInputEvent ievt;
+    SDL_Window *w;
 
-    for (p = devdata->firstwin; p != NULL; p = p->next) {
+    for (w = devdata->firstwin; w != NULL; w = w->next) {
+        SDL_DFB_WINDOWDATA(w);
         DFBWindowEvent evt;
-        SDL_Window *w = p->sdl_window;
 
-        while (p->eventbuffer->GetEvent(p->eventbuffer,
+        while (windata->eventbuffer->GetEvent(windata->eventbuffer,
                                         DFB_EVENT(&evt)) == DFB_OK) {
-            if (!DirectFB_WM_ProcessEvent(_this, w, &evt))
-                ProcessWindowEvent(_this, p, w->flags, &evt);
+            if (!DirectFB_WM_ProcessEvent(_this, w, &evt)) {
+                /* Send a SDL_SYSWMEVENT if the application wants them */
+                if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
+                    SDL_SysWMmsg wmmsg;
+                    SDL_VERSION(&wmmsg.version);
+                    wmmsg.subsystem = SDL_SYSWM_DIRECTFB;
+                    wmmsg.msg.dfb.event.window = evt;
+                    SDL_SendSysWMEvent(&wmmsg);
+                }
+                ProcessWindowEvent(_this, w, &evt);
+            }
         }
     }
 
     /* Now get relative events in case we need them */
     while (devdata->events->GetEvent(devdata->events,
                                      DFB_EVENT(&ievt)) == DFB_OK) {
+
+    	if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
+            SDL_SysWMmsg wmmsg;
+            SDL_VERSION(&wmmsg.version);
+            wmmsg.subsystem = SDL_SYSWM_DIRECTFB;
+            wmmsg.msg.dfb.event.input = ievt;
+            SDL_SendSysWMEvent(&wmmsg);
+        }
         ProcessInputEvent(_this, &ievt);
     }
 }
 
 void
-DirectFB_InitOSKeymap(_THIS, SDLKey * keymap, int numkeys)
+DirectFB_InitOSKeymap(_THIS, SDL_ScanCode * keymap, int numkeys)
 {
     int i;
 
@@ -552,15 +579,17 @@
 DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_KeySym * keysym)
 {
     SDL_DFB_DEVICEDATA(_this);
+    int kbd_idx = 0; /* Window events lag the device source KbdIndex(_this, evt->device_id); */
+    DFB_KeyboardData *kbd = &devdata->keyboard[kbd_idx];
 
-    if (evt->key_code >= 0 &&
-        evt->key_code < SDL_arraysize(linux_scancode_table))
-        keysym->scancode = linux_scancode_table[evt->key_code];
-    else
-        keysym->scancode = SDL_SCANCODE_UNKNOWN;
+    keysym->scancode = SDL_SCANCODE_UNKNOWN;
+
+    if (kbd->map && evt->key_code >= kbd->map_adjust &&
+	    evt->key_code < kbd->map_size + kbd->map_adjust)
+	    keysym->scancode = kbd->map[evt->key_code - kbd->map_adjust];
 
     if (keysym->scancode == SDL_SCANCODE_UNKNOWN ||
-        devdata->keyboard[0].is_generic) {
+        devdata->keyboard[kbd_idx].is_generic) {
         if (evt->key_id - DIKI_UNKNOWN < SDL_arraysize(oskeymap))
             keysym->scancode = oskeymap[evt->key_id - DIKI_UNKNOWN];
         else
@@ -577,19 +606,20 @@
 }
 
 static SDL_KeySym *
-DirectFB_TranslateKeyInputEvent(_THIS, int index, DFBInputEvent * evt,
+DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt,
                                 SDL_KeySym * keysym)
 {
     SDL_DFB_DEVICEDATA(_this);
+    int kbd_idx = KbdIndex(_this, evt->device_id);
+    DFB_KeyboardData *kbd = &devdata->keyboard[kbd_idx];
 
-    if (evt->key_code >= 0 &&
-        evt->key_code < SDL_arraysize(linux_scancode_table))
-        keysym->scancode = linux_scancode_table[evt->key_code];
-    else
-        keysym->scancode = SDL_SCANCODE_UNKNOWN;
+    keysym->scancode = SDL_SCANCODE_UNKNOWN;
 
-    if (keysym->scancode == SDL_SCANCODE_UNKNOWN ||
-        devdata->keyboard[index].is_generic) {
+    if (kbd->map && evt->key_code >= kbd->map_adjust &&
+	    evt->key_code < kbd->map_size + kbd->map_adjust)
+	    keysym->scancode = kbd->map[evt->key_code - kbd->map_adjust];
+
+    if (keysym->scancode == SDL_SCANCODE_UNKNOWN || devdata->keyboard[kbd_idx].is_generic) {
         if (evt->key_id - DIKI_UNKNOWN < SDL_arraysize(oskeymap))
             keysym->scancode = oskeymap[evt->key_id - DIKI_UNKNOWN];
         else
@@ -652,8 +682,18 @@
         devdata->keyboard[devdata->num_keyboard].id = device_id;
         devdata->keyboard[devdata->num_keyboard].is_generic = 0;
         if (!strncmp("X11", desc.name, 3))
-            devdata->keyboard[devdata->num_keyboard].is_generic = 1;
+        {
+        	devdata->keyboard[devdata->num_keyboard].map = xfree86_scancode_table2;
+        	devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(xfree86_scancode_table2);
+			devdata->keyboard[devdata->num_keyboard].map_adjust = 8;
+        } else {
+        	devdata->keyboard[devdata->num_keyboard].map = linux_scancode_table;
+        	devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(linux_scancode_table);
+			devdata->keyboard[devdata->num_keyboard].map_adjust = 0;
+        }
 
+		SDL_DFB_LOG("Keyboard %d - %s\n", device_id, desc.name);
+		
         SDL_GetDefaultKeymap(keymap);
 #if USE_MULTI_API
         SDL_SetKeymap(devdata->num_keyboard, 0, keymap, SDL_NUM_SCANCODES);
@@ -707,74 +747,3 @@
 
 }
 
-#if 0
-/* FIXME: Remove once determined this is not needed in fullscreen mode */
-void
-DirectFB_PumpEvents(_THIS)
-{
-    SDL_DFB_DEVICEDATA(_this);
-    DFBInputEvent evt;
-    static last_x = 0, last_y = 0;
-
-    while (devdata->eventbuffer->GetEvent(devdata->eventbuffer,
-                                          DFB_EVENT(&evt)) == DFB_OK) {
-        SDL_KeySym keysym;
-        DFBInputDeviceModifierMask mod;
-
-        if (evt.clazz = DFEC_INPUT) {
-            if (evt.flags & DIEF_MODIFIERS)
-                mod = evt.modifiers;
-            else
-                mod = 0;
-
-            switch (evt.type) {
-            case DIET_BUTTONPRESS:
-                posted +=
-                    SDL_PrivateMouseButton(SDL_PRESSED,
-                                           DirectFB_TranslateButton
-                                           (evt.button), 0, 0);
-                break;
-            case DIET_BUTTONRELEASE:
-                posted +=
-                    SDL_PrivateMouseButton(SDL_RELEASED,
-                                           DirectFB_TranslateButton
-                                           (evt.button), 0, 0);
-                break;
-            case DIET_KEYPRESS:
-                posted +=
-                    SDL_PrivateKeyboard(SDL_PRESSED,
-                                        DirectFB_TranslateKey
-                                        (evt.key_id, evt.key_symbol,
-                                         mod, &keysym));
-                break;
-            case DIET_KEYRELEASE:
-                posted +=
-                    SDL_PrivateKeyboard(SDL_RELEASED,
-                                        DirectFB_TranslateKey
-                                        (evt.key_id, evt.key_symbol,
-                                         mod, &keysym));
-                break;
-            case DIET_AXISMOTION:
-                if (evt.flags & DIEF_AXISREL) {
-                    if (evt.axis == DIAI_X)
-                        posted +=
-                            SDL_PrivateMouseMotion(0, 1, evt.axisrel, 0);
-                    else if (evt.axis == DIAI_Y)
-                        posted +=
-                            SDL_PrivateMouseMotion(0, 1, 0, evt.axisrel);
-                } else if (evt.flags & DIEF_AXISABS) {
-                    if (evt.axis == DIAI_X)
-                        last_x = evt.axisabs;
-                    else if (evt.axis == DIAI_Y)
-                        last_y = evt.axisabs;
-                    posted += SDL_PrivateMouseMotion(0, 0, last_x, last_y);
-                }
-                break;
-            default:
-                ;
-            }
-        }
-    }
-}
-#endif
-
--- a/src/video/directfb/SDL_DirectFB_events.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_events.h	Sun Feb 06 21:23:32 2011 -0800
@@ -18,13 +18,19 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
 
-#include "SDL_DirectFB_video.h"
+#ifndef _SDL_DirectFB_events_h
+#define _SDL_DirectFB_events_h
+
+#include "../SDL_sysvideo.h"
 
 /* Functions to be exported */
 extern void DirectFB_InitKeyboard(_THIS);
 extern void DirectFB_QuitKeyboard(_THIS);
 extern void DirectFB_PumpEventsWindow(_THIS);
-extern SDLKey DirectFB_GetLayoutKey(_THIS, SDLKey physicalKey);
+
+#endif
--- a/src/video/directfb/SDL_DirectFB_modes.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_modes.c	Sun Feb 06 21:23:32 2011 -0800
@@ -18,14 +18,17 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
 
 #include "SDL_DirectFB_video.h"
+#include "SDL_DirectFB_modes.h"
 
 #define DFB_MAX_MODES 200
 
-struct scn_callback_t
+struct screen_callback_t
 {
     int numscreens;
     DFBScreenID screenid[DFB_MAX_SCREENS];
@@ -40,103 +43,6 @@
     SDL_DisplayMode *modelist;
 };
 
-static const struct {
-    DFBSurfacePixelFormat dfb;
-    Uint32 sdl;
-} pixelformat_tab[] = 
-{
-    { DSPF_LUT8, SDL_PIXELFORMAT_INDEX8 },              /* 8 bit LUT (8 bit color and alpha lookup from palette) */
-    { DSPF_RGB332, SDL_PIXELFORMAT_RGB332 },            /* 8 bit RGB (1 byte, red 3@5, green 3@2, blue 2@0) */
-    { DSPF_ARGB4444, SDL_PIXELFORMAT_ARGB4444 },        /* 16 bit ARGB (2 byte, alpha 4@12, red 4@8, green 4@4, blue 4@0) */
-    { DSPF_ARGB1555, SDL_PIXELFORMAT_ARGB1555 },        /* 16 bit ARGB (2 byte, alpha 1@15, red 5@10, green 5@5, blue 5@0) */
-    { DSPF_RGB16, SDL_PIXELFORMAT_RGB565 },             /* 16 bit RGB (2 byte, red 5@11, green 6@5, blue 5@0) */
-    { DSPF_RGB24, SDL_PIXELFORMAT_RGB24 },              /* 24 bit RGB (3 byte, red 8@16, green 8@8, blue 8@0) */
-    { DSPF_RGB32, SDL_PIXELFORMAT_RGB888 },             /* 24 bit RGB (4 byte, nothing@24, red 8@16, green 8@8, blue 8@0) */
-    { DSPF_ARGB, SDL_PIXELFORMAT_ARGB8888 },            /* 32 bit ARGB (4 byte, alpha 8@24, red 8@16, green 8@8, blue 8@0) */
-    { DSPF_RGB444, SDL_PIXELFORMAT_RGB444 },            /* 16 bit RGB (2 byte, nothing @12, red 4@8, green 4@4, blue 4@0) */
-    { DSPF_YV12, SDL_PIXELFORMAT_YV12 },                /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size V/U planes) */
-    { DSPF_I420,SDL_PIXELFORMAT_IYUV },                 /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size U/V planes) */
-    { DSPF_YUY2, SDL_PIXELFORMAT_YUY2 },                /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains CbYCrY [31:0]) */
-    { DSPF_UYVY, SDL_PIXELFORMAT_UYVY },                /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains YCbYCr [31:0]) */
-    { DSPF_RGB555, SDL_PIXELFORMAT_RGB555 },            /* 16 bit RGB (2 byte, nothing @15, red 5@10, green 5@5, blue 5@0) */
-
-#if (DFB_VERSION_ATLEAST(1,2,0))
-    { DSPF_BGR555, SDL_PIXELFORMAT_BGR555 },            /* 16 bit BGR (2 byte, nothing @15, blue 5@10, green 5@5, red 5@0) */
-#else
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR555 },
-#endif
-
-    /* Pfff ... nonmatching formats follow */    
-    
-    { DSPF_ALUT44, SDL_PIXELFORMAT_UNKNOWN },           /* 8 bit ALUT (1 byte, alpha 4@4, color lookup 4@0) */
- 	{ DSPF_A8, SDL_PIXELFORMAT_UNKNOWN },               /* 	8 bit alpha (1 byte, alpha 8@0), e.g. anti-aliased glyphs */
- 	{ DSPF_AiRGB, SDL_PIXELFORMAT_UNKNOWN },            /* 	32 bit ARGB (4 byte, inv. alpha 8@24, red 8@16, green 8@8, blue 8@0) */
- 	{ DSPF_A1, SDL_PIXELFORMAT_UNKNOWN },               /* 	1 bit alpha (1 byte/ 8 pixel, most significant bit used first) */
- 	{ DSPF_NV12, SDL_PIXELFORMAT_UNKNOWN },             /* 	12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CbCr [15:0] plane) */
- 	{ DSPF_NV16, SDL_PIXELFORMAT_UNKNOWN },             /* 	16 bit YUV (8 bit Y plane followed by one 16 bit half width CbCr [15:0] plane) */
- 	{ DSPF_ARGB2554, SDL_PIXELFORMAT_UNKNOWN },         /* 	16 bit ARGB (2 byte, alpha 2@14, red 5@9, green 5@4, blue 4@0) */
- 	{ DSPF_NV21, SDL_PIXELFORMAT_UNKNOWN },             /* 	12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CrCb [15:0] plane) */
- 	{ DSPF_AYUV, SDL_PIXELFORMAT_UNKNOWN },             /* 	32 bit AYUV (4 byte, alpha 8@24, Y 8@16, Cb 8@8, Cr 8@0) */
- 	{ DSPF_A4, SDL_PIXELFORMAT_UNKNOWN },               /* 	4 bit alpha (1 byte/ 2 pixel, more significant nibble used first) */
- 	{ DSPF_ARGB1666, SDL_PIXELFORMAT_UNKNOWN },         /* 	1 bit alpha (3 byte/ alpha 1@18, red 6@16, green 6@6, blue 6@0) */
- 	{ DSPF_ARGB6666, SDL_PIXELFORMAT_UNKNOWN },         /* 	6 bit alpha (3 byte/ alpha 6@18, red 6@16, green 6@6, blue 6@0) */
- 	{ DSPF_RGB18, SDL_PIXELFORMAT_UNKNOWN },            /* 	6 bit RGB (3 byte/ red 6@16, green 6@6, blue 6@0) */
- 	{ DSPF_LUT2, SDL_PIXELFORMAT_UNKNOWN },             /* 	2 bit LUT (1 byte/ 4 pixel, 2 bit color and alpha lookup from palette) */
-
-#if (DFB_VERSION_ATLEAST(1,3,0))
- 	{ DSPF_RGBA4444, SDL_PIXELFORMAT_UNKNOWN },         /* 16 bit RGBA (2 byte, red 4@12, green 4@8, blue 4@4, alpha 4@0) */
-#endif
-
-#if (DFB_VERSION_ATLEAST(1,4,0))
- 	{ DSPF_RGBA5551, SDL_PIXELFORMAT_UNKNOWN },         /* 	16 bit RGBA (2 byte, red 5@11, green 5@6, blue 5@1, alpha 1@0) */
- 	{ DSPF_YUV444P, SDL_PIXELFORMAT_UNKNOWN },          /* 	24 bit full YUV planar (8 bit Y plane followed by an 8 bit Cb and an 8 bit Cr plane) */
- 	{ DSPF_ARGB8565, SDL_PIXELFORMAT_UNKNOWN },         /* 	24 bit ARGB (3 byte, alpha 8@16, red 5@11, green 6@5, blue 5@0) */
- 	{ DSPF_AVYU, SDL_PIXELFORMAT_UNKNOWN },             /* 	32 bit AVYU 4:4:4 (4 byte, alpha 8@24, Cr 8@16, Y 8@8, Cb 8@0) */
- 	{ DSPF_VYU, SDL_PIXELFORMAT_UNKNOWN },              /* 	24 bit VYU 4:4:4 (3 byte, Cr 8@16, Y 8@8, Cb 8@0)  */
-#endif
- 	
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1MSB },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4LSB }, 
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4MSB },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR24 },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR888 },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_RGBA8888 },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR8888 },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGRA8888 },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_ARGB2101010 },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR4444 },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR1555 },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR565 },
-    { DSPF_UNKNOWN, SDL_PIXELFORMAT_YVYU },                        /**< Packed mode: Y0+V0+Y1+U0 (1 pla	*/
-};
-
-static Uint32
-DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat)
-{
-    int i;
-    
-    for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
-        if (pixelformat_tab[i].dfb == pixelformat)
-        {
-            return pixelformat_tab[i].sdl;
-        }
-    return SDL_PIXELFORMAT_UNKNOWN;
-}
-
-static DFBSurfacePixelFormat
-SDLToDFBPixelFormat(Uint32 format)
-{
-    int i;
-    
-    for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
-        if (pixelformat_tab[i].sdl == format)
-        {
-            return pixelformat_tab[i].dfb;
-        }
-    return  DSPF_UNKNOWN;
-}
-
 static DFBEnumerationResult
 EnumModesCallback(int width, int height, int bpp, void *data)
 {
@@ -157,20 +63,20 @@
 }
 
 static DFBEnumerationResult
-cbScreens(DFBScreenID screen_id, DFBScreenDescription desc,
+EnumScreensCallback(DFBScreenID screen_id, DFBScreenDescription desc,
           void *callbackdata)
 {
-    struct scn_callback_t *devdata = (struct scn_callback_t *) callbackdata;
+    struct screen_callback_t *devdata = (struct screen_callback_t *) callbackdata;
 
     devdata->screenid[devdata->numscreens++] = screen_id;
     return DFENUM_OK;
 }
 
-DFBEnumerationResult
-cbLayers(DFBDisplayLayerID layer_id, DFBDisplayLayerDescription desc,
+static DFBEnumerationResult
+EnumLayersCallback(DFBDisplayLayerID layer_id, DFBDisplayLayerDescription desc,
          void *callbackdata)
 {
-    struct scn_callback_t *devdata = (struct scn_callback_t *) callbackdata;
+    struct screen_callback_t *devdata = (struct screen_callback_t *) callbackdata;
 
     if (desc.caps & DLCAPS_SURFACE) {
         if ((desc.type & DLTF_GRAPHICS) && (desc.type & DLTF_VIDEO)) {
@@ -195,7 +101,7 @@
                                                       DLSCL_ADMINISTRATIVE));
     config.width = mode->w;
     config.height = mode->h;
-    config.pixelformat = SDLToDFBPixelFormat(mode->format);
+    config.pixelformat = DirectFB_SDLToDFBPixelFormat(mode->format);
     config.flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT;
     if (devdata->use_yuv_underlays) {
         config.flags |= DLCONF_OPTIONS;
@@ -206,7 +112,10 @@
     SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
                                                       DLSCL_SHARED));
     if (failed == 0)
+    {
         SDL_AddDisplayMode(display, mode);
+        SDL_DFB_LOG("Mode %d x %d Added\n", mode->w, mode->h);
+    }
     else
         SDL_DFB_ERR("Mode %d x %d not available: %x\n", mode->w,
                       mode->h, failed);
@@ -216,6 +125,26 @@
     return;
 }
 
+
+void
+DirectFB_SetContext(_THIS, SDL_Window *window)
+{
+#if (DFB_VERSION_ATLEAST(1,0,0))
+    /* FIXME: does not work on 1.0/1.2 with radeon driver
+     *        the approach did work with the matrox driver
+     *        This has simply no effect.
+     */
+
+    SDL_VideoDisplay *display = window->display;
+    DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
+
+	/* FIXME: should we handle the error */
+    if (dispdata->vidIDinuse)
+        SDL_DFB_CHECK(dispdata->vidlayer->SwitchContext(dispdata->vidlayer,
+                                                           DFB_TRUE));
+#endif
+}
+
 void
 DirectFB_InitModes(_THIS)
 {
@@ -226,14 +155,14 @@
     SDL_DisplayMode mode;
     DFBGraphicsDeviceDescription caps;
     DFBDisplayLayerConfig dlc;
-    struct scn_callback_t *screencbdata;
+    struct screen_callback_t *screencbdata;
 
     int tcw[DFB_MAX_SCREENS];
     int tch[DFB_MAX_SCREENS];
     int i;
     DFBResult ret;
 
-    SDL_DFB_CALLOC(screencbdata, 1, sizeof(*screencbdata));
+    SDL_DFB_ALLOC_CLEAR(screencbdata, sizeof(*screencbdata));
 
     screencbdata->numscreens = 0;
 
@@ -242,7 +171,7 @@
         screencbdata->vidlayer[i] = -1;
     }
 
-    SDL_DFB_CHECKERR(devdata->dfb->EnumScreens(devdata->dfb, &cbScreens,
+    SDL_DFB_CHECKERR(devdata->dfb->EnumScreens(devdata->dfb, &EnumScreensCallback,
                                                screencbdata));
 
     for (i = 0; i < screencbdata->numscreens; i++) {
@@ -253,9 +182,10 @@
                                                  [i], &screen));
 
         screencbdata->aux = i;
-        SDL_DFB_CHECKERR(screen->EnumDisplayLayers(screen, &cbLayers,
+        SDL_DFB_CHECKERR(screen->EnumDisplayLayers(screen, &EnumLayersCallback,
                                                    screencbdata));
         screen->GetSize(screen, &tcw[i], &tch[i]);
+
         screen->Release(screen);
     }
 
@@ -263,10 +193,6 @@
 
     devdata->dfb->GetDeviceDescription(devdata->dfb, &caps);
 
-    SDL_DFB_DEBUG("SDL directfb video driver - %s %s\n", __DATE__, __TIME__);
-    SDL_DFB_DEBUG("Using %s (%s) driver.\n", caps.name, caps.vendor);
-    SDL_DFB_DEBUG("Found %d screens\n", screencbdata->numscreens);
-
     for (i = 0; i < screencbdata->numscreens; i++) {
         SDL_DFB_CHECKERR(devdata->dfb->GetDisplayLayer(devdata->dfb,
                                                        screencbdata->gralayer
@@ -282,7 +208,7 @@
             dlc.pixelformat = DSPF_ARGB;
             dlc.options = DLOP_ALPHACHANNEL;
 
-            ret = SDL_DFB_CHECK(layer->SetConfiguration(layer, &dlc));
+            ret = layer->SetConfiguration(layer, &dlc);
             if (ret != DFB_OK) {
                 /* try AiRGB if the previous failed */
                 dlc.pixelformat = DSPF_AiRGB;
@@ -294,7 +220,7 @@
         dlc.flags = DLCONF_ALL;
         SDL_DFB_CHECKERR(layer->GetConfiguration(layer, &dlc));
 
-        mode.format = DFBToSDLPixelFormat(dlc.pixelformat);
+        mode.format = DirectFB_DFBToSDLPixelFormat(dlc.pixelformat);
         
         if (mode.format == SDL_PIXELFORMAT_UNKNOWN) {
             SDL_DFB_ERR("Unknown dfb pixelformat %x !\n", dlc.pixelformat);
@@ -306,7 +232,7 @@
         mode.refresh_rate = 0;
         mode.driverdata = NULL;
 
-        SDL_DFB_CALLOC(dispdata, 1, sizeof(*dispdata));
+        SDL_DFB_ALLOC_CLEAR(dispdata, sizeof(*dispdata));
 
         dispdata->layer = layer;
         dispdata->pixelformat = dlc.pixelformat;
@@ -399,7 +325,7 @@
     config.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
     if (mode->format != SDL_PIXELFORMAT_UNKNOWN) {
         config.flags |= DLCONF_PIXELFORMAT;
-        config.pixelformat = SDLToDFBPixelFormat(mode->format);
+        config.pixelformat = DirectFB_SDLToDFBPixelFormat(mode->format);
         data->pixelformat = config.pixelformat;
     }
     config.width = mode->w;
@@ -420,7 +346,6 @@
         return -1;
     }
 
-    SDL_DFB_DEBUG("Trace\n");
     config.flags &= ~fail;
     SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config));
 #if (DFB_VERSION_ATLEAST(1,2,0))
@@ -454,7 +379,6 @@
 void
 DirectFB_QuitModes(_THIS)
 {
-    //DFB_DeviceData *devdata = (DFB_DeviceData *) _this->driverdata;
     SDL_DisplayMode tmode;
     int i;
 
--- a/src/video/directfb/SDL_DirectFB_modes.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_modes.h	Sun Feb 06 21:23:32 2011 -0800
@@ -18,32 +18,36 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
 
 #ifndef _SDL_directfb_modes_h
 #define _SDL_directfb_modes_h
 
-#include "SDL_DirectFB_video.h"
+#include <directfb.h>
 
-#define SDL_DFB_DISPLAYDATA(dev, win)  DFB_DisplayData *dispdata = ((win && dev) ? (DFB_DisplayData *) (win)->display->driverdata : NULL)
+#include "../SDL_sysvideo.h"
+
+#define SDL_DFB_DISPLAYDATA(win)  DFB_DisplayData *dispdata = ((win) ? (DFB_DisplayData *) (win)->display->driverdata : NULL)
 
 typedef struct _DFB_DisplayData DFB_DisplayData;
 struct _DFB_DisplayData
 {
-    IDirectFBDisplayLayer *layer;
-    DFBSurfacePixelFormat pixelformat;
+    IDirectFBDisplayLayer 	*layer;
+    DFBSurfacePixelFormat 	pixelformat;
     /* FIXME: support for multiple video layer. 
      * However, I do not know any card supporting 
      * more than one
      */
-    DFBDisplayLayerID vidID;
-    IDirectFBDisplayLayer *vidlayer;
+    DFBDisplayLayerID 		vidID;
+    IDirectFBDisplayLayer 	*vidlayer;
 
-    int vidIDinuse;
+    int 					vidIDinuse;
 
-    int cw;
-    int ch;
+    int 					cw;
+    int 					ch;
 };
 
 
@@ -52,6 +56,8 @@
 extern int DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
 extern void DirectFB_QuitModes(_THIS);
 
+extern void DirectFB_SetContext(_THIS, SDL_Window *window);
+
 #endif /* _SDL_directfb_modes_h */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/directfb/SDL_DirectFB_mouse.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_mouse.c	Sun Feb 06 21:23:32 2011 -0800
@@ -18,7 +18,11 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
+
 #include "SDL_config.h"
 
 #include "SDL_DirectFB_video.h"
@@ -123,8 +127,8 @@
     Uint32 *p;
     int pitch, i;
 
-    SDL_DFB_CALLOC(cursor, 1, sizeof(*cursor));
-    SDL_DFB_CALLOC(curdata, 1, sizeof(*curdata));
+    SDL_DFB_ALLOC_CLEAR(cursor, 1, sizeof(*cursor));
+    SDL_DFB_ALLOC_CLEAR(curdata, 1, sizeof(*curdata));
 
     dsc.flags =
         DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
@@ -175,7 +179,7 @@
 
             if (cursor)
                 SDL_DFB_CHECKERR(windata->window->
-                                 SetCursorShape(windata->window,
+                                 SetCursorShape(windata->dfbwin,
                                                 curdata->surf, curdata->hotx,
                                                 curdata->hoty));
 
@@ -224,7 +228,7 @@
     DFBResult ret;
     int cx, cy;
 
-    SDL_DFB_CHECKERR(windata->window->GetPosition(windata->window, &cx, &cy));
+    SDL_DFB_CHECKERR(windata->dfbwin->GetPosition(windata->dfbwin, &cx, &cy));
     SDL_DFB_CHECKERR(dispdata->layer->WarpCursor(dispdata->layer,
                                                  cx + x + windata->client.x,
                                                  cy + y + windata->client.y));
@@ -253,7 +257,6 @@
 void
 DirectFB_QuitMouse(_THIS)
 {
-    //SDL_DFB_DEVICEDATA(_this);
 }
 
 
--- a/src/video/directfb/SDL_DirectFB_mouse.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_mouse.h	Sun Feb 06 21:23:32 2011 -0800
@@ -18,19 +18,24 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
 
 #ifndef _SDL_DirectFB_mouse_h
 #define _SDL_DirectFB_mouse_h
 
+#include <directfb.h>
+
+#include "../SDL_sysvideo.h"
+
 typedef struct _DFB_CursorData DFB_CursorData;
-
 struct _DFB_CursorData
 {
     IDirectFBSurface *surf;
-    int hotx;
-    int hoty;
+    int 			hotx;
+    int 			hoty;
 };
 
 #define SDL_DFB_CURSORDATA(curs)  DFB_CursorData *curdata = (DFB_CursorData *) ((curs) ? (curs)->driverdata : NULL)
--- a/src/video/directfb/SDL_DirectFB_opengl.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_opengl.c	Sun Feb 06 21:23:32 2011 -0800
@@ -13,17 +13,27 @@
     Lesser General Public License for more details.
 
     You should have received a copy of the GNU Lesser General Public
-    License along with _this library; if not, write to the Free Software
+    License along with this library; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
 
 #include "SDL_DirectFB_video.h"
 
 #if SDL_DIRECTFB_OPENGL
+#include "SDL_DirectFB_opengl.h"
+#include "SDL_DirectFB_window.h"
+
+#include <directfbgl.h>
+#include "SDL_loadso.h"
+#endif
+
+#if SDL_DIRECTFB_OPENGL
 
 struct SDL_GLDriverData
 {
@@ -177,7 +187,7 @@
     SDL_DFB_WINDOWDATA(window);
     DirectFB_GLContext *context;
 
-    SDL_DFB_CALLOC(context, 1, sizeof(DirectFB_GLContext));
+    SDL_DFB_ALLOC_CLEAR(context, sizeof(DirectFB_GLContext));
 
     SDL_DFB_CHECKERR(windata->surface->GetGL(windata->surface,
                                              &context->context));
--- a/src/video/directfb/SDL_DirectFB_opengl.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_opengl.h	Sun Feb 06 21:23:32 2011 -0800
@@ -18,23 +18,29 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
+
 
 #ifndef _SDL_directfb_opengl_h
 #define _SDL_directfb_opengl_h
 
+#include "SDL_DirectFB_video.h"
+
 #if SDL_DIRECTFB_OPENGL
+
 #include "SDL_opengl.h"
 
 typedef struct _DirectFB_GLContext DirectFB_GLContext;
 struct _DirectFB_GLContext
 {
-    IDirectFBGL *context;
-    DirectFB_GLContext *next;
+    IDirectFBGL 		*context;
+    DirectFB_GLContext 	*next;
     
-    SDL_Window *sdl_window;
-    int is_locked;
+    SDL_Window 			*sdl_window;
+    int 				is_locked;
 };
 
 /* OpenGL functions */
--- a/src/video/directfb/SDL_DirectFB_render.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_render.c	Sun Feb 06 21:23:32 2011 -0800
@@ -18,26 +18,33 @@
 
     Sam Lantinga
     slouken@libsdl.org
-    
-    SDL1.3 implementation by couriersud@arcor.de
-    
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
+#include "SDL_DirectFB_video.h"
+#include "SDL_DirectFB_window.h"
+#include "SDL_DirectFB_modes.h"
 
-#include "SDL_DirectFB_video.h"
-#include "SDL_DirectFB_render.h"
-#include "../SDL_rect_c.h"
-#include "../SDL_yuv_sw_c.h"
+#include "SDL_DirectFB_shape.h"
+
+#include "../SDL_sysvideo.h"
+#include "../../render/SDL_sysrender.h"
+//#include "../SDL_rect_c.h"
+//#include "../SDL_yuv_sw_c.h"
 
 /* the following is not yet tested ... */
 #define USE_DISPLAY_PALETTE			(0)
 
+
+#define SDL_DFB_RENDERERDATA(rend) DirectFB_RenderData *renddata = ((rend) ? (DirectFB_RenderData *) (rend)->driverdata : NULL)
+
+
 /* GDI renderer implementation */
 
 static SDL_Renderer *DirectFB_CreateRenderer(SDL_Window * window,
                                              Uint32 flags);
-static int DirectFB_DisplayModeChanged(SDL_Renderer * renderer);
-static int DirectFB_ActivateRenderer(SDL_Renderer * renderer);
+static void DirectFB_ActivateRenderer(SDL_Renderer * renderer);
 static int DirectFB_CreateTexture(SDL_Renderer * renderer,
                                   SDL_Texture * texture);
 static int DirectFB_QueryTexturePixels(SDL_Renderer * renderer,
@@ -65,7 +72,7 @@
                                   const void *pixels, int pitch);
 static int DirectFB_LockTexture(SDL_Renderer * renderer,
                                 SDL_Texture * texture,
-                                const SDL_Rect * rect, int markDirty,
+                                const SDL_Rect * rect,
                                 void **pixels, int *pitch);
 static void DirectFB_UnlockTexture(SDL_Renderer * renderer,
                                    SDL_Texture * texture);
@@ -89,6 +96,11 @@
 static void DirectFB_DestroyTexture(SDL_Renderer * renderer,
                                     SDL_Texture * texture);
 static void DirectFB_DestroyRenderer(SDL_Renderer * renderer);
+static int DirectFB_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                     Uint32 format, void * pixels, int pitch);
+static int DirectFB_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                      Uint32 format, const void * pixels, int pitch);
+
 
 #define SDL_DFB_WINDOWSURFACE(win)  IDirectFBSurface *destsurf = ((DFB_WindowData *) ((win)->driverdata))->surface;
 
@@ -96,32 +108,17 @@
     DirectFB_CreateRenderer,
     {
      "directfb",
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
-      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
-      SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
-      SDL_RENDERER_ACCELERATED),
-     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
+     (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
+     /* (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
       SDL_TEXTUREMODULATE_ALPHA),
-     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND |
+      (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND |
       SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
      (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST |
-      SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST),
-     14,
+      SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST),*/
+     0,
      {
-      SDL_PIXELFORMAT_INDEX4LSB,
-      SDL_PIXELFORMAT_INDEX8,
-      SDL_PIXELFORMAT_RGB332,
-      SDL_PIXELFORMAT_RGB555,
-      SDL_PIXELFORMAT_RGB565,
-      SDL_PIXELFORMAT_RGB888,
-      SDL_PIXELFORMAT_ARGB8888,
-      SDL_PIXELFORMAT_ARGB4444,
-      SDL_PIXELFORMAT_ARGB1555,
-      SDL_PIXELFORMAT_RGB24,
-      SDL_PIXELFORMAT_YV12,
-      SDL_PIXELFORMAT_IYUV,
-      SDL_PIXELFORMAT_YUY2,
-      SDL_PIXELFORMAT_UYVY},
+    		 /* formats filled in later */
+     },
      0,
      0}
 };
@@ -130,7 +127,6 @@
 {
     SDL_Window *window;
     DFBSurfaceFlipFlags flipflags;
-    int isyuvdirect;
     int size_changed;
     int lastBlendMode;
     DFBSurfaceBlittingFlags blitFlags;
@@ -144,8 +140,10 @@
     void *pixels;
     int pitch;
     IDirectFBPalette *palette;
-    SDL_VideoDisplay *display;
-    SDL_DirtyRectList dirty;
+    int isDirty;
+
+    SDL_VideoDisplay *display;      /* only for yuv textures */
+
 #if (DFB_VERSION_ATLEAST(1,2,0))
     DFBSurfaceRenderOptions render_options;
 #endif
@@ -167,8 +165,12 @@
     /* Drawing primitive ? */
     if (!data)
         return 0;
+        
+    return (DFB_PIXELFORMAT_HAS_ALPHA(DirectFB_SDLToDFBPixelFormat(data->format)) ? 1 : 0);
+#if 0
     switch (data->format) {
     case SDL_PIXELFORMAT_INDEX4LSB:
+    case SDL_PIXELFORMAT_INDEX4MSB:
     case SDL_PIXELFORMAT_ARGB4444:
     case SDL_PIXELFORMAT_ARGB1555:
     case SDL_PIXELFORMAT_ARGB8888:
@@ -176,10 +178,11 @@
     case SDL_PIXELFORMAT_ABGR8888:
     case SDL_PIXELFORMAT_BGRA8888:
     case SDL_PIXELFORMAT_ARGB2101010:
-        return 1;
+       return 1;
     default:
         return 0;
     }
+#endif
 }
 
 static void
@@ -198,12 +201,14 @@
             SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE));
             SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO));
             break;
+#if 0
         case SDL_BLENDMODE_MASK:
-            data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
+            data->blitFlags =  DSBLIT_BLEND_ALPHACHANNEL;
             data->drawFlags = DSDRAW_BLEND;
             SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA));
             SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA));
             break;
+#endif
         case SDL_BLENDMODE_BLEND:
             data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
             data->drawFlags = DSDRAW_BLEND;
@@ -225,24 +230,18 @@
         case SDL_BLENDMODE_MOD:
             data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
             data->drawFlags = DSDRAW_BLEND;
-            SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_DESTCOLOR));
-            SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO));
+            //SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_DESTCOLOR));
+            //SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO));
+            //data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
+            SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ZERO));
+            SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_SRCCOLOR));
+
             break;
         }
         data->lastBlendMode = blendMode;
     }
 }
 
-void
-DirectFB_AddRenderDriver(_THIS)
-{
-    int i;
-
-    for (i = 0; i < _this->num_displays; ++i) {
-        SDL_AddRenderDriver(&_this->displays[i], &DirectFB_RenderDriver);
-    }
-}
-
 static int
 DisplayPaletteChanged(void *userdata, SDL_Palette * palette)
 {
@@ -275,6 +274,28 @@
     return -1;
 }
 
+static void
+DirectFB_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
+{
+    SDL_DFB_RENDERERDATA(renderer);
+
+    if (event->event == SDL_WINDOWEVENT_RESIZED) {
+        /* Rebind the context to the window area and update matrices */
+        //SDL_CurrentContext = NULL;
+        //data->updateSize = SDL_TRUE;
+        renddata->size_changed = SDL_TRUE;
+   }
+}
+
+int
+DirectFB_RenderClear(SDL_Renderer * renderer)
+{
+    SDL_DFB_RENDERERDATA(renderer);
+
+    DirectFB_ActivateRenderer(renderer);
+
+    return 0;
+}
 
 SDL_Renderer *
 DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
@@ -284,45 +305,52 @@
     SDL_Renderer *renderer = NULL;
     DirectFB_RenderData *data = NULL;
     DFBSurfaceCapabilities scaps;
-    char *p;
-
-    SDL_DFB_CALLOC(renderer, 1, sizeof(*renderer));
-    SDL_DFB_CALLOC(data, 1, sizeof(*data));
+    //char *p;
 
-    renderer->DisplayModeChanged = DirectFB_DisplayModeChanged;
-    renderer->ActivateRenderer = DirectFB_ActivateRenderer;
+    SDL_DFB_ALLOC_CLEAR(renderer, sizeof(*renderer));
+    SDL_DFB_ALLOC_CLEAR(data, sizeof(*data));
+
+    renderer->WindowEvent = DirectFB_WindowEvent;
     renderer->CreateTexture = DirectFB_CreateTexture;
-    renderer->QueryTexturePixels = DirectFB_QueryTexturePixels;
-    renderer->SetTexturePalette = DirectFB_SetTexturePalette;
-    renderer->GetTexturePalette = DirectFB_GetTexturePalette;
     renderer->SetTextureAlphaMod = DirectFB_SetTextureAlphaMod;
     renderer->SetTextureColorMod = DirectFB_SetTextureColorMod;
     renderer->SetTextureBlendMode = DirectFB_SetTextureBlendMode;
-    renderer->SetTextureScaleMode = DirectFB_SetTextureScaleMode;
     renderer->UpdateTexture = DirectFB_UpdateTexture;
     renderer->LockTexture = DirectFB_LockTexture;
+    renderer->RenderClear = DirectFB_RenderClear;
     renderer->UnlockTexture = DirectFB_UnlockTexture;
-    renderer->DirtyTexture = DirectFB_DirtyTexture;
     renderer->RenderDrawPoints = DirectFB_RenderDrawPoints;
     renderer->RenderDrawLines = DirectFB_RenderDrawLines;
     /* SetDrawColor - no needed */
-    renderer->SetDrawBlendMode = DirectFB_SetDrawBlendMode;
     renderer->RenderFillRects = DirectFB_RenderFillRects;
-    renderer->RenderDrawRects = DirectFB_RenderDrawRects;
     /* RenderDrawEllipse - no reference implementation yet */
     /* RenderFillEllipse - no reference implementation yet */
     renderer->RenderCopy = DirectFB_RenderCopy;
     renderer->RenderPresent = DirectFB_RenderPresent;
-    /* RenderReadPixels is difficult to implement */
-    /* RenderWritePixels is difficult to implement */
+    
+    /* FIXME: Yet to be tested */
+    renderer->RenderReadPixels = DirectFB_RenderReadPixels;
+    //renderer->RenderWritePixels = DirectFB_RenderWritePixels;
+    
     renderer->DestroyTexture = DirectFB_DestroyTexture;
     renderer->DestroyRenderer = DirectFB_DestroyRenderer;
+
+#if 0
+    renderer->QueryTexturePixels = DirectFB_QueryTexturePixels;
+    renderer->SetTexturePalette = DirectFB_SetTexturePalette;
+    renderer->GetTexturePalette = DirectFB_GetTexturePalette;
+    renderer->SetTextureScaleMode = DirectFB_SetTextureScaleMode;
+    renderer->DirtyTexture = DirectFB_DirtyTexture;
+    renderer->SetDrawBlendMode = DirectFB_SetDrawBlendMode;
+    renderer->RenderDrawRects = DirectFB_RenderDrawRects;
+#endif
+
     renderer->info = DirectFB_RenderDriver.info;
     renderer->window = window;      /* SDL window */
     renderer->driverdata = data;
 
     renderer->info.flags =
-        SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD;
+        SDL_RENDERER_ACCELERATED;
 
     data->window = window;
 
@@ -336,22 +364,24 @@
 
     SDL_DFB_CHECKERR(windata->surface->
                      GetCapabilities(windata->surface, &scaps));
+
+#if 0
     if (scaps & DSCAPS_DOUBLE)
         renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
     else if (scaps & DSCAPS_TRIPLE)
         renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
     else
         renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
+#endif
 
-    data->isyuvdirect = 0;      /* default is off! */
-    p = SDL_getenv(DFBENV_USE_YUV_DIRECT);
-    if (p)
-        data->isyuvdirect = atoi(p);
+    DirectFB_SetSupportedPixelFormats(&renderer->info);
 
+#if 0
     /* Set up a palette watch on the display palette */
     if (display->palette) {
         SDL_AddPaletteWatch(display->palette, DisplayPaletteChanged, data);
     }
+#endif
 
     return renderer;
 
@@ -361,68 +391,7 @@
     return NULL;
 }
 
-static DFBSurfacePixelFormat
-SDLToDFBPixelFormat(Uint32 format)
-{
-    switch (format) {
-    case SDL_PIXELFORMAT_INDEX4LSB:
-        return DSPF_ALUT44;
-    case SDL_PIXELFORMAT_INDEX8:
-        return DSPF_LUT8;
-    case SDL_PIXELFORMAT_RGB332:
-        return DSPF_RGB332;
-    case SDL_PIXELFORMAT_RGB555:
-        return DSPF_ARGB1555;
-    case SDL_PIXELFORMAT_ARGB4444:
-        return DSPF_ARGB4444;
-    case SDL_PIXELFORMAT_ARGB1555:
-        return DSPF_ARGB1555;
-    case SDL_PIXELFORMAT_RGB565:
-        return DSPF_RGB16;
-    case SDL_PIXELFORMAT_RGB24:
-        return DSPF_RGB24;
-    case SDL_PIXELFORMAT_RGB888:
-        return DSPF_RGB32;
-    case SDL_PIXELFORMAT_ARGB8888:
-        return DSPF_ARGB;
-    case SDL_PIXELFORMAT_YV12:
-        return DSPF_YV12;       /* Planar mode: Y + V + U  (3 planes) */
-    case SDL_PIXELFORMAT_IYUV:
-        return DSPF_I420;       /* Planar mode: Y + U + V  (3 planes) */
-    case SDL_PIXELFORMAT_YUY2:
-        return DSPF_YUY2;       /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
-    case SDL_PIXELFORMAT_UYVY:
-        return DSPF_UYVY;       /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
-    case SDL_PIXELFORMAT_YVYU:
-        return DSPF_UNKNOWN;    /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
-    case SDL_PIXELFORMAT_INDEX1LSB:
-        return DSPF_UNKNOWN;
-    case SDL_PIXELFORMAT_INDEX1MSB:
-        return DSPF_UNKNOWN;
-    case SDL_PIXELFORMAT_INDEX4MSB:
-        return DSPF_UNKNOWN;
-#if (DFB_VERSION_ATLEAST(1,2,0))
-    case SDL_PIXELFORMAT_RGB444:
-        return DSPF_RGB444;
-#endif
-    case SDL_PIXELFORMAT_BGR24:
-        return DSPF_UNKNOWN;
-    case SDL_PIXELFORMAT_BGR888:
-        return DSPF_UNKNOWN;
-    case SDL_PIXELFORMAT_RGBA8888:
-        return DSPF_UNKNOWN;
-    case SDL_PIXELFORMAT_ABGR8888:
-        return DSPF_UNKNOWN;
-    case SDL_PIXELFORMAT_BGRA8888:
-        return DSPF_UNKNOWN;
-    case SDL_PIXELFORMAT_ARGB2101010:
-        return DSPF_UNKNOWN;
-    default:
-        return DSPF_UNKNOWN;
-    }
-}
-
-static int
+static void
 DirectFB_ActivateRenderer(SDL_Renderer * renderer)
 {
     SDL_DFB_RENDERERDATA(renderer);
@@ -430,24 +399,15 @@
     SDL_DFB_WINDOWDATA(window);
 
     if (renddata->size_changed || windata->wm_needs_redraw) {
-//        DirectFB_AdjustWindowSurface(window);
+        DirectFB_AdjustWindowSurface(window);
     }
-    return 0;
 }
 
-static int
-DirectFB_DisplayModeChanged(SDL_Renderer * renderer)
-{
-    SDL_DFB_RENDERERDATA(renderer);
-
-    renddata->size_changed = SDL_TRUE;
-    return 0;
-}
 
 static int
 DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture)
 {
-    SDL_DFB_RENDERERDATA(renderer);
+    //SDL_DFB_RENDERERDATA(renderer);
     SDL_Window *window = renderer->window;
     SDL_VideoDisplay *display = window->display;
     SDL_DFB_DEVICEDATA(display->device);
@@ -456,7 +416,7 @@
     DFBDisplayLayerConfig layconf;
     DFBResult ret;
 
-    if (renddata->isyuvdirect && (dispdata->vidID >= 0)
+    if (devdata->use_yuv_direct && (dispdata->vidID >= 0)
         && (!dispdata->vidIDinuse)
         && SDL_ISPIXELFORMAT_FOURCC(data->format)) {
         layconf.flags =
@@ -464,7 +424,7 @@
             DLCONF_SURFACE_CAPS;
         layconf.width = texture->w;
         layconf.height = texture->h;
-        layconf.pixelformat = SDLToDFBPixelFormat(data->format);
+        layconf.pixelformat = DirectFB_SDLToDFBPixelFormat(data->format);
         layconf.surface_caps = DSCAPS_VIDEOONLY | DSCAPS_DOUBLE;
 
         SDL_DFB_CHECKERR(devdata->dfb->GetDisplayLayer(devdata->dfb,
@@ -475,7 +435,7 @@
                                                        DLSCL_EXCLUSIVE));
 
         if (devdata->use_yuv_underlays) {
-            ret = SDL_DFB_CHECK(dispdata->vidlayer->SetLevel(dispdata->vidlayer, -1));
+            ret = dispdata->vidlayer->SetLevel(dispdata->vidlayer, -1);
             if (ret != DFB_OK)
                 SDL_DFB_DEBUG("Underlay Setlevel not supported\n");
         }
@@ -511,11 +471,13 @@
     DFBSurfaceDescription dsc;
     DFBSurfacePixelFormat pixelformat;
 
-    SDL_DFB_CALLOC(data, 1, sizeof(*data));
+    DirectFB_ActivateRenderer(renderer);
+
+    SDL_DFB_ALLOC_CLEAR(data, sizeof(*data));
     texture->driverdata = data;
 
     /* find the right pixelformat */
-    pixelformat = SDLToDFBPixelFormat(texture->format);
+    pixelformat = DirectFB_SDLToDFBPixelFormat(texture->format);
     if (pixelformat == DSPF_UNKNOWN) {
         SDL_SetError("Unknown pixel format %d\n", data->format);
         goto error;
@@ -530,6 +492,12 @@
             DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
         dsc.width = texture->w;
         dsc.height = texture->h;
+        if(texture->format == SDL_PIXELFORMAT_YV12 ||
+           texture->format == SDL_PIXELFORMAT_IYUV) {
+           /* dfb has problems with odd sizes -make them even internally */
+           dsc.width += (dsc.width % 2);
+           dsc.height += (dsc.height % 2);
+        }
         /* <1.2 Never use DSCAPS_VIDEOONLY here. It kills performance
          * No DSCAPS_SYSTEMONLY either - let dfb decide
          * 1.2: DSCAPS_SYSTEMONLY boosts performance by factor ~8
@@ -551,22 +519,31 @@
                                                      &data->surface));
         if (SDL_ISPIXELFORMAT_INDEXED(data->format)
             && !SDL_ISPIXELFORMAT_FOURCC(data->format)) {
-            SDL_DFB_CHECKERR(data->surface->GetPalette(data->surface,
-                                                       &data->palette));
+#if 1
+            SDL_DFB_CHECKERR(data->surface->GetPalette(data->surface, &data->palette));
+#else
+            /* DFB has issues with blitting LUT8 surfaces.
+			 * Creating a new palette does not help.
+			 */
+        	DFBPaletteDescription pal_desc;
+        	pal_desc.flags = DPDESC_SIZE; // | DPDESC_ENTRIES
+        	pal_desc.size = 256;
+        	SDL_DFB_CHECKERR(devdata->dfb->CreatePalette(devdata->dfb, &pal_desc,&data->palette));
+        	SDL_DFB_CHECKERR(data->surface->SetPalette(data->surface, data->palette));
+#endif
         }
 
     }
 #if (DFB_VERSION_ATLEAST(1,2,0))
     data->render_options = DSRO_NONE;
 #endif
-
     if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
         /* 3 plane YUVs return 1 bpp, but we need more space for other planes */
         if(texture->format == SDL_PIXELFORMAT_YV12 ||
            texture->format == SDL_PIXELFORMAT_IYUV) {
-            SDL_DFB_CALLOC(data->pixels, 1, (texture->h * data->pitch * 3 + texture->h * data->pitch * 3 % 2) / 2);
+            SDL_DFB_ALLOC_CLEAR(data->pixels, (texture->h * data->pitch  + ((texture->h + texture->h % 2) * (data->pitch + data->pitch % 2) * 2) / 4));
         } else {
-            SDL_DFB_CALLOC(data->pixels, 1, texture->h * data->pitch);
+            SDL_DFB_ALLOC_CLEAR(data->pixels, texture->h * data->pitch);
         }
     }
 
@@ -602,21 +579,22 @@
                            int ncolors)
 {
     DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
- 
     if (SDL_ISPIXELFORMAT_INDEXED(data->format)
         && !SDL_ISPIXELFORMAT_FOURCC(data->format)) {
         DFBColor entries[256];
         int i;
 
+        if (ncolors > 256)
+        	ncolors = 256;
+
         for (i = 0; i < ncolors; ++i) {
             entries[i].r = colors[i].r;
             entries[i].g = colors[i].g;
             entries[i].b = colors[i].b;
-            entries[i].a = 0xFF;
+            entries[i].a = 0xff;
         }
         SDL_DFB_CHECKERR(data->
-                         palette->SetEntries(data->palette, entries, ncolors,
-                                             firstcolor));
+                         palette->SetEntries(data->palette, entries, ncolors, firstcolor));
         return 0;
     } else {
         SDL_SetError("YUV textures don't have a palette");
@@ -674,7 +652,7 @@
 {
     switch (texture->blendMode) {
     case SDL_BLENDMODE_NONE:
-    case SDL_BLENDMODE_MASK:
+    //case SDL_BLENDMODE_MASK:
     case SDL_BLENDMODE_BLEND:
     case SDL_BLENDMODE_ADD:
     case SDL_BLENDMODE_MOD:
@@ -691,7 +669,7 @@
 {
     switch (renderer->blendMode) {
     case SDL_BLENDMODE_NONE:
-    case SDL_BLENDMODE_MASK:
+    //case SDL_BLENDMODE_MASK:
     case SDL_BLENDMODE_BLEND:
     case SDL_BLENDMODE_ADD:
     case SDL_BLENDMODE_MOD:
@@ -703,6 +681,7 @@
     }
 }
 
+#if 0
 static int
 DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
 {
@@ -731,6 +710,7 @@
 #endif
     return 0;
 }
+#endif
 
 static int
 DirectFB_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
@@ -742,9 +722,16 @@
     Uint8 *src, *dst;
     int row;
     size_t length;
-    int bpp = DFB_BYTES_PER_PIXEL(SDLToDFBPixelFormat(texture->format));
+    int bpp = DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format));
     // FIXME: SDL_BYTESPERPIXEL(texture->format) broken for yuv yv12 3 planes
 
+    DirectFB_ActivateRenderer(renderer);
+
+    if ((texture->format == SDL_PIXELFORMAT_YV12) ||
+        (texture->format == SDL_PIXELFORMAT_IYUV)) {
+        bpp = 1;
+    }
+    
     SDL_DFB_CHECKERR(data->surface->Lock(data->surface,
                                          DSLF_WRITE | DSLF_READ,
                                          ((void **) &dpixels), &dpitch));
@@ -757,24 +744,25 @@
         dst += dpitch;
     }
     /* copy other planes for 3 plane formats */
-    if (texture->format == SDL_PIXELFORMAT_YV12 ||
-        texture->format == SDL_PIXELFORMAT_IYUV) {
+    if ((texture->format == SDL_PIXELFORMAT_YV12) ||
+        (texture->format == SDL_PIXELFORMAT_IYUV)) {
         src = (Uint8 *) pixels + texture->h * pitch;
         dst = (Uint8 *) dpixels + texture->h * dpitch + rect->y * dpitch / 4 + rect->x * bpp / 2;
-        for (row = 0; row < rect->h / 2; ++row) {
+        for (row = 0; row < rect->h / 2 + (rect->h & 1); ++row) {
             SDL_memcpy(dst, src, length / 2);
             src += pitch / 2;
             dst += dpitch / 2;
         }
         src = (Uint8 *) pixels + texture->h * pitch + texture->h * pitch / 4;
         dst = (Uint8 *) dpixels + texture->h * dpitch + texture->h * dpitch / 4 + rect->y * dpitch / 4 + rect->x * bpp / 2;
-        for (row = 0; row < rect->h / 2; ++row) {
+        for (row = 0; row < rect->h / 2 + (rect->h & 1); ++row) {
             SDL_memcpy(dst, src, length / 2);
             src += pitch / 2;
             dst += dpitch / 2;
         }
     }
     SDL_DFB_CHECKERR(data->surface->Unlock(data->surface));
+    data->isDirty = 0;
     return 0;
   error:
     return 1;
@@ -783,15 +771,18 @@
 
 static int
 DirectFB_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                     const SDL_Rect * rect, int markDirty,
-                     void **pixels, int *pitch)
+                     const SDL_Rect * rect, void **pixels, int *pitch)
 {
     DirectFB_TextureData *texturedata =
         (DirectFB_TextureData *) texture->driverdata;
 
+    DirectFB_ActivateRenderer(renderer);
+
+#if 0
     if (markDirty) {
         SDL_AddDirtyRect(&texturedata->dirty, rect);
     }
+#endif
 
     if (texturedata->display) {
         void *fdata;
@@ -806,8 +797,9 @@
         *pixels =
             (void *) ((Uint8 *) texturedata->pixels +
                       rect->y * texturedata->pitch +
-                      rect->x * DFB_BYTES_PER_PIXEL(SDLToDFBPixelFormat(texture->format)));
+                      rect->x * DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format)));
         *pitch = texturedata->pitch;
+        texturedata->isDirty = 1;
     }
     return 0;
 
@@ -821,12 +813,15 @@
     DirectFB_TextureData *texturedata =
         (DirectFB_TextureData *) texture->driverdata;
 
+    DirectFB_ActivateRenderer(renderer);
+
     if (texturedata->display) {
         SDL_DFB_CHECK(texturedata->surface->Unlock(texturedata->surface));
         texturedata->pixels = NULL;
     }
 }
 
+#if 0
 static void
 DirectFB_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                       int numrects, const SDL_Rect * rects)
@@ -838,6 +833,7 @@
         SDL_AddDirtyRect(&data->dirty, &rects[i]);
     }
 }
+#endif
 
 static int
 PrepareDraw(SDL_Renderer * renderer)
@@ -857,7 +853,7 @@
 
     switch (renderer->blendMode) {
     case SDL_BLENDMODE_NONE:
-    case SDL_BLENDMODE_MASK:
+    //case SDL_BLENDMODE_MASK:
     case SDL_BLENDMODE_BLEND:
         break;
     case SDL_BLENDMODE_ADD:
@@ -882,6 +878,8 @@
     SDL_DFB_WINDOWSURFACE(data->window);
     int i;
 
+    DirectFB_ActivateRenderer(renderer);
+
     PrepareDraw(renderer);
     for (i=0; i < count; i++)
     	SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, points[i].x, points[i].y, points[i].x, points[i].y));
@@ -897,6 +895,8 @@
     SDL_DFB_WINDOWSURFACE(data->window);
     int i;
 
+    DirectFB_ActivateRenderer(renderer);
+
     PrepareDraw(renderer);
     /* Use antialiasing when available */
 #if (DFB_VERSION_ATLEAST(1,2,0))
@@ -918,6 +918,8 @@
     SDL_DFB_WINDOWSURFACE(data->window);
     int i;
 
+    DirectFB_ActivateRenderer(renderer);
+
     PrepareDraw(renderer);
 
     for (i=0; i<count; i++)
@@ -936,6 +938,8 @@
     SDL_DFB_WINDOWSURFACE(data->window);
     int i;
 
+    DirectFB_ActivateRenderer(renderer);
+
     PrepareDraw(renderer);
 
     for (i=0; i<count; i++)
@@ -955,7 +959,9 @@
     SDL_DFB_WINDOWSURFACE(data->window);
     DirectFB_TextureData *texturedata =
         (DirectFB_TextureData *) texture->driverdata;
-    Uint8 alpha = 0xFF;
+    Uint8 alpha, r, g, b;
+
+    DirectFB_ActivateRenderer(renderer);
 
     if (texturedata->display) {
         int px, py;
@@ -969,7 +975,7 @@
                                                       srcrect->x, srcrect->y,
                                                       srcrect->w,
                                                       srcrect->h));
-        SDL_DFB_CHECK(windata->window->GetPosition(windata->window, &px, &py));
+        SDL_DFB_CHECK(windata->dfbwin->GetPosition(windata->dfbwin, &px, &py));
         px += windata->client.x;
         py += windata->client.y;
         SDL_DFB_CHECKERR(dispdata->
@@ -982,10 +988,11 @@
         DFBRectangle sr, dr;
         DFBSurfaceBlittingFlags flags = 0;
 
+#if 0
         if (texturedata->dirty.list) {
             SDL_DirtyRect *dirty;
             void *pixels;
-            int bpp = DFB_BYTES_PER_PIXEL(SDLToDFBPixelFormat(texture->format));
+            int bpp = DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format));
             int pitch = texturedata->pitch;
 
             for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
@@ -994,38 +1001,43 @@
                     (void *) ((Uint8 *) texturedata->pixels +
                               rect->y * pitch + rect->x * bpp);
                 DirectFB_UpdateTexture(renderer, texture, rect,
-                                       texturedata->pixels,
+                                       pixels,
                                        texturedata->pitch);
             }
             SDL_ClearDirtyRects(&texturedata->dirty);
         }
+#endif
+        if (texturedata->isDirty)
+        {
+            SDL_Rect rect;
+
+            rect.x = 0;
+            rect.y = 0;
+            rect.w = texture->w;
+            rect.h = texture->h;
+
+            DirectFB_UpdateTexture(renderer, texture, &rect, texturedata->pixels, texturedata->pitch);
+        }
 
         SDLtoDFBRect(srcrect, &sr);
         SDLtoDFBRect(dstrect, &dr);
 
-        SDL_DFB_CHECKERR(destsurf->
-                         SetColor(destsurf, 0xFF, 0xFF, 0xFF, 0xFF));
-        if (texture->
-            modMode & (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA))
-        {
-            if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
-                alpha = texture->a;
-                SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
-                                                    0xFF, alpha));
-            }
-            if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
+        alpha = r = g = b = 0xff;
+		if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA){
+			alpha = texture->a;
+        	flags |= DSBLIT_BLEND_COLORALPHA;
+		}
 
-                SDL_DFB_CHECKERR(destsurf->SetColor(destsurf,
-                                                    texture->r,
-                                                    texture->g,
-                                                    texture->b, alpha));
-                flags |= DSBLIT_COLORIZE;
-            }
-            if (alpha < 0xFF)
-                flags |= DSBLIT_SRC_PREMULTCOLOR;
-        } else
-            SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
-                                                0xFF, 0xFF));
+        if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
+            r = texture->r;
+            g = texture->g;
+            b = texture->b;
+            flags |= DSBLIT_COLORIZE;
+        }
+        SDL_DFB_CHECKERR(destsurf->
+                         SetColor(destsurf, r, g, b, alpha));
+
+        // ???? flags |= DSBLIT_SRC_PREMULTCOLOR;
 
         SetBlendMode(data, texture->blendMode, texturedata);
 
@@ -1059,13 +1071,27 @@
     DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
     SDL_Window *window = renderer->window;
     SDL_DFB_WINDOWDATA(window);
+    SDL_ShapeData *shape_data = (window->shaper ? window->shaper->driverdata : NULL);
 
-    DFBRectangle sr;
+    DirectFB_ActivateRenderer(renderer);
 
-    sr.x = 0;
-    sr.y = 0;
-    sr.w = window->w;
-    sr.h = window->h;
+    if (shape_data && shape_data->surface) {
+        /* saturate the window surface alpha channel */
+        SDL_DFB_CHECK(windata->window_surface->SetSrcBlendFunction(windata->window_surface, DSBF_ONE));
+        SDL_DFB_CHECK(windata->window_surface->SetDstBlendFunction(windata->window_surface, DSBF_ONE));
+        SDL_DFB_CHECK(windata->window_surface->SetDrawingFlags(windata->window_surface, DSDRAW_BLEND));
+        SDL_DFB_CHECK(windata->window_surface->SetColor(windata->window_surface, 0, 0, 0, 0xff));
+        SDL_DFB_CHECK(windata->window_surface->FillRectangle(windata->window_surface, 0,0, windata->size.w, windata->size.h));
+
+        /* blit the mask */
+        SDL_DFB_CHECK(windata->surface->SetSrcBlendFunction(windata->surface, DSBF_DESTCOLOR));
+        SDL_DFB_CHECK(windata->surface->SetDstBlendFunction(windata->surface, DSBF_ZERO));
+        SDL_DFB_CHECK(windata->surface->SetBlittingFlags(windata->surface, DSBLIT_BLEND_ALPHACHANNEL));
+#if (DFB_VERSION_ATLEAST(1,2,0))
+        SDL_DFB_CHECK(windata->surface->SetRenderOptions(windata->surface, DSRO_NONE));
+#endif
+        SDL_DFB_CHECK(windata->surface->Blit(windata->surface, shape_data->surface, NULL, 0, 0));
+    }
 
     /* Send the data to the display */
     SDL_DFB_CHECK(windata->window_surface->Flip(windata->window_surface, NULL,
@@ -1077,9 +1103,12 @@
 {
     DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
 
+    DirectFB_ActivateRenderer(renderer);
+
     if (!data) {
         return;
     }
+    //SDL_FreeDirtyRects(&data->dirty);
     SDL_DFB_RELEASE(data->palette);
     SDL_DFB_RELEASE(data->surface);
     if (data->display) {
@@ -1091,7 +1120,6 @@
                                                 DLSCL_ADMINISTRATIVE));
         SDL_DFB_RELEASE(dispdata->vidlayer);
     }
-    SDL_FreeDirtyRects(&data->dirty);
     SDL_DFB_FREE(data->pixels);
     SDL_free(data);
     texture->driverdata = NULL;
@@ -1101,6 +1129,13 @@
 DirectFB_DestroyRenderer(SDL_Renderer * renderer)
 {
     DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
+    SDL_VideoDisplay *display = renderer->window->display;
+
+#if 0
+    if (display->palette) {
+        SDL_DelPaletteWatch(display->palette, DisplayPaletteChanged, data);
+    }
+#endif
 
     if (data) {
         SDL_free(data);
@@ -1108,4 +1143,58 @@
     SDL_free(renderer);
 }
 
+static int
+DirectFB_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                     Uint32 format, void * pixels, int pitch)
+{
+    SDL_Window *window = renderer->window;
+    SDL_DFB_WINDOWDATA(window);
+    Uint32 sdl_format;
+   	void * laypixels;
+   	int laypitch;
+  	DFBSurfacePixelFormat dfb_format;
+
+    DirectFB_ActivateRenderer(renderer);
+
+    SDL_DFB_CHECK(windata->surface->GetPixelFormat(windata->surface, &dfb_format));
+    sdl_format = DirectFB_DFBToSDLPixelFormat(dfb_format);
+    SDL_DFB_CHECK(windata->surface->Lock(windata->surface, DSLF_READ, (void **) &laypixels, &laypitch));
+    
+    laypixels += (rect->y * laypitch + rect->x * SDL_BYTESPERPIXEL(sdl_format) );
+    SDL_ConvertPixels(rect->w, rect->h,
+                      sdl_format, laypixels, laypitch,
+                      format, pixels, pitch);
+
+    SDL_DFB_CHECK(windata->surface->Unlock(windata->surface));
+    
+    return 0;
+}
+
+static int
+DirectFB_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                      Uint32 format, const void * pixels, int pitch)
+{
+    SDL_Window *window = renderer->window;
+    SDL_DFB_WINDOWDATA(window);
+    Uint32 sdl_format;
+   	void * laypixels;
+   	int laypitch;
+  	DFBSurfacePixelFormat dfb_format;
+
+    SDL_DFB_CHECK(windata->surface->GetPixelFormat(windata->surface, &dfb_format));
+    sdl_format = DirectFB_DFBToSDLPixelFormat(dfb_format);
+
+    SDL_DFB_CHECK(windata->surface->Lock(windata->surface, DSLF_WRITE, (void **) &laypixels, &laypitch));
+      
+    laypixels += (rect->y * laypitch + rect->x * SDL_BYTESPERPIXEL(sdl_format) );
+    SDL_ConvertPixels(rect->w, rect->h,
+                      format, pixels, pitch,
+                      sdl_format, laypixels, laypitch);
+
+    SDL_DFB_CHECK(windata->surface->Unlock(windata->surface));
+
+    return 0;
+}
+
+
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/directfb/SDL_DirectFB_render.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_render.h	Sun Feb 06 21:23:32 2011 -0800
@@ -18,13 +18,12 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
+
 
 /* SDL surface based renderer implementation */
 
-#define SDL_DFB_RENDERERDATA(rend) DirectFB_RenderData *renddata = ((rend) ? (DirectFB_RenderData *) (rend)->driverdata : NULL)
-
-extern void DirectFB_AddRenderDriver(_THIS);
-
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/directfb/SDL_DirectFB_video.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_video.c	Sun Feb 06 21:23:32 2011 -0800
@@ -19,10 +19,23 @@
     Sam Lantinga
     slouken@libsdl.org
 
-    SDL1.3 implementation by couriersud@arcor.de
+    SDL1.3 DirectFB driver by couriersud@arcor.de
 	
 */
 
+#include "SDL_DirectFB_video.h"
+
+#include "SDL_DirectFB_events.h"
+/*
+ * #include "SDL_DirectFB_gamma.h"
+ * #include "SDL_DirectFB_keyboard.h"
+ */
+#include "SDL_DirectFB_modes.h"
+#include "SDL_DirectFB_mouse.h"
+#include "SDL_DirectFB_opengl.h"
+#include "SDL_DirectFB_window.h"
+#include "SDL_DirectFB_WM.h"
+
 
 #include "SDL_config.h"
 
@@ -46,6 +59,8 @@
 #include "SDL_DirectFB_events.h"
 #include "SDL_DirectFB_render.h"
 #include "SDL_DirectFB_mouse.h"
+#include "SDL_DirectFB_shape.h"
+
 
 #include "SDL_DirectFB_dyn.h"
 
@@ -61,6 +76,10 @@
     DirectFB_Available, DirectFB_CreateDevice
 };
 
+static const DirectFBSurfaceDrawingFlagsNames(drawing_flags);
+static const DirectFBSurfaceBlittingFlagsNames(blitting_flags);
+static const DirectFBAccelerationMaskNames(acceleration_mask);
+
 /* DirectFB driver bootstrap functions */
 
 static int
@@ -89,7 +108,7 @@
         return NULL;
 
     /* Initialize all variables that we clean on shutdown */
-    SDL_DFB_CALLOC(device, 1, sizeof(SDL_VideoDevice));
+    SDL_DFB_ALLOC_CLEAR(device, sizeof(SDL_VideoDevice));
 
     /* Set the function pointers */
 
@@ -128,8 +147,13 @@
 
 #endif
 
+	/* Shaped window support */
+	device->shape_driver.CreateShaper = DirectFB_CreateShaper;
+	device->shape_driver.SetWindowShape = DirectFB_SetWindowShape;
+	device->shape_driver.ResizeWindowShape = DirectFB_ResizeWindowShape;
+	
     device->free = DirectFB_DeleteDevice;
-	fprintf(LOG_CHANNEL, "Device setup %p!!\n", device->ShowWindow);
+    
     return device;
   error:
     if (device)
@@ -137,10 +161,6 @@
     return (0);
 }
 
-static const DirectFBSurfaceDrawingFlagsNames(drawing_flags);
-static const DirectFBSurfaceBlittingFlagsNames(blitting_flags);
-static const DirectFBAccelerationMaskNames(acceleration_mask);
-
 static void
 DirectFB_DeviceInformation(IDirectFB * dfb)
 {
@@ -149,59 +169,64 @@
 
     dfb->GetDeviceDescription(dfb, &desc);
 
-    fprintf(LOG_CHANNEL, "DirectFB Device Information\n");
-    fprintf(LOG_CHANNEL, "===========================\n");
-    fprintf(LOG_CHANNEL, "Name:           %s\n", desc.name);
-    fprintf(LOG_CHANNEL, "Vendor:         %s\n", desc.vendor);
-    fprintf(LOG_CHANNEL, "Driver Name:    %s\n", desc.driver.name);
-    fprintf(LOG_CHANNEL, "Driver Vendor:  %s\n", desc.driver.vendor);
-    fprintf(LOG_CHANNEL, "Driver Version: %d.%d\n", desc.driver.major,
+    SDL_DFB_LOG( "DirectFB Device Information\n");
+    SDL_DFB_LOG( "===========================\n");
+    SDL_DFB_LOG( "Name:           %s\n", desc.name);
+    SDL_DFB_LOG( "Vendor:         %s\n", desc.vendor);
+    SDL_DFB_LOG( "Driver Name:    %s\n", desc.driver.name);
+    SDL_DFB_LOG( "Driver Vendor:  %s\n", desc.driver.vendor);
+    SDL_DFB_LOG( "Driver Version: %d.%d\n", desc.driver.major,
             desc.driver.minor);
 
-    fprintf(LOG_CHANNEL, "\nVideo memoory:  %d\n", desc.video_memory);
+    SDL_DFB_LOG( "\nVideo memoory:  %d\n", desc.video_memory);
 
-    fprintf(LOG_CHANNEL, "\nBlitting flags:\n");
+    SDL_DFB_LOG( "\nBlitting flags:\n");
     for (n = 0; blitting_flags[n].flag; n++) {
         if (desc.blitting_flags & blitting_flags[n].flag)
-            fprintf(LOG_CHANNEL, "    %s\n", blitting_flags[n].name);
+            SDL_DFB_LOG( "    %s\n", blitting_flags[n].name);
     }
 
-    fprintf(LOG_CHANNEL, "\nDrawing flags:\n");
+    SDL_DFB_LOG( "\nDrawing flags:\n");
     for (n = 0; drawing_flags[n].flag; n++) {
         if (desc.drawing_flags & drawing_flags[n].flag)
-            fprintf(LOG_CHANNEL, "    %s\n", drawing_flags[n].name);
+            SDL_DFB_LOG( "    %s\n", drawing_flags[n].name);
     }
 
 
-    fprintf(LOG_CHANNEL, "\nAcceleration flags:\n");
+    SDL_DFB_LOG( "\nAcceleration flags:\n");
     for (n = 0; acceleration_mask[n].mask; n++) {
         if (desc.acceleration_mask & acceleration_mask[n].mask)
-            fprintf(LOG_CHANNEL, "    %s\n", acceleration_mask[n].name);
+            SDL_DFB_LOG( "    %s\n", acceleration_mask[n].name);
     }
 
 
 }
 
+static int readBoolEnv(const char *env_name, int def_val)
+{
+    char *stemp;
+
+    stemp = SDL_getenv(env_name);
+    if (stemp)
+        return atoi(stemp);
+    else
+        return def_val;
+}
+
 static int
 DirectFB_VideoInit(_THIS)
 {
     IDirectFB *dfb = NULL;
     DFB_DeviceData *devdata = NULL;
-    char *stemp;
     DFBResult ret;
 
-    SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata));
+    SDL_DFB_ALLOC_CLEAR(devdata, sizeof(*devdata));
 
     SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL));
 
     /* avoid switching to the framebuffer when we
      * are running X11 */
-    stemp = SDL_getenv(DFBENV_USE_X11_CHECK);
-    if (stemp)
-        ret = atoi(stemp);
-    else
-        ret = 1;
-
+    ret = readBoolEnv(DFBENV_USE_X11_CHECK , 1);
     if (ret) {
         if (SDL_getenv("DISPLAY"))
             DirectFBSetOption("system", "x11");
@@ -210,22 +235,20 @@
     }
 
 	/* FIXME: Reenable as default once multi kbd/mouse interface is sorted out */
-	devdata->use_linux_input = 0;       /* default: on */
-    stemp = SDL_getenv(DFBENV_USE_LINUX_INPUT);
-    if (stemp)
-        devdata->use_linux_input = atoi(stemp);
+	devdata->use_linux_input = readBoolEnv(DFBENV_USE_LINUX_INPUT, 0);       /* default: on */
 
     if (!devdata->use_linux_input)
+    {
+		SDL_DFB_LOG("Disabling linxu input\n");    
         DirectFBSetOption("disable-module", "linux_input");
-
+    }
+    
     SDL_DFB_CHECKERR(DirectFBCreate(&dfb));
 
     DirectFB_DeviceInformation(dfb);
-    devdata->use_yuv_underlays = 0;     /* default: off */
-    stemp = SDL_getenv(DFBENV_USE_YUV_UNDERLAY);
-    if (stemp)
-        devdata->use_yuv_underlays = atoi(stemp);
-
+    
+    devdata->use_yuv_underlays = readBoolEnv(DFBENV_USE_YUV_UNDERLAY, 0);     /* default: off */
+    devdata->use_yuv_direct = readBoolEnv(DFBENV_USE_YUV_DIRECT, 0);      /* default is off! */
 
     /* Create global Eventbuffer for axis events */
     if (devdata->use_linux_input) {
@@ -239,14 +262,10 @@
                                                      &devdata->events));
     }
 
-    devdata->initialized = 1;
+    /* simple window manager support */
+    devdata->has_own_wm = readBoolEnv(DFBENV_USE_WM, 0);
 
-    /* simple window manager support */
-    stemp = SDL_getenv(DFBENV_USE_WM);
-    if (stemp)
-        devdata->has_own_wm = atoi(stemp);
-    else
-        devdata->has_own_wm = 0;
+    devdata->initialized = 1;
 
     devdata->dfb = dfb;
     devdata->firstwin = NULL;
@@ -260,7 +279,6 @@
     DirectFB_GL_Initialize(_this);
 #endif
 
-    DirectFB_AddRenderDriver(_this);
     DirectFB_InitMouse(_this);
     DirectFB_InitKeyboard(_this);
 
@@ -282,6 +300,7 @@
     DirectFB_QuitKeyboard(_this);
     DirectFB_QuitMouse(_this);
 
+    devdata->events->Reset(devdata->events);
     SDL_DFB_RELEASE(devdata->events);
     SDL_DFB_RELEASE(devdata->dfb);
 
@@ -291,3 +310,114 @@
 
     devdata->initialized = 0;
 }
+
+/* DirectFB driver general support functions */
+
+static const struct {
+    DFBSurfacePixelFormat dfb;
+    Uint32 sdl;
+} pixelformat_tab[] = 
+{
+    { DSPF_RGB32, SDL_PIXELFORMAT_RGB888 },             /* 24 bit RGB (4 byte, nothing@24, red 8@16, green 8@8, blue 8@0) */
+    { DSPF_ARGB, SDL_PIXELFORMAT_ARGB8888 },            /* 32 bit ARGB (4 byte, alpha 8@24, red 8@16, green 8@8, blue 8@0) */
+    { DSPF_RGB16, SDL_PIXELFORMAT_RGB565 },             /* 16 bit RGB (2 byte, red 5@11, green 6@5, blue 5@0) */
+    { DSPF_RGB332, SDL_PIXELFORMAT_RGB332 },            /* 8 bit RGB (1 byte, red 3@5, green 3@2, blue 2@0) */
+    { DSPF_ARGB4444, SDL_PIXELFORMAT_ARGB4444 },        /* 16 bit ARGB (2 byte, alpha 4@12, red 4@8, green 4@4, blue 4@0) */
+    { DSPF_ARGB1555, SDL_PIXELFORMAT_ARGB1555 },        /* 16 bit ARGB (2 byte, alpha 1@15, red 5@10, green 5@5, blue 5@0) */
+    { DSPF_RGB24, SDL_PIXELFORMAT_RGB24 },              /* 24 bit RGB (3 byte, red 8@16, green 8@8, blue 8@0) */
+    { DSPF_RGB444, SDL_PIXELFORMAT_RGB444 },            /* 16 bit RGB (2 byte, nothing @12, red 4@8, green 4@4, blue 4@0) */
+    { DSPF_YV12, SDL_PIXELFORMAT_YV12 },                /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size V/U planes) */
+    { DSPF_I420,SDL_PIXELFORMAT_IYUV },                 /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size U/V planes) */
+    { DSPF_YUY2, SDL_PIXELFORMAT_YUY2 },                /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains CbYCrY [31:0]) */
+    { DSPF_UYVY, SDL_PIXELFORMAT_UYVY },                /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains YCbYCr [31:0]) */
+    { DSPF_RGB555, SDL_PIXELFORMAT_RGB555 },            /* 16 bit RGB (2 byte, nothing @15, red 5@10, green 5@5, blue 5@0) */
+#if (ENABLE_LUT8)
+    { DSPF_LUT8, SDL_PIXELFORMAT_INDEX8 },              /* 8 bit LUT (8 bit color and alpha lookup from palette) */
+#endif
+
+#if (DFB_VERSION_ATLEAST(1,2,0))
+    { DSPF_BGR555, SDL_PIXELFORMAT_BGR555 },            /* 16 bit BGR (2 byte, nothing @15, blue 5@10, green 5@5, red 5@0) */
+#else
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR555 },
+#endif
+
+    /* Pfff ... nonmatching formats follow */    
+    
+    { DSPF_ALUT44, SDL_PIXELFORMAT_UNKNOWN },           /* 8 bit ALUT (1 byte, alpha 4@4, color lookup 4@0) */
+ 	{ DSPF_A8, SDL_PIXELFORMAT_UNKNOWN },               /* 	8 bit alpha (1 byte, alpha 8@0), e.g. anti-aliased glyphs */
+ 	{ DSPF_AiRGB, SDL_PIXELFORMAT_UNKNOWN },            /* 	32 bit ARGB (4 byte, inv. alpha 8@24, red 8@16, green 8@8, blue 8@0) */
+ 	{ DSPF_A1, SDL_PIXELFORMAT_UNKNOWN },               /* 	1 bit alpha (1 byte/ 8 pixel, most significant bit used first) */
+ 	{ DSPF_NV12, SDL_PIXELFORMAT_UNKNOWN },             /* 	12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CbCr [15:0] plane) */
+ 	{ DSPF_NV16, SDL_PIXELFORMAT_UNKNOWN },             /* 	16 bit YUV (8 bit Y plane followed by one 16 bit half width CbCr [15:0] plane) */
+ 	{ DSPF_ARGB2554, SDL_PIXELFORMAT_UNKNOWN },         /* 	16 bit ARGB (2 byte, alpha 2@14, red 5@9, green 5@4, blue 4@0) */
+ 	{ DSPF_NV21, SDL_PIXELFORMAT_UNKNOWN },             /* 	12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CrCb [15:0] plane) */
+ 	{ DSPF_AYUV, SDL_PIXELFORMAT_UNKNOWN },             /* 	32 bit AYUV (4 byte, alpha 8@24, Y 8@16, Cb 8@8, Cr 8@0) */
+ 	{ DSPF_A4, SDL_PIXELFORMAT_UNKNOWN },               /* 	4 bit alpha (1 byte/ 2 pixel, more significant nibble used first) */
+ 	{ DSPF_ARGB1666, SDL_PIXELFORMAT_UNKNOWN },         /* 	1 bit alpha (3 byte/ alpha 1@18, red 6@16, green 6@6, blue 6@0) */
+ 	{ DSPF_ARGB6666, SDL_PIXELFORMAT_UNKNOWN },         /* 	6 bit alpha (3 byte/ alpha 6@18, red 6@16, green 6@6, blue 6@0) */
+ 	{ DSPF_RGB18, SDL_PIXELFORMAT_UNKNOWN },            /* 	6 bit RGB (3 byte/ red 6@16, green 6@6, blue 6@0) */
+ 	{ DSPF_LUT2, SDL_PIXELFORMAT_UNKNOWN },             /* 	2 bit LUT (1 byte/ 4 pixel, 2 bit color and alpha lookup from palette) */
+
+#if (DFB_VERSION_ATLEAST(1,3,0))
+ 	{ DSPF_RGBA4444, SDL_PIXELFORMAT_UNKNOWN },         /* 16 bit RGBA (2 byte, red 4@12, green 4@8, blue 4@4, alpha 4@0) */
+#endif
+
+#if (DFB_VERSION_ATLEAST(1,4,3))
+ 	{ DSPF_RGBA5551, SDL_PIXELFORMAT_UNKNOWN },         /* 	16 bit RGBA (2 byte, red 5@11, green 5@6, blue 5@1, alpha 1@0) */
+ 	{ DSPF_YUV444P, SDL_PIXELFORMAT_UNKNOWN },          /* 	24 bit full YUV planar (8 bit Y plane followed by an 8 bit Cb and an 8 bit Cr plane) */
+ 	{ DSPF_ARGB8565, SDL_PIXELFORMAT_UNKNOWN },         /* 	24 bit ARGB (3 byte, alpha 8@16, red 5@11, green 6@5, blue 5@0) */
+ 	{ DSPF_AVYU, SDL_PIXELFORMAT_UNKNOWN },             /* 	32 bit AVYU 4:4:4 (4 byte, alpha 8@24, Cr 8@16, Y 8@8, Cb 8@0) */
+ 	{ DSPF_VYU, SDL_PIXELFORMAT_UNKNOWN },              /* 	24 bit VYU 4:4:4 (3 byte, Cr 8@16, Y 8@8, Cb 8@0)  */
+#endif
+ 	
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1MSB },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4LSB }, 
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4MSB },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR24 },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR888 },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_RGBA8888 },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR8888 },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGRA8888 },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_ARGB2101010 },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR4444 },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR1555 },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR565 },
+    { DSPF_UNKNOWN, SDL_PIXELFORMAT_YVYU },                        /**< Packed mode: Y0+V0+Y1+U0 (1 pla	*/
+};
+
+Uint32
+DirectFB_DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat)
+{
+    int i;
+    
+    for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
+        if (pixelformat_tab[i].dfb == pixelformat)
+        {
+            return pixelformat_tab[i].sdl;
+        }
+    return SDL_PIXELFORMAT_UNKNOWN;
+}
+
+DFBSurfacePixelFormat
+DirectFB_SDLToDFBPixelFormat(Uint32 format)
+{
+    int i;
+    
+    for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
+        if (pixelformat_tab[i].sdl == format)
+        {
+            return pixelformat_tab[i].dfb;
+        }
+    return DSPF_UNKNOWN;
+}
+
+void DirectFB_SetSupportedPixelFormats(SDL_RendererInfo* ri)
+{
+	int i, j;
+
+    for (i=0, j=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
+    	if (pixelformat_tab[i].sdl != SDL_PIXELFORMAT_UNKNOWN)
+    		ri->texture_formats[j++] = pixelformat_tab[i].sdl;
+    ri->num_texture_formats = j;
+}
--- a/src/video/directfb/SDL_DirectFB_video.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_video.h	Sun Feb 06 21:23:32 2011 -0800
@@ -18,28 +18,22 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
+
 #include "SDL_config.h"
 
 #ifndef _SDL_DirectFB_video_h
 #define _SDL_DirectFB_video_h
 
-#include "../SDL_sysvideo.h"
-
 #include <directfb.h>
 #include <directfb_version.h>
 
-#include "SDL_mouse.h"
-
-
-/* Set below to 1 to compile with (old) multi mice/keyboard api. Code left in
- * in case we see this again ... 
- */
-
-#define USE_MULTI_API	(0)
-
-#define DEBUG 1
-#define LOG_CHANNEL 	stdout
+#include "../SDL_sysvideo.h"
+#include "SDL_scancode.h"
+#include "SDL_render.h"
 
 #define DFB_VERSIONNUM(X, Y, Z)						\
 	((X)*1000 + (Y)*100 + (Z))
@@ -52,25 +46,29 @@
 
 #if (DFB_VERSION_ATLEAST(1,0,0))
 #define SDL_DIRECTFB_OPENGL 1
-#include <directfbgl.h>
 #else
 #error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
 #endif
 
-#if SDL_DIRECTFB_OPENGL
-#include "SDL_loadso.h"
+/* Set below to 1 to compile with (old) multi mice/keyboard api. Code left in
+ * in case we see this again ... 
+ */
+
+#define USE_MULTI_API	(0)
+
+/* Support for LUT8/INDEX8 pixel format.
+ * This is broken in DirectFB 1.4.3. It works in 1.4.0 and 1.4.5
+ * occurred.
+ */
+
+#if (DFB_COMPILEDVERSION == DFB_VERSIONNUM(1, 4, 3))
+#define ENABLE_LUT8		(0)
+#else
+#define ENABLE_LUT8		(1)
 #endif
 
-#include "SDL_DirectFB_events.h"
-/*
- * #include "SDL_DirectFB_gamma.h"
- * #include "SDL_DirectFB_keyboard.h"
- */
-#include "SDL_DirectFB_modes.h"
-#include "SDL_DirectFB_mouse.h"
-#include "SDL_DirectFB_opengl.h"
-#include "SDL_DirectFB_window.h"
-#include "SDL_DirectFB_WM.h"
+#define DIRECTFB_DEBUG 1
+#define LOG_CHANNEL 	stdout
 
 #define DFBENV_USE_YUV_UNDERLAY 	"SDL_DIRECTFB_YUV_UNDERLAY"     /* Default: off */
 #define DFBENV_USE_YUV_DIRECT   	"SDL_DIRECTFB_YUV_DIRECT"       /* Default: off */
@@ -82,76 +80,103 @@
 #define SDL_DFB_FREE(x) do { if ( (x) != NULL ) { SDL_free(x); x = NULL; } } while (0)
 #define SDL_DFB_UNLOCK(x) do { if ( (x) != NULL ) { x->Unlock(x); } } while (0)
 
-#if DEBUG
-/* FIXME: do something with DEBUG */
-#endif
-
 #define SDL_DFB_CONTEXT "SDL_DirectFB"
 
-static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line, const char *src_code) {
+#define SDL_DFB_ERR(x...) 							\
+	do {											\
+		fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t",	\
+			SDL_DFB_CONTEXT, __FILE__, __LINE__ );	\
+        fprintf(LOG_CHANNEL, x ); 					\
+	} while (0)
+
+#if (DIRECTFB_DEBUG)
+
+#define SDL_DFB_LOG(x...) 							\
+	do {											\
+		fprintf(LOG_CHANNEL, SDL_DFB_CONTEXT);		\
+        fprintf(LOG_CHANNEL, x ); 					\
+		fprintf(LOG_CHANNEL, "\n");					\
+	} while (0)
+
+#define SDL_DFB_DEBUG(x...) SDL_DFB_ERR( x )
+
+static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line) {
 	if (ret != DFB_OK) {
-		fprintf(LOG_CHANNEL, "%s <%d>:\n\t", src_file, src_line );
-		fprintf(LOG_CHANNEL, "\t%s\n", src_code );
-		fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) );
-		SDL_SetError( src_code, DirectFBErrorString (ret) );
+		SDL_DFB_LOG("%s (%d):%s", src_file, src_line, DirectFBErrorString (ret) );
+		SDL_SetError("%s:%s", SDL_DFB_CONTEXT, DirectFBErrorString (ret) );
 	}
 	return ret;
 }
 
-#define SDL_DFB_CHECK(x...) sdl_dfb_check( x, __FILE__, __LINE__, #x )
+#define SDL_DFB_CHECK(x...) do { sdl_dfb_check( x, __FILE__, __LINE__); } while (0)
+#define SDL_DFB_CHECKERR(x...) do { if ( sdl_dfb_check( x, __FILE__, __LINE__) != DFB_OK ) goto error; } while (0)
 
-#define SDL_DFB_CHECKERR(x...) if ( sdl_dfb_check( x, __FILE__, __LINE__, #x ) != DFB_OK ) goto error
+#else
 
-#define SDL_DFB_DEBUG(x...) 							\
-	do {											\
-		fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t",			\
-			SDL_DFB_CONTEXT, __FILE__, __LINE__ );	\
-        fprintf(LOG_CHANNEL, x ); \
-	} while (0)
+#define SDL_DFB_CHECK(x...) x
+#define SDL_DFB_CHECKERR(x...) do { if (x != DFB_OK ) goto error; } while (0)
+#define SDL_DFB_LOG(x...) do {} while (0)
+#define SDL_DFB_DEBUG(x...) do {} while (0)
 
-#define SDL_DFB_ERR(x...) SDL_DFB_DEBUG( x )
+#endif
+
 
 #define SDL_DFB_CALLOC(r, n, s) \
-     do {                                                                \
-          r = SDL_calloc (n, s);                                      \
-          if (!(r)) {                                                 \
-               fprintf( LOG_CHANNEL, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
-               SDL_OutOfMemory();                                     \
-               goto error; 					      \
-          }                                                           \
+     do {                                           \
+          r = SDL_calloc (n, s);                    \
+          if (!(r)) {                               \
+               SDL_DFB_ERR("Out of memory"); 		\
+               SDL_OutOfMemory();                   \
+               goto error; 					      	\
+          }                                         \
      } while (0)
 
+#define SDL_DFB_ALLOC_CLEAR(r, s) SDL_DFB_CALLOC(r, 1, s)
+
 /* Private display data */
 
 #define SDL_DFB_DEVICEDATA(dev)  DFB_DeviceData *devdata = (dev ? (DFB_DeviceData *) ((dev)->driverdata) : NULL)
 
 #define DFB_MAX_SCREENS 10
 
+typedef struct _DFB_KeyboardData DFB_KeyboardData;
+struct _DFB_KeyboardData
+{
+	const SDL_ScanCode	*map;		/* keyboard scancode map */
+	int				map_size;	/* size of map */
+	int				map_adjust; /* index adjust */
+    int 			is_generic; /* generic keyboard */
+    int id;
+};
+
 typedef struct _DFB_DeviceData DFB_DeviceData;
 struct _DFB_DeviceData
 {
     int initialized;
 
-    IDirectFB *dfb;
-    int num_mice;
-    int mouse_id[0x100];
-    int num_keyboard;
-    struct
-    {
-        int is_generic;
-        int id;
-    } keyboard[10];
-    DFB_WindowData *firstwin;
+    IDirectFB 			*dfb;
+    int 				num_mice;
+    int 				mouse_id[0x100];
+    int 				num_keyboard;
+    DFB_KeyboardData 	keyboard[10];
+    SDL_Window	 		*firstwin;
 
-    int use_yuv_underlays;
-    int use_linux_input;
-    int has_own_wm;
+    int 				use_yuv_underlays;
+    int 				use_yuv_direct;
+    int 				use_linux_input;
+    int 				has_own_wm;
+
 
 	/* window grab */
-	SDL_Window *grabbed_window;
+	SDL_Window 			*grabbed_window;
 
     /* global events */
     IDirectFBEventBuffer *events;
 };
 
+Uint32 DirectFB_DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat);
+DFBSurfacePixelFormat DirectFB_SDLToDFBPixelFormat(Uint32 format);
+void DirectFB_SetSupportedPixelFormats(SDL_RendererInfo *ri);
+
+
 #endif /* _SDL_DirectFB_video_h */
--- a/src/video/directfb/SDL_DirectFB_window.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_window.c	Sun Feb 06 21:23:32 2011 -0800
@@ -18,41 +18,49 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
-
-#include "SDL_syswm.h"
-#include "../SDL_sysvideo.h"
-#include "../../events/SDL_keyboard_c.h"
-#include "../../video/SDL_pixels_c.h"
 
 #include "SDL_DirectFB_video.h"
+#include "SDL_DirectFB_modes.h"
+#include "SDL_DirectFB_window.h"
+#include "SDL_DirectFB_shape.h"
+
 #if SDL_DIRECTFB_OPENGL
 #include "SDL_DirectFB_opengl.h"
 #endif
 
-static void DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window);
+#include "SDL_syswm.h"
+
+#include "../SDL_pixels_c.h"
 
 int
 DirectFB_CreateWindow(_THIS, SDL_Window * window)
 {
     SDL_DFB_DEVICEDATA(_this);
-    SDL_DFB_DISPLAYDATA(_this, window);
+    SDL_DFB_DISPLAYDATA(window);
     DFB_WindowData *windata = NULL;
     DFBWindowOptions wopts;
     DFBWindowDescription desc;
     int x, y;
+    int bshaped = 0;
 
-    SDL_DFB_CALLOC(window->driverdata, 1, sizeof(DFB_WindowData));
+    SDL_DFB_ALLOC_CLEAR(window->driverdata, sizeof(DFB_WindowData));
     windata = (DFB_WindowData *) window->driverdata;
 
     windata->is_managed = devdata->has_own_wm;
-
+#if 1
     SDL_DFB_CHECKERR(devdata->dfb->SetCooperativeLevel(devdata->dfb,
                                                        DFSCL_NORMAL));
     SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer,
                                                           DLSCL_ADMINISTRATIVE));
-
+#endif
+	/* FIXME ... ughh, ugly */
+	if (window->x == -1000 && window->y == -1000)
+		bshaped = 1;
+	
     /* Fill the window description. */
     if (window->x == SDL_WINDOWPOS_CENTERED) {
         x = (dispdata->cw - window->w) / 2;
@@ -61,6 +69,7 @@
     } else {
         x = window->x;
     }
+    
     if (window->y == SDL_WINDOWPOS_CENTERED) {
         y = (dispdata->ch - window->h) / 2;
     } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
@@ -68,6 +77,7 @@
     } else {
         y = window->y;
     }
+    
     if (window->flags & SDL_WINDOW_FULLSCREEN) {
         x = 0;
         y = 0;
@@ -76,78 +86,103 @@
     DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
 
     /* Create Window */
+	desc.caps = 0;
     desc.flags =
-        DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT | DWDESC_POSX
-        | DWDESC_POSY | DWDESC_SURFACE_CAPS;
+        DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY | DWDESC_SURFACE_CAPS;
+
+    if (bshaped) {
+    	desc.flags |= DWDESC_CAPS;
+    	desc.caps |= DWCAPS_ALPHACHANNEL;
+    }
+    else
+    {
+    	desc.flags |= DWDESC_PIXELFORMAT;
+    }
+
+    if (!(window->flags & SDL_WINDOW_BORDERLESS))
+		desc.caps |= DWCAPS_NODECORATION;
+
     desc.posx = x;
     desc.posy = y;
     desc.width = windata->size.w;
     desc.height = windata->size.h;
     desc.pixelformat = dispdata->pixelformat;
     desc.surface_caps = DSCAPS_PREMULTIPLIED;
-
+    
     /* Create the window. */
     SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc,
-                                                   &windata->window));
+                                                   &windata->dfbwin));
 
     /* Set Options */
-    SDL_DFB_CHECK(windata->window->GetOptions(windata->window, &wopts));
+    SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts));
 
-    if (window->flags & SDL_WINDOW_RESIZABLE)
-        wopts |= DWOP_SCALE;
-    else
+    /* explicit rescaling of surface */
+    wopts |= DWOP_SCALE;
+    if (window->flags & SDL_WINDOW_RESIZABLE) {
+        wopts &= ~DWOP_KEEP_SIZE;
+    }
+    else {
         wopts |= DWOP_KEEP_SIZE;
+    }
 
     if (window->flags & SDL_WINDOW_FULLSCREEN) {
         wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_STACKING | DWOP_KEEP_SIZE;
-        SDL_DFB_CHECK(windata->window->SetStackingClass(windata->window, DWSC_UPPER));
+        SDL_DFB_CHECK(windata->dfbwin->SetStackingClass(windata->dfbwin, DWSC_UPPER));
     }
-    SDL_DFB_CHECK(windata->window->SetOptions(windata->window, wopts));
+    
+    if (bshaped) {
+        wopts |= DWOP_SHAPED | DWOP_ALPHACHANNEL;
+        wopts &= ~DWOP_OPAQUE_REGION;
+    }
+
+    SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
 
     /* See what we got */
-    SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
+    SDL_DFB_CHECK(DirectFB_WM_GetClientSize
                      (_this, window, &window->w, &window->h));
 
     /* Get the window's surface. */
-    SDL_DFB_CHECKERR(windata->window->GetSurface(windata->window,
+    SDL_DFB_CHECKERR(windata->dfbwin->GetSurface(windata->dfbwin,
                                                  &windata->window_surface));
+
     /* And get a subsurface for rendering */
     SDL_DFB_CHECKERR(windata->window_surface->
                      GetSubSurface(windata->window_surface, &windata->client,
                                    &windata->surface));
 
-    SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0xFF));
+    SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, 0xFF));
 
     /* Create Eventbuffer */
-    SDL_DFB_CHECKERR(windata->window->CreateEventBuffer(windata->window,
+
+    SDL_DFB_CHECKERR(windata->dfbwin->CreateEventBuffer(windata->dfbwin,
                                                         &windata->
                                                         eventbuffer));
-    SDL_DFB_CHECKERR(windata->window->
-                     EnableEvents(windata->window, DWET_ALL));
+    SDL_DFB_CHECKERR(windata->dfbwin->
+                     EnableEvents(windata->dfbwin, DWET_ALL));
 
     /* Create a font */
     /* FIXME: once during Video_Init */
     windata->font = NULL;
 
     /* Make it the top most window. */
-    SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window));
+    SDL_DFB_CHECK(windata->dfbwin->RaiseToTop(windata->dfbwin));
 
     /* remember parent */
-    windata->sdl_window = window;
+    //windata->sdlwin = window;
 
     /* Add to list ... */
 
     windata->next = devdata->firstwin;
     windata->opacity = 0xFF;
-    devdata->firstwin = windata;
+    devdata->firstwin = window;
 
     /* Draw Frame */
     DirectFB_WM_RedrawLayout(_this, window);
 
     return 0;
   error:
-    SDL_DFB_RELEASE(windata->window);
-    SDL_DFB_RELEASE(windata->surface);
+	SDL_DFB_RELEASE(windata->surface);
+    SDL_DFB_RELEASE(windata->dfbwin);
     return -1;
 }
 
@@ -226,61 +261,69 @@
 DirectFB_SetWindowPosition(_THIS, SDL_Window * window)
 {
     SDL_DFB_WINDOWDATA(window);
+    SDL_DFB_DISPLAYDATA(window);
     int x, y;
 
-    if (window->y == SDL_WINDOWPOS_UNDEFINED)
+    if (window->x == SDL_WINDOWPOS_CENTERED) {
+        x = (dispdata->cw - window->w) / 2;
+    } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
+        x = 0;
+    } else {
+        x = window->x;
+    }
+    
+    if (window->y == SDL_WINDOWPOS_CENTERED) {
+        y = (dispdata->ch - window->h) / 2;
+    } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
         y = 0;
-    else
+    } else {
         y = window->y;
-
-    if (window->x == SDL_WINDOWPOS_UNDEFINED)
-        x = 0;
-    else
-        x = window->x;
+    }
 
     if (window->flags & SDL_WINDOW_FULLSCREEN) {
         x = 0;
         y = 0;
     }
     DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
-    SDL_DFB_CHECK(windata->window->MoveTo(windata->window, x, y));
+    SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, x, y));
 }
 
 void
 DirectFB_SetWindowSize(_THIS, SDL_Window * window)
 {
-    //SDL_DFB_DEVICEDATA(_this);
     SDL_DFB_WINDOWDATA(window);
 
+    if(SDL_IsShapedWindow(window))
+        DirectFB_ResizeWindowShape(window);
+
     if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
         int cw;
         int ch;
 
         /* Make sure all events are disabled for this operation ! */
-        SDL_DFB_CHECKERR(windata->window->DisableEvents(windata->window,
+        SDL_DFB_CHECKERR(windata->dfbwin->DisableEvents(windata->dfbwin,
                                                         DWET_ALL));
-
         SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize(_this, window, &cw, &ch));
 
         if (cw != window->w || ch != window->h) {
 
 		    DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
-            SDL_DFB_CHECKERR(windata->window->Resize(windata->window,
+            SDL_DFB_CHECKERR(windata->dfbwin->Resize(windata->dfbwin,
                                                      windata->size.w,
                                                      windata->size.h));
         }
 
         SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
                      (_this, window, &window->w, &window->h));
-        DirectFB_AdjustWindowSurface(_this, window);
+        DirectFB_AdjustWindowSurface(window);
 
-        SDL_DFB_CHECKERR(windata->window->EnableEvents(windata->window,
+        SDL_DFB_CHECKERR(windata->dfbwin->EnableEvents(windata->dfbwin,
                                                        DWET_ALL));
 
     }
     return;
   error:
-    SDL_DFB_CHECK(windata->window->EnableEvents(windata->window, DWET_ALL));
+    SDL_DFB_CHECK(windata->dfbwin->EnableEvents(windata->dfbwin, DWET_ALL));
     return;
 }
 
@@ -289,7 +332,7 @@
 {
     SDL_DFB_WINDOWDATA(window);
 
-    SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, windata->opacity));
+    SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, windata->opacity));
 
 }
 
@@ -298,8 +341,8 @@
 {
     SDL_DFB_WINDOWDATA(window);
 
-    SDL_DFB_CHECK(windata->window->GetOpacity(windata->window, &windata->opacity));
-    SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0));
+    SDL_DFB_CHECK(windata->dfbwin->GetOpacity(windata->dfbwin, &windata->opacity));
+    SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, 0));
 }
 
 void
@@ -307,19 +350,32 @@
 {
     SDL_DFB_WINDOWDATA(window);
 
-    SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window));
-    SDL_DFB_CHECK(windata->window->RequestFocus(windata->window));
+    SDL_DFB_CHECK(windata->dfbwin->RaiseToTop(windata->dfbwin));
+    SDL_DFB_CHECK(windata->dfbwin->RequestFocus(windata->dfbwin));
 }
 
 void
 DirectFB_MaximizeWindow(_THIS, SDL_Window * window)
 {
     SDL_DFB_WINDOWDATA(window);
+    SDL_VideoDisplay *display = window->display;
+    DFBWindowOptions wopts;
 
-    if (windata->is_managed) {
-        DirectFB_WM_MaximizeWindow(_this, window);
-    } else
-        SDL_Unsupported();
+    SDL_DFB_CHECK(windata->dfbwin->GetPosition(windata->dfbwin,
+                                 &windata->restore.x, &windata->restore.y));
+    SDL_DFB_CHECK(windata->dfbwin->GetSize(windata->dfbwin, &windata->restore.w,
+                             &windata->restore.h));
+
+    DirectFB_WM_AdjustWindowLayout(window, window->flags | SDL_WINDOW_MAXIMIZED, display->current_mode.w, display->current_mode.h) ;
+
+    SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, 0, 0));
+    SDL_DFB_CHECK(windata->dfbwin->Resize(windata->dfbwin,
+                            display->current_mode.w, display->current_mode.h));
+
+    /* Set Options */
+    SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts));
+    wopts |= DWOP_KEEP_SIZE | DWOP_KEEP_POSITION;
+    SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
 }
 
 void
@@ -334,11 +390,29 @@
 DirectFB_RestoreWindow(_THIS, SDL_Window * window)
 {
     SDL_DFB_WINDOWDATA(window);
+    DFBWindowOptions wopts;
 
-    if (windata->is_managed) {
-        DirectFB_WM_RestoreWindow(_this, window);
-    } else
-        SDL_Unsupported();
+    /* Set Options */
+    SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts));
+    wopts &= ~(DWOP_KEEP_SIZE | DWOP_KEEP_POSITION);
+    SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
+
+    /* Window layout */
+    DirectFB_WM_AdjustWindowLayout(window, window->flags & ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED),
+    	windata->restore.w, windata->restore.h);
+    SDL_DFB_CHECK(windata->dfbwin->Resize(windata->dfbwin, windata->restore.w,
+                            windata->restore.h));
+    SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, windata->restore.x,
+                            windata->restore.y));
+
+    if (!(window->flags & SDL_WINDOW_RESIZABLE))
+        wopts |= DWOP_KEEP_SIZE;
+
+    if (window->flags & SDL_WINDOW_FULLSCREEN)
+        wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_SIZE;
+    SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
+
+
 }
 
 void
@@ -351,15 +425,15 @@
     if ((window->flags & SDL_WINDOW_INPUT_GRABBED)) {
         if (gwindata != NULL)
         {
-		    SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window));
-		    SDL_DFB_CHECK(gwindata->window->UngrabKeyboard(gwindata->window));
+		    SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin));
+		    SDL_DFB_CHECK(gwindata->dfbwin->UngrabKeyboard(gwindata->dfbwin));
         }
-        SDL_DFB_CHECK(windata->window->GrabPointer(windata->window));
-        SDL_DFB_CHECK(windata->window->GrabKeyboard(windata->window));
+        SDL_DFB_CHECK(windata->dfbwin->GrabPointer(windata->dfbwin));
+        SDL_DFB_CHECK(windata->dfbwin->GrabKeyboard(windata->dfbwin));
         devdata->grabbed_window = window;
     } else {
-        SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
-        SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window));
+        SDL_DFB_CHECK(windata->dfbwin->UngrabPointer(windata->dfbwin));
+        SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin));
         devdata->grabbed_window = NULL;
     }
 }
@@ -372,13 +446,22 @@
     DFB_WindowData *p;
 
     /* Some cleanups */
-    SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
-    SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window));
+    SDL_DFB_CHECK(windata->dfbwin->UngrabPointer(windata->dfbwin));
+    SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin));
 
 #if SDL_DIRECTFB_OPENGL
 	DirectFB_GL_DestroyWindowContexts(_this, window);
 #endif
 
+	if (window->shaper)
+	{
+	    SDL_ShapeData *data = window->shaper->driverdata;
+	    SDL_DFB_CHECK(data->surface->ReleaseSource(data->surface));
+    	SDL_DFB_RELEASE(data->surface);
+    	SDL_DFB_FREE(data);
+    	SDL_DFB_FREE(window->shaper);
+	}
+
     SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, NULL));
     SDL_DFB_CHECK(windata->surface->ReleaseSource(windata->surface));
     SDL_DFB_CHECK(windata->window_surface->ReleaseSource(windata->window_surface));
@@ -388,13 +471,14 @@
     SDL_DFB_RELEASE(windata->surface);
     SDL_DFB_RELEASE(windata->window_surface);
 
-    SDL_DFB_RELEASE(windata->window);
+    SDL_DFB_RELEASE(windata->dfbwin);
 
     /* Remove from list ... */
 
-    p = devdata->firstwin;
-    while (p && p->next != windata)
-        p = p->next;
+    p = devdata->firstwin->driverdata;
+
+    while (p && p->next != window)
+        p = (p->next ? p->next->driverdata : NULL);
     if (p)
         p->next = windata->next;
     else
@@ -407,12 +491,25 @@
 DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
                          struct SDL_SysWMinfo * info)
 {
-    SDL_Unsupported();
-    return SDL_FALSE;
+    SDL_DFB_DEVICEDATA(_this);
+    SDL_DFB_WINDOWDATA(window);
+
+    if (info->version.major == SDL_MAJOR_VERSION &&
+        info->version.minor == SDL_MINOR_VERSION) {
+        info->subsystem = SDL_SYSWM_DIRECTFB;
+        info->info.dfb.dfb = devdata->dfb;
+        info->info.dfb.window = windata->dfbwin;
+        info->info.dfb.surface = windata->surface;
+        return SDL_TRUE;
+    } else {
+        SDL_SetError("Application not compiled with SDL %d.%d\n",
+                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+        return SDL_FALSE;
+    }
 }
 
-static void
-DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window)
+void
+DirectFB_AdjustWindowSurface(SDL_Window * window)
 {
     SDL_DFB_WINDOWDATA(window);
     int adjust = windata->wm_needs_redraw;
@@ -429,11 +526,11 @@
 
     if (adjust) {
 #if SDL_DIRECTFB_OPENGL
-		DirectFB_GL_FreeWindowContexts(_this, window);
+		DirectFB_GL_FreeWindowContexts(window->display->device, window);
 #endif
 
-#if DFB_VERSION_ATLEAST(1,2,1)
-        SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
+#if (DFB_VERSION_ATLEAST(1,2,1))
+        SDL_DFB_CHECKERR(windata->dfbwin->ResizeSurface(windata->dfbwin,
                                                         windata->size.w,
                                                         windata->size.h));
         SDL_DFB_CHECKERR(windata->surface->MakeSubSurface(windata->surface,
@@ -443,22 +540,22 @@
 #else
         DFBWindowOptions opts;
 
-        SDL_DFB_CHECKERR(windata->window->GetOptions(windata->window, &opts));
+        SDL_DFB_CHECKERR(windata->dfbwin->GetOptions(windata->dfbwin, &opts));
         /* recreate subsurface */
         SDL_DFB_RELEASE(windata->surface);
 
         if (opts & DWOP_SCALE)
-            SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
+            SDL_DFB_CHECKERR(windata->dfbwin->ResizeSurface(windata->dfbwin,
                                                             windata->size.w,
                                                             windata->size.h));
         SDL_DFB_CHECKERR(windata->window_surface->
                          GetSubSurface(windata->window_surface,
                                        &windata->client, &windata->surface));
 #endif
-        DirectFB_WM_RedrawLayout(_this, window);
+        DirectFB_WM_RedrawLayout(window->display->device, window);
         
 #if SDL_DIRECTFB_OPENGL
-		DirectFB_GL_ReAllocWindowContexts(_this, window);
+		DirectFB_GL_ReAllocWindowContexts(window->display->device, window);
 #endif
    }
   error:
--- a/src/video/directfb/SDL_DirectFB_window.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_window.h	Sun Feb 06 21:23:32 2011 -0800
@@ -18,12 +18,15 @@
 
     Sam Lantinga
     slouken@libsdl.org
+
+    SDL1.3 DirectFB driver by couriersud@arcor.de
+	
 */
-#include "SDL_config.h"
 
 #ifndef _SDL_directfb_window_h
 #define _SDL_directfb_window_h
 
+#include "SDL_DirectFB_video.h"
 #include "SDL_DirectFB_WM.h"
 
 #define SDL_DFB_WINDOWDATA(win)  DFB_WindowData *windata = ((win) ? (DFB_WindowData *) ((win)->driverdata) : NULL)
@@ -31,22 +34,28 @@
 typedef struct _DFB_WindowData DFB_WindowData;
 struct _DFB_WindowData
 {
-    IDirectFBSurface *surface;
-    IDirectFBSurface *window_surface;   /* only used with has_own_wm */
-    IDirectFBWindow *window;
-    IDirectFBEventBuffer *eventbuffer;
-    SDL_Window *sdl_window;
-    DFB_WindowData *next;
-    Uint8 opacity;
-    DFBRectangle client;
-    DFBDimension size;
+    IDirectFBSurface 		*window_surface;	/* window surface */
+    IDirectFBSurface 		*surface;			/* client drawing surface */
+    IDirectFBWindow 		*dfbwin;
+    IDirectFBEventBuffer 	*eventbuffer;
+    //SDL_Window 				*sdlwin;
+    SDL_Window	 			*next;
+    Uint8 					opacity;
+    DFBRectangle 			client;
+    DFBDimension 			size;
+    DFBRectangle 			restore;
+
     /* WM extras */
-    DFBRectangle restore;
-    int is_managed;
-    int wm_needs_redraw;
-    IDirectFBSurface *icon;
-    IDirectFBFont *font;
-    DFB_Theme theme;
+    int 					is_managed;
+    int 					wm_needs_redraw;
+    IDirectFBSurface 		*icon;
+    IDirectFBFont 			*font;
+    DFB_Theme 				theme;
+
+    /* WM moving and sizing */
+    int 					wm_grab;
+    int 					wm_lastx;
+    int 					wm_lasty;
 };
 
 extern int DirectFB_CreateWindow(_THIS, SDL_Window * window);
@@ -69,7 +78,7 @@
 extern SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
                                          struct SDL_SysWMinfo *info);
 
-//extern void DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window);
+extern void DirectFB_AdjustWindowSurface(SDL_Window * window);
 
 #endif /* _SDL_directfb_window_h */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/dummy/SDL_nullframebuffer.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,90 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "../SDL_sysvideo.h"
+
+
+#define DUMMY_SURFACE   "_SDL_DummySurface"
+
+int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
+{
+    SDL_Surface *surface;
+    const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
+    int w, h;
+    int bpp;
+    Uint32 Rmask, Gmask, Bmask, Amask;
+
+    /* Free the old framebuffer surface */
+    surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE);
+    if (surface) {
+        SDL_FreeSurface(surface);
+    }
+
+    /* Create a new one */
+    SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
+    SDL_GetWindowSize(window, &w, &h);
+    surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
+    if (!surface) {
+        return -1;
+    }
+
+    /* Save the info and return! */
+    SDL_SetWindowData(window, DUMMY_SURFACE, surface);
+    *format = surface_format;
+    *pixels = surface->pixels;
+    *pitch = surface->pitch;
+    return 0;
+}
+
+int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window * window, int numrects, SDL_Rect * rects)
+{
+    static int frame_number;
+    SDL_Surface *surface;
+
+    surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE);
+    if (!surface) {
+        SDL_SetError("Couldn't find dummy surface for window");
+        return -1;
+    }
+
+    /* Send the data to the display */
+    if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
+        char file[128];
+        SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
+                     SDL_GetWindowID(window), ++frame_number);
+        SDL_SaveBMP(surface, file);
+    }
+    return 0;
+}
+
+void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
+{
+    SDL_Surface *surface;
+
+    surface = (SDL_Surface *) SDL_SetWindowData(window, DUMMY_SURFACE, NULL);
+    if (surface) {
+        SDL_FreeSurface(surface);
+    }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/dummy/SDL_nullframebuffer_c.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,28 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+extern int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
+extern int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window * window, int numrects, SDL_Rect * rects);
+extern void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/dummy/SDL_nullrender.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,344 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_video.h"
-#include "../SDL_sysvideo.h"
-#include "../SDL_yuv_sw_c.h"
-#include "../SDL_renderer_sw.h"
-
-
-/* SDL surface based renderer implementation */
-
-static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window,
-                                              Uint32 flags);
-static int SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer,
-                                      const SDL_Point * points, int count);
-static int SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer,
-                                     const SDL_Point * points, int count);
-static int SDL_DUMMY_RenderDrawRects(SDL_Renderer * renderer,
-                                     const SDL_Rect ** rects, int count);
-static int SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer,
-                                     const SDL_Rect ** rects, int count);
-static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer,
-                                SDL_Texture * texture,
-                                const SDL_Rect * srcrect,
-                                const SDL_Rect * dstrect);
-static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer,
-                                      const SDL_Rect * rect,
-                                      Uint32 format,
-                                      void * pixels, int pitch);
-static int SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer,
-                                       const SDL_Rect * rect,
-                                       Uint32 format,
-                                       const void * pixels, int pitch);
-static void SDL_DUMMY_RenderPresent(SDL_Renderer * renderer);
-static void SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver SDL_DUMMY_RenderDriver = {
-    SDL_DUMMY_CreateRenderer,
-    {
-     "dummy",
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
-      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
-      SDL_RENDERER_PRESENTDISCARD),
-     }
-};
-
-typedef struct
-{
-    int current_screen;
-    SDL_Surface *screens[3];
-} SDL_DUMMY_RenderData;
-
-SDL_Renderer *
-SDL_DUMMY_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_VideoDisplay *display = window->display;
-    SDL_DisplayMode *displayMode = &display->current_mode;
-    SDL_Renderer *renderer;
-    SDL_DUMMY_RenderData *data;
-    int i, n;
-    int bpp;
-    Uint32 Rmask, Gmask, Bmask, Amask;
-
-    if (!SDL_PixelFormatEnumToMasks
-        (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-        SDL_SetError("Unknown display format");
-        return NULL;
-    }
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (SDL_DUMMY_RenderData *) SDL_malloc(sizeof(*data));
-    if (!data) {
-        SDL_DUMMY_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-    SDL_zerop(data);
-
-    renderer->RenderDrawPoints = SDL_DUMMY_RenderDrawPoints;
-    renderer->RenderDrawLines = SDL_DUMMY_RenderDrawLines;
-    renderer->RenderDrawRects = SDL_DUMMY_RenderDrawRects;
-    renderer->RenderFillRects = SDL_DUMMY_RenderFillRects;
-    renderer->RenderCopy = SDL_DUMMY_RenderCopy;
-    renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels;
-    renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels;
-    renderer->RenderPresent = SDL_DUMMY_RenderPresent;
-    renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer;
-    renderer->info.name = SDL_DUMMY_RenderDriver.info.name;
-    renderer->info.flags = 0;
-    renderer->window = window;
-    renderer->driverdata = data;
-    Setup_SoftwareRenderer(renderer);
-
-    if (flags & SDL_RENDERER_PRESENTFLIP2) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
-        n = 2;
-    } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
-        n = 3;
-    } else {
-        renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
-        n = 1;
-    }
-    for (i = 0; i < n; ++i) {
-        data->screens[i] =
-            SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
-                                 Bmask, Amask);
-        if (!data->screens[i]) {
-            SDL_DUMMY_DestroyRenderer(renderer);
-            return NULL;
-        }
-        SDL_SetSurfacePalette(data->screens[i], display->palette);
-    }
-    data->current_screen = 0;
-
-    return renderer;
-}
-
-static int
-SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer,
-                           const SDL_Point * points, int count)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Surface *target = data->screens[data->current_screen];
-
-    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
-        renderer->blendMode == SDL_BLENDMODE_MASK) {
-        Uint32 color = SDL_MapRGBA(target->format,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-
-        return SDL_DrawPoints(target, points, count, color);
-    } else {
-        return SDL_BlendPoints(target, points, count, renderer->blendMode,
-                               renderer->r, renderer->g, renderer->b,
-                               renderer->a);
-    }
-}
-
-static int
-SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer,
-                          const SDL_Point * points, int count)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Surface *target = data->screens[data->current_screen];
-
-    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
-        renderer->blendMode == SDL_BLENDMODE_MASK) {
-        Uint32 color = SDL_MapRGBA(target->format,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-
-        return SDL_DrawLines(target, points, count, color);
-    } else {
-        return SDL_BlendLines(target, points, count, renderer->blendMode,
-                              renderer->r, renderer->g, renderer->b,
-                              renderer->a);
-    }
-}
-
-static int
-SDL_DUMMY_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                          int count)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Surface *target = data->screens[data->current_screen];
-
-    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
-        renderer->blendMode == SDL_BLENDMODE_MASK) {
-        Uint32 color = SDL_MapRGBA(target->format,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-
-        return SDL_DrawRects(target, rects, count, color);
-    } else {
-        return SDL_BlendRects(target, rects, count,
-                              renderer->blendMode,
-                              renderer->r, renderer->g, renderer->b,
-                              renderer->a);
-    }
-}
-
-static int
-SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                          int count)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Surface *target = data->screens[data->current_screen];
-
-    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
-        renderer->blendMode == SDL_BLENDMODE_MASK) {
-        Uint32 color = SDL_MapRGBA(target->format,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-
-        return SDL_FillRects(target, rects, count, color);
-    } else {
-        return SDL_BlendFillRects(target, rects, count,
-                                  renderer->blendMode,
-                                  renderer->r, renderer->g, renderer->b,
-                                  renderer->a);
-    }
-}
-
-static int
-SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                     const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        SDL_Surface *target = data->screens[data->current_screen];
-        void *pixels =
-            (Uint8 *) target->pixels + dstrect->y * target->pitch +
-            dstrect->x * target->format->BytesPerPixel;
-        return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
-                                   srcrect, display->current_mode.format,
-                                   dstrect->w, dstrect->h, pixels,
-                                   target->pitch);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-        SDL_Surface *target = data->screens[data->current_screen];
-        SDL_Rect real_srcrect = *srcrect;
-        SDL_Rect real_dstrect = *dstrect;
-
-        return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
-    }
-}
-
-static int
-SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                           Uint32 format, void * pixels, int pitch)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    SDL_Surface *screen = data->screens[data->current_screen];
-    Uint32 screen_format = display->current_mode.format;
-    Uint8 *screen_pixels = (Uint8 *) screen->pixels +
-                            rect->y * screen->pitch +
-                            rect->x * screen->format->BytesPerPixel;
-    int screen_pitch = screen->pitch;
-
-    return SDL_ConvertPixels(rect->w, rect->h,
-                             screen_format, screen_pixels, screen_pitch,
-                             format, pixels, pitch);
-}
-
-static int
-SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                            Uint32 format, const void * pixels, int pitch)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    SDL_Surface *screen = data->screens[data->current_screen];
-    Uint32 screen_format = display->current_mode.format;
-    Uint8 *screen_pixels = (Uint8 *) screen->pixels +
-                            rect->y * screen->pitch +
-                            rect->x * screen->format->BytesPerPixel;
-    int screen_pitch = screen->pitch;
-
-    return SDL_ConvertPixels(rect->w, rect->h,
-                             format, pixels, pitch,
-                             screen_format, screen_pixels, screen_pitch);
-}
-
-static void
-SDL_DUMMY_RenderPresent(SDL_Renderer * renderer)
-{
-    static int frame_number;
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-
-    /* Send the data to the display */
-    if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
-        char file[128];
-        SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
-                     renderer->window->id, ++frame_number);
-        SDL_SaveBMP(data->screens[data->current_screen], file);
-    }
-
-    /* Update the flipping chain, if any */
-    if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
-        data->current_screen = (data->current_screen + 1) % 2;
-    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
-        data->current_screen = (data->current_screen + 1) % 3;
-    }
-}
-
-static void
-SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    int i;
-
-    if (data) {
-        for (i = 0; i < SDL_arraysize(data->screens); ++i) {
-            if (data->screens[i]) {
-                SDL_FreeSurface(data->screens[i]);
-            }
-        }
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/dummy/SDL_nullrender_c.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* SDL surface based renderer implementation */
-
-extern SDL_RenderDriver SDL_DUMMY_RenderDriver;
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/dummy/SDL_nullvideo.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/dummy/SDL_nullvideo.c	Sun Feb 06 21:23:32 2011 -0800
@@ -44,7 +44,7 @@
 
 #include "SDL_nullvideo.h"
 #include "SDL_nullevents_c.h"
-#include "SDL_nullrender_c.h"
+#include "SDL_nullframebuffer_c.h"
 
 #define DUMMYVID_DRIVER_NAME "dummy"
 
@@ -92,6 +92,9 @@
     device->VideoQuit = DUMMY_VideoQuit;
     device->SetDisplayMode = DUMMY_SetDisplayMode;
     device->PumpEvents = DUMMY_PumpEvents;
+    device->CreateWindowFramebuffer = SDL_DUMMY_CreateWindowFramebuffer;
+    device->UpdateWindowFramebuffer = SDL_DUMMY_UpdateWindowFramebuffer;
+    device->DestroyWindowFramebuffer = SDL_DUMMY_DestroyWindowFramebuffer;
 
     device->free = DUMMY_DeleteDevice;
 
@@ -118,7 +121,6 @@
     if (SDL_AddBasicVideoDisplay(&mode) < 0) {
         return -1;
     }
-    SDL_AddRenderDriver(&_this->displays[0], &SDL_DUMMY_RenderDriver);
 
     SDL_zero(mode);
     SDL_AddDisplayMode(&_this->displays[0], &mode);
--- a/src/video/mmx.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,642 +0,0 @@
-/*	mmx.h
-
-	MultiMedia eXtensions GCC interface library for IA32.
-
-	To use this library, simply include this header file
-	and compile with GCC.  You MUST have inlining enabled
-	in order for mmx_ok() to work; this can be done by
-	simply using -O on the GCC command line.
-
-	Compiling with -DMMX_TRACE will cause detailed trace
-	output to be sent to stderr for each mmx operation.
-	This adds lots of code, and obviously slows execution to
-	a crawl, but can be very useful for debugging.
-
-	THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
-	EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
-	LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY
-	AND FITNESS FOR ANY PARTICULAR PURPOSE.
-
-	1997-99 by H. Dietz and R. Fisher
-
- Notes:
-	It appears that the latest gas has the pand problem fixed, therefore
-	  I'll undefine BROKEN_PAND by default.
-*/
-
-#ifndef _MMX_H
-#define _MMX_H
-
-
-/*	Warning:  at this writing, the version of GAS packaged
-	with most Linux distributions does not handle the
-	parallel AND operation mnemonic correctly.  If the
-	symbol BROKEN_PAND is defined, a slower alternative
-	coding will be used.  If execution of mmxtest results
-	in an illegal instruction fault, define this symbol.
-*/
-#undef	BROKEN_PAND
-
-
-/*	The type of an value that fits in an MMX register
-	(note that long long constant values MUST be suffixed
-	 by LL and unsigned long long values by ULL, lest
-	 they be truncated by the compiler)
-*/
-typedef union
-{
-    long long q;                /* Quadword (64-bit) value */
-    unsigned long long uq;      /* Unsigned Quadword */
-    int d[2];                   /* 2 Doubleword (32-bit) values */
-    unsigned int ud[2];         /* 2 Unsigned Doubleword */
-    short w[4];                 /* 4 Word (16-bit) values */
-    unsigned short uw[4];       /* 4 Unsigned Word */
-    char b[8];                  /* 8 Byte (8-bit) values */
-    unsigned char ub[8];        /* 8 Unsigned Byte */
-    float s[2];                 /* Single-precision (32-bit) value */
-} __attribute__ ((aligned(8))) mmx_t;   /* On an 8-byte (64-bit) boundary */
-
-
-#if 0
-/*	Function to test if multimedia instructions are supported...
-*/
-inline extern int
-mm_support(void)
-{
-    /* Returns 1 if MMX instructions are supported,
-       3 if Cyrix MMX and Extended MMX instructions are supported
-       5 if AMD MMX and 3DNow! instructions are supported
-       0 if hardware does not support any of these
-     */
-    register int rval = 0;
-
-    __asm__ __volatile__(
-                            /* See if CPUID instruction is supported ... */
-                            /* ... Get copies of EFLAGS into eax and ecx */
-                            "pushf\n\t"
-                            "popl %%eax\n\t" "movl %%eax, %%ecx\n\t"
-                            /* ... Toggle the ID bit in one copy and store */
-                            /*     to the EFLAGS reg */
-                            "xorl $0x200000, %%eax\n\t"
-                            "push %%eax\n\t" "popf\n\t"
-                            /* ... Get the (hopefully modified) EFLAGS */
-                            "pushf\n\t" "popl %%eax\n\t"
-                            /* ... Compare and test result */
-                            "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* CPUID not supported */
-                            /* Get standard CPUID information, and
-                               go to a specific vendor section */
-                            "movl $0, %%eax\n\t" "cpuid\n\t"
-                            /* Check for Intel */
-                            "cmpl $0x756e6547, %%ebx\n\t"
-                            "jne TryAMD\n\t"
-                            "cmpl $0x49656e69, %%edx\n\t"
-                            "jne TryAMD\n\t"
-                            "cmpl $0x6c65746e, %%ecx\n"
-                            "jne TryAMD\n\t" "jmp Intel\n\t"
-                            /* Check for AMD */
-                            "\nTryAMD:\n\t"
-                            "cmpl $0x68747541, %%ebx\n\t"
-                            "jne TryCyrix\n\t"
-                            "cmpl $0x69746e65, %%edx\n\t"
-                            "jne TryCyrix\n\t"
-                            "cmpl $0x444d4163, %%ecx\n"
-                            "jne TryCyrix\n\t" "jmp AMD\n\t"
-                            /* Check for Cyrix */
-                            "\nTryCyrix:\n\t"
-                            "cmpl $0x69727943, %%ebx\n\t"
-                            "jne NotSupported2\n\t"
-                            "cmpl $0x736e4978, %%edx\n\t"
-                            "jne NotSupported3\n\t"
-                            "cmpl $0x64616574, %%ecx\n\t"
-                            "jne NotSupported4\n\t"
-                            /* Drop through to Cyrix... */
-                            /* Cyrix Section */
-                            /* See if extended CPUID level 80000001 is supported */
-                            /* The value of CPUID/80000001 for the 6x86MX is undefined
-                               according to the Cyrix CPU Detection Guide (Preliminary
-                               Rev. 1.01 table 1), so we'll check the value of eax for
-                               CPUID/0 to see if standard CPUID level 2 is supported.
-                               According to the table, the only CPU which supports level
-                               2 is also the only one which supports extended CPUID levels.
-                             */
-                            "cmpl $0x2, %%eax\n\t" "jne MMXtest\n\t"    /* Use standard CPUID instead */
-                            /* Extended CPUID supported (in theory), so get extended
-                               features */
-                            "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t"    /* Test for MMX */
-                            "jz NotSupported5\n\t"      /* MMX not supported */
-                            "testl $0x01000000, %%eax\n\t"      /* Test for Ext'd MMX */
-                            "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t"        /* MMX Supported */
-                            "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t"  /* EMMX and MMX Supported */
-                            "jmp Return\n\t"
-                            /* AMD Section */
-                            "AMD:\n\t"
-                            /* See if extended CPUID is supported */
-                            "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t"    /* Use standard CPUID instead */
-                            /* Extended CPUID supported, so get extended features */
-                            "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t"    /* Test for MMX */
-                            "jz NotSupported6\n\t"      /* MMX not supported */
-                            "testl $0x80000000, %%edx\n\t"      /* Test for 3DNow! */
-                            "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t"   /* MMX Supported */
-                            "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t"     /* 3DNow! and MMX Supported */
-                            "jmp Return\n\t"
-                            /* Intel Section */
-                            "Intel:\n\t"
-                            /* Check for MMX */
-                            "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t"      /* Test for MMX */
-                            "jz NotSupported7\n\t"      /* MMX Not supported */
-                            "movl $1, %0:\n\n\t"        /* MMX Supported */
-                            "jmp Return\n\t"
-                            /* Nothing supported */
-                            "\nNotSupported1:\n\t" "#movl $101, %0:\n\n\t" "\nNotSupported2:\n\t" "#movl $102, %0:\n\n\t" "\nNotSupported3:\n\t" "#movl $103, %0:\n\n\t" "\nNotSupported4:\n\t" "#movl $104, %0:\n\n\t" "\nNotSupported5:\n\t" "#movl $105, %0:\n\n\t" "\nNotSupported6:\n\t" "#movl $106, %0:\n\n\t" "\nNotSupported7:\n\t" "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a"(rval):     /* no input */
-                            :"eax", "ebx", "ecx", "edx");
-
-    /* Return */
-    return (rval);
-}
-
-/*	Function to test if mmx instructions are supported...
-*/
-inline extern int
-mmx_ok(void)
-{
-    /* Returns 1 if MMX instructions are supported, 0 otherwise */
-    return (mm_support() & 0x1);
-}
-#endif
-
-/*	Helper functions for the instruction macros that follow...
-	(note that memory-to-register, m2r, instructions are nearly
-	 as efficient as register-to-register, r2r, instructions;
-	 however, memory-to-memory instructions are really simulated
-	 as a convenience, and are only 1/3 as efficient)
-*/
-#ifdef	MMX_TRACE
-
-/*	Include the stuff for printing a trace to stderr...
-*/
-
-#define	mmx_i2r(op, imm, reg) \
-	{ \
-		mmx_t mmx_trace; \
-		mmx_trace.uq = (imm); \
-		printf(#op "_i2r(" #imm "=0x%08x%08x, ", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-		__asm__ __volatile__ ("movq %%" #reg ", %0" \
-				      : "=X" (mmx_trace) \
-				      : /* nothing */ ); \
-		printf(#reg "=0x%08x%08x) => ", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-		__asm__ __volatile__ (#op " %0, %%" #reg \
-				      : /* nothing */ \
-				      : "X" (imm)); \
-		__asm__ __volatile__ ("movq %%" #reg ", %0" \
-				      : "=X" (mmx_trace) \
-				      : /* nothing */ ); \
-		printf(#reg "=0x%08x%08x\n", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-	}
-
-#define	mmx_m2r(op, mem, reg) \
-	{ \
-		mmx_t mmx_trace; \
-		mmx_trace = (mem); \
-		printf(#op "_m2r(" #mem "=0x%08x%08x, ", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-		__asm__ __volatile__ ("movq %%" #reg ", %0" \
-				      : "=X" (mmx_trace) \
-				      : /* nothing */ ); \
-		printf(#reg "=0x%08x%08x) => ", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-		__asm__ __volatile__ (#op " %0, %%" #reg \
-				      : /* nothing */ \
-				      : "X" (mem)); \
-		__asm__ __volatile__ ("movq %%" #reg ", %0" \
-				      : "=X" (mmx_trace) \
-				      : /* nothing */ ); \
-		printf(#reg "=0x%08x%08x\n", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-	}
-
-#define	mmx_r2m(op, reg, mem) \
-	{ \
-		mmx_t mmx_trace; \
-		__asm__ __volatile__ ("movq %%" #reg ", %0" \
-				      : "=X" (mmx_trace) \
-				      : /* nothing */ ); \
-		printf(#op "_r2m(" #reg "=0x%08x%08x, ", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-		mmx_trace = (mem); \
-		printf(#mem "=0x%08x%08x) => ", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-		__asm__ __volatile__ (#op " %%" #reg ", %0" \
-				      : "=X" (mem) \
-				      : /* nothing */ ); \
-		mmx_trace = (mem); \
-		printf(#mem "=0x%08x%08x\n", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-	}
-
-#define	mmx_r2r(op, regs, regd) \
-	{ \
-		mmx_t mmx_trace; \
-		__asm__ __volatile__ ("movq %%" #regs ", %0" \
-				      : "=X" (mmx_trace) \
-				      : /* nothing */ ); \
-		printf(#op "_r2r(" #regs "=0x%08x%08x, ", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-		__asm__ __volatile__ ("movq %%" #regd ", %0" \
-				      : "=X" (mmx_trace) \
-				      : /* nothing */ ); \
-		printf(#regd "=0x%08x%08x) => ", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-		__asm__ __volatile__ (#op " %" #regs ", %" #regd); \
-		__asm__ __volatile__ ("movq %%" #regd ", %0" \
-				      : "=X" (mmx_trace) \
-				      : /* nothing */ ); \
-		printf(#regd "=0x%08x%08x\n", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-	}
-
-#define	mmx_m2m(op, mems, memd) \
-	{ \
-		mmx_t mmx_trace; \
-		mmx_trace = (mems); \
-		printf(#op "_m2m(" #mems "=0x%08x%08x, ", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-		mmx_trace = (memd); \
-		printf(#memd "=0x%08x%08x) => ", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-		__asm__ __volatile__ ("movq %0, %%mm0\n\t" \
-				      #op " %1, %%mm0\n\t" \
-				      "movq %%mm0, %0" \
-				      : "=X" (memd) \
-				      : "X" (mems)); \
-		mmx_trace = (memd); \
-		printf(#memd "=0x%08x%08x\n", \
-			mmx_trace.d[1], mmx_trace.d[0]); \
-	}
-
-#else
-
-/*	These macros are a lot simpler without the tracing...
-*/
-
-#define	mmx_i2r(op, imm, reg) \
-	__asm__ __volatile__ (#op " %0, %%" #reg \
-			      : /* nothing */ \
-			      : "X" (imm) )
-
-#define	mmx_m2r(op, mem, reg) \
-	__asm__ __volatile__ (#op " %0, %%" #reg \
-			      : /* nothing */ \
-			      : "m" (mem))
-
-#define	mmx_r2m(op, reg, mem) \
-	__asm__ __volatile__ (#op " %%" #reg ", %0" \
-			      : "=m" (mem) \
-			      : /* nothing */ )
-
-#define	mmx_r2r(op, regs, regd) \
-	__asm__ __volatile__ (#op " %" #regs ", %" #regd)
-
-#define	mmx_m2m(op, mems, memd) \
-	__asm__ __volatile__ ("movq %0, %%mm0\n\t" \
-			      #op " %1, %%mm0\n\t" \
-			      "movq %%mm0, %0" \
-			      : "=X" (memd) \
-			      : "X" (mems))
-
-#endif
-
-
-/*	1x64 MOVe Quadword
-	(this is both a load and a store...
-	 in fact, it is the only way to store)
-*/
-#define	movq_m2r(var, reg)	mmx_m2r(movq, var, reg)
-#define	movq_r2m(reg, var)	mmx_r2m(movq, reg, var)
-#define	movq_r2r(regs, regd)	mmx_r2r(movq, regs, regd)
-#define	movq(vars, vard) \
-	__asm__ __volatile__ ("movq %1, %%mm0\n\t" \
-			      "movq %%mm0, %0" \
-			      : "=X" (vard) \
-			      : "X" (vars))
-
-
-/*	1x32 MOVe Doubleword
-	(like movq, this is both load and store...
-	 but is most useful for moving things between
-	 mmx registers and ordinary registers)
-*/
-#define	movd_m2r(var, reg)	mmx_m2r(movd, var, reg)
-#define	movd_r2m(reg, var)	mmx_r2m(movd, reg, var)
-#define	movd_r2r(regs, regd)	mmx_r2r(movd, regs, regd)
-#define	movd(vars, vard) \
-	__asm__ __volatile__ ("movd %1, %%mm0\n\t" \
-			      "movd %%mm0, %0" \
-			      : "=X" (vard) \
-			      : "X" (vars))
-
-
-/*	2x32, 4x16, and 8x8 Parallel ADDs
-*/
-#define	paddd_m2r(var, reg)	mmx_m2r(paddd, var, reg)
-#define	paddd_r2r(regs, regd)	mmx_r2r(paddd, regs, regd)
-#define	paddd(vars, vard)	mmx_m2m(paddd, vars, vard)
-
-#define	paddw_m2r(var, reg)	mmx_m2r(paddw, var, reg)
-#define	paddw_r2r(regs, regd)	mmx_r2r(paddw, regs, regd)
-#define	paddw(vars, vard)	mmx_m2m(paddw, vars, vard)
-
-#define	paddb_m2r(var, reg)	mmx_m2r(paddb, var, reg)
-#define	paddb_r2r(regs, regd)	mmx_r2r(paddb, regs, regd)
-#define	paddb(vars, vard)	mmx_m2m(paddb, vars, vard)
-
-
-/*	4x16 and 8x8 Parallel ADDs using Saturation arithmetic
-*/
-#define	paddsw_m2r(var, reg)	mmx_m2r(paddsw, var, reg)
-#define	paddsw_r2r(regs, regd)	mmx_r2r(paddsw, regs, regd)
-#define	paddsw(vars, vard)	mmx_m2m(paddsw, vars, vard)
-
-#define	paddsb_m2r(var, reg)	mmx_m2r(paddsb, var, reg)
-#define	paddsb_r2r(regs, regd)	mmx_r2r(paddsb, regs, regd)
-#define	paddsb(vars, vard)	mmx_m2m(paddsb, vars, vard)
-
-
-/*	4x16 and 8x8 Parallel ADDs using Unsigned Saturation arithmetic
-*/
-#define	paddusw_m2r(var, reg)	mmx_m2r(paddusw, var, reg)
-#define	paddusw_r2r(regs, regd)	mmx_r2r(paddusw, regs, regd)
-#define	paddusw(vars, vard)	mmx_m2m(paddusw, vars, vard)
-
-#define	paddusb_m2r(var, reg)	mmx_m2r(paddusb, var, reg)
-#define	paddusb_r2r(regs, regd)	mmx_r2r(paddusb, regs, regd)
-#define	paddusb(vars, vard)	mmx_m2m(paddusb, vars, vard)
-
-
-/*	2x32, 4x16, and 8x8 Parallel SUBs
-*/
-#define	psubd_m2r(var, reg)	mmx_m2r(psubd, var, reg)
-#define	psubd_r2r(regs, regd)	mmx_r2r(psubd, regs, regd)
-#define	psubd(vars, vard)	mmx_m2m(psubd, vars, vard)
-
-#define	psubw_m2r(var, reg)	mmx_m2r(psubw, var, reg)
-#define	psubw_r2r(regs, regd)	mmx_r2r(psubw, regs, regd)
-#define	psubw(vars, vard)	mmx_m2m(psubw, vars, vard)
-
-#define	psubb_m2r(var, reg)	mmx_m2r(psubb, var, reg)
-#define	psubb_r2r(regs, regd)	mmx_r2r(psubb, regs, regd)
-#define	psubb(vars, vard)	mmx_m2m(psubb, vars, vard)
-
-
-/*	4x16 and 8x8 Parallel SUBs using Saturation arithmetic
-*/
-#define	psubsw_m2r(var, reg)	mmx_m2r(psubsw, var, reg)
-#define	psubsw_r2r(regs, regd)	mmx_r2r(psubsw, regs, regd)
-#define	psubsw(vars, vard)	mmx_m2m(psubsw, vars, vard)
-
-#define	psubsb_m2r(var, reg)	mmx_m2r(psubsb, var, reg)
-#define	psubsb_r2r(regs, regd)	mmx_r2r(psubsb, regs, regd)
-#define	psubsb(vars, vard)	mmx_m2m(psubsb, vars, vard)
-
-
-/*	4x16 and 8x8 Parallel SUBs using Unsigned Saturation arithmetic
-*/
-#define	psubusw_m2r(var, reg)	mmx_m2r(psubusw, var, reg)
-#define	psubusw_r2r(regs, regd)	mmx_r2r(psubusw, regs, regd)
-#define	psubusw(vars, vard)	mmx_m2m(psubusw, vars, vard)
-
-#define	psubusb_m2r(var, reg)	mmx_m2r(psubusb, var, reg)
-#define	psubusb_r2r(regs, regd)	mmx_r2r(psubusb, regs, regd)
-#define	psubusb(vars, vard)	mmx_m2m(psubusb, vars, vard)
-
-
-/*	4x16 Parallel MULs giving Low 4x16 portions of results
-*/
-#define	pmullw_m2r(var, reg)	mmx_m2r(pmullw, var, reg)
-#define	pmullw_r2r(regs, regd)	mmx_r2r(pmullw, regs, regd)
-#define	pmullw(vars, vard)	mmx_m2m(pmullw, vars, vard)
-
-
-/*	4x16 Parallel MULs giving High 4x16 portions of results
-*/
-#define	pmulhw_m2r(var, reg)	mmx_m2r(pmulhw, var, reg)
-#define	pmulhw_r2r(regs, regd)	mmx_r2r(pmulhw, regs, regd)
-#define	pmulhw(vars, vard)	mmx_m2m(pmulhw, vars, vard)
-
-
-/*	4x16->2x32 Parallel Mul-ADD
-	(muls like pmullw, then adds adjacent 16-bit fields
-	 in the multiply result to make the final 2x32 result)
-*/
-#define	pmaddwd_m2r(var, reg)	mmx_m2r(pmaddwd, var, reg)
-#define	pmaddwd_r2r(regs, regd)	mmx_r2r(pmaddwd, regs, regd)
-#define	pmaddwd(vars, vard)	mmx_m2m(pmaddwd, vars, vard)
-
-
-/*	1x64 bitwise AND
-*/
-#ifdef	BROKEN_PAND
-#define	pand_m2r(var, reg) \
-	{ \
-		mmx_m2r(pandn, (mmx_t) -1LL, reg); \
-		mmx_m2r(pandn, var, reg); \
-	}
-#define	pand_r2r(regs, regd) \
-	{ \
-		mmx_m2r(pandn, (mmx_t) -1LL, regd); \
-		mmx_r2r(pandn, regs, regd) \
-	}
-#define	pand(vars, vard) \
-	{ \
-		movq_m2r(vard, mm0); \
-		mmx_m2r(pandn, (mmx_t) -1LL, mm0); \
-		mmx_m2r(pandn, vars, mm0); \
-		movq_r2m(mm0, vard); \
-	}
-#else
-#define	pand_m2r(var, reg)	mmx_m2r(pand, var, reg)
-#define	pand_r2r(regs, regd)	mmx_r2r(pand, regs, regd)
-#define	pand(vars, vard)	mmx_m2m(pand, vars, vard)
-#endif
-
-
-/*	1x64 bitwise AND with Not the destination
-*/
-#define	pandn_m2r(var, reg)	mmx_m2r(pandn, var, reg)
-#define	pandn_r2r(regs, regd)	mmx_r2r(pandn, regs, regd)
-#define	pandn(vars, vard)	mmx_m2m(pandn, vars, vard)
-
-
-/*	1x64 bitwise OR
-*/
-#define	por_m2r(var, reg)	mmx_m2r(por, var, reg)
-#define	por_r2r(regs, regd)	mmx_r2r(por, regs, regd)
-#define	por(vars, vard)	mmx_m2m(por, vars, vard)
-
-
-/*	1x64 bitwise eXclusive OR
-*/
-#define	pxor_m2r(var, reg)	mmx_m2r(pxor, var, reg)
-#define	pxor_r2r(regs, regd)	mmx_r2r(pxor, regs, regd)
-#define	pxor(vars, vard)	mmx_m2m(pxor, vars, vard)
-
-
-/*	2x32, 4x16, and 8x8 Parallel CoMPare for EQuality
-	(resulting fields are either 0 or -1)
-*/
-#define	pcmpeqd_m2r(var, reg)	mmx_m2r(pcmpeqd, var, reg)
-#define	pcmpeqd_r2r(regs, regd)	mmx_r2r(pcmpeqd, regs, regd)
-#define	pcmpeqd(vars, vard)	mmx_m2m(pcmpeqd, vars, vard)
-
-#define	pcmpeqw_m2r(var, reg)	mmx_m2r(pcmpeqw, var, reg)
-#define	pcmpeqw_r2r(regs, regd)	mmx_r2r(pcmpeqw, regs, regd)
-#define	pcmpeqw(vars, vard)	mmx_m2m(pcmpeqw, vars, vard)
-
-#define	pcmpeqb_m2r(var, reg)	mmx_m2r(pcmpeqb, var, reg)
-#define	pcmpeqb_r2r(regs, regd)	mmx_r2r(pcmpeqb, regs, regd)
-#define	pcmpeqb(vars, vard)	mmx_m2m(pcmpeqb, vars, vard)
-
-
-/*	2x32, 4x16, and 8x8 Parallel CoMPare for Greater Than
-	(resulting fields are either 0 or -1)
-*/
-#define	pcmpgtd_m2r(var, reg)	mmx_m2r(pcmpgtd, var, reg)
-#define	pcmpgtd_r2r(regs, regd)	mmx_r2r(pcmpgtd, regs, regd)
-#define	pcmpgtd(vars, vard)	mmx_m2m(pcmpgtd, vars, vard)
-
-#define	pcmpgtw_m2r(var, reg)	mmx_m2r(pcmpgtw, var, reg)
-#define	pcmpgtw_r2r(regs, regd)	mmx_r2r(pcmpgtw, regs, regd)
-#define	pcmpgtw(vars, vard)	mmx_m2m(pcmpgtw, vars, vard)
-
-#define	pcmpgtb_m2r(var, reg)	mmx_m2r(pcmpgtb, var, reg)
-#define	pcmpgtb_r2r(regs, regd)	mmx_r2r(pcmpgtb, regs, regd)
-#define	pcmpgtb(vars, vard)	mmx_m2m(pcmpgtb, vars, vard)
-
-
-/*	1x64, 2x32, and 4x16 Parallel Shift Left Logical
-*/
-#define	psllq_i2r(imm, reg)	mmx_i2r(psllq, imm, reg)
-#define	psllq_m2r(var, reg)	mmx_m2r(psllq, var, reg)
-#define	psllq_r2r(regs, regd)	mmx_r2r(psllq, regs, regd)
-#define	psllq(vars, vard)	mmx_m2m(psllq, vars, vard)
-
-#define	pslld_i2r(imm, reg)	mmx_i2r(pslld, imm, reg)
-#define	pslld_m2r(var, reg)	mmx_m2r(pslld, var, reg)
-#define	pslld_r2r(regs, regd)	mmx_r2r(pslld, regs, regd)
-#define	pslld(vars, vard)	mmx_m2m(pslld, vars, vard)
-
-#define	psllw_i2r(imm, reg)	mmx_i2r(psllw, imm, reg)
-#define	psllw_m2r(var, reg)	mmx_m2r(psllw, var, reg)
-#define	psllw_r2r(regs, regd)	mmx_r2r(psllw, regs, regd)
-#define	psllw(vars, vard)	mmx_m2m(psllw, vars, vard)
-
-
-/*	1x64, 2x32, and 4x16 Parallel Shift Right Logical
-*/
-#define	psrlq_i2r(imm, reg)	mmx_i2r(psrlq, imm, reg)
-#define	psrlq_m2r(var, reg)	mmx_m2r(psrlq, var, reg)
-#define	psrlq_r2r(regs, regd)	mmx_r2r(psrlq, regs, regd)
-#define	psrlq(vars, vard)	mmx_m2m(psrlq, vars, vard)
-
-#define	psrld_i2r(imm, reg)	mmx_i2r(psrld, imm, reg)
-#define	psrld_m2r(var, reg)	mmx_m2r(psrld, var, reg)
-#define	psrld_r2r(regs, regd)	mmx_r2r(psrld, regs, regd)
-#define	psrld(vars, vard)	mmx_m2m(psrld, vars, vard)
-
-#define	psrlw_i2r(imm, reg)	mmx_i2r(psrlw, imm, reg)
-#define	psrlw_m2r(var, reg)	mmx_m2r(psrlw, var, reg)
-#define	psrlw_r2r(regs, regd)	mmx_r2r(psrlw, regs, regd)
-#define	psrlw(vars, vard)	mmx_m2m(psrlw, vars, vard)
-
-
-/*	2x32 and 4x16 Parallel Shift Right Arithmetic
-*/
-#define	psrad_i2r(imm, reg)	mmx_i2r(psrad, imm, reg)
-#define	psrad_m2r(var, reg)	mmx_m2r(psrad, var, reg)
-#define	psrad_r2r(regs, regd)	mmx_r2r(psrad, regs, regd)
-#define	psrad(vars, vard)	mmx_m2m(psrad, vars, vard)
-
-#define	psraw_i2r(imm, reg)	mmx_i2r(psraw, imm, reg)
-#define	psraw_m2r(var, reg)	mmx_m2r(psraw, var, reg)
-#define	psraw_r2r(regs, regd)	mmx_r2r(psraw, regs, regd)
-#define	psraw(vars, vard)	mmx_m2m(psraw, vars, vard)
-
-
-/*	2x32->4x16 and 4x16->8x8 PACK and Signed Saturate
-	(packs source and dest fields into dest in that order)
-*/
-#define	packssdw_m2r(var, reg)	mmx_m2r(packssdw, var, reg)
-#define	packssdw_r2r(regs, regd) mmx_r2r(packssdw, regs, regd)
-#define	packssdw(vars, vard)	mmx_m2m(packssdw, vars, vard)
-
-#define	packsswb_m2r(var, reg)	mmx_m2r(packsswb, var, reg)
-#define	packsswb_r2r(regs, regd) mmx_r2r(packsswb, regs, regd)
-#define	packsswb(vars, vard)	mmx_m2m(packsswb, vars, vard)
-
-
-/*	4x16->8x8 PACK and Unsigned Saturate
-	(packs source and dest fields into dest in that order)
-*/
-#define	packuswb_m2r(var, reg)	mmx_m2r(packuswb, var, reg)
-#define	packuswb_r2r(regs, regd) mmx_r2r(packuswb, regs, regd)
-#define	packuswb(vars, vard)	mmx_m2m(packuswb, vars, vard)
-
-
-/*	2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK Low
-	(interleaves low half of dest with low half of source
-	 as padding in each result field)
-*/
-#define	punpckldq_m2r(var, reg)	mmx_m2r(punpckldq, var, reg)
-#define	punpckldq_r2r(regs, regd) mmx_r2r(punpckldq, regs, regd)
-#define	punpckldq(vars, vard)	mmx_m2m(punpckldq, vars, vard)
-
-#define	punpcklwd_m2r(var, reg)	mmx_m2r(punpcklwd, var, reg)
-#define	punpcklwd_r2r(regs, regd) mmx_r2r(punpcklwd, regs, regd)
-#define	punpcklwd(vars, vard)	mmx_m2m(punpcklwd, vars, vard)
-
-#define	punpcklbw_m2r(var, reg)	mmx_m2r(punpcklbw, var, reg)
-#define	punpcklbw_r2r(regs, regd) mmx_r2r(punpcklbw, regs, regd)
-#define	punpcklbw(vars, vard)	mmx_m2m(punpcklbw, vars, vard)
-
-
-/*	2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK High
-	(interleaves high half of dest with high half of source
-	 as padding in each result field)
-*/
-#define	punpckhdq_m2r(var, reg)	mmx_m2r(punpckhdq, var, reg)
-#define	punpckhdq_r2r(regs, regd) mmx_r2r(punpckhdq, regs, regd)
-#define	punpckhdq(vars, vard)	mmx_m2m(punpckhdq, vars, vard)
-
-#define	punpckhwd_m2r(var, reg)	mmx_m2r(punpckhwd, var, reg)
-#define	punpckhwd_r2r(regs, regd) mmx_r2r(punpckhwd, regs, regd)
-#define	punpckhwd(vars, vard)	mmx_m2m(punpckhwd, vars, vard)
-
-#define	punpckhbw_m2r(var, reg)	mmx_m2r(punpckhbw, var, reg)
-#define	punpckhbw_r2r(regs, regd) mmx_r2r(punpckhbw, regs, regd)
-#define	punpckhbw(vars, vard)	mmx_m2m(punpckhbw, vars, vard)
-
-
-/*	Empty MMx State
-	(used to clean-up when going from mmx to float use
-	 of the registers that are shared by both; note that
-	 there is no float-to-mmx operation needed, because
-	 only the float tag word info is corruptible)
-*/
-#ifdef	MMX_TRACE
-
-#define	emms() \
-	{ \
-		printf("emms()\n"); \
-		__asm__ __volatile__ ("emms"); \
-	}
-
-#else
-
-#define	emms()			__asm__ __volatile__ ("emms")
-
-#endif
-
-#endif
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/nds/SDL_ndsrender.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/nds/SDL_ndsrender.c	Sun Feb 06 21:23:32 2011 -0800
@@ -43,21 +43,6 @@
 static int NDS_QueryTexturePixels(SDL_Renderer * renderer,
                                   SDL_Texture * texture, void **pixels,
                                   int *pitch);
-static int NDS_SetTexturePalette(SDL_Renderer * renderer,
-                                 SDL_Texture * texture,
-                                 const SDL_Color * colors, int firstcolor,
-                                 int ncolors);
-static int NDS_GetTexturePalette(SDL_Renderer * renderer,
-                                 SDL_Texture * texture, SDL_Color * colors,
-                                 int firstcolor, int ncolors);
-static int NDS_SetTextureColorMod(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int NDS_SetTextureAlphaMod(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int NDS_SetTextureBlendMode(SDL_Renderer * renderer,
-                                   SDL_Texture * texture);
-static int NDS_SetTextureScaleMode(SDL_Renderer * renderer,
-                                   SDL_Texture * texture);
 static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                              const SDL_Rect * rect, const void *pixels,
                              int pitch);
@@ -79,13 +64,9 @@
 SDL_RenderDriver NDS_RenderDriver = {
     NDS_CreateRenderer,
     {"nds",                     /* char* name */
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC),  /* u32 flags */
-     (SDL_TEXTUREMODULATE_NONE),        /* u32 mod_modes */
-     (SDL_BLENDMODE_MASK),      /* u32 blend_modes */
-     (SDL_SCALEMODE_FAST),       /* u32 scale_modes */
-     3,                         /* u32 num_texture_formats */
+     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),  /* u32 flags */
+     2,                         /* u32 num_texture_formats */
      {
-      SDL_PIXELFORMAT_INDEX8,
       SDL_PIXELFORMAT_ABGR1555,
       SDL_PIXELFORMAT_BGR555,
       },                        /* u32 texture_formats[20] */
@@ -140,7 +121,6 @@
         return NULL;
     }
     switch (displayMode->format) {
-    case SDL_PIXELFORMAT_INDEX8:
     case SDL_PIXELFORMAT_ABGR1555:
     case SDL_PIXELFORMAT_BGR555:
         /* okay */
@@ -179,20 +159,11 @@
     renderer->driverdata = data;
     renderer->CreateTexture = NDS_CreateTexture;
     renderer->QueryTexturePixels = NDS_QueryTexturePixels;
-    renderer->SetTexturePalette = NDS_SetTexturePalette;
-    renderer->GetTexturePalette = NDS_GetTexturePalette;
-    renderer->SetTextureColorMod = NDS_SetTextureColorMod;
-    renderer->SetTextureAlphaMod = NDS_SetTextureAlphaMod;
-    renderer->SetTextureBlendMode = NDS_SetTextureBlendMode;
-    renderer->SetTextureScaleMode = NDS_SetTextureScaleMode;
     renderer->UpdateTexture = NDS_UpdateTexture;
     renderer->LockTexture = NDS_LockTexture;
     renderer->UnlockTexture = NDS_UnlockTexture;
     renderer->DestroyTexture = NDS_DestroyTexture;
 
-    renderer->info.mod_modes = NDS_RenderDriver.info.mod_modes;
-    renderer->info.blend_modes = NDS_RenderDriver.info.blend_modes;
-    renderer->info.scale_modes = NDS_RenderDriver.info.scale_modes;
     renderer->info.num_texture_formats =
         NDS_RenderDriver.info.num_texture_formats;
     SDL_memcpy(renderer->info.texture_formats,
@@ -547,52 +518,4 @@
     SDL_free(renderer);
 }
 
-static int
-NDS_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                      const SDL_Color * colors, int firstcolor, int ncolors)
-{
-    NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
-    /* set 8-bit modes in the background control registers
-       for backgrounds, BGn_CR |= BG_256_COLOR */
-
-    return 0;
-}
-
-static int
-NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                      SDL_Color * colors, int firstcolor, int ncolors)
-{
-    NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
-    /* stub! */
-    return 0;
-}
-
-static int
-NDS_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    /* stub! */
-    return 0;
-}
-
-static int
-NDS_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    /* stub! */
-    return 0;
-}
-
-static int
-NDS_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    /* stub! */
-    return 0;
-}
-
-static int
-NDS_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    /* stub! (note: NDS hardware scaling is nearest neighbor.) */
-    return 0;
-}
-
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/pandora/SDL_pandora.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/pandora/SDL_pandora.h	Sun Feb 06 21:23:32 2011 -0800
@@ -70,8 +70,6 @@
 void PND_videoquit(_THIS);
 void PND_getdisplaymodes(_THIS, SDL_VideoDisplay * display);
 int PND_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
-int PND_setdisplaypalette(_THIS, SDL_Palette * palette);
-int PND_getdisplaypalette(_THIS, SDL_Palette * palette);
 int PND_setdisplaygammaramp(_THIS, Uint16 * ramp);
 int PND_getdisplaygammaramp(_THIS, Uint16 * ramp);
 int PND_createwindow(_THIS, SDL_Window * window);
--- a/src/video/photon/SDL_photon.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2852 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Photon GUI SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-/* SDL internals */
-#include "SDL_config.h"
-#include "../SDL_sysvideo.h"
-#include "SDL_version.h"
-#include "SDL_syswm.h"
-#include "SDL_loadso.h"
-#include "SDL_events.h"
-#include "../../events/SDL_mouse_c.h"
-#include "../../events/SDL_keyboard_c.h"
-
-/* Photon declarations */
-#include "SDL_photon.h"
-
-/* Pixel format conversion routines */
-#include "SDL_photon_pixelfmt.h"
-
-/* Use GF's pixel format functions for OpenGL ES context creation */
-#if defined(SDL_VIDEO_OPENGL_ES)
-#include "../qnxgf/SDL_gf_pixelfmt.h"
-
-/* If GF driver is not compiled in, include some of usefull functions */
-#if !defined(SDL_VIDEO_DRIVER_QNXGF)
-#include "../qnxgf/SDL_gf_pixelfmt.c"
-#endif /* SDL_VIDEO_DRIVER_QNXGF */
-#endif /* SDL_VIDEO_OPENGL_ES */
-
-/* Use GF's OpenGL ES 1.1 functions emulation */
-#if defined(SDL_VIDEO_OPENGL_ES)
-#include "../qnxgf/SDL_gf_opengles.h"
-
-/* If GF driver is not compiled in, include some of usefull functions */
-#if !defined(SDL_VIDEO_DRIVER_QNXGF)
-#include "../qnxgf/SDL_gf_opengles.c"
-#endif /* SDL_VIDEO_DRIVER_QNXGF */
-#endif /* SDL_VIDEO_OPENGL_ES */
-
-/* Low level device graphics driver names, which they are reporting */
-static const Photon_DeviceCaps photon_devicename[] = {
-    /* ATI Rage 128 graphics driver (devg-ati_rage128)      */
-    {"ati_rage128", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* Fujitsu Carmine graphics driver (devg-carmine.so)    */
-    {"carmine", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
-    ,
-    /* C&T graphics driver (devg-chips.so)                  */
-    {"chips", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* Fujitsu Coral graphics driver (devg-coral.so)        */
-    {"coral", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
-    ,
-    /* Intel integrated graphics driver (devg-extreme2.so)  */
-    {"extreme2", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
-    ,
-    /* Unaccelerated FB driver (devg-flat.so)               */
-    {"flat", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* NS Geode graphics driver (devg-geode.so)             */
-    {"geode", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* Geode LX graphics driver (devg-geodelx.so)           */
-    {"geodelx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* Intel integrated graphics driver (devg-gma9xx.so)    */
-    {"gma", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
-    ,
-    /* Intel integrated graphics driver (devg-i810.so)      */
-    {"i810", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* Intel integrated graphics driver (devg-i830.so)      */
-    {"i830", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* Geode LX graphics driver (devg-lx800.so)             */
-    {"lx800", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* Matrox Gxx graphics driver (devg-matroxg.so)         */
-    {"matroxg", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* Intel Poulsbo graphics driver (devg-poulsbo.so)      */
-    {"poulsbo", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
-    ,
-    /* ATI Radeon driver (devg-radeon.so)                   */
-    {"radeon", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* ATI Rage driver (devg-rage.so)                       */
-    {"rage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* S3 Savage graphics driver (devg-s3_savage.so)        */
-    {"s3_savage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* SiS630 integrated graphics driver (devg-sis630.so)   */
-    {"sis630", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* PowerVR SGX 535 graphics driver (devg-poulsbo.so)    */
-    {"sgx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
-    ,
-    /* SM Voyager GX graphics driver (devg-smi5xx.so)       */
-    {"smi5xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* Silicon Motion graphics driver (devg-smi7xx.so)      */
-    {"smi7xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* SVGA unaccelerated gfx driver (devg-svga.so)         */
-    {"svga", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* nVidia TNT graphics driver (devg-tnt.so)             */
-    {"tnt", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* VIA integrated graphics driver (devg-tvia.so)        */
-    {"tvia", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* VIA UniChrome graphics driver (devg-unichrome.so)    */
-    {"unichrome", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* VESA unaccelerated gfx driver (devg-vesabios.so)     */
-    {"vesa", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* VmWare graphics driver (devg-volari.so)              */
-    {"vmware", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* XGI XP10 graphics driver (devg-volari.so), OpenGL 1.5 */
-    {"volari", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
-    ,
-    /* End of list */
-    {NULL, 0x00000000}
-};
-
-static SDL_bool photon_initialized = SDL_FALSE;
-
-static int
-photon_available(void)
-{
-    int32_t status;
-
-    /* Check if Photon was initialized before */
-    if (photon_initialized == SDL_FALSE) {
-        /* Initialize Photon widget library and open channel to Photon */
-        status = PtInit(NULL);
-        if (status == 0) {
-            photon_initialized = SDL_TRUE;
-            return 1;
-        } else {
-            photon_initialized = SDL_FALSE;
-            return 0;
-        }
-    }
-
-    return 1;
-}
-
-static void
-photon_destroy(SDL_VideoDevice * device)
-{
-    SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata;
-
-#if defined(SDL_VIDEO_OPENGL_ES)
-    if (phdata->gfinitialized != SDL_FALSE) {
-        gf_dev_detach(phdata->gfdev);
-    }
-#endif /* SDL_VIDEO_OPENGL_ES */
-
-    if (device->driverdata != NULL) {
-        device->driverdata = NULL;
-    }
-}
-
-static SDL_VideoDevice *
-photon_create(int devindex)
-{
-    SDL_VideoDevice *device;
-    SDL_VideoData *phdata;
-    int32_t status;
-
-    /* Check if photon could be initialized */
-    status = photon_available();
-    if (status == 0) {
-        /* Photon could not be used */
-        return NULL;
-    }
-
-    /* Photon agregates all video devices to one with multiple heads */
-    if (devindex != 0) {
-        /* devindex could be zero only in Photon SDL driver */
-        return NULL;
-    }
-
-    /* Initialize SDL_VideoDevice structure */
-    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
-    if (device == NULL) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    /* Initialize internal photon specific data */
-    phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
-    if (phdata == NULL) {
-        SDL_OutOfMemory();
-        SDL_free(device);
-        return NULL;
-    }
-    device->driverdata = phdata;
-
-    /* Get all photon display devices */
-    phdata->avail_rids =
-        PdGetDevices(&phdata->rid[0], SDL_VIDEO_PHOTON_MAX_RIDS);
-    if (phdata->avail_rids > SDL_VIDEO_PHOTON_MAX_RIDS) {
-        phdata->avail_rids = SDL_VIDEO_PHOTON_MAX_RIDS;
-    }
-#if defined(SDL_VIDEO_OPENGL_ES)
-    /* TODO: add real device detection versus multiple heads */
-    status =
-        gf_dev_attach(&phdata->gfdev, GF_DEVICE_INDEX(0),
-                      &phdata->gfdev_info);
-    if (status != GF_ERR_OK) {
-        /* Do not fail right now, if GF can't be attached */
-        phdata->gfinitialized = SDL_FALSE;
-    } else {
-        phdata->gfinitialized = SDL_TRUE;
-    }
-#endif /* SDL_VIDEO_OPENGL_ES */
-
-    /* Set default target device */
-    status = PdSetTargetDevice(NULL, phdata->rid[0]);
-    if (status == -1) {
-        SDL_SetError("Photon: Can't set default target device");
-#if defined(SDL_VIDEO_OPENGL_ES)
-        gf_dev_detach(phdata->gfdev);
-#endif /* SDL_VIDEO_OPENGL_ES */
-        SDL_free(phdata);
-        SDL_free(device);
-        return NULL;
-    }
-    phdata->current_device_id = 0;
-
-    /* Setup amount of available displays and current display */
-    device->num_displays = 0;
-    device->current_display = 0;
-
-    /* Set device free function */
-    device->free = photon_destroy;
-
-    /* Setup all functions which we can handle */
-    device->VideoInit = photon_videoinit;
-    device->VideoQuit = photon_videoquit;
-    device->GetDisplayModes = photon_getdisplaymodes;
-    device->SetDisplayMode = photon_setdisplaymode;
-    device->CreateWindow = photon_createwindow;
-    device->CreateWindowFrom = photon_createwindowfrom;
-    device->SetWindowTitle = photon_setwindowtitle;
-    device->SetWindowIcon = photon_setwindowicon;
-    device->SetWindowPosition = photon_setwindowposition;
-    device->SetWindowSize = photon_setwindowsize;
-    device->ShowWindow = photon_showwindow;
-    device->HideWindow = photon_hidewindow;
-    device->RaiseWindow = photon_raisewindow;
-    device->MaximizeWindow = photon_maximizewindow;
-    device->MinimizeWindow = photon_minimizewindow;
-    device->RestoreWindow = photon_restorewindow;
-    device->SetWindowGrab = photon_setwindowgrab;
-    device->DestroyWindow = photon_destroywindow;
-    device->GetWindowWMInfo = photon_getwindowwminfo;
-    device->GL_LoadLibrary = photon_gl_loadlibrary;
-    device->GL_GetProcAddress = photon_gl_getprocaddres;
-    device->GL_UnloadLibrary = photon_gl_unloadlibrary;
-    device->GL_CreateContext = photon_gl_createcontext;
-    device->GL_MakeCurrent = photon_gl_makecurrent;
-    device->GL_SetSwapInterval = photon_gl_setswapinterval;
-    device->GL_GetSwapInterval = photon_gl_getswapinterval;
-    device->GL_SwapWindow = photon_gl_swapwindow;
-    device->GL_DeleteContext = photon_gl_deletecontext;
-    device->PumpEvents = photon_pumpevents;
-    device->SuspendScreenSaver = photon_suspendscreensaver;
-
-    return device;
-}
-
-VideoBootStrap photon_bootstrap = {
-    "photon",
-    "SDL QNX Photon video driver",
-    photon_available,
-    photon_create
-};
-
-/*****************************************************************************/
-/* SDL Video and Display initialization/handling functions                   */
-/*****************************************************************************/
-int
-photon_videoinit(_THIS)
-{
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    PgHWCaps_t hwcaps;
-    PgVideoModeInfo_t modeinfo;
-    int32_t status;
-    SDL_VideoDisplay display;
-    SDL_DisplayMode current_mode;
-    SDL_DisplayData *didata;
-    uint32_t it;
-    uint32_t jt;
-    char *override;
-
-    /* By default Photon do not uses swap on VSYNC */
-#if defined(SDL_VIDEO_OPENGL_ES)
-    phdata->swapinterval = 0;
-#endif /* SDL_VIDEO_OPENGL_ES */
-
-    for (it = 0; it < phdata->avail_rids; it++) {
-        didata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
-        if (didata == NULL) {
-            /* memory allocation error */
-            SDL_OutOfMemory();
-            return -1;
-        }
-
-        /* Allocate two cursors with SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE size */
-        /* and 128 bytes of spare place                                    */
-        didata->cursor_size =
-            ((SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE * 4) >> 3) + 128;
-        didata->cursor = (PhCursorDef_t *) SDL_calloc(1, didata->cursor_size);
-        if (didata->cursor == NULL) {
-            /* memory allocation error */
-            SDL_OutOfMemory();
-            SDL_free(didata);
-            return -1;
-        }
-
-        /* Initialize GF in case of OpenGL ES support is compiled in */
-#if defined(SDL_VIDEO_OPENGL_ES)
-        /* TODO: add real device detection versus multiple heads */
-        if (phdata->gfinitialized == SDL_TRUE) {
-            status =
-                gf_display_attach(&didata->display, phdata->gfdev, it,
-                                  &didata->display_info);
-            if (status != GF_ERR_OK) {
-                /* Just shutdown GF, do not fail */
-                gf_dev_detach(phdata->gfdev);
-                phdata->gfinitialized = SDL_FALSE;
-            }
-        }
-#endif /* SDL_VIDEO_OPENGL_ES */
-
-        /* Check if current device is not the same as target */
-        if (phdata->current_device_id != it) {
-            /* Set target device as default for Pd and Pg functions */
-            status = PdSetTargetDevice(NULL, phdata->rid[it]);
-            if (status != 0) {
-                SDL_SetError("Photon: Can't set default target device\n");
-                SDL_free(didata->cursor);
-                SDL_free(didata);
-                return -1;
-            }
-            phdata->current_device_id = it;
-        }
-
-        /* Store device id */
-        didata->device_id = it;
-
-        /* Query photon about graphics hardware caps and current video mode */
-        SDL_memset(&hwcaps, 0x00, sizeof(PgHWCaps_t));
-        status = PgGetGraphicsHWCaps(&hwcaps);
-        if (status != 0) {
-            PhRect_t extent;
-            PdOffscreenContext_t* curctx;
-
-            /* If error happens, this also could mean, that photon is working */
-            /* under custom (not listed by photon) video mode                 */
-            status=PhWindowQueryVisible(Ph_QUERY_GRAPHICS, 0, 0, &extent);
-            if (status != 0) {
-                SDL_SetError("Photon: Can't get graphics driver region");
-                SDL_free(didata->cursor);
-                SDL_free(didata);
-                return -1;
-            }
-            modeinfo.width=extent.lr.x+1;
-            modeinfo.height=extent.lr.y+1;
-            /* Hardcode 60Hz, as the base refresh rate frequency */
-            hwcaps.current_rrate=60;
-            /* Clear current video driver name, no way to get it somehow */
-            hwcaps.chip_name[0]=0x00;
-
-            /* Create offscreen context from video memory, which is currently */
-            /* displayed on the screen                                        */
-            curctx=PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
-            if (curctx==NULL)
-            {
-                SDL_SetError("Photon: Can't get display area capabilities");
-                SDL_free(didata->cursor);
-                SDL_free(didata);
-                return -1;
-            }
-            /* Retrieve current bpp */
-            modeinfo.type=curctx->format;
-            PhDCRelease(curctx);
-        } else {
-            /* Get current video mode details */
-            status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo);
-            if (status != 0) {
-                SDL_SetError("Photon: Can't get current video mode information");
-                SDL_free(didata->cursor);
-                SDL_free(didata);
-                return -1;
-            }
-
-            /* Get current video mode 2D capabilities for the renderer */
-            didata->mode_2dcaps=0;
-            if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND)
-            {
-               didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND;
-            }
-            if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT)
-            {
-               didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_SCALED_BLIT;
-            }
-        }
-
-        /* Setup current desktop mode for SDL */
-        SDL_zero(current_mode);
-        current_mode.w = modeinfo.width;
-        current_mode.h = modeinfo.height;
-        current_mode.refresh_rate = hwcaps.current_rrate;
-        current_mode.format = photon_image_to_sdl_pixelformat(modeinfo.type);
-        current_mode.driverdata = NULL;
-
-        /* Copy device name */
-        SDL_strlcpy(didata->description, hwcaps.chip_name,
-                    SDL_VIDEO_PHOTON_DEVICENAME_MAX - 1);
-
-        /* Search device capabilities and possible workarounds */
-        jt = 0;
-        do {
-            if (photon_devicename[jt].name == NULL) {
-                break;
-            }
-            if (SDL_strncmp
-                (photon_devicename[jt].name, didata->description,
-                 SDL_strlen(photon_devicename[jt].name)) == 0) {
-                didata->caps = photon_devicename[jt].caps;
-            }
-            jt++;
-        } while (1);
-
-        /* Initialize display structure */
-        SDL_zero(display);
-        display.desktop_mode = current_mode;
-        display.current_mode = current_mode;
-        display.fullscreen_mode = current_mode;
-        display.driverdata = didata;
-        didata->current_mode = current_mode;
-        SDL_AddVideoDisplay(&display);
-
-        /* Check for environment variables which could override some SDL settings */
-        didata->custom_refresh = 0;
-        override = SDL_getenv("SDL_VIDEO_PHOTON_REFRESH_RATE");
-        if (override != NULL) {
-            if (SDL_sscanf(override, "%u", &didata->custom_refresh) != 1) {
-                didata->custom_refresh = 0;
-            }
-        }
-    }
-
-    /* Add photon input devices */
-    status = photon_addinputdevices(_this);
-    if (status != 0) {
-        /* SDL error is set by photon_addinputdevices() function */
-        return -1;
-    }
-
-    /* Add photon renderer to SDL */
-    photon_addrenderdriver(_this);
-
-    /* video has been initialized successfully */
-    return 1;
-}
-
-void
-photon_videoquit(_THIS)
-{
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *didata;
-    uint32_t it;
-
-    /* SDL will restore our desktop mode on exit */
-    for (it = 0; it < _this->num_displays; it++) {
-        didata = _this->displays[it].driverdata;
-
-        if (didata->cursor != NULL) {
-            SDL_free(didata->cursor);
-        }
-#if defined(SDL_VIDEO_OPENGL_ES)
-        if (phdata->gfinitialized == SDL_TRUE) {
-            /* Detach GF display */
-            gf_display_detach(didata->display);
-        }
-#endif /* SDL_VIDEO_OPENGL_ES */
-    }
-}
-
-void
-photon_getdisplaymodes(_THIS, SDL_VideoDisplay * display)
-{
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-    SDL_DisplayMode mode;
-    PgVideoModes_t modes;
-    PgVideoModeInfo_t modeinfo;
-    int32_t status;
-    uint32_t it;
-    uint32_t jt;
-
-    /* Check if current device is not the same as target */
-    if (phdata->current_device_id != didata->device_id) {
-        /* Set target device as default for Pd and Pg functions */
-        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
-        if (status != 0) {
-            SDL_SetError("Photon: Can't set default target device\n");
-            return;
-        }
-        phdata->current_device_id = didata->device_id;
-    }
-
-    /* Get array of available video modes */
-    status = PgGetVideoModeList(&modes);
-    if (status != 0) {
-        SDL_SetError("Photon: Can't get video mode list");
-        return;
-    }
-
-    for (it = 0; it < modes.num_modes; it++) {
-        status = PgGetVideoModeInfo(modes.modes[it], &modeinfo);
-        if (status != 0) {
-            /* Maybe something wrong with this particular mode, skip it */
-            continue;
-        }
-
-        jt = 0;
-        do {
-            if (modeinfo.refresh_rates[jt] != 0) {
-                mode.w = modeinfo.width;
-                mode.h = modeinfo.height;
-                mode.refresh_rate = modeinfo.refresh_rates[jt];
-                mode.format = photon_image_to_sdl_pixelformat(modeinfo.type);
-                mode.driverdata = NULL;
-                SDL_AddDisplayMode(display, &mode);
-
-                /* If mode is RGBA8888, add the same mode as RGBx888 */
-                if (modeinfo.type == Pg_IMAGE_DIRECT_8888) {
-                    mode.w = modeinfo.width;
-                    mode.h = modeinfo.height;
-                    mode.refresh_rate = modeinfo.refresh_rates[jt];
-                    mode.format = SDL_PIXELFORMAT_RGB888;
-                    mode.driverdata = NULL;
-                    SDL_AddDisplayMode(display, &mode);
-                }
-
-                /* If mode is RGBA1555, add the same mode as RGBx555 */
-                if (modeinfo.type == Pg_IMAGE_DIRECT_1555) {
-                    mode.w = modeinfo.width;
-                    mode.h = modeinfo.height;
-                    mode.refresh_rate = modeinfo.refresh_rates[jt];
-                    mode.format = SDL_PIXELFORMAT_RGB555;
-                    mode.driverdata = NULL;
-                    SDL_AddDisplayMode(display, &mode);
-                }
-
-                jt++;
-            } else {
-                break;
-            }
-        } while (1);
-    }
-}
-
-int
-photon_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
-{
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-    PgVideoModes_t modes;
-    PgVideoModeInfo_t modeinfo;
-    PgDisplaySettings_t modesettings;
-    uint32_t refresh_rate = 0;
-    int32_t status;
-    uint32_t it;
-
-    /* Check if current device is not the same as target */
-    if (phdata->current_device_id != didata->device_id) {
-        /* Set target device as default for Pd and Pg functions */
-        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
-        if (status != 0) {
-            SDL_SetError("Photon: Can't set default target device\n");
-            return -1;
-        }
-        phdata->current_device_id = didata->device_id;
-    }
-
-    /* Get array of available video modes */
-    status = PgGetVideoModeList(&modes);
-    if (status != 0) {
-        SDL_SetError("Photon: Can't get video mode list");
-        return -1;
-    }
-
-    /* Current display dimension and bpp are no more valid */
-    didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN;
-    didata->current_mode.w = 0;
-    didata->current_mode.h = 0;
-
-    /* Check if custom refresh rate requested */
-    if (didata->custom_refresh != 0) {
-        refresh_rate = didata->custom_refresh;
-    } else {
-        refresh_rate = mode->refresh_rate;
-    }
-
-    /* Check if SDL GF driver needs to find appropriate refresh rate itself */
-    if (refresh_rate == 0) {
-        SDL_DisplayMode tempmode;
-
-        /* Clear display mode structure */
-        SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode));
-        tempmode.refresh_rate = 0x0000FFFF;
-
-        /* Check if window width and height matches one of our modes */
-        for (it = 0; it < display->num_display_modes; it++) {
-            if ((display->display_modes[it].w == mode->w) &&
-                (display->display_modes[it].h == mode->h) &&
-                (display->display_modes[it].format == mode->format))
-            {
-                /* Find the lowest refresh rate available */
-                if (tempmode.refresh_rate >
-                    display->display_modes[it].refresh_rate) {
-                    tempmode = display->display_modes[it];
-                }
-            }
-        }
-        if (tempmode.refresh_rate != 0x0000FFFF) {
-            refresh_rate = tempmode.refresh_rate;
-        } else {
-            /* Let video driver decide what to do with this */
-            refresh_rate = 0;
-        }
-    }
-
-    /* Check if SDL GF driver needs to check custom refresh rate */
-    if (didata->custom_refresh != 0) {
-        SDL_DisplayMode tempmode;
-
-        /* Clear display mode structure */
-        SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode));
-        tempmode.refresh_rate = 0x0000FFFF;
-
-        /* Check if window width and height matches one of our modes */
-        for (it = 0; it < display->num_display_modes; it++) {
-            if ((display->display_modes[it].w == mode->w) &&
-                (display->display_modes[it].h == mode->h) &&
-                (display->display_modes[it].format == mode->format))
-            {
-                /* Find the lowest refresh rate available */
-                if (tempmode.refresh_rate >
-                    display->display_modes[it].refresh_rate) {
-                    tempmode = display->display_modes[it];
-                }
-
-                /* Check if requested refresh rate found */
-                if (refresh_rate ==
-                    display->display_modes[it].refresh_rate) {
-                    tempmode = display->display_modes[it];
-                    break;
-                }
-            }
-        }
-        if (tempmode.refresh_rate != 0x0000FFFF) {
-            refresh_rate = tempmode.refresh_rate;
-        } else {
-            /* Let video driver decide what to do with this */
-            refresh_rate = 0;
-        }
-    }
-
-    /* Find photon's video mode number */
-    for (it = 0; it < modes.num_modes; it++) {
-        uint32_t jt;
-        uint32_t foundrefresh;
-
-        /* Get current video mode details */
-        status = PgGetVideoModeInfo(modes.modes[it], &modeinfo);
-        if (status != 0) {
-            /* Maybe something wrong with this particular mode, skip it */
-            continue;
-        }
-        if ((modeinfo.width == mode->w) && (modeinfo.height == mode->h) &&
-            (modeinfo.type == photon_sdl_to_image_pixelformat(mode->format)))
-        {
-            /* Mode is found, find requested refresh rate, this case is for */
-            /* video drivers, which provide non-generic video modes.        */
-            jt = 0;
-            foundrefresh = 0;
-            do {
-                if (modeinfo.refresh_rates[jt] != 0) {
-                    if (modeinfo.refresh_rates[jt] == refresh_rate) {
-                        foundrefresh = 1;
-                        break;
-                    }
-                    jt++;
-                } else {
-                    break;
-                }
-            } while (1);
-            if (foundrefresh != 0) {
-                break;
-            }
-        }
-    }
-
-    /* Check if video mode has not been found */
-    if (it == modes.num_modes) {
-        SDL_SetError("Photon: Can't find appropriate video mode");
-        return -1;
-    }
-
-    /* Fill mode settings */
-    modesettings.flags = 0x00000000;
-    modesettings.mode = modes.modes[it];
-    modesettings.refresh = refresh_rate;
-
-    /* Finally set new video mode */
-    status = PgSetVideoMode(&modesettings);
-    if (status != 0) {
-        SDL_SetError("Photon: Can't set new video mode");
-        return -1;
-    }
-
-    /* Store new video mode parameters */
-    didata->current_mode = *mode;
-    didata->current_mode.refresh_rate = refresh_rate;
-
-    /* Get current video mode 2D capabilities for the renderer */
-    didata->mode_2dcaps=0;
-    if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND)
-    {
-       didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND;
-    }
-    if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT)
-    {
-       didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_SCALED_BLIT;
-    }
-
-    return 0;
-}
-
-int
-photon_createwindow(_THIS, SDL_Window * window)
-{
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) window->display->driverdata;
-    SDL_WindowData *wdata;
-    PhDim_t winsize;
-    PhPoint_t winpos;
-    PtArg_t winargs[32];
-    uint32_t winargc = 0;
-    int32_t status;
-    PhRegion_t wregion;
-
-    /* Allocate window internal data */
-    wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
-    if (wdata == NULL) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    /* Setup driver data for this window */
-    window->driverdata = wdata;
-
-    /* Set initial window title */
-    if (window->title != NULL) {
-        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, window->title, 0);
-    } else {
-        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, "SDL unnamed application", 0);
-    }
-
-    /* TODO: handle SDL_WINDOW_INPUT_GRABBED */
-
-    /* Disable default window filling on redraw */
-    PtSetArg(&winargs[winargc++], Pt_ARG_BASIC_FLAGS, Pt_TRUE,
-             Pt_BASIC_PREVENT_FILL);
-
-    /* Reset default managed flags to disabled state */
-    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE,
-             Ph_WM_APP_DEF_MANAGED);
-    /* Set which events we will not handle, let WM to handle them */
-    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE,
-             Ph_WM_BACKDROP | Ph_WM_TOFRONT | Ph_WM_COLLAPSE | Ph_WM_FFRONT |
-             Ph_WM_FOCUS | Ph_WM_HELP | Ph_WM_HIDE | Ph_WM_MAX |
-             Ph_WM_MENU | Ph_WM_MOVE | Ph_WM_RESTORE | Ph_WM_TASKBAR |
-             Ph_WM_TOBACK | Ph_WM_RESIZE);
-
-    /* Reset default notify events to disable */
-    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE,
-             Ph_WM_RESIZE | Ph_WM_CLOSE | Ph_WM_HELP);
-    /* Set which events we will handle */
-    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE,
-             Ph_WM_CLOSE | Ph_WM_COLLAPSE | Ph_WM_FOCUS | Ph_WM_MAX |
-             Ph_WM_MOVE | Ph_WM_RESIZE | Ph_WM_RESTORE | Ph_WM_HIDE);
-
-    /* Borderless window can't be resizeable */
-    if ((window->flags & SDL_WINDOW_BORDERLESS) == SDL_WINDOW_BORDERLESS) {
-        window->flags &= ~(SDL_WINDOW_RESIZABLE);
-    }
-
-    /* Reset all default decorations */
-    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE,
-             Ph_WM_APP_DEF_RENDER);
-
-    /* Fullscreen window has its own decorations */
-    if ((window->flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN) {
-        window->flags |= SDL_WINDOW_BORDERLESS;
-        window->flags &= ~(SDL_WINDOW_RESIZABLE);
-        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE,
-                 Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_TITLE);
-    } else {
-        uint32_t decorations =
-            Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN |
-            Ph_WM_RENDER_TITLE | Ph_WM_RENDER_MOVE;
-
-        if ((window->flags & SDL_WINDOW_RESIZABLE) == SDL_WINDOW_RESIZABLE) {
-            decorations |=
-                Ph_WM_RENDER_BORDER | Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX;
-            PtSetArg(&winargs[winargc++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE,
-                     Pt_RESIZE_XY_AS_REQUIRED);
-        }
-        if ((window->flags & SDL_WINDOW_BORDERLESS) != SDL_WINDOW_BORDERLESS) {
-            decorations |= Ph_WM_RENDER_BORDER;
-        }
-        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE,
-                 decorations);
-    }
-
-    /* Set initial window state */
-    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_FALSE,
-             Ph_WM_STATE_ISFOCUS);
-    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_TRUE,
-             Ph_WM_STATE_ISALTKEY);
-
-    /* Special case, do not handle maximize events, if window can't be resized */
-    if ((window->flags & SDL_WINDOW_RESIZABLE) != SDL_WINDOW_RESIZABLE)
-    {
-       PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE,
-                Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE);
-    }
-
-    /* Set window dimension */
-    winsize.w = window->w;
-    winsize.h = window->h;
-    PtSetArg(&winargs[winargc++], Pt_ARG_DIM, &winsize, 0);
-
-    /* Check if upper level requests WM to position window */
-    if ((window->x == SDL_WINDOWPOS_UNDEFINED)
-        && (window->y == SDL_WINDOWPOS_UNDEFINED)) {
-        /* Do not set widget position, let WM to set it */
-    } else {
-        if (window->x == SDL_WINDOWPOS_UNDEFINED) {
-            window->x = 0;
-        }
-        if (window->y == SDL_WINDOWPOS_UNDEFINED) {
-            window->y = 0;
-        }
-        if (window->x == SDL_WINDOWPOS_CENTERED) {
-            window->x = (didata->current_mode.w - window->w) / 2;
-        }
-        if (window->y == SDL_WINDOWPOS_CENTERED) {
-            window->y = (didata->current_mode.h - window->h) / 2;
-        }
-
-        /* Now set window position */
-        winpos.x = window->x;
-        winpos.y = window->y;
-        PtSetArg(&winargs[winargc++], Pt_ARG_POS, &winpos, 0);
-    }
-
-    /* Check if window must support OpenGL ES rendering */
-    if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) {
-#if defined(SDL_VIDEO_OPENGL_ES)
-        EGLBoolean initstatus;
-
-        /* Check if GF was initialized correctly */
-        if (phdata->gfinitialized == SDL_FALSE) {
-            SDL_SetError
-                ("Photon: GF initialization failed, no OpenGL ES support");
-            return -1;
-        }
-
-        /* Mark this window as OpenGL ES compatible */
-        wdata->uses_gles = SDL_TRUE;
-
-        /* Create connection to OpenGL ES */
-        if (phdata->egldisplay == EGL_NO_DISPLAY) {
-            phdata->egldisplay = eglGetDisplay(phdata->gfdev);
-            if (phdata->egldisplay == EGL_NO_DISPLAY) {
-                SDL_SetError("Photon: Can't get connection to OpenGL ES");
-                return -1;
-            }
-
-            /* Initialize OpenGL ES library, ignore EGL version */
-            initstatus = eglInitialize(phdata->egldisplay, NULL, NULL);
-            if (initstatus != EGL_TRUE) {
-                SDL_SetError("Photon: Can't init OpenGL ES library");
-                return -1;
-            }
-        }
-
-        /* Increment GL ES reference count usage */
-        phdata->egl_refcount++;
-#else
-        SDL_SetError("Photon: OpenGL ES support is not compiled in");
-        return -1;
-#endif /* SDL_VIDEO_OPENGL_ES */
-    }
-
-    /* Finally create the window */
-    wdata->window = PtCreateWidget(PtWindow, Pt_NO_PARENT, winargc, winargs);
-    if (wdata->window == NULL) {
-        SDL_SetError("Photon: Can't create window widget");
-        SDL_free(wdata);
-        return -1;
-    }
-
-    /* Show widget */
-    status = PtRealizeWidget(wdata->window);
-    if (status != 0) {
-        SDL_SetError("Photon: Can't realize window widget");
-        PtDestroyWidget(wdata->window);
-        SDL_free(wdata);
-        return;
-    }
-
-    /* Just created SDL window always gets focus */
-    window->flags |= SDL_WINDOW_INPUT_FOCUS;
-
-    /* Create window-specific cursor after creation */
-    if (didata->cursor_visible == SDL_TRUE) {
-        /* Setup cursor type. shape and default color */
-        PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR,
-                      Ph_CURSOR_DEFAULT_COLOR, 0);
-        PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0);
-        PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR, didata->cursor,
-                      didata->cursor->hdr.len + sizeof(PhRegionDataHdr_t));
-    } else {
-        PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0);
-    }
-
-    /* Set window region sensible to mouse motion events */
-    status =
-        PhRegionQuery(PtWidgetRid(wdata->window), &wregion, NULL, NULL, 0);
-    if (status != 0) {
-        SDL_SetError
-            ("Photon: Can't set region sensivity to mouse motion events");
-        PtDestroyWidget(wdata->window);
-        SDL_free(wdata);
-        return -1;
-    }
-    wregion.events_sense |=
-        Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON;
-    status = PhRegionChange(Ph_REGION_EV_SENSE, 0, &wregion, NULL, NULL);
-    if (status < 0) {
-        SDL_SetError("Photon: Can't change region sensivity");
-        PtDestroyWidget(wdata->window);
-        SDL_free(wdata);
-        return -1;
-    }
-
-    /* Flush all widget operations again */
-    PtFlush();
-
-    /* By default last created window got a input focus */
-    SDL_SetKeyboardFocus(0, window);
-
-    /* Emit focus gained event, because photon is not sending it */
-    SDL_OnWindowFocusGained(window);
-
-    /* Window has been successfully created */
-    return 0;
-}
-
-int
-photon_createwindowfrom(_THIS, SDL_Window * window, const void *data)
-{
-    /* TODO: it is possible */
-
-    /* Failed to create window from another window */
-    return -1;
-}
-
-void
-photon_setwindowtitle(_THIS, SDL_Window * window)
-{
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    int32_t status;
-
-    /* Set window title */
-    if (window->title != NULL) {
-        status =
-            PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, window->title,
-                          0);
-    } else {
-        status = PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, "", 0);
-    }
-
-    if (status != 0) {
-        SDL_SetError("Photon: Can't set window title");
-    }
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-void
-photon_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon)
-{
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    int32_t status;
-
-    /* TODO: Use iconify ? */
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-void
-photon_setwindowposition(_THIS, SDL_Window * window)
-{
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) window->display->driverdata;
-    PhPoint_t winpos;
-    int32_t status;
-
-    /* Check if upper level requests WM to position window */
-    if ((window->x == SDL_WINDOWPOS_UNDEFINED)
-        && (window->y == SDL_WINDOWPOS_UNDEFINED)) {
-        /* Do not set widget position, let WM to set it */
-    } else {
-        if (window->x == SDL_WINDOWPOS_UNDEFINED) {
-            window->x = 0;
-        }
-        if (window->y == SDL_WINDOWPOS_UNDEFINED) {
-            window->y = 0;
-        }
-        if (window->x == SDL_WINDOWPOS_CENTERED) {
-            window->x = (didata->current_mode.w - window->w) / 2;
-        }
-        if (window->y == SDL_WINDOWPOS_CENTERED) {
-            window->y = (didata->current_mode.h - window->h) / 2;
-        }
-
-        /* Now set window position */
-        winpos.x = window->x;
-        winpos.y = window->y;
-        status = PtSetResource(wdata->window, Pt_ARG_POS, &winpos, 0);
-        if (status != 0) {
-            SDL_SetError("Photon: Can't set window position");
-        }
-    }
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-void
-photon_setwindowsize(_THIS, SDL_Window * window)
-{
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    PhDim_t winsize;
-    int32_t status;
-
-    winsize.w = window->w;
-    winsize.h = window->h;
-
-    status = PtSetResource(wdata->window, Pt_ARG_DIM, &winsize, 0);
-    if (status != 0) {
-        SDL_SetError("Photon: Can't set window size");
-    }
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-void
-photon_showwindow(_THIS, SDL_Window * window)
-{
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    int32_t status;
-
-    /* Bring focus to window and put it in front of others */
-    PtWindowToFront(wdata->window);
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-void
-photon_hidewindow(_THIS, SDL_Window * window)
-{
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    PhWindowEvent_t winevent;
-    int32_t status;
-
-    SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t));
-    winevent.event_f = Ph_WM_HIDE;
-    winevent.rid = PtWidgetRid(wdata->window);
-    winevent.event_state = Ph_WM_EVSTATE_HIDE;
-
-    status = PtForwardWindowEvent(&winevent);
-    if (status != 0) {
-        SDL_SetError("Photon: Can't hide window");
-    }
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-void
-photon_raisewindow(_THIS, SDL_Window * window)
-{
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    PhWindowEvent_t winevent;
-    int32_t status;
-
-    SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t));
-    winevent.event_f = Ph_WM_HIDE;
-    winevent.rid = PtWidgetRid(wdata->window);
-    winevent.event_state = Ph_WM_EVSTATE_UNHIDE;
-
-    status = PtForwardWindowEvent(&winevent);
-    if (status != 0) {
-        SDL_SetError("Photon: Can't hide window");
-    }
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-void
-photon_maximizewindow(_THIS, SDL_Window * window)
-{
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    PhWindowEvent_t winevent;
-    int32_t status;
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-void
-photon_minimizewindow(_THIS, SDL_Window * window)
-{
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    PhWindowEvent_t winevent;
-    int32_t status;
-
-    SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t));
-    winevent.event_f = Ph_WM_HIDE;
-    winevent.rid = PtWidgetRid(wdata->window);
-    winevent.event_state = Ph_WM_EVSTATE_HIDE;
-
-    status = PtForwardWindowEvent(&winevent);
-    if (status != 0) {
-        SDL_SetError("Photon: Can't hide window");
-    }
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-void
-photon_restorewindow(_THIS, SDL_Window * window)
-{
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    PhWindowEvent_t winevent;
-    int32_t status;
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-void
-photon_setwindowgrab(_THIS, SDL_Window * window)
-{
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    PhWindowEvent_t winevent;
-    int32_t status;
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-void
-photon_destroywindow(_THIS, SDL_Window * window)
-{
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) window->display->driverdata;
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    int32_t status;
-
-    if (wdata != NULL) {
-        status = PtDestroyWidget(wdata->window);
-        if (status != 0) {
-            SDL_SetError("Photon: Can't destroy window widget");
-        }
-        wdata->window = NULL;
-
-#if defined(SDL_VIDEO_OPENGL_ES)
-        if (phdata->gfinitialized == SDL_TRUE) {
-            /* Destroy photon handle to GF surface */
-            if (wdata->phsurface != NULL) {
-                PhDCRelease(wdata->phsurface);
-                wdata->phsurface=NULL;
-            }
-
-            /* Destroy OpenGL ES surface if it was created */
-            if (wdata->gles_surface != EGL_NO_SURFACE) {
-                eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
-            }
-
-            /* Free OpenGL ES target surface */
-            if (wdata->gfsurface != NULL) {
-                gf_surface_free(wdata->gfsurface);
-                wdata->gfsurface=NULL;
-            }
-
-            phdata->egl_refcount--;
-            if (phdata->egl_refcount == 0) {
-                /* Terminate connection to OpenGL ES */
-                if (phdata->egldisplay != EGL_NO_DISPLAY) {
-                    eglTerminate(phdata->egldisplay);
-                    phdata->egldisplay = EGL_NO_DISPLAY;
-                }
-            }
-        }
-#endif /* SDL_VIDEO_OPENGL_ES */
-    }
-
-    /* Flush all widget operations */
-    PtFlush();
-}
-
-/*****************************************************************************/
-/* SDL Window Manager function                                               */
-/*****************************************************************************/
-SDL_bool
-photon_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
-{
-    if (info->version.major <= SDL_MAJOR_VERSION) {
-        return SDL_TRUE;
-    } else {
-        SDL_SetError("application not compiled with SDL %d.%d\n",
-                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
-        return SDL_FALSE;
-    }
-
-    /* Failed to get window manager information */
-    return SDL_FALSE;
-}
-
-/*****************************************************************************/
-/* SDL OpenGL/OpenGL ES functions                                            */
-/*****************************************************************************/
-int
-photon_gl_loadlibrary(_THIS, const char *path)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-
-    if (phdata->gfinitialized != SDL_TRUE) {
-        SDL_SetError
-            ("Photon: GF initialization failed, no OpenGL ES support");
-        return -1;
-    }
-
-    /* Check if OpenGL ES library is specified for GF driver */
-    if (path == NULL) {
-        path = SDL_getenv("SDL_OPENGL_LIBRARY");
-        if (path == NULL) {
-            path = SDL_getenv("SDL_OPENGLES_LIBRARY");
-        }
-    }
-
-    /* Check if default library loading requested */
-    if (path == NULL) {
-        /* Already linked with GF library which provides egl* subset of  */
-        /* functions, use Common profile of OpenGL ES library by default */
-        path = "/usr/lib/libGLES_CM.so.1";
-    }
-
-    /* Load dynamic library */
-    _this->gl_config.dll_handle = SDL_LoadObject(path);
-    if (!_this->gl_config.dll_handle) {
-        /* Failed to load new GL ES library */
-        SDL_SetError("Photon: Failed to locate OpenGL ES library");
-        return -1;
-    }
-
-    /* Store OpenGL ES library path and name */
-    SDL_strlcpy(_this->gl_config.driver_path, path,
-                SDL_arraysize(_this->gl_config.driver_path));
-
-    /* New OpenGL ES library is loaded */
-    return 0;
-#else
-    SDL_SetError("Photon: OpenGL ES support is not compiled in");
-    return -1;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-void *
-photon_gl_getprocaddres(_THIS, const char *proc)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    void *function_address;
-
-    if (phdata->gfinitialized != SDL_TRUE) {
-        SDL_SetError
-            ("Photon: GF initialization failed, no OpenGL ES support");
-        return NULL;
-    }
-
-    /* Try to get function address through the egl interface */
-    function_address = eglGetProcAddress(proc);
-    if (function_address != NULL) {
-        return function_address;
-    }
-
-    /* Then try to get function in the OpenGL ES library */
-    if (_this->gl_config.dll_handle) {
-        function_address =
-            SDL_LoadFunction(_this->gl_config.dll_handle, proc);
-        if (function_address != NULL) {
-            return function_address;
-        }
-    }
-
-    /* Add emulated OpenGL ES 1.1 functions */
-    if (SDL_strcmp(proc, "glTexParameteri") == 0) {
-        return glTexParameteri;
-    }
-    if (SDL_strcmp(proc, "glTexParameteriv") == 0) {
-        return glTexParameteriv;
-    }
-    if (SDL_strcmp(proc, "glColor4ub") == 0) {
-        return glColor4ub;
-    }
-
-    /* Failed to get GL ES function address pointer */
-    SDL_SetError("Photon: Cannot locate OpenGL ES function name");
-    return NULL;
-#else
-    SDL_SetError("Photon: OpenGL ES support is not compiled in");
-    return NULL;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-void
-photon_gl_unloadlibrary(_THIS)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-
-    if (phdata->gfinitialized == SDL_TRUE) {
-        /* Unload OpenGL ES library */
-        if (_this->gl_config.dll_handle) {
-            SDL_UnloadObject(_this->gl_config.dll_handle);
-            _this->gl_config.dll_handle = NULL;
-        }
-    } else {
-        SDL_SetError
-            ("Photon: GF initialization failed, no OpenGL ES support");
-    }
-#else
-    SDL_SetError("Photon: OpenGL ES support is not compiled in");
-    return;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-SDL_GLContext
-photon_gl_createcontext(_THIS, SDL_Window * window)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) window->display->driverdata;
-    EGLBoolean status;
-    int32_t gfstatus;
-    EGLint configs;
-    uint32_t attr_pos;
-    EGLint attr_value;
-    EGLint cit;
-
-    /* Check if GF was initialized */
-    if (phdata->gfinitialized != SDL_TRUE) {
-        SDL_SetError
-            ("Photon: GF initialization failed, no OpenGL ES support");
-        return NULL;
-    }
-
-    /* Prepare attributes list to pass them to OpenGL ES egl interface */
-    attr_pos = 0;
-    wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID;
-    wdata->gles_attributes[attr_pos++] =
-        qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format);
-    wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE;
-    wdata->gles_attributes[attr_pos++] = _this->gl_config.red_size;
-    wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE;
-    wdata->gles_attributes[attr_pos++] = _this->gl_config.green_size;
-    wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE;
-    wdata->gles_attributes[attr_pos++] = _this->gl_config.blue_size;
-    wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE;
-
-    /* Setup alpha size in bits */
-    if (_this->gl_config.alpha_size) {
-        wdata->gles_attributes[attr_pos++] = _this->gl_config.alpha_size;
-    } else {
-        wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-    }
-
-    /* Setup color buffer size */
-    if (_this->gl_config.buffer_size) {
-        wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE;
-        wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size;
-    } else {
-        wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE;
-        wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-    }
-
-    /* Setup depth buffer bits */
-    wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
-    if (_this->gl_config.depth_size)
-    {
-        wdata->gles_attributes[attr_pos++] = _this->gl_config.depth_size;
-    }
-    else
-    {
-        wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-    }
-
-    /* Setup stencil bits */
-    if (_this->gl_config.stencil_size) {
-        wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
-        wdata->gles_attributes[attr_pos++] = _this->gl_config.stencil_size;
-    } else {
-        wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
-        wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-    }
-
-    /* Set number of samples in multisampling */
-    if (_this->gl_config.multisamplesamples) {
-        wdata->gles_attributes[attr_pos++] = EGL_SAMPLES;
-        wdata->gles_attributes[attr_pos++] =
-            _this->gl_config.multisamplesamples;
-    }
-
-    /* Multisample buffers, OpenGL ES 1.0 spec defines 0 or 1 buffer */
-    if (_this->gl_config.multisamplebuffers) {
-        wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS;
-        wdata->gles_attributes[attr_pos++] =
-            _this->gl_config.multisamplebuffers;
-    }
-
-    /* Finish attributes list */
-    wdata->gles_attributes[attr_pos] = EGL_NONE;
-
-    /* Request first suitable framebuffer configuration */
-    status = eglChooseConfig(phdata->egldisplay, wdata->gles_attributes,
-                             wdata->gles_configs, SDL_VIDEO_GF_OPENGLES_CONFS,
-                             &configs);
-    if (status != EGL_TRUE) {
-        SDL_SetError
-            ("Photon: Can't find closest configuration for OpenGL ES");
-        return NULL;
-    }
-
-    /* Check if nothing has been found, try "don't care" settings */
-    if (configs == 0) {
-        int32_t it;
-        int32_t jt;
-        static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE };
-
-        for (it = 0; it < 4; it++) {
-            for (jt = 16; jt >= 0; jt--) {
-                /* Don't care about color buffer bits, use what exist */
-                /* Replace previous set data with EGL_DONT_CARE       */
-                attr_pos = 0;
-                wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID;
-                wdata->gles_attributes[attr_pos++] =
-                    qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format);
-                wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-
-                /* Try to find requested or smallest depth */
-                if (_this->gl_config.depth_size) {
-                    wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
-                    wdata->gles_attributes[attr_pos++] = depthbits[it];
-                } else {
-                    wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
-                    wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                }
-
-                if (_this->gl_config.stencil_size) {
-                    wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
-                    wdata->gles_attributes[attr_pos++] = jt;
-                } else {
-                    wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
-                    wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                }
-
-                wdata->gles_attributes[attr_pos++] = EGL_SAMPLES;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos] = EGL_NONE;
-
-                /* Request first suitable framebuffer configuration */
-                status =
-                    eglChooseConfig(phdata->egldisplay,
-                                    wdata->gles_attributes,
-                                    wdata->gles_configs,
-                                    SDL_VIDEO_GF_OPENGLES_CONFS, &configs);
-                if (status != EGL_TRUE) {
-                    SDL_SetError
-                        ("Photon: Can't find closest configuration for OpenGL ES");
-                    return NULL;
-                }
-                if (configs != 0) {
-                    break;
-                }
-            }
-            if (configs != 0) {
-                break;
-            }
-        }
-
-        /* No available configs */
-        if (configs == 0) {
-            SDL_SetError
-                ("Photon: Can't find any configuration for OpenGL ES");
-            return NULL;
-        }
-    }
-
-    /* Initialize config index */
-    wdata->gles_config = 0;
-
-    /* Now check each configuration to find out the best */
-    for (cit = 0; cit < configs; cit++) {
-        uint32_t stencil_found;
-        uint32_t depth_found;
-        EGLint   cur_depth;
-        EGLint   cur_stencil;
-
-        stencil_found = 0;
-        depth_found = 0;
-
-        if (_this->gl_config.stencil_size) {
-            status =
-                eglGetConfigAttrib(phdata->egldisplay,
-                                   wdata->gles_configs[cit], EGL_STENCIL_SIZE,
-                                   &cur_stencil);
-            if (status == EGL_TRUE) {
-                if (cur_stencil != 0) {
-                    stencil_found = 1;
-                }
-            }
-        } else {
-            stencil_found = 1;
-        }
-
-        if (_this->gl_config.depth_size) {
-            status =
-                eglGetConfigAttrib(phdata->egldisplay,
-                                   wdata->gles_configs[cit], EGL_DEPTH_SIZE,
-                                   &cur_depth);
-            if (status == EGL_TRUE) {
-                if (cur_depth != 0) {
-                    depth_found = 1;
-                }
-            }
-        } else {
-            depth_found = 1;
-        }
-
-        /* Exit from loop if found appropriate configuration */
-        if ((depth_found != 0) && (stencil_found != 0)) {
-            /* Store last satisfied configuration id */
-            wdata->gles_config = cit;
-
-            if (cur_depth==_this->gl_config.depth_size)
-            {
-                /* Exact match on depth bits */
-                if (!_this->gl_config.stencil_size)
-                {
-                    /* Stencil is not required */
-                    break;
-                }
-                else
-                {
-                    if (cur_stencil==_this->gl_config.stencil_size)
-                    {
-                        /* Exact match on stencil bits */
-                        break;
-                    }
-                }
-            }
-        }
-    }
-
-    /* If best could not be found, use first or last satisfied */
-    if ((cit == configs) && (wdata->gles_config==0)) {
-        cit = 0;
-        wdata->gles_config = cit;
-    }
-
-    /* Create OpenGL ES context */
-    wdata->gles_context =
-        eglCreateContext(phdata->egldisplay,
-                         wdata->gles_configs[wdata->gles_config],
-                         EGL_NO_CONTEXT, NULL);
-    if (wdata->gles_context == EGL_NO_CONTEXT) {
-        SDL_SetError("Photon: OpenGL ES context creation has been failed");
-        return NULL;
-    }
-
-    /* Check if surface is exist */
-    if (wdata->gfsurface != NULL) {
-        gf_surface_free(wdata->gfsurface);
-        wdata->gfsurface = NULL;
-    }
-
-    /* Create GF surface */
-    gfstatus =
-        gf_surface_create(&wdata->gfsurface, phdata->gfdev, window->w,
-                          window->h,
-                          qnxgf_sdl_to_gf_pixelformat(didata->current_mode.
-                                                      format), NULL,
-                          GF_SURFACE_CREATE_2D_ACCESSIBLE |
-                          GF_SURFACE_CREATE_3D_ACCESSIBLE |
-                          GF_SURFACE_CREATE_SHAREABLE);
-    if (gfstatus != GF_ERR_OK) {
-        eglDestroyContext(phdata->egldisplay, wdata->gles_context);
-        wdata->gles_context = EGL_NO_CONTEXT;
-        SDL_SetError("Photon: Can't create GF 3D surface (%08X)", gfstatus);
-        return NULL;
-    }
-
-    /* Create pixmap 3D target surface */
-    wdata->gles_surface =
-        eglCreatePixmapSurface(phdata->egldisplay,
-                               wdata->gles_configs[wdata->gles_config],
-                               wdata->gfsurface, NULL);
-    if (wdata->gles_surface == EGL_NO_SURFACE) {
-        gf_surface_free(wdata->gfsurface);
-        wdata->gfsurface=NULL;
-        eglDestroyContext(phdata->egldisplay, wdata->gles_context);
-        wdata->gles_context = EGL_NO_CONTEXT;
-        SDL_SetError("Photon: Can't create EGL pixmap surface");
-        return NULL;
-    }
-
-    /* Store last used context and surface */
-    phdata->lgles_surface=wdata->gles_surface;
-    phdata->lgles_context=wdata->gles_context;
-
-    /* Make just created context current */
-    status =
-        eglMakeCurrent(phdata->egldisplay, wdata->gles_surface,
-                       wdata->gles_surface, wdata->gles_context);
-    if (status != EGL_TRUE) {
-        /* Reset last used context and surface */
-        phdata->lgles_surface=EGL_NO_SURFACE;
-        phdata->lgles_context=EGL_NO_CONTEXT;
-
-        /* Destroy OpenGL ES surface */
-        eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
-        wdata->gles_surface=EGL_NO_SURFACE;
-        gf_surface_free(wdata->gfsurface);
-        wdata->gfsurface=NULL;
-        eglDestroyContext(phdata->egldisplay, wdata->gles_context);
-        wdata->gles_context = EGL_NO_CONTEXT;
-        SDL_SetError("Photon: Can't set OpenGL ES context on creation");
-        return NULL;
-    }
-
-    /* Setup into SDL internals state of OpenGL ES:  */
-    /* it is accelerated or not                      */
-    if ((didata->caps & SDL_PHOTON_ACCELERATED_3D) ==
-        SDL_PHOTON_ACCELERATED_3D) {
-        _this->gl_config.accelerated = 1;
-    } else {
-        _this->gl_config.accelerated = 0;
-    }
-
-    /* Always clear stereo enable, since OpenGL ES do not supports stereo */
-    _this->gl_config.stereo = 0;
-
-    /* Get back samples and samplebuffers configurations. Rest framebuffer */
-    /* parameters could be obtained through the OpenGL ES API              */
-    status =
-        eglGetConfigAttrib(phdata->egldisplay,
-                           wdata->gles_configs[wdata->gles_config],
-                           EGL_SAMPLES, &attr_value);
-    if (status == EGL_TRUE) {
-        _this->gl_config.multisamplesamples = attr_value;
-    }
-    status =
-        eglGetConfigAttrib(phdata->egldisplay,
-                           wdata->gles_configs[wdata->gles_config],
-                           EGL_SAMPLE_BUFFERS, &attr_value);
-    if (status == EGL_TRUE) {
-        _this->gl_config.multisamplebuffers = attr_value;
-    }
-
-    /* Get back stencil and depth buffer sizes */
-    status =
-        eglGetConfigAttrib(phdata->egldisplay,
-                           wdata->gles_configs[wdata->gles_config],
-                           EGL_DEPTH_SIZE, &attr_value);
-    if (status == EGL_TRUE) {
-        _this->gl_config.depth_size = attr_value;
-    }
-    status =
-        eglGetConfigAttrib(phdata->egldisplay,
-                           wdata->gles_configs[wdata->gles_config],
-                           EGL_STENCIL_SIZE, &attr_value);
-    if (status == EGL_TRUE) {
-        _this->gl_config.stencil_size = attr_value;
-    }
-
-    /* Under Photon OpenGL ES output can't be double buffered */
-    _this->gl_config.double_buffer = 0;
-
-    /* Check if current device is not the same as target */
-    if (phdata->current_device_id != didata->device_id) {
-        /* Set target device as default for Pd and Pg functions */
-        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
-        if (status != 0) {
-            /* Destroy OpenGL ES surface */
-            eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
-            wdata->gles_surface=EGL_NO_SURFACE;
-            gf_surface_free(wdata->gfsurface);
-            wdata->gfsurface=NULL;
-            eglDestroyContext(phdata->egldisplay, wdata->gles_context);
-            wdata->gles_context = EGL_NO_CONTEXT;
-            SDL_SetError("Photon: Can't set default target device\n");
-            return NULL;
-        }
-        phdata->current_device_id = didata->device_id;
-    }
-
-    wdata->phsurface = PdCreateOffscreenContextGF(wdata->gfsurface);
-    if (wdata->phsurface == NULL) {
-        /* Destroy OpenGL ES surface */
-        eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
-        wdata->gles_surface=EGL_NO_SURFACE;
-        gf_surface_free(wdata->gfsurface);
-        wdata->gfsurface=NULL;
-        eglDestroyContext(phdata->egldisplay, wdata->gles_context);
-        wdata->gles_context = EGL_NO_CONTEXT;
-        SDL_SetError("Photon: Can't bind GF surface to Photon\n");
-        return NULL;
-    }
-
-    /* GL ES context was successfully created */
-    return wdata->gles_context;
-#else
-    SDL_SetError("Photon: OpenGL ES support is not compiled in");
-    return NULL;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-int
-photon_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_WindowData *wdata;
-    EGLBoolean status;
-
-    if (phdata->gfinitialized != SDL_TRUE) {
-        SDL_SetError
-            ("Photon: GF initialization failed, no OpenGL ES support");
-        return -1;
-    }
-
-    if ((window == NULL) && (context == NULL)) {
-        /* Reset last used context and surface */
-        phdata->lgles_surface=EGL_NO_SURFACE;
-        phdata->lgles_context=EGL_NO_CONTEXT;
-
-        /* Unset current context */
-        status =
-            eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
-                           EGL_NO_CONTEXT);
-        if (status != EGL_TRUE) {
-            /* Failed to set current GL ES context */
-            SDL_SetError("Photon: Can't empty current OpenGL ES context");
-            return -1;
-        }
-    } else {
-        wdata = (SDL_WindowData *) window->driverdata;
-        if (wdata->gles_surface == EGL_NO_SURFACE) {
-            SDL_SetError
-                ("Photon: OpenGL ES surface is not initialized for this window");
-            return -1;
-        }
-        if (wdata->gles_context == EGL_NO_CONTEXT) {
-            SDL_SetError
-                ("Photon: OpenGL ES context is not initialized for this window");
-            return -1;
-        }
-        if (wdata->gles_context != context) {
-            SDL_SetError
-                ("Photon: OpenGL ES context is not belong to this window");
-            return -1;
-        }
-
-        /* Store last set surface and context */
-        phdata->lgles_surface=wdata->gles_surface;
-        phdata->lgles_context=wdata->gles_context;
-
-        /* Set new current context */
-        status =
-            eglMakeCurrent(phdata->egldisplay, wdata->gles_surface,
-                           wdata->gles_surface, wdata->gles_context);
-        if (status != EGL_TRUE) {
-            /* Reset last used context and surface */
-            phdata->lgles_surface=EGL_NO_SURFACE;
-            phdata->lgles_context=EGL_NO_CONTEXT;
-            /* Failed to set current GL ES context */
-            SDL_SetError("Photon: Can't set OpenGL ES context");
-            return -1;
-        }
-    }
-
-    return 0;
-#else
-    SDL_SetError("Photon: OpenGL ES support is not compiled in");
-    return -1;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-int
-photon_gl_setswapinterval(_THIS, int interval)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    EGLBoolean status;
-
-    if (phdata->gfinitialized != SDL_TRUE) {
-        SDL_SetError
-            ("Photon: GF initialization failed, no OpenGL ES support");
-        return -1;
-    }
-
-    /* Check if OpenGL ES connection has been initialized */
-    if (phdata->egldisplay != EGL_NO_DISPLAY) {
-        /* Set swap OpenGL ES interval */
-        status = eglSwapInterval(phdata->egldisplay, interval);
-        if (status == EGL_TRUE) {
-            /* Return success to upper level */
-            phdata->swapinterval = interval;
-            return 0;
-        }
-    }
-
-    /* Failed to set swap interval */
-    SDL_SetError("Photon: Cannot set swap interval");
-    return -1;
-#else
-    SDL_SetError("Photon: OpenGL ES support is not compiled in");
-    return -1;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-int
-photon_gl_getswapinterval(_THIS)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-
-    if (phdata->gfinitialized != SDL_TRUE) {
-        SDL_SetError
-            ("Photon: GF initialization failed, no OpenGL ES support");
-        return -1;
-    }
-
-    /* Return default swap interval value */
-    return phdata->swapinterval;
-#else
-    SDL_SetError("Photon: OpenGL ES support is not compiled in");
-    return -1;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-void
-photon_gl_swapwindow(_THIS, SDL_Window * window)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) window->display->driverdata;
-    PhRect_t dst_rect;
-    PhRect_t src_rect;
-    int32_t status;
-
-    if (phdata->gfinitialized != SDL_TRUE) {
-        SDL_SetError
-            ("Photon: GF initialization failed, no OpenGL ES support");
-        return;
-    }
-
-    if (wdata->phsurface==NULL) {
-        SDL_SetError
-            ("Photon: Photon OpenGL ES surface is not initialized");
-        return;
-    }
-
-    /* Many applications do not uses glFinish(), so we call it for them */
-    glFinish();
-
-    /* Wait until OpenGL ES rendering is completed */
-    eglWaitGL();
-
-    /* Wait for VSYNC manually, if it was enabled */
-    if (phdata->swapinterval != 0) {
-        /* Wait for VSYNC, we use GF function, since Photon requires */
-        /* to enter to the Direct mode to call PgWaitVSync()         */
-        gf_display_wait_vsync(didata->display);
-    }
-
-    /* Set blit area */
-    dst_rect = *PtGetCanvas(wdata->window);
-    src_rect.ul.x = 0;
-    src_rect.ul.y = 0;
-    src_rect.lr.x = window->w - 1;
-    src_rect.lr.y = window->h - 1;
-
-    /* Check if current device is not the same as target */
-    if (phdata->current_device_id != didata->device_id) {
-        /* Set target device as default for Pd and Pg functions */
-        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
-        if (status != 0) {
-            SDL_SetError("Photon: Can't set default target device\n");
-            return;
-        }
-        phdata->current_device_id = didata->device_id;
-    }
-
-    /* Blit OpenGL ES pixmap surface directly to window region */
-    PgFFlush(Ph_START_DRAW);
-    PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window));
-    PgClearTranslationCx(PgGetGCCx(PhDCGetCurrent()));
-    PgContextBlit(wdata->phsurface, &src_rect, NULL, &dst_rect);
-    PgFFlush(Ph_DONE_DRAW);
-    PgWaitHWIdle();
-
-    eglSwapBuffers(phdata->egldisplay, wdata->gles_surface);
-#else
-    SDL_SetError("Photon: OpenGL ES support is not compiled in");
-    return;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-void
-photon_gl_deletecontext(_THIS, SDL_GLContext context)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    EGLBoolean status;
-
-    if (phdata->gfinitialized != SDL_TRUE) {
-        SDL_SetError
-            ("Photon: GF initialization failed, no OpenGL ES support");
-        return;
-    }
-
-    /* Check if OpenGL ES connection has been initialized */
-    if (phdata->egldisplay != EGL_NO_DISPLAY) {
-        if (context != EGL_NO_CONTEXT) {
-            /* Check if we are destroying current active context */
-            if (phdata->lgles_context==context) {
-                /* Release current context */
-                eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-                phdata->lgles_context=EGL_NO_CONTEXT;
-                phdata->lgles_surface=EGL_NO_SURFACE;
-            }
-            status = eglDestroyContext(phdata->egldisplay, context);
-            if (status != EGL_TRUE) {
-                /* Error during OpenGL ES context destroying */
-                SDL_SetError("Photon: OpenGL ES context destroy error");
-                return;
-            }
-        }
-    }
-
-    return;
-#else
-    SDL_SetError("Photon: OpenGL ES support is not compiled in");
-    return;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-/* Helper function, which re-creates surface, not an API */
-int photon_gl_recreatesurface(_THIS, SDL_Window * window, uint32_t width, uint32_t height)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) window->display->driverdata;
-    SDL_bool makecurrent=SDL_FALSE;
-    int32_t gfstatus;
-
-    /* Check if context has been initialized */
-    if (wdata->gles_context == EGL_NO_CONTEXT) {
-        /* If no, abort surface re-creating */
-        return -1;
-    }
-
-    /* Check if last used surface the same as one which must be re-created */
-    if (phdata->lgles_surface == wdata->gles_surface) {
-        makecurrent=SDL_TRUE;
-        /* Flush all current drawings */
-        glFinish();
-        /* Wait until OpenGL ES rendering is completed */
-        eglWaitGL();
-        /* Release current context */
-        eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-        phdata->lgles_surface=EGL_NO_SURFACE;
-    }
-
-    /* Check if we need to destroy previous surface */
-    if (wdata->gles_surface != EGL_NO_SURFACE) {
-        /* Destroy photon handle to GF surface */
-        if (wdata->phsurface != NULL) {
-            PhDCRelease(wdata->phsurface);
-            wdata->phsurface=NULL;
-        }
-
-        /* Destroy previous surface */
-        eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
-
-        /* Set surface to uninitialized */
-        wdata->gles_surface = EGL_NO_SURFACE;
-
-        if (wdata->gfsurface!=NULL) {
-           gf_surface_free(wdata->gfsurface);
-           wdata->gfsurface=NULL;
-        }
-    }
-
-    /* Create new GF surface */
-    gfstatus =
-        gf_surface_create(&wdata->gfsurface, phdata->gfdev, width,
-                          height,
-                          qnxgf_sdl_to_gf_pixelformat(didata->current_mode.
-                                                      format), NULL,
-                          GF_SURFACE_CREATE_2D_ACCESSIBLE |
-                          GF_SURFACE_CREATE_3D_ACCESSIBLE |
-                          GF_SURFACE_CREATE_SHAREABLE);
-    if (gfstatus != GF_ERR_OK) {
-        SDL_SetError("Photon: Can't create GF 3D surface (%08X)", gfstatus);
-        return -1;
-    }
-
-    /* Create new pixmap 3D target surface */
-    wdata->gles_surface =
-        eglCreatePixmapSurface(phdata->egldisplay,
-                               wdata->gles_configs[wdata->gles_config],
-                               wdata->gfsurface, NULL);
-    if (wdata->gles_surface == EGL_NO_SURFACE) {
-        gf_surface_free(wdata->gfsurface);
-        wdata->gfsurface=NULL;
-        SDL_SetError("Photon: Can't create EGL pixmap surface");
-        return -1;
-    }
-
-    wdata->phsurface = PdCreateOffscreenContextGF(wdata->gfsurface);
-    if (wdata->phsurface == NULL) {
-        /* Destroy OpenGL ES surface */
-        eglDestroySurface(phdata->egldisplay, wdata->gles_surface);
-        wdata->gles_surface=EGL_NO_SURFACE;
-        gf_surface_free(wdata->gfsurface);
-        wdata->gfsurface=NULL;
-        SDL_SetError("Photon: Can't bind GF surface to Photon\n");
-        return -1;
-    }
-
-    /* Check if we need to set this surface and context as current */
-    if (makecurrent == SDL_TRUE) {
-        return photon_gl_makecurrent(_this, window, wdata->gles_context);
-    } else {
-        return 0;
-    }
-#else
-    /* Do nothing, if OpenGL ES support is not compiled in */
-    return 0;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-/*****************************************************************************/
-/* SDL Event handling function                                               */
-/*****************************************************************************/
-void
-photon_pumpevents(_THIS)
-{
-    uint8_t eventbuffer[SDL_VIDEO_PHOTON_EVENT_SIZE];
-    PhEvent_t *event = (PhEvent_t *) eventbuffer;
-    int32_t status;
-    uint32_t finish = 0;
-    SDL_Window *window;
-    SDL_WindowData *wdata;
-
-    do {
-        status = PhEventPeek(event, SDL_VIDEO_PHOTON_EVENT_SIZE);
-        switch (status) {
-        case Ph_RESIZE_MSG:
-            {
-                SDL_SetError("Photon: Event size too much for buffer");
-                return;
-            }
-            break;
-        case Ph_EVENT_MSG:
-            {
-                /* Find a window, to which this handle destinated */
-                status = 0;
-                for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) {
-                    SDL_VideoDisplay *display = SDL_GetVideoDisplay(i);
-                    for (j = 0; j < display->num_windows; ++j) {
-                        wdata = (SDL_WindowData *) display->windows[j].driverdata;
-
-                        /* Find the proper window */
-                        if (wdata->window != NULL) {
-                            if (PtWidgetRid(wdata->window) ==
-                                event->collector.rid) {
-                                window = (SDL_Window *) &display->windows[it];
-                                status = 1;
-                                break;
-                            }
-                        } else {
-                            continue;
-                        }
-                    }
-                }
-                if (status == 0) {
-                    window = NULL;
-                    wdata = NULL;
-                }
-
-                /* Event is ready */
-                switch (event->type) {
-                case Ph_EV_BOUNDARY:
-                    {
-                        switch (event->subtype) {
-                        case Ph_EV_PTR_ENTER:
-                            {
-                                /* Mouse cursor over handled window */
-                                if (window != NULL) {
-                                    SDL_SendWindowEvent(window,
-                                                        SDL_WINDOWEVENT_ENTER,
-                                                        0, 0);
-                                    SDL_SetMouseFocus(0, window);
-                                }
-                            }
-                            break;
-                        case Ph_EV_PTR_LEAVE:
-                            {
-                                /* Mouse cursor out of handled window */
-                                if (window != NULL) {
-                                    SDL_SendWindowEvent(window,
-                                                        SDL_WINDOWEVENT_LEAVE,
-                                                        0, 0);
-                                }
-                            }
-                            break;
-                        }
-                    }
-                    break;
-                case Ph_EV_PTR_MOTION_BUTTON:
-                case Ph_EV_PTR_MOTION_NOBUTTON:
-                    {
-                        PhPointerEvent_t *pevent = NULL;
-                        PhRect_t *prects = NULL;
-
-                        /* Get event data */
-                        pevent = PhGetData(event);
-                        /* Get associated event rectangles */
-                        prects = PhGetRects(event);
-                        if ((pevent != NULL) && (prects != NULL)) {
-                            SDL_SendMouseMotion(0, 0, prects->ul.x,
-                                                prects->ul.y, 0);
-                        }
-                    }
-                    break;
-                case Ph_EV_BUT_PRESS:
-                    {
-                        /* Button press event */
-                        PhPointerEvent_t *pevent = NULL;
-                        uint32_t sdlbutton = 0x00000000;
-
-                        /* Get event data */
-                        pevent = PhGetData(event);
-                        if (pevent != NULL) {
-                            for (it = 0; it < sizeof(pevent->buttons) * 8;
-                                 it++) {
-                                if ((pevent->buttons & (0x0001 << it)) ==
-                                    (0x0001 << it)) {
-                                    switch (it) {
-                                    case 0:
-                                        {
-                                            sdlbutton = SDL_BUTTON_RIGHT;
-                                        }
-                                        break;
-                                    case 1:
-                                        {
-                                            sdlbutton = SDL_BUTTON_MIDDLE;
-                                        }
-                                        break;
-                                    case 2:
-                                        {
-                                            sdlbutton = SDL_BUTTON_LEFT;
-                                        }
-                                        break;
-                                    default:
-                                        {
-                                            sdlbutton = it + 1;
-                                        }
-                                        break;
-                                    }
-                                    SDL_SendMouseButton(0, SDL_PRESSED,
-                                                        sdlbutton);
-                                }
-                            }
-                        }
-                    }
-                    break;
-                case Ph_EV_BUT_RELEASE:
-                    {
-                        /* Button press event */
-                        PhPointerEvent_t *pevent = NULL;
-                        uint32_t sdlbutton = 0x00000000;
-
-                        /* Get event data */
-                        pevent = PhGetData(event);
-                        if (pevent != NULL) {
-                            for (it = 0; it < sizeof(pevent->buttons) * 8;
-                                 it++) {
-                                if ((pevent->buttons & (0x0001 << it)) ==
-                                    (0x0001 << it)) {
-                                    switch (it) {
-                                    case 0:
-                                        {
-                                            sdlbutton = SDL_BUTTON_RIGHT;
-                                        }
-                                        break;
-                                    case 1:
-                                        {
-                                            sdlbutton = SDL_BUTTON_MIDDLE;
-                                        }
-                                        break;
-                                    case 2:
-                                        {
-                                            sdlbutton = SDL_BUTTON_LEFT;
-                                        }
-                                        break;
-                                    default:
-                                        {
-                                            sdlbutton = it + 1;
-                                        }
-                                        break;
-                                    }
-                                }
-                            }
-                        }
-
-                        switch (event->subtype) {
-                        case Ph_EV_RELEASE_REAL:
-                            {
-                                /* Real release button event */
-                                SDL_SendMouseButton(0, SDL_RELEASED,
-                                                    sdlbutton);
-                            }
-                            break;
-                        case Ph_EV_RELEASE_PHANTOM:
-                            {
-                                /* We will get phantom button release */
-                                /* event in case if it was unpressed  */
-                                /* outside of window                  */
-                                if (window != NULL) {
-                                    if ((window->
-                                         flags & SDL_WINDOW_MOUSE_FOCUS) !=
-                                        SDL_WINDOW_MOUSE_FOCUS) {
-                                        /* Send phantom button release */
-                                        SDL_SendMouseButton(0, SDL_RELEASED,
-                                                            sdlbutton);
-                                    }
-                                }
-                            }
-                            break;
-                        }
-                    }
-                    break;
-                case Ph_EV_EXPOSE:
-                    {
-                        switch (event->subtype) {
-                        case Ph_NORMAL_EXPOSE:
-                            {
-                                PhRect_t *rects = NULL;
-
-                                /* Get array of rectangles to be updated */
-                                rects = PhGetRects(event);
-                                if (rects == NULL) {
-                                    break;
-                                }
-
-                                /* Check if expose come to one of the our windows */
-                                if ((wdata != NULL) && (window != NULL)) {
-                                    /* Check if window uses OpenGL ES */
-                                    if (wdata->uses_gles == SDL_TRUE) {
-                                        #if defined(SDL_VIDEO_OPENGL_ES)
-                                        /* Cycle through each rectangle */
-                                        for (it = 0; it < event->num_rects; it++) {
-                                            /* Blit OpenGL ES pixmap surface directly to window region */
-                                            PgFFlush(Ph_START_DRAW);
-                                            PgSetRegionCx(PhDCGetCurrent(),
-                                                          PtWidgetRid(wdata->
-                                                                      window));
-                                            PgClearTranslationCx(PgGetGCCx
-                                                                 (PhDCGetCurrent
-                                                                  ()));
-                                            PgContextBlit(wdata->phsurface,
-                                                          &rects[it], NULL,
-                                                          &rects[it]);
-                                            PgFFlush(Ph_DONE_DRAW);
-                                            PgWaitHWIdle();
-                                        }
-                                        #endif /* SDL_VIDEO_OPENGL_ES */
-                                    } else {
-                                        /* Cycle through each rectangle */
-                                        for (it = 0; it < event->num_rects;
-                                             it++) {
-                                            /* Blit 2D pixmap surface directly to window region */
-                                            _photon_update_rectangles(window->renderer, &rects[it]);
-                                        }
-                                        PgFlush();
-                                        PgWaitHWIdle();
-                                    }
-                                }
-
-                                /* Flush all blittings */
-                                PgFlush();
-                            }
-                            break;
-                        case Ph_CAPTURE_EXPOSE:
-                            {
-                                /* Check if expose come to one of the our windows */
-                                if ((wdata != NULL) && (window != NULL)) {
-                                    /* Check if window uses OpenGL ES */
-                                    if (wdata->uses_gles == SDL_TRUE) {
-                                        PhRect_t dst_rect;
-                                        PhRect_t src_rect;
-
-                                        /* Set blit area */
-                                        dst_rect =
-                                            *PtGetCanvas(wdata->window);
-                                        src_rect.ul.x = 0;
-                                        src_rect.ul.y = 0;
-                                        src_rect.lr.x = window->w - 1;
-                                        src_rect.lr.y = window->h - 1;
-
-                                        #if defined(SDL_VIDEO_OPENGL_ES)
-                                        /* We need to redraw entire window */
-                                        PgFFlush(Ph_START_DRAW);
-                                        PgSetRegionCx(PhDCGetCurrent(),
-                                                      PtWidgetRid(wdata->
-                                                                  window));
-                                        PgClearTranslationCx(PgGetGCCx
-                                                             (PhDCGetCurrent
-                                                              ()));
-                                        PgContextBlit(wdata->phsurface,
-                                                      &src_rect, NULL,
-                                                      &dst_rect);
-                                        PgFFlush(Ph_DONE_DRAW);
-                                        PgWaitHWIdle();
-                                        #endif /* SDL_VIDEO_OPENGL_ES */
-                                    } else {
-                                        PhRect_t rect;
-
-                                        /* We need to redraw entire window */
-                                        rect.ul.x = 0;
-                                        rect.ul.y = 0;
-                                        rect.lr.x = window->w - 1;
-                                        rect.lr.y = window->h - 1;
-
-                                        /* Blit 2D pixmap surface directly to window region */
-                                        PgFFlush(Ph_START_DRAW);
-                                        _photon_update_rectangles(window->renderer, &rect);
-                                        PgFFlush(Ph_DONE_DRAW);
-                                        PgWaitHWIdle();
-                                    }
-                                }
-                            }
-                            break;
-                        case Ph_GRAPHIC_EXPOSE:
-                            {
-                                /* TODO: What this event means ? */
-                            }
-                            break;
-                        }
-                    }
-                    break;
-                case Ph_EV_INFO:
-                    {
-                        switch (event->subtype)
-                        {
-                           case Ph_OFFSCREEN_INVALID:
-                                {
-                                   uint32_t* type;
-
-                                   type = PhGetData(event);
-                                   switch (*type)
-                                   {
-                                      case Pg_VIDEO_MODE_SWITCHED:
-                                      case Pg_ENTERED_DIRECT:
-                                      case Pg_EXITED_DIRECT:
-                                      case Pg_DRIVER_STARTED:
-                                           {
-                                               /* TODO: */
-                                               /* We must tell the renderer, that it have */
-                                               /* to recreate all surfaces                */
-                                           }
-                                           break;
-                                      default:
-                                           {
-                                           }
-                                           break;
-                                   }
-                                }
-                                break;
-                           default:
-                                break;
-                        }
-                    }
-                    break;
-                case Ph_EV_KEY:
-                    {
-                        PhKeyEvent_t *keyevent = NULL;
-                        SDL_ScanCode scancode = SDL_SCANCODE_UNKNOWN;
-                        SDL_bool pressed = SDL_FALSE;
-
-                        keyevent = PhGetData(event);
-                        if (keyevent == NULL) {
-                            break;
-                        }
-
-                        /* Check if key is repeated */
-                        if ((keyevent->key_flags & Pk_KF_Key_Repeat) ==
-                            Pk_KF_Key_Repeat) {
-                            /* Ignore such events */
-                            break;
-                        }
-
-                        /* Check if key has its own scancode */
-                        if ((keyevent->key_flags & Pk_KF_Scan_Valid) ==
-                            Pk_KF_Scan_Valid) {
-                            if ((keyevent->key_flags & Pk_KF_Key_Down) ==
-                                Pk_KF_Key_Down) {
-                                pressed = SDL_TRUE;
-                            } else {
-                                pressed = SDL_FALSE;
-                            }
-                            scancode =
-                                photon_to_sdl_keymap(keyevent->key_scan);
-
-                            /* Add details for the pressed key */
-                            if ((keyevent->key_flags & Pk_KF_Cap_Valid) ==
-                                Pk_KF_Cap_Valid) {
-                                switch (keyevent->key_cap) {
-                                case Pk_Hyper_R:       /* Right windows flag key */
-                                    scancode = SDL_SCANCODE_RGUI;
-                                    break;
-                                case Pk_Control_R:     /* Right Ctrl key */
-                                    scancode = SDL_SCANCODE_RCTRL;
-                                    break;
-                                case Pk_Alt_R: /* Right Alt key */
-                                    scancode = SDL_SCANCODE_RALT;
-                                    break;
-                                case Pk_Up:    /* Up key but with invalid scan */
-                                    if (scancode != SDL_SCANCODE_UP) {
-                                        /* This is a mouse wheel event */
-                                        SDL_SendMouseWheel(0, 0, 1);
-                                        return;
-                                    }
-                                    break;
-                                case Pk_KP_8:  /* Up arrow or 8 on keypad */
-                                    scancode = SDL_SCANCODE_KP_8;
-                                    break;
-                                case Pk_Down:  /* Down key but with invalid scan */
-                                    if (scancode != SDL_SCANCODE_DOWN) {
-                                        /* This is a mouse wheel event */
-                                        SDL_SendMouseWheel(0, 0, -1);
-                                        return;
-                                    }
-                                    break;
-                                case Pk_KP_2:  /* Down arrow or 2 on keypad */
-                                    scancode = SDL_SCANCODE_KP_2;
-                                    break;
-                                case Pk_Left:  /* Left arrow key */
-                                    scancode = SDL_SCANCODE_LEFT;
-                                    break;
-                                case Pk_KP_4:  /* Left arrow or 4 on keypad */
-                                    scancode = SDL_SCANCODE_KP_4;
-                                    break;
-                                case Pk_Right: /* Right arrow key */
-                                    scancode = SDL_SCANCODE_RIGHT;
-                                    break;
-                                case Pk_KP_6:  /* Right arrow or 6 on keypad */
-                                    scancode = SDL_SCANCODE_KP_6;
-                                    break;
-                                case Pk_Insert:        /* Insert key */
-                                    scancode = SDL_SCANCODE_INSERT;
-                                    break;
-                                case Pk_KP_0:  /* Insert or 0 on keypad */
-                                    scancode = SDL_SCANCODE_KP_0;
-                                    break;
-                                case Pk_Home:  /* Home key */
-                                    scancode = SDL_SCANCODE_HOME;
-                                    break;
-                                case Pk_KP_7:  /* Home or 7 on keypad */
-                                    scancode = SDL_SCANCODE_KP_7;
-                                    break;
-                                case Pk_Pg_Up: /* PageUp key */
-                                    scancode = SDL_SCANCODE_PAGEUP;
-                                    break;
-                                case Pk_KP_9:  /* PgUp or 9 on keypad */
-                                    scancode = SDL_SCANCODE_KP_9;
-                                    break;
-                                case Pk_Delete:        /* Delete key */
-                                    scancode = SDL_SCANCODE_DELETE;
-                                    break;
-                                case Pk_KP_Decimal:    /* Del or . on keypad */
-                                    scancode = SDL_SCANCODE_KP_PERIOD;
-                                    break;
-                                case Pk_End:   /* End key */
-                                    scancode = SDL_SCANCODE_END;
-                                    break;
-                                case Pk_KP_1:  /* End or 1 on keypad */
-                                    scancode = SDL_SCANCODE_KP_1;
-                                    break;
-                                case Pk_Pg_Down:       /* PageDown key */
-                                    scancode = SDL_SCANCODE_PAGEDOWN;
-                                    break;
-                                case Pk_KP_3:  /* PgDn or 3 on keypad */
-                                    scancode = SDL_SCANCODE_KP_3;
-                                    break;
-                                case Pk_KP_5:  /* 5 on keypad */
-                                    scancode = SDL_SCANCODE_KP_5;
-                                    break;
-                                case Pk_KP_Enter:
-                                    scancode = SDL_SCANCODE_KP_ENTER;
-                                    break;
-                                case Pk_KP_Add:
-                                    scancode = SDL_SCANCODE_KP_PLUS;
-                                    break;
-                                case Pk_KP_Subtract:
-                                    scancode = SDL_SCANCODE_KP_MINUS;
-                                    break;
-                                case Pk_KP_Multiply:
-                                    scancode = SDL_SCANCODE_KP_MULTIPLY;
-                                    break;
-                                case Pk_KP_Divide:
-                                    scancode = SDL_SCANCODE_KP_DIVIDE;
-                                    break;
-                                case Pk_Pause:
-                                    scancode = SDL_SCANCODE_PAUSE;
-                                    break;
-                                }
-                            }
-
-                            /* Finally check if scancode has been decoded */
-                            if (scancode == SDL_SCANCODE_UNKNOWN) {
-                                /* Something was pressed, which is not supported */
-                                break;
-                            }
-
-                            /* Report pressed/released key to SDL */
-                            if (pressed == SDL_TRUE) {
-                                SDL_SendKeyboardKey(0, SDL_PRESSED, scancode);
-                            } else {
-                                SDL_SendKeyboardKey(0, SDL_RELEASED,
-                                                    scancode);
-                            }
-
-                            /* Photon doesn't send a release event for PrnScr key */
-                            if ((scancode == SDL_SCANCODE_PRINTSCREEN)
-                                && (pressed)) {
-                                SDL_SendKeyboardKey(0, SDL_RELEASED,
-                                                    scancode);
-                            }
-
-                        }
-
-                        /* Handle UTF-8 text input if requested by caller */
-                        if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY))
-                        {
-                            char text[5];
-
-                            SDL_memset(text, 0x00, 5);
-                            if (PhKeyToMb(text, keyevent)!=-1)
-                            {
-                                SDL_SendKeyboardText(0, text);
-                            }
-                            else
-                            {
-                                /* Just do nothing if it is not a UTF-8 character */
-                            }
-                        }
-                    }
-                    break;
-                case Ph_EV_SERVICE:
-                    {
-                    }
-                    break;
-                case Ph_EV_SYSTEM:
-                    {
-                    }
-                    break;
-                case Ph_EV_WM:
-                    {
-                        PhWindowEvent_t *wmevent = NULL;
-
-                        /* Get associated event data */
-                        wmevent = PhGetData(event);
-                        if (wmevent == NULL) {
-                            break;
-                        }
-
-                        switch (wmevent->event_f) {
-                        case Ph_WM_CLOSE:
-                            {
-                                if (window != NULL) {
-                                    SDL_SendWindowEvent(window,
-                                                        SDL_WINDOWEVENT_CLOSE,
-                                                        0, 0);
-                                }
-                            }
-                            break;
-                        case Ph_WM_FOCUS:
-                            {
-                                if (wmevent->event_state ==
-                                    Ph_WM_EVSTATE_FOCUS) {
-                                    if (window != NULL) {
-                                        PhRegion_t wregion;
-
-                                        SDL_SendWindowEvent(window,
-                                                            SDL_WINDOWEVENT_FOCUS_GAINED,
-                                                            0, 0);
-                                        SDL_SetKeyboardFocus(0, window);
-
-                                        /* Set window region sensible to mouse motion events */
-                                        PhRegionQuery(PtWidgetRid
-                                                      (wdata->window),
-                                                      &wregion, NULL, NULL,
-                                                      0);
-                                        wregion.events_sense |=
-                                            Ph_EV_PTR_MOTION_BUTTON |
-                                            Ph_EV_PTR_MOTION_NOBUTTON;
-                                        PhRegionChange(Ph_REGION_EV_SENSE, 0,
-                                                       &wregion, NULL, NULL);
-
-                                        /* If window got a focus, then it is visible */
-                                        SDL_SendWindowEvent(window,
-                                                            SDL_WINDOWEVENT_SHOWN,
-                                                            0, 0);
-                                    }
-                                }
-                                if (wmevent->event_state ==
-                                    Ph_WM_EVSTATE_FOCUSLOST) {
-                                    if (window != NULL) {
-                                        PhRegion_t wregion;
-
-                                        SDL_SendWindowEvent(window,
-                                                            SDL_WINDOWEVENT_FOCUS_LOST,
-                                                            0, 0);
-
-                                        /* Set window region ignore mouse motion events */
-                                        PhRegionQuery(PtWidgetRid
-                                                      (wdata->window),
-                                                      &wregion, NULL, NULL,
-                                                      0);
-                                        wregion.events_sense &=
-                                            ~(Ph_EV_PTR_MOTION_BUTTON |
-                                              Ph_EV_PTR_MOTION_NOBUTTON);
-                                        PhRegionChange(Ph_REGION_EV_SENSE, 0,
-                                                       &wregion, NULL, NULL);
-                                    }
-                                }
-                            }
-                            break;
-                        case Ph_WM_MOVE:
-                            {
-                                if (window != NULL) {
-                                    SDL_SendWindowEvent(window,
-                                                        SDL_WINDOWEVENT_MOVED,
-                                                        wmevent->pos.x,
-                                                        wmevent->pos.y);
-                                }
-                            }
-                            break;
-                        case Ph_WM_RESIZE:
-                            {
-                                if (window != NULL) {
-                                    /* Set new window position after resize */
-                                    SDL_SendWindowEvent(window,
-                                                        SDL_WINDOWEVENT_MOVED,
-                                                        wmevent->pos.x,
-                                                        wmevent->pos.y);
-
-                                    /* Check if this window uses OpenGL ES */
-                                    if (wdata->uses_gles == SDL_TRUE) {
-                                        /* If so, recreate surface with new dimensions */
-                                        photon_gl_recreatesurface(_this, window, wmevent->size.w, wmevent->size.h);
-                                    }
-
-                                    /* Set new window size after resize */
-                                    SDL_SendWindowEvent(window,
-                                                        SDL_WINDOWEVENT_RESIZED,
-                                                        wmevent->size.w,
-                                                        wmevent->size.h);
-                                }
-                            }
-                            break;
-                        case Ph_WM_HIDE:
-                            {
-                                if (window != NULL) {
-                                    /* Send new window state: minimized */
-                                    SDL_SendWindowEvent(window,
-                                                        SDL_WINDOWEVENT_MINIMIZED,
-                                                        0, 0);
-                                    /* In case window is minimized, then it is hidden */
-                                    SDL_SendWindowEvent(window,
-                                                        SDL_WINDOWEVENT_HIDDEN,
-                                                        0, 0);
-                                }
-                            }
-                            break;
-                        case Ph_WM_MAX:
-                            {
-                                if (window != NULL) {
-                                    if ((window->flags & SDL_WINDOW_RESIZABLE)==SDL_WINDOW_RESIZABLE)
-                                    {
-                                       SDL_SendWindowEvent(window,
-                                                           SDL_WINDOWEVENT_MAXIMIZED,
-                                                           0, 0);
-                                    }
-                                    else
-                                    {
-                                       /* otherwise ignor the resize events */
-                                    }
-                                }
-                            }
-                            break;
-                        case Ph_WM_RESTORE:
-                            {
-                                if (window != NULL) {
-                                    SDL_SendWindowEvent(window,
-                                                        SDL_WINDOWEVENT_RESTORED,
-                                                        0, 0);
-                                }
-                            }
-                            break;
-                        }
-                    }
-                    break;
-                }
-                PtEventHandler(event);
-            }
-            break;
-        case 0:
-            {
-                /* All events are read */
-                finish = 1;
-                break;
-            }
-        case -1:
-            {
-                /* Error occured in event reading */
-                SDL_SetError("Photon: Can't read event");
-                return;
-            }
-            break;
-        }
-        if (finish != 0) {
-            break;
-        }
-    } while (1);
-}
-
-/*****************************************************************************/
-/* SDL screen saver related functions                                        */
-/*****************************************************************************/
-void
-photon_suspendscreensaver(_THIS)
-{
-    /* There is no screensaver in pure console, it may exist when running */
-    /* GF under Photon, but I do not know, how to disable screensaver     */
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/photon/SDL_photon.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Photon GUI SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_PHOTON_H__
-#define __SDL_PHOTON_H__
-
-/* GF headers must be included first for the Photon GF functions */
-#if defined(SDL_VIDEO_OPENGL_ES)
-#include <gf/gf.h>
-#include <GLES/egl.h>
-#endif /* SDL_VIDEO_OPENGL_ES */
-
-#include "SDL_config.h"
-#include "../SDL_sysvideo.h"
-
-#include <Ph.h>
-#include <Pt.h>
-#include <photon/PkKeyDef.h>
-
-/* Maximum display devices, which can handle SDL Photon driver */
-#define SDL_VIDEO_PHOTON_MAX_RIDS 16
-
-typedef struct SDL_VideoData
-{
-    PhRid_t rid[SDL_VIDEO_PHOTON_MAX_RIDS];
-    uint32_t avail_rids;
-    uint32_t current_device_id;
-#if defined(SDL_VIDEO_OPENGL_ES)
-    gf_dev_t gfdev;             /* GF device handle                     */
-    gf_dev_info_t gfdev_info;   /* GF device information                */
-    SDL_bool gfinitialized;     /* GF device initialization status      */
-    EGLDisplay egldisplay;      /* OpenGL ES display connection         */
-    uint32_t egl_refcount;      /* OpenGL ES reference count            */
-    uint32_t swapinterval;      /* OpenGL ES default swap interval      */
-    EGLContext lgles_context;   /* Last used OpenGL ES context          */
-    EGLSurface lgles_surface;   /* Last used OpenGL ES target surface   */
-#endif /* SDL_VIDEO_OPENGL_ES */
-} SDL_VideoData;
-
-/* This is hardcoded value in photon/Pg.h */
-#define SDL_VIDEO_PHOTON_DEVICENAME_MAX  41
-#define SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE 128
-
-/* Maximum event message size with data payload */
-#define SDL_VIDEO_PHOTON_EVENT_SIZE 8192
-
-/* Current video mode graphics capabilities */
-#define SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND 0x00000001
-#define SDL_VIDEO_PHOTON_CAP_SCALED_BLIT 0x00000002
-
-typedef struct SDL_DisplayData
-{
-    uint32_t device_id;
-    uint32_t custom_refresh;            /* Custom refresh rate for all modes  */
-    SDL_DisplayMode current_mode;       /* Current video mode                 */
-    uint8_t description[SDL_VIDEO_PHOTON_DEVICENAME_MAX];
-    /* Device description */
-    uint32_t caps;                      /* Device capabilities                */
-    PhCursorDef_t *cursor;              /* Global cursor settings             */
-    SDL_bool cursor_visible;            /* SDL_TRUE if cursor visible         */
-    uint32_t cursor_size;               /* Cursor size in memory w/ structure */
-    uint32_t mode_2dcaps;               /* Current video mode 2D capabilities */
-    SDL_bool direct_mode;               /* Direct mode state                  */
-#if defined(SDL_VIDEO_OPENGL_ES)
-    gf_display_t display;               /* GF display handle                  */
-    gf_display_info_t display_info;     /* GF display information             */
-#endif /* SDL_VIDEO_OPENGL_ES */
-} SDL_DisplayData;
-
-/* Maximum amount of OpenGL ES framebuffer configurations */
-#define SDL_VIDEO_GF_OPENGLES_CONFS 32
-
-typedef struct SDL_WindowData
-{
-    SDL_bool uses_gles;         /* if true window must support OpenGL ES */
-    PtWidget_t *window;         /* window handle                         */
-#if defined(SDL_VIDEO_OPENGL_ES)
-    EGLConfig gles_configs[SDL_VIDEO_GF_OPENGLES_CONFS];
-    /* OpenGL ES framebuffer confs */
-    EGLint gles_config;                 /* OpenGL ES configuration index      */
-    EGLContext gles_context;            /* OpenGL ES context                  */
-    EGLint gles_attributes[256];        /* OpenGL ES attributes for context   */
-    EGLSurface gles_surface;            /* OpenGL ES target rendering surface */
-    gf_surface_t gfsurface;             /* OpenGL ES GF's surface             */
-    PdOffscreenContext_t *phsurface;    /* OpenGL ES Photon's surface         */
-#endif /* SDL_VIDEO_OPENGL_ES */
-} SDL_WindowData;
-
-/****************************************************************************/
-/* Low level Photon graphics driver capabilities                            */
-/****************************************************************************/
-typedef struct Photon_DeviceCaps
-{
-    uint8_t *name;
-    uint32_t caps;
-} Photon_DeviceCaps;
-
-#define SDL_PHOTON_UNACCELERATED         0x00000000
-#define SDL_PHOTON_ACCELERATED           0x00000001
-#define SDL_PHOTON_UNACCELERATED_3D      0x00000000
-#define SDL_PHOTON_ACCELERATED_3D        0x00000004
-
-/****************************************************************************/
-/* SDL_VideoDevice functions declaration                                    */
-/****************************************************************************/
-
-/* Display and window functions */
-int photon_videoinit(_THIS);
-void photon_videoquit(_THIS);
-void photon_getdisplaymodes(_THIS);
-int photon_setdisplaymode(_THIS, SDL_DisplayMode * mode);
-int photon_setdisplaypalette(_THIS, SDL_Palette * palette);
-int photon_getdisplaypalette(_THIS, SDL_Palette * palette);
-int photon_setdisplaygammaramp(_THIS, Uint16 * ramp);
-int photon_getdisplaygammaramp(_THIS, Uint16 * ramp);
-int photon_createwindow(_THIS, SDL_Window * window);
-int photon_createwindowfrom(_THIS, SDL_Window * window, const void *data);
-void photon_setwindowtitle(_THIS, SDL_Window * window);
-void photon_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon);
-void photon_setwindowposition(_THIS, SDL_Window * window);
-void photon_setwindowsize(_THIS, SDL_Window * window);
-void photon_showwindow(_THIS, SDL_Window * window);
-void photon_hidewindow(_THIS, SDL_Window * window);
-void photon_raisewindow(_THIS, SDL_Window * window);
-void photon_maximizewindow(_THIS, SDL_Window * window);
-void photon_minimizewindow(_THIS, SDL_Window * window);
-void photon_restorewindow(_THIS, SDL_Window * window);
-void photon_setwindowgrab(_THIS, SDL_Window * window);
-void photon_destroywindow(_THIS, SDL_Window * window);
-
-/* Window manager function */
-SDL_bool photon_getwindowwminfo(_THIS, SDL_Window * window,
-                                struct SDL_SysWMinfo *info);
-
-/* OpenGL/OpenGL ES functions */
-int photon_gl_loadlibrary(_THIS, const char *path);
-void *photon_gl_getprocaddres(_THIS, const char *proc);
-void photon_gl_unloadlibrary(_THIS);
-SDL_GLContext photon_gl_createcontext(_THIS, SDL_Window * window);
-int photon_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context);
-int photon_gl_setswapinterval(_THIS, int interval);
-int photon_gl_getswapinterval(_THIS);
-void photon_gl_swapwindow(_THIS, SDL_Window * window);
-void photon_gl_deletecontext(_THIS, SDL_GLContext context);
-
-/* Helper function, which re-creates surface, not an API */
-int photon_gl_recreatesurface(_THIS, SDL_Window * window, uint32_t width, uint32_t height);
-
-/* Event handling function */
-void photon_pumpevents(_THIS);
-
-/* Screen saver related function */
-void photon_suspendscreensaver(_THIS);
-
-#endif /* __SDL_PHOTON_H__ */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/photon/SDL_photon_input.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,726 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Photon GUI SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#include "SDL_photon_input.h"
-
-#include "SDL_config.h"
-#include "SDL_events.h"
-#include "../../events/SDL_mouse_c.h"
-#include "../../events/SDL_keyboard_c.h"
-
-#include "SDL_photon_keycodes.h"
-
-/* Mouse related functions */
-SDL_Cursor *photon_createcursor(SDL_Surface * surface, int hot_x, int hot_y);
-int photon_showcursor(SDL_Cursor * cursor);
-void photon_movecursor(SDL_Cursor * cursor);
-void photon_freecursor(SDL_Cursor * cursor);
-void photon_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y);
-void photon_freemouse(SDL_Mouse * mouse);
-
-int32_t
-photon_addinputdevices(_THIS)
-{
-    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *didata = NULL;
-    struct SDL_Mouse photon_mouse;
-    SDL_MouseData *mdata = NULL;
-    SDL_Keyboard photon_keyboard;
-    SDLKey keymap[SDL_NUM_SCANCODES];
-    uint32_t it;
-
-    for (it = 0; it < _this->num_displays; it++) {
-        SDL_VideoDisplay *display = &_this->displays[it];
-
-        /* Clear SDL mouse structure */
-        SDL_memset(&photon_mouse, 0x00, sizeof(struct SDL_Mouse));
-
-        /* Allocate SDL_MouseData structure */
-        mdata = (SDL_MouseData *) SDL_calloc(1, sizeof(SDL_MouseData));
-        if (mdata == NULL) {
-            SDL_OutOfMemory();
-            return -1;
-        }
-
-        /* Mark this mouse with ID 0 */
-        photon_mouse.id = it;
-        photon_mouse.driverdata = (void *) mdata;
-        photon_mouse.CreateCursor = photon_createcursor;
-        photon_mouse.ShowCursor = photon_showcursor;
-        photon_mouse.MoveCursor = photon_movecursor;
-        photon_mouse.FreeCursor = photon_freecursor;
-        photon_mouse.WarpMouse = photon_warpmouse;
-        photon_mouse.FreeMouse = photon_freemouse;
-
-        /* Get display data */
-        didata = (SDL_DisplayData *) display->driverdata;
-
-        /* Store SDL_DisplayData pointer in the mouse driver internals */
-        mdata->didata = didata;
-
-        /* Register mouse cursor in SDL */
-        SDL_AddMouse(&photon_mouse, "Photon mouse cursor", 0, 0, 1);
-    }
-
-    /* Photon maps all keyboards to one */
-    SDL_zero(photon_keyboard);
-    SDL_AddKeyboard(&photon_keyboard, -1);
-
-    /* Add default scancode to key mapping */
-    SDL_GetDefaultKeymap(keymap);
-    SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
-
-    return 0;
-}
-
-int32_t
-photon_delinputdevices(_THIS)
-{
-    /* Destroy all of the mice */
-    SDL_MouseQuit();
-}
-
-/*****************************************************************************/
-/* Photon mouse related functions                                            */
-/*****************************************************************************/
-SDL_Cursor *
-photon_createcursor(SDL_Surface * surface, int hot_x, int hot_y)
-{
-    PhCursorDef_t *internal_cursor;
-    SDL_Cursor *sdl_cursor;
-    uint8_t *image0 = NULL;
-    uint8_t *image1 = NULL;
-    uint32_t it;
-    uint32_t jt;
-    uint32_t shape_color;
-
-    /* SDL converts monochrome cursor shape to 32bpp cursor shape      */
-    /* and we must convert it back to monochrome, this routine handles */
-    /* 24/32bpp surfaces only                                          */
-    if ((surface->format->BitsPerPixel != 32)
-        && (surface->format->BitsPerPixel != 24)) {
-        SDL_SetError("Photon: Cursor shape is not 24/32bpp.");
-        return NULL;
-    }
-
-    /* Checking data parameters */
-    if ((surface->w == 0) || (surface->h == 0)) {
-        SDL_SetError("Photon: Cursor shape dimensions are zero");
-        return NULL;
-    }
-
-    /* Allocate memory for the internal cursor format */
-    internal_cursor = (PhCursorDef_t *) SDL_calloc(1, sizeof(PhCursorDef_t) +
-                                                   ((((surface->w +
-                                                       7) >> 3) *
-                                                     surface->h) * 2) - 1);
-    if (internal_cursor == NULL) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    /* Allocate memory for the SDL cursor */
-    sdl_cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(SDL_Cursor));
-    if (sdl_cursor == NULL) {
-        SDL_free(internal_cursor);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    /* Set driverdata as photon cursor format */
-    image0 = (uint8_t *) internal_cursor;
-    image0 += sizeof(PhCursorDef_t) - 1;
-    image1 = image0;
-    image1 += ((surface->w + 7) >> 3) * surface->h;
-    sdl_cursor->driverdata = (void *) internal_cursor;
-    internal_cursor->hdr.len =
-        (sizeof(PhCursorDef_t) - sizeof(PhRegionDataHdr_t)) +
-        ((((surface->w + 7) >> 3) * surface->h) * 2) - 1;
-    internal_cursor->hdr.type = Ph_RDATA_CURSOR;
-    internal_cursor->size1.x = surface->w;
-    internal_cursor->size1.y = surface->h;
-    internal_cursor->size2.x = surface->w;
-    internal_cursor->size2.y = surface->h;
-    internal_cursor->offset1.x = -hot_x;
-    internal_cursor->offset1.y = -hot_y;
-    internal_cursor->offset2.x = -hot_x;
-    internal_cursor->offset2.y = -hot_y;
-    internal_cursor->bytesperline1 = ((surface->w + 7) >> 3);
-    internal_cursor->bytesperline2 = ((surface->w + 7) >> 3);
-    internal_cursor->color1 = (SDL_PHOTON_MOUSE_COLOR_BLACK) & 0x00FFFFFF;
-    internal_cursor->color2 = (SDL_PHOTON_MOUSE_COLOR_WHITE) & 0x00FFFFFF;
-
-    /* Convert cursor from 32 bpp */
-    for (jt = 0; jt < surface->h; jt++) {
-        for (it = 0; it < surface->w; it++) {
-            shape_color =
-                *((uint32_t *) ((uint8_t *) surface->pixels +
-                                jt * surface->pitch +
-                                it * surface->format->BytesPerPixel));
-            switch (shape_color) {
-            case SDL_PHOTON_MOUSE_COLOR_BLACK:
-                {
-                    *(image0 + jt * (internal_cursor->bytesperline1) +
-                      (it >> 3)) |= 0x80 >> (it % 8);
-                    *(image1 + jt * (internal_cursor->bytesperline2) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                }
-                break;
-            case SDL_PHOTON_MOUSE_COLOR_WHITE:
-                {
-                    *(image0 + jt * (internal_cursor->bytesperline1) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                    *(image1 + jt * (internal_cursor->bytesperline2) +
-                      (it >> 3)) |= 0x80 >> (it % 8);
-                }
-                break;
-            case SDL_PHOTON_MOUSE_COLOR_TRANS:
-                {
-                    *(image0 + jt * (internal_cursor->bytesperline1) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                    *(image1 + jt * (internal_cursor->bytesperline2) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                }
-                break;
-            default:
-                {
-                    /* The same as transparent color, must not happen */
-                    *(image0 + jt * (internal_cursor->bytesperline1) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                    *(image1 + jt * (internal_cursor->bytesperline2) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                }
-                break;
-            }
-        }
-    }
-
-    return sdl_cursor;
-}
-
-int
-photon_showcursor(SDL_Cursor * cursor)
-{
-    SDL_VideoDisplay *display;
-    SDL_DisplayData *didata;
-    SDL_Window *window;
-    SDL_WindowData *wdata;
-    PhCursorDef_t *internal_cursor;
-    int32_t status;
-
-    /* Get current window id */
-    window = SDL_GetFocusWindow();
-    if (!window) {
-        SDL_MouseData *mdata = NULL;
-
-        /* If there is no current window, then someone calls this function */
-        /* to set global mouse settings during SDL initialization          */
-        if (cursor != NULL) {
-            /* Store cursor for future usage */
-            mdata = (SDL_MouseData *) cursor->mouse->driverdata;
-            didata = (SDL_DisplayData *) mdata->didata;
-            internal_cursor = (PhCursorDef_t *) cursor->driverdata;
-
-            if (didata->cursor_size >=
-                (internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t))) {
-                SDL_memcpy(didata->cursor, internal_cursor,
-                           internal_cursor->hdr.len +
-                           sizeof(PhRegionDataHdr_t));
-            } else {
-                /* Partitial cursor image */
-                SDL_memcpy(didata->cursor, internal_cursor,
-                           didata->cursor_size);
-            }
-
-            didata->cursor_visible = SDL_TRUE;
-            return 0;
-        } else {
-            /* We can't get SDL_DisplayData at this point, return fake success */
-            return 0;
-        }
-    } else {
-        /* Sanity checks */
-        display = window->display;
-        if (display != NULL) {
-            didata = (SDL_DisplayData *) display->driverdata;
-            if (didata != NULL) {
-                wdata = (SDL_WindowData *) window->driverdata;
-                if (wdata == NULL) {
-                    return -1;
-                }
-            } else {
-                return -1;
-            }
-        } else {
-            return -1;
-        }
-    }
-
-    /* return if window widget has been destroyed already */
-    if (wdata->window == NULL) {
-        return;
-    }
-
-    /* Check if we need to set new shape or disable cursor shape */
-    if (cursor != NULL) {
-        /* Retrieve photon cursor shape */
-        internal_cursor = (PhCursorDef_t *) cursor->driverdata;
-        if (internal_cursor == NULL) {
-            SDL_SetError("Photon: Internal cursor data is absent");
-            return -1;
-        }
-
-        /* Setup cursor type */
-        status =
-            PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP,
-                          0);
-        if (status != 0) {
-            SDL_SetError("Photon: Failed to set cursor type to bitmap");
-            return -1;
-        }
-
-        /* Setup cursor color to default */
-        status =
-            PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR,
-                          Ph_CURSOR_DEFAULT_COLOR, 0);
-        if (status != 0) {
-            SDL_SetError("Photon: Failed to set cursor color");
-            return -1;
-        }
-
-        /* Setup cursor shape */
-        status =
-            PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR,
-                          internal_cursor,
-                          internal_cursor->hdr.len +
-                          sizeof(PhRegionDataHdr_t));
-        if (status != 0) {
-            SDL_SetError("Photon: Failed to set cursor color");
-            return -1;
-        }
-
-        /* Store current cursor for future usage */
-        if (didata->cursor_size >=
-            (internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t))) {
-            SDL_memcpy(didata->cursor, internal_cursor,
-                       internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t));
-        } else {
-            /* Partitial cursor image */
-            SDL_memcpy(didata->cursor, internal_cursor, didata->cursor_size);
-        }
-
-        /* Set cursor visible */
-        didata->cursor_visible = SDL_TRUE;
-    } else {
-        /* SDL requests to disable cursor */
-        status =
-            PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE,
-                          0);
-        if (status != 0) {
-            SDL_SetError("Photon: Can't disable cursor");
-            return -1;
-        }
-
-        /* Set cursor invisible */
-        didata->cursor_visible = SDL_FALSE;
-    }
-
-    /* Flush all pending widget data */
-    PtFlush();
-
-    /* New cursor shape is set */
-    return 0;
-}
-
-void
-photon_movecursor(SDL_Cursor * cursor)
-{
-    SDL_VideoDisplay *display;
-    SDL_DisplayData *didata;
-    SDL_Window *window;
-    SDL_WindowData *wdata;
-    SDL_WindowID window_id;
-    int32_t status;
-
-    /* Get current window id */
-    window_id = SDL_GetFocusWindow();
-    if (window_id <= 0) {
-        didata = (SDL_DisplayData *) cursor->mouse->driverdata;
-    } else {
-        /* Sanity checks */
-        window = SDL_GetWindowFromID(window_id);
-        if (window != NULL) {
-            display = window->display;
-            if (display != NULL) {
-                didata = (SDL_DisplayData *) display->driverdata;
-                if (didata != NULL) {
-                    wdata = (SDL_WindowData *) window->driverdata;
-                    if (wdata == NULL) {
-                        return;
-                    }
-                } else {
-                    return;
-                }
-            } else {
-                return;
-            }
-        } else {
-            return;
-        }
-    }
-
-    /* No need to move mouse cursor manually in the photon */
-
-    return;
-}
-
-void
-photon_freecursor(SDL_Cursor * cursor)
-{
-    PhCursorDef_t *internal_cursor = NULL;
-
-    if (cursor != NULL) {
-        internal_cursor = (PhCursorDef_t *) cursor->driverdata;
-        if (internal_cursor != NULL) {
-            SDL_free(internal_cursor);
-            cursor->driverdata = NULL;
-        }
-    }
-}
-
-void
-photon_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y)
-{
-    SDL_VideoDisplay *display;
-    SDL_DisplayData *didata;
-    SDL_WindowData *wdata;
-    int16_t wx;
-    int16_t wy;
-
-    /* Sanity checks */
-    if (window != NULL) {
-        display = window->display;
-        if (display != NULL) {
-            didata = (SDL_DisplayData *) display->driverdata;
-            if (didata != NULL) {
-                wdata = (SDL_WindowData *) window->driverdata;
-                if (wdata == NULL) {
-                    return;
-                }
-            } else {
-                return;
-            }
-        } else {
-            return;
-        }
-    } else {
-        return;
-    }
-
-    PtGetAbsPosition(wdata->window, &wx, &wy);
-    PhMoveCursorAbs(PhInputGroup(NULL), wx + x, wy + y);
-
-    return;
-}
-
-void
-photon_freemouse(SDL_Mouse * mouse)
-{
-    if (mouse->driverdata == NULL) {
-        return;
-    }
-
-    /* Mouse framework doesn't deletes automatically our driverdata */
-    SDL_free(mouse->driverdata);
-    mouse->driverdata = NULL;
-
-    return;
-}
-
-SDL_ScanCode
-photon_to_sdl_keymap(uint32_t key)
-{
-    SDL_ScanCode scancode = SDL_SCANCODE_UNKNOWN;
-
-    switch (key & 0x0000007F) {
-    case PHOTON_SCANCODE_ESCAPE:
-        scancode = SDL_SCANCODE_ESCAPE;
-        break;
-    case PHOTON_SCANCODE_F1:
-        scancode = SDL_SCANCODE_F1;
-        break;
-    case PHOTON_SCANCODE_F2:
-        scancode = SDL_SCANCODE_F2;
-        break;
-    case PHOTON_SCANCODE_F3:
-        scancode = SDL_SCANCODE_F3;
-        break;
-    case PHOTON_SCANCODE_F4:
-        scancode = SDL_SCANCODE_F4;
-        break;
-    case PHOTON_SCANCODE_F5:
-        scancode = SDL_SCANCODE_F5;
-        break;
-    case PHOTON_SCANCODE_F6:
-        scancode = SDL_SCANCODE_F6;
-        break;
-    case PHOTON_SCANCODE_F7:
-        scancode = SDL_SCANCODE_F7;
-        break;
-    case PHOTON_SCANCODE_F8:
-        scancode = SDL_SCANCODE_F8;
-        break;
-    case PHOTON_SCANCODE_F9:
-        scancode = SDL_SCANCODE_F9;
-        break;
-    case PHOTON_SCANCODE_F10:
-        scancode = SDL_SCANCODE_F10;
-        break;
-    case PHOTON_SCANCODE_F11:
-        scancode = SDL_SCANCODE_F11;
-        break;
-    case PHOTON_SCANCODE_F12:
-        scancode = SDL_SCANCODE_F12;
-        break;
-    case PHOTON_SCANCODE_BACKQOUTE:
-        scancode = SDL_SCANCODE_GRAVE;
-        break;
-    case PHOTON_SCANCODE_1:
-        scancode = SDL_SCANCODE_1;
-        break;
-    case PHOTON_SCANCODE_2:
-        scancode = SDL_SCANCODE_2;
-        break;
-    case PHOTON_SCANCODE_3:
-        scancode = SDL_SCANCODE_3;
-        break;
-    case PHOTON_SCANCODE_4:
-        scancode = SDL_SCANCODE_4;
-        break;
-    case PHOTON_SCANCODE_5:
-        scancode = SDL_SCANCODE_5;
-        break;
-    case PHOTON_SCANCODE_6:
-        scancode = SDL_SCANCODE_6;
-        break;
-    case PHOTON_SCANCODE_7:
-        scancode = SDL_SCANCODE_7;
-        break;
-    case PHOTON_SCANCODE_8:
-        scancode = SDL_SCANCODE_8;
-        break;
-    case PHOTON_SCANCODE_9:
-        scancode = SDL_SCANCODE_9;
-        break;
-    case PHOTON_SCANCODE_0:
-        scancode = SDL_SCANCODE_0;
-        break;
-    case PHOTON_SCANCODE_MINUS:
-        scancode = SDL_SCANCODE_MINUS;
-        break;
-    case PHOTON_SCANCODE_EQUAL:
-        scancode = SDL_SCANCODE_EQUALS;
-        break;
-    case PHOTON_SCANCODE_BACKSPACE:
-        scancode = SDL_SCANCODE_BACKSPACE;
-        break;
-    case PHOTON_SCANCODE_TAB:
-        scancode = SDL_SCANCODE_TAB;
-        break;
-    case PHOTON_SCANCODE_Q:
-        scancode = SDL_SCANCODE_Q;
-        break;
-    case PHOTON_SCANCODE_W:
-        scancode = SDL_SCANCODE_W;
-        break;
-    case PHOTON_SCANCODE_E:
-        scancode = SDL_SCANCODE_E;
-        break;
-    case PHOTON_SCANCODE_R:
-        scancode = SDL_SCANCODE_R;
-        break;
-    case PHOTON_SCANCODE_T:
-        scancode = SDL_SCANCODE_T;
-        break;
-    case PHOTON_SCANCODE_Y:
-        scancode = SDL_SCANCODE_Y;
-        break;
-    case PHOTON_SCANCODE_U:
-        scancode = SDL_SCANCODE_U;
-        break;
-    case PHOTON_SCANCODE_I:
-        scancode = SDL_SCANCODE_I;
-        break;
-    case PHOTON_SCANCODE_O:
-        scancode = SDL_SCANCODE_O;
-        break;
-    case PHOTON_SCANCODE_P:
-        scancode = SDL_SCANCODE_P;
-        break;
-    case PHOTON_SCANCODE_LEFT_SQ_BR:
-        scancode = SDL_SCANCODE_LEFTBRACKET;
-        break;
-    case PHOTON_SCANCODE_RIGHT_SQ_BR:
-        scancode = SDL_SCANCODE_RIGHTBRACKET;
-        break;
-    case PHOTON_SCANCODE_ENTER:
-        scancode = SDL_SCANCODE_RETURN;
-        break;
-    case PHOTON_SCANCODE_CAPSLOCK:
-        scancode = SDL_SCANCODE_CAPSLOCK;
-        break;
-    case PHOTON_SCANCODE_A:
-        scancode = SDL_SCANCODE_A;
-        break;
-    case PHOTON_SCANCODE_S:
-        scancode = SDL_SCANCODE_S;
-        break;
-    case PHOTON_SCANCODE_D:
-        scancode = SDL_SCANCODE_D;
-        break;
-    case PHOTON_SCANCODE_F:
-        scancode = SDL_SCANCODE_F;
-        break;
-    case PHOTON_SCANCODE_G:
-        scancode = SDL_SCANCODE_G;
-        break;
-    case PHOTON_SCANCODE_H:
-        scancode = SDL_SCANCODE_H;
-        break;
-    case PHOTON_SCANCODE_J:
-        scancode = SDL_SCANCODE_J;
-        break;
-    case PHOTON_SCANCODE_K:
-        scancode = SDL_SCANCODE_K;
-        break;
-    case PHOTON_SCANCODE_L:
-        scancode = SDL_SCANCODE_L;
-        break;
-    case PHOTON_SCANCODE_SEMICOLON:
-        scancode = SDL_SCANCODE_SEMICOLON;
-        break;
-    case PHOTON_SCANCODE_QUOTE:
-        scancode = SDL_SCANCODE_APOSTROPHE;
-        break;
-    case PHOTON_SCANCODE_BACKSLASH:
-        scancode = SDL_SCANCODE_BACKSLASH;
-        break;
-    case PHOTON_SCANCODE_LEFT_SHIFT:
-        scancode = SDL_SCANCODE_LSHIFT;
-        break;
-    case PHOTON_SCANCODE_Z:
-        scancode = SDL_SCANCODE_Z;
-        break;
-    case PHOTON_SCANCODE_X:
-        scancode = SDL_SCANCODE_X;
-        break;
-    case PHOTON_SCANCODE_C:
-        scancode = SDL_SCANCODE_C;
-        break;
-    case PHOTON_SCANCODE_V:
-        scancode = SDL_SCANCODE_V;
-        break;
-    case PHOTON_SCANCODE_B:
-        scancode = SDL_SCANCODE_B;
-        break;
-    case PHOTON_SCANCODE_N:
-        scancode = SDL_SCANCODE_N;
-        break;
-    case PHOTON_SCANCODE_M:
-        scancode = SDL_SCANCODE_M;
-        break;
-    case PHOTON_SCANCODE_COMMA:
-        scancode = SDL_SCANCODE_COMMA;
-        break;
-    case PHOTON_SCANCODE_POINT:
-        scancode = SDL_SCANCODE_PERIOD;
-        break;
-    case PHOTON_SCANCODE_SLASH:
-        scancode = SDL_SCANCODE_SLASH;
-        break;
-    case PHOTON_SCANCODE_RIGHT_SHIFT:
-        scancode = SDL_SCANCODE_RSHIFT;
-        break;
-    case PHOTON_SCANCODE_CTRL:
-        scancode = SDL_SCANCODE_LCTRL;
-        break;
-    case PHOTON_SCANCODE_WFLAG:
-        scancode = SDL_SCANCODE_LGUI;
-        break;
-    case PHOTON_SCANCODE_ALT:
-        scancode = SDL_SCANCODE_LALT;
-        break;
-    case PHOTON_SCANCODE_SPACE:
-        scancode = SDL_SCANCODE_SPACE;
-        break;
-    case PHOTON_SCANCODE_MENU:
-        scancode = SDL_SCANCODE_MENU;
-        break;
-    case PHOTON_SCANCODE_PRNSCR:
-        scancode = SDL_SCANCODE_PRINTSCREEN;
-        break;
-    case PHOTON_SCANCODE_SCROLLLOCK:
-        scancode = SDL_SCANCODE_SCROLLLOCK;
-        break;
-    case PHOTON_SCANCODE_INSERT:
-        scancode = SDL_SCANCODE_INSERT;
-        break;
-    case PHOTON_SCANCODE_HOME:
-        scancode = SDL_SCANCODE_HOME;
-        break;
-    case PHOTON_SCANCODE_PAGEUP:
-        scancode = SDL_SCANCODE_PAGEUP;
-        break;
-    case PHOTON_SCANCODE_DELETE:
-        scancode = SDL_SCANCODE_DELETE;
-        break;
-    case PHOTON_SCANCODE_END:
-        scancode = SDL_SCANCODE_END;
-        break;
-    case PHOTON_SCANCODE_PAGEDOWN:
-        scancode = SDL_SCANCODE_PAGEDOWN;
-        break;
-    case PHOTON_SCANCODE_UP:
-        scancode = SDL_SCANCODE_UP;
-        break;
-    case PHOTON_SCANCODE_DOWN:
-        scancode = SDL_SCANCODE_DOWN;
-        break;
-    case PHOTON_SCANCODE_LEFT:
-        scancode = SDL_SCANCODE_LEFT;
-        break;
-    case PHOTON_SCANCODE_RIGHT:
-        scancode = SDL_SCANCODE_RIGHT;
-        break;
-    case PHOTON_SCANCODE_NUMLOCK:
-        scancode = SDL_SCANCODE_NUMLOCKCLEAR;
-        break;
-    default:
-        break;
-    }
-
-    return scancode;
-}
--- a/src/video/photon/SDL_photon_input.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Photon GUI SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_PHOTON_INPUT_H__
-#define __SDL_PHOTON_INPUT_H__
-
-#include "SDL_config.h"
-#include "SDL_video.h"
-#include "../SDL_sysvideo.h"
-
-#include "SDL_photon.h"
-
-typedef struct SDL_MouseData
-{
-    SDL_DisplayData *didata;
-} SDL_MouseData;
-
-int32_t photon_addinputdevices(_THIS);
-int32_t photon_delinputdevices(_THIS);
-
-#define SDL_PHOTON_MOUSE_COLOR_BLACK 0xFF000000
-#define SDL_PHOTON_MOUSE_COLOR_WHITE 0xFFFFFFFF
-#define SDL_PHOTON_MOUSE_COLOR_TRANS 0x00000000
-
-SDL_ScanCode photon_to_sdl_keymap(uint32_t key);
-
-#endif /* __SDL_GF_INPUT_H__ */
--- a/src/video/photon/SDL_photon_keycodes.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Photon GUI SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_PHOTON_KEYCODES_H__
-#define __SDL_PHOTON_KEYCODES_H__
-
-#define PHOTON_SCANCODE_ESCAPE      0x01
-#define PHOTON_SCANCODE_F1          0x3B
-#define PHOTON_SCANCODE_F2          0x3C
-#define PHOTON_SCANCODE_F3          0x3D
-#define PHOTON_SCANCODE_F4          0x3E
-#define PHOTON_SCANCODE_F5          0x3F
-#define PHOTON_SCANCODE_F6          0x40
-#define PHOTON_SCANCODE_F7          0x41
-#define PHOTON_SCANCODE_F8          0x42
-#define PHOTON_SCANCODE_F9          0x43
-#define PHOTON_SCANCODE_F10         0x44
-#define PHOTON_SCANCODE_F11         0x57
-#define PHOTON_SCANCODE_F12         0x58
-
-#define PHOTON_SCANCODE_BACKQOUTE   0x29
-#define PHOTON_SCANCODE_1           0x02
-#define PHOTON_SCANCODE_2           0x03
-#define PHOTON_SCANCODE_3           0x04
-#define PHOTON_SCANCODE_4           0x05
-#define PHOTON_SCANCODE_5           0x06
-#define PHOTON_SCANCODE_6           0x07
-#define PHOTON_SCANCODE_7           0x08
-#define PHOTON_SCANCODE_8           0x09
-#define PHOTON_SCANCODE_9           0x0A
-#define PHOTON_SCANCODE_0           0x0B
-#define PHOTON_SCANCODE_MINUS       0x0C
-#define PHOTON_SCANCODE_EQUAL       0x0D
-#define PHOTON_SCANCODE_BACKSPACE   0x0E
-
-#define PHOTON_SCANCODE_TAB         0x0F
-#define PHOTON_SCANCODE_Q           0x10
-#define PHOTON_SCANCODE_W           0x11
-#define PHOTON_SCANCODE_E           0x12
-#define PHOTON_SCANCODE_R           0x13
-#define PHOTON_SCANCODE_T           0x14
-#define PHOTON_SCANCODE_Y           0x15
-#define PHOTON_SCANCODE_U           0x16
-#define PHOTON_SCANCODE_I           0x17
-#define PHOTON_SCANCODE_O           0x18
-#define PHOTON_SCANCODE_P           0x19
-#define PHOTON_SCANCODE_LEFT_SQ_BR  0x1A
-#define PHOTON_SCANCODE_RIGHT_SQ_BR 0x1B
-#define PHOTON_SCANCODE_ENTER       0x1C
-
-#define PHOTON_SCANCODE_CAPSLOCK    0x3A
-#define PHOTON_SCANCODE_A           0x1E
-#define PHOTON_SCANCODE_S           0x1F
-#define PHOTON_SCANCODE_D           0x20
-#define PHOTON_SCANCODE_F           0x21
-#define PHOTON_SCANCODE_G           0x22
-#define PHOTON_SCANCODE_H           0x23
-#define PHOTON_SCANCODE_J           0x24
-#define PHOTON_SCANCODE_K           0x25
-#define PHOTON_SCANCODE_L           0x26
-#define PHOTON_SCANCODE_SEMICOLON   0x27
-#define PHOTON_SCANCODE_QUOTE       0x28
-#define PHOTON_SCANCODE_BACKSLASH   0x2B
-
-#define PHOTON_SCANCODE_LEFT_SHIFT  0x2A
-#define PHOTON_SCANCODE_Z           0x2C
-#define PHOTON_SCANCODE_X           0x2D
-#define PHOTON_SCANCODE_C           0x2E
-#define PHOTON_SCANCODE_V           0x2F
-#define PHOTON_SCANCODE_B           0x30
-#define PHOTON_SCANCODE_N           0x31
-#define PHOTON_SCANCODE_M           0x32
-#define PHOTON_SCANCODE_COMMA       0x33
-#define PHOTON_SCANCODE_POINT       0x34
-#define PHOTON_SCANCODE_SLASH       0x35
-#define PHOTON_SCANCODE_RIGHT_SHIFT 0x36
-
-#define PHOTON_SCANCODE_CTRL        0x1D
-#define PHOTON_SCANCODE_WFLAG       0x5B
-#define PHOTON_SCANCODE_ALT         0x38
-#define PHOTON_SCANCODE_SPACE       0x39
-#define PHOTON_SCANCODE_MENU        0x5D
-
-#define PHOTON_SCANCODE_PRNSCR      0x54        /* only key pressed event, no release */
-#define PHOTON_SCANCODE_SCROLLLOCK  0x46
-#if 0                                           /* pause doesn't generates a scancode */
-#define PHOTON_SCANCODE_PAUSE       0x??
-#endif
-#define PHOTON_SCANCODE_INSERT      0x52
-#define PHOTON_SCANCODE_HOME        0x47
-#define PHOTON_SCANCODE_PAGEUP      0x49
-#define PHOTON_SCANCODE_DELETE      0x53
-#define PHOTON_SCANCODE_END         0x4F
-#define PHOTON_SCANCODE_PAGEDOWN    0x51
-#define PHOTON_SCANCODE_UP          0x48
-#define PHOTON_SCANCODE_DOWN        0x50
-#define PHOTON_SCANCODE_LEFT        0x4B
-#define PHOTON_SCANCODE_RIGHT       0x4D
-
-#define PHOTON_SCANCODE_NUMLOCK     0x45
-
-#endif /* __SDL_PHOTON_KEYCODES_H__ */
--- a/src/video/photon/SDL_photon_pixelfmt.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,218 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Photon GUI SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#include "SDL_photon_pixelfmt.h"
-
-uint32_t
-photon_bits_to_sdl_pixelformat(uint32_t pixelfmt)
-{
-    switch (pixelfmt) {
-    case 8:
-        {
-            return SDL_PIXELFORMAT_INDEX8;
-        }
-        break;
-    case 15:
-        {
-            return SDL_PIXELFORMAT_ARGB1555;
-        }
-        break;
-    case 16:
-        {
-            return SDL_PIXELFORMAT_RGB565;
-        }
-        break;
-    case 24:
-        {
-            return SDL_PIXELFORMAT_RGB888;
-        }
-        break;
-    case 32:
-        {
-            return SDL_PIXELFORMAT_ARGB8888;
-        }
-        break;
-    }
-}
-
-uint32_t
-photon_sdl_to_bits_pixelformat(uint32_t pixelfmt)
-{
-    switch (pixelfmt) {
-    case SDL_PIXELFORMAT_INDEX8:
-        {
-            return 8;
-        }
-        break;
-    case SDL_PIXELFORMAT_ARGB1555:
-        {
-            return 15;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB555:
-        {
-            return 15;
-        }
-        break;
-    case SDL_PIXELFORMAT_ABGR1555:
-        {
-            return 15;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB565:
-        {
-            return 16;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB24:
-        {
-            return 24;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB888:
-        {
-            return 32;
-        }
-        break;
-    case SDL_PIXELFORMAT_BGRA8888:
-        {
-            return 32;
-        }
-        break;
-    case SDL_PIXELFORMAT_ARGB8888:
-        {
-            return 32;
-        }
-        break;
-    case SDL_PIXELFORMAT_YV12:
-        {
-            return 8;
-        }
-        break;
-    case SDL_PIXELFORMAT_YUY2:
-        {
-            return 16;
-        }
-        break;
-    case SDL_PIXELFORMAT_UYVY:
-        {
-            return 16;
-        }
-        break;
-    case SDL_PIXELFORMAT_YVYU:
-        {
-            return 16;
-        }
-        break;
-    }
-
-    return 0;
-}
-
-uint32_t
-photon_image_to_sdl_pixelformat(uint32_t pixelfmt)
-{
-    switch (pixelfmt) {
-    case Pg_IMAGE_PALETTE_BYTE:
-        {
-            return SDL_PIXELFORMAT_INDEX8;
-        }
-        break;
-    case Pg_IMAGE_DIRECT_8888:
-        {
-            return SDL_PIXELFORMAT_ARGB8888;
-        }
-        break;
-    case Pg_IMAGE_DIRECT_888:
-        {
-            return SDL_PIXELFORMAT_RGB24;
-        }
-        break;
-    case Pg_IMAGE_DIRECT_565:
-        {
-            return SDL_PIXELFORMAT_RGB565;
-        }
-        break;
-    case Pg_IMAGE_DIRECT_555:
-        {
-            return SDL_PIXELFORMAT_RGB555;
-        }
-        break;
-    case Pg_IMAGE_DIRECT_1555:
-        {
-            return SDL_PIXELFORMAT_ARGB1555;
-        }
-        break;
-    }
-
-    return 0;
-}
-
-uint32_t
-photon_sdl_to_image_pixelformat(uint32_t pixelfmt)
-{
-    switch (pixelfmt) {
-    case SDL_PIXELFORMAT_INDEX8:
-        {
-            return Pg_IMAGE_PALETTE_BYTE;
-        }
-        break;
-    case SDL_PIXELFORMAT_ARGB8888:
-        {
-            return Pg_IMAGE_DIRECT_8888;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB888:
-        {
-            return Pg_IMAGE_DIRECT_8888;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB24:
-        {
-            return Pg_IMAGE_DIRECT_888;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB565:
-        {
-            return Pg_IMAGE_DIRECT_565;
-        }
-        break;
-    case SDL_PIXELFORMAT_ARGB1555:
-        {
-            return Pg_IMAGE_DIRECT_1555;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB555:
-        {
-            return Pg_IMAGE_DIRECT_555;
-        }
-        break;
-    }
-
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/photon/SDL_photon_pixelfmt.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Photon GUI SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#include "SDL_config.h"
-#include "../SDL_sysvideo.h"
-
-#include <Ph.h>
-
-#ifndef __SDL_PHOTON_PIXELFMT_H__
-#define __SDL_PHOTON_PIXELFMT_H__
-
-uint32_t photon_bits_to_sdl_pixelformat(uint32_t pixelfmt);
-uint32_t photon_sdl_to_bits_pixelformat(uint32_t pixelfmt);
-uint32_t photon_image_to_sdl_pixelformat(uint32_t pixelfmt);
-uint32_t photon_sdl_to_image_pixelformat(uint32_t pixelfmt);
-
-#endif /* __SDL_PHOTON_PIXELFMT_H__ */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/photon/SDL_photon_render.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1690 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Photon GUI SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#include "SDL_config.h"
-
-#include "../SDL_pixels_c.h"
-#include "../SDL_yuv_sw_c.h"
-
-#include "SDL_video.h"
-
-#include "SDL_photon_render.h"
-#include "SDL_photon.h"
-
-#ifndef Pg_OSC_MEM_LINEAR_ACCESSIBLE
-    /* For QNX 6.3.2 compatibility */
-    #define Pg_OSC_MEM_LINEAR_ACCESSIBLE 0
-#endif /* Pg_OSC_MEM_LINEAR_ACCESSIBLE */
-
-static SDL_Renderer *photon_createrenderer(SDL_Window * window, Uint32 flags);
-static int photon_displaymodechanged(SDL_Renderer * renderer);
-static int photon_activaterenderer(SDL_Renderer * renderer);
-static int photon_createtexture(SDL_Renderer * renderer,
-                                SDL_Texture * texture);
-static int photon_querytexturepixels(SDL_Renderer * renderer,
-                                     SDL_Texture * texture, void **pixels,
-                                     int *pitch);
-static int photon_settexturepalette(SDL_Renderer * renderer,
-                                    SDL_Texture * texture,
-                                    const SDL_Color * colors, int firstcolor,
-                                    int ncolors);
-static int photon_gettexturepalette(SDL_Renderer * renderer,
-                                    SDL_Texture * texture, SDL_Color * colors,
-                                    int firstcolor, int ncolors);
-static int photon_settexturecolormod(SDL_Renderer * renderer,
-                                     SDL_Texture * texture);
-static int photon_settexturealphamod(SDL_Renderer * renderer,
-                                     SDL_Texture * texture);
-static int photon_settextureblendmode(SDL_Renderer * renderer,
-                                      SDL_Texture * texture);
-static int photon_settexturescalemode(SDL_Renderer * renderer,
-                                      SDL_Texture * texture);
-static int photon_updatetexture(SDL_Renderer * renderer,
-                                SDL_Texture * texture, const SDL_Rect * rect,
-                                const void *pixels, int pitch);
-static int photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                              const SDL_Rect * rect, int markDirty,
-                              void **pixels, int *pitch);
-static void photon_unlocktexture(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
-static void photon_dirtytexture(SDL_Renderer * renderer,
-                                SDL_Texture * texture, int numrects,
-                                const SDL_Rect * rects);
-static int photon_setdrawcolor(SDL_Renderer * renderer);
-static int photon_setdrawblendmode(SDL_Renderer * renderer);
-static int photon_renderpoint(SDL_Renderer * renderer, int x, int y);
-static int photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2,
-                             int y2);
-static int photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect);
-static int photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                             const SDL_Rect * srcrect,
-                             const SDL_Rect * dstrect);
-static int photon_renderreadpixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                   Uint32 format, void * pixels, int pitch);
-static int photon_renderwritepixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                    Uint32 format, const void * pixels, int pitch);
-static void photon_renderpresent(SDL_Renderer * renderer);
-static void photon_destroytexture(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static void photon_destroyrenderer(SDL_Renderer * renderer);
-
-static int _photon_recreate_surfaces(SDL_Renderer * renderer);
-
-SDL_RenderDriver photon_renderdriver = {
-    photon_createrenderer,
-    {
-     "photon",
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
-      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
-      SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
-      SDL_RENDERER_ACCELERATED),
-     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA),
-     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND |
-      SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
-     (SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW | SDL_SCALEMODE_FAST),
-     10,
-     {SDL_PIXELFORMAT_INDEX8,
-      SDL_PIXELFORMAT_RGB555,
-      SDL_PIXELFORMAT_RGB565,
-      SDL_PIXELFORMAT_RGB24,
-      SDL_PIXELFORMAT_RGB888,
-      SDL_PIXELFORMAT_ARGB8888,
-      SDL_PIXELFORMAT_YV12,
-      SDL_PIXELFORMAT_YUY2,
-      SDL_PIXELFORMAT_UYVY,
-      SDL_PIXELFORMAT_YVYU},
-     0,
-     0}
-};
-
-static SDL_Renderer *
-photon_createrenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_VideoDisplay *display = window->display;
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    SDL_Renderer *renderer = NULL;
-    SDL_RenderData *rdata = NULL;
-
-    /* Allocate new renderer structure */
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer));
-    if (renderer == NULL) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    /* Allocate renderer data */
-    rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData));
-    if (rdata == NULL) {
-        SDL_free(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    renderer->DisplayModeChanged = photon_displaymodechanged;
-    renderer->ActivateRenderer = photon_activaterenderer;
-    renderer->CreateTexture = photon_createtexture;
-    renderer->QueryTexturePixels = photon_querytexturepixels;
-    renderer->SetTexturePalette = photon_settexturepalette;
-    renderer->GetTexturePalette = photon_gettexturepalette;
-    renderer->SetTextureAlphaMod = photon_settexturealphamod;
-    renderer->SetTextureColorMod = photon_settexturecolormod;
-    renderer->SetTextureBlendMode = photon_settextureblendmode;
-    renderer->SetTextureScaleMode = photon_settexturescalemode;
-    renderer->UpdateTexture = photon_updatetexture;
-    renderer->LockTexture = photon_locktexture;
-    renderer->UnlockTexture = photon_unlocktexture;
-    renderer->DirtyTexture = photon_dirtytexture;
-    renderer->SetDrawColor = photon_setdrawcolor;
-    renderer->SetDrawBlendMode = photon_setdrawblendmode;
-    renderer->RenderPoint = photon_renderpoint;
-    renderer->RenderLine = photon_renderline;
-    renderer->RenderFill = photon_renderfill;
-    renderer->RenderCopy = photon_rendercopy;
-    renderer->RenderReadPixels = photon_renderreadpixels;
-    renderer->RenderWritePixels = photon_renderwritepixels;
-    renderer->RenderPresent = photon_renderpresent;
-    renderer->DestroyTexture = photon_destroytexture;
-    renderer->DestroyRenderer = photon_destroyrenderer;
-    renderer->info = photon_renderdriver.info;
-    renderer->window = window;
-    renderer->driverdata = rdata;
-
-    /* Copy direct_mode status */
-    rdata->direct_mode=didata->direct_mode;
-
-    /* Set render acceleration flag in case it is accelerated */
-    if ((didata->caps & SDL_PHOTON_ACCELERATED) == SDL_PHOTON_ACCELERATED) {
-        renderer->info.flags = SDL_RENDERER_ACCELERATED;
-    } else {
-        renderer->info.flags = 0;
-    }
-
-    /* Check if upper level requested synchronization on vsync signal */
-    if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) {
-        if (rdata->direct_mode==SDL_TRUE)
-        {
-           /* We can control vsync only in direct mode */
-           rdata->enable_vsync = SDL_TRUE;
-           renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
-        }
-        else
-        {
-           rdata->enable_vsync = SDL_FALSE;
-        }
-    } else {
-        rdata->enable_vsync = SDL_FALSE;
-    }
-
-    /* Check what buffer copy/flip scheme is requested */
-    rdata->surfaces_count = 0;
-    if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) {
-        if ((flags & SDL_RENDERER_PRESENTDISCARD) ==
-            SDL_RENDERER_PRESENTDISCARD) {
-            renderer->info.flags |=
-                SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD;
-        } else {
-            renderer->info.flags |=
-                SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
-        }
-        rdata->surfaces_count = 1;
-        rdata->surface_visible_idx = 0;
-        rdata->surface_render_idx = 0;
-    } else {
-        if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) {
-            renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
-            rdata->surfaces_count = 2;
-            rdata->surface_visible_idx = 0;
-            rdata->surface_render_idx = 1;
-        } else {
-            if ((flags & SDL_RENDERER_PRESENTFLIP3) ==
-                SDL_RENDERER_PRESENTFLIP3) {
-                renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
-                rdata->surfaces_count = 3;
-                rdata->surface_visible_idx = 0;
-                rdata->surface_render_idx = 1;
-            } else {
-                renderer->info.flags |=
-                    SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
-                rdata->surfaces_count = 1;
-                rdata->surface_visible_idx = 0;
-                rdata->surface_render_idx = 0;
-            }
-        }
-    }
-
-    /* Create new graphics context for the renderer */
-    if (rdata->gc==NULL)
-    {
-       rdata->gc=PgCreateGC(0);
-       PgDefaultGC(rdata->gc);
-    }
-
-    /* Setup textures supported by current renderer instance */
-    renderer->info.num_texture_formats=1;
-    renderer->info.texture_formats[0]=didata->current_mode.format;
-
-    /* Initialize surfaces */
-    _photon_recreate_surfaces(renderer);
-
-    /* Set current scale blitting capabilities */
-    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN)
-    {
-       renderer->info.scale_modes=SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW;
-       if ((didata->mode_2dcaps & SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)==SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)
-       {
-          /* This video mode supports hardware scaling */
-          renderer->info.scale_modes|=SDL_SCALEMODE_FAST;
-       }
-    }
-    else
-    {
-       /* PhImage blit functions do not support scaling */
-       renderer->info.scale_modes=SDL_SCALEMODE_NONE;
-    }
-
-    return renderer;
-}
-
-void
-photon_addrenderdriver(_THIS)
-{
-    uint32_t it;
-
-    for (it = 0; it < _this->num_displays; it++) {
-        SDL_AddRenderDriver(&_this->displays[it], &photon_renderdriver);
-    }
-}
-
-/****************************************************************************/
-/* Renderer helper functions                                                  */
-/****************************************************************************/
-
-static int _photon_recreate_surfaces(SDL_Renderer * renderer)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-    SDL_VideoDisplay *display = NULL;
-    SDL_DisplayData *didata = NULL;
-    SDL_Window *window = NULL;
-    SDL_WindowData *wdata = NULL;
-    SDL_VideoData *phdata = NULL;
-    uint32_t allocate_task=SDL_PHOTON_SURFTYPE_UNKNOWN;
-    int32_t status;
-
-    /* Obtain window and display structures */
-    window=SDL_GetWindowFromID(renderer->window);
-    wdata=(SDL_WindowData*)window->driverdata;
-    display=window->display;
-    didata=(SDL_DisplayData *) display->driverdata;
-    phdata=(SDL_VideoData *) display->device->driverdata;
-
-    /* Check if it is OpenGL ES window */
-    if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) {
-        /* If so, do not waste surfaces */
-        rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN;
-        return 0;
-    }
-
-    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-    {
-       /* Try to allocate offscreen surfaces */
-       allocate_task=SDL_PHOTON_SURFTYPE_OFFSCREEN;
-    }
-    else
-    {
-       uint32_t it;
-
-       if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN)
-       {
-          /* Create offscreen surfaces */
-          allocate_task=SDL_PHOTON_SURFTYPE_OFFSCREEN;
-
-          /* Before destroying surfaces, be sure, that rendering was completed */
-          PgFlush();
-          PgWaitHWIdle();
-
-          /* Destroy current surfaces */
-          for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++)
-          {
-             if (rdata->osurfaces[it] != NULL)
-             {
-                PhDCRelease(rdata->osurfaces[it]);
-                rdata->osurfaces[it] = NULL;
-             }
-          }
-       }
-       else
-       {
-          if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_PHIMAGE)
-          {
-             /* Create shared phimage surfaces */
-             allocate_task=SDL_PHOTON_SURFTYPE_PHIMAGE;
-
-             /* Destroy current surfaces */
-             for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++)
-             {
-                if (rdata->pcontexts[it]!=NULL)
-                {
-                   PmMemReleaseMC(rdata->pcontexts[it]);
-                   rdata->pcontexts[it]=NULL;
-                }
-                if (rdata->psurfaces[it]!=NULL)
-                {
-                   if (rdata->psurfaces[it]->palette!=NULL)
-                   {
-                      SDL_free(rdata->psurfaces[it]->palette);
-                      rdata->psurfaces[it]->palette=NULL;
-                   }
-                   /* Destroy shared memory for PhImage_t */
-                   PgShmemDestroy(rdata->psurfaces[it]->image);
-                   rdata->psurfaces[it]->image=NULL;
-                   SDL_free(rdata->psurfaces[it]);
-                   rdata->psurfaces[it]=NULL;
-                }
-             }
-          }
-       }
-    }
-
-    /* Check if current device is not the same as target */
-    if (phdata->current_device_id != didata->device_id) {
-        /* Set target device as default for Pd and Pg functions */
-        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
-        if (status != 0) {
-            SDL_SetError("Photon: Can't set default target device\n");
-            return -1;
-        }
-        phdata->current_device_id = didata->device_id;
-    }
-
-    switch (allocate_task)
-    {
-       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-            {
-               int32_t it;
-               int32_t jt;
-
-               /* Try the hardware accelerated offscreen surfaces first */
-               for (it=0; it<rdata->surfaces_count; it++)
-               {
-                  rdata->osurfaces[it]=PdCreateOffscreenContext(0, window->w, window->h,
-                  Pg_OSC_MEM_LINEAR_ACCESSIBLE | Pg_OSC_MEM_PAGE_ALIGN |
-                  /* in case if 2D acceleration is available use it */
-                  Pg_OSC_MEM_2D_WRITABLE | Pg_OSC_MEM_2D_READABLE);
-                  /* If we can't create an offscreen surface, then fallback to software */
-                  if (rdata->osurfaces[it]==NULL)
-                  {
-                     /* Destroy previously allocated surface(s) */
-                     for (jt = it - 1; jt > 0; jt--)
-                     {
-                        PhDCRelease(rdata->osurfaces[jt]);
-                        rdata->osurfaces[jt] = NULL;
-                     }
-                     break;
-                  }
-               }
-
-               /* Check if all required surfaces have been created */
-               if (rdata->osurfaces[0]!=NULL)
-               {
-                  rdata->surfaces_type=SDL_PHOTON_SURFTYPE_OFFSCREEN;
-                  /* exit from switch if surfaces have been created */
-                  break;
-               }
-               else
-               {
-                  /* else fall through to software phimage surface allocation */
-               }
-            }
-            /* fall through */
-       case SDL_PHOTON_SURFTYPE_PHIMAGE:
-            {
-               int32_t it;
-               int32_t jt;
-               uint32_t image_pfmt=photon_sdl_to_image_pixelformat(didata->current_mode.format);
-
-               /* Try to allocate the software surfaces in shared memory */
-               for (it=0; it<rdata->surfaces_count; it++)
-               {
-                  /* If this surface with palette, create a palette space */
-                  if (image_pfmt==Pg_IMAGE_PALETTE_BYTE)
-                  {
-                     rdata->psurfaces[it]=PhCreateImage(NULL, window->w, window->h,
-                        image_pfmt, NULL, 256, 1);
-                  }
-                  else
-                  {
-                     rdata->psurfaces[it]=PhCreateImage(NULL, window->w, window->h,
-                        image_pfmt, NULL, 0, 1);
-                  }
-
-                  if (rdata->psurfaces[it]!=NULL)
-                  {
-                     PhPoint_t translation={0, 0};
-                     PhDim_t   dimension={window->w, window->h};
-
-                     /* Create memory context for PhImage_t */
-                     rdata->pcontexts[it]=PmMemCreateMC(rdata->psurfaces[it], &dimension, &translation);
-                  }
-
-                  if ((rdata->psurfaces[it]==NULL) || (rdata->pcontexts[it]==NULL))
-                  {
-                     /* Destroy previously allocated surface(s) */
-                     for (jt = it - 1; jt > 0; jt--)
-                     {
-                        if (rdata->pcontexts[jt]!=NULL)
-                        {
-                           PmMemReleaseMC(rdata->pcontexts[it]);
-                           rdata->pcontexts[jt]=NULL;
-                        }
-                        if (rdata->psurfaces[jt]!=NULL)
-                        {
-                           if (rdata->psurfaces[jt]->palette!=NULL)
-                           {
-                              SDL_free(rdata->psurfaces[jt]->palette);
-                              rdata->psurfaces[jt]->palette=NULL;
-                           }
-                           /* Destroy shared memory for PhImage_t */
-                           PgShmemDestroy(rdata->psurfaces[jt]->image);
-                           rdata->psurfaces[jt]->image=NULL;
-                           SDL_free(rdata->psurfaces[jt]);
-                           rdata->psurfaces[jt] = NULL;
-                        }
-                     }
-                     break;
-                  }
-               }
-
-               /* Check if all required surfaces have been created */
-               if (rdata->psurfaces[0]!=NULL)
-               {
-                  rdata->surfaces_type=SDL_PHOTON_SURFTYPE_PHIMAGE;
-               }
-               else
-               {
-                  rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN;
-               }
-            }
-            break;
-       case SDL_PHOTON_SURFTYPE_UNKNOWN:
-       default:
-            {
-               /* do nothing with surface allocation */
-               rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN;
-            }
-            break;
-    }
-
-    /* Check if one of two allocation scheme was successful */
-    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-    {
-       SDL_SetError("Photon: primary surface(s) allocation failure");
-       return -1;
-    }
-
-    /* Store current surface dimensions */
-    rdata->window_width=window->w;
-    rdata->window_height=window->h;
-
-    /* If current copy/flip scheme is single buffer, then set initial parameters */
-    if ((renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)==SDL_RENDERER_SINGLEBUFFER)
-    {
-       rdata->surface_visible_idx = 0;
-       rdata->surface_render_idx = 0;
-    }
-
-    /* If current copy/flip scheme is double buffer, then set initial parameters */
-    if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP2)==SDL_RENDERER_PRESENTFLIP2)
-    {
-       rdata->surface_visible_idx = 0;
-       rdata->surface_render_idx = 1;
-    }
-
-    /* If current copy/flip scheme is triple buffer, then set initial parameters */
-    if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP3)==SDL_RENDERER_PRESENTFLIP3)
-    {
-       rdata->surface_visible_idx = 0;
-       rdata->surface_render_idx = 1;
-    }
-
-    switch (rdata->surfaces_type)
-    {
-       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-            PgSetGCCx(rdata->osurfaces[rdata->surface_render_idx], rdata->gc);
-            break;
-       case SDL_PHOTON_SURFTYPE_PHIMAGE:
-            PgSetGCCx(rdata->pcontexts[rdata->surface_render_idx], rdata->gc);
-            break;
-       case SDL_PHOTON_SURFTYPE_UNKNOWN:
-       default:
-            break;
-    }
-
-    return 0;
-}
-
-int _photon_update_rectangles(SDL_Renderer* renderer, PhRect_t* rect)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-   SDL_Window *window = window=SDL_GetWindowFromID(renderer->window);
-   SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-   PhPoint_t src_point;
-
-   /* If currently single buffer is in use, we have to flush all data */
-   if (rdata->surface_render_idx==rdata->surface_visible_idx)
-   {
-      /* Flush all undrawn graphics data to surface */
-      switch (rdata->surfaces_type)
-      {
-          case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-               PgFlushCx(rdata->osurfaces[rdata->surface_visible_idx]);
-               PgWaitHWIdle();
-               break;
-          case SDL_PHOTON_SURFTYPE_PHIMAGE:
-               PmMemFlush(rdata->pcontexts[rdata->surface_visible_idx], rdata->psurfaces[rdata->surface_visible_idx]);
-               break;
-          case SDL_PHOTON_SURFTYPE_UNKNOWN:
-          default:
-               return;
-      }
-   }
-
-   PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window));
-
-   src_point.x = rect->ul.x;
-   src_point.y = rect->ul.y;
-
-   switch (rdata->surfaces_type)
-   {
-       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-            PgContextBlit(rdata->osurfaces[rdata->surface_visible_idx], rect, NULL, rect);
-            break;
-       case SDL_PHOTON_SURFTYPE_PHIMAGE:
-            PgDrawPhImageRectv(&src_point, rdata->psurfaces[rdata->surface_visible_idx], rect, 0);
-            break;
-       case SDL_PHOTON_SURFTYPE_UNKNOWN:
-       default:
-            break;
-   }
-}
-
-int _photon_set_blending(SDL_Renderer* renderer, uint32_t blendmode, uint32_t globalalpha, uint32_t blendsource)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-   /* Switch on requested graphics context modifiers */
-   switch (blendmode)
-   {
-      case SDL_BLENDMODE_MASK:
-           /* Enable and set chroma key */
-           if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
-           {
-              PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
-              PgChromaOnCx(rdata->gc);
-           }
-           break;
-      case SDL_BLENDMODE_BLEND:
-           /* Enable and set chroma key and alpha blending */
-           if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
-           {
-              PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
-              PgChromaOnCx(rdata->gc);
-           }
-           PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1mAs, NULL, NULL, globalalpha, 0);
-           PgAlphaOnCx(rdata->gc);
-           break;
-      case SDL_BLENDMODE_ADD:
-           /* Enable and set chroma key and alpha blending */
-           if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
-           {
-              PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
-              PgChromaOnCx(rdata->gc);
-           }
-           PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1, NULL, NULL, globalalpha, 0);
-           PgAlphaOnCx(rdata->gc);
-           break;
-      case SDL_BLENDMODE_MOD:
-           /* Enable and set alpha blending */
-           PgSetAlphaCx(rdata->gc, Pg_BLEND_SRC_0 | Pg_BLEND_DST_S, NULL, NULL, 0, 0);
-           PgAlphaOnCx(rdata->gc);
-           break;
-      case SDL_BLENDMODE_NONE:
-           /* Do nothing */
-           break;
-      default:
-           return -1;
-   }
-
-   return 0;
-}
-
-int _photon_reset_blending(SDL_Renderer* renderer, uint32_t blendmode, uint32_t blendsource)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-   /* Switch off graphics context modifiers */
-   switch (blendmode)
-   {
-      case SDL_BLENDMODE_MASK:
-           /* Disable chroma key */
-           if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
-           {
-              PgChromaOffCx(rdata->gc);
-           }
-           break;
-      case SDL_BLENDMODE_BLEND:
-           /* Disable chroma key and alpha blending */
-           if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
-           {
-              PgChromaOffCx(rdata->gc);
-           }
-           PgAlphaOffCx(rdata->gc);
-           break;
-      case SDL_BLENDMODE_ADD:
-           /* Disable chroma key and alpha blending */
-           if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
-           {
-              PgChromaOffCx(rdata->gc);
-           }
-           PgAlphaOffCx(rdata->gc);
-           break;
-      case SDL_BLENDMODE_MOD:
-           /* Disable chroma key and alpha blending */
-           PgAlphaOffCx(rdata->gc);
-           break;
-      case SDL_BLENDMODE_NONE:
-           /* Do nothing */
-           break;
-      default:
-           return -1;
-   }
-
-   return 0;
-}
-
-/****************************************************************************/
-/* SDL render interface                                                     */
-/****************************************************************************/
-
-static int
-photon_activaterenderer(SDL_Renderer * renderer)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-   SDL_Window *window = SDL_GetWindowFromID(renderer->window);
-   SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;
-
-   if ((rdata->window_width!=window->w) || (rdata->window_height!=window->h))
-   {
-      return _photon_recreate_surfaces(renderer);
-   }
-
-   switch (rdata->surfaces_type)
-   {
-      case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-           PgSetGCCx(rdata->osurfaces[rdata->surface_render_idx], rdata->gc);
-           break;
-      case SDL_PHOTON_SURFTYPE_PHIMAGE:
-           PgSetGCCx(rdata->pcontexts[rdata->surface_render_idx], rdata->gc);
-           break;
-      case SDL_PHOTON_SURFTYPE_UNKNOWN:
-      default:
-           break;
-   }
-
-   return 0;
-}
-
-static int
-photon_displaymodechanged(SDL_Renderer * renderer)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
-    SDL_VideoDisplay *display = window->display;
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-
-    /* Copy direct_mode status */
-    rdata->direct_mode=didata->direct_mode;
-
-    /* Update the surfaces */
-    return _photon_recreate_surfaces(renderer);
-}
-
-static int
-photon_createtexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
-    SDL_VideoDisplay *display = window->display;
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-    SDL_TextureData *tdata = NULL;
-    uint32_t it;
-
-    /* Check, if it is not initialized */
-    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-    {
-       SDL_SetError("Photon: can't create texture for OpenGL ES window");
-       return -1;
-    }
-
-    /* Check if requested texture format is supported */
-    for (it=0; it<renderer->info.num_texture_formats; it++)
-    {
-       if (renderer->info.texture_formats[it]==texture->format)
-       {
-          break;
-       }
-    }
-    if (it==renderer->info.num_texture_formats)
-    {
-       SDL_SetError("Photon: requested texture format is not supported");
-       return -1;
-    }
-
-    /* Allocate texture driver data */
-    tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData));
-    if (tdata == NULL) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    /* Set texture driver data */
-    texture->driverdata = tdata;
-
-    /* Try offscreen allocation only in case if displayable buffers are also offscreen */
-    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN)
-    {
-       /* Try to allocate offscreen memory first */
-       tdata->osurface=PdCreateOffscreenContext(0, texture->w, texture->h,
-                       Pg_OSC_MEM_LINEAR_ACCESSIBLE | Pg_OSC_MEM_PAGE_ALIGN |
-                       /* in case if 2D acceleration is available use it */
-                       Pg_OSC_MEM_2D_WRITABLE | Pg_OSC_MEM_2D_READABLE);
-    }
-
-    /* Check if offscreen allocation has been failed or not performed */
-    if (tdata->osurface==NULL)
-    {
-       PhPoint_t translation={0, 0};
-       PhDim_t   dimension={texture->w, texture->h};
-       uint32_t  image_pfmt=photon_sdl_to_image_pixelformat(didata->current_mode.format);
-
-       /* Allocate photon image */
-       if (image_pfmt==Pg_IMAGE_PALETTE_BYTE)
-       {
-          tdata->psurface=PhCreateImage(NULL, texture->w, texture->h,
-                          image_pfmt, NULL, 256, 1);
-       }
-       else
-       {
-          tdata->psurface=PhCreateImage(NULL, texture->w, texture->h,
-                          image_pfmt, NULL, 0, 1);
-       }
-
-       if (tdata->psurface==NULL)
-       {
-          return -1;
-       }
-
-       /* Create memory context for PhImage_t */
-       tdata->pcontext=PmMemCreateMC(tdata->psurface, &dimension, &translation);
-       if (tdata->pcontext==NULL)
-       {
-          /* Destroy PhImage */
-          if (tdata->psurface!=NULL)
-          {
-             if (tdata->psurface->palette!=NULL)
-             {
-                SDL_free(tdata->psurface->palette);
-                tdata->psurface->palette=NULL;
-             }
-             /* Destroy shared memory for PhImage_t */
-             PgShmemDestroy(tdata->psurface->image);
-             tdata->psurface->image=NULL;
-             SDL_free(tdata->psurface);
-             tdata->psurface=NULL;
-          }
-       }
-       tdata->surface_type=SDL_PHOTON_SURFTYPE_PHIMAGE;
-    }
-    else
-    {
-       tdata->surface_type=SDL_PHOTON_SURFTYPE_OFFSCREEN;
-    }
-
-    return 0;
-}
-
-static int
-photon_querytexturepixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                          void **pixels, int *pitch)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-      SDL_SetError("Photon: can't query texture pixels for OpenGL ES window");
-      return -1;
-   }
-
-   /* Clear outcoming parameters */
-   *pixels=NULL;
-   *pitch=0;
-
-   switch (tdata->surface_type)
-   {
-      case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-           *pixels=(void*)PdGetOffscreenContextPtr(tdata->osurface);
-           *pitch=tdata->osurface->pitch;
-           break;
-      case SDL_PHOTON_SURFTYPE_PHIMAGE:
-           *pixels=(void*)tdata->psurface->image;
-           *pitch=tdata->psurface->bpl;
-           break;
-      default:
-           break;
-   }
-
-   return 0;
-}
-
-static int
-photon_settexturepalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                         const SDL_Color * colors, int firstcolor,
-                         int ncolors)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-      SDL_SetError("Photon: can't set texture palette for OpenGL ES window");
-      return -1;
-   }
-
-   if (texture->format!=SDL_PIXELFORMAT_INDEX8)
-   {
-      SDL_SetError("Photon: can't set palette for non-paletted texture");
-      return -1;
-   }
-
-   SDL_Unsupported();
-   return -1;
-}
-
-static int
-photon_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                         SDL_Color * colors, int firstcolor, int ncolors)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-      SDL_SetError("Photon: can't return texture palette for OpenGL ES window");
-      return -1;
-   }
-
-   if (texture->format!=SDL_PIXELFORMAT_INDEX8)
-   {
-      SDL_SetError("Photon: can't return palette for non-paletted texture");
-      return -1;
-   }
-
-   SDL_Unsupported();
-   return -1;
-}
-
-static int
-photon_settexturecolormod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-   SDL_Unsupported();
-   return -1;
-}
-
-static int
-photon_settexturealphamod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-    /* Check, if it is not initialized */
-    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-    {
-       SDL_SetError("Photon: can't set texture blend mode for OpenGL ES window");
-       return -1;
-    }
-
-    /* Check if current renderer instance supports alpha modulation */
-    if ((renderer->info.mod_modes & SDL_TEXTUREMODULATE_ALPHA)!=SDL_TEXTUREMODULATE_ALPHA)
-    {
-       SDL_Unsupported();
-       return -1;
-    }
-
-    return 0;
-}
-
-static int
-photon_settextureblendmode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-    /* Check, if it is not initialized */
-    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-    {
-       SDL_SetError("Photon: can't set texture blend mode for OpenGL ES window");
-       return -1;
-    }
-
-    switch (texture->blendMode)
-    {
-        case SDL_BLENDMODE_NONE:
-        case SDL_BLENDMODE_MASK:
-        case SDL_BLENDMODE_BLEND:
-        case SDL_BLENDMODE_ADD:
-        case SDL_BLENDMODE_MOD:
-             return 0;
-        default:
-             SDL_Unsupported();
-             texture->blendMode = SDL_BLENDMODE_NONE;
-             return -1;
-    }
-}
-
-static int
-photon_settexturescalemode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-   switch (texture->scaleMode)
-   {
-      case SDL_SCALEMODE_NONE:
-           return 0;
-      case SDL_SCALEMODE_FAST:
-           if ((renderer->info.scale_modes & SDL_SCALEMODE_FAST)==SDL_SCALEMODE_FAST)
-           {
-              return 0;
-           }
-           else
-           {
-              SDL_Unsupported();
-              texture->scaleMode = SDL_SCALEMODE_FAST;
-              return -1;
-           }
-           break;
-      case SDL_SCALEMODE_SLOW:
-           if ((renderer->info.scale_modes & SDL_SCALEMODE_SLOW)==SDL_SCALEMODE_SLOW)
-           {
-              return 0;
-           }
-           else
-           {
-              SDL_Unsupported();
-              texture->scaleMode = SDL_SCALEMODE_SLOW;
-              return -1;
-           }
-           break;
-      case SDL_SCALEMODE_BEST:
-           SDL_Unsupported();
-           texture->scaleMode = SDL_SCALEMODE_SLOW;
-           return -1;
-      default:
-           SDL_Unsupported();
-           texture->scaleMode = SDL_SCALEMODE_NONE;
-           return -1;
-   }
-
-   SDL_Unsupported();
-   return -1;
-}
-
-static int
-photon_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                     const SDL_Rect * rect, const void *pixels, int pitch)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
-
-   uint8_t* src=(uint8_t*)pixels;
-   uint8_t* dst;
-   uint32_t dst_pitch;
-   uint32_t it;
-   uint32_t copy_length;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-       SDL_SetError("Photon: can't update texture for OpenGL ES window");
-       return -1;
-   }
-
-   switch (tdata->surface_type)
-   {
-      case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-           dst=(uint8_t*)PdGetOffscreenContextPtr(tdata->osurface);
-           dst_pitch=tdata->osurface->pitch;
-           if (dst==NULL)
-           {
-              SDL_SetError("Photon: can't get pointer to texture surface");
-              return -1;
-           }
-           break;
-      case SDL_PHOTON_SURFTYPE_PHIMAGE:
-           dst=(uint8_t*)tdata->psurface->image;
-           dst_pitch=tdata->psurface->bpl;
-           if (dst==NULL)
-           {
-              SDL_SetError("Photon: can't get pointer to texture surface");
-              return -1;
-           }
-           break;
-      default:
-           SDL_SetError("Photon: invalid internal surface type");
-           return -1;
-   }
-
-   dst+=rect->y * dst_pitch + rect->x * SDL_BYTESPERPIXEL(texture->format);
-   copy_length=rect->w * SDL_BYTESPERPIXEL(texture->format);
-   for (it = 0; it < rect->h; it++)
-   {
-      SDL_memcpy(dst, src, copy_length);
-      src+=pitch;
-      dst+=dst_pitch;
-   }
-
-   return 0;
-}
-
-static int
-photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                   const SDL_Rect * rect, int markDirty, void **pixels,
-                   int *pitch)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-       SDL_SetError("Photon: can't lock texture for OpenGL ES window");
-       return -1;
-   }
-
-   /* Clear outcoming parameters */
-   *pixels=NULL;
-   *pitch=0;
-
-   switch (tdata->surface_type)
-   {
-      case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-           *pixels=(void*)((uint8_t*)PdGetOffscreenContextPtr(tdata->osurface) +
-                   rect->y * tdata->osurface->pitch +
-                   rect->x * SDL_BYTESPERPIXEL(texture->format));
-           *pitch=tdata->osurface->pitch;
-           break;
-      case SDL_PHOTON_SURFTYPE_PHIMAGE:
-           *pixels=(void*)((uint8_t*)tdata->psurface->image +
-                   rect->y * tdata->osurface->pitch +
-                   rect->x * SDL_BYTESPERPIXEL(texture->format));
-           *pitch=tdata->psurface->bpl;
-           break;
-      default:
-           break;
-   }
-
-   return 0;
-}
-
-static void
-photon_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-       SDL_SetError("Photon: can't unlock texture for OpenGL ES window");
-       return;
-   }
-}
-
-static void
-photon_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                    int numrects, const SDL_Rect * rects)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-       SDL_SetError("Photon: can't update dirty texture for OpenGL ES window");
-       return;
-   }
-}
-
-static int
-photon_setdrawcolor(SDL_Renderer * renderer)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-       SDL_SetError("Photon: can't set draw color for OpenGL ES window");
-       return -1;
-   }
-
-   switch (rdata->surfaces_type)
-   {
-       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-       case SDL_PHOTON_SURFTYPE_PHIMAGE:
-            PgSetFillColorCx(rdata->gc, PgRGB(renderer->r, renderer->g, renderer->b));
-            PgSetStrokeColorCx(rdata->gc, PgRGB(renderer->r, renderer->g, renderer->b));
-            break;
-       case SDL_PHOTON_SURFTYPE_UNKNOWN:
-       default:
-            break;
-   }
-
-   return 0;
-}
-
-static int
-photon_setdrawblendmode(SDL_Renderer * renderer)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-    /* Check, if it is not initialized */
-    if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-    {
-       SDL_SetError("Photon: can't set texture blend mode for OpenGL ES window");
-       return -1;
-    }
-
-    switch (renderer->blendMode)
-    {
-        case SDL_BLENDMODE_NONE:
-        case SDL_BLENDMODE_MASK:
-        case SDL_BLENDMODE_BLEND:
-        case SDL_BLENDMODE_ADD:
-        case SDL_BLENDMODE_MOD:
-             return 0;
-        default:
-             SDL_Unsupported();
-             renderer->blendMode = SDL_BLENDMODE_NONE;
-             return -1;
-    }
-
-    return 0;
-}
-
-static int
-photon_renderpoint(SDL_Renderer * renderer, int x, int y)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-       SDL_SetError("Photon: can't render point in OpenGL ES window");
-       return -1;
-   }
-
-   /* Enable blending, if requested */
-   _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
-
-   switch (rdata->surfaces_type)
-   {
-       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-            PgDrawIPixelCx(rdata->osurfaces[rdata->surface_render_idx], x, y);
-            break;
-       case SDL_PHOTON_SURFTYPE_PHIMAGE:
-            PgDrawIPixelCx(rdata->pcontexts[rdata->surface_render_idx], x, y);
-            break;
-       case SDL_PHOTON_SURFTYPE_UNKNOWN:
-       default:
-            break;
-   }
-
-   /* Disable blending, if it was enabled */
-   _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
-
-   return 0;
-}
-
-static int
-photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-       SDL_SetError("Photon: can't render line in OpenGL ES window");
-       return -1;
-   }
-
-   /* Enable blending, if requested */
-   _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
-
-   switch (rdata->surfaces_type)
-   {
-       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-            PgDrawILineCx(rdata->osurfaces[rdata->surface_render_idx], x1, y1, x2, y2);
-            break;
-       case SDL_PHOTON_SURFTYPE_PHIMAGE:
-            PgDrawILineCx(rdata->pcontexts[rdata->surface_render_idx], x1, y1, x2, y2);
-            break;
-       case SDL_PHOTON_SURFTYPE_UNKNOWN:
-       default:
-            break;
-   }
-
-   /* Disable blending, if it was enabled */
-   _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
-
-   return 0;
-}
-
-static int
-photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-       SDL_SetError("Photon: can't render filled box in OpenGL ES window");
-       return -1;
-   }
-
-   /* Enable blending, if requested */
-   _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
-
-   switch (rdata->surfaces_type)
-   {
-       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-            PgDrawIRectCx(rdata->osurfaces[rdata->surface_render_idx], rect->x, rect->y, rect->w+rect->x-1, rect->h+rect->y-1, Pg_DRAW_FILL);
-            break;
-       case SDL_PHOTON_SURFTYPE_PHIMAGE:
-            PgDrawIRectCx(rdata->pcontexts[rdata->surface_render_idx], rect->x, rect->y, rect->w+rect->x-1, rect->h+rect->y-1, Pg_DRAW_FILL);
-            break;
-       case SDL_PHOTON_SURFTYPE_UNKNOWN:
-       default:
-            break;
-   }
-
-   /* Disable blending, if it was enabled */
-   _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
-
-   return 0;
-}
-
-static int
-photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                  const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
-
-   PhRect_t src_rect;
-   PhRect_t dst_rect;
-   PhPoint_t dst_point;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-       SDL_SetError("Photon: can't blit textures in OpenGL ES window");
-       return -1;
-   }
-
-   _photon_set_blending(renderer, texture->blendMode, texture->a, SDL_PHOTON_TEXTURE_BLEND);
-
-   /* Set source blit area */
-   src_rect.ul.x = srcrect->x;
-   src_rect.ul.y = srcrect->y;
-   src_rect.lr.x = srcrect->x + srcrect->w - 1;
-   src_rect.lr.y = srcrect->y + srcrect->h - 1;
-
-   /* Set destination blit area */
-   dst_rect.ul.x = dstrect->x;
-   dst_rect.ul.y = dstrect->y;
-   dst_rect.lr.x = dstrect->x + dstrect->w - 1;
-   dst_rect.lr.y = dstrect->y + dstrect->h - 1;
-
-   /* Set destination point */
-   dst_point.x = dstrect->x;
-   dst_point.y = dstrect->y;
-
-   /* Do blit */
-   switch (rdata->surfaces_type)
-   {
-       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-            /* two possible combinations */
-            switch (tdata->surface_type)
-            {
-               case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-                    /* easiest full accelerated combination: offscreen->offscreen */
-                    PgContextBlitCx(rdata->osurfaces[rdata->surface_render_idx], tdata->osurface,
-                                    &src_rect, rdata->osurfaces[rdata->surface_render_idx], &dst_rect);
-                    break;
-               case SDL_PHOTON_SURFTYPE_PHIMAGE:
-                    /* not accelerated combination: PhImage->offscreen */
-                    /* scaling is not supported in this method */
-                    PgDrawPhImageRectCxv(rdata->osurfaces[rdata->surface_render_idx], &dst_point,
-                                         tdata->psurface, &src_rect, 0);
-                    break;
-               default:
-                    break;
-            }
-            break;
-       case SDL_PHOTON_SURFTYPE_PHIMAGE:
-            /* two possible combinations */
-            switch (tdata->surface_type)
-            {
-               case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-                    /* not supported combination: offscreen->PhImage */
-                    return -1;
-               case SDL_PHOTON_SURFTYPE_PHIMAGE:
-                    /* not accelerated combination, but fast: PhImage->PhImage */
-                    /* scaling is not supported in this method */
-                    PgDrawPhImageRectCxv(rdata->pcontexts[rdata->surface_render_idx], &dst_point, tdata->psurface, &src_rect, 0);
-                    break;
-               default:
-                    break;
-            }
-            break;
-   }
-
-   _photon_reset_blending(renderer, texture->blendMode, SDL_PHOTON_TEXTURE_BLEND);
-
-   return 0;
-}
-
-static void
-photon_renderpresent(SDL_Renderer * renderer)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-   SDL_Window *window = window=SDL_GetWindowFromID(renderer->window);
-   SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-   PhRect_t src_rect;
-   PhPoint_t src_point;
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-       SDL_SetError("Photon: can't render present for OpenGL ES window");
-       return;
-   }
-
-   /* Flush all undrawn graphics data to surface */
-   switch (rdata->surfaces_type)
-   {
-       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-            PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
-            PgWaitHWIdle();
-            break;
-       case SDL_PHOTON_SURFTYPE_PHIMAGE:
-            PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]);
-            break;
-       case SDL_PHOTON_SURFTYPE_UNKNOWN:
-       default:
-            return;
-   }
-
-   PgFFlush(Ph_START_DRAW);
-   PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window));
-
-   /* Set blit area */
-   src_rect.ul.x = 0;
-   src_rect.ul.y = 0;
-   src_rect.lr.x = rdata->window_width - 1;
-   src_rect.lr.y = rdata->window_height - 1;
-
-   src_point.x = 0;
-   src_point.y = 0;
-
-   switch (rdata->surfaces_type)
-   {
-       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-            PgContextBlit(rdata->osurfaces[rdata->surface_render_idx], &src_rect, NULL, &src_rect);
-            break;
-       case SDL_PHOTON_SURFTYPE_PHIMAGE:
-            PgDrawPhImagev(&src_point, rdata->psurfaces[rdata->surface_render_idx], 0);
-            break;
-       case SDL_PHOTON_SURFTYPE_UNKNOWN:
-       default:
-            break;
-   }
-
-   /* finish blit */
-   PgFFlush(Ph_DONE_DRAW);
-   PgWaitHWIdle();
-
-   /* Check if we are using double buffering */
-   if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2)
-   {
-      rdata->surface_visible_idx=rdata->surface_render_idx;
-      rdata->surface_render_idx=(rdata->surface_render_idx + 1) % 2;
-   }
-
-   /* Check if we are using triple buffering */
-   if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) == SDL_RENDERER_PRESENTFLIP3)
-   {
-      rdata->surface_visible_idx=rdata->surface_render_idx;
-      rdata->surface_render_idx=(rdata->surface_render_idx + 1) % 3;
-   }
-}
-
-static void
-photon_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-   SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-   SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;
-
-   /* Check if partially created texture must be destroyed */
-   if (tdata==NULL)
-   {
-      return;
-   }
-
-   /* Check, if it is not initialized */
-   if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
-   {
-       SDL_SetError("Photon: can't destroy texture for OpenGL ES window");
-       return;
-   }
-
-   switch (tdata->surface_type)
-   {
-      case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-           if (tdata->osurface!=NULL)
-           {
-              PhDCRelease(tdata->osurface);
-              tdata->osurface = NULL;
-           }
-           break;
-      case SDL_PHOTON_SURFTYPE_PHIMAGE:
-           if (tdata->pcontext!=NULL)
-           {
-              PmMemReleaseMC(tdata->pcontext);
-              tdata->pcontext=NULL;
-           }
-
-           if (tdata->psurface!=NULL)
-           {
-              if (tdata->psurface->palette!=NULL)
-              {
-                 SDL_free(tdata->psurface->palette);
-                 tdata->psurface->palette=NULL;
-              }
-              /* Destroy shared memory for PhImage_t */
-              PgShmemDestroy(tdata->psurface->image);
-              tdata->psurface->image=NULL;
-              SDL_free(tdata->psurface);
-              tdata->psurface=NULL;
-           }
-           break;
-      default:
-           break;
-   }
-}
-
-static void
-photon_destroyrenderer(SDL_Renderer * renderer)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
-    SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;
-    uint32_t it;
-
-    /* Before destroying the renderer, be sure, that rendering was completed */
-    PgFlush();
-    PgWaitHWIdle();
-
-    /* Destroy graphics context */
-    if (rdata->gc!=NULL)
-    {
-       PgDestroyGC(rdata->gc);
-       rdata->gc=NULL;
-    }
-
-    switch (rdata->surfaces_type)
-    {
-       case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-            {
-               /* Destroy current surfaces */
-               for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++)
-               {
-                  if (rdata->osurfaces[it] != NULL)
-                  {
-                     PhDCRelease(rdata->osurfaces[it]);
-                     rdata->osurfaces[it] = NULL;
-                  }
-               }
-            }
-            break;
-       case SDL_PHOTON_SURFTYPE_PHIMAGE:
-            {
-               /* Destroy current surfaces */
-               for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++)
-               {
-                  if (rdata->pcontexts[it]!=NULL)
-                  {
-                     PmMemReleaseMC(rdata->pcontexts[it]);
-                     rdata->pcontexts[it]=NULL;
-                  }
-                  if (rdata->psurfaces[it]!=NULL)
-                  {
-                     if (rdata->psurfaces[it]->palette!=NULL)
-                     {
-                        SDL_free(rdata->psurfaces[it]->palette);
-                        rdata->psurfaces[it]->palette=NULL;
-                     }
-                     /* Destroy shared memory for PhImage_t */
-                     PgShmemDestroy(rdata->psurfaces[it]->image);
-                     rdata->psurfaces[it]->image=NULL;
-                     SDL_free(rdata->psurfaces[it]);
-                     rdata->psurfaces[it]=NULL;
-                  }
-               }
-            }
-            break;
-       case SDL_PHOTON_SURFTYPE_UNKNOWN:
-       default:
-            {
-               /* nothing to do */
-            }
-            break;
-    }
-}
-
-static int
-photon_renderreadpixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                        Uint32 format, void * pixels, int pitch)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *)renderer->driverdata;
-    Uint32 sformat=0;
-    uint8_t* spixels=NULL;
-    unsigned int spitch=0;
-
-    /* Flush all undrawn graphics data to surface */
-    switch (rdata->surfaces_type)
-    {
-        case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-             PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
-             PgWaitHWIdle();
-             break;
-        case SDL_PHOTON_SURFTYPE_PHIMAGE:
-             PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]);
-             break;
-        case SDL_PHOTON_SURFTYPE_UNKNOWN:
-        default:
-             return;
-    }
-
-    switch (rdata->surfaces_type)
-    {
-        case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-             sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_render_idx]->format);
-             spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_render_idx]);
-             spitch=rdata->osurfaces[rdata->surface_render_idx]->pitch;
-             break;
-        case SDL_PHOTON_SURFTYPE_PHIMAGE:
-             sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_render_idx]->type);
-             spixels=(uint8_t*)rdata->psurfaces[rdata->surface_render_idx]->image;
-             spitch=rdata->psurfaces[rdata->surface_render_idx]->bpl;
-             break;
-        case SDL_PHOTON_SURFTYPE_UNKNOWN:
-        default:
-             SDL_SetError("Photon: surfaces are not initialized");
-             return -1;
-    }
-
-    /* Adjust surface pixels pointer to the rectangle coordinates */
-    spixels+=rect->y*spitch + rect->x*SDL_BYTESPERPIXEL(sformat);
-
-    SDL_ConvertPixels(rect->w, rect->h,
-                      sformat, spixels, spitch,
-                      format, pixels, pitch);
-
-    return 0;
-}
-
-static int
-photon_renderwritepixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                         Uint32 format, const void * pixels, int pitch)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *)renderer->driverdata;
-    Uint32 sformat=0;
-    uint8_t* spixels=NULL;
-    unsigned int spitch=0;
-
-    /* Flush all undrawn graphics data to surface */
-    switch (rdata->surfaces_type)
-    {
-        case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-             PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
-             PgWaitHWIdle();
-             break;
-        case SDL_PHOTON_SURFTYPE_PHIMAGE:
-             PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]);
-             break;
-        case SDL_PHOTON_SURFTYPE_UNKNOWN:
-        default:
-             return;
-    }
-
-    switch (rdata->surfaces_type)
-    {
-        case SDL_PHOTON_SURFTYPE_OFFSCREEN:
-             sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_render_idx]->format);
-             spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_render_idx]);
-             spitch=rdata->osurfaces[rdata->surface_render_idx]->pitch;
-             break;
-        case SDL_PHOTON_SURFTYPE_PHIMAGE:
-             sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_render_idx]->type);
-             spixels=(uint8_t*)rdata->psurfaces[rdata->surface_render_idx]->image;
-             spitch=rdata->psurfaces[rdata->surface_render_idx]->bpl;
-             break;
-        case SDL_PHOTON_SURFTYPE_UNKNOWN:
-        default:
-             SDL_SetError("Photon: surfaces are not initialized");
-             return -1;
-    }
-
-    /* Adjust surface pixels pointer to the rectangle coordinates */
-    spixels+=rect->y*spitch + rect->x*SDL_BYTESPERPIXEL(sformat);
-
-    SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch,
-                      sformat, spixels, spitch);
-
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/photon/SDL_photon_render.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Photon GUI SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_PHOTON_RENDER_H__
-#define __SDL_PHOTON_RENDER_H__
-
-#include "../SDL_sysvideo.h"
-
-#include <Ph.h>
-#include <photon/PhRender.h>
-
-#define SDL_PHOTON_MAX_SURFACES 3
-
-#define SDL_PHOTON_SURFTYPE_UNKNOWN    0x00000000
-#define SDL_PHOTON_SURFTYPE_OFFSCREEN  0x00000001
-#define SDL_PHOTON_SURFTYPE_PHIMAGE    0x00000002
-
-#define SDL_PHOTON_UNKNOWN_BLEND       0x00000000
-#define SDL_PHOTON_DRAW_BLEND          0x00000001
-#define SDL_PHOTON_TEXTURE_BLEND       0x00000002
-
-typedef struct SDL_RenderData
-{
-    SDL_bool enable_vsync;              /* VSYNC flip synchronization enable  */
-    uint32_t surface_visible_idx;       /* Index of visible surface           */
-    uint32_t surface_render_idx;        /* Index of render surface            */
-    uint32_t surfaces_count;            /* Amount of allocated surfaces       */
-    uint32_t surfaces_type;             /* Type of allocated surfaces         */
-    uint32_t window_width;              /* Last active window width           */
-    uint32_t window_height;             /* Last active window height          */
-    PhGC_t* gc;                         /* Graphics context                   */
-    SDL_bool direct_mode;               /* Direct Mode state                  */
-    PdOffscreenContext_t* osurfaces[SDL_PHOTON_MAX_SURFACES];
-    PhImage_t* psurfaces[SDL_PHOTON_MAX_SURFACES];
-    PmMemoryContext_t* pcontexts[SDL_PHOTON_MAX_SURFACES];
-} SDL_RenderData;
-
-typedef struct SDL_TextureData
-{
-   uint32_t surface_type;
-   PdOffscreenContext_t* osurface;
-   PhImage_t* psurface;
-   PmMemoryContext_t* pcontext;
-} SDL_TextureData;
-
-extern void photon_addrenderdriver(_THIS);
-
-/* Helper function, which redraws the backbuffer */
-int _photon_update_rectangles(SDL_Renderer* renderer, PhRect_t* rect);
-
-#endif /* __SDL_PHOTON_RENDER_H__ */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/qnxgf/SDL_gf_input.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1144 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#include "SDL_gf_input.h"
-
-#include "SDL_config.h"
-#include "SDL_events.h"
-#include "../../events/SDL_mouse_c.h"
-#include "../../events/SDL_keyboard_c.h"
-
-/* Include QNX HIDDI definitions */
-#include "SDL_hiddi_keyboard.h"
-#include "SDL_hiddi_mouse.h"
-#include "SDL_hiddi_joystick.h"
-
-/* Mouse related functions */
-SDL_Cursor *gf_createcursor(SDL_Surface * surface, int hot_x, int hot_y);
-int gf_showcursor(SDL_Cursor * cursor);
-void gf_movecursor(SDL_Cursor * cursor);
-void gf_freecursor(SDL_Cursor * cursor);
-void gf_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y);
-void gf_freemouse(SDL_Mouse * mouse);
-
-/* HIDDI interacting functions */
-static int32_t hiddi_connect_devices();
-static int32_t hiddi_disconnect_devices();
-
-int32_t
-gf_addinputdevices(_THIS)
-{
-    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *didata;
-    struct SDL_Mouse gf_mouse;
-    SDL_Keyboard gf_keyboard;
-    SDLKey keymap[SDL_NUM_SCANCODES];
-    SDL_MouseData *mdata;
-    uint32_t it;
-
-    for (it = 0; it < _this->num_displays; it++) {
-        SDL_VideoDisplay *display = &_this->displays[it];
-
-        /* Clear SDL mouse structure */
-        SDL_memset(&gf_mouse, 0x00, sizeof(struct SDL_Mouse));
-
-        /* Allocate SDL_MouseData structure */
-        mdata = (SDL_MouseData *) SDL_calloc(1, sizeof(SDL_MouseData));
-        if (mdata == NULL) {
-            SDL_OutOfMemory();
-            return -1;
-        }
-
-        /* Mark this mouse with ID 0 */
-        gf_mouse.id = it;
-        gf_mouse.driverdata = (void *) mdata;
-        gf_mouse.CreateCursor = gf_createcursor;
-        gf_mouse.ShowCursor = gf_showcursor;
-        gf_mouse.MoveCursor = gf_movecursor;
-        gf_mouse.FreeCursor = gf_freecursor;
-        gf_mouse.WarpMouse = gf_warpmouse;
-        gf_mouse.FreeMouse = gf_freemouse;
-
-        /* Get display data */
-        didata = (SDL_DisplayData *) display->driverdata;
-
-        /* Store SDL_DisplayData pointer in the mouse driver internals */
-        mdata->didata = didata;
-
-        /* Set cursor pos to 0,0 to avoid cursor disappearing in some drivers */
-        gf_cursor_set_pos(didata->display, 0, 0, 0);
-
-        /* Register mouse cursor in SDL */
-        SDL_AddMouse(&gf_mouse, "GF mouse cursor", 0, 0, 1);
-    }
-
-    /* Keyboard could be one only */
-    SDL_zero(gf_keyboard);
-    SDL_AddKeyboard(&gf_keyboard, -1);
-
-    /* Add scancode to key mapping, HIDDI uses USB HID codes, so */
-    /* map will be exact one-to-one */
-    SDL_GetDefaultKeymap(keymap);
-    SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
-
-    /* Connect to HID server and enumerate all input devices */
-    hiddi_connect_devices();
-
-    return 0;
-}
-
-int32_t
-gf_delinputdevices(_THIS)
-{
-    /* Disconnect from HID server and release input devices */
-    hiddi_disconnect_devices();
-
-    /* Delete keyboard */
-    SDL_KeyboardQuit();
-
-    /* Destroy all of the mice */
-    SDL_MouseQuit();
-}
-
-/*****************************************************************************/
-/* GF Mouse related functions                                                */
-/*****************************************************************************/
-SDL_Cursor *
-gf_createcursor(SDL_Surface * surface, int hot_x, int hot_y)
-{
-    gf_cursor_t *internal_cursor;
-    SDL_Cursor *sdl_cursor;
-    uint8_t *image0 = NULL;
-    uint8_t *image1 = NULL;
-    uint32_t it;
-    uint32_t jt;
-    uint32_t shape_color;
-
-    /* SDL converts monochrome cursor shape to 32bpp cursor shape      */
-    /* and we must convert it back to monochrome, this routine handles */
-    /* 24/32bpp surfaces only                                          */
-    if ((surface->format->BitsPerPixel != 32)
-        && (surface->format->BitsPerPixel != 24)) {
-        SDL_SetError("GF: Cursor shape is not 24/32bpp.");
-        return NULL;
-    }
-
-    /* Since GF is not checking data, we must check */
-    if ((surface->w == 0) || (surface->h == 0)) {
-        SDL_SetError("GF: Cursor shape dimensions are zero");
-        return NULL;
-    }
-
-    /* Allocate memory for the internal cursor format */
-    internal_cursor = (gf_cursor_t *) SDL_calloc(1, sizeof(gf_cursor_t));
-    if (internal_cursor == NULL) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    /* Allocate memory for the SDL cursor */
-    sdl_cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(SDL_Cursor));
-    if (sdl_cursor == NULL) {
-        SDL_free(internal_cursor);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    /* Allocate two monochrome images */
-    image0 = (uint8_t *) SDL_calloc(1, ((surface->w + 7) / 8) * surface->h);
-    if (image0 == NULL) {
-        SDL_free(sdl_cursor);
-        SDL_free(internal_cursor);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-    image1 = (uint8_t *) SDL_calloc(1, ((surface->w + 7) >> 3) * surface->h);
-    if (image1 == NULL) {
-        SDL_free(image0);
-        SDL_free(sdl_cursor);
-        SDL_free(internal_cursor);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    /* Set driverdata as GF cursor format */
-    sdl_cursor->driverdata = (void *) internal_cursor;
-    internal_cursor->type = GF_CURSOR_BITMAP;
-    internal_cursor->hotspot.x = hot_x;
-    internal_cursor->hotspot.y = hot_y;
-    internal_cursor->cursor.bitmap.w = surface->w;
-    internal_cursor->cursor.bitmap.h = surface->h;
-    internal_cursor->cursor.bitmap.color0 = SDL_GF_MOUSE_COLOR_BLACK;
-    internal_cursor->cursor.bitmap.color1 = SDL_GF_MOUSE_COLOR_WHITE;
-
-    /* Setup cursor shape images */
-    internal_cursor->cursor.bitmap.stride = ((surface->w + 7) >> 3);
-    internal_cursor->cursor.bitmap.image0 = image0;
-    internal_cursor->cursor.bitmap.image1 = image1;
-
-    /* Convert cursor from 32 bpp */
-    for (jt = 0; jt < surface->h; jt++) {
-        for (it = 0; it < surface->w; it++) {
-            shape_color =
-                *((uint32_t *) ((uint8_t *) surface->pixels +
-                                jt * surface->pitch +
-                                it * surface->format->BytesPerPixel));
-            switch (shape_color) {
-            case SDL_GF_MOUSE_COLOR_BLACK:
-                {
-                    *(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
-                      (it >> 3)) |= 0x80 >> (it % 8);
-                    *(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                }
-                break;
-            case SDL_GF_MOUSE_COLOR_WHITE:
-                {
-                    *(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                    *(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
-                      (it >> 3)) |= 0x80 >> (it % 8);
-                }
-                break;
-            case SDL_GF_MOUSE_COLOR_TRANS:
-                {
-                    *(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                    *(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                }
-                break;
-            default:
-                {
-                    /* The same as transparent color, must not happen */
-                    *(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                    *(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
-                      (it >> 3)) &= ~(0x80 >> (it % 8));
-                }
-                break;
-            }
-        }
-    }
-
-    return sdl_cursor;
-}
-
-int
-gf_showcursor(SDL_Cursor * cursor)
-{
-    SDL_VideoDisplay *display;
-    SDL_DisplayData *didata;
-    SDL_Window *window;
-    SDL_WindowID window_id;
-    gf_cursor_t *internal_cursor;
-    int32_t status;
-
-    /* Get current window id */
-    window_id = SDL_GetFocusWindow();
-    if (window_id <= 0) {
-        SDL_MouseData *mdata = NULL;
-
-        /* If there is no current window, then someone calls this function */
-        /* to set global mouse settings during SDL initialization          */
-        if (cursor != NULL) {
-            mdata = (SDL_MouseData *) cursor->mouse->driverdata;
-            didata = (SDL_DisplayData *) mdata->didata;
-            if ((didata == NULL) || (mdata == NULL)) {
-                return;
-            }
-        } else {
-            /* We can't get SDL_DisplayData at this point, return fake success */
-            return 0;
-        }
-    } else {
-        /* Sanity checks */
-        window = SDL_GetWindowFromID(window_id);
-        if (window != NULL) {
-            display = window->display;
-            if (display != NULL) {
-                didata = (SDL_DisplayData *) display->driverdata;
-                if (didata == NULL) {
-                    return -1;
-                }
-            } else {
-                return -1;
-            }
-        } else {
-            return -1;
-        }
-    }
-
-    /* Check if we need to set new shape or disable cursor shape */
-    if (cursor != NULL) {
-        /* Retrieve GF cursor shape */
-        internal_cursor = (gf_cursor_t *) cursor->driverdata;
-        if (internal_cursor == NULL) {
-            SDL_SetError("GF: Internal cursor data is absent");
-            return -1;
-        }
-        if ((internal_cursor->cursor.bitmap.image0 == NULL) ||
-            (internal_cursor->cursor.bitmap.image1 == NULL)) {
-            SDL_SetError("GF: Cursor shape is absent");
-            return -1;
-        }
-
-        /* Store last shown cursor to display data */
-        didata->cursor.type = internal_cursor->type;
-        didata->cursor.hotspot.x = internal_cursor->hotspot.x;
-        didata->cursor.hotspot.y = internal_cursor->hotspot.y;
-        if (internal_cursor->cursor.bitmap.w > SDL_VIDEO_GF_MAX_CURSOR_SIZE) {
-            didata->cursor.cursor.bitmap.w = SDL_VIDEO_GF_MAX_CURSOR_SIZE;
-        } else {
-            didata->cursor.cursor.bitmap.w = internal_cursor->cursor.bitmap.w;
-        }
-
-        if (didata->cursor.cursor.bitmap.h > SDL_VIDEO_GF_MAX_CURSOR_SIZE) {
-            didata->cursor.cursor.bitmap.h = SDL_VIDEO_GF_MAX_CURSOR_SIZE;
-        } else {
-            didata->cursor.cursor.bitmap.h = internal_cursor->cursor.bitmap.h;
-        }
-
-        didata->cursor.cursor.bitmap.color0 =
-            internal_cursor->cursor.bitmap.color0;
-        didata->cursor.cursor.bitmap.color1 =
-            internal_cursor->cursor.bitmap.color1;
-        didata->cursor.cursor.bitmap.stride =
-            internal_cursor->cursor.bitmap.stride;
-        SDL_memcpy(didata->cursor.cursor.bitmap.image0,
-                   internal_cursor->cursor.bitmap.image0,
-                   ((internal_cursor->cursor.bitmap.w +
-                     7) / (sizeof(uint8_t) * 8)) *
-                   internal_cursor->cursor.bitmap.h);
-        SDL_memcpy(didata->cursor.cursor.bitmap.image1,
-                   internal_cursor->cursor.bitmap.image1,
-                   ((internal_cursor->cursor.bitmap.w +
-                     7) / (sizeof(uint8_t) * 8)) *
-                   internal_cursor->cursor.bitmap.h);
-
-        /* Setup cursor shape */
-        status = gf_cursor_set(didata->display, 0, internal_cursor);
-        if (status != GF_ERR_OK) {
-            if (status != GF_ERR_NOSUPPORT) {
-                SDL_SetError("GF: Can't set hardware cursor shape");
-                return -1;
-            }
-        }
-
-        /* Enable just set cursor */
-        status = gf_cursor_enable(didata->display, 0);
-        if (status != GF_ERR_OK) {
-            if (status != GF_ERR_NOSUPPORT) {
-                SDL_SetError("GF: Can't enable hardware cursor");
-                return -1;
-            }
-        }
-
-        /* Set cursor visible */
-        didata->cursor_visible = SDL_TRUE;
-    } else {
-        /* SDL requests to disable cursor */
-        status = gf_cursor_disable(didata->display, 0);
-        if (status != GF_ERR_OK) {
-            if (status != GF_ERR_NOSUPPORT) {
-                SDL_SetError("GF: Can't disable hardware cursor");
-                return -1;
-            }
-        }
-
-        /* Set cursor invisible */
-        didata->cursor_visible = SDL_FALSE;
-    }
-
-    /* New cursor shape is set */
-    return 0;
-}
-
-void
-gf_movecursor(SDL_Cursor * cursor)
-{
-    SDL_VideoDisplay *display;
-    SDL_DisplayData *didata;
-    SDL_Window *window;
-    SDL_WindowID window_id;
-    int32_t status;
-    uint32_t xmax;
-    uint32_t ymax;
-
-    /* Get current window id */
-    window_id = SDL_GetFocusWindow();
-    if (window_id <= 0) {
-        didata = (SDL_DisplayData *) cursor->mouse->driverdata;
-        if (didata == NULL) {
-            return;
-        }
-    } else {
-        /* Sanity checks */
-        window = SDL_GetWindowFromID(window_id);
-        if (window != NULL) {
-            display = window->display;
-            if (display != NULL) {
-                didata = (SDL_DisplayData *) display->driverdata;
-                if (didata == NULL) {
-                    return;
-                }
-            } else {
-                return;
-            }
-        } else {
-            return;
-        }
-    }
-
-    /* Add checks for out of screen bounds position */
-    if (cursor->mouse->x < 0) {
-        cursor->mouse->x = 0;
-    }
-    if (cursor->mouse->y < 0) {
-        cursor->mouse->y = 0;
-    }
-
-    /* Get window size to clamp maximum coordinates */
-    SDL_GetWindowSize(window_id, &xmax, &ymax);
-    if (cursor->mouse->x >= xmax) {
-        cursor->mouse->x = xmax - 1;
-    }
-    if (cursor->mouse->y >= ymax) {
-        cursor->mouse->y = ymax - 1;
-    }
-
-    status =
-        gf_cursor_set_pos(didata->display, 0, cursor->mouse->x,
-                          cursor->mouse->y);
-    if (status != GF_ERR_OK) {
-        if (status != GF_ERR_NOSUPPORT) {
-            SDL_SetError("GF: Can't set hardware cursor position");
-            return;
-        }
-    }
-}
-
-void
-gf_freecursor(SDL_Cursor * cursor)
-{
-    gf_cursor_t *internal_cursor;
-
-    if (cursor != NULL) {
-        internal_cursor = (gf_cursor_t *) cursor->driverdata;
-        if (internal_cursor != NULL) {
-            if (internal_cursor->cursor.bitmap.image0 != NULL) {
-                SDL_free((uint8_t *) internal_cursor->cursor.bitmap.image0);
-            }
-            if (internal_cursor->cursor.bitmap.image1 != NULL) {
-                SDL_free((uint8_t *) internal_cursor->cursor.bitmap.image1);
-            }
-            SDL_free(internal_cursor);
-        }
-    }
-}
-
-void
-gf_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y)
-{
-    SDL_VideoDisplay *display;
-    SDL_DisplayData *didata;
-    uint32_t xmax;
-    uint32_t ymax;
-    int32_t status;
-
-    /* Sanity checks */
-    if (window != NULL) {
-        display = window->display;
-        if (display != NULL) {
-            didata = (SDL_DisplayData *) display->driverdata;
-            if (didata == NULL) {
-                return;
-            }
-        } else {
-            return;
-        }
-    } else {
-        return;
-    }
-
-    /* Add checks for out of screen bounds position */
-    if (x < 0) {
-        x = 0;
-    }
-    if (y < 0) {
-        y = 0;
-    }
-
-    /* Get window size to clamp maximum coordinates */
-    SDL_GetWindowSize(window, &xmax, &ymax);
-    if (x >= xmax) {
-        x = xmax - 1;
-    }
-    if (y >= ymax) {
-        y = ymax - 1;
-    }
-
-    status = gf_cursor_set_pos(didata->display, 0, x, y);
-    if (status != GF_ERR_OK) {
-        if (status != GF_ERR_NOSUPPORT) {
-            SDL_SetError("GF: Can't set hardware cursor position");
-            return;
-        }
-    }
-}
-
-void
-gf_freemouse(SDL_Mouse * mouse)
-{
-    if (mouse->driverdata == NULL) {
-        return;
-    }
-
-    /* Mouse framework doesn't deletes automatically our driverdata */
-    SDL_free(mouse->driverdata);
-    mouse->driverdata = NULL;
-
-    return;
-}
-
-/*****************************************************************************/
-/* HIDDI handlers code                                                       */
-/*****************************************************************************/
-static key_packet key_last_state[SDL_HIDDI_MAX_DEVICES];
-
-static void
-hiddi_keyboard_handler(uint32_t devno, uint8_t * report_data,
-                       uint32_t report_len)
-{
-    key_packet *packet;
-    uint32_t it;
-    uint32_t jt;
-
-    packet = (key_packet *) report_data;
-
-    /* Check for special states */
-    switch (report_len) {
-    case 8:                    /* 8 bytes of report length */
-        {
-            for (it = 0; it < 6; it++) {
-                /* Check for keyboard overflow, when it can't handle */
-                /* many simultaneous pressed keys */
-                if (packet->codes[it] == HIDDI_KEY_OVERFLOW) {
-                    return;
-                }
-            }
-        }
-        break;
-    default:
-        {
-            /* Do not process unknown reports */
-            return;
-        }
-        break;
-    }
-
-    /* Check if modifier key was pressed */
-    if (packet->modifiers != key_last_state[devno].modifiers) {
-        if (((packet->modifiers & HIDDI_MKEY_LEFT_CTRL) ==
-             HIDDI_MKEY_LEFT_CTRL)
-            && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_CTRL) == 0) {
-            /* Left Ctrl key was pressed */
-            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LCTRL);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_LEFT_CTRL) == 0) &&
-            (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_CTRL) ==
-            HIDDI_MKEY_LEFT_CTRL) {
-            /* Left Ctrl key was released */
-            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LCTRL);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_LEFT_SHIFT) ==
-             HIDDI_MKEY_LEFT_SHIFT)
-            && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_SHIFT) == 0) {
-            /* Left Shift key was pressed */
-            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LSHIFT);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_LEFT_SHIFT) == 0) &&
-            (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_SHIFT) ==
-            HIDDI_MKEY_LEFT_SHIFT) {
-            /* Left Shift key was released */
-            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_LEFT_ALT) == HIDDI_MKEY_LEFT_ALT)
-            && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_ALT) == 0) {
-            /* Left Alt key was pressed */
-            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LALT);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_LEFT_ALT) == 0) &&
-            (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_ALT) ==
-            HIDDI_MKEY_LEFT_ALT) {
-            /* Left Alt key was released */
-            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LALT);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_LEFT_WFLAG) ==
-             HIDDI_MKEY_LEFT_WFLAG)
-            && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_WFLAG) == 0) {
-            /* Left Windows flag key was pressed */
-            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LGUI);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_LEFT_WFLAG) == 0) &&
-            (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_WFLAG) ==
-            HIDDI_MKEY_LEFT_WFLAG) {
-            /* Left Windows flag key was released */
-            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LGUI);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_RIGHT_CTRL) ==
-             HIDDI_MKEY_RIGHT_CTRL)
-            && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_CTRL) == 0) {
-            /* Right Ctrl key was pressed */
-            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RCTRL);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_RIGHT_CTRL) == 0) &&
-            (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_CTRL) ==
-            HIDDI_MKEY_RIGHT_CTRL) {
-            /* Right Ctrl key was released */
-            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RCTRL);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_RIGHT_SHIFT) ==
-             HIDDI_MKEY_RIGHT_SHIFT)
-            && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_SHIFT) ==
-            0) {
-            /* Right Shift key was pressed */
-            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RSHIFT);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_RIGHT_SHIFT) == 0) &&
-            (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_SHIFT) ==
-            HIDDI_MKEY_RIGHT_SHIFT) {
-            /* Right Shift key was released */
-            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RSHIFT);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_RIGHT_ALT) ==
-             HIDDI_MKEY_RIGHT_ALT)
-            && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_ALT) == 0) {
-            /* Right Alt key was pressed */
-            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RALT);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_RIGHT_ALT) == 0) &&
-            (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_ALT) ==
-            HIDDI_MKEY_RIGHT_ALT) {
-            /* Right Alt key was released */
-            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RALT);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_RIGHT_WFLAG) ==
-             HIDDI_MKEY_RIGHT_WFLAG)
-            && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_WFLAG) ==
-            0) {
-            /* Right Windows flag key was pressed */
-            SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RGUI);
-        }
-        if (((packet->modifiers & HIDDI_MKEY_RIGHT_WFLAG) == 0) &&
-            (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_WFLAG) ==
-            HIDDI_MKEY_RIGHT_WFLAG) {
-            /* Right Windows flag key was released */
-            SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RGUI);
-        }
-    }
-
-    /* Check each key in the press/release buffer */
-    switch (report_len) {
-    case 8:                    /* 8 bytes of report length */
-        {
-            /* Check if at least one key was unpressed */
-            for (it = 0; it < 6; it++) {
-                if (key_last_state[devno].codes[it] == HIDDI_KEY_UNPRESSED) {
-                    /* if stored keycode is zero, find another */
-                    continue;
-                }
-                for (jt = 0; jt < 6; jt++) {
-                    /* Find stored keycode in the current pressed codes */
-                    if (packet->codes[jt] == key_last_state[devno].codes[it]) {
-                        /* If found then particular key state is not changed */
-                        break;
-                    }
-                }
-
-                /* Check if pressed key can't longer be found */
-                if (jt == 6) {
-                    SDL_SendKeyboardKey(0, SDL_RELEASED,
-                                        key_last_state[devno].codes[it]);
-                }
-            }
-
-            /* Check if at least one new key was pressed */
-            for (it = 0; it < 6; it++) {
-                if (packet->codes[it] == HIDDI_KEY_UNPRESSED) {
-                    continue;
-                }
-                for (jt = 0; jt < 6; jt++) {
-                    /* Find new keycode it the array of old pressed keys */
-                    if (packet->codes[it] == key_last_state[devno].codes[jt]) {
-                        break;
-                    }
-                }
-
-                /* Check if new key was pressed */
-                if (jt == 6) {
-                    SDL_SendKeyboardKey(0, SDL_PRESSED, packet->codes[it]);
-                }
-            }
-        }
-    default:                   /* unknown keyboard report type */
-        {
-            /* Ignore all unknown reports */
-        }
-        break;
-    }
-
-    /* Store last state */
-    key_last_state[devno] = *packet;
-}
-
-static uint32_t mouse_last_state_button[SDL_HIDDI_MAX_DEVICES];
-static uint32_t collect_reports = 0;
-
-static void
-hiddi_mouse_handler(uint32_t devno, uint8_t * report_data,
-                    uint32_t report_len)
-{
-    uint32_t it;
-    uint32_t sdlbutton;
-
-    /* We do not want to collect stored events */
-    if (collect_reports == 0) {
-        return;
-    }
-
-    /* Check for special states */
-    switch (report_len) {
-    case 8:                    /* 8 bytes of report length, usually multi-button USB mice */
-        {
-            mouse_packet8 *packet;
-            packet = (mouse_packet8 *) report_data;
-
-            /* Send motion event if motion really was */
-            if ((packet->horizontal_precision != 0)
-                || (packet->vertical_precision != 0)) {
-                SDL_SendMouseMotion(0, 1, packet->horizontal_precision,
-                                    packet->vertical_precision, 0);
-            }
-
-            /* Send mouse button press/release events */
-            if (mouse_last_state_button[devno] != packet->buttons) {
-                /* Cycle all buttons status */
-                for (it = 0; it < 8; it++) {
-                    /* convert hiddi button id to sdl button id */
-                    switch (it) {
-                    case 0:
-                        {
-                            sdlbutton = SDL_BUTTON_LEFT;
-                        }
-                        break;
-                    case 1:
-                        {
-                            sdlbutton = SDL_BUTTON_RIGHT;
-                        }
-                        break;
-                    case 2:
-                        {
-                            sdlbutton = SDL_BUTTON_MIDDLE;
-                        }
-                        break;
-                    default:
-                        {
-                            sdlbutton = it + 1;
-                        }
-                        break;
-                    }
-
-                    /* Button pressed */
-                    if (((packet->buttons & (0x01 << it)) == (0x01 << it)) &&
-                        ((mouse_last_state_button[devno] & (0x01 << it)) ==
-                         0x00)) {
-                        SDL_SendMouseButton(0, SDL_PRESSED, sdlbutton);
-                    }
-                    /* Button released */
-                    if (((packet->buttons & (0x01 << it)) == 0x00) &&
-                        ((mouse_last_state_button[devno] & (0x01 << it)) ==
-                         (0x01 << it))) {
-                        SDL_SendMouseButton(0, SDL_RELEASED, sdlbutton);
-                    }
-                }
-                mouse_last_state_button[devno] = packet->buttons;
-            }
-
-            /* Send mouse wheel events */
-            if (packet->wheel != 0) {
-                /* Send vertical wheel event only */
-                SDL_SendMouseWheel(0, 0, packet->wheel);
-            }
-        }
-        break;
-    case 4:                    /* 4 bytes of report length, usually PS/2 mice */
-        {
-            mouse_packet4 *packet;
-            packet = (mouse_packet4 *) report_data;
-
-            /* Send motion event if motion really was */
-            if ((packet->horizontal != 0) || (packet->vertical != 0)) {
-                SDL_SendMouseMotion(0, 1, packet->horizontal,
-                                    packet->vertical, 0);
-            }
-
-            /* Send mouse button press/release events */
-            if (mouse_last_state_button[devno] != packet->buttons) {
-                /* Cycle all buttons status */
-                for (it = 0; it < 8; it++) {
-                    /* convert hiddi button id to sdl button id */
-                    switch (it) {
-                    case 0:
-                        {
-                            sdlbutton = SDL_BUTTON_LEFT;
-                        }
-                        break;
-                    case 1:
-                        {
-                            sdlbutton = SDL_BUTTON_RIGHT;
-                        }
-                        break;
-                    case 2:
-                        {
-                            sdlbutton = SDL_BUTTON_MIDDLE;
-                        }
-                        break;
-                    default:
-                        {
-                            sdlbutton = it + 1;
-                        }
-                        break;
-                    }
-
-                    /* Button pressed */
-                    if (((packet->buttons & (0x01 << it)) == (0x01 << it)) &&
-                        ((mouse_last_state_button[devno] & (0x01 << it)) ==
-                         0x00)) {
-                        SDL_SendMouseButton(0, SDL_PRESSED, sdlbutton);
-                    }
-                    /* Button released */
-                    if (((packet->buttons & (0x01 << it)) == 0x00) &&
-                        ((mouse_last_state_button[devno] & (0x01 << it)) ==
-                         (0x01 << it))) {
-                        SDL_SendMouseButton(0, SDL_RELEASED, sdlbutton);
-                    }
-                }
-                mouse_last_state_button[devno] = packet->buttons;
-            }
-
-            /* Send mouse wheel events */
-            if (packet->wheel != 0) {
-                /* Send vertical wheel event only */
-                SDL_SendMouseWheel(0, 0, packet->wheel);
-            }
-        }
-        break;
-    }
-}
-
-/*****************************************************************************/
-/* HIDDI interacting code                                                    */
-/*****************************************************************************/
-static hidd_device_ident_t hiddevice = {
-    HIDD_CONNECT_WILDCARD,      /* vendor id:  any */
-    HIDD_CONNECT_WILDCARD,      /* product id: any */
-    HIDD_CONNECT_WILDCARD,      /* version:    any */
-};
-
-static hidd_connect_parm_t hidparams =
-    { NULL, HID_VERSION, HIDD_VERSION, 0, 0, &hiddevice, NULL, 0 };
-
-static void hiddi_insertion(struct hidd_connection *connection,
-                            hidd_device_instance_t * device_instance);
-static void hiddi_removal(struct hidd_connection *connection,
-                          hidd_device_instance_t * instance);
-static void hiddi_report(struct hidd_connection *connection,
-                         struct hidd_report *report, void *report_data,
-                         uint32_t report_len, uint32_t flags, void *user);
-
-static hidd_funcs_t hidfuncs =
-    { _HIDDI_NFUNCS, hiddi_insertion, hiddi_removal, hiddi_report, NULL };
-
-/* HID handle, singletone */
-struct hidd_connection *connection = NULL;
-
-/* SDL detected input device types, singletone */
-static uint32_t sdl_input_devices[SDL_HIDDI_MAX_DEVICES];
-
-static int
-hiddi_register_for_reports(struct hidd_collection *col,
-                           hidd_device_instance_t * device_instance)
-{
-    int it;
-    uint16_t num_col;
-    struct hidd_collection **hidd_collections;
-    struct hidd_report_instance *report_instance;
-    struct hidd_report *report;
-    int status = 0;
-    hidview_device_t *device;
-
-    for (it = 0; it < 10 && !status; it++) {
-        status =
-            hidd_get_report_instance(col, it, HID_INPUT_REPORT,
-                                     &report_instance);
-        if (status == EOK) {
-            status =
-                hidd_report_attach(connection, device_instance,
-                                   report_instance, 0,
-                                   sizeof(hidview_device_t), &report);
-            if (status == EOK) {
-                device = hidd_report_extra(report);
-                device->report = report;
-                device->instance = report_instance;
-            }
-        }
-    }
-    hidd_get_collections(NULL, col, &hidd_collections, &num_col);
-
-    for (it = 0; it < num_col; it++) {
-        hiddi_register_for_reports(hidd_collections[it], device_instance);
-    }
-
-    return EOK;
-}
-
-static void
-hiddi_insertion(struct hidd_connection *connection,
-                hidd_device_instance_t * device_instance)
-{
-    uint32_t it;
-    struct hidd_collection **hidd_collections;
-    uint16_t num_col;
-
-    /* get root level collections */
-    hidd_get_collections(device_instance, NULL, &hidd_collections, &num_col);
-    for (it = 0; it < num_col; it++) {
-        hiddi_register_for_reports(hidd_collections[it], device_instance);
-    }
-}
-
-static void
-hiddi_removal(struct hidd_connection *connection,
-              hidd_device_instance_t * instance)
-{
-    hidd_reports_detach(connection, instance);
-}
-
-static void
-hiddi_report(struct hidd_connection *connection, hidd_report_t * report,
-             void *report_data, uint32_t report_len, uint32_t flags,
-             void *user)
-{
-    if (report->dev_inst->devno >= SDL_HIDDI_MAX_DEVICES) {
-        /* Unknown HID device, with devno number out of supported range */
-        return;
-    }
-
-    /* Check device type which generates event */
-    switch (sdl_input_devices[report->dev_inst->devno]) {
-    case SDL_GF_HIDDI_NONE:
-        {
-            /* We do not handle other devices type */
-            return;
-        }
-        break;
-    case SDL_GF_HIDDI_MOUSE:
-        {
-            /* Call mouse handler */
-            hiddi_mouse_handler(report->dev_inst->devno, report_data,
-                                report_len);
-        }
-        break;
-    case SDL_GF_HIDDI_KEYBOARD:
-        {
-            /* Call keyboard handler */
-            hiddi_keyboard_handler(report->dev_inst->devno, report_data,
-                                   report_len);
-        }
-        break;
-    case SDL_GF_HIDDI_JOYSTICK:
-        {
-            /* Call joystick handler */
-        }
-        break;
-    }
-}
-
-static
-hiddi_get_device_type(uint8_t * report_data, uint16_t report_length)
-{
-    hid_byte_t byte;
-    uint16_t usage_page = 0;
-    uint16_t usage = 0;
-    uint16_t data = 0;
-
-    while (report_length && !(usage_page && usage)) {
-        if (hidp_analyse_byte(*report_data, &byte)) {
-            /* Error in parser, do nothing */
-        }
-        data = hidp_get_data((report_data + 1), &byte);
-        switch (byte.HIDB_Type) {
-        case HID_TYPE_GLOBAL:
-            if (!usage_page && byte.HIDB_Tag == HID_GLOBAL_USAGE_PAGE) {
-                usage_page = data;
-            }
-            break;
-        case HID_TYPE_LOCAL:
-            if (!usage && byte.HIDB_Tag == HID_LOCAL_USAGE) {
-                usage = data;
-            }
-            break;
-        }
-        report_data += byte.HIDB_Length + 1;
-        report_length -= byte.HIDB_Length + 1;
-    }
-
-    switch (usage_page) {
-    case HIDD_PAGE_DESKTOP:
-        {
-            switch (usage) {
-            case HIDD_USAGE_MOUSE:
-                {
-                    return SDL_GF_HIDDI_MOUSE;
-                }
-                break;
-            case HIDD_USAGE_JOYSTICK:
-                {
-                    return SDL_GF_HIDDI_JOYSTICK;
-                }
-                break;
-            case HIDD_USAGE_KEYBOARD:
-                {
-                    return SDL_GF_HIDDI_KEYBOARD;
-                }
-                break;
-            }
-        }
-        break;
-    case HIDD_PAGE_DIGITIZER:
-        {
-            /* Do not handle digitizers */
-        }
-        break;
-    case HIDD_PAGE_CONSUMER:
-        {
-            /* Do not handle consumer input devices */
-        }
-        break;
-    }
-
-    return SDL_GF_HIDDI_NONE;
-}
-
-static int32_t
-hiddi_connect_devices()
-{
-    int32_t status;
-    uint32_t it;
-    uint8_t *report_data;
-    uint16_t report_length;
-    hidd_device_instance_t instance;
-
-    /* Cleanup initial keys and mice state */
-    SDL_memset(key_last_state, 0x00,
-               sizeof(key_packet) * SDL_HIDDI_MAX_DEVICES);
-    SDL_memset(mouse_last_state_button, 0x00,
-               sizeof(uint32_t) * SDL_HIDDI_MAX_DEVICES);
-
-    status = hidd_connect(&hidparams, &connection);
-    if (status != EOK) {
-        connection=NULL;
-        return -1;
-    }
-
-    for (it = 0; it < SDL_HIDDI_MAX_DEVICES; it++) {
-        /* Get device instance */
-        status = hidd_get_device_instance(connection, it, &instance);
-        if (status != EOK) {
-            continue;
-        }
-
-        status =
-            hidd_get_report_desc(connection, &instance, &report_data,
-                                 &report_length);
-        if (status != EOK) {
-            continue;
-        }
-
-        status = hiddi_get_device_type(report_data, report_length);
-        sdl_input_devices[it] = status;
-
-        free(report_data);
-    }
-
-    /* Disconnect from HID server */
-    status = hidd_disconnect(connection);
-    if (status != EOK) {
-        connection=NULL;
-        return -1;
-    }
-
-    /* Add handlers for HID devices */
-    hidparams.funcs = &hidfuncs;
-
-    status = hidd_connect(&hidparams, &connection);
-    if (status != EOK) {
-        connection=NULL;
-        return -1;
-    }
-
-    return 0;
-}
-
-static int32_t
-hiddi_disconnect_devices()
-{
-    int32_t status;
-
-    hiddi_disable_mouse();
-
-    /* Disconnect from HID server */
-    if (connection!=NULL)
-    {
-        status = hidd_disconnect(connection);
-        if (status != EOK) {
-            return -1;
-        }
-    }
-}
-
-void
-hiddi_enable_mouse()
-{
-    collect_reports = 1;
-}
-
-void
-hiddi_disable_mouse()
-{
-    collect_reports = 0;
-}
--- a/src/video/qnxgf/SDL_gf_input.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_GF_INPUT_H__
-#define __SDL_GF_INPUT_H__
-
-#include "SDL_config.h"
-#include "SDL_video.h"
-#include "../SDL_sysvideo.h"
-
-#include <errno.h>
-
-#include <gf/gf.h>
-
-#include <sys/hiddi.h>
-#include <sys/hidut.h>
-
-#include "SDL_qnxgf.h"
-
-typedef struct SDL_MouseData
-{
-    SDL_DisplayData *didata;
-} SDL_MouseData;
-
-int32_t gf_addinputdevices(_THIS);
-int32_t gf_delinputdevices(_THIS);
-
-#define SDL_GF_MOUSE_COLOR_BLACK 0xFF000000
-#define SDL_GF_MOUSE_COLOR_WHITE 0xFFFFFFFF
-#define SDL_GF_MOUSE_COLOR_TRANS 0x00000000
-
-/*****************************************************************************/
-/* This is HIDDI closed interface declarations                               */
-/*****************************************************************************/
-#define HID_TYPE_MAIN      0x0
-#define HID_TYPE_GLOBAL    0x1
-#define HID_TYPE_LOCAL     0x2
-#define HID_TYPE_RESERVED  0x3
-
-#define HID_GLOBAL_USAGE_PAGE 0x0
-#define HID_LOCAL_USAGE       0x0
-
-typedef struct _hid_byte
-{
-    uint8_t HIDB_Length;
-    uint8_t HIDB_Type;
-    uint8_t HIDB_Tag;
-    uint8_t reserved[1];
-} hid_byte_t;
-
-typedef struct _hidd_global_item
-{
-    uint16_t usage_page;
-    uint16_t logical_min;
-    uint16_t logical_max;
-    uint16_t physical_min;
-    uint16_t physical_max;
-    uint16_t unit_expo;
-    uint16_t unit;
-    uint16_t report_size;
-    uint16_t report_id;
-    uint16_t report_count;
-} hidd_global_item_t;
-
-typedef struct _hidd_local_item
-{
-    uint16_t type;
-    uint8_t reserved[2];
-    uint32_t value;
-    struct _hidd_local_item *next_local;
-    struct _hidd_local_item *alt_local;
-} hidd_local_item_t;
-
-typedef struct _hidd_local_table
-{
-    hidd_local_item_t *usage_info;
-    hidd_local_item_t *designator_info;
-    hidd_local_item_t *string_info;
-    uint8_t delimiter;
-    uint8_t reserved[3];
-} hidd_local_table_t;
-
-typedef struct _hidd_field
-{
-    struct hidd_report_instance *report;
-    struct hidd_collection *collection;
-    uint16_t report_offset;
-    uint16_t flags;
-    hidd_global_item_t gitem;
-    hidd_local_table_t *ltable;
-    struct _hidd_field *next_field;
-    void *user;
-} hidd_field_t;
-
-typedef struct hidd_report_instance
-{
-    uint8_t report_id;
-    uint8_t reserved[1];
-    uint16_t report_type;
-    hidd_field_t *field;
-    uint16_t num_field;
-    uint16_t byte_len;
-    uint16_t bit_len;
-    uint8_t reserved2[2];
-    struct hidd_collection *collection;
-    struct hidd_report_instance *next_col_report;
-    struct hidd_report_instance *next_report;
-} hidd_report_instance_t;
-
-typedef struct hidd_report
-{
-    TAILQ_ENTRY(hidd_report) link;
-    hidd_report_instance_t *rinst;
-    hidd_device_instance_t *dev_inst;
-    uint32_t flags;
-    struct hidd_connection *connection;
-    void *user;
-} hidd_report_t;
-
-typedef struct hidview_device
-{
-    struct hidd_report_instance *instance;
-    struct hidd_report *report;
-} hidview_device_t;
-
-/*****************************************************************************/
-/* Closed HIDDI interface declarations end                                   */
-/*****************************************************************************/
-
-/* Maximum devices and subdevices amount per host */
-#define SDL_HIDDI_MAX_DEVICES 64
-
-/* Detected device/subdevice type for SDL */
-#define SDL_GF_HIDDI_NONE     0x00000000
-#define SDL_GF_HIDDI_MOUSE    0x00000001
-#define SDL_GF_HIDDI_KEYBOARD 0x00000002
-#define SDL_GF_HIDDI_JOYSTICK 0x00000003
-
-extern void hiddi_enable_mouse();
-extern void hiddi_disable_mouse();
-
-#endif /* __SDL_GF_INPUT_H__ */
--- a/src/video/qnxgf/SDL_gf_opengles.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-/* This is OpenGL ES 1.0 helper functions from OpenGL ES 1.1 specification,  */
-/* which could be implemented independently from hardware, just wrappers     */
-
-GLAPI void APIENTRY
-glTexParameteri(GLenum target, GLenum pname, GLint param)
-{
-    glTexParameterx(target, pname, (GLfixed) param);
-    return;
-}
-
-GLAPI void APIENTRY
-glTexParameteriv(GLenum target, GLenum pname, const GLint * params)
-{
-    /* Retrieve one parameter only */
-    glTexParameterx(target, pname, (GLfixed) * params);
-    return;
-}
-
-GLAPI void APIENTRY
-glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
-{
-    glColor4f(((GLfloat) red) / 255.f, ((GLfloat) green) / 255.f,
-              ((GLfloat) blue) / 255.f, ((GLfloat) alpha) / 255.f);
-    return;
-}
--- a/src/video/qnxgf/SDL_gf_opengles.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_GF_OPENGLES_H__
-#define __SDL_GF_OPENGLES_H__
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-GLAPI void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param);
-GLAPI void APIENTRY glTexParameteriv(GLenum target, GLenum pname,
-                                     const GLint * params);
-GLAPI void APIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue,
-                               GLubyte alpha);
-
-#endif /* __SDL_GF_OPENGLES_H__ */
--- a/src/video/qnxgf/SDL_gf_pixelfmt.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,187 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#include "SDL_config.h"
-#include "SDL_gf_pixelfmt.h"
-
-gf_format_t
-qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt)
-{
-    switch (pixelfmt) {
-    case SDL_PIXELFORMAT_INDEX8:
-        {
-            return GF_FORMAT_PAL8;
-        }
-        break;
-    case SDL_PIXELFORMAT_ARGB1555:
-        {
-            return GF_FORMAT_PACK_ARGB1555;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB555:
-        {
-            /* RGB555 is the same as ARGB1555, but alpha is ignored */
-            return GF_FORMAT_PACK_ARGB1555;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB565:
-        {
-            return GF_FORMAT_PACK_RGB565;
-        }
-        break;
-    case SDL_PIXELFORMAT_BGR565:
-        {
-            return GF_FORMAT_PKBE_RGB565;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB24:
-        {
-            /* GF has wrong components order */
-            return GF_FORMAT_BGR888;
-        }
-        break;
-    case SDL_PIXELFORMAT_RGB888:
-        {
-            /* The same format as ARGB8888, but with alpha ignored */
-            /* and GF has wrong components order                   */
-            return GF_FORMAT_BGRA8888;
-        }
-        break;
-    case SDL_PIXELFORMAT_ARGB8888:
-        {
-            /* GF has wrong components order */
-            return GF_FORMAT_BGRA8888;
-        }
-        break;
-    case SDL_PIXELFORMAT_BGRA8888:
-        {
-            /* GF has wrong components order */
-            return GF_FORMAT_ARGB8888;
-        }
-        break;
-    case SDL_PIXELFORMAT_YV12:
-        {
-            return GF_FORMAT_PLANAR_YUV_YV12;
-        }
-        break;
-    case SDL_PIXELFORMAT_YUY2:
-        {
-            return GF_FORMAT_PACK_YUV_YUY2;
-        }
-        break;
-    case SDL_PIXELFORMAT_UYVY:
-        {
-            return GF_FORMAT_PACK_YUV_UYVY;
-        }
-        break;
-    case SDL_PIXELFORMAT_YVYU:
-        {
-            return GF_FORMAT_PACK_YUV_YVYU;
-        }
-        break;
-    }
-
-    return GF_FORMAT_INVALID;
-}
-
-uint32_t
-qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt)
-{
-    switch (pixelfmt) {
-    case GF_FORMAT_PAL8:
-        {
-            return SDL_PIXELFORMAT_INDEX8;
-        }
-        break;
-    case GF_FORMAT_PKLE_ARGB1555:
-        {
-            return SDL_PIXELFORMAT_ARGB1555;
-        }
-        break;
-    case GF_FORMAT_PACK_ARGB1555:
-        {
-            return SDL_PIXELFORMAT_ARGB1555;
-        }
-        break;
-    case GF_FORMAT_PKBE_RGB565:
-        {
-            return SDL_PIXELFORMAT_BGR565;
-        }
-        break;
-    case GF_FORMAT_PKLE_RGB565:
-        {
-            return SDL_PIXELFORMAT_RGB565;
-        }
-        break;
-    case GF_FORMAT_PACK_RGB565:
-        {
-            return SDL_PIXELFORMAT_RGB565;
-        }
-        break;
-    case GF_FORMAT_BGR888:
-        {
-            /* GF has wrong components order */
-            return SDL_PIXELFORMAT_RGB24;
-        }
-        break;
-    case GF_FORMAT_BGRA8888:
-        {
-            /* GF has wrong components order */
-            return SDL_PIXELFORMAT_ARGB8888;
-        }
-        break;
-    case GF_FORMAT_ARGB8888:
-        {
-            /* GF has wrong components order */
-            return SDL_PIXELFORMAT_BGRA8888;
-        }
-        break;
-    case GF_FORMAT_PLANAR_YUV_YV12:
-        {
-            return SDL_PIXELFORMAT_YV12;
-        }
-        break;
-    case GF_FORMAT_PACK_YUV_YUY2:
-        {
-            return SDL_PIXELFORMAT_YUY2;
-        }
-        break;
-    case GF_FORMAT_PACK_YUV_UYVY:
-        {
-            return SDL_PIXELFORMAT_UYVY;
-        }
-        break;
-    case GF_FORMAT_PACK_YUV_YVYU:
-        {
-            return SDL_PIXELFORMAT_YVYU;
-        }
-        break;
-    }
-
-    return SDL_PIXELFORMAT_UNKNOWN;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/qnxgf/SDL_gf_pixelfmt.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_GF_PIXELFMT_H__
-#define __SDL_GF_PIXELFMT_H__
-
-#include "../SDL_sysvideo.h"
-
-#include <gf/gf.h>
-
-gf_format_t qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt);
-uint32_t qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt);
-
-#endif /* __SDL_GF_PIXELFMT_H__ */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/qnxgf/SDL_gf_render.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,425 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#include "SDL_config.h"
-
-#include "../SDL_pixels_c.h"
-#include "../SDL_yuv_sw_c.h"
-
-#include "SDL_video.h"
-
-#include "SDL_gf_render.h"
-#include "SDL_qnxgf.h"
-
-static SDL_Renderer *gf_createrenderer(SDL_Window * window, Uint32 flags);
-static int gf_displaymodechanged(SDL_Renderer * renderer);
-static int gf_activaterenderer(SDL_Renderer * renderer);
-static int gf_createtexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int gf_querytexturepixels(SDL_Renderer * renderer,
-                                 SDL_Texture * texture, void **pixels,
-                                 int *pitch);
-static int gf_settexturepalette(SDL_Renderer * renderer,
-                                SDL_Texture * texture,
-                                const SDL_Color * colors, int firstcolor,
-                                int ncolors);
-static int gf_gettexturepalette(SDL_Renderer * renderer,
-                                SDL_Texture * texture, SDL_Color * colors,
-                                int firstcolor, int ncolors);
-static int gf_settexturecolormod(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
-static int gf_settexturealphamod(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
-static int gf_settextureblendmode(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int gf_settexturescalemode(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int gf_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                            const SDL_Rect * rect, const void *pixels,
-                            int pitch);
-static int gf_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * rect, int markDirty, void **pixels,
-                          int *pitch);
-static void gf_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static void gf_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                            int numrects, const SDL_Rect * rects);
-static int gf_renderpoint(SDL_Renderer * renderer, int x, int y);
-static int gf_renderline(SDL_Renderer * renderer, int x1, int y1, int x2,
-                         int y2);
-static int gf_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect);
-static int gf_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
-static void gf_renderpresent(SDL_Renderer * renderer);
-static void gf_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static void gf_destroyrenderer(SDL_Renderer * renderer);
-
-SDL_RenderDriver gf_renderdriver = {
-    gf_createrenderer,
-    {
-     "qnxgf",
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
-      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
-      SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
-      SDL_RENDERER_ACCELERATED),
-     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
-      SDL_TEXTUREMODULATE_ALPHA),
-     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
-      SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
-     (SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW),
-     13,
-     {
-      SDL_PIXELFORMAT_INDEX8,
-      SDL_PIXELFORMAT_RGB555,
-      SDL_PIXELFORMAT_RGB565,
-      SDL_PIXELFORMAT_RGB888,
-      SDL_PIXELFORMAT_BGR888,
-      SDL_PIXELFORMAT_ARGB8888,
-      SDL_PIXELFORMAT_RGBA8888,
-      SDL_PIXELFORMAT_ABGR8888,
-      SDL_PIXELFORMAT_BGRA8888,
-      SDL_PIXELFORMAT_YV12,
-      SDL_PIXELFORMAT_YUY2,
-      SDL_PIXELFORMAT_UYVY,
-      SDL_PIXELFORMAT_YVYU},
-     0,
-     0}
-};
-
-static SDL_Renderer *
-gf_createrenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_VideoDisplay *display = window->display;
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    SDL_Renderer *renderer = NULL;
-    SDL_RenderData *rdata = NULL;
-    uint32_t it;
-    int32_t jt;
-    int32_t status;
-
-    /* Check if it is OpenGL ES window */
-    if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) {
-        /* No error, just no need to create 2D renderer for OpenGL ES window */
-        return NULL;
-    }
-
-    /* Allocate new renderer structure */
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer));
-    if (renderer == NULL) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    /* Allocate renderer data */
-    rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData));
-    if (rdata == NULL) {
-        SDL_free(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    renderer->DisplayModeChanged = gf_displaymodechanged;
-    renderer->ActivateRenderer = gf_activaterenderer;
-    renderer->CreateTexture = gf_createtexture;
-    renderer->QueryTexturePixels = gf_querytexturepixels;
-    renderer->SetTexturePalette = gf_settexturepalette;
-    renderer->GetTexturePalette = gf_gettexturepalette;
-    renderer->SetTextureAlphaMod = gf_settexturealphamod;
-    renderer->SetTextureColorMod = gf_settexturecolormod;
-    renderer->SetTextureBlendMode = gf_settextureblendmode;
-    renderer->SetTextureScaleMode = gf_settexturescalemode;
-    renderer->UpdateTexture = gf_updatetexture;
-    renderer->LockTexture = gf_locktexture;
-    renderer->UnlockTexture = gf_unlocktexture;
-    renderer->DirtyTexture = gf_dirtytexture;
-    renderer->RenderPoint = gf_renderpoint;
-    renderer->RenderLine = gf_renderline;
-    renderer->RenderFill = gf_renderfill;
-    renderer->RenderCopy = gf_rendercopy;
-    renderer->RenderPresent = gf_renderpresent;
-    renderer->DestroyTexture = gf_destroytexture;
-    renderer->DestroyRenderer = gf_destroyrenderer;
-    renderer->info = gf_renderdriver.info;
-    renderer->window = window;
-    renderer->driverdata = rdata;
-
-    /* Set render acceleration flag in case it is accelerated */
-    if ((didata->caps & SDL_GF_ACCELERATED) == SDL_GF_ACCELERATED) {
-        renderer->info.flags = SDL_RENDERER_ACCELERATED;
-    } else {
-        renderer->info.flags &= ~(SDL_RENDERER_ACCELERATED);
-    }
-
-    rdata->window = window;
-
-    /* Check if upper level requested synchronization on vsync signal */
-    if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) {
-        rdata->enable_vsync = SDL_TRUE;
-    } else {
-        rdata->enable_vsync = SDL_FALSE;
-    }
-
-    /* Check what buffer copy/flip scheme is requested */
-    rdata->surfaces_count = 0;
-    if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) {
-        if ((flags & SDL_RENDERER_PRESENTDISCARD) ==
-            SDL_RENDERER_PRESENTDISCARD) {
-            renderer->info.flags |=
-                SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD;
-        } else {
-            renderer->info.flags |=
-                SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
-        }
-        rdata->surfaces_count = 1;
-        rdata->surface_visible_idx = 0;
-        rdata->surface_render_idx = 0;
-    } else {
-        if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) {
-            renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
-            rdata->surfaces_count = 2;
-            rdata->surface_visible_idx = 0;
-            rdata->surface_render_idx = 1;
-        } else {
-            if ((flags & SDL_RENDERER_PRESENTFLIP3) ==
-                SDL_RENDERER_PRESENTFLIP3) {
-                renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
-                rdata->surfaces_count = 3;
-                rdata->surface_visible_idx = 0;
-                rdata->surface_render_idx = 1;
-            } else {
-                renderer->info.flags |=
-                    SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
-                rdata->surfaces_count = 1;
-                rdata->surface_visible_idx = 0;
-                rdata->surface_render_idx = 0;
-            }
-        }
-    }
-
-    /* Create layer surfaces, which could be visible */
-    for (it = 0; it < rdata->surfaces_count; it++) {
-        /* TODO: add palette creation */
-
-        /* Create displayable surfaces */
-        status =
-            gf_surface_create_layer(&rdata->surface[it], &didata->layer, 1, 0,
-                                    didata->current_mode.w,
-                                    didata->current_mode.h,
-                                    qnxgf_sdl_to_gf_pixelformat(didata->
-                                                                current_mode.
-                                                                format), NULL,
-                                    GF_SURFACE_CREATE_2D_ACCESSIBLE);
-
-        if (status != GF_ERR_OK) {
-            /* Free already allocated surfaces */
-            for (jt = it - 1; jt > 0; jt--) {
-                gf_surface_free(rdata->surface[jt]);
-                rdata->surface[jt] = NULL;
-            }
-            SDL_free(rdata);
-            SDL_free(renderer);
-            if (status == GF_ERR_MEM) {
-                SDL_SetError("unsufficient free video memory");
-            } else {
-                SDL_SetError("error during displayable surface creation");
-            }
-            return NULL;
-        }
-
-        /* Get detailed information about allocated surface */
-        gf_surface_get_info(rdata->surface[it], &rdata->surface_info[it]);
-    }
-
-    return renderer;
-}
-
-void
-gf_addrenderdriver(_THIS)
-{
-    uint32_t it;
-
-    for (it = 0; it < _this->num_displays; it++) {
-        SDL_AddRenderDriver(&_this->displays[it], &gf_renderdriver);
-    }
-}
-
-/****************************************************************************/
-/* SDL render interface                                                     */
-/****************************************************************************/
-static int
-gf_displaymodechanged(SDL_Renderer * renderer)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-
-    /* Remove all allocated surfaces, they are no more valid */
-
-    /* TODO: Add video mode change detection and new parameters detection */
-
-    return 0;
-}
-
-static int
-gf_activaterenderer(SDL_Renderer * renderer)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-    SDL_VideoDisplay *display = rdata->window->display;
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-
-    /* Setup current surface as visible */
-//   gf_layer_set_surfaces(didata->layer, &rdata->surface[rdata->surface_visible_idx], 1);
-
-    /* Set visible surface when hardware in idle state */
-//   gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE);
-
-    return 0;
-}
-
-static int
-gf_createtexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_RenderData *renderdata = (SDL_RenderData *) renderer->driverdata;
-    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
-    SDL_VideoDisplay *display = window->display;
-    SDL_TextureData *tdata = NULL;
-
-    /* Allocate texture driver data */
-    tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData));
-    if (tdata == NULL) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    /* Set texture driver data */
-    texture->driverdata = tdata;
-
-}
-
-static int
-gf_querytexturepixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                      void **pixels, int *pitch)
-{
-}
-
-static int
-gf_settexturepalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                     const SDL_Color * colors, int firstcolor, int ncolors)
-{
-}
-
-static int
-gf_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                     SDL_Color * colors, int firstcolor, int ncolors)
-{
-}
-
-static int
-gf_settexturecolormod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-}
-
-static int
-gf_settexturealphamod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-}
-
-static int
-gf_settextureblendmode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-}
-
-static int
-gf_settexturescalemode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-}
-
-static int
-gf_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                 const SDL_Rect * rect, const void *pixels, int pitch)
-{
-}
-
-static int
-gf_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
-               const SDL_Rect * rect, int markDirty, void **pixels,
-               int *pitch)
-{
-}
-
-static void
-gf_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-}
-
-static void
-gf_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
-                const SDL_Rect * rects)
-{
-}
-
-static int
-gf_renderpoint(SDL_Renderer * renderer, int x, int y)
-{
-}
-
-static int
-gf_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
-{
-}
-
-static int
-gf_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect)
-{
-}
-
-static int
-gf_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
-              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-}
-
-static void
-gf_renderpresent(SDL_Renderer * renderer)
-{
-}
-
-static void
-gf_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-}
-
-static void
-gf_destroyrenderer(SDL_Renderer * renderer)
-{
-    SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
-    uint32_t it;
-
-    for (it = 0; it < rdata->surfaces_count; it++) {
-        if (rdata->surface[it] != NULL) {
-            gf_surface_free(rdata->surface[it]);
-        }
-    }
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/qnxgf/SDL_gf_render.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_GF_RENDER_H__
-#define __SDL_GF_RENDER_H__
-
-#include "../SDL_sysvideo.h"
-
-#include <gf/gf.h>
-
-#define SDL_GF_MAX_SURFACES 3
-
-typedef struct SDL_RenderData
-{
-    SDL_Window *window;         /* SDL window type                    */
-    SDL_bool enable_vsync;      /* VSYNC flip synchronization enable  */
-    gf_surface_t surface[SDL_GF_MAX_SURFACES];  /* Surface handles     */
-    gf_surface_info_t surface_info[SDL_GF_MAX_SURFACES];        /* Surface info   */
-    uint32_t surface_visible_idx;       /* Index of visible surface     */
-    uint32_t surface_render_idx;        /* Index of render surface      */
-    uint32_t surfaces_count;    /* Amount of allocated surfaces */
-} SDL_RenderData;
-
-typedef struct SDL_TextureData
-{
-    gf_surface_t surface;
-    gf_surface_info_t surface_info;
-} SDL_TextureData;
-
-extern void gf_addrenderdriver(_THIS);
-
-#endif /* __SDL_GF_RENDER_H__ */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/qnxgf/SDL_hiddi_joystick.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_HIDDI_JOYSTICK_H__
-#define __SDL_HIDDI_JOYSTICK_H__
-
-#include <inttypes.h>
-
-#endif /* __SDL_HIDDI_JOYSTICK_H__ */
--- a/src/video/qnxgf/SDL_hiddi_keyboard.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_HIDDI_KEYBOARD_H__
-#define __SDL_HIDDI_KEYBOARD_H__
-
-#include <inttypes.h>
-
-/* PS/2 and USB keyboards are generating this packet */
-typedef struct key_packet
-{
-    uint8_t modifiers;
-    uint8_t data;
-    uint8_t codes[6];
-} key_packet;
-
-/* Key modifier codes */
-#define HIDDI_MKEY_LEFT_CTRL            0x00000001
-#define HIDDI_MKEY_LEFT_SHIFT           0x00000002
-#define HIDDI_MKEY_LEFT_ALT             0x00000004
-#define HIDDI_MKEY_LEFT_WFLAG           0x00000008
-#define HIDDI_MKEY_RIGHT_CTRL           0x00000010
-#define HIDDI_MKEY_RIGHT_SHIFT          0x00000020
-#define HIDDI_MKEY_RIGHT_ALT            0x00000040
-#define HIDDI_MKEY_RIGHT_WFLAG          0x00000080
-
-/* Key codes */
-#define HIDDI_KEY_UNPRESSED             0x00000000
-#define HIDDI_KEY_OVERFLOW              0x00000001
-#define HIDDI_KEY_ESC                   0x00000029
-#define HIDDI_KEY_F1                    0x0000003A
-#define HIDDI_KEY_F2                    0x0000003B
-#define HIDDI_KEY_F3                    0x0000003C
-#define HIDDI_KEY_F4                    0x0000003D
-#define HIDDI_KEY_F5                    0x0000003E
-#define HIDDI_KEY_F6                    0x0000003F
-#define HIDDI_KEY_F7                    0x00000040
-#define HIDDI_KEY_F8                    0x00000041
-#define HIDDI_KEY_F9                    0x00000042
-#define HIDDI_KEY_F10                   0x00000043
-#define HIDDI_KEY_F11                   0x00000044
-#define HIDDI_KEY_F12                   0x00000045
-
-#define HIDDI_KEY_BACKQUOTE             0x00000035
-#define HIDDI_KEY_1                     0x0000001E
-#define HIDDI_KEY_2                     0x0000001F
-#define HIDDI_KEY_3                     0x00000020
-#define HIDDI_KEY_4                     0x00000021
-#define HIDDI_KEY_5                     0x00000022
-#define HIDDI_KEY_6                     0x00000023
-#define HIDDI_KEY_7                     0x00000024
-#define HIDDI_KEY_8                     0x00000025
-#define HIDDI_KEY_9                     0x00000026
-#define HIDDI_KEY_0                     0x00000027
-#define HIDDI_KEY_MINUS                 0x0000002D
-#define HIDDI_KEY_EQUAL                 0x0000002E
-#define HIDDI_KEY_BACKSPACE             0x0000002A
-
-#define HIDDI_KEY_TAB                   0x0000002B
-#define HIDDI_KEY_Q                     0x00000014
-#define HIDDI_KEY_W                     0x0000001A
-#define HIDDI_KEY_E                     0x00000008
-#define HIDDI_KEY_R                     0x00000015
-#define HIDDI_KEY_T                     0x00000017
-#define HIDDI_KEY_Y                     0x0000001C
-#define HIDDI_KEY_U                     0x00000018
-#define HIDDI_KEY_I                     0x0000000C
-#define HIDDI_KEY_O                     0x00000012
-#define HIDDI_KEY_P                     0x00000013
-#define HIDDI_KEY_LEFT_SQ_BRACKET       0x0000002F
-#define HIDDI_KEY_RIGHT_SQ_BRACKET      0x00000030
-#define HIDDI_KEY_BACKSLASH             0x00000031
-
-#define HIDDI_KEY_CAPSLOCK              0x00000039
-#define HIDDI_KEY_A                     0x00000004
-#define HIDDI_KEY_S                     0x00000016
-#define HIDDI_KEY_D                     0x00000007
-#define HIDDI_KEY_F                     0x00000009
-#define HIDDI_KEY_G                     0x0000000A
-#define HIDDI_KEY_H                     0x0000000B
-#define HIDDI_KEY_J                     0x0000000D
-#define HIDDI_KEY_K                     0x0000000E
-#define HIDDI_KEY_L                     0x0000000F
-#define HIDDI_KEY_SEMICOLON             0x00000033
-#define HIDDI_KEY_QUOTE                 0x00000034
-#define HIDDI_KEY_ENTER                 0x00000028
-
-#define HIDDI_KEY_Z                     0x0000001D
-#define HIDDI_KEY_X                     0x0000001B
-#define HIDDI_KEY_C                     0x00000006
-#define HIDDI_KEY_V                     0x00000019
-#define HIDDI_KEY_B                     0x00000005
-#define HIDDI_KEY_N                     0x00000011
-#define HIDDI_KEY_M                     0x00000010
-#define HIDDI_KEY_COMMA                 0x00000036
-#define HIDDI_KEY_POINT                 0x00000037
-#define HIDDI_KEY_SLASH                 0x00000038
-
-#define HIDDI_KEY_SPACE                 0x0000002C
-#define HIDDI_KEY_MENU                  0x00000065
-
-#define HIDDI_KEY_PRINTSCREEN           0x00000046
-#define HIDDI_KEY_SCROLLLOCK            0x00000047
-#define HIDDI_KEY_PAUSE                 0x00000048
-
-#define HIDDI_KEY_INSERT                0x00000049
-#define HIDDI_KEY_HOME                  0x0000004A
-#define HIDDI_KEY_PAGEUP                0x0000004B
-#define HIDDI_KEY_DELETE                0x0000004C
-#define HIDDI_KEY_END                   0x0000004D
-#define HIDDI_KEY_PAGEDOWN              0x0000004E
-
-#define HIDDI_KEY_UP                    0x00000052
-#define HIDDI_KEY_LEFT                  0x00000050
-#define HIDDI_KEY_DOWN                  0x00000051
-#define HIDDI_KEY_RIGHT                 0x0000004F
-
-#define HIDDI_KEY_NUMLOCK               0x00000053
-#define HIDDI_KEY_GR_SLASH              0x00000054
-#define HIDDI_KEY_GR_ASTERISK           0x00000055
-#define HIDDI_KEY_GR_MINUS              0x00000056
-#define HIDDI_KEY_GR_7                  0x0000005F
-#define HIDDI_KEY_GR_8                  0x00000060
-#define HIDDI_KEY_GR_9                  0x00000061
-#define HIDDI_KEY_GR_PLUS               0x00000057
-#define HIDDI_KEY_GR_4                  0x0000005C
-#define HIDDI_KEY_GR_5                  0x0000005D
-#define HIDDI_KEY_GR_6                  0x0000005E
-#define HIDDI_KEY_GR_1                  0x00000059
-#define HIDDI_KEY_GR_2                  0x0000005A
-#define HIDDI_KEY_GR_3                  0x0000005B
-#define HIDDI_KEY_GR_ENTER              0x00000058
-#define HIDDI_KEY_GR_0                  0x00000062
-#define HIDDI_KEY_GR_DELETE             0x00000063
-
-#endif /* __SDL_HIDDI_KEYBOARD_H__ */
--- a/src/video/qnxgf/SDL_hiddi_mouse.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_HIDDI_MOUSE_H__
-#define __SDL_HIDDI_MOUSE_H__
-
-#include <inttypes.h>
-
-/* USB keyboard multimedia keys are generating this packet */
-typedef struct mouse_packet2
-{
-    uint8_t buttons;
-    int8_t wheel;
-} mouse_packet2;
-
-/* PS/2 mice are generating this packet */
-typedef struct mouse_packet4
-{
-    uint8_t buttons;
-    int8_t horizontal;
-    int8_t vertical;
-    int8_t wheel;
-} mouse_packet4;
-
-/* USB keyboard with mice wheel onboard generating this packet */
-typedef struct mouse_packet5
-{
-    uint8_t buttons;
-    int8_t horizontal;
-    int8_t vertical;
-    int8_t wheel;
-    uint8_t state;
-} mouse_packet5;
-
-/* USB multi-button mice are generating this packet */
-typedef struct mouse_packet8
-{
-    uint8_t buttons;
-    int8_t horizontal;
-    int8_t vertical;
-    int8_t wheel;
-    int16_t horizontal_precision;
-    int16_t vertical_precision;
-} mouse_packet8;
-
-#endif /* __SDL_HIDDI_MOUSE_H__ */
--- a/src/video/qnxgf/SDL_qnxgf.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1934 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#include "SDL_config.h"
-
-#include "../SDL_sysvideo.h"
-#include "SDL_version.h"
-#include "SDL_syswm.h"
-#include "SDL_loadso.h"
-
-/* Include QNX Graphics Framework declarations */
-#include <gf/gf.h>
-
-#include "SDL_qnxgf.h"
-#include "SDL_gf_render.h"
-#include "SDL_gf_pixelfmt.h"
-#include "SDL_gf_opengles.h"
-#include "SDL_gf_input.h"
-
-/******************************************************************************/
-/* SDL Generic video modes, which could provide GF                            */
-/* This is real pain in the ass. GF is just wrapper around a selected driver  */
-/* some drivers could support double scan modes, like 320x200, 512x384, etc   */
-/* but some drivers are not. Later we can distinguish one driver from another */
-/* Feel free to add any new custom graphics mode                              */
-/******************************************************************************/
-static const SDL_DisplayMode generic_mode[] = {
-    {0, 320, 200, 70, NULL},    /* 320x200 modes are 70Hz and 85Hz          */
-    {0, 320, 200, 85, NULL},
-    {0, 320, 240, 70, NULL},    /* 320x240 modes are 70Hz and 85Hz          */
-    {0, 320, 240, 85, NULL},
-    {0, 400, 300, 60, NULL},    /* 400x300 mode is 60Hz only                */
-    {0, 480, 360, 60, NULL},    /* 480x360 mode is 60Hz only                */
-    {0, 512, 384, 60, NULL},    /* 512x384 modes are 60Hz and 70Hz          */
-    {0, 512, 384, 70, NULL},
-    {0, 640, 480, 60, NULL},    /* 640x480 modes are 60Hz, 75Hz, 85Hz       */
-    {0, 640, 480, 75, NULL},
-    {0, 640, 480, 85, NULL},
-    {0, 800, 600, 60, NULL},    /* 800x600 modes are 60Hz, 75Hz, 85Hz       */
-    {0, 800, 600, 75, NULL},
-    {0, 800, 600, 85, NULL},
-    {0, 800, 480, 60, NULL},    /* 800x480 mode is 60Hz only                */
-    {0, 848, 480, 60, NULL},    /* 848x480 mode is 60Hz only                */
-    {0, 960, 600, 60, NULL},    /* 960x600 mode is 60Hz only                */
-    {0, 1024, 640, 60, NULL},   /* 1024x640 mode is 60Hz only               */
-    {0, 1024, 768, 60, NULL},   /* 1024x768 modes are 60Hz, 70Hz, 75Hz      */
-    {0, 1024, 768, 70, NULL},
-    {0, 1024, 768, 75, NULL},
-    {0, 1088, 612, 60, NULL},   /* 1088x612 mode is 60Hz only               */
-    {0, 1152, 864, 60, NULL},   /* 1152x864 modes are 60Hz, 70Hz, 72Hz      */
-    {0, 1152, 864, 70, NULL},   /* 75Hz and 85Hz                            */
-    {0, 1152, 864, 72, NULL},
-    {0, 1152, 864, 75, NULL},
-    {0, 1152, 864, 85, NULL},
-    {0, 1280, 720, 60, NULL},   /* 1280x720 mode is 60Hz only               */
-    {0, 1280, 768, 60, NULL},   /* 1280x768 mode is 60Hz only               */
-    {0, 1280, 800, 60, NULL},   /* 1280x800 mode is 60Hz only               */
-    {0, 1280, 960, 60, NULL},   /* 1280x960 mode is 60Hz only               */
-    {0, 1280, 1024, 60, NULL},  /* 1280x1024 modes are 60Hz, 75Hz, 85Hz and */
-    {0, 1280, 1024, 75, NULL},  /* 100 Hz                                   */
-    {0, 1280, 1024, 85, NULL},  /*                                          */
-    {0, 1280, 1024, 100, NULL}, /*                                          */
-    {0, 1360, 768, 60, NULL},   /* 1360x768 mode is 60Hz only               */
-    {0, 1400, 1050, 60, NULL},  /* 1400x1050 mode is 60Hz only              */
-    {0, 1440, 900, 60, NULL},   /* 1440x900 mode is 60Hz only               */
-    {0, 1440, 960, 60, NULL},   /* 1440x960 mode is 60Hz only               */
-    {0, 1600, 900, 60, NULL},   /* 1600x900 mode is 60Hz only               */
-    {0, 1600, 1024, 60, NULL},  /* 1600x1024 mode is 60Hz only              */
-    {0, 1600, 1200, 60, NULL},  /* 1600x1200 mode is 60Hz only              */
-    {0, 1680, 1050, 60, NULL},  /* 1680x1050 mode is 60Hz only              */
-    {0, 1920, 1080, 60, NULL},  /* 1920x1080 mode is 60Hz only              */
-    {0, 1920, 1200, 60, NULL},  /* 1920x1200 mode is 60Hz only              */
-    {0, 1920, 1440, 60, NULL},  /* 1920x1440 mode is 60Hz only              */
-    {0, 2048, 1536, 60, NULL},  /* 2048x1536 mode is 60Hz only              */
-    {0, 2048, 1080, 60, NULL},  /* 2048x1080 mode is 60Hz only              */
-    {0, 0, 0, 0, NULL}          /* End of generic mode list                 */
-};
-
-/* Low level device graphics driver names, which they are reporting */
-static const GF_DeviceCaps gf_devicename[] = {
-    /* ATI Rage 128 graphics driver (devg-ati_rage128)      */
-    {"ati_rage128", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Fujitsu Carmine graphics driver (devg-carmine.so)    */
-    {"carmine", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* C&T graphics driver (devg-chips.so)                  */
-    {"chips", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Fujitsu Coral graphics driver (devg-coral.so)        */
-    {"coral", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Intel integrated graphics driver (devg-extreme2.so)  */
-    {"extreme2", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Unaccelerated FB driver (devg-flat.so)               */
-    {"flat", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY},
-    /* NS Geode graphics driver (devg-geode.so)             */
-    {"geode", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Geode LX graphics driver (devg-geodelx.so)           */
-    {"geodelx", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Intel integrated graphics driver (devg-gma9xx.so)    */
-    {"gma", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Intel integrated graphics driver (devg-i810.so)      */
-    {"i810", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Intel integrated graphics driver (devg-i830.so)      */
-    {"i830", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Geode LX graphics driver (devg-lx800.so)             */
-    {"lx800", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Matrox Gxx graphics driver (devg-matroxg.so)         */
-    {"matroxg", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Intel Poulsbo graphics driver (devg-poulsbo.so)      */
-    {"poulsbo", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* ATI Radeon driver (devg-radeon.so)                   */
-    {"radeon", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* ATI Rage driver (devg-rage.so)                       */
-    {"rage", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* S3 Savage graphics driver (devg-s3_savage.so)        */
-    {"s3_savage", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* SiS630 integrated graphics driver (devg-sis630.so)   */
-    {"sis630", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* PowerVR SGX 535 graphics driver (devg-poulsbo.so)    */
-    {"sgx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* SM Voyager GX graphics driver (devg-smi5xx.so)       */
-    {"smi5xx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* Silicon Motion graphics driver (devg-smi7xx.so)      */
-    {"smi7xx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* SVGA unaccelerated gfx driver (devg-svga.so)         */
-    {"svga", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY},
-    /* nVidia TNT graphics driver (devg-tnt.so)             */
-    {"tnt", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* VIA integrated graphics driver (devg-tvia.so)        */
-    {"tvia", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* VIA UniChrome graphics driver (devg-unichrome.so)    */
-    {"unichrome", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* VESA unaccelerated gfx driver (devg-vesa.so)         */
-    {"vesa", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY},
-    /* VmWare graphics driver (devg-volari.so)              */
-    {"vmware", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY},
-    /* XGI XP10 graphics driver (devg-volari.so)            */
-    {"volari", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION |
-     SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
-    /* End of list */
-    {NULL, 0x00000000}
-};
-
-/*****************************************************************************/
-/* SDL Video Device initialization functions                                 */
-/*****************************************************************************/
-
-static int
-qnxgf_available(void)
-{
-    gf_dev_t gfdev;
-    gf_dev_info_t gfdev_info;
-    int status;
-
-    /* Try to attach to graphics device driver */
-    status = gf_dev_attach(&gfdev, GF_DEVICE_INDEX(0), &gfdev_info);
-    if (status != GF_ERR_OK) {
-        return 0;
-    }
-
-    /* Detach from graphics device driver for now */
-    gf_dev_detach(gfdev);
-
-    return 1;
-}
-
-static void
-qnxgf_destroy(SDL_VideoDevice * device)
-{
-    SDL_VideoData *gfdata = (SDL_VideoData *) device->driverdata;
-
-    /* Detach from graphics device driver, if it was initialized */
-    if (gfdata->gfinitialized != SDL_FALSE) {
-        gf_dev_detach(gfdata->gfdev);
-        gfdata->gfdev = NULL;
-    }
-
-    if (device->driverdata != NULL) {
-        device->driverdata = NULL;
-    }
-}
-
-static SDL_VideoDevice *
-qnxgf_create(int devindex)
-{
-    SDL_VideoDevice *device;
-    SDL_VideoData *gfdata;
-    int status;
-
-    /* Initialize SDL_VideoDevice structure */
-    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
-    if (device == NULL) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    /* Initialize internal GF specific data */
-    gfdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
-    if (gfdata == NULL) {
-        SDL_OutOfMemory();
-        SDL_free(device);
-        return NULL;
-    }
-    device->driverdata = gfdata;
-
-    /* By default GF is not initialized */
-    gfdata->gfinitialized = SDL_FALSE;
-
-    /* Try to attach to graphics device driver */
-    status =
-        gf_dev_attach(&gfdata->gfdev, GF_DEVICE_INDEX(devindex),
-                      &gfdata->gfdev_info);
-    if (status != GF_ERR_OK) {
-        SDL_OutOfMemory();
-        SDL_free(gfdata);
-        SDL_free(device);
-        return NULL;
-    }
-
-    if (gfdata->gfdev_info.description == NULL) {
-        gf_dev_detach(gfdata->gfdev);
-        SDL_SetError("GF: Failed to initialize graphics driver");
-        return NULL;
-    }
-
-    /* Setup amount of available displays and current display */
-    device->num_displays = 0;
-    device->current_display = 0;
-
-    /* Setup device shutdown function */
-    gfdata->gfinitialized = SDL_TRUE;
-    device->free = qnxgf_destroy;
-
-    /* Setup all functions which we can handle */
-    device->VideoInit = qnxgf_videoinit;
-    device->VideoQuit = qnxgf_videoquit;
-    device->GetDisplayModes = qnxgf_getdisplaymodes;
-    device->SetDisplayMode = qnxgf_setdisplaymode;
-    device->SetDisplayPalette = qnxgf_setdisplaypalette;
-    device->GetDisplayPalette = qnxgf_getdisplaypalette;
-    device->SetDisplayGammaRamp = qnxgf_setdisplaygammaramp;
-    device->GetDisplayGammaRamp = qnxgf_getdisplaygammaramp;
-    device->CreateWindow = qnxgf_createwindow;
-    device->CreateWindowFrom = qnxgf_createwindowfrom;
-    device->SetWindowTitle = qnxgf_setwindowtitle;
-    device->SetWindowIcon = qnxgf_setwindowicon;
-    device->SetWindowPosition = qnxgf_setwindowposition;
-    device->SetWindowSize = qnxgf_setwindowsize;
-    device->ShowWindow = qnxgf_showwindow;
-    device->HideWindow = qnxgf_hidewindow;
-    device->RaiseWindow = qnxgf_raisewindow;
-    device->MaximizeWindow = qnxgf_maximizewindow;
-    device->MinimizeWindow = qnxgf_minimizewindow;
-    device->RestoreWindow = qnxgf_restorewindow;
-    device->SetWindowGrab = qnxgf_setwindowgrab;
-    device->DestroyWindow = qnxgf_destroywindow;
-    device->GetWindowWMInfo = qnxgf_getwindowwminfo;
-    device->GL_LoadLibrary = qnxgf_gl_loadlibrary;
-    device->GL_GetProcAddress = qnxgf_gl_getprocaddres;
-    device->GL_UnloadLibrary = qnxgf_gl_unloadlibrary;
-    device->GL_CreateContext = qnxgf_gl_createcontext;
-    device->GL_MakeCurrent = qnxgf_gl_makecurrent;
-    device->GL_SetSwapInterval = qnxgf_gl_setswapinterval;
-    device->GL_GetSwapInterval = qnxgf_gl_getswapinterval;
-    device->GL_SwapWindow = qnxgf_gl_swapwindow;
-    device->GL_DeleteContext = qnxgf_gl_deletecontext;
-    device->PumpEvents = qnxgf_pumpevents;
-    device->SuspendScreenSaver = qnxgf_suspendscreensaver;
-
-    return device;
-}
-
-VideoBootStrap qnxgf_bootstrap = {
-    "qnxgf",
-    "SDL QNX Graphics Framework (GF) video driver",
-    qnxgf_available,
-    qnxgf_create
-};
-
-/*****************************************************************************/
-/* SDL Video and Display initialization/handling functions                   */
-/*****************************************************************************/
-int
-qnxgf_videoinit(_THIS)
-{
-    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
-    uint32_t it;
-    uint32_t jt;
-    char *override;
-    int32_t status;
-
-    /* By default GF uses buffer swap on vsync */
-    gfdata->swapinterval = 1;
-
-    /* Add each detected output to SDL */
-    for (it = 0; it < gfdata->gfdev_info.ndisplays; it++) {
-        SDL_VideoDisplay display;
-        SDL_DisplayMode current_mode;
-        SDL_DisplayData *didata;
-
-        didata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
-        if (didata == NULL) {
-            /* memory allocation problem */
-            SDL_OutOfMemory();
-            return -1;
-        }
-
-        /* Set default cursor settings, maximum 128x128 cursor */
-        didata->cursor_visible = SDL_FALSE;
-        didata->cursor.type = GF_CURSOR_BITMAP;
-        didata->cursor.hotspot.x = 0;
-        didata->cursor.hotspot.y = 0;
-        didata->cursor.cursor.bitmap.w = SDL_VIDEO_GF_MAX_CURSOR_SIZE;
-        didata->cursor.cursor.bitmap.h = SDL_VIDEO_GF_MAX_CURSOR_SIZE;
-        didata->cursor.cursor.bitmap.stride =
-            (didata->cursor.cursor.bitmap.w + 7) / (sizeof(uint8_t) * 8);
-        didata->cursor.cursor.bitmap.color0 = 0x00000000;
-        didata->cursor.cursor.bitmap.color1 = 0x00000000;
-        didata->cursor.cursor.bitmap.image0 =
-            SDL_calloc(sizeof(uint8_t),
-                       (didata->cursor.cursor.bitmap.w +
-                        7) * didata->cursor.cursor.bitmap.h /
-                       (sizeof(uint8_t) * 8));
-        if (didata->cursor.cursor.bitmap.image0 == NULL) {
-            SDL_free(didata);
-            SDL_OutOfMemory();
-            return -1;
-        }
-        didata->cursor.cursor.bitmap.image1 =
-            SDL_calloc(sizeof(uint8_t),
-                       (didata->cursor.cursor.bitmap.w +
-                        7) * didata->cursor.cursor.bitmap.h /
-                       (sizeof(uint8_t) * 8));
-        if (didata->cursor.cursor.bitmap.image1 == NULL) {
-            SDL_OutOfMemory();
-            SDL_free((void *) didata->cursor.cursor.bitmap.image0);
-            SDL_free(didata);
-            return -1;
-        }
-
-        /* Query current display settings */
-        status = gf_display_query(gfdata->gfdev, it, &didata->display_info);
-        if (status == GF_ERR_OK) {
-            SDL_zero(current_mode);
-            current_mode.w = didata->display_info.xres;
-            current_mode.h = didata->display_info.yres;
-            current_mode.refresh_rate = didata->display_info.refresh;
-            current_mode.format =
-                qnxgf_gf_to_sdl_pixelformat(didata->display_info.format);
-            current_mode.driverdata = NULL;
-        } else {
-            /* video initialization problem */
-            SDL_free((void *) didata->cursor.cursor.bitmap.image0);
-            SDL_free((void *) didata->cursor.cursor.bitmap.image1);
-            SDL_free(didata);
-            SDL_SetError("GF: Display query failed");
-            return -1;
-        }
-
-        /* Attach GF to selected display */
-        status = gf_display_attach(&didata->display, gfdata->gfdev, it, NULL);
-        if (status != GF_ERR_OK) {
-            /* video initialization problem */
-            SDL_free((void *) didata->cursor.cursor.bitmap.image0);
-            SDL_free((void *) didata->cursor.cursor.bitmap.image1);
-            SDL_free(didata);
-            SDL_SetError("GF: Couldn't attach to display");
-            return -1;
-        }
-
-        /* Initialize status variables */
-        didata->layer_attached = SDL_FALSE;
-
-        /* Attach to main display layer */
-        status =
-            gf_layer_attach(&didata->layer, didata->display,
-                            didata->display_info.main_layer_index, 0);
-        if (status != GF_ERR_OK) {
-            /* Failed to attach to main layer */
-            SDL_free((void *) didata->cursor.cursor.bitmap.image0);
-            SDL_free((void *) didata->cursor.cursor.bitmap.image1);
-            SDL_free(didata);
-            SDL_SetError
-                ("GF: Couldn't attach to main layer, it could be busy");
-            return -1;
-        }
-
-        /* Mark main display layer is attached */
-        didata->layer_attached = SDL_TRUE;
-
-        /* Set layer source and destination viewport */
-        gf_layer_set_src_viewport(didata->layer, 0, 0, current_mode.w - 1,
-                                  current_mode.h - 1);
-        gf_layer_set_dst_viewport(didata->layer, 0, 0, current_mode.w - 1,
-                                  current_mode.h - 1);
-
-        /* Create main visible on display surface */
-        status = gf_surface_create_layer(&didata->surface[0], &didata->layer,
-                                         1, 0, current_mode.w, current_mode.h,
-                                         qnxgf_sdl_to_gf_pixelformat
-                                         (current_mode.format), NULL,
-                                         GF_SURFACE_CREATE_2D_ACCESSIBLE |
-                                         GF_SURFACE_CREATE_3D_ACCESSIBLE |
-                                         GF_SURFACE_CREATE_SHAREABLE);
-        if (status != GF_ERR_OK) {
-            gf_layer_disable(didata->layer);
-            gf_layer_detach(didata->layer);
-            didata->layer_attached = SDL_FALSE;
-            SDL_free((void *) didata->cursor.cursor.bitmap.image0);
-            SDL_free((void *) didata->cursor.cursor.bitmap.image1);
-            SDL_free(didata);
-            SDL_SetError("GF: Can't create main layer surface at init (%d)\n",
-                         status);
-            return -1;
-        }
-
-        /* Set just created surface as main visible on the layer */
-//      gf_layer_set_surfaces(didata->layer, &didata->surface[0], 1);
-
-        /* Update layer parameters */
-        status = gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE);
-        if (status != GF_ERR_OK) {
-            /* Free allocated surface */
-            gf_surface_free(didata->surface[0]);
-            didata->surface[0] = NULL;
-
-            /* Disable and detach from layer */
-            gf_layer_disable(didata->layer);
-            gf_layer_detach(didata->layer);
-            didata->layer_attached = SDL_FALSE;
-            SDL_free((void *) didata->cursor.cursor.bitmap.image0);
-            SDL_free((void *) didata->cursor.cursor.bitmap.image1);
-            SDL_free(didata);
-            SDL_SetError("GF: Can't update layer parameters\n");
-            return -1;
-        }
-
-        /* Enable layer in case if hardware supports layer enable/disable */
-        gf_layer_enable(didata->layer);
-
-        /* Copy device name for each display */
-        SDL_strlcpy(didata->description, gfdata->gfdev_info.description,
-                    SDL_VIDEO_GF_DEVICENAME_MAX - 1);
-
-        /* Search device capabilities and possible workarounds */
-        jt = 0;
-        do {
-            if (gf_devicename[jt].name == NULL) {
-                break;
-            }
-            if (SDL_strncmp
-                (gf_devicename[jt].name, didata->description,
-                 SDL_strlen(gf_devicename[jt].name)) == 0) {
-                didata->caps = gf_devicename[jt].caps;
-            }
-            jt++;
-        } while (1);
-
-        /* Initialize display structure */
-        SDL_zero(display);
-        display.desktop_mode = current_mode;
-        display.current_mode = current_mode;
-        display.driverdata = didata;
-        didata->current_mode = current_mode;
-        SDL_AddVideoDisplay(&display);
-
-        /* Check for environment variables which could override some SDL settings */
-        didata->custom_refresh = 0;
-        override = SDL_getenv("SDL_VIDEO_GF_REFRESH_RATE");
-        if (override != NULL) {
-            if (SDL_sscanf(override, "%u", &didata->custom_refresh) != 1) {
-                didata->custom_refresh = 0;
-            }
-        }
-
-        /* Get all display modes for this display */
-        qnxgf_getdisplaymodes(_this, display);
-    }
-
-    /* Add GF renderer to SDL */
-    gf_addrenderdriver(_this);
-
-    /* Add GF input devices */
-    status = gf_addinputdevices(_this);
-    if (status != 0) {
-        /* SDL error is set by gf_addinputdevices() function */
-        return -1;
-    }
-
-    /* video has been initialized successfully */
-    return 1;
-}
-
-void
-qnxgf_videoquit(_THIS)
-{
-    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *didata = NULL;
-    uint32_t it;
-
-    /* Check if GF was initialized before */
-    if ((gfdata == NULL) || (gfdata->gfinitialized != SDL_TRUE))
-    {
-        /* If not, do not deinitialize */
-        return;
-    }
-
-    /* Stop collecting mouse events */
-    hiddi_disable_mouse();
-    /* Delete GF input devices */
-    gf_delinputdevices(_this);
-
-    /* SDL will restore old desktop mode on exit */
-    for (it = 0; it < _this->num_displays; it++) {
-        didata = _this->displays[it].driverdata;
-
-        /* Free cursor image */
-        if (didata->cursor.cursor.bitmap.image0 != NULL) {
-            SDL_free((void *) didata->cursor.cursor.bitmap.image0);
-            didata->cursor.cursor.bitmap.image0 = NULL;
-        }
-        if (didata->cursor.cursor.bitmap.image1 != NULL) {
-            SDL_free((void *) didata->cursor.cursor.bitmap.image1);
-            didata->cursor.cursor.bitmap.image1 = NULL;
-        }
-
-        /* Free main surface */
-        if (didata->surface[0] != NULL) {
-            gf_surface_free(didata->surface[0]);
-            didata->surface[0] = NULL;
-        }
-
-        /* Free back surface */
-        if (didata->surface[1] != NULL) {
-            gf_surface_free(didata->surface[1]);
-            didata->surface[1] = NULL;
-        }
-
-        /* Free second back surface */
-        if (didata->surface[2] != NULL) {
-            gf_surface_free(didata->surface[2]);
-            didata->surface[2] = NULL;
-        }
-
-        /* Detach layer before quit */
-        if (didata->layer_attached == SDL_TRUE) {
-            /* Disable layer if hardware supports this */
-            gf_layer_disable(didata->layer);
-
-            /* Detach from layer, free it for others */
-            gf_layer_detach(didata->layer);
-            didata->layer = NULL;
-
-            /* Mark it as detached */
-            didata->layer_attached = SDL_FALSE;
-        }
-
-        /* Detach from selected display */
-        gf_display_detach(didata->display);
-        didata->display = NULL;
-    }
-}
-
-void
-qnxgf_getdisplaymodes(_THIS, SDL_VideoDisplay * display)
-{
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-    SDL_DisplayMode mode;
-    gf_modeinfo_t modeinfo;
-    uint32_t it = 0;
-    uint32_t jt = 0;
-    uint32_t kt = 0;
-    int status;
-
-    do {
-        status = gf_display_query_mode(didata->display, it, &modeinfo);
-        if (status == GF_ERR_OK) {
-            /* Parsing current mode */
-            if ((modeinfo.flags & GF_MODE_GENERIC) == GF_MODE_GENERIC) {
-                /* This mode is generic, so we can add to SDL our resolutions */
-                /* Only pixel format is fixed, refresh rate could be any      */
-                jt = 0;
-                do {
-                    if (generic_mode[jt].w == 0) {
-                        break;
-                    }
-
-                    /* Check if driver do not supports doublescan video modes */
-                    if ((didata->caps & SDL_GF_LOWRESOLUTION) !=
-                        SDL_GF_LOWRESOLUTION) {
-                        if (generic_mode[jt].w < 640) {
-                            jt++;
-                            continue;
-                        }
-                    }
-
-                    mode.w = generic_mode[jt].w;
-                    mode.h = generic_mode[jt].h;
-                    mode.refresh_rate = generic_mode[jt].refresh_rate;
-                    mode.format =
-                        qnxgf_gf_to_sdl_pixelformat(modeinfo.primary_format);
-                    mode.driverdata = NULL;
-                    SDL_AddDisplayMode(display, &mode);
-
-                    /* If mode is RGBA8888, add the same mode as RGBx888 */
-                    if (modeinfo.primary_format == GF_FORMAT_BGRA8888) {
-                        mode.w = generic_mode[jt].w;
-                        mode.h = generic_mode[jt].h;
-                        mode.refresh_rate = generic_mode[jt].refresh_rate;
-                        mode.format = SDL_PIXELFORMAT_RGB888;
-                        mode.driverdata = NULL;
-                        SDL_AddDisplayMode(display, &mode);
-                    }
-                    /* If mode is RGBA1555, add the same mode as RGBx555 */
-                    if (modeinfo.primary_format == GF_FORMAT_PACK_ARGB1555) {
-                        mode.w = generic_mode[jt].w;
-                        mode.h = generic_mode[jt].h;
-                        mode.refresh_rate = generic_mode[jt].refresh_rate;
-                        mode.format = SDL_PIXELFORMAT_RGB555;
-                        mode.driverdata = NULL;
-                        SDL_AddDisplayMode(display, &mode);
-                    }
-
-                    jt++;
-                } while (1);
-            } else {
-                /* Add this display mode as is in case if it is non-generic */
-                /* But go through the each refresh rate, supported by gf    */
-                jt = 0;
-                do {
-                    if (modeinfo.refresh[jt] != 0) {
-                        mode.w = modeinfo.xres;
-                        mode.h = modeinfo.yres;
-                        mode.refresh_rate = modeinfo.refresh[jt];
-                        mode.format =
-                            qnxgf_gf_to_sdl_pixelformat(modeinfo.
-                                                        primary_format);
-                        mode.driverdata = NULL;
-                        SDL_AddDisplayMode(display, &mode);
-
-                        /* If mode is RGBA8888, add the same mode as RGBx888 */
-                        if (modeinfo.primary_format == GF_FORMAT_BGRA8888) {
-                            mode.w = modeinfo.xres;
-                            mode.h = modeinfo.yres;
-                            mode.refresh_rate = modeinfo.refresh[jt];
-                            mode.format = SDL_PIXELFORMAT_RGB888;
-                            mode.driverdata = NULL;
-                            SDL_AddDisplayMode(display, &mode);
-                        }
-                        /* If mode is RGBA1555, add the same mode as RGBx555 */
-                        if (modeinfo.primary_format ==
-                            GF_FORMAT_PACK_ARGB1555) {
-                            mode.w = modeinfo.xres;
-                            mode.h = modeinfo.yres;
-                            mode.refresh_rate = modeinfo.refresh[jt];
-                            mode.format = SDL_PIXELFORMAT_RGB555;
-                            mode.driverdata = NULL;
-                            SDL_AddDisplayMode(display, &mode);
-                        }
-
-                        jt++;
-                    } else {
-                        break;
-                    }
-                } while (1);
-            }
-        } else {
-            if (status == GF_ERR_PARM) {
-                /* out of available modes, all are listed */
-                break;
-            }
-
-            /* Error occured during mode listing */
-            break;
-        }
-        it++;
-    } while (1);
-}
-
-int
-qnxgf_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
-{
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-    uint32_t refresh_rate = 0;
-    int status;
-
-    /* Current display dimensions and bpp are no more valid */
-    didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN;
-    didata->current_mode.w = 0;
-    didata->current_mode.h = 0;
-
-    /* Check if custom refresh rate requested */
-    if (didata->custom_refresh != 0) {
-        refresh_rate = didata->custom_refresh;
-    } else {
-        refresh_rate = mode->refresh_rate;
-    }
-
-    /* Check if SDL GF driver needs to find appropriate refresh rate itself */
-    if (refresh_rate == 0) {
-        uint32_t it;
-        SDL_DisplayMode tempmode;
-
-        /* Clear display mode structure */
-        SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode));
-        tempmode.refresh_rate = 0x0000FFFF;
-
-        /* Check if window width and height matches one of our modes */
-        for (it = 0; it < display->num_display_modes; it++) {
-            if ((display->display_modes[it].w == mode->w) &&
-                (display->display_modes[it].h == mode->h) &&
-                (display->display_modes[it].format == mode->format))
-            {
-                /* Find the lowest refresh rate available */
-                if (tempmode.refresh_rate >
-                    display->display_modes[it].refresh_rate) {
-                    tempmode = display->display_modes[it];
-                }
-            }
-        }
-        if (tempmode.refresh_rate != 0x0000FFFF) {
-            refresh_rate = tempmode.refresh_rate;
-        } else {
-            /* Let video driver decide what to do with this */
-            refresh_rate = 0;
-        }
-    }
-
-    /* Check if SDL GF driver needs to check custom refresh rate */
-    if (didata->custom_refresh != 0) {
-        uint32_t it;
-        SDL_DisplayMode tempmode;
-
-        /* Clear display mode structure */
-        SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode));
-        tempmode.refresh_rate = 0x0000FFFF;
-
-        /* Check if window width and height matches one of our modes */
-        for (it = 0; it < display->num_display_modes; it++) {
-            if ((display->display_modes[it].w == mode->w) &&
-                (display->display_modes[it].h == mode->h) &&
-                (display->display_modes[it].format == mode->format))
-            {
-                /* Find the lowest refresh rate available */
-                if (tempmode.refresh_rate >
-                    display->display_modes[it].refresh_rate) {
-                    tempmode = display->display_modes[it];
-                }
-
-                /* Check if requested refresh rate found */
-                if (refresh_rate ==
-                    display->display_modes[it].refresh_rate) {
-                    tempmode = display->display_modes[it];
-                    break;
-                }
-            }
-        }
-        if (tempmode.refresh_rate != 0x0000FFFF) {
-            refresh_rate = tempmode.refresh_rate;
-        } else {
-            /* Let video driver decide what to do with this */
-            refresh_rate = 0;
-        }
-    }
-
-    /* Free main surface */
-    if (didata->surface[0] != NULL) {
-        gf_surface_free(didata->surface[0]);
-        didata->surface[0] = NULL;
-    }
-
-    /* Free back surface */
-    if (didata->surface[1] != NULL) {
-        gf_surface_free(didata->surface[1]);
-        didata->surface[1] = NULL;
-    }
-
-    /* Free second back surface */
-    if (didata->surface[2] != NULL) {
-        gf_surface_free(didata->surface[2]);
-        didata->surface[2] = NULL;
-    }
-
-    /* Detach layer before switch to new graphics mode */
-    if (didata->layer_attached == SDL_TRUE) {
-        /* Disable layer if hardware supports this */
-        gf_layer_disable(didata->layer);
-
-        /* Detach from layer, free it for others */
-        gf_layer_detach(didata->layer);
-
-        /* Mark it as detached */
-        didata->layer_attached = SDL_FALSE;
-    }
-
-    /* Set new display video mode */
-    status =
-        gf_display_set_mode(didata->display, mode->w, mode->h, refresh_rate,
-                            qnxgf_sdl_to_gf_pixelformat(mode->format), 0);
-    if (status != GF_ERR_OK) {
-        /* Display mode/resolution switch has been failed */
-        SDL_SetError("GF: Mode is not supported by graphics driver");
-        return -1;
-    } else {
-        didata->current_mode = *mode;
-        didata->current_mode.refresh_rate = refresh_rate;
-    }
-
-    /* Attach to main display layer */
-    status =
-        gf_layer_attach(&didata->layer, didata->display,
-                        didata->display_info.main_layer_index, 0);
-    if (status != GF_ERR_OK) {
-        SDL_SetError("GF: Couldn't attach to main layer, it could be busy");
-
-        /* Failed to attach to main displayable layer */
-        return -1;
-    }
-
-    /* Mark main display layer is attached */
-    didata->layer_attached = SDL_TRUE;
-
-    /* Set layer source and destination viewports */
-    gf_layer_set_src_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1);
-    gf_layer_set_dst_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1);
-
-    /* Create main visible on display surface */
-    status =
-        gf_surface_create_layer(&didata->surface[0], &didata->layer, 1, 0,
-                                mode->w, mode->h,
-                                qnxgf_sdl_to_gf_pixelformat(mode->format),
-                                NULL,
-                                GF_SURFACE_CREATE_2D_ACCESSIBLE |
-                                GF_SURFACE_CREATE_3D_ACCESSIBLE |
-                                GF_SURFACE_CREATE_SHAREABLE);
-    if (status != GF_ERR_OK) {
-        gf_layer_disable(didata->layer);
-        gf_layer_detach(didata->layer);
-        didata->layer_attached = SDL_FALSE;
-        SDL_SetError
-            ("GF: Can't create main layer surface at modeswitch (%d)\n",
-             status);
-        return -1;
-    }
-
-    /* Set just created surface as main visible on the layer */
-    gf_layer_set_surfaces(didata->layer, &didata->surface[0], 1);
-
-    /* Update layer parameters */
-    status = gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE);
-    if (status != GF_ERR_OK) {
-        /* Free main surface */
-        gf_surface_free(didata->surface[0]);
-        didata->surface[0] = NULL;
-
-        /* Detach layer */
-        gf_layer_disable(didata->layer);
-        gf_layer_detach(didata->layer);
-        didata->layer_attached = SDL_FALSE;
-        SDL_SetError("GF: Can't update layer parameters\n");
-        return -1;
-    }
-
-    /* Restore cursor if it was visible */
-    if (didata->cursor_visible == SDL_TRUE) {
-        gf_cursor_set(didata->display, 0, &didata->cursor);
-        gf_cursor_enable(didata->display, 0);
-    }
-
-    /* Enable layer in case if hardware supports layer enable/disable */
-    gf_layer_enable(didata->layer);
-
-    return 0;
-}
-
-int
-qnxgf_setdisplaypalette(_THIS, SDL_VideoDisplay * display, SDL_Palette * palette)
-{
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-
-    /* QNX GF doesn't have support for global palette changing, but we */
-    /* could store it for usage in future */
-
-    SDL_Unsupported();
-    return -1;
-}
-
-int
-qnxgf_getdisplaypalette(_THIS, SDL_VideoDisplay * display, SDL_Palette * palette)
-{
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-
-    /* We can't provide current palette settings and looks like SDL          */
-    /* do not call this function also, in such case this function returns -1 */
-
-    SDL_Unsupported();
-    return -1;
-}
-
-int
-qnxgf_setdisplaygammaramp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
-{
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-    int status;
-
-    /* Setup gamma ramp, for each color channel */
-    status =
-        gf_display_set_color_lut16(didata->display, (uint16_t *) ramp,
-                                   (uint16_t *) ramp + 256,
-                                   (uint16_t *) ramp + 512);
-    if (status != GF_ERR_OK) {
-        /* Setting display gamma ramp operation has been failed */
-        return -1;
-    }
-
-    return 0;
-}
-
-int
-qnxgf_getdisplaygammaramp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
-{
-    /* TODO: We need to return previous gamma set           */
-    /*       Also we need some initial fake gamma to return */
-
-    SDL_Unsupported();
-    return -1;
-}
-
-int
-qnxgf_createwindow(_THIS, SDL_Window * window)
-{
-    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
-    SDL_VideoDisplay *display = window->display;
-    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
-    SDL_WindowData *wdata;
-    int32_t status;
-
-    /* QNX GF supports fullscreen window modes only */
-    if ((window->flags & SDL_WINDOW_FULLSCREEN) != SDL_WINDOW_FULLSCREEN) {
-        uint32_t it;
-        SDL_DisplayMode mode;
-
-        /* Clear display mode structure */
-        SDL_memset(&mode, 0x00, sizeof(SDL_DisplayMode));
-        mode.refresh_rate = 0x0000FFFF;
-
-        /* Check if window width and height matches one of our modes */
-        for (it = 0; it < display->num_display_modes; it++) {
-            if ((display->display_modes[it].w == window->w) &&
-                (display->display_modes[it].h == window->h) &&
-                (display->display_modes[it].format ==
-                 display->desktop_mode.format)) {
-                /* Find the lowest refresh rate available */
-                if (mode.refresh_rate >
-                    display->display_modes[it].refresh_rate) {
-                    mode = display->display_modes[it];
-                }
-            }
-        }
-
-        /* Check if end of display list has been reached */
-        if (mode.refresh_rate == 0x0000FFFF) {
-            SDL_SetError("GF: Desired video mode is not supported");
-
-            /* Failed to create new window */
-            return -1;
-        } else {
-            /* Tell to the caller that mode will be fullscreen */
-            window->flags |= SDL_WINDOW_FULLSCREEN;
-
-            /* Setup fullscreen mode, bpp used from desktop mode in this case */
-            status = qnxgf_setdisplaymode(_this, &mode);
-            if (status != 0) {
-                /* Failed to swith fullscreen video mode */
-                return -1;
-            }
-        }
-    }
-
-    /* Setup our own window decorations and states, which are depend on fullscreen mode */
-    window->flags |= SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS |
-        SDL_WINDOW_MAXIMIZED | SDL_WINDOW_INPUT_GRABBED |
-        SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS;
-    window->flags &= ~(SDL_WINDOW_RESIZABLE | SDL_WINDOW_MINIMIZED);
-
-    /* Ignore any window position settings */
-    window->x = SDL_WINDOWPOS_UNDEFINED;
-    window->y = SDL_WINDOWPOS_UNDEFINED;
-
-    /* Allocate window internal data */
-    wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
-    if (wdata == NULL) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    /* Setup driver data for this window */
-    window->driverdata = wdata;
-
-    /* Check if window must support OpenGL ES rendering */
-    if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) {
-#if defined(SDL_VIDEO_OPENGL_ES)
-        EGLBoolean initstatus;
-
-        /* Mark this window as OpenGL ES compatible */
-        wdata->uses_gles = SDL_TRUE;
-
-        /* Create connection to OpenGL ES */
-        if (gfdata->egldisplay == EGL_NO_DISPLAY) {
-            gfdata->egldisplay = eglGetDisplay(gfdata->gfdev);
-            if (gfdata->egldisplay == EGL_NO_DISPLAY) {
-                SDL_SetError("GF: Can't get connection to OpenGL ES");
-                return -1;
-            }
-
-            /* Initialize OpenGL ES library, ignore EGL version */
-            initstatus = eglInitialize(gfdata->egldisplay, NULL, NULL);
-            if (initstatus != EGL_TRUE) {
-                SDL_SetError("GF: Can't init OpenGL ES library");
-                return -1;
-            }
-        }
-
-        /* Increment GL ES reference count usage */
-        gfdata->egl_refcount++;
-#else
-        SDL_SetError("GF: OpenGL ES support is not compiled in");
-        return -1;
-#endif /* SDL_VIDEO_OPENGL_ES */
-    }
-
-    /* Enable mouse event collecting */
-    hiddi_enable_mouse();
-
-    /* By default last created window got a input focus */
-    SDL_SetKeyboardFocus(0, window);
-    SDL_SetMouseFocus(0, window);
-
-    /* Window has been successfully created */
-    return 0;
-}
-
-int
-qnxgf_createwindowfrom(_THIS, SDL_Window * window, const void *data)
-{
-    /* Failed to create window from another window */
-    return -1;
-}
-
-void
-qnxgf_setwindowtitle(_THIS, SDL_Window * window)
-{
-}
-
-void
-qnxgf_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon)
-{
-}
-
-void
-qnxgf_setwindowposition(_THIS, SDL_Window * window)
-{
-}
-
-void
-qnxgf_setwindowsize(_THIS, SDL_Window * window)
-{
-}
-
-void
-qnxgf_showwindow(_THIS, SDL_Window * window)
-{
-}
-
-void
-qnxgf_hidewindow(_THIS, SDL_Window * window)
-{
-}
-
-void
-qnxgf_raisewindow(_THIS, SDL_Window * window)
-{
-}
-
-void
-qnxgf_maximizewindow(_THIS, SDL_Window * window)
-{
-}
-
-void
-qnxgf_minimizewindow(_THIS, SDL_Window * window)
-{
-}
-
-void
-qnxgf_restorewindow(_THIS, SDL_Window * window)
-{
-}
-
-void
-qnxgf_setwindowgrab(_THIS, SDL_Window * window)
-{
-}
-
-void
-qnxgf_destroywindow(_THIS, SDL_Window * window)
-{
-    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) window->display->driverdata;
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-
-    if (wdata != NULL) {
-#if defined(SDL_VIDEO_OPENGL_ES)
-        /* Destroy OpenGL ES surface if it was created */
-        if (wdata->gles_surface != EGL_NO_SURFACE) {
-            eglDestroySurface(gfdata->egldisplay, wdata->gles_surface);
-        }
-
-        /* Free any 3D target if it was created before */
-        if (wdata->target_created == SDL_TRUE) {
-            gf_3d_target_free(wdata->target);
-            wdata->target_created == SDL_FALSE;
-        }
-
-        gfdata->egl_refcount--;
-        if (gfdata->egl_refcount == 0) {
-            /* Terminate connection to OpenGL ES */
-            if (gfdata->egldisplay != EGL_NO_DISPLAY) {
-                eglTerminate(gfdata->egldisplay);
-                gfdata->egldisplay = EGL_NO_DISPLAY;
-            }
-        }
-#endif /* SDL_VIDEO_OPENGL_ES */
-    }
-}
-
-/*****************************************************************************/
-/* SDL Window Manager function                                               */
-/*****************************************************************************/
-SDL_bool
-qnxgf_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
-{
-    /* QNX GF do not operates at window level, this means we are have no */
-    /* Window Manager available, no specific data in SDL_SysWMinfo too   */
-
-    if (info->version.major <= SDL_MAJOR_VERSION) {
-        return SDL_TRUE;
-    } else {
-        SDL_SetError("Application not compiled with SDL %d.%d\n",
-                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
-        return SDL_FALSE;
-    }
-
-    /* Failed to get window manager information */
-    return SDL_FALSE;
-}
-
-/*****************************************************************************/
-/* SDL OpenGL/OpenGL ES functions                                            */
-/*****************************************************************************/
-int
-qnxgf_gl_loadlibrary(_THIS, const char *path)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    /* Check if OpenGL ES library is specified for GF driver */
-    if (path == NULL) {
-        path = SDL_getenv("SDL_OPENGL_LIBRARY");
-        if (path == NULL) {
-            path = SDL_getenv("SDL_OPENGLES_LIBRARY");
-        }
-    }
-
-    /* Check if default library loading requested */
-    if (path == NULL) {
-        /* Already linked with GF library which provides egl* subset of  */
-        /* functions, use Common profile of OpenGL ES library by default */
-        path = "/usr/lib/libGLES_CM.so.1";
-    }
-
-    /* Load dynamic library */
-    _this->gl_config.dll_handle = SDL_LoadObject(path);
-    if (!_this->gl_config.dll_handle) {
-        /* Failed to load new GL ES library */
-        SDL_SetError("GF: Failed to locate OpenGL ES library");
-        return -1;
-    }
-
-    /* Store OpenGL ES library path and name */
-    SDL_strlcpy(_this->gl_config.driver_path, path,
-                SDL_arraysize(_this->gl_config.driver_path));
-
-    /* New OpenGL ES library is loaded */
-    return 0;
-#else
-    SDL_SetError("GF: OpenGL ES support is not compiled in");
-    return -1;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-void *
-qnxgf_gl_getprocaddres(_THIS, const char *proc)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    void *function_address;
-
-    /* Try to get function address through the egl interface */
-    function_address = eglGetProcAddress(proc);
-    if (function_address != NULL) {
-        return function_address;
-    }
-
-    /* Then try to get function in the OpenGL ES library */
-    if (_this->gl_config.dll_handle) {
-        function_address =
-            SDL_LoadFunction(_this->gl_config.dll_handle, proc);
-        if (function_address != NULL) {
-            return function_address;
-        }
-    }
-
-    /* Add emulated OpenGL ES 1.1 functions */
-    if (SDL_strcmp(proc, "glTexParameteri") == 0) {
-        return glTexParameteri;
-    }
-    if (SDL_strcmp(proc, "glTexParameteriv") == 0) {
-        return glTexParameteriv;
-    }
-    if (SDL_strcmp(proc, "glColor4ub") == 0) {
-        return glColor4ub;
-    }
-
-    /* Failed to get GL ES function address pointer */
-    SDL_SetError("GF: Cannot locate OpenGL ES function name");
-    return NULL;
-#else
-    SDL_SetError("GF: OpenGL ES support is not compiled in");
-    return NULL;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-void
-qnxgf_gl_unloadlibrary(_THIS)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    /* Unload OpenGL ES library */
-    if (_this->gl_config.dll_handle) {
-        SDL_UnloadObject(_this->gl_config.dll_handle);
-        _this->gl_config.dll_handle = NULL;
-    }
-#else
-    SDL_SetError("GF: OpenGL ES support is not compiled in");
-    return;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-SDL_GLContext
-qnxgf_gl_createcontext(_THIS, SDL_Window * window)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) window->display->driverdata;
-    EGLBoolean status;
-    int32_t gfstatus;
-    EGLint configs;
-    uint32_t surfaces;
-    uint32_t attr_pos;
-    EGLint attr_value;
-    EGLint cit;
-
-    /* Choose buffeingr scheme */
-    if (!_this->gl_config.double_buffer) {
-        surfaces = 1;
-    } else {
-        surfaces = 2;
-    }
-
-    /* If driver has no support of video memory allocation, then */
-    /* disable double buffering, use single buffer present copy  */
-    if ((didata->caps & SDL_GF_VIDEOMEMORY) != SDL_GF_VIDEOMEMORY) {
-        surfaces = 1;
-    }
-
-    /* Free main surface */
-    if (didata->surface[0] != NULL) {
-        gf_surface_free(didata->surface[0]);
-        didata->surface[0] = NULL;
-    }
-
-    /* Free back surface */
-    if (didata->surface[1] != NULL) {
-        gf_surface_free(didata->surface[1]);
-        didata->surface[1] = NULL;
-    }
-
-    /* Free second back surface */
-    if (didata->surface[2] != NULL) {
-        gf_surface_free(didata->surface[2]);
-        didata->surface[2] = NULL;
-    }
-
-    /* Detach layer before switch to new graphics mode */
-    if (didata->layer_attached == SDL_TRUE) {
-        /* Disable layer if hardware supports this */
-        gf_layer_disable(didata->layer);
-
-        /* Detach from layer, free it for others */
-        gf_layer_detach(didata->layer);
-
-        /* Mark it as detached */
-        didata->layer_attached = SDL_FALSE;
-    }
-
-    /* Attach to main display layer */
-    gfstatus =
-        gf_layer_attach(&didata->layer, didata->display,
-                        didata->display_info.main_layer_index, 0);
-    if (gfstatus != GF_ERR_OK) {
-        SDL_SetError("GF: Couldn't attach to main layer, it could be busy");
-
-        /* Failed to attach to main displayable layer */
-        return NULL;
-    }
-
-    /* Mark main display layer is attached */
-    didata->layer_attached = SDL_TRUE;
-
-    /* Set layer source and destination viewport */
-    gf_layer_set_src_viewport(didata->layer, 0, 0, didata->current_mode.w - 1,
-                              didata->current_mode.h - 1);
-    gf_layer_set_dst_viewport(didata->layer, 0, 0, didata->current_mode.w - 1,
-                              didata->current_mode.h - 1);
-
-    /* Create main visible on display surface */
-    gfstatus =
-        gf_surface_create_layer(&didata->surface[0], &didata->layer, 1, 0,
-                                didata->current_mode.w,
-                                didata->current_mode.h,
-                                qnxgf_sdl_to_gf_pixelformat(didata->
-                                                            current_mode.
-                                                            format), NULL,
-                                GF_SURFACE_CREATE_2D_ACCESSIBLE |
-                                GF_SURFACE_CREATE_3D_ACCESSIBLE |
-                                GF_SURFACE_CREATE_SHAREABLE);
-    if (gfstatus != GF_ERR_OK) {
-        gf_layer_disable(didata->layer);
-        gf_layer_detach(didata->layer);
-        didata->layer_attached = SDL_FALSE;
-        SDL_SetError("GF: Can't create main layer surface at glctx (%d)\n",
-                     gfstatus);
-        return NULL;
-    }
-
-    /* Set just created surface as main visible on the layer */
-//      gf_layer_set_surfaces(didata->layer, &didata->surface[0], 1);
-
-    if (surfaces > 1) {
-        /* Create back display surface */
-        gfstatus =
-            gf_surface_create_layer(&didata->surface[1], &didata->layer, 1, 0,
-                                    didata->current_mode.w,
-                                    didata->current_mode.h,
-                                    qnxgf_sdl_to_gf_pixelformat(didata->
-                                                                current_mode.
-                                                                format), NULL,
-                                    GF_SURFACE_CREATE_2D_ACCESSIBLE |
-                                    GF_SURFACE_CREATE_3D_ACCESSIBLE |
-                                    GF_SURFACE_CREATE_SHAREABLE);
-        if (gfstatus != GF_ERR_OK) {
-            gf_surface_free(didata->surface[0]);
-            gf_layer_disable(didata->layer);
-            gf_layer_detach(didata->layer);
-            didata->layer_attached = SDL_FALSE;
-            SDL_SetError
-                ("GF: Can't create main layer surface at glctx (%d)\n",
-                 gfstatus);
-            return NULL;
-        }
-    }
-
-    /* Update layer parameters */
-    gfstatus = gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE);
-    if (gfstatus != GF_ERR_OK) {
-        /* Free main and back surfaces */
-        gf_surface_free(didata->surface[1]);
-        didata->surface[1] = NULL;
-        gf_surface_free(didata->surface[0]);
-        didata->surface[0] = NULL;
-
-        /* Detach layer */
-        gf_layer_disable(didata->layer);
-        gf_layer_detach(didata->layer);
-        didata->layer_attached = SDL_FALSE;
-        SDL_SetError("GF: Can't update layer parameters\n");
-        return NULL;
-    }
-
-    /* Enable layer in case if hardware supports layer enable/disable */
-    gf_layer_enable(didata->layer);
-
-    /* Prepare attributes list to pass them to OpenGL ES */
-    attr_pos = 0;
-    wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID;
-    wdata->gles_attributes[attr_pos++] =
-        qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format);
-    wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE;
-    wdata->gles_attributes[attr_pos++] = _this->gl_config.red_size;
-    wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE;
-    wdata->gles_attributes[attr_pos++] = _this->gl_config.green_size;
-    wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE;
-    wdata->gles_attributes[attr_pos++] = _this->gl_config.blue_size;
-    wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE;
-    if (_this->gl_config.alpha_size) {
-        wdata->gles_attributes[attr_pos++] = _this->gl_config.alpha_size;
-    } else {
-        wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-    }
-
-    wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
-    if (_this->gl_config.depth_size) {
-        wdata->gles_attributes[attr_pos++] = _this->gl_config.depth_size;
-    } else {
-        wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-    }
-
-    if (_this->gl_config.buffer_size) {
-        wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE;
-        wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size;
-    }
-    if (_this->gl_config.stencil_size) {
-        wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
-        wdata->gles_attributes[attr_pos++] = _this->gl_config.stencil_size;
-    }
-
-    /* Set number of samples in multisampling */
-    if (_this->gl_config.multisamplesamples) {
-        wdata->gles_attributes[attr_pos++] = EGL_SAMPLES;
-        wdata->gles_attributes[attr_pos++] =
-            _this->gl_config.multisamplesamples;
-    }
-
-    /* Multisample buffers, OpenGL ES 1.0 spec defines 0 or 1 buffer */
-    if (_this->gl_config.multisamplebuffers) {
-        wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS;
-        wdata->gles_attributes[attr_pos++] =
-            _this->gl_config.multisamplebuffers;
-    }
-
-    /* Finish attributes list */
-    wdata->gles_attributes[attr_pos] = EGL_NONE;
-
-    /* Request first suitable framebuffer configuration */
-    status = eglChooseConfig(gfdata->egldisplay, wdata->gles_attributes,
-                             wdata->gles_configs, SDL_VIDEO_GF_OPENGLES_CONFS,
-                             &configs);
-    if (status != EGL_TRUE) {
-        SDL_SetError("GF: Can't find closest configuration for OpenGL ES");
-        return NULL;
-    }
-
-    /* Check if nothing has been found, try "don't care" settings */
-    if (configs == 0) {
-        int32_t it;
-        int32_t jt;
-        static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE };
-
-        for (it = 0; it < 4; it++) {
-            for (jt = 16; jt >= 0; jt--) {
-                /* Don't care about color buffer bits, use what exist */
-                /* Replace previous data set with EGL_DONT_CARE       */
-                attr_pos = 0;
-                wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID;
-                wdata->gles_attributes[attr_pos++] =
-                    qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format);
-                wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-
-                /* Try to find requested or smallest depth */
-                if (_this->gl_config.depth_size) {
-                    wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
-                    wdata->gles_attributes[attr_pos++] = depthbits[it];
-                } else {
-                    wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
-                    wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                }
-
-                if (_this->gl_config.stencil_size) {
-                    wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
-                    wdata->gles_attributes[attr_pos++] = jt;
-                } else {
-                    wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
-                    wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-
-                    /* exit from stencil loop */
-                    jt = 0;
-                }
-
-                /* Don't care about antialiasing */
-                wdata->gles_attributes[attr_pos++] = EGL_SAMPLES;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS;
-                wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
-                wdata->gles_attributes[attr_pos] = EGL_NONE;
-
-                /* Request first suitable framebuffer configuration */
-                status =
-                    eglChooseConfig(gfdata->egldisplay,
-                                    wdata->gles_attributes,
-                                    wdata->gles_configs,
-                                    SDL_VIDEO_GF_OPENGLES_CONFS, &configs);
-                if (status != EGL_TRUE) {
-                    SDL_SetError
-                        ("GF: Can't find closest configuration for OpenGL ES");
-                    return NULL;
-                }
-                if (configs != 0) {
-                    break;
-                }
-            }
-            if (configs != 0) {
-                break;
-            }
-        }
-
-        /* No available configs */
-        if (configs == 0) {
-            SDL_SetError("GF: Can't find any configuration for OpenGL ES");
-            return NULL;
-        }
-    }
-
-    /* Initialize config index */
-    wdata->gles_config = 0;
-
-    /* Now check each configuration to find out the best */
-    for (cit = 0; cit < configs; cit++) {
-        uint32_t stencil_found;
-        uint32_t depth_found;
-        EGLint   cur_depth;
-        EGLint   cur_stencil;
-
-        stencil_found = 0;
-        depth_found = 0;
-
-        if (_this->gl_config.stencil_size) {
-            status =
-                eglGetConfigAttrib(gfdata->egldisplay,
-                                   wdata->gles_configs[cit], EGL_STENCIL_SIZE,
-                                   &cur_stencil);
-            if (status == EGL_TRUE) {
-                if (attr_value != 0) {
-                    stencil_found = 1;
-                }
-            }
-        } else {
-            stencil_found = 1;
-        }
-
-        if (_this->gl_config.depth_size) {
-            status =
-                eglGetConfigAttrib(gfdata->egldisplay,
-                                   wdata->gles_configs[cit], EGL_DEPTH_SIZE,
-                                   &cur_depth);
-            if (status == EGL_TRUE) {
-                if (attr_value != 0) {
-                    depth_found = 1;
-                }
-            }
-        } else {
-            depth_found = 1;
-        }
-
-        /* Exit from loop if found appropriate configuration */
-        if ((depth_found != 0) && (stencil_found != 0)) {
-            /* Store last satisfied configuration id */
-            wdata->gles_config = cit;
-
-            if (cur_depth==_this->gl_config.depth_size)
-            {
-                /* Exact match on depth bits */
-                if (!_this->gl_config.stencil_size)
-                {
-                    /* Stencil is not required */
-                    break;
-                }
-                else
-                {
-                    if (cur_stencil==_this->gl_config.stencil_size)
-                    {
-                        /* Exact match on stencil bits */
-                        break;
-                    }
-                }
-            }
-        }
-    }
-
-    /* If best could not be found, use first or last satisfied */
-    if ((cit == configs) && (wdata->gles_config==0)) {
-        cit = 0;
-        wdata->gles_config = cit;
-    }
-
-    /* Create OpenGL ES context */
-    wdata->gles_context =
-        eglCreateContext(gfdata->egldisplay,
-                         wdata->gles_configs[wdata->gles_config],
-                         EGL_NO_CONTEXT, NULL);
-    if (wdata->gles_context == EGL_NO_CONTEXT) {
-        SDL_SetError("GF: OpenGL ES context creation has been failed");
-        return NULL;
-    }
-
-    /* Free any 3D target if it was created before */
-    if (wdata->target_created == SDL_TRUE) {
-        gf_3d_target_free(wdata->target);
-        wdata->target_created == SDL_FALSE;
-    }
-
-    /* Create surface(s) target for OpenGL ES */
-    gfstatus =
-        gf_3d_target_create(&wdata->target, didata->layer,
-                            &didata->surface[0], surfaces,
-                            didata->current_mode.w, didata->current_mode.h,
-                            qnxgf_sdl_to_gf_pixelformat(didata->current_mode.
-                                                        format));
-    if (gfstatus != GF_ERR_OK) {
-        /* Destroy just created context */
-        eglDestroyContext(gfdata->egldisplay, wdata->gles_context);
-        wdata->gles_context = EGL_NO_CONTEXT;
-
-        /* Mark 3D target as unallocated */
-        wdata->target_created = SDL_FALSE;
-        SDL_SetError("GF: OpenGL ES target could not be created");
-        return NULL;
-    } else {
-        wdata->target_created = SDL_TRUE;
-    }
-
-    /* Create target rendering surface on whole screen */
-    wdata->gles_surface =
-        eglCreateWindowSurface(gfdata->egldisplay,
-                               wdata->gles_configs[wdata->gles_config],
-                               wdata->target, NULL);
-    if (wdata->gles_surface == EGL_NO_SURFACE) {
-        /* Destroy 3d target */
-        gf_3d_target_free(wdata->target);
-        wdata->target_created = SDL_FALSE;
-
-        /* Destroy OpenGL ES context */
-        eglDestroyContext(gfdata->egldisplay, wdata->gles_context);
-        wdata->gles_context = EGL_NO_CONTEXT;
-
-        SDL_SetError("GF: OpenGL ES surface could not be created");
-        return NULL;
-    }
-
-    /* Make just created context current */
-    status =
-        eglMakeCurrent(gfdata->egldisplay, wdata->gles_surface,
-                       wdata->gles_surface, wdata->gles_context);
-    if (status != EGL_TRUE) {
-        /* Destroy OpenGL ES surface */
-        eglDestroySurface(gfdata->egldisplay, wdata->gles_surface);
-
-        /* Destroy 3d target */
-        gf_3d_target_free(wdata->target);
-        wdata->target_created = SDL_FALSE;
-
-        /* Destroy OpenGL ES context */
-        eglDestroyContext(gfdata->egldisplay, wdata->gles_context);
-        wdata->gles_context = EGL_NO_CONTEXT;
-
-        /* Failed to set current GL ES context */
-        SDL_SetError("GF: Can't set OpenGL ES context on creation");
-        return NULL;
-    }
-
-    /* Setup into SDL internals state of OpenGL ES:  */
-    /* it is accelerated or not                      */
-    if ((didata->caps & SDL_GF_ACCELERATED_3D) == SDL_GF_ACCELERATED_3D) {
-        _this->gl_config.accelerated = 1;
-    } else {
-        _this->gl_config.accelerated = 0;
-    }
-
-    /* Always clear stereo enable, since OpenGL ES do not supports stereo */
-    _this->gl_config.stereo = 0;
-
-    /* Get back samples and samplebuffers configurations. Rest framebuffer */
-    /* parameters could be obtained through the OpenGL ES API              */
-    status =
-        eglGetConfigAttrib(gfdata->egldisplay,
-                           wdata->gles_configs[wdata->gles_config],
-                           EGL_SAMPLES, &attr_value);
-    if (status == EGL_TRUE) {
-        _this->gl_config.multisamplesamples = attr_value;
-    }
-    status =
-        eglGetConfigAttrib(gfdata->egldisplay,
-                           wdata->gles_configs[wdata->gles_config],
-                           EGL_SAMPLE_BUFFERS, &attr_value);
-    if (status == EGL_TRUE) {
-        _this->gl_config.multisamplebuffers = attr_value;
-    }
-
-    /* Get back stencil and depth buffer sizes */
-    status =
-        eglGetConfigAttrib(gfdata->egldisplay,
-                           wdata->gles_configs[wdata->gles_config],
-                           EGL_DEPTH_SIZE, &attr_value);
-    if (status == EGL_TRUE) {
-        _this->gl_config.depth_size = attr_value;
-    }
-    status =
-        eglGetConfigAttrib(gfdata->egldisplay,
-                           wdata->gles_configs[wdata->gles_config],
-                           EGL_STENCIL_SIZE, &attr_value);
-    if (status == EGL_TRUE) {
-        _this->gl_config.stencil_size = attr_value;
-    }
-
-    /* Restore cursor if it was visible */
-    if (didata->cursor_visible == SDL_TRUE) {
-        gf_cursor_set(didata->display, 0, &didata->cursor);
-        gf_cursor_enable(didata->display, 0);
-    }
-
-    /* GL ES context was successfully created */
-    return wdata->gles_context;
-#else
-    SDL_SetError("GF: OpenGL ES support is not compiled in");
-    return NULL;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-int
-qnxgf_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
-    SDL_WindowData *wdata;
-    EGLBoolean status;
-
-    if ((window == NULL) && (context == NULL)) {
-        status =
-            eglMakeCurrent(gfdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
-                           EGL_NO_CONTEXT);
-        if (status != EGL_TRUE) {
-            /* Failed to set current GL ES context */
-            SDL_SetError("GF: Can't set OpenGL ES context");
-            return -1;
-        }
-    } else {
-        wdata = (SDL_WindowData *) window->driverdata;
-        status =
-            eglMakeCurrent(gfdata->egldisplay, wdata->gles_surface,
-                           wdata->gles_surface, wdata->gles_context);
-        if (status != EGL_TRUE) {
-            /* Failed to set current GL ES context */
-            SDL_SetError("GF: Can't set OpenGL ES context");
-            return -1;
-        }
-    }
-
-    return 0;
-#else
-    SDL_SetError("GF: OpenGL ES support is not compiled in");
-    return -1;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-int
-qnxgf_gl_setswapinterval(_THIS, int interval)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
-    EGLBoolean status;
-
-    /* Check if OpenGL ES connection has been initialized */
-    if (gfdata->egldisplay != EGL_NO_DISPLAY) {
-        /* Set swap OpenGL ES interval */
-        status = eglSwapInterval(gfdata->egldisplay, interval);
-        if (status == EGL_TRUE) {
-            /* Return success to upper level */
-            gfdata->swapinterval = interval;
-            return 0;
-        }
-    }
-
-    /* Failed to set swap interval */
-    SDL_SetError("GF: Cannot set swap interval");
-    return -1;
-#else
-    SDL_SetError("GF: OpenGL ES support is not compiled in");
-    return -1;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-int
-qnxgf_gl_getswapinterval(_THIS)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
-
-    /* Return default swap interval value */
-    return gfdata->swapinterval;
-#else
-    SDL_SetError("GF: OpenGL ES support is not compiled in");
-    return -1;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-void
-qnxgf_gl_swapwindow(_THIS, SDL_Window * window)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
-    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
-
-    /* Finish all drawings */
-    glFinish();
-
-    /* Swap buffers */
-    eglSwapBuffers(gfdata->egldisplay, wdata->gles_surface);
-#else
-    SDL_SetError("GF: OpenGL ES support is not compiled in");
-    return;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-void
-qnxgf_gl_deletecontext(_THIS, SDL_GLContext context)
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-    SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
-    EGLBoolean status;
-
-    /* Check if OpenGL ES connection has been initialized */
-    if (gfdata->egldisplay != EGL_NO_DISPLAY) {
-        if (context != EGL_NO_CONTEXT) {
-            status = eglDestroyContext(gfdata->egldisplay, context);
-            if (status != EGL_TRUE) {
-                /* Error during OpenGL ES context destroying */
-                SDL_SetError("GF: OpenGL ES context destroy error");
-                return;
-            }
-        }
-    }
-
-    return;
-#else
-    SDL_SetError("GF: OpenGL ES support is not compiled in");
-    return;
-#endif /* SDL_VIDEO_OPENGL_ES */
-}
-
-/*****************************************************************************/
-/* SDL Event handling function                                               */
-/*****************************************************************************/
-void
-qnxgf_pumpevents(_THIS)
-{
-}
-
-/*****************************************************************************/
-/* SDL screen saver related functions                                        */
-/*****************************************************************************/
-void
-qnxgf_suspendscreensaver(_THIS)
-{
-    /* There is no screensaver in pure console, it may exist when running */
-    /* GF under Photon, but I do not know, how to disable screensaver     */
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/qnxgf/SDL_qnxgf.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-
-    QNX Graphics Framework SDL driver
-    Copyright (C) 2009 Mike Gorchak
-    (mike@malva.ua, lestat@i.com.ua)
-*/
-
-#ifndef __SDL_QNXGF_H__
-#define __SDL_QNXGF_H__
-
-#include "../SDL_sysvideo.h"
-
-#include <gf/gf.h>
-#include <gf/gf3d.h>
-
-#if defined(SDL_VIDEO_OPENGL_ES)
-#include <GLES/egl.h>
-#endif /* SDL_VIDEO_OPENGL_ES */
-
-typedef struct SDL_VideoData
-{
-    gf_dev_t gfdev;             /* GF device handle                     */
-    gf_dev_info_t gfdev_info;   /* GF device information                */
-    SDL_bool gfinitialized;     /* GF device initialization status      */
-#if defined(SDL_VIDEO_OPENGL_ES)
-    EGLDisplay egldisplay;      /* OpenGL ES display connection         */
-    uint32_t egl_refcount;      /* OpenGL ES reference count            */
-    uint32_t swapinterval;      /* OpenGL ES default swap interval      */
-#endif                          /* SDL_VIDEO_OPENGL_ES */
-} SDL_VideoData;
-
-#define SDL_VIDEO_GF_DEVICENAME_MAX  257
-#define SDL_VIDEO_GF_MAX_CURSOR_SIZE 128
-
-typedef struct SDL_DisplayData
-{
-    gf_display_info_t display_info;     /* GF display information             */
-    gf_display_t display;       /* GF display handle                  */
-    uint32_t custom_refresh;    /* Custom refresh rate for all modes  */
-    SDL_DisplayMode current_mode;       /* Current video mode                 */
-    uint8_t description[SDL_VIDEO_GF_DEVICENAME_MAX];
-    /* Device description                 */
-    uint32_t caps;              /* Device capabilities                */
-    SDL_bool layer_attached;    /* Layer attach status                */
-    gf_layer_t layer;           /* Graphics layer to which attached   */
-    gf_surface_t surface[3];    /* Visible surface on the display     */
-    SDL_bool cursor_visible;    /* SDL_TRUE if cursor visible         */
-    gf_cursor_t cursor;         /* Cursor shape which was set last    */
-} SDL_DisplayData;
-
-/* Maximum amount of OpenGL ES framebuffer configurations */
-#define SDL_VIDEO_GF_OPENGLES_CONFS 32
-
-typedef struct SDL_WindowData
-{
-    SDL_bool uses_gles;         /* true if window support OpenGL ES   */
-#if defined(SDL_VIDEO_OPENGL_ES)
-    gf_3d_target_t target;      /* OpenGL ES window target            */
-    SDL_bool target_created;    /* GF 3D target is created if true    */
-    EGLConfig gles_configs[SDL_VIDEO_GF_OPENGLES_CONFS];
-    /* OpenGL ES framebuffer confs        */
-    EGLint gles_config;         /* Config index in the array of cfgs  */
-    EGLContext gles_context;    /* OpenGL ES context                  */
-    EGLint gles_attributes[256];        /* OpenGL ES attributes for context   */
-    EGLSurface gles_surface;    /* OpenGL ES target rendering surface */
-#endif                          /* SDL_VIDEO_OPENGL_ES */
-} SDL_WindowData;
-
-typedef struct SDL_GLDriverData
-{
-#if defined(SDL_VIDEO_OPENGL_ES)
-#endif                          /* SDL_VIDEO_OPENGL_ES */
-} SDL_GLDriverData;
-
-/****************************************************************************/
-/* Low level GF graphics driver capabilities                                */
-/****************************************************************************/
-typedef struct GF_DeviceCaps
-{
-    uint8_t *name;
-    uint32_t caps;
-} GF_DeviceCaps;
-
-#define SDL_GF_UNACCELERATED         0x00000000 /* driver is unaccelerated  */
-#define SDL_GF_ACCELERATED           0x00000001 /* driver is accelerated    */
-#define SDL_GF_NOLOWRESOLUTION       0x00000000 /* no modes below 640x480   */
-#define SDL_GF_LOWRESOLUTION         0x00000002 /* support modes <640x480   */
-#define SDL_GF_UNACCELERATED_3D      0x00000000 /* software OpenGL ES       */
-#define SDL_GF_ACCELERATED_3D        0x00000004 /* hardware acc. OpenGL ES  */
-#define SDL_GF_NOVIDEOMEMORY         0x00000000 /* no video memory alloc.   */
-#define SDL_GF_VIDEOMEMORY           0x00000008 /* has video memory alloc.  */
-
-/****************************************************************************/
-/* SDL_VideoDevice functions declaration                                    */
-/****************************************************************************/
-
-/* Display and window functions */
-int qnxgf_videoinit(_THIS);
-void qnxgf_videoquit(_THIS);
-void qnxgf_getdisplaymodes(_THIS);
-int qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode);
-int qnxgf_setdisplaypalette(_THIS, SDL_Palette * palette);
-int qnxgf_getdisplaypalette(_THIS, SDL_Palette * palette);
-int qnxgf_setdisplaygammaramp(_THIS, Uint16 * ramp);
-int qnxgf_getdisplaygammaramp(_THIS, Uint16 * ramp);
-int qnxgf_createwindow(_THIS, SDL_Window * window);
-int qnxgf_createwindowfrom(_THIS, SDL_Window * window, const void *data);
-void qnxgf_setwindowtitle(_THIS, SDL_Window * window);
-void qnxgf_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon);
-void qnxgf_setwindowposition(_THIS, SDL_Window * window);
-void qnxgf_setwindowsize(_THIS, SDL_Window * window);
-void qnxgf_showwindow(_THIS, SDL_Window * window);
-void qnxgf_hidewindow(_THIS, SDL_Window * window);
-void qnxgf_raisewindow(_THIS, SDL_Window * window);
-void qnxgf_maximizewindow(_THIS, SDL_Window * window);
-void qnxgf_minimizewindow(_THIS, SDL_Window * window);
-void qnxgf_restorewindow(_THIS, SDL_Window * window);
-void qnxgf_setwindowgrab(_THIS, SDL_Window * window);
-void qnxgf_destroywindow(_THIS, SDL_Window * window);
-
-/* Window manager function */
-SDL_bool qnxgf_getwindowwminfo(_THIS, SDL_Window * window,
-                               struct SDL_SysWMinfo *info);
-
-/* OpenGL/OpenGL ES functions */
-int qnxgf_gl_loadlibrary(_THIS, const char *path);
-void *qnxgf_gl_getprocaddres(_THIS, const char *proc);
-void qnxgf_gl_unloadlibrary(_THIS);
-SDL_GLContext qnxgf_gl_createcontext(_THIS, SDL_Window * window);
-int qnxgf_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context);
-int qnxgf_gl_setswapinterval(_THIS, int interval);
-int qnxgf_gl_getswapinterval(_THIS);
-void qnxgf_gl_swapwindow(_THIS, SDL_Window * window);
-void qnxgf_gl_deletecontext(_THIS, SDL_GLContext context);
-
-/* Event handling function */
-void qnxgf_pumpevents(_THIS);
-
-/* Screen saver related function */
-void qnxgf_suspendscreensaver(_THIS);
-
-#endif /* __SDL_QNXGF_H__ */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/sdlgenblit.pl	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/sdlgenblit.pl	Sun Feb 06 21:23:32 2011 -0800
@@ -9,7 +9,6 @@
 my %file;
 
 # The formats potentially supported by this script:
-# SDL_PIXELFORMAT_INDEX8
 # SDL_PIXELFORMAT_RGB332
 # SDL_PIXELFORMAT_RGB444
 # SDL_PIXELFORMAT_RGB555
@@ -83,7 +82,7 @@
 /* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
 /*
     SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2009 Sam Lantinga
+    Copyright (C) 1997-2011 Sam Lantinga
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public
@@ -238,14 +237,7 @@
                     ${s}B = (${s}B * ${s}A) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
-            case SDL_COPY_MASK:
-                if (${s}A) {
-                    ${d}R = ${s}R;
-                    ${d}G = ${s}G;
-                    ${d}B = ${s}B;
-                }
-                break;
+            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
             case SDL_COPY_BLEND:
                 ${d}R = ${s}R + ((255 - ${s}A) * ${d}R) / 255;
                 ${d}G = ${s}G + ((255 - ${s}A) * ${d}G) / 255;
@@ -410,7 +402,7 @@
                                 }
                             }
                             if ( $blend ) {
-                                $flag = "SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD";
+                                $flag = "SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD";
                                 if ( $flags eq "" ) {
                                     $flags = $flag;
                                 } else {
--- a/src/video/uikit/SDL_uikitappdelegate.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitappdelegate.h	Sun Feb 06 21:23:32 2011 -0800
@@ -31,3 +31,5 @@
 
 @end
 /* *INDENT-ON* */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitappdelegate.m	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitappdelegate.m	Sun Feb 06 21:23:32 2011 -0800
@@ -37,69 +37,68 @@
 
 int main(int argc, char **argv) {
 
-	int i;
-	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-	
-	/* store arguments */
-	forward_argc = argc;
-	forward_argv = (char **)malloc((argc+1) * sizeof(char *));
-	for (i=0; i<argc; i++) {
-		forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char));
-		strcpy(forward_argv[i], argv[i]);
-	}
-	forward_argv[i] = NULL;
+    int i;
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    
+    /* store arguments */
+    forward_argc = argc;
+    forward_argv = (char **)malloc((argc+1) * sizeof(char *));
+    for (i=0; i<argc; i++) {
+        forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char));
+        strcpy(forward_argv[i], argv[i]);
+    }
+    forward_argv[i] = NULL;
 
-	/* Give over control to run loop, SDLUIKitDelegate will handle most things from here */
-	UIApplicationMain(argc, argv, NULL, @"SDLUIKitDelegate");
-	
-	[pool release];
-	
+    /* Give over control to run loop, SDLUIKitDelegate will handle most things from here */
+    UIApplicationMain(argc, argv, NULL, @"SDLUIKitDelegate");
+    
+    [pool release];
+    
 }
 
 @implementation SDLUIKitDelegate
 
 /* convenience method */
 +(SDLUIKitDelegate *)sharedAppDelegate {
-	/* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */
-	return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
+    /* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */
+    return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
 }
 
 - (id)init {
-	self = [super init];
-	return self;
+    self = [super init];
+    return self;
 }
 
 - (void)postFinishLaunch {
 
-	/* run the user's application, passing argc and argv */
-	int exit_status = SDL_main(forward_argc, forward_argv);
-	
-	/* free the memory we used to hold copies of argc and argv */
-	int i;
-	for (i=0; i<forward_argc; i++) {
-		free(forward_argv[i]);
-	}
-	free(forward_argv);	
-		
-	/* exit, passing the return status from the user's application */
-	exit(exit_status);
+    /* run the user's application, passing argc and argv */
+    int exit_status = SDL_main(forward_argc, forward_argv);
+    
+    /* free the memory we used to hold copies of argc and argv */
+    int i;
+    for (i=0; i<forward_argc; i++) {
+        free(forward_argv[i]);
+    }
+    free(forward_argv);    
+        
+    /* exit, passing the return status from the user's application */
+    exit(exit_status);
 }
 
 - (void)applicationDidFinishLaunching:(UIApplication *)application {
-			
-	/* Set working directory to resource path */
-	[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
-	
-	[self performSelector:@selector(postFinishLaunch) withObject:nil
+            
+    /* Set working directory to resource path */
+    [[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
+    
+    [self performSelector:@selector(postFinishLaunch) withObject:nil
 afterDelay:0.0];
 }
 
 - (void)applicationWillTerminate:(UIApplication *)application {
-	
-	SDL_SendQuit();
-	 /* hack to prevent automatic termination.  See SDL_uikitevents.m for details */
-	longjmp(*(jump_env()), 1);
-	
+    
+    SDL_SendQuit();
+     /* hack to prevent automatic termination.  See SDL_uikitevents.m for details */
+    longjmp(*(jump_env()), 1);
 }
 
 - (void) applicationWillResignActive:(UIApplication*)application
@@ -143,3 +142,5 @@
 }
 
 @end
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitevents.m	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitevents.m	Sun Feb 06 21:23:32 2011 -0800
@@ -32,25 +32,24 @@
 void
 UIKit_PumpEvents(_THIS)
 {
-	/* 
-		When the user presses the 'home' button on the iPod
-		the application exits -- immediatly.
-	 
-		Unlike in Mac OS X, it appears there is no way to cancel the termination.
-	 
-		This doesn't give the SDL user's application time to respond to an SDL_Quit event.
-		So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelegate),
-		when the delegate receives the ApplicationWillTerminate message, we execute
-		a longjmp statement to get back here, preventing an immediate exit.
-	 */	
-	if (setjmp(*jump_env()) == 0) {
-		/* if we're setting the jump, rather than jumping back */
-		SInt32 result;
-		do {
-			result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE);
-		} while(result == kCFRunLoopRunHandledSource);
-	}
-
+    /* 
+        When the user presses the 'home' button on the iPod
+        the application exits -- immediatly.
+     
+        Unlike in Mac OS X, it appears there is no way to cancel the termination.
+     
+        This doesn't give the SDL user's application time to respond to an SDL_Quit event.
+        So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelegate),
+        when the delegate receives the ApplicationWillTerminate message, we execute
+        a longjmp statement to get back here, preventing an immediate exit.
+     */    
+    if (setjmp(*jump_env()) == 0) {
+        /* if we're setting the jump, rather than jumping back */
+        SInt32 result;
+        do {
+            result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE);
+        } while(result == kCFRunLoopRunHandledSource);
+    }
 }
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitkeyboard.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitkeyboard.h	Sun Feb 06 21:23:32 2011 -0800
@@ -29,3 +29,5 @@
 extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardToggle(SDL_Window * window);
 
 #endif
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitopengles.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitopengles.h	Sun Feb 06 21:23:32 2011 -0800
@@ -36,3 +36,5 @@
 extern int UIKit_GL_LoadLibrary(_THIS, const char *path);
 
 #endif
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitopengles.m	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitopengles.m	Sun Feb 06 21:23:32 2011 -0800
@@ -35,42 +35,42 @@
 
 void *
 UIKit_GL_GetProcAddress(_THIS, const char *proc)
-{	
-	/* Look through all SO's for the proc symbol.  Here's why:
-	   -Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator.
-	   -We don't know that the path won't change in the future.
-	*/
+{    
+    /* Look through all SO's for the proc symbol.  Here's why:
+       -Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator.
+       -We don't know that the path won't change in the future.
+    */
     return SDL_LoadFunction(RTLD_DEFAULT, proc);
 }
 
 /*
-	note that SDL_GL_Delete context makes it current without passing the window
+    note that SDL_GL_Delete context makes it current without passing the window
 */
 int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
 {
-	
-	if (context) {
-		SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
-		[data->view setCurrentContext];
-	}
-	else {
-		[EAGLContext setCurrentContext: nil];
-	}
-		
+    
+    if (context) {
+        SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
+        [data->view setCurrentContext];
+    }
+    else {
+        [EAGLContext setCurrentContext: nil];
+    }
+        
     return 0;
 }
 
 int
 UIKit_GL_LoadLibrary(_THIS, const char *path)
 {
-	/* 
-		shouldn't be passing a path into this function 
-		why?  Because we've already loaded the library
-		and because the SDK forbids loading an external SO
-	*/
+    /* 
+        shouldn't be passing a path into this function 
+        why?  Because we've already loaded the library
+        and because the SDK forbids loading an external SO
+    */
     if (path != NULL) {
-		SDL_SetError("iPhone GL Load Library just here for compatibility");
-		return -1;
+        SDL_SetError("iPhone GL Load Library just here for compatibility");
+        return -1;
     }
     return 0;
 }
@@ -84,65 +84,64 @@
     SDL_UIKit_UpdateBatteryMonitoring();
     #endif
 
-	SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
-	
-	if (nil == data->view) {
-		return;
-	}
-	[data->view swapBuffers];
-	/* since now we've got something to draw
-	   make the window visible */
-	[data->uiwindow makeKeyAndVisible];
+    SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
+    
+    if (nil == data->view) {
+        return;
+    }
+    [data->view swapBuffers];
+    /* since now we've got something to draw
+       make the window visible */
+    [data->uiwindow makeKeyAndVisible];
 
-	/* we need to let the event cycle run, or the OS won't update the OpenGL view! */
-	SDL_PumpEvents();
-	
+    /* we need to let the event cycle run, or the OS won't update the OpenGL view! */
+    SDL_PumpEvents();
+    
 }
 
 SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
 {
-	SDL_uikitopenglview *view;
-	SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+    SDL_uikitopenglview *view;
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     UIScreen *uiscreen = (UIScreen *) window->display->driverdata;
-	UIWindow *uiwindow = data->uiwindow;
+    UIWindow *uiwindow = data->uiwindow;
 
     /* construct our view, passing in SDL's OpenGL configuration data */
     view = [[SDL_uikitopenglview alloc] initWithFrame: [uiwindow bounds] \
-									retainBacking: _this->gl_config.retained_backing \
-									rBits: _this->gl_config.red_size \
-									gBits: _this->gl_config.green_size \
-									bBits: _this->gl_config.blue_size \
-									aBits: _this->gl_config.alpha_size \
-									depthBits: _this->gl_config.depth_size];
-	
-	data->view = view;
-	
-	/* add the view to our window */
-	[uiwindow addSubview: view ];
-	
-	/* Don't worry, the window retained the view */
-	[view release];
-	
-	if ( UIKit_GL_MakeCurrent(_this, window, view) < 0 ) {
+                                    retainBacking: _this->gl_config.retained_backing \
+                                    rBits: _this->gl_config.red_size \
+                                    gBits: _this->gl_config.green_size \
+                                    bBits: _this->gl_config.blue_size \
+                                    aBits: _this->gl_config.alpha_size \
+                                    depthBits: _this->gl_config.depth_size \
+                                    majorVersion: _this->gl_config.major_version];
+    
+    data->view = view;
+    
+    /* add the view to our window */
+    [uiwindow addSubview: view ];
+    
+    /* Don't worry, the window retained the view */
+    [view release];
+    
+    if ( UIKit_GL_MakeCurrent(_this, window, view) < 0 ) {
         UIKit_GL_DeleteContext(_this, view);
         return NULL;
     }
 
-	/* Make this window the current mouse focus for touch input */
-	SDL_SetMouseFocus(window);
-	SDL_SetKeyboardFocus(window);
+    /* Make this window the current mouse focus for touch input */
+    SDL_SetMouseFocus(window);
+    SDL_SetKeyboardFocus(window);
 
-	return view;
+    return view;
 }
 
 void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
 {
-	/* the delegate has retained the view, this will release him */
-	SDL_uikitopenglview *view = (SDL_uikitopenglview *)context;
-	/* this will also delete it */
-	[view removeFromSuperview];
-	
-	return;
+    /* the delegate has retained the view, this will release him */
+    SDL_uikitopenglview *view = (SDL_uikitopenglview *)context;
+    /* this will also delete it */
+    [view removeFromSuperview];
 }
 
-
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitopenglview.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitopenglview.h	Sun Feb 06 21:23:32 2011 -0800
@@ -26,26 +26,26 @@
 #import <OpenGLES/ES1/glext.h>
 #import "SDL_uikitview.h"
 /*
-	This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
-	The view content is basically an EAGL surface you render your OpenGL scene into.
-	Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
+    This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
+    The view content is basically an EAGL surface you render your OpenGL scene into.
+    Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
  */
 /* *INDENT-OFF* */
 @interface SDL_uikitopenglview : SDL_uikitview {
-	
+    
 @private
-	/* The pixel dimensions of the backbuffer */
-	GLint backingWidth;
-	GLint backingHeight;
-	
-	EAGLContext *context;
-	
-	/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
-	GLuint viewRenderbuffer, viewFramebuffer;
-	
-	/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
-	GLuint depthRenderbuffer;
-	
+    /* The pixel dimensions of the backbuffer */
+    GLint backingWidth;
+    GLint backingHeight;
+    
+    EAGLContext *context;
+    
+    /* OpenGL names for the renderbuffer and framebuffers used to render to this view */
+    GLuint viewRenderbuffer, viewFramebuffer;
+    
+    /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
+    GLuint depthRenderbuffer;
+    
 }
 
 @property (nonatomic, retain, readonly) EAGLContext *context;
@@ -54,12 +54,15 @@
 - (void)setCurrentContext;
 
 - (id)initWithFrame:(CGRect)frame
-	retainBacking:(BOOL)retained \
-	rBits:(int)rBits \
-	gBits:(int)gBits \
-	bBits:(int)bBits \
-	aBits:(int)aBits \
-	depthBits:(int)depthBits;
+    retainBacking:(BOOL)retained \
+    rBits:(int)rBits \
+    gBits:(int)gBits \
+    bBits:(int)bBits \
+    aBits:(int)aBits \
+    depthBits:(int)depthBits \
+    majorVersion:(int)majorVersion;
 
 @end
 /* *INDENT-ON* */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitopenglview.m	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitopenglview.m	Sun Feb 06 21:23:32 2011 -0800
@@ -37,128 +37,134 @@
 @synthesize context;
 
 + (Class)layerClass {
-	return [CAEAGLLayer class];
+    return [CAEAGLLayer class];
 }
 
 - (id)initWithFrame:(CGRect)frame \
-	  retainBacking:(BOOL)retained \
-	  rBits:(int)rBits \
-	  gBits:(int)gBits \
-	  bBits:(int)bBits \
-	  aBits:(int)aBits \
-	  depthBits:(int)depthBits \
+      retainBacking:(BOOL)retained \
+      rBits:(int)rBits \
+      gBits:(int)gBits \
+      bBits:(int)bBits \
+      aBits:(int)aBits \
+      depthBits:(int)depthBits \
+      majorVersion:(int)majorVersion \
 {
-	
-	NSString *colorFormat=nil;
-	GLuint depthBufferFormat;
-	BOOL useDepthBuffer;
-	
-	if (rBits == 8 && gBits == 8 && bBits == 8) {
-		/* if user specifically requests rbg888 or some color format higher than 16bpp */
-		colorFormat = kEAGLColorFormatRGBA8;
-	}
-	else {
-		/* default case (faster) */
-		colorFormat = kEAGLColorFormatRGB565;
-	}
-	
-	if (depthBits == 24) {
-		useDepthBuffer = YES;
-		depthBufferFormat = GL_DEPTH_COMPONENT24_OES;
-	}
-	else if (depthBits == 0) {
-		useDepthBuffer = NO;
-	}
-	else {
-		/* default case when depth buffer is not disabled */
-		/* 
-		   strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone.
-		   perhaps that's the only depth format iPhone actually supports
-		*/
-		useDepthBuffer = YES;
-		depthBufferFormat = GL_DEPTH_COMPONENT16_OES;
-	}
-	
-	if ((self = [super initWithFrame:frame])) {
-		// Get the layer
-		CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
-		
-		eaglLayer.opaque = YES;
-		eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
-										[NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil];
-		
-		context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
-		
-		if (!context || ![EAGLContext setCurrentContext:context]) {
-			[self release];
-			return nil;
-		}
-		
-		/* create the buffers */
-		glGenFramebuffersOES(1, &viewFramebuffer);
-		glGenRenderbuffersOES(1, &viewRenderbuffer);
-		
-		glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
-		glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
-		[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
-		glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
-		
-		glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
-		glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
-		
-		if (useDepthBuffer) {
-			glGenRenderbuffersOES(1, &depthRenderbuffer);
-			glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
-			glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight);
-			glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
-		}
-			
-		if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
-			return NO;
-		}
-		/* end create buffers */
-	}
-	return self;
+    NSString *colorFormat=nil;
+    GLuint depthBufferFormat;
+    BOOL useDepthBuffer;
+    
+    if (rBits == 8 && gBits == 8 && bBits == 8) {
+        /* if user specifically requests rbg888 or some color format higher than 16bpp */
+        colorFormat = kEAGLColorFormatRGBA8;
+    }
+    else {
+        /* default case (faster) */
+        colorFormat = kEAGLColorFormatRGB565;
+    }
+    
+    if (depthBits == 24) {
+        useDepthBuffer = YES;
+        depthBufferFormat = GL_DEPTH_COMPONENT24_OES;
+    }
+    else if (depthBits == 0) {
+        useDepthBuffer = NO;
+    }
+    else {
+        /* default case when depth buffer is not disabled */
+        /* 
+           strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone.
+           perhaps that's the only depth format iPhone actually supports
+        */
+        useDepthBuffer = YES;
+        depthBufferFormat = GL_DEPTH_COMPONENT16_OES;
+    }
+    
+    if ((self = [super initWithFrame:frame])) {
+        // Get the layer
+        CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
+        
+        eaglLayer.opaque = YES;
+        eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
+                                        [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil];
+        
+        if (majorVersion > 1) {
+            context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2];
+        } else {
+            context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
+        }
+        if (!context || ![EAGLContext setCurrentContext:context]) {
+            [self release];
+            return nil;
+        }
+        
+        /* create the buffers */
+        glGenFramebuffersOES(1, &viewFramebuffer);
+        glGenRenderbuffersOES(1, &viewRenderbuffer);
+        
+        glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
+        glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
+        [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
+        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
+        
+        glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
+        glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
+        
+        if (useDepthBuffer) {
+            glGenRenderbuffersOES(1, &depthRenderbuffer);
+            glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
+            glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight);
+            glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
+        }
+            
+        if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
+            return NO;
+        }
+        /* end create buffers */
+
+        /* Use the main screen scale (for retina display support) */
+        if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
+            self.contentScaleFactor = [UIScreen mainScreen].scale;
+    }
+    return self;
 }
 
 - (void)setCurrentContext {
-	[EAGLContext setCurrentContext:context];
+    [EAGLContext setCurrentContext:context];
 }
 
 
 - (void)swapBuffers {
-	glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
-	[context presentRenderbuffer:GL_RENDERBUFFER_OES];
+    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
+    [context presentRenderbuffer:GL_RENDERBUFFER_OES];
 }
 
 
 - (void)layoutSubviews {
-	[EAGLContext setCurrentContext:context];
+    [EAGLContext setCurrentContext:context];
 }
 
 - (void)destroyFramebuffer {
-	
-	glDeleteFramebuffersOES(1, &viewFramebuffer);
-	viewFramebuffer = 0;
-	glDeleteRenderbuffersOES(1, &viewRenderbuffer);
-	viewRenderbuffer = 0;
-	
-	if (depthRenderbuffer) {
-		glDeleteRenderbuffersOES(1, &depthRenderbuffer);
-		depthRenderbuffer = 0;
-	}
+    glDeleteFramebuffersOES(1, &viewFramebuffer);
+    viewFramebuffer = 0;
+    glDeleteRenderbuffersOES(1, &viewRenderbuffer);
+    viewRenderbuffer = 0;
+    
+    if (depthRenderbuffer) {
+        glDeleteRenderbuffersOES(1, &depthRenderbuffer);
+        depthRenderbuffer = 0;
+    }
 }
 
 
 - (void)dealloc {
-		
-	[self destroyFramebuffer];
-	if ([EAGLContext currentContext] == context) {
-		[EAGLContext setCurrentContext:nil];
-	}
-	[context release];	
-	[super dealloc];
-	
+    [self destroyFramebuffer];
+    if ([EAGLContext currentContext] == context) {
+        [EAGLContext setCurrentContext:nil];
+    }
+    [context release];    
+    [super dealloc];
 }
 
 @end
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitvideo.m	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitvideo.m	Sun Feb 06 21:23:32 2011 -0800
@@ -35,9 +35,6 @@
 #include "SDL_uikitwindow.h"
 #include "SDL_uikitopengles.h"
 
-#include "SDL_renderer_sw.h"
-#include "SDL_renderer_gles.h"
-
 #include "SDL_assert.h"
 
 #define UIKITVID_DRIVER_NAME "uikit"
@@ -56,7 +53,7 @@
 static int
 UIKit_Available(void)
 {
-	return (1);
+    return (1);
 }
 
 static void UIKit_DeleteDevice(SDL_VideoDevice * device)
@@ -85,22 +82,22 @@
     device->GetDisplayModes = UIKit_GetDisplayModes;
     device->SetDisplayMode = UIKit_SetDisplayMode;
     device->PumpEvents = UIKit_PumpEvents;
-	device->CreateWindow = UIKit_CreateWindow;
-	device->DestroyWindow = UIKit_DestroyWindow;
+    device->CreateWindow = UIKit_CreateWindow;
+    device->DestroyWindow = UIKit_DestroyWindow;
     device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
-	
-	
-	/* OpenGL (ES) functions */
-	device->GL_MakeCurrent		= UIKit_GL_MakeCurrent;
-	device->GL_SwapWindow		= UIKit_GL_SwapWindow;
-	device->GL_CreateContext	= UIKit_GL_CreateContext;
-	device->GL_DeleteContext    = UIKit_GL_DeleteContext;
-	device->GL_GetProcAddress   = UIKit_GL_GetProcAddress;
-	device->GL_LoadLibrary	    = UIKit_GL_LoadLibrary;
-	device->free = UIKit_DeleteDevice;
+    
+    
+    /* OpenGL (ES) functions */
+    device->GL_MakeCurrent        = UIKit_GL_MakeCurrent;
+    device->GL_SwapWindow        = UIKit_GL_SwapWindow;
+    device->GL_CreateContext    = UIKit_GL_CreateContext;
+    device->GL_DeleteContext    = UIKit_GL_DeleteContext;
+    device->GL_GetProcAddress   = UIKit_GL_GetProcAddress;
+    device->GL_LoadLibrary        = UIKit_GL_LoadLibrary;
+    device->free = UIKit_DeleteDevice;
 
-	device->gl_config.accelerated = 1;
-	
+    device->gl_config.accelerated = 1;
+
     return device;
 }
 
--- a/src/video/uikit/SDL_uikitview.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitview.h	Sun Feb 06 21:23:32 2011 -0800
@@ -38,17 +38,17 @@
 #endif
 
 #ifdef FIXED_MULTITOUCH
-	long touchId;
+    long touchId;
 #ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
-	UITouch *finger[MAX_SIMULTANEOUS_TOUCHES];
+    UITouch *finger[MAX_SIMULTANEOUS_TOUCHES];
 #endif
 #endif
 
 #if SDL_IPHONE_KEYBOARD
-	UITextField *textField;
-	BOOL keyboardVisible;
-#endif	
-	
+    UITextField *textField;
+    BOOL keyboardVisible;
+#endif    
+    
 }
 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
@@ -63,3 +63,5 @@
 
 @end
 /* *INDENT-ON* */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitview.m	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitview.m	Sun Feb 06 21:23:32 2011 -0800
@@ -35,271 +35,272 @@
 @implementation SDL_uikitview
 
 - (void)dealloc {
-	[super dealloc];
+    [super dealloc];
 }
 
 - (id)initWithFrame:(CGRect)frame {
 
-	self = [super initWithFrame: frame];
-	
+    self = [super initWithFrame: frame];
+    
 #if SDL_IPHONE_KEYBOARD
-	[self initializeKeyboard];
-#endif	
+    [self initializeKeyboard];
+#endif    
 
 #ifdef FIXED_MULTITOUCH
-	SDL_Touch touch;
-	touch.id = 0; //TODO: Should be -1?
+    SDL_Touch touch;
+    touch.id = 0; //TODO: Should be -1?
 
-	//touch.driverdata = SDL_malloc(sizeof(EventTouchData));
-	//EventTouchData* data = (EventTouchData*)(touch.driverdata);
-	
-	touch.x_min = 0;
-	touch.x_max = frame.size.width;
-	touch.native_xres = touch.x_max - touch.x_min;
-	touch.y_min = 0;
-	touch.y_max = frame.size.height;
-	touch.native_yres = touch.y_max - touch.y_min;
-	touch.pressure_min = 0;
-	touch.pressure_max = 1;
-	touch.native_pressureres = touch.pressure_max - touch.pressure_min;
+    //touch.driverdata = SDL_malloc(sizeof(EventTouchData));
+    //EventTouchData* data = (EventTouchData*)(touch.driverdata);
+    
+    touch.x_min = 0;
+    touch.x_max = frame.size.width;
+    touch.native_xres = touch.x_max - touch.x_min;
+    touch.y_min = 0;
+    touch.y_max = frame.size.height;
+    touch.native_yres = touch.y_max - touch.y_min;
+    touch.pressure_min = 0;
+    touch.pressure_max = 1;
+    touch.native_pressureres = touch.pressure_max - touch.pressure_min;
 
 
-	touchId = SDL_AddTouch(&touch, "IPHONE SCREEN");
+    touchId = SDL_AddTouch(&touch, "IPHONE SCREEN");
 #endif
 
-	return self;
+    return self;
 
 }
 
 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
 
-	NSEnumerator *enumerator = [touches objectEnumerator];
-	UITouch *touch = (UITouch*)[enumerator nextObject];
-	
-	//NSLog("Click");
-	
-	if (touch) {
-		CGPoint locationInView = [touch locationInView: self];
-			
-		/* send moved event */
-		SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
+    NSEnumerator *enumerator = [touches objectEnumerator];
+    UITouch *touch = (UITouch*)[enumerator nextObject];
+    
+    //NSLog("Click");
+    
+    if (touch) {
+        CGPoint locationInView = [touch locationInView: self];
+            
+        /* send moved event */
+        SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
 
-		/* send mouse down event */
-		SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
-	}
+        /* send mouse down event */
+        SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
+    }
 
 #ifdef FIXED_MULTITOUCH
-	while(touch) {
-	  CGPoint locationInView = [touch locationInView: self];
+    while(touch) {
+      CGPoint locationInView = [touch locationInView: self];
 
 
 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
-	  //FIXME: TODO: Using touch as the fingerId is potentially dangerous
-	  //It is also much more efficient than storing the UITouch pointer
-	  //and comparing it to the incoming event.
-	  SDL_SendFingerDown(touchId,(long)touch,
-			     SDL_TRUE,locationInView.x,locationInView.y,
-			     1);
+      //FIXME: TODO: Using touch as the fingerId is potentially dangerous
+      //It is also much more efficient than storing the UITouch pointer
+      //and comparing it to the incoming event.
+      SDL_SendFingerDown(touchId,(long)touch,
+                 SDL_TRUE,locationInView.x,locationInView.y,
+                 1);
 #else
-	  int i;
-	  for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
-	    if(finger[i] == NULL) {
-	      finger[i] = touch;
-	      SDL_SendFingerDown(touchId,i,
-				 SDL_TRUE,locationInView.x,locationInView.y,
-				 1);
-	      break;
-	    }
-	  }
+      int i;
+      for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
+        if(finger[i] == NULL) {
+          finger[i] = touch;
+          SDL_SendFingerDown(touchId,i,
+                 SDL_TRUE,locationInView.x,locationInView.y,
+                 1);
+          break;
+        }
+      }
 #endif
-	  
+      
 
-	  
+      
 
-	  touch = (UITouch*)[enumerator nextObject]; 
-	}
+      touch = (UITouch*)[enumerator nextObject]; 
+    }
 #endif
 }
 
 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
-	
-	NSEnumerator *enumerator = [touches objectEnumerator];
-	UITouch *touch = (UITouch*)[enumerator nextObject];
-	
-	if (touch) {
-		/* send mouse up */
-		SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
-	}
+    
+    NSEnumerator *enumerator = [touches objectEnumerator];
+    UITouch *touch = (UITouch*)[enumerator nextObject];
+    
+    if (touch) {
+        /* send mouse up */
+        SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
+    }
 
 #ifdef FIXED_MULTITOUCH
-	while(touch) {
-	  CGPoint locationInView = [touch locationInView: self];
-	  
+    while(touch) {
+      CGPoint locationInView = [touch locationInView: self];
+      
 
 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
-	  SDL_SendFingerDown(touchId,(long)touch,
-			     SDL_FALSE,locationInView.x,locationInView.y,
-			     1);
+      SDL_SendFingerDown(touchId,(long)touch,
+                 SDL_FALSE,locationInView.x,locationInView.y,
+                 1);
 #else
-	  int i;
-	  for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
-	    if(finger[i] == touch) {
-	      SDL_SendFingerDown(touchId,i,
-				 SDL_FALSE,locationInView.x,locationInView.y,
-				 1);
-	      break;
-	    }
-	  }
+      int i;
+      for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
+        if(finger[i] == touch) {
+          SDL_SendFingerDown(touchId,i,
+                 SDL_FALSE,locationInView.x,locationInView.y,
+                 1);
+          break;
+        }
+      }
 #endif
 
-	  touch = (UITouch*)[enumerator nextObject]; 
-	}
+      touch = (UITouch*)[enumerator nextObject]; 
+    }
 #endif
 }
 
 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
-	/*
-		this can happen if the user puts more than 5 touches on the screen
-		at once, or perhaps in other circumstances.  Usually (it seems)
-		all active touches are canceled.
-	*/
-	[self touchesEnded: touches withEvent: event];
+    /*
+        this can happen if the user puts more than 5 touches on the screen
+        at once, or perhaps in other circumstances.  Usually (it seems)
+        all active touches are canceled.
+    */
+    [self touchesEnded: touches withEvent: event];
 }
 
 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
-	
-	NSEnumerator *enumerator = [touches objectEnumerator];
-	UITouch *touch = (UITouch*)[enumerator nextObject];
-	
-	if (touch) {
-		CGPoint locationInView = [touch locationInView: self];
+    
+    NSEnumerator *enumerator = [touches objectEnumerator];
+    UITouch *touch = (UITouch*)[enumerator nextObject];
+    
+    if (touch) {
+        CGPoint locationInView = [touch locationInView: self];
 
-		/* send moved event */
-		SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
-	}
+        /* send moved event */
+        SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
+    }
 
 #ifdef FIXED_MULTITOUCH
-	while(touch) {
-	  CGPoint locationInView = [touch locationInView: self];
-	  
+    while(touch) {
+      CGPoint locationInView = [touch locationInView: self];
+      
 
 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
-	  SDL_SendTouchMotion(touchId,(long)touch,
-			      SDL_FALSE,locationInView.x,locationInView.y,
-			      1);
+      SDL_SendTouchMotion(touchId,(long)touch,
+                  SDL_FALSE,locationInView.x,locationInView.y,
+                  1);
 #else
-	  int i;
-	  for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
-	    if(finger[i] == touch) {
-	      SDL_SendTouchMotion(touchId,i,
-				  SDL_FALSE,locationInView.x,locationInView.y,
-				  1);
-	      break;
-	    }
-	  }
+      int i;
+      for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
+        if(finger[i] == touch) {
+          SDL_SendTouchMotion(touchId,i,
+                  SDL_FALSE,locationInView.x,locationInView.y,
+                  1);
+          break;
+        }
+      }
 #endif
 
-	  touch = (UITouch*)[enumerator nextObject]; 
-	}
+      touch = (UITouch*)[enumerator nextObject]; 
+    }
 #endif
 }
 
 /*
-	---- Keyboard related functionality below this line ----
+    ---- Keyboard related functionality below this line ----
 */
 #if SDL_IPHONE_KEYBOARD
 
 /* Is the iPhone virtual keyboard visible onscreen? */
 - (BOOL)keyboardVisible {
-	return keyboardVisible;
+    return keyboardVisible;
 }
 
 /* Set ourselves up as a UITextFieldDelegate */
 - (void)initializeKeyboard {
-		
-	textField = [[UITextField alloc] initWithFrame: CGRectZero];
-	textField.delegate = self;
-	/* placeholder so there is something to delete! */
-	textField.text = @" ";	
-	
-	/* set UITextInputTrait properties, mostly to defaults */
-	textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
-	textField.autocorrectionType = UITextAutocorrectionTypeNo;
-	textField.enablesReturnKeyAutomatically = NO;
-	textField.keyboardAppearance = UIKeyboardAppearanceDefault;
-	textField.keyboardType = UIKeyboardTypeDefault;
-	textField.returnKeyType = UIReturnKeyDefault;
-	textField.secureTextEntry = NO;	
-	
-	textField.hidden = YES;
-	keyboardVisible = NO;
-	/* add the UITextField (hidden) to our view */
-	[self addSubview: textField];
-	[textField release];
+        
+    textField = [[UITextField alloc] initWithFrame: CGRectZero];
+    textField.delegate = self;
+    /* placeholder so there is something to delete! */
+    textField.text = @" ";    
+    
+    /* set UITextInputTrait properties, mostly to defaults */
+    textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
+    textField.autocorrectionType = UITextAutocorrectionTypeNo;
+    textField.enablesReturnKeyAutomatically = NO;
+    textField.keyboardAppearance = UIKeyboardAppearanceDefault;
+    textField.keyboardType = UIKeyboardTypeDefault;
+    textField.returnKeyType = UIReturnKeyDefault;
+    textField.secureTextEntry = NO;    
+    
+    textField.hidden = YES;
+    keyboardVisible = NO;
+    /* add the UITextField (hidden) to our view */
+    [self addSubview: textField];
+    [textField release];
 }
 
 /* reveal onscreen virtual keyboard */
 - (void)showKeyboard {
-	keyboardVisible = YES;
-	[textField becomeFirstResponder];
+    keyboardVisible = YES;
+    [textField becomeFirstResponder];
 }
 
 /* hide onscreen virtual keyboard */
 - (void)hideKeyboard {
-	keyboardVisible = NO;
-	[textField resignFirstResponder];
+    keyboardVisible = NO;
+    [textField resignFirstResponder];
 }
 
 /* UITextFieldDelegate method.  Invoked when user types something. */
 - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
-	
-	if ([string length] == 0) {
-		/* it wants to replace text with nothing, ie a delete */
-		SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
-		SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
-	}
-	else {
-		/* go through all the characters in the string we've been sent
-		   and convert them to key presses */
-		int i;
-		for (i=0; i<[string length]; i++) {
-			
-			unichar c = [string characterAtIndex: i];
-			
-			Uint16 mod = 0;
-			SDL_ScanCode code;
-			
-			if (c < 127) {
-				/* figure out the SDL_ScanCode and SDL_keymod for this unichar */
-				code = unicharToUIKeyInfoTable[c].code;
-				mod  = unicharToUIKeyInfoTable[c].mod;
-			}
-			else {
-				/* we only deal with ASCII right now */
-				code = SDL_SCANCODE_UNKNOWN;
-				mod = 0;
-			}
-			
-			if (mod & KMOD_SHIFT) {
-				/* If character uses shift, press shift down */
-				SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
-			}
-			/* send a keydown and keyup even for the character */
-			SDL_SendKeyboardKey(SDL_PRESSED, code);
-			SDL_SendKeyboardKey(SDL_RELEASED, code);
-			if (mod & KMOD_SHIFT) {
-				/* If character uses shift, press shift back up */
-				SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
-			}			
-		}
-	}
-	return NO; /* don't allow the edit! (keep placeholder text there) */
+    
+    if ([string length] == 0) {
+        /* it wants to replace text with nothing, ie a delete */
+        SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
+        SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
+    }
+    else {
+        /* go through all the characters in the string we've been sent
+           and convert them to key presses */
+        int i;
+        for (i=0; i<[string length]; i++) {
+            
+            unichar c = [string characterAtIndex: i];
+            
+            Uint16 mod = 0;
+            SDL_ScanCode code;
+            
+            if (c < 127) {
+                /* figure out the SDL_ScanCode and SDL_keymod for this unichar */
+                code = unicharToUIKeyInfoTable[c].code;
+                mod  = unicharToUIKeyInfoTable[c].mod;
+            }
+            else {
+                /* we only deal with ASCII right now */
+                code = SDL_SCANCODE_UNKNOWN;
+                mod = 0;
+            }
+            
+            if (mod & KMOD_SHIFT) {
+                /* If character uses shift, press shift down */
+                SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
+            }
+            /* send a keydown and keyup even for the character */
+            SDL_SendKeyboardKey(SDL_PRESSED, code);
+            SDL_SendKeyboardKey(SDL_RELEASED, code);
+            if (mod & KMOD_SHIFT) {
+                /* If character uses shift, press shift back up */
+                SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
+            }            
+        }
+    }
+    return NO; /* don't allow the edit! (keep placeholder text there) */
 }
 
 /* Terminates the editing session */
 - (BOOL)textFieldShouldReturn:(UITextField*)_textField {
-	[self hideKeyboard];
-	return YES;
+    SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN);
+    [self hideKeyboard];
+    return YES;
 }
 
 #endif
@@ -310,99 +311,99 @@
 #if SDL_IPHONE_KEYBOARD
 
 int SDL_iPhoneKeyboardShow(SDL_Window * window) {
-	
-	SDL_WindowData *data;
-	SDL_uikitview *view;
-	
-	if (NULL == window) {
-		SDL_SetError("Window does not exist");
-		return -1;
-	}
-	
-	data = (SDL_WindowData *)window->driverdata;
-	view = data->view;
-	
-	if (nil == view) {
-		SDL_SetError("Window has no view");
-		return -1;
-	}
-	else {
-		[view showKeyboard];
-		return 0;
-	}
+    
+    SDL_WindowData *data;
+    SDL_uikitview *view;
+    
+    if (NULL == window) {
+        SDL_SetError("Window does not exist");
+        return -1;
+    }
+    
+    data = (SDL_WindowData *)window->driverdata;
+    view = data->view;
+    
+    if (nil == view) {
+        SDL_SetError("Window has no view");
+        return -1;
+    }
+    else {
+        [view showKeyboard];
+        return 0;
+    }
 }
 
 int SDL_iPhoneKeyboardHide(SDL_Window * window) {
-	
-	SDL_WindowData *data;
-	SDL_uikitview *view;
-	
-	if (NULL == window) {
-		SDL_SetError("Window does not exist");
-		return -1;
-	}	
-	
-	data = (SDL_WindowData *)window->driverdata;
-	view = data->view;
-	
-	if (NULL == view) {
-		SDL_SetError("Window has no view");
-		return -1;
-	}
-	else {
-		[view hideKeyboard];
-		return 0;
-	}
+    
+    SDL_WindowData *data;
+    SDL_uikitview *view;
+    
+    if (NULL == window) {
+        SDL_SetError("Window does not exist");
+        return -1;
+    }    
+    
+    data = (SDL_WindowData *)window->driverdata;
+    view = data->view;
+    
+    if (NULL == view) {
+        SDL_SetError("Window has no view");
+        return -1;
+    }
+    else {
+        [view hideKeyboard];
+        return 0;
+    }
 }
 
 SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) {
-	
-	SDL_WindowData *data;
-	SDL_uikitview *view;
-	
-	if (NULL == window) {
-		SDL_SetError("Window does not exist");
-		return -1;
-	}	
-	
-	data = (SDL_WindowData *)window->driverdata;
-	view = data->view;
-	
-	if (NULL == view) {
-		SDL_SetError("Window has no view");
-		return 0;
-	}
-	else {
-		return view.keyboardVisible;
-	}
+    
+    SDL_WindowData *data;
+    SDL_uikitview *view;
+    
+    if (NULL == window) {
+        SDL_SetError("Window does not exist");
+        return -1;
+    }    
+    
+    data = (SDL_WindowData *)window->driverdata;
+    view = data->view;
+    
+    if (NULL == view) {
+        SDL_SetError("Window has no view");
+        return 0;
+    }
+    else {
+        return view.keyboardVisible;
+    }
 }
 
 int SDL_iPhoneKeyboardToggle(SDL_Window * window) {
-	
-	SDL_WindowData *data;
-	SDL_uikitview *view;
-	
-	if (NULL == window) {
-		SDL_SetError("Window does not exist");
-		return -1;
-	}	
-	
-	data = (SDL_WindowData *)window->driverdata;
-	view = data->view;
-	
-	if (NULL == view) {
-		SDL_SetError("Window has no view");
-		return -1;
-	}
-	else {
-		if (SDL_iPhoneKeyboardIsShown(window)) {
-			SDL_iPhoneKeyboardHide(window);
-		}
-		else {
-			SDL_iPhoneKeyboardShow(window);
-		}
-		return 0;
-	}
+    
+    SDL_WindowData *data;
+    SDL_uikitview *view;
+    
+    if (NULL == window) {
+        SDL_SetError("Window does not exist");
+        return -1;
+    }    
+    
+    data = (SDL_WindowData *)window->driverdata;
+    view = data->view;
+    
+    if (NULL == view) {
+        SDL_SetError("Window has no view");
+        return -1;
+    }
+    else {
+        if (SDL_iPhoneKeyboardIsShown(window)) {
+            SDL_iPhoneKeyboardHide(window);
+        }
+        else {
+            SDL_iPhoneKeyboardShow(window);
+        }
+        return 0;
+    }
 }
 
 #else
@@ -410,23 +411,24 @@
 /* stubs, used if compiled without keyboard support */
 
 int SDL_iPhoneKeyboardShow(SDL_Window * window) {
-	SDL_SetError("Not compiled with keyboard support");
-	return -1;
+    SDL_SetError("Not compiled with keyboard support");
+    return -1;
 }
 
 int SDL_iPhoneKeyboardHide(SDL_Window * window) {
-	SDL_SetError("Not compiled with keyboard support");
-	return -1;
+    SDL_SetError("Not compiled with keyboard support");
+    return -1;
 }
 
 SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) {
-	return 0;
+    return 0;
 }
 
 int SDL_iPhoneKeyboardToggle(SDL_Window * window) {
-	SDL_SetError("Not compiled with keyboard support");
-	return -1;
+    SDL_SetError("Not compiled with keyboard support");
+    return -1;
 }
 
+#endif /* SDL_IPHONE_KEYBOARD */
 
-#endif /* SDL_IPHONE_KEYBOARD */
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitwindow.m	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/SDL_uikitwindow.m	Sun Feb 06 21:23:32 2011 -0800
@@ -35,7 +35,6 @@
 #import "SDL_uikitappdelegate.h"
 
 #import "SDL_uikitopenglview.h"
-#import "SDL_renderer_sw.h"
 
 #include <Foundation/Foundation.h>
 
--- a/src/video/uikit/jumphack.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/jumphack.h	Sun Feb 06 21:23:32 2011 -0800
@@ -14,3 +14,5 @@
 extern jmp_buf *jump_env(void);
 
 #endif
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/keyinfotable.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/uikit/keyinfotable.h	Sun Feb 06 21:23:32 2011 -0800
@@ -26,10 +26,10 @@
 #include "SDL_scancode.h"
 
 /*
-	This file is used by the keyboard code in SDL_uikitview.m to convert between characters
-	passed in from the iPhone's virtual keyboard, and tuples of SDL_ScanCodes and SDL_keymods.
-	For example unicharToUIKeyInfoTable['a'] would give you the scan code and keymod for lower
-	case a.
+    This file is used by the keyboard code in SDL_uikitview.m to convert between characters
+    passed in from the iPhone's virtual keyboard, and tuples of SDL_ScanCodes and SDL_keymods.
+    For example unicharToUIKeyInfoTable['a'] would give you the scan code and keymod for lower
+    case a.
 */
 
 typedef struct
@@ -54,7 +54,7 @@
 /*  10 */ {   SDL_SCANCODE_UNKNOWN, 0 },
 /*  11 */ {   SDL_SCANCODE_UNKNOWN, 0 },
 /*  12 */ {   SDL_SCANCODE_UNKNOWN, 0 },
-/*  13 */ {   SDL_SCANCODE_UNKNOWN, 0 },
+/*  13 */ {   SDL_SCANCODE_RETURN, 0 },
 /*  14 */ {   SDL_SCANCODE_UNKNOWN, 0 },
 /*  15 */ {   SDL_SCANCODE_UNKNOWN, 0 },
 /*  16 */ {   SDL_SCANCODE_UNKNOWN, 0 },
@@ -74,22 +74,22 @@
 /*  30 */ {   SDL_SCANCODE_UNKNOWN, 0 },
 /*  31 */ {   SDL_SCANCODE_UNKNOWN, 0 },
 /*  32 */ {   SDL_SCANCODE_SPACE, 0 },
-/*  33 */ {   SDL_SCANCODE_1,	KMOD_SHIFT },		/* plus shift modifier '!' */
-/*  34 */ {   SDL_SCANCODE_APOSTROPHE, KMOD_SHIFT },	/* plus shift modifier '"' */
-/*  35 */ {   SDL_SCANCODE_3, KMOD_SHIFT },			/* plus shift modifier '#' */
-/*  36 */ {   SDL_SCANCODE_4, KMOD_SHIFT },			/* plus shift modifier '$' */
-/*  37 */ {   SDL_SCANCODE_5, KMOD_SHIFT },			/* plus shift modifier '%' */
-/*  38 */ {   SDL_SCANCODE_7, KMOD_SHIFT },			/* plus shift modifier '&' */
-/*  39 */ {   SDL_SCANCODE_APOSTROPHE, 0 },	/* '''					   */
-/*  40 */ {   SDL_SCANCODE_9, KMOD_SHIFT },	 		/* plus shift modifier '(' */
-/*  41 */ {   SDL_SCANCODE_0, KMOD_SHIFT },			/* plus shift modifier ')' */
-/*  42 */ {   SDL_SCANCODE_8, KMOD_SHIFT },			/* '*' */
-/*  43 */ {   SDL_SCANCODE_EQUALS, KMOD_SHIFT },	/* plus shift modifier '+' */
-/*  44 */ {   SDL_SCANCODE_COMMA, 0 },		/* ','					   */
-/*  45 */ {   SDL_SCANCODE_MINUS, 0 },		/* '-'					   */
-/*  46 */ {   SDL_SCANCODE_PERIOD, 0 },		/* '.'					   */
-/*  47 */ {   SDL_SCANCODE_SLASH, 0 },		/* '/'					   */
-/*  48 */ {   SDL_SCANCODE_0, 0	},		
+/*  33 */ {   SDL_SCANCODE_1,    KMOD_SHIFT },        /* plus shift modifier '!' */
+/*  34 */ {   SDL_SCANCODE_APOSTROPHE, KMOD_SHIFT },    /* plus shift modifier '"' */
+/*  35 */ {   SDL_SCANCODE_3, KMOD_SHIFT },            /* plus shift modifier '#' */
+/*  36 */ {   SDL_SCANCODE_4, KMOD_SHIFT },            /* plus shift modifier '$' */
+/*  37 */ {   SDL_SCANCODE_5, KMOD_SHIFT },            /* plus shift modifier '%' */
+/*  38 */ {   SDL_SCANCODE_7, KMOD_SHIFT },            /* plus shift modifier '&' */
+/*  39 */ {   SDL_SCANCODE_APOSTROPHE, 0 },    /* '''                       */
+/*  40 */ {   SDL_SCANCODE_9, KMOD_SHIFT },             /* plus shift modifier '(' */
+/*  41 */ {   SDL_SCANCODE_0, KMOD_SHIFT },            /* plus shift modifier ')' */
+/*  42 */ {   SDL_SCANCODE_8, KMOD_SHIFT },            /* '*' */
+/*  43 */ {   SDL_SCANCODE_EQUALS, KMOD_SHIFT },    /* plus shift modifier '+' */
+/*  44 */ {   SDL_SCANCODE_COMMA, 0 },        /* ','                       */
+/*  45 */ {   SDL_SCANCODE_MINUS, 0 },        /* '-'                       */
+/*  46 */ {   SDL_SCANCODE_PERIOD, 0 },        /* '.'                       */
+/*  47 */ {   SDL_SCANCODE_SLASH, 0 },        /* '/'                       */
+/*  48 */ {   SDL_SCANCODE_0, 0    },        
 /*  49 */ {   SDL_SCANCODE_1, 0 },
 /*  50 */ {   SDL_SCANCODE_2, 0 },
 /*  51 */ {   SDL_SCANCODE_3, 0 },
@@ -99,14 +99,14 @@
 /*  55 */ {   SDL_SCANCODE_7, 0 },
 /*  56 */ {   SDL_SCANCODE_8, 0 },
 /*  57 */ {   SDL_SCANCODE_9, 0 },
-/*  58 */ {   SDL_SCANCODE_SEMICOLON,  KMOD_SHIFT },	/* plus shift modifier ';' */
+/*  58 */ {   SDL_SCANCODE_SEMICOLON,  KMOD_SHIFT },    /* plus shift modifier ';' */
 /*  59 */ {   SDL_SCANCODE_SEMICOLON, 0 },
-/*  60 */ {   SDL_SCANCODE_COMMA,  KMOD_SHIFT },	 	/* plus shift modifier '<' */
+/*  60 */ {   SDL_SCANCODE_COMMA,  KMOD_SHIFT },         /* plus shift modifier '<' */
 /*  61 */ {   SDL_SCANCODE_EQUALS, 0 },
-/*  62 */ {   SDL_SCANCODE_PERIOD,  KMOD_SHIFT },		/* plus shift modifier '>' */
-/*  63 */ {   SDL_SCANCODE_SLASH,  KMOD_SHIFT },		/* plus shift modifier '?' */
-/*  64 */ {   SDL_SCANCODE_2,  KMOD_SHIFT },			/* plus shift modifier '@' */
-/*  65 */ {   SDL_SCANCODE_A,  KMOD_SHIFT },			/* all the following need shift modifiers */
+/*  62 */ {   SDL_SCANCODE_PERIOD,  KMOD_SHIFT },        /* plus shift modifier '>' */
+/*  63 */ {   SDL_SCANCODE_SLASH,  KMOD_SHIFT },        /* plus shift modifier '?' */
+/*  64 */ {   SDL_SCANCODE_2,  KMOD_SHIFT },            /* plus shift modifier '@' */
+/*  65 */ {   SDL_SCANCODE_A,  KMOD_SHIFT },            /* all the following need shift modifiers */
 /*  66 */ {   SDL_SCANCODE_B,  KMOD_SHIFT },
 /*  67 */ {   SDL_SCANCODE_C,  KMOD_SHIFT },
 /*  68 */ {   SDL_SCANCODE_D,  KMOD_SHIFT },
@@ -135,10 +135,10 @@
 /*  91 */ {   SDL_SCANCODE_LEFTBRACKET, 0 },
 /*  92 */ {   SDL_SCANCODE_BACKSLASH, 0 },
 /*  93 */ {   SDL_SCANCODE_RIGHTBRACKET, 0 },
-/*  94 */ {   SDL_SCANCODE_6,  KMOD_SHIFT },			/* plus shift modifier '^' */
-/*  95 */ {   SDL_SCANCODE_MINUS,  KMOD_SHIFT },		/* plus shift modifier '_' */
-/*  96 */ {   SDL_SCANCODE_GRAVE,  KMOD_SHIFT },		/* '`'
-/*  97 */ {   SDL_SCANCODE_A, 0	},	
+/*  94 */ {   SDL_SCANCODE_6,  KMOD_SHIFT },            /* plus shift modifier '^' */
+/*  95 */ {   SDL_SCANCODE_MINUS,  KMOD_SHIFT },        /* plus shift modifier '_' */
+/*  96 */ {   SDL_SCANCODE_GRAVE,  KMOD_SHIFT },        /* '`' */
+/*  97 */ {   SDL_SCANCODE_A, 0    },    
 /*  98 */ {   SDL_SCANCODE_B, 0 },
 /*  99 */ {   SDL_SCANCODE_C, 0 },
 /*  100 */{    SDL_SCANCODE_D, 0 },
@@ -164,12 +164,14 @@
 /*  120 */{    SDL_SCANCODE_X, 0 },
 /*  121 */{    SDL_SCANCODE_Y, 0 },
 /*  122 */{    SDL_SCANCODE_Z, 0 },
-/*  123 */{    SDL_SCANCODE_LEFTBRACKET, KMOD_SHIFT },	/* plus shift modifier '{' */
-/*  124 */{    SDL_SCANCODE_BACKSLASH, KMOD_SHIFT },	/* plus shift modifier '|' */
-/*  125 */{    SDL_SCANCODE_RIGHTBRACKET, KMOD_SHIFT },	/* plus shift modifier '}' */
-/*  126 */{    SDL_SCANCODE_GRAVE, KMOD_SHIFT },	 	/* plus shift modifier '~' */
+/*  123 */{    SDL_SCANCODE_LEFTBRACKET, KMOD_SHIFT },    /* plus shift modifier '{' */
+/*  124 */{    SDL_SCANCODE_BACKSLASH, KMOD_SHIFT },    /* plus shift modifier '|' */
+/*  125 */{    SDL_SCANCODE_RIGHTBRACKET, KMOD_SHIFT },    /* plus shift modifier '}' */
+/*  126 */{    SDL_SCANCODE_GRAVE, KMOD_SHIFT },         /* plus shift modifier '~' */
 /*  127 */{    SDL_SCANCODE_DELETE, KMOD_SHIFT }
 /* *INDENT-ON* */
 };
 
 #endif /* UIKitKeyInfo */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_ceddrawrender.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,835 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-    
-    Stefan Klug
-    klug.stefan@gmx.de
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_DDRAW
-
-#include "SDL_windowsvideo.h"
-#include "../SDL_yuv_sw_c.h"
-
-#if 0
-#define DDRAW_LOG(...) printf(__VA_ARGS__)
-#else
-#define DDRAW_LOG(...)
-#endif
-
-
-/* DirectDraw renderer implementation */
-
-static SDL_Renderer *DDRAW_CreateRenderer(SDL_Window * window, Uint32 flags);
-static int DDRAW_DisplayModeChanged(SDL_Renderer * renderer);
-static int DDRAW_CreateTexture(SDL_Renderer * renderer,
-                               SDL_Texture * texture);
-static int DDRAW_QueryTexturePixels(SDL_Renderer * renderer,
-                                    SDL_Texture * texture, void **pixels,
-                                    int *pitch);
-static int DDRAW_SetTextureColorMod(SDL_Renderer * renderer,
-                                    SDL_Texture * texture);
-static int DDRAW_SetTextureAlphaMod(SDL_Renderer * renderer,
-                                    SDL_Texture * texture);
-static int DDRAW_SetTextureBlendMode(SDL_Renderer * renderer,
-                                     SDL_Texture * texture);
-static int DDRAW_SetTextureScaleMode(SDL_Renderer * renderer,
-                                     SDL_Texture * texture);
-static int DDRAW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                               const SDL_Rect * rect, const void *pixels,
-                               int pitch);
-static int DDRAW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                             const SDL_Rect * rect, int markDirty,
-                             void **pixels, int *pitch);
-static void DDRAW_UnlockTexture(SDL_Renderer * renderer,
-                                SDL_Texture * texture);
-static void DDRAW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                               int numrects, const SDL_Rect * rects);
-static int DDRAW_RenderPoint(SDL_Renderer * renderer, int x, int y);
-static int DDRAW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
-                            int y2);
-static int DDRAW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
-static int DDRAW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                            const SDL_Rect * srcrect,
-                            const SDL_Rect * dstrect);
-static void DDRAW_RenderPresent(SDL_Renderer * renderer);
-static void DDRAW_DestroyTexture(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
-static void DDRAW_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver DDRAW_RenderDriver = {
-    DDRAW_CreateRenderer,
-    {
-     "ddraw",
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
-      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
-      SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
-     (SDL_TEXTUREMODULATE_NONE),
-     (SDL_BLENDMODE_NONE),
-     (SDL_SCALEMODE_NONE),
-     0,
-     {0},
-     0,
-     0}
-};
-
-typedef struct
-{
-    IDirectDraw *ddraw;
-    IDirectDrawSurface *primary;
-} DDRAW_RenderData;
-
-typedef struct
-{
-    RECT lock;
-    IDirectDrawSurface *surface;
-} DDRAW_TextureData;
-
-
-static void
-DDRAW_SetError(const char *prefix, HRESULT result)
-{
-    const char *error;
-
-    switch (result) {
-    case DDERR_CANTCREATEDC:
-        error = "CANTCREATEDC";
-        break;
-    case DDERR_CANTLOCKSURFACE:
-        error = "CANTLOCKSURFACE";
-        break;
-    case DDERR_CLIPPERISUSINGHWND:
-        error = "CLIPPERISUSINGHWND";
-        break;
-    case DDERR_COLORKEYNOTSET:
-        error = "COLORKEYNOTSET";
-        break;
-    case DDERR_CURRENTLYNOTAVAIL:
-        error = "CURRENTLYNOTAVAIL";
-        break;
-    case DDERR_DCALREADYCREATED:
-        error = "DCALREADYCREATED";
-        break;
-    case DDERR_DEVICEDOESNTOWNSURFACE:
-        error = "DEVICEDOESNTOWNSURFACE";
-        break;
-    case DDERR_DIRECTDRAWALREADYCREATED:
-        error = "DIRECTDRAWALREADYCREATED";
-        break;
-    case DDERR_EXCLUSIVEMODEALREADYSET:
-        error = "EXCLUSIVEMODEALREADYSET";
-        break;
-    case DDERR_GENERIC:
-        error = "GENERIC";
-        break;
-    case DDERR_HEIGHTALIGN:
-        error = "HEIGHTALIGN";
-        break;
-    case DDERR_IMPLICITLYCREATED:
-        error = "IMPLICITLYCREATED";
-        break;
-    case DDERR_INCOMPATIBLEPRIMARY:
-        error = "INCOMPATIBLEPRIMARY";
-        break;
-    case DDERR_INVALIDCAPS:
-        error = "INVALIDCAPS";
-        break;
-    case DDERR_INVALIDCLIPLIST:
-        error = "INVALIDCLIPLIST";
-        break;
-    case DDERR_INVALIDMODE:
-        error = "INVALIDMODE";
-        break;
-    case DDERR_INVALIDOBJECT:
-        error = "INVALIDOBJECT";
-        break;
-    case DDERR_INVALIDPARAMS:
-        error = "INVALIDPARAMS";
-        break;
-    case DDERR_INVALIDPIXELFORMAT:
-        error = "INVALIDPIXELFORMAT";
-        break;
-    case DDERR_INVALIDPOSITION:
-        error = "INVALIDPOSITION";
-        break;
-    case DDERR_INVALIDRECT:
-        error = "INVALIDRECT";
-        break;
-    case DDERR_LOCKEDSURFACES:
-        error = "LOCKEDSURFACES";
-        break;
-    case DDERR_MOREDATA:
-        error = "MOREDATA";
-        break;
-    case DDERR_NOALPHAHW:
-        error = "NOALPHAHW";
-        break;
-    case DDERR_NOBLTHW:
-        error = "NOBLTHW";
-        break;
-    case DDERR_NOCLIPLIST:
-        error = "NOCLIPLIST";
-        break;
-    case DDERR_NOCLIPPERATTACHED:
-        error = "NOCLIPPERATTACHED";
-        break;
-    case DDERR_NOCOLORCONVHW:
-        error = "NOCOLORCONVHW";
-        break;
-    case DDERR_NOCOLORKEYHW:
-        error = "NOCOLORKEYHW";
-        break;
-    case DDERR_NOCOOPERATIVELEVELSET:
-        error = "NOCOOPERATIVELEVELSET";
-        break;
-    case DDERR_NODC:
-        error = "NODC";
-        break;
-    case DDERR_NOFLIPHW:
-        error = "NOFLIPHW";
-        break;
-    case DDERR_NOOVERLAYDEST:
-        error = "NOOVERLAYDEST";
-        break;
-    case DDERR_NOOVERLAYHW:
-        error = "NOOVERLAYHW";
-        break;
-    case DDERR_NOPALETTEATTACHED:
-        error = "NOPALETTEATTACHED";
-        break;
-    case DDERR_NOPALETTEHW:
-        error = "NOPALETTEHW";
-        break;
-    case DDERR_NORASTEROPHW:
-        error = "NORASTEROPHW";
-        break;
-    case DDERR_NOSTRETCHHW:
-        error = "NOSTRETCHHW";
-        break;
-    case DDERR_NOTAOVERLAYSURFACE:
-        error = "NOTAOVERLAYSURFACE";
-        break;
-    case DDERR_NOTFLIPPABLE:
-        error = "NOTFLIPPABLE";
-        break;
-    case DDERR_NOTFOUND:
-        error = "NOTFOUND";
-        break;
-    case DDERR_NOTLOCKED:
-        error = "NOTLOCKED";
-        break;
-    case DDERR_NOTPALETTIZED:
-        error = "NOTPALETTIZED";
-        break;
-    case DDERR_NOVSYNCHW:
-        error = "NOVSYNCHW";
-        break;
-    case DDERR_NOZOVERLAYHW:
-        error = "NOZOVERLAYHW";
-        break;
-    case DDERR_OUTOFCAPS:
-        error = "OUTOFCAPS";
-        break;
-    case DDERR_OUTOFMEMORY:
-        error = "OUTOFMEMORY";
-        break;
-    case DDERR_OUTOFVIDEOMEMORY:
-        error = "OUTOFVIDEOMEMORY";
-        break;
-    case DDERR_OVERLAPPINGRECTS:
-        error = "OVERLAPPINGRECTS";
-        break;
-    case DDERR_OVERLAYNOTVISIBLE:
-        error = "OVERLAYNOTVISIBLE";
-        break;
-    case DDERR_PALETTEBUSY:
-        error = "PALETTEBUSY";
-        break;
-    case DDERR_PRIMARYSURFACEALREADYEXISTS:
-        error = "PRIMARYSURFACEALREADYEXISTS";
-        break;
-    case DDERR_REGIONTOOSMALL:
-        error = "REGIONTOOSMALL";
-        break;
-    case DDERR_SURFACEBUSY:
-        error = "SURFACEBUSY";
-        break;
-    case DDERR_SURFACELOST:
-        error = "SURFACELOST";
-        break;
-    case DDERR_TOOBIGHEIGHT:
-        error = "TOOBIGHEIGHT";
-        break;
-    case DDERR_TOOBIGSIZE:
-        error = "TOOBIGSIZE";
-        break;
-    case DDERR_TOOBIGWIDTH:
-        error = "TOOBIGWIDTH";
-        break;
-    case DDERR_UNSUPPORTED:
-        error = "UNSUPPORTED";
-        break;
-    case DDERR_UNSUPPORTEDFORMAT:
-        error = "UNSUPPORTEDFORMAT";
-        break;
-    case DDERR_VERTICALBLANKINPROGRESS:
-        error = "VERTICALBLANKINPROGRESS";
-        break;
-    case DDERR_VIDEONOTACTIVE:
-        error = "VIDEONOTACTIVE";
-        break;
-    case DDERR_WASSTILLDRAWING:
-        error = "WASSTILLDRAWING";
-        break;
-    case DDERR_WRONGMODE:
-        error = "WRONGMODE";
-        break;
-    default:
-        error = "UNKNOWN";
-        break;
-    }
-    SDL_SetError("%s: %s", prefix, error);
-}
-
-static SDL_bool
-PixelFormatToDDPIXELFORMAT(Uint32 format, LPDDPIXELFORMAT dst)
-{
-    SDL_zerop(dst);
-    dst->dwSize = sizeof(*dst);
-
-    if (SDL_ISPIXELFORMAT_FOURCC(format)) {
-        dst->dwFlags = DDPF_FOURCC;
-        dst->dwFourCC = format;
-    } else if (SDL_ISPIXELFORMAT_INDEXED(format)) {
-        SDL_SetError("Indexed pixelformats are not supported.");
-        return SDL_FALSE;
-    } else {
-        int bpp;
-        Uint32 Rmask, Gmask, Bmask, Amask;
-        if (!SDL_PixelFormatEnumToMasks
-            (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-            SDL_SetError("pixelformat not supported");
-            return SDL_FALSE;
-        }
-
-        if (!Rmask && !Gmask && !Bmask) {
-            dst->dwFlags = DDPF_ALPHA;
-            dst->dwAlphaBitDepth = bpp;
-        } else {
-            dst->dwFlags = DDPF_RGB;
-            dst->dwRGBBitCount = bpp;
-            dst->dwRBitMask = Rmask;
-            dst->dwGBitMask = Gmask;
-            dst->dwBBitMask = Bmask;
-
-            if (Amask) {
-                dst->dwFlags |= DDPF_ALPHAPIXELS;
-                dst->dwRGBAlphaBitMask = Amask;
-            }
-        }
-    }
-
-    return SDL_TRUE;
-}
-
-static SDL_bool
-DDRAW_IsTextureFormatAvailable(IDirectDraw * ddraw, Uint32 display_format,
-                               Uint32 texture_format)
-{
-    int bpp;
-    Uint32 Rmask, Gmask, Bmask, Amask;
-
-    if (SDL_ISPIXELFORMAT_FOURCC(texture_format)) {
-        //TODO I don't expect DDRAW to support all 4CC formats, but I don't know which ones
-        return SDL_TRUE;
-    }
-    //These are only basic checks
-    if (SDL_ISPIXELFORMAT_INDEXED(texture_format)) {
-        return SDL_FALSE;
-    }
-
-    if (!SDL_PixelFormatEnumToMasks
-        (texture_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-        return SDL_FALSE;
-    }
-
-    switch (bpp) {
-    case 4:
-    case 8:
-    case 16:
-    case 24:
-    case 32:
-        break;
-    default:
-        return SDL_FALSE;
-    }
-
-    return SDL_TRUE;
-}
-
-void
-DDRAW_AddRenderDriver(_THIS)
-{
-    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    SDL_RendererInfo *info = &DDRAW_RenderDriver.info;
-    SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode;
-
-    if (data->ddraw) {
-        int i;
-        int formats[] = {
-            SDL_PIXELFORMAT_INDEX8,
-            SDL_PIXELFORMAT_RGB332,
-            SDL_PIXELFORMAT_RGB444,
-            SDL_PIXELFORMAT_RGB555,
-            SDL_PIXELFORMAT_ARGB4444,
-            SDL_PIXELFORMAT_ARGB1555,
-            SDL_PIXELFORMAT_RGB565,
-            SDL_PIXELFORMAT_RGB888,
-            SDL_PIXELFORMAT_ARGB8888,
-            SDL_PIXELFORMAT_ARGB2101010,
-        };
-
-        for (i = 0; i < SDL_arraysize(formats); ++i) {
-            if (DDRAW_IsTextureFormatAvailable
-                (data->ddraw, mode->format, formats[i])) {
-                info->texture_formats[info->num_texture_formats++] =
-                    formats[i];
-            }
-        }
-
-        //TODO the fourcc formats should get fetched from IDirectDraw::GetFourCCCodes
-        info->texture_formats[info->num_texture_formats++] =
-            SDL_PIXELFORMAT_YV12;
-        info->texture_formats[info->num_texture_formats++] =
-            SDL_PIXELFORMAT_IYUV;
-        info->texture_formats[info->num_texture_formats++] =
-            SDL_PIXELFORMAT_YUY2;
-        info->texture_formats[info->num_texture_formats++] =
-            SDL_PIXELFORMAT_UYVY;
-        info->texture_formats[info->num_texture_formats++] =
-            SDL_PIXELFORMAT_YVYU;
-
-        for (i = 0; i < _this->num_displays; ++i)
-            SDL_AddRenderDriver(&_this->displays[i], &DDRAW_RenderDriver);
-        }
-    }
-}
-
-SDL_Renderer *
-DDRAW_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_VideoDisplay *display = window->display;
-    SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata;
-    SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
-    SDL_Renderer *renderer;
-    DDRAW_RenderData *data;
-    HRESULT result;
-    DDSURFACEDESC ddsd;
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (DDRAW_RenderData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        DDRAW_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-    data->ddraw = videodata->ddraw;
-
-    videodata->render = RENDER_DDRAW;
-
-    renderer->DisplayModeChanged = DDRAW_DisplayModeChanged;
-    renderer->CreateTexture = DDRAW_CreateTexture;
-    renderer->QueryTexturePixels = DDRAW_QueryTexturePixels;
-
-    renderer->SetTextureColorMod = DDRAW_SetTextureColorMod;
-    renderer->SetTextureAlphaMod = DDRAW_SetTextureAlphaMod;
-    renderer->SetTextureBlendMode = DDRAW_SetTextureBlendMode;
-    renderer->SetTextureScaleMode = DDRAW_SetTextureScaleMode;
-    renderer->UpdateTexture = DDRAW_UpdateTexture;
-    renderer->LockTexture = DDRAW_LockTexture;
-    renderer->UnlockTexture = DDRAW_UnlockTexture;
-    renderer->DirtyTexture = DDRAW_DirtyTexture;
-    renderer->RenderPoint = DDRAW_RenderPoint;
-    renderer->RenderLine = DDRAW_RenderLine;
-    renderer->RenderFill = DDRAW_RenderFill;
-    renderer->RenderCopy = DDRAW_RenderCopy;
-    renderer->RenderPresent = DDRAW_RenderPresent;
-    renderer->DestroyTexture = DDRAW_DestroyTexture;
-    renderer->DestroyRenderer = DDRAW_DestroyRenderer;
-    renderer->info = DDRAW_RenderDriver.info;
-    renderer->window = window;
-    renderer->driverdata = data;
-
-    renderer->info.flags = SDL_RENDERER_ACCELERATED;
-
-    SDL_zero(ddsd);
-    ddsd.dwSize = sizeof(ddsd);
-    ddsd.dwFlags = DDSD_CAPS;
-
-    if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-    } else {
-        //TODO handle non fullscreen
-        SDL_SetError("DirectDraw renderer has only fullscreen implemented");
-        DDRAW_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    if (flags & SDL_RENDERER_PRESENTFLIP2) {
-        ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT;
-        ddsd.dwBackBufferCount = 2;
-    } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
-        ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT;
-        ddsd.dwBackBufferCount = 3;
-    } else if (flags & SDL_RENDERER_PRESENTCOPY) {
-        //TODO what is the best approximation to this mode
-    } else {
-
-    }
-
-    if (flags & SDL_RENDERER_PRESENTVSYNC) {
-        SDL_SetError("DirectDraw renderer with v-sync is not implemented");
-        DDRAW_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    result =
-        data->ddraw->lpVtbl->SetCooperativeLevel(data->ddraw,
-                                                 windowdata->hwnd,
-                                                 DDSCL_NORMAL);
-    if (result != DD_OK) {
-        DDRAW_SetError("CreateDevice()", result);
-        DDRAW_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    result =
-        data->ddraw->lpVtbl->CreateSurface(data->ddraw, &ddsd, &data->primary,
-                                           NULL);
-    if (result != DD_OK) {
-        DDRAW_SetError("CreateDevice()", result);
-        DDRAW_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    return renderer;
-}
-
-static int
-DDRAW_Reset(SDL_Renderer * renderer)
-{
-    //TODO implement
-    /*D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-       HRESULT result;
-
-       result = IDirect3DDevice9_Reset(data->device, &data->pparams);
-       if (FAILED(result)) {
-       if (result == D3DERR_DEVICELOST) {
-       /* Don't worry about it, we'll reset later... *
-       return 0;
-       } else {
-       D3D_SetError("Reset()", result);
-       return -1;
-       }
-       }
-       IDirect3DDevice9_SetVertexShader(data->device, NULL);
-       IDirect3DDevice9_SetFVF(data->device,
-       D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
-       IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
-       D3DCULL_NONE);
-       IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE); */
-    return 0;
-}
-
-static int
-DDRAW_DisplayModeChanged(SDL_Renderer * renderer)
-{
-    //TODO implement
-    /*D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-       SDL_Window *window = renderer->window;
-       SDL_VideoDisplay *display = window->display;
-
-       data->pparams.BackBufferWidth = window->w;
-       data->pparams.BackBufferHeight = window->h;
-       if (window->flags & SDL_WINDOW_FULLSCREEN) {
-       data->pparams.BackBufferFormat =
-       PixelFormatToD3DFMT(display->fullscreen_mode.format);
-       } else {
-       data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
-       }
-       return D3D_Reset(renderer); */
-    return 0;
-}
-
-static int
-DDRAW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    DDRAW_RenderData *renderdata = (DDRAW_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    Uint32 display_format = display->current_mode.format;
-    DDRAW_TextureData *data;
-    DDSURFACEDESC ddsd;
-    HRESULT result;
-
-    data = (DDRAW_TextureData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    SDL_zero(ddsd);
-    ddsd.dwSize = sizeof(ddsd);
-    ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_HEIGHT | DDSD_WIDTH;
-    ddsd.dwWidth = texture->w;
-    ddsd.dwHeight = texture->h;
-
-
-    if (!PixelFormatToDDPIXELFORMAT(texture->format, &ddsd.ddpfPixelFormat)) {
-        SDL_free(data);
-        return -1;
-    }
-
-    texture->driverdata = data;
-
-    result =
-        renderdata->ddraw->lpVtbl->CreateSurface(renderdata->ddraw, &ddsd,
-                                                 &data->surface, NULL);
-    if (result != DD_OK) {
-        SDL_free(data);
-        DDRAW_SetError("CreateTexture", result);
-        return -1;
-    }
-
-    return 0;
-}
-
-static int
-DDRAW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                         void **pixels, int *pitch)
-{
-    //TODO implement
-    SDL_SetError("QueryTexturePixels is not implemented");
-    return -1;
-}
-
-static int
-DDRAW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    return 0;
-}
-
-static int
-DDRAW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    return 0;
-}
-
-static int
-DDRAW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    switch (texture->blendMode) {
-    case SDL_BLENDMODE_NONE:
-        return 0;
-    default:
-        SDL_Unsupported();
-        texture->blendMode = SDL_BLENDMODE_NONE;
-        return -1;
-    }
-}
-
-static int
-DDRAW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    switch (texture->scaleMode) {
-    case SDL_SCALEMODE_NONE:
-    default:
-        SDL_Unsupported();
-        texture->scaleMode = SDL_SCALEMODE_NONE;
-        return -1;
-    }
-    return 0;
-}
-
-static int
-DDRAW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                    const SDL_Rect * rect, const void *pixels, int pitch)
-{
-    DDRAW_TextureData *data = (DDRAW_TextureData *) texture->driverdata;
-
-    //TODO implement
-    SDL_SetError("UpdateTexture is not implemented");
-    return 0;
-}
-
-static int
-DDRAW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                  const SDL_Rect * rect, int markDirty, void **pixels,
-                  int *pitch)
-{
-    DDRAW_TextureData *data = (DDRAW_TextureData *) texture->driverdata;
-    HRESULT result;
-    DDSURFACEDESC ddsd;
-
-    SDL_zero(ddsd);
-    ddsd.dwSize = sizeof(ddsd);
-
-    /**
-     * On a Axim x51v locking a subrect returns the startaddress of the whole surface,
-     * wheras on my ASUS MyPal 696 the startaddress of the locked area is returned,
-     * thats why I always lock the whole surface and calculate the pixels pointer by hand.
-     * This shouldn't be a speed problem, as multiple locks aren't available on DDraw Mobile
-     * see http://msdn.microsoft.com/en-us/library/ms858221.aspx
-     */
-
-    result = data->surface->lpVtbl->Lock(data->surface, NULL, &ddsd, 0, NULL);
-    if (result != DD_OK) {
-        DDRAW_SetError("LockRect()", result);
-        return -1;
-    }
-
-    *pixels = ddsd.lpSurface + rect->y * ddsd.lPitch + rect->x * ddsd.lXPitch;
-    *pitch = ddsd.lPitch;
-    return 0;
-}
-
-static void
-DDRAW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    DDRAW_TextureData *data = (DDRAW_TextureData *) texture->driverdata;
-
-    data->surface->lpVtbl->Unlock(data->surface, NULL);
-}
-
-static void
-DDRAW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                   int numrects, const SDL_Rect * rects)
-{
-}
-
-static void
-DDRAW_SetBlendMode(DDRAW_RenderData * data, int blendMode)
-{
-    switch (blendMode) {
-
-    }
-}
-
-static int
-DDRAW_RenderPoint(SDL_Renderer * renderer, int x, int y)
-{
-    return -1;
-}
-
-static int
-DDRAW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
-{
-    return -1;
-}
-
-static int
-DDRAW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
-{
-    return -1;
-}
-
-static int
-DDRAW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    DDRAW_RenderData *data = (DDRAW_RenderData *) renderer->driverdata;
-    DDRAW_TextureData *texturedata =
-        (DDRAW_TextureData *) texture->driverdata;
-    HRESULT result;
-    RECT srcr;
-    RECT dstr;
-    DDBLTFX bltfx;
-
-    srcr.left = srcrect->x;
-    srcr.top = srcrect->y;
-    srcr.right = srcrect->x + srcrect->w;
-    srcr.bottom = srcrect->y + srcrect->h;
-
-    dstr.left = dstrect->x;
-    dstr.top = dstrect->y;
-    dstr.right = dstrect->x + dstrect->w;
-    dstr.bottom = dstrect->y + dstrect->h;
-
-    SDL_zero(bltfx);
-    bltfx.dwSize = sizeof(bltfx);
-    bltfx.dwROP = SRCCOPY;
-
-    data->primary->lpVtbl->Blt(data->primary, &dstr, texturedata->surface,
-                               &srcr, DDBLT_ROP, &bltfx);
-
-    return 0;
-}
-
-static void
-DDRAW_RenderPresent(SDL_Renderer * renderer)
-{
-    DDRAW_RenderData *data = (DDRAW_RenderData *) renderer->driverdata;
-    HRESULT result;
-
-    return;
-
-    result =
-        data->primary->lpVtbl->Flip(data->primary, NULL, DDFLIP_INTERVAL1);
-    if (result != DD_OK) {
-        DDRAW_SetError("Present()", result);
-    }
-}
-
-static void
-DDRAW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    DDRAW_TextureData *data = (DDRAW_TextureData *) texture->driverdata;
-
-    if (!data) {
-        return;
-    }
-
-    data->surface->lpVtbl->Release(data->surface);
-    SDL_free(data);
-    texture->driverdata = NULL;
-}
-
-static void
-DDRAW_DestroyRenderer(SDL_Renderer * renderer)
-{
-    DDRAW_RenderData *data = (DDRAW_RenderData *) renderer->driverdata;
-
-    if (data) {
-        data->primary->lpVtbl->Release(data->primary);
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-#endif /* SDL_VIDEO_RENDER_DDRAW */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_ceddrawrender.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-    
-    Stefan Klug
-    klug.stefan@gmx.de
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_DDRAW
-extern void DDRAW_AddRenderDriver(_THIS);
-#endif
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_d3drender.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1533 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_D3D
-
-#include "SDL_windowsvideo.h"
-#include "../SDL_yuv_sw_c.h"
-
-#ifdef ASSEMBLE_SHADER
-///////////////////////////////////////////////////////////////////////////
-// ID3DXBuffer:
-// ------------
-// The buffer object is used by D3DX to return arbitrary size data.
-//
-// GetBufferPointer -
-//    Returns a pointer to the beginning of the buffer.
-//
-// GetBufferSize -
-//    Returns the size of the buffer, in bytes.
-///////////////////////////////////////////////////////////////////////////
-
-typedef interface ID3DXBuffer ID3DXBuffer;
-typedef interface ID3DXBuffer *LPD3DXBUFFER;
-
-// {8BA5FB08-5195-40e2-AC58-0D989C3A0102}
-DEFINE_GUID(IID_ID3DXBuffer, 
-0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2);
-
-#undef INTERFACE
-#define INTERFACE ID3DXBuffer
-
-typedef interface ID3DXBuffer {
-    const struct ID3DXBufferVtbl FAR* lpVtbl;
-} ID3DXBuffer;
-typedef const struct ID3DXBufferVtbl ID3DXBufferVtbl;
-const struct ID3DXBufferVtbl
-{
-    // IUnknown
-    STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
-    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG, Release)(THIS) PURE;
-
-    // ID3DXBuffer
-    STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE;
-    STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE;
-};
-
-HRESULT WINAPI
-    D3DXAssembleShader(
-        LPCSTR                          pSrcData,
-        UINT                            SrcDataLen,
-        CONST LPVOID*                   pDefines,
-        LPVOID                          pInclude,
-        DWORD                           Flags,
-        LPD3DXBUFFER*                   ppShader,
-        LPD3DXBUFFER*                   ppErrorMsgs);
-
-#endif /* ASSEMBLE_SHADER */
-
-
-/* Direct3D renderer implementation */
-
-#if 1                           /* This takes more memory but you won't lose your texture data */
-#define D3DPOOL_SDL    D3DPOOL_MANAGED
-#define SDL_MEMORY_POOL_MANAGED
-#else
-#define D3DPOOL_SDL    D3DPOOL_DEFAULT
-#define SDL_MEMORY_POOL_DEFAULT
-#endif
-
-static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags);
-static int D3D_DisplayModeChanged(SDL_Renderer * renderer);
-static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int D3D_QueryTexturePixels(SDL_Renderer * renderer,
-                                  SDL_Texture * texture, void **pixels,
-                                  int *pitch);
-static int D3D_SetTexturePalette(SDL_Renderer * renderer,
-                                 SDL_Texture * texture,
-                                 const SDL_Color * colors, int firstcolor,
-                                 int ncolors);
-static int D3D_GetTexturePalette(SDL_Renderer * renderer,
-                                 SDL_Texture * texture, SDL_Color * colors,
-                                 int firstcolor, int ncolors);
-static int D3D_SetTextureColorMod(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int D3D_SetTextureAlphaMod(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int D3D_SetTextureBlendMode(SDL_Renderer * renderer,
-                                   SDL_Texture * texture);
-static int D3D_SetTextureScaleMode(SDL_Renderer * renderer,
-                                   SDL_Texture * texture);
-static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                             const SDL_Rect * rect, const void *pixels,
-                             int pitch);
-static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                           const SDL_Rect * rect, int markDirty,
-                           void **pixels, int *pitch);
-static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                             int numrects, const SDL_Rect * rects);
-static int D3D_RenderDrawPoints(SDL_Renderer * renderer,
-                                const SDL_Point * points, int count);
-static int D3D_RenderDrawLines(SDL_Renderer * renderer,
-                               const SDL_Point * points, int count);
-static int D3D_RenderDrawRects(SDL_Renderer * renderer,
-                               const SDL_Rect ** rects, int count);
-static int D3D_RenderFillRects(SDL_Renderer * renderer,
-                               const SDL_Rect ** rects, int count);
-static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * srcrect, const SDL_Rect * dstrect);
-static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                Uint32 format, void * pixels, int pitch);
-static int D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                 Uint32 format, const void * pixels, int pitch);
-static void D3D_RenderPresent(SDL_Renderer * renderer);
-static void D3D_DestroyTexture(SDL_Renderer * renderer,
-                               SDL_Texture * texture);
-static void D3D_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver D3D_RenderDriver = {
-    D3D_CreateRenderer,
-    {
-     "d3d",
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
-      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
-      SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC |
-      SDL_RENDERER_ACCELERATED),
-     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
-      SDL_TEXTUREMODULATE_ALPHA),
-     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
-      SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
-     (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST |
-      SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST),
-     0,
-     {0},
-     0,
-     0}
-};
-
-typedef struct
-{
-    IDirect3D9 *d3d;
-    IDirect3DDevice9 *device;
-    UINT adapter;
-    D3DPRESENT_PARAMETERS pparams;
-    LPDIRECT3DPIXELSHADER9 ps_mask;
-    SDL_bool beginScene;
-} D3D_RenderData;
-
-typedef struct
-{
-    SDL_SW_YUVTexture *yuv;
-    Uint32 format;
-    IDirect3DTexture9 *texture;
-} D3D_TextureData;
-
-typedef struct
-{
-    float x, y, z;
-    float rhw;
-    DWORD color;
-    float u, v;
-} Vertex;
-
-static void
-D3D_SetError(const char *prefix, HRESULT result)
-{
-    const char *error;
-
-    switch (result) {
-    case D3DERR_WRONGTEXTUREFORMAT:
-        error = "WRONGTEXTUREFORMAT";
-        break;
-    case D3DERR_UNSUPPORTEDCOLOROPERATION:
-        error = "UNSUPPORTEDCOLOROPERATION";
-        break;
-    case D3DERR_UNSUPPORTEDCOLORARG:
-        error = "UNSUPPORTEDCOLORARG";
-        break;
-    case D3DERR_UNSUPPORTEDALPHAOPERATION:
-        error = "UNSUPPORTEDALPHAOPERATION";
-        break;
-    case D3DERR_UNSUPPORTEDALPHAARG:
-        error = "UNSUPPORTEDALPHAARG";
-        break;
-    case D3DERR_TOOMANYOPERATIONS:
-        error = "TOOMANYOPERATIONS";
-        break;
-    case D3DERR_CONFLICTINGTEXTUREFILTER:
-        error = "CONFLICTINGTEXTUREFILTER";
-        break;
-    case D3DERR_UNSUPPORTEDFACTORVALUE:
-        error = "UNSUPPORTEDFACTORVALUE";
-        break;
-    case D3DERR_CONFLICTINGRENDERSTATE:
-        error = "CONFLICTINGRENDERSTATE";
-        break;
-    case D3DERR_UNSUPPORTEDTEXTUREFILTER:
-        error = "UNSUPPORTEDTEXTUREFILTER";
-        break;
-    case D3DERR_CONFLICTINGTEXTUREPALETTE:
-        error = "CONFLICTINGTEXTUREPALETTE";
-        break;
-    case D3DERR_DRIVERINTERNALERROR:
-        error = "DRIVERINTERNALERROR";
-        break;
-    case D3DERR_NOTFOUND:
-        error = "NOTFOUND";
-        break;
-    case D3DERR_MOREDATA:
-        error = "MOREDATA";
-        break;
-    case D3DERR_DEVICELOST:
-        error = "DEVICELOST";
-        break;
-    case D3DERR_DEVICENOTRESET:
-        error = "DEVICENOTRESET";
-        break;
-    case D3DERR_NOTAVAILABLE:
-        error = "NOTAVAILABLE";
-        break;
-    case D3DERR_OUTOFVIDEOMEMORY:
-        error = "OUTOFVIDEOMEMORY";
-        break;
-    case D3DERR_INVALIDDEVICE:
-        error = "INVALIDDEVICE";
-        break;
-    case D3DERR_INVALIDCALL:
-        error = "INVALIDCALL";
-        break;
-    case D3DERR_DRIVERINVALIDCALL:
-        error = "DRIVERINVALIDCALL";
-        break;
-    case D3DERR_WASSTILLDRAWING:
-        error = "WASSTILLDRAWING";
-        break;
-    default:
-        error = "UNKNOWN";
-        break;
-    }
-    SDL_SetError("%s: %s", prefix, error);
-}
-
-static D3DFORMAT
-PixelFormatToD3DFMT(Uint32 format)
-{
-    switch (format) {
-    case SDL_PIXELFORMAT_INDEX8:
-        return D3DFMT_P8;
-    case SDL_PIXELFORMAT_RGB332:
-        return D3DFMT_R3G3B2;
-    case SDL_PIXELFORMAT_RGB444:
-        return D3DFMT_X4R4G4B4;
-    case SDL_PIXELFORMAT_RGB555:
-        return D3DFMT_X1R5G5B5;
-    case SDL_PIXELFORMAT_ARGB4444:
-        return D3DFMT_A4R4G4B4;
-    case SDL_PIXELFORMAT_ARGB1555:
-        return D3DFMT_A1R5G5B5;
-    case SDL_PIXELFORMAT_RGB565:
-        return D3DFMT_R5G6B5;
-    case SDL_PIXELFORMAT_RGB888:
-        return D3DFMT_X8R8G8B8;
-    case SDL_PIXELFORMAT_ARGB8888:
-        return D3DFMT_A8R8G8B8;
-    case SDL_PIXELFORMAT_ARGB2101010:
-        return D3DFMT_A2R10G10B10;
-    case SDL_PIXELFORMAT_YV12:
-        return MAKEFOURCC('Y','V','1','2');
-    case SDL_PIXELFORMAT_IYUV:
-        return MAKEFOURCC('I','4','2','0');
-    case SDL_PIXELFORMAT_UYVY:
-        return D3DFMT_UYVY;
-    case SDL_PIXELFORMAT_YUY2:
-        return D3DFMT_YUY2;
-    default:
-        return D3DFMT_UNKNOWN;
-    }
-}
-
-static UINT D3D_FindAdapter(IDirect3D9 * d3d, SDL_VideoDisplay * display)
-{
-    SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
-    UINT adapter, count;
-
-    count = IDirect3D9_GetAdapterCount(d3d);
-    for (adapter = 0; adapter < count; ++adapter) {
-        HRESULT result;
-        D3DADAPTER_IDENTIFIER9 info;
-        char *name;
-
-        result = IDirect3D9_GetAdapterIdentifier(d3d, adapter, 0, &info);
-        if (FAILED(result)) {
-            continue;
-        }
-        name = WIN_StringToUTF8(displaydata->DeviceName);
-        if (SDL_strcmp(name, info.DeviceName) == 0) {
-            SDL_free(name);
-            return adapter;
-        }
-        SDL_free(name);
-    }
-
-    /* This should never happen, but just in case... */
-    return D3DADAPTER_DEFAULT;
-}
-
-static SDL_bool
-D3D_IsTextureFormatAvailable(IDirect3D9 * d3d, UINT adapter,
-                             Uint32 display_format,
-                             Uint32 texture_format)
-{
-    HRESULT result;
-
-    result = IDirect3D9_CheckDeviceFormat(d3d, adapter,
-                                          D3DDEVTYPE_HAL,
-                                          PixelFormatToD3DFMT(display_format),
-                                          0,
-                                          D3DRTYPE_TEXTURE,
-                                          PixelFormatToD3DFMT
-                                          (texture_format));
-    return FAILED(result) ? SDL_FALSE : SDL_TRUE;
-}
-
-static void
-UpdateYUVTextureData(SDL_Texture * texture)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-    SDL_Rect rect;
-    RECT d3drect;
-    D3DLOCKED_RECT locked;
-    HRESULT result;
-
-    d3drect.left = 0;
-    d3drect.right = texture->w;
-    d3drect.top = 0;
-    d3drect.bottom = texture->h;
-
-    result =
-        IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
-    if (FAILED(result)) {
-        return;
-    }
-
-    rect.x = 0;
-    rect.y = 0;
-    rect.w = texture->w;
-    rect.h = texture->h;
-    SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w,
-                        texture->h, locked.pBits, locked.Pitch);
-
-    IDirect3DTexture9_UnlockRect(data->texture, 0);
-}
-
-void
-D3D_AddRenderDriver(_THIS)
-{
-    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    SDL_RendererInfo *info = &D3D_RenderDriver.info;
-
-    if (data->d3d) {
-        int i, j;
-        int formats[] = {
-            SDL_PIXELFORMAT_INDEX8,
-            SDL_PIXELFORMAT_RGB332,
-            SDL_PIXELFORMAT_RGB444,
-            SDL_PIXELFORMAT_RGB555,
-            SDL_PIXELFORMAT_ARGB4444,
-            SDL_PIXELFORMAT_ARGB1555,
-            SDL_PIXELFORMAT_RGB565,
-            SDL_PIXELFORMAT_RGB888,
-            SDL_PIXELFORMAT_ARGB8888,
-            SDL_PIXELFORMAT_ARGB2101010,
-        };
-
-        for (i = 0; i < _this->num_displays; ++i) {
-            SDL_VideoDisplay *display = &_this->displays[i];
-            SDL_DisplayMode *mode = &display->desktop_mode;
-            UINT adapter = D3D_FindAdapter(data->d3d, display);
-
-            /* Get the matching D3D adapter for this display */
-            info->num_texture_formats = 0;
-            for (j = 0; j < SDL_arraysize(formats); ++j) {
-                if (D3D_IsTextureFormatAvailable
-                    (data->d3d, adapter, mode->format, formats[j])) {
-                    info->texture_formats[info->num_texture_formats++] =
-                        formats[j];
-                }
-            }
-            info->texture_formats[info->num_texture_formats++] =
-                SDL_PIXELFORMAT_YV12;
-            info->texture_formats[info->num_texture_formats++] =
-                SDL_PIXELFORMAT_IYUV;
-            info->texture_formats[info->num_texture_formats++] =
-                SDL_PIXELFORMAT_YUY2;
-            info->texture_formats[info->num_texture_formats++] =
-                SDL_PIXELFORMAT_UYVY;
-            info->texture_formats[info->num_texture_formats++] =
-                SDL_PIXELFORMAT_YVYU;
-
-            SDL_AddRenderDriver(display, &D3D_RenderDriver);
-        }
-    }
-}
-
-SDL_Renderer *
-D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_VideoDisplay *display = window->display;
-    SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata;
-    SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
-    SDL_Renderer *renderer;
-    D3D_RenderData *data;
-    HRESULT result;
-    D3DPRESENT_PARAMETERS pparams;
-    IDirect3DSwapChain9 *chain;
-    D3DCAPS9 caps;
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        D3D_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-    data->d3d = videodata->d3d;
-
-    videodata->render = RENDER_D3D;
-
-    renderer->DisplayModeChanged = D3D_DisplayModeChanged;
-    renderer->CreateTexture = D3D_CreateTexture;
-    renderer->QueryTexturePixels = D3D_QueryTexturePixels;
-    renderer->SetTexturePalette = D3D_SetTexturePalette;
-    renderer->GetTexturePalette = D3D_GetTexturePalette;
-    renderer->SetTextureColorMod = D3D_SetTextureColorMod;
-    renderer->SetTextureAlphaMod = D3D_SetTextureAlphaMod;
-    renderer->SetTextureBlendMode = D3D_SetTextureBlendMode;
-    renderer->SetTextureScaleMode = D3D_SetTextureScaleMode;
-    renderer->UpdateTexture = D3D_UpdateTexture;
-    renderer->LockTexture = D3D_LockTexture;
-    renderer->UnlockTexture = D3D_UnlockTexture;
-    renderer->DirtyTexture = D3D_DirtyTexture;
-    renderer->RenderDrawPoints = D3D_RenderDrawPoints;
-    renderer->RenderDrawLines = D3D_RenderDrawLines;
-    renderer->RenderDrawRects = D3D_RenderDrawRects;
-    renderer->RenderFillRects = D3D_RenderFillRects;
-    renderer->RenderCopy = D3D_RenderCopy;
-    renderer->RenderReadPixels = D3D_RenderReadPixels;
-    renderer->RenderWritePixels = D3D_RenderWritePixels;
-    renderer->RenderPresent = D3D_RenderPresent;
-    renderer->DestroyTexture = D3D_DestroyTexture;
-    renderer->DestroyRenderer = D3D_DestroyRenderer;
-    renderer->info = D3D_RenderDriver.info;
-    renderer->window = window;
-    renderer->driverdata = data;
-
-    renderer->info.flags = SDL_RENDERER_ACCELERATED;
-
-    SDL_zero(pparams);
-    pparams.BackBufferWidth = window->w;
-    pparams.BackBufferHeight = window->h;
-    if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        pparams.BackBufferFormat =
-            PixelFormatToD3DFMT(window->fullscreen_mode.format);
-    } else {
-        pparams.BackBufferFormat = D3DFMT_UNKNOWN;
-    }
-    if (flags & SDL_RENDERER_PRESENTFLIP2) {
-        pparams.BackBufferCount = 2;
-        pparams.SwapEffect = D3DSWAPEFFECT_FLIP;
-    } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
-        pparams.BackBufferCount = 3;
-        pparams.SwapEffect = D3DSWAPEFFECT_FLIP;
-    } else if (flags & SDL_RENDERER_PRESENTCOPY) {
-        pparams.BackBufferCount = 1;
-        pparams.SwapEffect = D3DSWAPEFFECT_COPY;
-    } else {
-        pparams.BackBufferCount = 1;
-        pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
-    }
-    if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        pparams.Windowed = FALSE;
-        pparams.FullScreen_RefreshRateInHz =
-            window->fullscreen_mode.refresh_rate;
-    } else {
-        pparams.Windowed = TRUE;
-        pparams.FullScreen_RefreshRateInHz = 0;
-    }
-    if (flags & SDL_RENDERER_PRESENTVSYNC) {
-        pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
-    } else {
-        pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
-    }
-
-    data->adapter = D3D_FindAdapter(videodata->d3d, display);
-    IDirect3D9_GetDeviceCaps(videodata->d3d, data->adapter,
-                             D3DDEVTYPE_HAL, &caps);
-
-    result = IDirect3D9_CreateDevice(videodata->d3d, data->adapter,
-                                     D3DDEVTYPE_HAL,
-                                     windowdata->hwnd,
-                                     (caps.
-                                      DevCaps &
-                                      D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
-                                     D3DCREATE_HARDWARE_VERTEXPROCESSING :
-                                     D3DCREATE_SOFTWARE_VERTEXPROCESSING,
-                                     &pparams, &data->device);
-    if (FAILED(result)) {
-        D3D_DestroyRenderer(renderer);
-        D3D_SetError("CreateDevice()", result);
-        return NULL;
-    }
-    data->beginScene = SDL_TRUE;
-
-    /* Get presentation parameters to fill info */
-    result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
-    if (FAILED(result)) {
-        D3D_DestroyRenderer(renderer);
-        D3D_SetError("GetSwapChain()", result);
-        return NULL;
-    }
-    result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams);
-    if (FAILED(result)) {
-        IDirect3DSwapChain9_Release(chain);
-        D3D_DestroyRenderer(renderer);
-        D3D_SetError("GetPresentParameters()", result);
-        return NULL;
-    }
-    IDirect3DSwapChain9_Release(chain);
-    switch (pparams.SwapEffect) {
-    case D3DSWAPEFFECT_COPY:
-        renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
-        break;
-    case D3DSWAPEFFECT_FLIP:
-        switch (pparams.BackBufferCount) {
-        case 2:
-            renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
-            break;
-        case 3:
-            renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
-            break;
-        }
-        break;
-    case D3DSWAPEFFECT_DISCARD:
-        renderer->info.flags |= SDL_RENDERER_PRESENTDISCARD;
-        break;
-    }
-    if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
-    }
-    data->pparams = pparams;
-
-    IDirect3DDevice9_GetDeviceCaps(data->device, &caps);
-    renderer->info.max_texture_width = caps.MaxTextureWidth;
-    renderer->info.max_texture_height = caps.MaxTextureHeight;
-
-    /* Set up parameters for rendering */
-    IDirect3DDevice9_SetVertexShader(data->device, NULL);
-    IDirect3DDevice9_SetFVF(data->device,
-                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_ZENABLE, D3DZB_FALSE);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
-                                    D3DCULL_NONE);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
-    /* Enable color modulation by diffuse color */
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLOROP,
-                                          D3DTOP_MODULATE);
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG1,
-                                          D3DTA_TEXTURE);
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG2,
-                                          D3DTA_DIFFUSE);
-    /* Enable alpha modulation by diffuse alpha */
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAOP,
-                                          D3DTOP_MODULATE);
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG1,
-                                          D3DTA_TEXTURE);
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG2,
-                                          D3DTA_DIFFUSE);
-    /* Disable second texture stage, since we're done */
-    IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP,
-                                          D3DTOP_DISABLE);
-    IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP,
-                                          D3DTOP_DISABLE);
-
-    {
-#ifdef ASSEMBLE_SHADER
-        const char *shader_text =
-"ps_1_1\n"
-"def c0, 0, 0, 0, 0.496\n"
-"def c1, 0, 0, 0, 1\n"
-"def c2, 0, 0, 0, -1\n"
-"tex t0\n"
-"mul r1, t0, v0\n"
-"add r0, r1, c0\n"
-"cnd r0, r0.a, c1, c2\n"
-"add r0, r0, r1\n";
-        LPD3DXBUFFER pCode;         // buffer with the assembled shader code
-        LPD3DXBUFFER pErrorMsgs;    // buffer with error messages
-        LPDWORD shader_data;
-        DWORD   shader_size;
-        result = D3DXAssembleShader( shader_text, SDL_strlen(shader_text), NULL, NULL, 0, &pCode, &pErrorMsgs );
-        if (FAILED(result)) {
-            D3D_SetError("D3DXAssembleShader()", result);
-        }
-        shader_data = (DWORD*)pCode->lpVtbl->GetBufferPointer(pCode);
-        shader_size = pCode->lpVtbl->GetBufferSize(pCode);
-#else
-        const DWORD shader_data[] = {
-            0xffff0101,0x00000051,0xa00f0000,0x00000000,0x00000000,0x00000000,
-            0x3efdf3b6,0x00000051,0xa00f0001,0x00000000,0x00000000,0x00000000,
-            0x3f800000,0x00000051,0xa00f0002,0x00000000,0x00000000,0x00000000,
-            0xbf800000,0x00000042,0xb00f0000,0x00000005,0x800f0001,0xb0e40000,
-            0x90e40000,0x00000002,0x800f0000,0x80e40001,0xa0e40000,0x00000050,
-            0x800f0000,0x80ff0000,0xa0e40001,0xa0e40002,0x00000002,0x800f0000,
-            0x80e40000,0x80e40001,0x0000ffff
-        };
-#endif
-        result = IDirect3DDevice9_CreatePixelShader(data->device, shader_data, &data->ps_mask);
-        if (FAILED(result)) {
-            D3D_SetError("CreatePixelShader()", result);
-        }
-    }
-
-    return renderer;
-}
-
-static int
-D3D_Reset(SDL_Renderer * renderer)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    HRESULT result;
-
-    result = IDirect3DDevice9_Reset(data->device, &data->pparams);
-    if (FAILED(result)) {
-        if (result == D3DERR_DEVICELOST) {
-            /* Don't worry about it, we'll reset later... */
-            return 0;
-        } else {
-            D3D_SetError("Reset()", result);
-            return -1;
-        }
-    }
-    IDirect3DDevice9_SetVertexShader(data->device, NULL);
-    IDirect3DDevice9_SetFVF(data->device,
-                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
-                                    D3DCULL_NONE);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
-    return 0;
-}
-
-static int
-D3D_DisplayModeChanged(SDL_Renderer * renderer)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-
-    data->pparams.BackBufferWidth = window->w;
-    data->pparams.BackBufferHeight = window->h;
-    if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        data->pparams.BackBufferFormat =
-            PixelFormatToD3DFMT(window->fullscreen_mode.format);
-    } else {
-        data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
-    }
-    return D3D_Reset(renderer);
-}
-
-static int
-D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    Uint32 display_format = display->current_mode.format;
-    D3D_TextureData *data;
-    HRESULT result;
-
-    data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    texture->driverdata = data;
-
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format) &&
-        (texture->format != SDL_PIXELFORMAT_YUY2 ||
-         !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter,
-                                       display_format, texture->format))
-        && (texture->format != SDL_PIXELFORMAT_YVYU
-            || !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter,
-                                             display_format, texture->format))) {
-        data->yuv =
-            SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
-        if (!data->yuv) {
-            return -1;
-        }
-        data->format = display->current_mode.format;
-    } else {
-        data->format = texture->format;
-    }
-
-    result =
-        IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
-                                       texture->h, 1, 0,
-                                       PixelFormatToD3DFMT(data->format),
-                                       D3DPOOL_SDL, &data->texture, NULL);
-    if (FAILED(result)) {
-        D3D_SetError("CreateTexture()", result);
-        return -1;
-    }
-
-    return 0;
-}
-
-static int
-D3D_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                       void **pixels, int *pitch)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
-    } else {
-        /* D3D textures don't have their pixels hanging out */
-        return -1;
-    }
-}
-
-static int
-D3D_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                      const SDL_Color * colors, int firstcolor, int ncolors)
-{
-    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-
-    return 0;
-}
-
-static int
-D3D_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                      SDL_Color * colors, int firstcolor, int ncolors)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-
-    return 0;
-}
-
-static int
-D3D_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    return 0;
-}
-
-static int
-D3D_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    return 0;
-}
-
-static int
-D3D_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    switch (texture->blendMode) {
-    case SDL_BLENDMODE_NONE:
-    case SDL_BLENDMODE_MASK:
-    case SDL_BLENDMODE_BLEND:
-    case SDL_BLENDMODE_ADD:
-    case SDL_BLENDMODE_MOD:
-        return 0;
-    default:
-        SDL_Unsupported();
-        texture->blendMode = SDL_BLENDMODE_NONE;
-        return -1;
-    }
-}
-
-static int
-D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    switch (texture->scaleMode) {
-    case SDL_SCALEMODE_NONE:
-    case SDL_SCALEMODE_FAST:
-    case SDL_SCALEMODE_SLOW:
-    case SDL_SCALEMODE_BEST:
-        return 0;
-    default:
-        SDL_Unsupported();
-        texture->scaleMode = SDL_SCALEMODE_NONE;
-        return -1;
-    }
-    return 0;
-}
-
-static int
-D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                  const SDL_Rect * rect, const void *pixels, int pitch)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
-
-    if (data->yuv) {
-        if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
-            return -1;
-        }
-        UpdateYUVTextureData(texture);
-        return 0;
-    } else {
-#ifdef SDL_MEMORY_POOL_DEFAULT
-        IDirect3DTexture9 *temp;
-        RECT d3drect;
-        D3DLOCKED_RECT locked;
-        const Uint8 *src;
-        Uint8 *dst;
-        int row, length;
-        HRESULT result;
-
-        result =
-            IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
-                                           texture->h, 1, 0,
-                                           PixelFormatToD3DFMT(texture->
-                                                               format),
-                                           D3DPOOL_SYSTEMMEM, &temp, NULL);
-        if (FAILED(result)) {
-            D3D_SetError("CreateTexture()", result);
-            return -1;
-        }
-
-        d3drect.left = rect->x;
-        d3drect.right = rect->x + rect->w;
-        d3drect.top = rect->y;
-        d3drect.bottom = rect->y + rect->h;
-
-        result = IDirect3DTexture9_LockRect(temp, 0, &locked, &d3drect, 0);
-        if (FAILED(result)) {
-            IDirect3DTexture9_Release(temp);
-            D3D_SetError("LockRect()", result);
-            return -1;
-        }
-
-        src = pixels;
-        dst = locked.pBits;
-        length = rect->w * SDL_BYTESPERPIXEL(texture->format);
-        for (row = 0; row < rect->h; ++row) {
-            SDL_memcpy(dst, src, length);
-            src += pitch;
-            dst += locked.Pitch;
-        }
-        IDirect3DTexture9_UnlockRect(temp, 0);
-
-        result =
-            IDirect3DDevice9_UpdateTexture(renderdata->device,
-                                           (IDirect3DBaseTexture9 *) temp,
-                                           (IDirect3DBaseTexture9 *)
-                                           data->texture);
-        IDirect3DTexture9_Release(temp);
-        if (FAILED(result)) {
-            D3D_SetError("UpdateTexture()", result);
-            return -1;
-        }
-#else
-        RECT d3drect;
-        D3DLOCKED_RECT locked;
-        const Uint8 *src;
-        Uint8 *dst;
-        int row, length;
-        HRESULT result;
-
-        d3drect.left = rect->x;
-        d3drect.right = rect->x + rect->w;
-        d3drect.top = rect->y;
-        d3drect.bottom = rect->y + rect->h;
-
-        result =
-            IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
-                                       0);
-        if (FAILED(result)) {
-            D3D_SetError("LockRect()", result);
-            return -1;
-        }
-
-        src = pixels;
-        dst = locked.pBits;
-        length = rect->w * SDL_BYTESPERPIXEL(texture->format);
-        for (row = 0; row < rect->h; ++row) {
-            SDL_memcpy(dst, src, length);
-            src += pitch;
-            dst += locked.Pitch;
-        }
-        IDirect3DTexture9_UnlockRect(data->texture, 0);
-#endif // SDL_MEMORY_POOL_DEFAULT
-
-        return 0;
-    }
-}
-
-static int
-D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                const SDL_Rect * rect, int markDirty, void **pixels,
-                int *pitch)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
-                                     pitch);
-    } else {
-        RECT d3drect;
-        D3DLOCKED_RECT locked;
-        HRESULT result;
-
-        d3drect.left = rect->x;
-        d3drect.right = rect->x + rect->w;
-        d3drect.top = rect->y;
-        d3drect.bottom = rect->y + rect->h;
-
-        result =
-            IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
-                                       markDirty ? 0 :
-                                       D3DLOCK_NO_DIRTY_UPDATE);
-        if (FAILED(result)) {
-            D3D_SetError("LockRect()", result);
-            return -1;
-        }
-        *pixels = locked.pBits;
-        *pitch = locked.Pitch;
-        return 0;
-    }
-}
-
-static void
-D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        SDL_SW_UnlockYUVTexture(data->yuv);
-        UpdateYUVTextureData(texture);
-    } else {
-        IDirect3DTexture9_UnlockRect(data->texture, 0);
-    }
-}
-
-static void
-D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
-                 const SDL_Rect * rects)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-    RECT d3drect;
-    int i;
-
-    for (i = 0; i < numrects; ++i) {
-        const SDL_Rect *rect = &rects[i];
-
-        d3drect.left = rect->x;
-        d3drect.right = rect->x + rect->w;
-        d3drect.top = rect->y;
-        d3drect.bottom = rect->y + rect->h;
-
-        IDirect3DTexture9_AddDirtyRect(data->texture, &d3drect);
-    }
-}
-
-static void
-D3D_SetBlendMode(D3D_RenderData * data, int blendMode)
-{
-    switch (blendMode) {
-    case SDL_BLENDMODE_NONE:
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
-                                        FALSE);
-        break;
-    case SDL_BLENDMODE_MASK:
-    case SDL_BLENDMODE_BLEND:
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
-                                        TRUE);
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
-                                        D3DBLEND_SRCALPHA);
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
-                                        D3DBLEND_INVSRCALPHA);
-        break;
-    case SDL_BLENDMODE_ADD:
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
-                                        TRUE);
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
-                                        D3DBLEND_SRCALPHA);
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
-                                        D3DBLEND_ONE);
-        break;
-    case SDL_BLENDMODE_MOD:
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
-                                        TRUE);
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
-                                        D3DBLEND_ZERO);
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
-                                        D3DBLEND_SRCCOLOR);
-        break;
-    }
-}
-
-static int
-D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
-                     int count)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    DWORD color;
-    Vertex *vertices;
-    int i;
-    HRESULT result;
-
-    if (data->beginScene) {
-        IDirect3DDevice9_BeginScene(data->device);
-        data->beginScene = SDL_FALSE;
-    }
-
-    D3D_SetBlendMode(data, renderer->blendMode);
-
-    result =
-        IDirect3DDevice9_SetTexture(data->device, 0,
-                                    (IDirect3DBaseTexture9 *) 0);
-    if (FAILED(result)) {
-        D3D_SetError("SetTexture()", result);
-        return -1;
-    }
-
-    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
-
-    vertices = SDL_stack_alloc(Vertex, count);
-    for (i = 0; i < count; ++i) {
-        vertices[i].x = (float) points[i].x;
-        vertices[i].y = (float) points[i].y;
-        vertices[i].z = 0.0f;
-        vertices[i].rhw = 1.0f;
-        vertices[i].color = color;
-        vertices[i].u = 0.0f;
-        vertices[i].v = 0.0f;
-    }
-    result =
-        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, count,
-                                         vertices, sizeof(*vertices));
-    SDL_stack_free(vertices);
-    if (FAILED(result)) {
-        D3D_SetError("DrawPrimitiveUP()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
-                    int count)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    DWORD color;
-    Vertex *vertices;
-    int i;
-    HRESULT result;
-
-    if (data->beginScene) {
-        IDirect3DDevice9_BeginScene(data->device);
-        data->beginScene = SDL_FALSE;
-    }
-
-    D3D_SetBlendMode(data, renderer->blendMode);
-
-    result =
-        IDirect3DDevice9_SetTexture(data->device, 0,
-                                    (IDirect3DBaseTexture9 *) 0);
-    if (FAILED(result)) {
-        D3D_SetError("SetTexture()", result);
-        return -1;
-    }
-
-    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
-
-    vertices = SDL_stack_alloc(Vertex, count);
-    for (i = 0; i < count; ++i) {
-        vertices[i].x = (float) points[i].x;
-        vertices[i].y = (float) points[i].y;
-        vertices[i].z = 0.0f;
-        vertices[i].rhw = 1.0f;
-        vertices[i].color = color;
-        vertices[i].u = 0.0f;
-        vertices[i].v = 0.0f;
-    }
-    result =
-        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count-1,
-                                         vertices, sizeof(*vertices));
-
-    /* DirectX 9 has the same line rasterization semantics as GDI,
-       so we need to close the endpoint of the line */
-    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
-        vertices[0].x = (float) points[count-1].x;
-        vertices[0].y = (float) points[count-1].y;
-        result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices));
-    }
-
-    SDL_stack_free(vertices);
-    if (FAILED(result)) {
-        D3D_SetError("DrawPrimitiveUP()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-D3D_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                    int count)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    DWORD color;
-    int i;
-    Vertex vertices[5];
-    HRESULT result;
-
-    if (data->beginScene) {
-        IDirect3DDevice9_BeginScene(data->device);
-        data->beginScene = SDL_FALSE;
-    }
-
-    D3D_SetBlendMode(data, renderer->blendMode);
-
-    result =
-        IDirect3DDevice9_SetTexture(data->device, 0,
-                                    (IDirect3DBaseTexture9 *) 0);
-    if (FAILED(result)) {
-        D3D_SetError("SetTexture()", result);
-        return -1;
-    }
-
-    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
-
-    for (i = 0; i < SDL_arraysize(vertices); ++i) {
-        vertices[i].z = 0.0f;
-        vertices[i].rhw = 1.0f;
-        vertices[i].color = color;
-        vertices[i].u = 0.0f;
-        vertices[i].v = 0.0f;
-    }
-
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect *rect = rects[i];
-
-        vertices[0].x = (float) rect->x;
-        vertices[0].y = (float) rect->y;
-
-        vertices[1].x = (float) rect->x+rect->w-1;
-        vertices[1].y = (float) rect->y;
-
-        vertices[2].x = (float) rect->x+rect->w-1;
-        vertices[2].y = (float) rect->y+rect->h-1;
-
-        vertices[3].x = (float) rect->x;
-        vertices[3].y = (float) rect->y+rect->h-1;
-
-        vertices[4].x = (float) rect->x;
-        vertices[4].y = (float) rect->y;
-
-        result =
-            IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, 4,
-                                             vertices, sizeof(*vertices));
-
-        if (FAILED(result)) {
-            D3D_SetError("DrawPrimitiveUP()", result);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-static int
-D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                    int count)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    DWORD color;
-    int i;
-    float minx, miny, maxx, maxy;
-    Vertex vertices[4];
-    HRESULT result;
-
-    if (data->beginScene) {
-        IDirect3DDevice9_BeginScene(data->device);
-        data->beginScene = SDL_FALSE;
-    }
-
-    D3D_SetBlendMode(data, renderer->blendMode);
-
-    result =
-        IDirect3DDevice9_SetTexture(data->device, 0,
-                                    (IDirect3DBaseTexture9 *) 0);
-    if (FAILED(result)) {
-        D3D_SetError("SetTexture()", result);
-        return -1;
-    }
-
-    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
-
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect *rect = rects[i];
-
-        minx = (float) rect->x;
-        miny = (float) rect->y;
-        maxx = (float) rect->x + rect->w;
-        maxy = (float) rect->y + rect->h;
-
-        vertices[0].x = minx;
-        vertices[0].y = miny;
-        vertices[0].z = 0.0f;
-        vertices[0].rhw = 1.0f;
-        vertices[0].color = color;
-        vertices[0].u = 0.0f;
-        vertices[0].v = 0.0f;
-
-        vertices[1].x = maxx;
-        vertices[1].y = miny;
-        vertices[1].z = 0.0f;
-        vertices[1].rhw = 1.0f;
-        vertices[1].color = color;
-        vertices[1].u = 0.0f;
-        vertices[1].v = 0.0f;
-
-        vertices[2].x = maxx;
-        vertices[2].y = maxy;
-        vertices[2].z = 0.0f;
-        vertices[2].rhw = 1.0f;
-        vertices[2].color = color;
-        vertices[2].u = 0.0f;
-        vertices[2].v = 0.0f;
-
-        vertices[3].x = minx;
-        vertices[3].y = maxy;
-        vertices[3].z = 0.0f;
-        vertices[3].rhw = 1.0f;
-        vertices[3].color = color;
-        vertices[3].u = 0.0f;
-        vertices[3].v = 0.0f;
-
-        result =
-            IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN,
-                                             2, vertices, sizeof(*vertices));
-        if (FAILED(result)) {
-            D3D_SetError("DrawPrimitiveUP()", result);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-static int
-D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
-    LPDIRECT3DPIXELSHADER9 shader = NULL;
-    float minx, miny, maxx, maxy;
-    float minu, maxu, minv, maxv;
-    DWORD color;
-    Vertex vertices[4];
-    HRESULT result;
-
-    if (data->beginScene) {
-        IDirect3DDevice9_BeginScene(data->device);
-        data->beginScene = SDL_FALSE;
-    }
-
-    minx = (float) dstrect->x - 0.5f;
-    miny = (float) dstrect->y - 0.5f;
-    maxx = (float) dstrect->x + dstrect->w - 0.5f;
-    maxy = (float) dstrect->y + dstrect->h - 0.5f;
-
-    minu = (float) srcrect->x / texture->w;
-    maxu = (float) (srcrect->x + srcrect->w) / texture->w;
-    minv = (float) srcrect->y / texture->h;
-    maxv = (float) (srcrect->y + srcrect->h) / texture->h;
-
-    color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b);
-
-    vertices[0].x = minx;
-    vertices[0].y = miny;
-    vertices[0].z = 0.0f;
-    vertices[0].rhw = 1.0f;
-    vertices[0].color = color;
-    vertices[0].u = minu;
-    vertices[0].v = minv;
-
-    vertices[1].x = maxx;
-    vertices[1].y = miny;
-    vertices[1].z = 0.0f;
-    vertices[1].rhw = 1.0f;
-    vertices[1].color = color;
-    vertices[1].u = maxu;
-    vertices[1].v = minv;
-
-    vertices[2].x = maxx;
-    vertices[2].y = maxy;
-    vertices[2].z = 0.0f;
-    vertices[2].rhw = 1.0f;
-    vertices[2].color = color;
-    vertices[2].u = maxu;
-    vertices[2].v = maxv;
-
-    vertices[3].x = minx;
-    vertices[3].y = maxy;
-    vertices[3].z = 0.0f;
-    vertices[3].rhw = 1.0f;
-    vertices[3].color = color;
-    vertices[3].u = minu;
-    vertices[3].v = maxv;
-
-    D3D_SetBlendMode(data, texture->blendMode);
-
-    if (texture->blendMode == SDL_BLENDMODE_MASK) {
-        shader = data->ps_mask;
-    }
-
-    switch (texture->scaleMode) {
-    case SDL_SCALEMODE_NONE:
-    case SDL_SCALEMODE_FAST:
-        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
-                                         D3DTEXF_POINT);
-        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
-                                         D3DTEXF_POINT);
-        break;
-    case SDL_SCALEMODE_SLOW:
-        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
-                                         D3DTEXF_LINEAR);
-        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
-                                         D3DTEXF_LINEAR);
-        break;
-    case SDL_SCALEMODE_BEST:
-        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
-                                         D3DTEXF_GAUSSIANQUAD);
-        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
-                                         D3DTEXF_GAUSSIANQUAD);
-        break;
-    }
-
-    result =
-        IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *)
-                                    texturedata->texture);
-    if (FAILED(result)) {
-        D3D_SetError("SetTexture()", result);
-        return -1;
-    }
-    if (shader) {
-        result = IDirect3DDevice9_SetPixelShader(data->device, shader);
-        if (FAILED(result)) {
-            D3D_SetError("SetShader()", result);
-            return -1;
-        }
-    }
-    result =
-        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
-                                         vertices, sizeof(*vertices));
-    if (FAILED(result)) {
-        D3D_SetError("DrawPrimitiveUP()", result);
-        return -1;
-    }
-    if (shader) {
-        result = IDirect3DDevice9_SetPixelShader(data->device, NULL);
-        if (FAILED(result)) {
-            D3D_SetError("SetShader()", result);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-static int
-D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                     Uint32 format, void * pixels, int pitch)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    D3DSURFACE_DESC desc;
-    LPDIRECT3DSURFACE9 backBuffer;
-    LPDIRECT3DSURFACE9 surface;
-    RECT d3drect;
-    D3DLOCKED_RECT locked;
-    HRESULT result;
-
-    result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
-    if (FAILED(result)) {
-        D3D_SetError("GetBackBuffer()", result);
-        return -1;
-    }
-
-    result = IDirect3DSurface9_GetDesc(backBuffer, &desc);
-    if (FAILED(result)) {
-        D3D_SetError("GetDesc()", result);
-        IDirect3DSurface9_Release(backBuffer);
-        return -1;
-    }
-
-    result = IDirect3DDevice9_CreateOffscreenPlainSurface(data->device, desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL);
-    if (FAILED(result)) {
-        D3D_SetError("CreateOffscreenPlainSurface()", result);
-        IDirect3DSurface9_Release(backBuffer);
-        return -1;
-    }
-
-    result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface);
-    if (FAILED(result)) {
-        D3D_SetError("GetRenderTargetData()", result);
-        IDirect3DSurface9_Release(surface);
-        IDirect3DSurface9_Release(backBuffer);
-        return -1;
-    }
-
-    d3drect.left = rect->x;
-    d3drect.right = rect->x + rect->w;
-    d3drect.top = rect->y;
-    d3drect.bottom = rect->y + rect->h;
-
-    result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
-    if (FAILED(result)) {
-        D3D_SetError("LockRect()", result);
-        IDirect3DSurface9_Release(surface);
-        IDirect3DSurface9_Release(backBuffer);
-        return -1;
-    }
-
-    SDL_ConvertPixels(rect->w, rect->h,
-                      display->current_mode.format, locked.pBits, locked.Pitch,
-                      format, pixels, pitch);
-
-    IDirect3DSurface9_UnlockRect(surface);
-
-    IDirect3DSurface9_Release(surface);
-    IDirect3DSurface9_Release(backBuffer);
-
-    return 0;
-}
-
-static int
-D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                      Uint32 format, const void * pixels, int pitch)
-{
-    /* Work in progress */
-    SDL_Unsupported();
-    return -1;
-}
-
-static void
-D3D_RenderPresent(SDL_Renderer * renderer)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    HRESULT result;
-
-    if (!data->beginScene) {
-        IDirect3DDevice9_EndScene(data->device);
-        data->beginScene = SDL_TRUE;
-    }
-
-    result = IDirect3DDevice9_TestCooperativeLevel(data->device);
-    if (result == D3DERR_DEVICELOST) {
-        /* We'll reset later */
-        return;
-    }
-    if (result == D3DERR_DEVICENOTRESET) {
-        D3D_Reset(renderer);
-    }
-    result = IDirect3DDevice9_Present(data->device, NULL, NULL, NULL, NULL);
-    if (FAILED(result)) {
-        D3D_SetError("Present()", result);
-    }
-}
-
-static void
-D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-
-    if (!data) {
-        return;
-    }
-    if (data->yuv) {
-        SDL_SW_DestroyYUVTexture(data->yuv);
-    }
-    if (data->texture) {
-        IDirect3DTexture9_Release(data->texture);
-    }
-    SDL_free(data);
-    texture->driverdata = NULL;
-}
-
-static void
-D3D_DestroyRenderer(SDL_Renderer * renderer)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-
-    if (data) {
-        if (data->device) {
-            IDirect3DDevice9_Release(data->device);
-        }
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-#endif /* SDL_VIDEO_RENDER_D3D */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_d3drender.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_D3D
-extern void D3D_AddRenderDriver(_THIS);
-#endif
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_gapirender.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1295 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2010 by Andrey Afletdinov <afletdinov@gmail.com>        *
- *                                                                         *
- *   WinCE RAW/GAPI video driver                                           *
- *                                                                         *
- *   Part of the SDL - (Simple DirectMedia Layer)                          *
- *   http://www.libsdl.org                                                 *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_GAPI
-
-#include "SDL_windowsvideo.h"
-#include "SDL_windowswindow.h"
-#include "../SDL_yuv_sw_c.h"
-
-// RawFrameBufferInfo
-typedef struct
-{
-   WORD wFormat;
-   WORD wBPP;
-   VOID *pFramePointer;
-   int  cxStride;
-   int  cyStride;
-   int  cxPixels;
-   int  cyPixels;
-} RawFrameBufferInfo;
-
-// GXDeviceInfo
-typedef struct
-{
-    long Version;
-    void* pvFrameBuffer;
-    unsigned long cbStride;
-    unsigned long cxWidth;
-    unsigned long cyHeight;
-    unsigned long cBPP;
-    unsigned long ffFormat;
-    char unknown[0x84 - 7 * 4];
-} GXDeviceInfo;
-
-// wince: GXDisplayProperties
-struct GXDisplayProperties
-{
-    DWORD cxWidth;
-    DWORD cyHeight;
-    long cbxPitch;
-    long cbyPitch;
-    long cBPP;
-    DWORD ffFormat;
-};
-
-// gx.dll
-typedef int   (*PFNGXOpenDisplay)(HWND hWnd, DWORD dwFlags);
-typedef int   (*PFNGXCloseDisplay)();
-typedef void* (*PFNGXBeginDraw)();
-typedef int   (*PFNGXEndDraw)();
-typedef struct GXDisplayProperties (*PFNGXGetDisplayProperties)();
-typedef int   (*PFNGXSuspend)();
-typedef int   (*PFNGXResume)();
-
-typedef struct
-{
-    // gx.dll
-    void*                     hGapiLib;
-    PFNGXOpenDisplay          GXOpenDisplay;
-    PFNGXCloseDisplay         GXCloseDisplay;
-    PFNGXBeginDraw            GXBeginDraw;
-    PFNGXEndDraw              GXEndDraw;
-    PFNGXGetDisplayProperties GXGetDisplayProperties;
-    PFNGXSuspend              GXSuspend;
-    PFNGXResume               GXResume;
-} GapiInfo;
-
-//#ifndef DM_DISPLAYORIENTATION
-//#define DM_DISPLAYORIENTATION 0x00800000L
-//#endif
-
-#define FORMAT_565                1
-#define FORMAT_555                2
-#define FORMAT_OTHER                3
-
-#define GETRAWFRAMEBUFFER        0x00020001
-#define GETGXINFO                0x00020000
-
-#define kfPalette                0x10
-#define kfDirect                0x20
-#define kfDirect555                0x40
-#define kfDirect565                0x80
-
-#define GX_FULLSCREEN                0x01
-
-enum ScreenOrientation { ORIENTATION_UNKNOWN = -1, ORIENTATION_UP = DMDO_0, ORIENTATION_DOWN = DMDO_180, ORIENTATION_LEFT = DMDO_270, ORIENTATION_RIGHT = DMDO_90 };
-enum ScreenGeometry { GEOMETRY_UNKNOWN, GEOMETRY_PORTRAIT, GEOMETRY_LANDSCAPE, GEOMETRY_SQUARE };
-enum FrameBufferFlags { FB_SKIP_OFFSET = 0x0001, FB_RAW_MODE = 0x0002, FB_SUSPENDED = 0x0004 };
-
-// private framebuffer info
-typedef struct
-{
-    int width;
-    int height;
-    int xpitch;
-    int ypitch;
-    int offset;
-} FrameBufferInfo;
-
-// private display data
-typedef struct
-{
-    unsigned char* pixels;        // video memory
-    int format;                        // video format
-    FrameBufferInfo fb;                // framebuffer geometry
-    GapiInfo* gapi;                // GAPI module
-    int userOrientation;
-    int systemOrientation;
-    int hardwareGeometry;
-    int flags;                        // fb flags
-    float scale;                // scale pointer position
-    int debug;
-
-} WINCE_RenderData;
-
-typedef struct
-{
-    SDL_SW_YUVTexture *yuv;
-    Uint32 format;
-    void *pixels;
-    int pitch;
-
-} WINCE_TextureData;
-
-
-// system func
-SDL_Renderer*        WINCE_CreateRenderer(SDL_Window* window, Uint32 flags);
-void                WINCE_DestroyRenderer(SDL_Renderer* renderer);
-
-int                WINCE_CreateTexture(SDL_Renderer* renderer, SDL_Texture* texture);
-void                WINCE_DestroyTexture(SDL_Renderer* renderer, SDL_Texture* texture);
-int                WINCE_QueryTexturePixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch);
-int                WINCE_UpdateTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch);
-int                WINCE_LockTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int dirty, void** pixels, int* pitch);
-void                WINCE_UnlockTexture(SDL_Renderer* renderer, SDL_Texture* texture);
-
-int                WINCE_Available(void);
-void                WINCE_SetupOrientation(WINCE_RenderData* data, int width, int height);
-
-int                WINCE_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srect, const SDL_Rect* drect);
-void                WINCE_ShowWindow(_THIS, SDL_Window* window, int visible);
-
-void                WINCE_RenderPresent(SDL_Renderer* renderer);
-int                WINCE_RenderDrawPoints(SDL_Renderer* renderer, const SDL_Point* points, int count);
-int                WINCE_RenderDrawLines(SDL_Renderer* renderer, const SDL_Point* points, int count);
-int                WINCE_RenderDrawRects(SDL_Renderer* renderer, const SDL_Rect ** rects, int count);
-int                WINCE_RenderFillRects(SDL_Renderer* renderer, const SDL_Rect** rects, int count);
-
-void                WINCE_PointerCoordinateTransform(SDL_Window* window, POINT* pt);
-void                WINCE_DumpVideoInfo(WINCE_RenderData* data);
-void                WINCE_PortraitTransform(WINCE_RenderData* data, int width, int height);
-void                WINCE_LandscapeTransform(WINCE_RenderData* data, int width, int height);
-void                WINCE_SquareTransform(WINCE_RenderData* data, int width, int height);
-int                WINCE_FixedGeometry(FrameBufferInfo* fb, int bpp, int debug);
-int                WINCE_GetDMOrientation(void);
-int                WINCE_SetDMOrientation(int orientation);
-void                WINCE_UpdateYUVTextureData(SDL_Texture* texture);
-
-// gapi engine specific
-int                GAPI_Init(WINCE_RenderData* data, HWND hwnd);
-void                GAPI_Quit(WINCE_RenderData* data);
-
-// raw engine specific
-int                RAW_Init(WINCE_RenderData* data);
-void                RAW_Quit(WINCE_RenderData* data);
-
-// tools
-void                FrameBufferRotate(FrameBufferInfo* src, int orientation);
-int                GetFrameBufferOrientation(const FrameBufferInfo* src);
-void                PointerRotate(POINT* pt, const FrameBufferInfo* fb, int orientation);
-void                FrameBufferInitialize(FrameBufferInfo* fb);
-void                FrameBufferDumpInfo(const FrameBufferInfo* fb, const char*);
-const                char* GetOrientationName(int orientation);
-void                UpdateLine16to16(const FrameBufferInfo* fb, const Uint16* src, Uint16* dst, Uint16 width);
-
-// stdlib
-static __inline__ int        __abs(int x){ return x < 0 ? -x : x; };
-static __inline__ void        __swap(int* a, int* b){ int t = *a; *a = *b; *b = t; };
-
-#define GAPI_RENDER_NAME        "gapi"
-#define RAW_RENDER_NAME                "raw"
-//
-SDL_RenderDriver GAPI_RenderDriver = {
-    WINCE_CreateRenderer,
-    {
-        GAPI_RENDER_NAME,
-        (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
-        (SDL_TEXTUREMODULATE_NONE),
-        (SDL_BLENDMODE_NONE),
-        (SDL_SCALEMODE_NONE),
-        7,
-        {
-            SDL_PIXELFORMAT_RGB555,
-            SDL_PIXELFORMAT_RGB565,
-            SDL_PIXELFORMAT_YV12,
-            SDL_PIXELFORMAT_IYUV,
-            SDL_PIXELFORMAT_YUY2,
-            SDL_PIXELFORMAT_UYVY,
-            SDL_PIXELFORMAT_YVYU
-        },
-        0,
-        0
-    }
-};
-
-SDL_RenderDriver RAW_RenderDriver = {
-    WINCE_CreateRenderer,
-    {
-        RAW_RENDER_NAME,
-        (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
-        (SDL_TEXTUREMODULATE_NONE),
-        (SDL_BLENDMODE_NONE),
-        (SDL_SCALEMODE_NONE),
-        7,
-        {
-            SDL_PIXELFORMAT_RGB555,
-            SDL_PIXELFORMAT_RGB565,
-            SDL_PIXELFORMAT_YV12,
-            SDL_PIXELFORMAT_IYUV,
-            SDL_PIXELFORMAT_YUY2,
-            SDL_PIXELFORMAT_UYVY,
-            SDL_PIXELFORMAT_YVYU
-        },
-        0,
-        0
-    }
-};
-
-int WINCE_Available(void)
-{
-    void* render_gapi;
-    const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
-
-    // raw check
-    RawFrameBufferInfo rfbi = { 0 };
-    HDC hdc = GetDC(NULL);
-    int render_raw = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi);
-    ReleaseDC(NULL, hdc);
-
-    if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 &&
-       rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0)
-        render_raw = 1;
-
-    if(preferably && 0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0 != render_raw;
-
-    // gapi check
-    render_gapi = SDL_LoadObject("\\Windows\\gx.dll");
-    if(0 == render_gapi)
-        render_gapi = SDL_LoadObject("gx.dll");
-    SDL_UnloadObject(render_gapi);
-
-    if(preferably && 0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0 != render_gapi;
-
-    return 0 != render_raw || 0 != render_gapi;
-}
-
-void WINCE_AddRenderDriver(_THIS)
-{
-    HDC hdc;
-    void* render_gapi;
-    int render_raw, ii;
-    const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
-
-   // raw check
-    RawFrameBufferInfo rfbi = { 0 };
-    hdc = GetDC(NULL);
-    render_raw = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi);
-    ReleaseDC(NULL, hdc);
-
-    if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 &&
-            rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0)
-            render_raw = 1;
-
-    // gapi check
-    render_gapi = SDL_LoadObject("\\Windows\\gx.dll");
-    if(0 == render_gapi)
-        render_gapi = SDL_LoadObject("gx.dll");
-
-    if(render_gapi)
-        SDL_UnloadObject(render_gapi);
-
-    for(ii = 0; ii < _this->num_displays; ++ii)
-    {
-        if(preferably)
-        {
-            if(0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME) && render_raw)
-                SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver);
-            else
-            if(0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME) && render_gapi)
-                SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver);
-        }
-        else
-        {
-            if(render_raw)
-                SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver);
-            if(render_gapi)
-                SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver);
-        }
-    }
-}
-
-SDL_Renderer* WINCE_CreateRenderer(SDL_Window* window, Uint32 flags)
-{
-    SDL_VideoDisplay* display = window->display;
-    SDL_DisplayMode* displayMode = &display->current_mode;
-    SDL_WindowData* windowdata = (SDL_WindowData *) window->driverdata;
-    SDL_Renderer* renderer;
-    WINCE_RenderData* data;
-    int bpp;
-    Uint32 Rmask, Gmask, Bmask, Amask;
-
-    if(!(window->flags & SDL_WINDOW_FULLSCREEN))
-        window->flags |= SDL_WINDOW_FULLSCREEN;
-
-    if(!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask))
-    {
-        SDL_SetError("Unknown display format");
-        return NULL;
-    }
-
-    switch(window->fullscreen_mode.format)
-    {
-        case SDL_PIXELFORMAT_RGB555:
-        case SDL_PIXELFORMAT_RGB565:
-            break;
-
-        default:
-            SDL_SetError("Support only 16 or 15 bpp");
-            return NULL;
-    }
-
-    renderer = (SDL_Renderer*) SDL_calloc(1, sizeof(SDL_Renderer));
-    if(!renderer)
-    {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (WINCE_RenderData*) SDL_calloc(1, sizeof(WINCE_RenderData));
-    if(!data)
-    {
-        WINCE_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    // initialize internal engine
-    if(!RAW_Init(data) && !GAPI_Init(data, windowdata->hwnd))
-    {
-        WINCE_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-
-    // set debug
-    data->debug        = SDL_getenv("DEBUG_VIDEO_GAPI") || SDL_getenv("GAPI_RENDERER_DEBUG") ? 1 : 0;
-#if defined(DEBUG_VIDEO_GAPI) || defined(GAPI_RENDERER_DEBUG)
-    data->debug        = 1;
-#endif
-
-    windowdata->videodata->render = data->gapi ? RENDER_GAPI : RENDER_RAW;
-    windowdata->videodata->CoordTransform = WINCE_PointerCoordinateTransform;
-
-    window->display->device->MaximizeWindow = NULL;
-    window->display->device->MinimizeWindow = NULL;
-
-    WINCE_SetupOrientation(data, window->w, window->h);
-
-    renderer->CreateTexture = WINCE_CreateTexture;
-    renderer->DestroyTexture = WINCE_DestroyTexture;
-    renderer->QueryTexturePixels = WINCE_QueryTexturePixels;
-    renderer->UpdateTexture = WINCE_UpdateTexture;
-    renderer->LockTexture = WINCE_LockTexture;
-    renderer->UnlockTexture = WINCE_UnlockTexture;
-
-    renderer->RenderCopy = WINCE_RenderCopy;
-    renderer->DestroyRenderer = WINCE_DestroyRenderer;
-
-    renderer->RenderPresent = WINCE_RenderPresent;
-    renderer->RenderDrawPoints = WINCE_RenderDrawPoints;
-    renderer->RenderDrawLines = WINCE_RenderDrawLines;
-    renderer->RenderDrawRects = WINCE_RenderDrawRects;
-    renderer->RenderFillRects = WINCE_RenderFillRects;
-
-    renderer->info = data->gapi ? GAPI_RenderDriver.info : RAW_RenderDriver.info;
-
-    renderer->window = window;
-    renderer->driverdata = data;
-
-    return renderer;
-}
-
-void WINCE_DestroyRenderer(SDL_Renderer* renderer)
-{
-    WINCE_RenderData *renderdata = (WINCE_RenderData*) renderer->driverdata;
-
-    if(renderdata)
-    {
-        if(renderdata->gapi)
-            GAPI_Quit(renderdata);
-        else
-            RAW_Quit(renderdata);
-
-        SDL_free(renderdata);
-    }
-
-    SDL_free(renderer);
-}
-
-int WINCE_CreateTexture(SDL_Renderer* renderer, SDL_Texture* texture)
-{
-    WINCE_TextureData* texturedata = (WINCE_TextureData*) SDL_calloc(1, sizeof(WINCE_TextureData));
-    if(NULL == texturedata)
-    {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    texturedata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
-    texturedata->pixels = SDL_malloc(texture->h * texturedata->pitch);
-    if(NULL == texturedata->pixels)
-    {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    if(SDL_ISPIXELFORMAT_FOURCC(texture->format))
-    {
-        SDL_Window* window = renderer->window;
-        SDL_VideoDisplay* display = window->display;
-
-        texturedata->yuv = SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
-        if(NULL == texturedata->yuv)
-        {
-            SDL_OutOfMemory();
-            return -1;
-        }
-        texturedata->format = display->current_mode.format;
-    }
-    else
-    {
-        texturedata->yuv = NULL;
-        texturedata->format = texture->format;
-    }
-
-    texture->driverdata = texturedata;
-
-    return 0;
-}
-
-void WINCE_DestroyTexture(SDL_Renderer* renderer, SDL_Texture* texture)
-{
-    WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata;
-
-    if(texturedata)
-    {
-        if(texturedata->yuv) SDL_SW_DestroyYUVTexture(texturedata->yuv);
-        if(texturedata->pixels) SDL_free(texturedata->pixels);
-        SDL_free(texturedata);
-        texture->driverdata = NULL;
-    }
-}
-
-int WINCE_QueryTexturePixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch)
-{
-    WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata;
-
-    if(texturedata->yuv)
-        return SDL_SW_QueryYUVTexturePixels(texturedata->yuv, pixels, pitch);
-
-    *pixels = texturedata->pixels;
-    *pitch = texturedata->pitch;
-
-    return 0;
-}
-
-int WINCE_UpdateTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch)
-{
-    WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata;
-
-    if(texturedata->yuv)
-    {
-        if(SDL_SW_UpdateYUVTexture(texturedata->yuv, rect, pixels, pitch) < 0)
-            return -1;
-        WINCE_UpdateYUVTextureData(texture);
-        return 0;
-    }
-
-    if(0 < rect->w && 0 < rect->h)
-    {
-        const unsigned char *src = ((const unsigned char*) pixels);
-        unsigned char *dst = ((unsigned char*) texturedata->pixels) +
-                                rect->y * texturedata->pitch +
-                                rect->x * SDL_BYTESPERPIXEL(texture->format);
-        int length = rect->w * SDL_BYTESPERPIXEL(texture->format);
-        int height = rect->h;
-
-        while(height--)
-        {
-            SDL_memcpy(dst, src, length);
-            dst += texturedata->pitch;
-            src += pitch;
-        }
-    }
-
-    return 0;
-}
-
-int WINCE_LockTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int dirty, void** pixels, int* pitch)
-{
-    WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata;
-
-    if(texturedata->yuv)
-        return SDL_SW_LockYUVTexture(texturedata->yuv, rect, dirty, pixels, pitch);
-
-    *pixels = (void *) ((unsigned char*) texturedata->pixels +
-                    rect->y * texturedata->pitch +
-                    rect->x * SDL_BYTESPERPIXEL(texture->format));
-    *pitch = texturedata->pitch;
-    return 0;
-}
-
-void WINCE_UnlockTexture(SDL_Renderer* renderer, SDL_Texture* texture)
-{
-    WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata;
-
-    if(texturedata->yuv)
-    {
-        SDL_SW_UnlockYUVTexture(texturedata->yuv);
-        WINCE_UpdateYUVTextureData(texture);
-    }
-}
-
-int WINCE_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srect, const SDL_Rect* drect)
-{
-    WINCE_RenderData* dstdata = (WINCE_RenderData*) renderer->driverdata;
-    WINCE_TextureData* srcdata = (WINCE_TextureData*) texture->driverdata;
-    const unsigned char *src;
-    unsigned char *dst;
-
-    if((dstdata->flags & FB_SUSPENDED) ||
-       0 >= srect->w || 0 >= srect->h) return 0;
-
-    // lock gapi
-    if(dstdata->gapi) dstdata->gapi->GXBeginDraw();
-
-    src = ((const unsigned char*) srcdata->pixels);
-    dst = dstdata->pixels + (dstdata->flags & FB_SKIP_OFFSET ? 0 : dstdata->fb.offset) +
-                                drect->y * dstdata->fb.ypitch +
-                                drect->x * dstdata->fb.xpitch;
-    if(srcdata->yuv)
-    {
-        return SDL_SW_CopyYUVToRGB(srcdata->yuv,
-                                   srect, srcdata->format,
-                                   drect->w, drect->h, dst,
-                                   dstdata->fb.ypitch);
-    }
-    else
-    {
-        int height = drect->h;
-        int length = drect->w * SDL_BYTESPERPIXEL(texture->format); // in bytes
-
-        while(height--)
-        {
-            switch(SDL_BYTESPERPIXEL(texture->format))
-            {
-                case 2: UpdateLine16to16(&dstdata->fb, (Uint16*) src, (Uint16*) dst, length >> 1); break;
-
-                default: break;
-            }
-
-            dst += dstdata->fb.ypitch;
-            src += srcdata->pitch;
-        }
-    }
-
-    // unlock gapi
-    if(dstdata->gapi) dstdata->gapi->GXEndDraw();
-
-    return 0;
-}
-
-void WINCE_RenderPresent(SDL_Renderer* renderer)
-{
-}
-
-int WINCE_RenderDrawPoints(SDL_Renderer* renderer, const SDL_Point* points, int count)
-{
-    SDL_Unsupported();
-    return -1;
-}
-
-int WINCE_RenderDrawLines(SDL_Renderer* renderer, const SDL_Point* points, int count)
-{
-    SDL_Unsupported();
-    return -1;
-}
-
-int WINCE_RenderDrawRects(SDL_Renderer* renderer, const SDL_Rect ** rects, int count)
-{
-    SDL_Unsupported();
-    return -1;
-}
-
-int WINCE_RenderFillRects(SDL_Renderer* renderer, const SDL_Rect** rects, int count)
-{
-    SDL_Unsupported();
-    return -1;
-}
-
-
-
-void WINCE_SetupOrientation(WINCE_RenderData* data, int width, int height)
-{
-    const float maxW1 = (float)(GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN) ? GetSystemMetrics(SM_CXSCREEN) : GetSystemMetrics(SM_CYSCREEN));
-    const float maxW2 = (float)(data->fb.width > data->fb.height ? data->fb.width : data->fb.height);
-
-    // scale define
-    data->scale = maxW2 / maxW1;
-
-    // init fb values
-    FrameBufferInitialize(&data->fb);
-
-    // orientation values
-    data->userOrientation = ORIENTATION_UP;
-    data->systemOrientation = WINCE_GetDMOrientation();
-    data->hardwareGeometry = data->fb.width == data->fb.height ? GEOMETRY_SQUARE :
-                                (data->fb.width < data->fb.height ? GEOMETRY_PORTRAIT : GEOMETRY_LANDSCAPE);
-
-    if(data->debug)
-        WINCE_DumpVideoInfo(data);
-
-    if(data->systemOrientation == ORIENTATION_UNKNOWN)
-        data->systemOrientation = ORIENTATION_UP;
-
-    data->userOrientation = ORIENTATION_UP;
-
-    switch(data->hardwareGeometry)
-    {
-        case GEOMETRY_PORTRAIT:  WINCE_PortraitTransform(data, width, height); break;
-        case GEOMETRY_LANDSCAPE: WINCE_LandscapeTransform(data, width, height); break;
-        case GEOMETRY_SQUARE:    WINCE_SquareTransform(data, width, height); break;
-        default: break;
-    }
-
-    // debug
-    if(data->debug)
-    {
-        printf("\n");
-        printf("user video width:          %d\n", width);
-        printf("user video height:         %d\n", height);
-        FrameBufferDumpInfo(&data->fb, "user");
-    }
-}
-
-void WINCE_DumpVideoInfo(WINCE_RenderData* data)
-{
-    // get oem info
-    WCHAR oemInfo[48];
-    SDL_memset(oemInfo, 0, sizeof(oemInfo));
-    SystemParametersInfo(SPI_GETOEMINFO, sizeof(oemInfo) - sizeof(WCHAR), oemInfo, 0);
-
-    printf("hardware oem: ");
-    wprintf(oemInfo);
-    printf("\n");
-
-    printf("video driver mode:             %s\n", (data->flags & FB_RAW_MODE ? RAW_RENDER_NAME : GAPI_RENDER_NAME));
-    printf("GetSystemMetrics(SM_CXSCREEN): %d\n", GetSystemMetrics(SM_CXSCREEN));
-    printf("GetSystemMetrics(SM_CYSCREEN): %d\n", GetSystemMetrics(SM_CYSCREEN));
-    printf("scale coord:                   %f\n", data->scale);
-
-    FrameBufferDumpInfo(&data->fb, "hardware");
-
-    printf("display format:                %p\n", data->format);
-    printf("display bits per pixel:        %d\n", SDL_BITSPERPIXEL(data->format));
-    printf("display bytes per pixel:       %d\n", SDL_BYTESPERPIXEL(data->format));
-    printf("display memory:                %p\n", data->pixels);
-    printf("system orientation:            %d, %s\n", data->systemOrientation, GetOrientationName(data->systemOrientation));
-    printf("hardware geometry:             %d\n", data->hardwareGeometry);
-}
-
-void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible)
-{
-    SDL_WindowData* windowdata = (SDL_WindowData*) window->driverdata;
-    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
-    SDL_Renderer* renderer = (SDL_Renderer*) window->renderer;
-
-    if(visible)
-    {
-        if(window->flags & SDL_WINDOW_FULLSCREEN)
-        {
-            if(videodata->SHFullScreen)
-                videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
-            ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE);
-        }
-
-        ShowWindow(windowdata->hwnd, SW_SHOW);
-        SetForegroundWindow(windowdata->hwnd);
-
-        if(renderer &&
-            (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
-        {
-            WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata;
-            renderdata->flags &= ~FB_SUSPENDED;
-            if(renderdata->gapi) renderdata->gapi->GXResume();
-        }
-    }
-    else
-    {
-        if(renderer &&
-            (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
-        {
-            WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata;
-            if(renderdata->gapi) renderdata->gapi->GXSuspend();
-            renderdata->flags |= FB_SUSPENDED;
-        }
-
-        ShowWindow(windowdata->hwnd, SW_HIDE);
-
-        if(window->flags & SDL_WINDOW_FULLSCREEN)
-        {
-            if(videodata->SHFullScreen)
-                videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
-            ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW);
-        }
-    }
-}
-
-
-void WINCE_PointerCoordinateTransform(SDL_Window* window, POINT* pt)
-{
-    WINCE_RenderData* data = (WINCE_RenderData*) window->renderer->driverdata;
-
-    pt->x = (LONG)(pt->x * data->scale);
-    pt->y = (LONG)(pt->y * data->scale);
-
-    PointerRotate(pt, &data->fb, data->userOrientation);
-}
-
-void WINCE_PortraitTransform(WINCE_RenderData* data, int width, int height)
-{
-    if(data->systemOrientation != ORIENTATION_UP)
-        FrameBufferRotate(&data->fb, data->systemOrientation);
-
-    if(data->fb.width != width || data->fb.height != height) {
-        switch(data->systemOrientation)
-        {
-            case ORIENTATION_UP:
-            case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break;
-            case ORIENTATION_RIGHT:
-            case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break;
-            default: break;
-        }
-    }
-
-    if(data->userOrientation != ORIENTATION_UP)
-        FrameBufferRotate(&data->fb, data->userOrientation);
-}
-
-void WINCE_LandscapeTransform(WINCE_RenderData* data, int width, int height)
-{
-    switch(data->systemOrientation)
-    {
-        case ORIENTATION_UP:  FrameBufferRotate(&data->fb, ORIENTATION_LEFT); break;
-        case ORIENTATION_LEFT:FrameBufferRotate(&data->fb, ORIENTATION_DOWN); break;
-        case ORIENTATION_DOWN:FrameBufferRotate(&data->fb, ORIENTATION_RIGHT); break;
-        default: break;
-    }
-
-    if(data->fb.width != width || data->fb.height != height)
-    switch(data->systemOrientation)
-    {
-        case ORIENTATION_UP:
-        case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break;
-        case ORIENTATION_RIGHT:
-        case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break;
-        default: break;
-    }
-
-    if(data->userOrientation != ORIENTATION_UP)
-        FrameBufferRotate(&data->fb, data->userOrientation);
-}
-
-void WINCE_SquareTransform(WINCE_RenderData* data, int width, int height)
-{
-    WINCE_PortraitTransform(data, width, height);
-}
-
-int WINCE_FixedGeometry(FrameBufferInfo* fb, int bpp, int debug)
-{
-    // check square
-    if(GetSystemMetrics(SM_CXSCREEN) == GetSystemMetrics(SM_CYSCREEN) &&
-        fb->width != fb->height)
-    {
-        if(fb->width < fb->height)
-            fb->height = fb->width;
-        else
-        if(fb->height < fb->width)
-            fb->width = fb->height;
-    }
-
-    // check width
-    if(__abs(fb->xpitch) == bpp &&
-        fb->width  != __abs(fb->ypitch) / bpp)
-    {
-        if(fb->height == __abs(fb->ypitch) / bpp)
-            {
-            __swap(&fb->width, &fb->height);
-
-            if(debug)
-                printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height);
-        }
-        else
-            return -1;
-    }
-    else
-    // check height
-    if(__abs(fb->ypitch) == bpp &&
-        fb->height != __abs(fb->xpitch) / bpp)
-    {
-        if(fb->width  == __abs(fb->xpitch) / bpp)
-            {
-            __swap(&fb->width, &fb->height);
-
-            if(debug)
-                printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height);
-        }
-        else
-            return -1;
-    }
-
-    return 0;
-}
-
-void WINCE_UpdateYUVTextureData(SDL_Texture* texture)
-{
-    WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata;
-    SDL_Rect rect;
-
-    rect.x = 0;
-    rect.y = 0;
-    rect.w = texture->w;
-    rect.h = texture->h;
-    SDL_SW_CopyYUVToRGB(texturedata->yuv, &rect, texturedata->format, texture->w, texture->h, texturedata->pixels, texturedata->pitch);
-}
-
-int GAPI_Init(WINCE_RenderData* data, HWND hwnd)
-{
-    if(NULL == data->gapi)
-    {
-        struct GXDisplayProperties gxProperties;
-        GXDeviceInfo gxInfo = { 0 };
-        HDC hdc;
-        int enable, result;
-        const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
-        if(preferably && 0 != SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0;
-
-        data->gapi = (GapiInfo *) SDL_calloc(1, sizeof(GapiInfo));
-        if(NULL == data->gapi)
-        {
-            SDL_OutOfMemory();
-            return 0;
-        }
-
-        data->gapi->hGapiLib = SDL_LoadObject("\\Windows\\gx.dll");
-        if(0 == data->gapi->hGapiLib)
-        {
-            data->gapi->hGapiLib = SDL_LoadObject("gx.dll");
-            if(0 == data->gapi->hGapiLib) return 0;
-        }
-
-        // load gapi library
-#define LINK(type,name,import) name=(PFN##type)SDL_LoadFunction(data->gapi->hGapiLib,import)
-        LINK(GXOpenDisplay,         data->gapi->GXOpenDisplay,         "?GXOpenDisplay@@YAHPAUHWND__@@K@Z");
-        LINK(GXCloseDisplay,        data->gapi->GXCloseDisplay,        "?GXCloseDisplay@@YAHXZ");
-        LINK(GXBeginDraw,           data->gapi->GXBeginDraw,           "?GXBeginDraw@@YAPAXXZ");
-        LINK(GXEndDraw,             data->gapi->GXEndDraw,             "?GXEndDraw@@YAHXZ");
-        LINK(GXGetDisplayProperties,data->gapi->GXGetDisplayProperties,"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ");
-        LINK(GXSuspend,             data->gapi->GXSuspend,             "?GXSuspend@@YAHXZ");
-        LINK(GXResume,              data->gapi->GXResume,              "?GXResume@@YAHXZ");
-#undef LINK
-
-        enable = data->gapi->GXGetDisplayProperties && data->gapi->GXCloseDisplay && data->gapi->GXOpenDisplay &&
-            data->gapi->GXBeginDraw && data->gapi->GXEndDraw && data->gapi->GXSuspend && data->gapi->GXResume;
-
-        if(!enable)
-        {
-            SDL_SetError("GAPI_Init: error gx.dll: internal error");
-            GAPI_Quit(data);
-            return 0;
-        }
-
-        if(0 == data->gapi->GXOpenDisplay(hwnd, GX_FULLSCREEN))
-        {
-            SDL_SetError("GAPI_Init: couldn't initialize GAPI");
-            GAPI_Quit(data);
-            return 0;
-        }
-
-        gxProperties = data->gapi->GXGetDisplayProperties();
-
-        // fill FrameBufferInfo
-        data->fb.xpitch = gxProperties.cbxPitch;
-        data->fb.ypitch = gxProperties.cbyPitch;
-        data->fb.width  = gxProperties.cxWidth;
-        data->fb.height = gxProperties.cyHeight;
-        data->fb.offset = 0;
-
-        if((gxProperties.ffFormat & kfDirect565) || 16 == gxProperties.cBPP)
-            data->format = SDL_PIXELFORMAT_RGB565;
-        else
-        if((gxProperties.ffFormat & kfDirect555) || 15 == gxProperties.cBPP)
-            data->format = SDL_PIXELFORMAT_RGB555;
-        else
-            data->format = 0;
-
-        // get pixels
-        hdc = GetDC(NULL);
-
-        gxInfo.Version = 100;
-        result = ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(gxInfo), (char *) &gxInfo);
-        ReleaseDC(NULL, hdc);
-
-        if(result > 0)
-        {
-            // more debug
-            if(data->debug)
-            {
-                int i;
-
-                printf("GXDeviceInfo.pvFrameBuffer:    %p\n", gxInfo.pvFrameBuffer);
-                printf("GXDeviceInfo.cxWidth:          %d\n", gxInfo.cxWidth);
-                printf("GXDeviceInfo.cyHeight:         %d\n", gxInfo.cyHeight);
-                printf("GXDeviceInfo.cbStride:         %d\n", gxInfo.cbStride);
-                printf("GXDeviceInfo.cBPP:             %d\n", gxInfo.cBPP);
-                printf("GXDeviceInfo.ffFormat:        0x%x\n", gxInfo.ffFormat);
-
-                printf("GXDeviceInfo.unk:\n");
-                for(i = 0; i <  sizeof(gxInfo.unknown); ++i)
-                    printf("0x%02hhX,", gxInfo.unknown[i]);
-                printf("\n");
-            }
-
-                if(gxInfo.ffFormat && gxInfo.ffFormat != gxProperties.ffFormat) {
-                    if((gxInfo.ffFormat & kfDirect565) || 16 == gxInfo.cBPP)
-                        data->format = SDL_PIXELFORMAT_RGB565;
-                    else
-                    if((gxInfo.ffFormat & kfDirect555) || 15 == gxInfo.cBPP)
-                        data->format = SDL_PIXELFORMAT_RGB555;
-                }
-
-                data->pixels = gxInfo.pvFrameBuffer;
-        }
-        else
-        {
-            data->flags |= FB_SKIP_OFFSET;
-            data->pixels = data->gapi->GXBeginDraw();
-            data->gapi->GXEndDraw();
-
-            if(data->debug)
-            {
-                printf("GAPI_Init\n");
-                printf("use GXBeginDraw:               %p\n", data->pixels);
-                printf("use skip offset\n");
-            }
-        }
-
-        if(0 == data->format ||
-            0 > WINCE_FixedGeometry(&data->fb, SDL_BYTESPERPIXEL(data->format), data->debug))
-        {
-            SDL_SetError("GAPI_Init: unknown hardware");
-            GAPI_Quit(data);
-            return 0;
-        }
-    }
-
-    return data->gapi && data->pixels ? 1 : 0;
-}
-
-void GAPI_Quit(WINCE_RenderData* data)
-{
-    if(data->gapi)
-    {
-        if(data->gapi->GXCloseDisplay) data->gapi->GXCloseDisplay(); 
-        if(data->gapi->hGapiLib)  SDL_UnloadObject(data->gapi->hGapiLib);
-
-        SDL_free(data->gapi);
-        data->gapi = NULL;
-    }
-}
-
-int RAW_Init(WINCE_RenderData* data)
-{
-    RawFrameBufferInfo rfbi = { 0 };
-    HDC hdc;
-    int result;
-    const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
-    if(preferably && 0 != SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0;
-
-    hdc = GetDC(NULL);
-    result = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi);
-    ReleaseDC(NULL, hdc);
-
-    //disable
-    if(result == 0 || rfbi.pFramePointer == 0 ||
-            rfbi.cxPixels == 0 || rfbi.cyPixels == 0 ||
-        rfbi.cxStride == 0 || rfbi.cyStride == 0) return 0;
-
-    data->flags     = FB_RAW_MODE;
-
-    // fill FrameBufferInfo
-    SDL_memset(&data->fb, 0, sizeof(FrameBufferInfo));
-
-    data->fb.xpitch = rfbi.cxStride;
-    data->fb.ypitch = rfbi.cyStride;
-    data->fb.width  = rfbi.cxPixels;
-    data->fb.height = rfbi.cyPixels;
-    data->fb.offset = 0;
-
-    if((FORMAT_565 & rfbi.wFormat) || 16 == rfbi.wBPP)
-        data->format = SDL_PIXELFORMAT_RGB565;
-    else
-    if((FORMAT_555 & rfbi.wFormat) || 15 == rfbi.wBPP)
-        data->format = SDL_PIXELFORMAT_RGB555;
-    else
-        data->format = 0;
-
-    if(0 == data->format ||
-        0 > WINCE_FixedGeometry(&data->fb, SDL_BYTESPERPIXEL(data->format), data->debug))
-    {
-        SDL_SetError("RAW_Init: unknown hardware");
-        RAW_Quit(data);
-        return 0;
-    }
-
-    data->pixels = rfbi.pFramePointer;
-
-    return data->pixels ? 1 : 0;
-}
-
-void RAW_Quit(WINCE_RenderData* data)
-{
-}
-
-void FrameBufferInitialize(FrameBufferInfo* fb)
-{
-    int orientation = GetFrameBufferOrientation(fb);
-
-    // set correct start offset
-    switch(orientation)
-    {
-        case ORIENTATION_UP:
-            fb->offset = 0;
-            break;
-
-        case ORIENTATION_LEFT:
-            fb->offset = __abs(fb->ypitch * (fb->height - 1));
-            break;
-
-        case ORIENTATION_RIGHT:
-            fb->offset = __abs(fb->xpitch * (fb->width - 1));
-            break;
-
-        case ORIENTATION_DOWN:
-            fb->offset = __abs(fb->xpitch * (fb->width - 1) +
-                                fb->ypitch * (fb->height - 1));
-            break;
-
-        default: break;
-    }
-
-    //if(orientation != ORIENTATION_UP)
-    switch(orientation)
-    {
-        case ORIENTATION_LEFT: FrameBufferRotate(fb, ORIENTATION_RIGHT); break;
-        case ORIENTATION_RIGHT:FrameBufferRotate(fb, ORIENTATION_LEFT); break;
-        case ORIENTATION_DOWN: FrameBufferRotate(fb, ORIENTATION_DOWN); break;
-
-        default: break;
-    }
-}
-
-int GetFrameBufferOrientation(const FrameBufferInfo* src)
-{
-    if(src->xpitch > 0 && src->ypitch > 0)
-        return ORIENTATION_UP;
-    else
-    if(src->xpitch > 0 && src->ypitch < 0)
-        return ORIENTATION_LEFT;
-    else
-    if(src->xpitch < 0 && src->ypitch > 0)
-        return ORIENTATION_RIGHT;
-    else
-    if(src->xpitch < 0 && src->ypitch < 0)
-        return ORIENTATION_DOWN;
-
-    return ORIENTATION_UNKNOWN;
-}
-
-void FrameBufferRotate(FrameBufferInfo* dst, int orientation)
-{
-    FrameBufferInfo src;
-    // copy dst -> src
-    SDL_memcpy(&src, dst, sizeof(FrameBufferInfo));
-
-    switch(orientation)
-    {
-        case ORIENTATION_LEFT:
-            dst->width  = src.height;
-            dst->height = src.width;
-            dst->xpitch = src.ypitch;
-            dst->ypitch = -src.xpitch;
-            dst->offset = src.offset + src.xpitch * (src.width - 1);
-            break;
-
-        case ORIENTATION_RIGHT:
-            dst->width  = src.height;
-            dst->height = src.width;
-            dst->xpitch = -src.ypitch;
-            dst->ypitch = src.xpitch;
-            dst->offset = src.offset + src.ypitch * (src.height - 1);
-            break;
-
-        case ORIENTATION_DOWN:
-            FrameBufferRotate(dst, ORIENTATION_LEFT);
-            FrameBufferRotate(dst, ORIENTATION_LEFT);
-            break;
-
-        default:
-            break;
-    }
-}
-
-void PointerRotate(POINT* pt, const FrameBufferInfo* fb, int orientation)
-{
-    switch(orientation)
-    {
-        case ORIENTATION_UP:
-            break;
-
-        case ORIENTATION_LEFT:
-        {
-            int temp = pt->y;
-            pt->y = fb->height - pt->x;
-            pt->x = temp;
-        }
-            break;
-
-        case ORIENTATION_RIGHT:
-        {
-            int temp = pt->x;
-            pt->x = fb->width - pt->y;
-            pt->y = temp;
-        }
-            break;
-
-        case ORIENTATION_DOWN:
-            pt->x = fb->width  - pt->x;
-            pt->y = fb->height - pt->y;
-            break;
-
-        default: break;
-    }
-}
-
-const char* GetOrientationName(int orientation)
-{
-    switch(orientation)
-    {
-        case ORIENTATION_UP:        return "UP";
-        case ORIENTATION_DOWN:      return "DOWN";
-        case ORIENTATION_LEFT:      return "LEFT";
-        case ORIENTATION_RIGHT:     return "RIGHT";
-        default: break;
-    }
-
-    return "UNKNOWN";
-}
-
-int WINCE_GetDMOrientation(void)
-{
-    DEVMODE sDevMode = {0};
-    sDevMode.dmSize = sizeof(DEVMODE);
-    sDevMode.dmFields = DM_DISPLAYORIENTATION;
-
-    // DMDO_0, DMDO_90, DMDO_180, DMDO_270
-    if(DISP_CHANGE_BADMODE != ChangeDisplaySettingsEx(NULL, &sDevMode, 0, CDS_TEST, NULL))
-        switch(sDevMode.dmDisplayOrientation)
-        {
-            case DMDO_0:        return DMDO_0;
-            case DMDO_90:        return DMDO_90;
-            case DMDO_180:        return DMDO_180;
-            case DMDO_270:        return DMDO_270;
-            default: break;
-        }
-
-    SDL_SetError("WINCE_GetDMOrientation: ChangeDisplaySettingsEx return BADMODE");
-    return -1;
-}
-
-int WINCE_SetDMOrientation(int orientation)
-{
-    DEVMODE sDevMode = {0};
-    sDevMode.dmSize = sizeof(DEVMODE);
-    sDevMode.dmFields = DM_DISPLAYORIENTATION;
-
-    switch(orientation)
-    {
-        case DMDO_0:        sDevMode.dmDisplayOrientation = DMDO_0;   break;
-        case DMDO_90:        sDevMode.dmDisplayOrientation = DMDO_90;  break;
-        case DMDO_180:        sDevMode.dmDisplayOrientation = DMDO_180; break;
-        case DMDO_270:        sDevMode.dmDisplayOrientation = DMDO_270; break;
-        default: return 0;
-    }
-
-    if(DISP_CHANGE_BADMODE != ChangeDisplaySettingsEx(NULL, &sDevMode, 0, CDS_RESET, NULL))
-        return 1;
-
-    SDL_SetError("WINCE_SetDMOrientation: ChangeDisplaySettingsEx return BADMODE");
-    return -1;
-}
-
-void FrameBufferDumpInfo(const FrameBufferInfo* fb, const char* name)
-{
-    int orientation;
-
-    printf("%s fb.width:       %d\n", name, fb->width);
-    printf("%s fb.height:      %d\n", name, fb->height);
-    printf("%s fb.xpitch:      %d\n", name, fb->xpitch);
-    printf("%s fb.ypitch:      %d\n", name, fb->ypitch);
-    printf("%s fb.offset:      %d\n", name, fb->offset);
-
-    orientation = GetFrameBufferOrientation(fb);
-    printf("%s fb.orientation: %d, %s\n", name, orientation, GetOrientationName(orientation));
-}
-
-void UpdateLine16to16(const FrameBufferInfo* fb, const Uint16* src, Uint16* dst, Uint16 width)
-{
-    if(2 == fb->xpitch)
-    {
-        switch(width)
-        {
-            case 1:
-                *dst = *src;
-                break;
-
-            case 2:
-                *((Uint32*) dst) = *((Uint32*) src);
-                break;
-
-            default:
-                SDL_memcpy(dst, src, width * 2);
-                break;
-        }
-    }
-    else
-    if(-2 == fb->xpitch)
-    {
-        while(width--)
-            *dst-- = *src++;
-    }
-    else
-    {
-        while(width--)
-        {
-            *dst = *src++;
-            dst += fb->xpitch / 2;
-        }
-    }
-}
-
-#endif // SDL_VIDEO_RENDER_GAPI
--- a/src/video/windows/SDL_gapirender.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-    
-    Stefan Klug
-    klug.stefan@gmx.de
-*/
-#include "SDL_config.h"
-
-/* SDL surface based renderer implementation */
-
-#if SDL_VIDEO_RENDER_GAPI
-extern void WINCE_AddRenderDriver(_THIS);
-extern int  WINCE_Available(void);
-extern void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible);
-extern int  WINCE_GetDMOrientation(void);
-extern int  WINCE_SetDMOrientation(int orientation);
-#endif
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_gapirender_c.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-    
-    Stefan Klug
-    klug.stefan@gmx.de
-*/
--- a/src/video/windows/SDL_gdirender.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1129 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_GDI
-
-#include "SDL_windowsvideo.h"
-#include "../SDL_rect_c.h"
-#include "../SDL_yuv_sw_c.h"
-#include "../SDL_alphamult.h"
-
-#ifdef _WIN32_WCE
-#define NO_GETDIBBITS 1
-#endif
-
-/* GDI renderer implementation */
-
-static SDL_Renderer *GDI_CreateRenderer(SDL_Window * window, Uint32 flags);
-static int GDI_DisplayModeChanged(SDL_Renderer * renderer);
-static int GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int GDI_QueryTexturePixels(SDL_Renderer * renderer,
-                                  SDL_Texture * texture, void **pixels,
-                                  int *pitch);
-static int GDI_SetTexturePalette(SDL_Renderer * renderer,
-                                 SDL_Texture * texture,
-                                 const SDL_Color * colors, int firstcolor,
-                                 int ncolors);
-static int GDI_GetTexturePalette(SDL_Renderer * renderer,
-                                 SDL_Texture * texture, SDL_Color * colors,
-                                 int firstcolor, int ncolors);
-static int GDI_SetTextureAlphaMod(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int GDI_SetTextureBlendMode(SDL_Renderer * renderer,
-                                   SDL_Texture * texture);
-static int GDI_SetTextureScaleMode(SDL_Renderer * renderer,
-                                   SDL_Texture * texture);
-static int GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                             const SDL_Rect * rect, const void *pixels,
-                             int pitch);
-static int GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                           const SDL_Rect * rect, int markDirty,
-                           void **pixels, int *pitch);
-static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int GDI_SetDrawBlendMode(SDL_Renderer * renderer);
-static int GDI_RenderDrawPoints(SDL_Renderer * renderer,
-                                const SDL_Point * points, int count);
-static int GDI_RenderDrawLines(SDL_Renderer * renderer,
-                               const SDL_Point * points, int count);
-static int GDI_RenderDrawRects(SDL_Renderer * renderer,
-                               const SDL_Rect ** rects, int count);
-static int GDI_RenderFillRects(SDL_Renderer * renderer,
-                               const SDL_Rect ** rects, int count);
-static int GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * srcrect, const SDL_Rect * dstrect);
-static int GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                Uint32 format, void * pixels, int pitch);
-static int GDI_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                 Uint32 format, const void * pixels, int pitch);
-static void GDI_RenderPresent(SDL_Renderer * renderer);
-static void GDI_DestroyTexture(SDL_Renderer * renderer,
-                               SDL_Texture * texture);
-static void GDI_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver GDI_RenderDriver = {
-    GDI_CreateRenderer,
-    {
-     "gdi",
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
-      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
-      SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
-     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA),
-     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK),
-     (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST),
-     14,
-     {
-      SDL_PIXELFORMAT_INDEX8,
-      SDL_PIXELFORMAT_RGB555,
-      SDL_PIXELFORMAT_RGB565,
-      SDL_PIXELFORMAT_RGB888,
-      SDL_PIXELFORMAT_BGR888,
-      SDL_PIXELFORMAT_ARGB8888,
-      SDL_PIXELFORMAT_RGBA8888,
-      SDL_PIXELFORMAT_ABGR8888,
-      SDL_PIXELFORMAT_BGRA8888,
-      SDL_PIXELFORMAT_YV12,
-      SDL_PIXELFORMAT_IYUV,
-      SDL_PIXELFORMAT_YUY2,
-      SDL_PIXELFORMAT_UYVY,
-      SDL_PIXELFORMAT_YVYU},
-     0,
-     0}
-};
-
-typedef struct
-{
-    HWND hwnd;
-    HDC window_hdc;
-    HDC render_hdc;
-    HDC memory_hdc;
-    HDC current_hdc;
-#ifndef NO_GETDIBBITS
-    LPBITMAPINFO bmi;
-#endif
-    HBITMAP hbm[3];
-    int current_hbm;
-    SDL_DirtyRectList dirty;
-    SDL_bool makedirty;
-} GDI_RenderData;
-
-typedef struct
-{
-    SDL_SW_YUVTexture *yuv;
-    Uint32 format;
-    HPALETTE hpal;
-    HBITMAP hbm;
-    void *pixels;
-    int pitch;
-    SDL_bool premultiplied;
-} GDI_TextureData;
-
-static void
-UpdateYUVTextureData(SDL_Texture * texture)
-{
-    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
-    SDL_Rect rect;
-
-    rect.x = 0;
-    rect.y = 0;
-    rect.w = texture->w;
-    rect.h = texture->h;
-    SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w,
-                        texture->h, data->pixels, data->pitch);
-}
-
-void
-GDI_AddRenderDriver(_THIS)
-{
-    int i;
-    for (i = 0; i < _this->num_displays; ++i) {
-        SDL_AddRenderDriver(&_this->displays[i], &GDI_RenderDriver);
-    }
-}
-
-SDL_Renderer *
-GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
-    SDL_Renderer *renderer;
-    GDI_RenderData *data;
-#ifndef NO_GETDIBBITS
-    int bmi_size;
-    HBITMAP hbm;
-#endif
-    int i, n;
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (GDI_RenderData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        GDI_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    windowdata->videodata->render = RENDER_GDI;
-
-    renderer->DisplayModeChanged = GDI_DisplayModeChanged;
-    renderer->CreateTexture = GDI_CreateTexture;
-    renderer->QueryTexturePixels = GDI_QueryTexturePixels;
-    renderer->SetTexturePalette = GDI_SetTexturePalette;
-    renderer->GetTexturePalette = GDI_GetTexturePalette;
-    renderer->SetTextureAlphaMod = GDI_SetTextureAlphaMod;
-    renderer->SetTextureBlendMode = GDI_SetTextureBlendMode;
-    renderer->SetTextureScaleMode = GDI_SetTextureScaleMode;
-    renderer->UpdateTexture = GDI_UpdateTexture;
-    renderer->LockTexture = GDI_LockTexture;
-    renderer->UnlockTexture = GDI_UnlockTexture;
-    renderer->SetDrawBlendMode = GDI_SetDrawBlendMode;
-    renderer->RenderDrawPoints = GDI_RenderDrawPoints;
-    renderer->RenderDrawLines = GDI_RenderDrawLines;
-    renderer->RenderDrawRects = GDI_RenderDrawRects;
-    renderer->RenderFillRects = GDI_RenderFillRects;
-    renderer->RenderCopy = GDI_RenderCopy;
-    renderer->RenderReadPixels = GDI_RenderReadPixels;
-    renderer->RenderWritePixels = GDI_RenderWritePixels;
-    renderer->RenderPresent = GDI_RenderPresent;
-    renderer->DestroyTexture = GDI_DestroyTexture;
-    renderer->DestroyRenderer = GDI_DestroyRenderer;
-    renderer->info = GDI_RenderDriver.info;
-    renderer->window = window;
-    renderer->driverdata = data;
-
-    renderer->info.flags = SDL_RENDERER_ACCELERATED;
-
-    data->hwnd = windowdata->hwnd;
-    data->window_hdc = windowdata->hdc;
-    data->render_hdc = CreateCompatibleDC(data->window_hdc);
-    data->memory_hdc = CreateCompatibleDC(data->window_hdc);
-
-#ifndef NO_GETDIBBITS
-    /* Fill in the compatible bitmap info */
-    bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
-    data->bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size);
-    if (!data->bmi) {
-        GDI_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-    data->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-
-    hbm = CreateCompatibleBitmap(data->window_hdc, 1, 1);
-    GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS);
-    GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS);
-    DeleteObject(hbm);
-#endif
-
-    if (flags & SDL_RENDERER_SINGLEBUFFER) {
-        renderer->info.flags |=
-            (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY);
-        n = 0;
-    } else if (flags & SDL_RENDERER_PRESENTFLIP2) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
-        n = 2;
-    } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
-        n = 3;
-    } else {
-        renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
-        n = 1;
-    }
-    for (i = 0; i < n; ++i) {
-        data->hbm[i] =
-            CreateCompatibleBitmap(data->window_hdc, window->w, window->h);
-        if (!data->hbm[i]) {
-            GDI_DestroyRenderer(renderer);
-            WIN_SetError("CreateCompatibleBitmap()");
-            return NULL;
-        }
-    }
-    if (n > 0) {
-        SelectObject(data->render_hdc, data->hbm[0]);
-        data->current_hdc = data->render_hdc;
-        data->makedirty = SDL_TRUE;
-    } else {
-        data->current_hdc = data->window_hdc;
-        data->makedirty = SDL_FALSE;
-    }
-    data->current_hbm = 0;
-
-#ifdef _WIN32_WCE
-    // check size for GDI fullscreen and rotate
-    if((window->flags & SDL_WINDOW_FULLSCREEN) &&
-        GetSystemMetrics(SM_CXSCREEN) != GetSystemMetrics(SM_CYSCREEN) &&
-        ((GetSystemMetrics(SM_CXSCREEN) < GetSystemMetrics(SM_CYSCREEN) && window->w > window->h) ||
-         (GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN) && window->w < window->h)))
-    {
-	int orientation = WINCE_GetDMOrientation();
-	switch(orientation)
-	{
-	    case DMDO_0:   orientation = DMDO_90; break;
-	    case DMDO_270: orientation = DMDO_180; break;
-	    case DMDO_90:  orientation = DMDO_0; break;
-	    case DMDO_180: orientation = DMDO_270; break;
-
-	    default:
-		GDI_DestroyRenderer(renderer);
-		return NULL;
-	}
-
-	if(0 > WINCE_SetDMOrientation(orientation))
-	{
-	    GDI_DestroyRenderer(renderer);
-	    return NULL;
-	}
-    }
-#endif
-
-    return renderer;
-}
-
-static int
-GDI_DisplayModeChanged(SDL_Renderer * renderer)
-{
-    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    int i, n;
-
-    if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) {
-        n = 0;
-    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
-        n = 2;
-    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
-        n = 3;
-    } else {
-        n = 1;
-    }
-    for (i = 0; i < n; ++i) {
-        if (data->hbm[i]) {
-            DeleteObject(data->hbm[i]);
-            data->hbm[i] = NULL;
-        }
-    }
-    for (i = 0; i < n; ++i) {
-        data->hbm[i] =
-            CreateCompatibleBitmap(data->window_hdc, window->w, window->h);
-        if (!data->hbm[i]) {
-            WIN_SetError("CreateCompatibleBitmap()");
-            return -1;
-        }
-    }
-    if (n > 0) {
-        SelectObject(data->render_hdc, data->hbm[0]);
-    }
-    data->current_hbm = 0;
-
-    return 0;
-}
-
-static HBITMAP
-GDI_CreateDIBSection(HDC hdc, int w, int h, int pitch, Uint32 format,
-                     HPALETTE * hpal, void ** pixels)
-{
-    int bmi_size;
-    LPBITMAPINFO bmi;
-
-    bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
-    bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size);
-    if (!bmi) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-    bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-    bmi->bmiHeader.biWidth = w;
-    bmi->bmiHeader.biHeight = -h;  /* topdown bitmap */
-    bmi->bmiHeader.biPlanes = 1;
-    bmi->bmiHeader.biSizeImage = h * pitch;
-    bmi->bmiHeader.biXPelsPerMeter = 0;
-    bmi->bmiHeader.biYPelsPerMeter = 0;
-    bmi->bmiHeader.biClrUsed = 0;
-    bmi->bmiHeader.biClrImportant = 0;
-    bmi->bmiHeader.biBitCount = SDL_BYTESPERPIXEL(format) * 8;
-    if (SDL_ISPIXELFORMAT_INDEXED(format)) {
-        bmi->bmiHeader.biCompression = BI_RGB;
-        if (hpal) {
-            int i, ncolors;
-            LOGPALETTE *palette;
-
-            ncolors = (1 << SDL_BITSPERPIXEL(format));
-            palette =
-                (LOGPALETTE *) SDL_malloc(sizeof(*palette) +
-                                          ncolors * sizeof(PALETTEENTRY));
-            if (!palette) {
-                SDL_free(bmi);
-                SDL_OutOfMemory();
-                return NULL;
-            }
-            palette->palVersion = 0x300;
-            palette->palNumEntries = ncolors;
-            for (i = 0; i < ncolors; ++i) {
-                palette->palPalEntry[i].peRed = 0xFF;
-                palette->palPalEntry[i].peGreen = 0xFF;
-                palette->palPalEntry[i].peBlue = 0xFF;
-                palette->palPalEntry[i].peFlags = 0;
-            }
-            *hpal = CreatePalette(palette);
-            SDL_free(palette);
-        }
-    } else {
-        int bpp;
-        Uint32 Rmask, Gmask, Bmask, Amask;
-
-        bmi->bmiHeader.biCompression = BI_BITFIELDS;
-        SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask,
-                                   &Amask);
-        ((Uint32 *) bmi->bmiColors)[0] = Rmask;
-        ((Uint32 *) bmi->bmiColors)[1] = Gmask;
-        ((Uint32 *) bmi->bmiColors)[2] = Bmask;
-        if (hpal) {
-            *hpal = NULL;
-        }
-    }
-    return CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, pixels, NULL, 0);
-}
-
-static int
-GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    GDI_TextureData *data;
-
-    data = (GDI_TextureData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    texture->driverdata = data;
-
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        data->yuv =
-            SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
-        if (!data->yuv) {
-            return -1;
-        }
-        data->format = display->current_mode.format;
-    } else {
-        data->format = texture->format;
-    }
-    data->pitch = (texture->w * SDL_BYTESPERPIXEL(data->format));
-
-    if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING
-        || texture->format != display->current_mode.format) {
-        data->hbm = GDI_CreateDIBSection(renderdata->memory_hdc,
-                                         texture->w, texture->h,
-                                         data->pitch, data->format,
-                                         &data->hpal, &data->pixels);
-    } else {
-        data->hbm = CreateCompatibleBitmap(renderdata->window_hdc,
-                                           texture->w, texture->h);
-    }
-    if (!data->hbm) {
-        WIN_SetError("Couldn't create bitmap");
-        return -1;
-    }
-
-    return 0;
-}
-
-static int
-GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                       void **pixels, int *pitch)
-{
-    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
-    } else {
-        *pixels = data->pixels;
-        *pitch = data->pitch;
-        return 0;
-    }
-}
-
-static int
-GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                      const SDL_Color * colors, int firstcolor, int ncolors)
-{
-    GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
-    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        SDL_SetError("YUV textures don't have a palette");
-        return -1;
-    } else {
-        PALETTEENTRY entries[256];
-        int i;
-
-        for (i = 0; i < ncolors; ++i) {
-            entries[i].peRed = colors[i].r;
-            entries[i].peGreen = colors[i].g;
-            entries[i].peBlue = colors[i].b;
-            entries[i].peFlags = 0;
-        }
-        if (!SetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) {
-            WIN_SetError("SetPaletteEntries()");
-            return -1;
-        }
-        return 0;
-    }
-}
-
-static int
-GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                      SDL_Color * colors, int firstcolor, int ncolors)
-{
-    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        SDL_SetError("YUV textures don't have a palette");
-        return -1;
-    } else {
-        PALETTEENTRY entries[256];
-        int i;
-
-        if (!GetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) {
-            WIN_SetError("GetPaletteEntries()");
-            return -1;
-        }
-        for (i = 0; i < ncolors; ++i) {
-            colors[i].r = entries[i].peRed;
-            colors[i].g = entries[i].peGreen;
-            colors[i].b = entries[i].peBlue;
-        }
-        return 0;
-    }
-}
-
-static int
-GDI_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    return 0;
-}
-
-static int
-GDI_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
-
-    switch (texture->blendMode) {
-    case SDL_BLENDMODE_NONE:
-        if (data->premultiplied) {
-            /* Crap, we've lost the original pixel data... *sigh* */
-        }
-        return 0;
-#ifndef _WIN32_WCE              /* WinCE has no alphablend */
-    case SDL_BLENDMODE_MASK:
-    case SDL_BLENDMODE_BLEND:
-        if (!data->premultiplied && data->pixels) {
-            switch (texture->format) {
-            case SDL_PIXELFORMAT_ARGB8888:
-                SDL_PreMultiplyAlphaARGB8888(texture->w, texture->h,
-                                             (Uint32 *) data->pixels,
-                                             data->pitch);
-                data->premultiplied = SDL_TRUE;
-                break;
-            case SDL_PIXELFORMAT_RGBA8888:
-                SDL_PreMultiplyAlphaRGBA8888(texture->w, texture->h,
-                                             (Uint32 *) data->pixels,
-                                             data->pitch);
-                data->premultiplied = SDL_TRUE;
-                break;
-            case SDL_PIXELFORMAT_ABGR8888:
-                SDL_PreMultiplyAlphaABGR8888(texture->w, texture->h,
-                                             (Uint32 *) data->pixels,
-                                             data->pitch);
-                data->premultiplied = SDL_TRUE;
-                break;
-            case SDL_PIXELFORMAT_BGRA8888:
-                SDL_PreMultiplyAlphaBGRA8888(texture->w, texture->h,
-                                             (Uint32 *) data->pixels,
-                                             data->pitch);
-                data->premultiplied = SDL_TRUE;
-                break;
-            }
-        }
-        return 0;
-#endif
-    default:
-        SDL_Unsupported();
-        texture->blendMode = SDL_BLENDMODE_NONE;
-        return -1;
-    }
-}
-
-static int
-GDI_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    switch (texture->scaleMode) {
-    case SDL_SCALEMODE_NONE:
-    case SDL_SCALEMODE_FAST:
-        return 0;
-    case SDL_SCALEMODE_SLOW:
-    case SDL_SCALEMODE_BEST:
-        SDL_Unsupported();
-        texture->scaleMode = SDL_SCALEMODE_FAST;
-        return -1;
-    default:
-        SDL_Unsupported();
-        texture->scaleMode = SDL_SCALEMODE_NONE;
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                  const SDL_Rect * rect, const void *pixels, int pitch)
-{
-    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
-            return -1;
-        }
-        UpdateYUVTextureData(texture);
-        return 0;
-    } else {
-        GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
-
-        if (data->pixels) {
-            Uint8 *src, *dst;
-            int row;
-            size_t length;
-
-            src = (Uint8 *) pixels;
-            dst =
-                (Uint8 *) data->pixels + rect->y * data->pitch +
-                rect->x * SDL_BYTESPERPIXEL(texture->format);
-            length = rect->w * SDL_BYTESPERPIXEL(texture->format);
-            for (row = 0; row < rect->h; ++row) {
-                SDL_memcpy(dst, src, length);
-                src += pitch;
-                dst += data->pitch;
-            }
-            if (data->premultiplied) {
-                Uint32 *pixels =
-                    (Uint32 *) data->pixels + rect->y * (data->pitch / 4) +
-                    rect->x;
-                switch (texture->format) {
-                case SDL_PIXELFORMAT_ARGB8888:
-                    SDL_PreMultiplyAlphaARGB8888(rect->w, rect->h, pixels,
-                                                 data->pitch);
-                    break;
-                case SDL_PIXELFORMAT_RGBA8888:
-                    SDL_PreMultiplyAlphaRGBA8888(rect->w, rect->h, pixels,
-                                                 data->pitch);
-                    break;
-                case SDL_PIXELFORMAT_ABGR8888:
-                    SDL_PreMultiplyAlphaABGR8888(rect->w, rect->h, pixels,
-                                                 data->pitch);
-                    break;
-                case SDL_PIXELFORMAT_BGRA8888:
-                    SDL_PreMultiplyAlphaBGRA8888(rect->w, rect->h, pixels,
-                                                 data->pitch);
-                    break;
-                }
-            }
-        } else if (rect->w == texture->w && pitch == data->pitch) {
-#ifndef NO_GETDIBBITS
-            if (!SetDIBits
-                (renderdata->window_hdc, data->hbm, rect->y, rect->h, pixels,
-                 renderdata->bmi, DIB_RGB_COLORS)) {
-                WIN_SetError("SetDIBits()");
-                return -1;
-            }
-#else
-            SDL_SetError("FIXME: Update Texture");
-            return -1;
-#endif
-        } else {
-            SDL_SetError
-                ("FIXME: Need to allocate temporary memory and do GetDIBits() followed by SetDIBits(), since we can only set blocks of scanlines at a time");
-            return -1;
-        }
-        return 0;
-    }
-}
-
-static int
-GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                const SDL_Rect * rect, int markDirty, void **pixels,
-                int *pitch)
-{
-    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
-                                     pitch);
-    } else if (data->pixels) {
-#ifndef _WIN32_WCE
-        /* WinCE has no GdiFlush */
-        GdiFlush();
-#endif
-        *pixels =
-            (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
-                      rect->x * SDL_BYTESPERPIXEL(texture->format));
-        *pitch = data->pitch;
-        return 0;
-    } else {
-        SDL_SetError("No pixels available");
-        return -1;
-    }
-}
-
-static void
-GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        SDL_SW_UnlockYUVTexture(data->yuv);
-        UpdateYUVTextureData(texture);
-    }
-}
-
-static int
-GDI_SetDrawBlendMode(SDL_Renderer * renderer)
-{
-    switch (renderer->blendMode) {
-    case SDL_BLENDMODE_NONE:
-        return 0;
-    default:
-        SDL_Unsupported();
-        renderer->blendMode = SDL_BLENDMODE_NONE;
-        return -1;
-    }
-}
-
-static int
-GDI_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
-                     int count)
-{
-    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
-    int i;
-    COLORREF color;
-
-    if (data->makedirty) {
-        /* Get the smallest rectangle that contains everything */
-        SDL_Window *window = renderer->window;
-        SDL_Rect rect;
-
-        rect.x = 0;
-        rect.y = 0;
-        rect.w = window->w;
-        rect.h = window->h;
-        if (!SDL_EnclosePoints(points, count, &rect, &rect)) {
-            /* Nothing to draw */
-            return 0;
-        }
-
-        SDL_AddDirtyRect(&data->dirty, &rect);
-    }
-
-    color = RGB(renderer->r, renderer->g, renderer->b);
-    for (i = 0; i < count; ++i) {
-        SetPixel(data->current_hdc, points[i].x, points[i].y, color);
-    }
-
-    return 0;
-}
-
-static int
-GDI_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
-                    int count)
-{
-    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
-    HPEN pen;
-    BOOL status;
-
-    if (data->makedirty) {
-        /* Get the smallest rectangle that contains everything */
-        SDL_Window *window = renderer->window;
-        SDL_Rect clip, rect;
-
-        clip.x = 0;
-        clip.y = 0;
-        clip.w = window->w;
-        clip.h = window->h;
-        SDL_EnclosePoints(points, count, NULL, &rect);
-        if (!SDL_IntersectRect(&rect, &clip, &rect)) {
-            /* Nothing to draw */
-            return 0;
-        }
-
-        SDL_AddDirtyRect(&data->dirty, &rect);
-    }
-
-    /* Should we cache the pen? .. it looks like GDI does for us. :) */
-    pen = CreatePen(PS_SOLID, 1, RGB(renderer->r, renderer->g, renderer->b));
-    SelectObject(data->current_hdc, pen);
-    {
-        LPPOINT p = SDL_stack_alloc(POINT, count);
-        int i;
-
-        for (i = 0; i < count; ++i) {
-            p[i].x = points[i].x;
-            p[i].y = points[i].y;
-        }
-        status = Polyline(data->current_hdc, p, count);
-        SDL_stack_free(p);
-    }
-    DeleteObject(pen);
-
-    /* Need to close the endpoint of the line */
-    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
-        SetPixel(data->current_hdc, points[count-1].x, points[count-1].y,
-                 RGB(renderer->r, renderer->g, renderer->b));
-    }
-
-    if (!status) {
-        WIN_SetError("Polyline()");
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GDI_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                    int count)
-{
-    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
-    HPEN pen;
-    POINT vertices[5];
-    int i, status = 1;
-
-    if (data->makedirty) {
-        SDL_Window *window = renderer->window;
-        SDL_Rect clip, rect;
-
-        clip.x = 0;
-        clip.y = 0;
-        clip.w = window->w;
-        clip.h = window->h;
-
-        for (i = 0; i < count; ++i) {
-            if (SDL_IntersectRect(rects[i], &clip, &rect)) {
-                SDL_AddDirtyRect(&data->dirty, &rect);
-            }
-        }
-    }
-
-    /* Should we cache the pen? .. it looks like GDI does for us. :) */
-    pen = CreatePen(PS_SOLID, 1, RGB(renderer->r, renderer->g, renderer->b));
-    SelectObject(data->current_hdc, pen);
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect *rect = rects[i];
-
-        vertices[0].x = rect->x;
-        vertices[0].y = rect->y;
-
-        vertices[1].x = rect->x+rect->w-1;
-        vertices[1].y = rect->y;
-
-        vertices[2].x = rect->x+rect->w-1;
-        vertices[2].y = rect->y+rect->h-1;
-
-        vertices[3].x = rect->x;
-        vertices[3].y = rect->y+rect->h-1;
-
-        vertices[4].x = rect->x;
-        vertices[4].y = rect->y;
-
-        status &= Polyline(data->current_hdc, vertices, 5);
-    }
-    DeleteObject(pen);
-
-    if (!status) {
-        WIN_SetError("Polyline()");
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GDI_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                    int count)
-{
-    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
-    RECT rc;
-    HBRUSH brush;
-    int i, status = 1;
-
-    if (data->makedirty) {
-        SDL_Window *window = renderer->window;
-        SDL_Rect clip, rect;
-
-        clip.x = 0;
-        clip.y = 0;
-        clip.w = window->w;
-        clip.h = window->h;
-
-        for (i = 0; i < count; ++i) {
-            if (SDL_IntersectRect(rects[i], &clip, &rect)) {
-                SDL_AddDirtyRect(&data->dirty, &rect);
-            }
-        }
-    }
-
-    /* Should we cache the brushes? .. it looks like GDI does for us. :) */
-    brush = CreateSolidBrush(RGB(renderer->r, renderer->g, renderer->b));
-    SelectObject(data->current_hdc, brush);
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect *rect = rects[i];
-
-        rc.left = rect->x;
-        rc.top = rect->y;
-        rc.right = rect->x + rect->w;
-        rc.bottom = rect->y + rect->h;
-
-        status &= FillRect(data->current_hdc, &rc, brush);
-    }
-    DeleteObject(brush);
-
-    if (!status) {
-        WIN_SetError("FillRect()");
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
-    GDI_TextureData *texturedata = (GDI_TextureData *) texture->driverdata;
-
-    if (data->makedirty) {
-        SDL_AddDirtyRect(&data->dirty, dstrect);
-    }
-
-    SelectObject(data->memory_hdc, texturedata->hbm);
-    if (texturedata->hpal) {
-        SelectPalette(data->memory_hdc, texturedata->hpal, TRUE);
-        RealizePalette(data->memory_hdc);
-    }
-    if (texture->blendMode & (SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND)) {
-#ifdef _WIN32_WCE
-        SDL_SetError("Texture has blendmode not supported under WinCE");
-        return -1;
-#else
-        BLENDFUNCTION blendFunc = {
-            AC_SRC_OVER,
-            0,
-            texture->a,
-            AC_SRC_ALPHA
-        };
-        if (!AlphaBlend
-            (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
-             dstrect->h, data->memory_hdc, srcrect->x, srcrect->y, srcrect->w,
-             srcrect->h, blendFunc)) {
-            WIN_SetError("AlphaBlend()");
-            return -1;
-        }
-#endif
-    } else {
-        if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
-            if (!BitBlt
-                (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
-                 srcrect->h, data->memory_hdc, srcrect->x, srcrect->y,
-                 SRCCOPY)) {
-                WIN_SetError("BitBlt()");
-                return -1;
-            }
-        } else {
-            if (!StretchBlt
-                (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
-                 dstrect->h, data->memory_hdc, srcrect->x, srcrect->y,
-                 srcrect->w, srcrect->h, SRCCOPY)) {
-                WIN_SetError("StretchBlt()");
-                return -1;
-            }
-        }
-    }
-    return 0;
-}
-
-static int
-GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                     Uint32 format, void * pixels, int pitch)
-{
-    GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    struct {
-        HBITMAP hbm;
-        void *pixels;
-        int pitch;
-        Uint32 format;
-    } data;
-
-    data.format = display->current_mode.format;
-    data.pitch = (rect->w * SDL_BYTESPERPIXEL(data.format));
-
-    data.hbm = GDI_CreateDIBSection(renderdata->memory_hdc, rect->w, rect->h,
-                                    data.pitch, data.format, NULL,
-                                    &data.pixels);
-    if (!data.hbm) {
-        WIN_SetError("Couldn't create bitmap");
-        return -1;
-    }
-
-    SelectObject(renderdata->memory_hdc, data.hbm);
-    if (!BitBlt(renderdata->memory_hdc, 0, 0, rect->w, rect->h,
-                renderdata->current_hdc, rect->x, rect->y, SRCCOPY)) {
-        WIN_SetError("BitBlt()");
-        DeleteObject(data.hbm);
-        return -1;
-    }
-
-    SDL_ConvertPixels(rect->w, rect->h,
-                      data.format, data.pixels, data.pitch,
-                      format, pixels, pitch);
-
-    DeleteObject(data.hbm);
-    return 0;
-}
-
-static int
-GDI_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                      Uint32 format, const void * pixels, int pitch)
-{
-    GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    struct {
-        HBITMAP hbm;
-        void *pixels;
-        int pitch;
-        Uint32 format;
-    } data;
-
-    data.format = display->current_mode.format;
-    data.pitch = (rect->w * SDL_BYTESPERPIXEL(data.format));
-
-    data.hbm = GDI_CreateDIBSection(renderdata->memory_hdc, rect->w, rect->h,
-                                    data.pitch, data.format,
-                                    NULL, &data.pixels);
-    if (!data.hbm) {
-        WIN_SetError("Couldn't create bitmap");
-        return -1;
-    }
-
-    SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch,
-                      data.format, data.pixels, data.pitch);
-
-    SelectObject(renderdata->memory_hdc, data.hbm);
-    if (!BitBlt(renderdata->current_hdc, rect->x, rect->y, rect->w, rect->h,
-                renderdata->memory_hdc, 0, 0, SRCCOPY)) {
-        WIN_SetError("BitBlt()");
-        DeleteObject(data.hbm);
-        return -1;
-    }
-
-    DeleteObject(data.hbm);
-    return 0;
-}
-
-static void
-GDI_RenderPresent(SDL_Renderer * renderer)
-{
-    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
-    SDL_DirtyRect *dirty;
-
-    /* Send the data to the display */
-    if (!(renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)) {
-        for (dirty = data->dirty.list; dirty; dirty = dirty->next) {
-            const SDL_Rect *rect = &dirty->rect;
-            BitBlt(data->window_hdc, rect->x, rect->y, rect->w, rect->h,
-                   data->render_hdc, rect->x, rect->y, SRCCOPY);
-        }
-        SDL_ClearDirtyRects(&data->dirty);
-    }
-
-    /* Update the flipping chain, if any */
-    if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
-        data->current_hbm = (data->current_hbm + 1) % 2;
-        SelectObject(data->render_hdc, data->hbm[data->current_hbm]);
-    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
-        data->current_hbm = (data->current_hbm + 1) % 3;
-        SelectObject(data->render_hdc, data->hbm[data->current_hbm]);
-    }
-}
-
-static void
-GDI_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
-
-    if (!data) {
-        return;
-    }
-    if (data->yuv) {
-        SDL_SW_DestroyYUVTexture(data->yuv);
-    }
-    if (data->hpal) {
-        DeleteObject(data->hpal);
-    }
-    if (data->hbm) {
-        DeleteObject(data->hbm);
-    }
-    SDL_free(data);
-    texture->driverdata = NULL;
-}
-
-static void
-GDI_DestroyRenderer(SDL_Renderer * renderer)
-{
-    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
-    int i;
-
-    if (data) {
-        DeleteDC(data->render_hdc);
-        DeleteDC(data->memory_hdc);
-#ifndef NO_GETDIBBITS
-        if (data->bmi) {
-            SDL_free(data->bmi);
-        }
-#endif
-        for (i = 0; i < SDL_arraysize(data->hbm); ++i) {
-            if (data->hbm[i]) {
-                DeleteObject(data->hbm[i]);
-            }
-        }
-        SDL_FreeDirtyRects(&data->dirty);
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-#endif /* SDL_VIDEO_RENDER_GDI */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_gdirender.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* SDL surface based renderer implementation */
-
-#if SDL_VIDEO_RENDER_GDI
-extern void GDI_AddRenderDriver(_THIS);
-#endif
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_windowsevents.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/windows/SDL_windowsevents.c	Sun Feb 06 21:23:32 2011 -0800
@@ -195,14 +195,12 @@
         /* transform coords for VGA, WVGA... */
         {
             SDL_VideoData *videodata = data->videodata;
-            if(videodata->CoordTransform &&
-                (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
-            {
+            if(videodata->CoordTransform) {
                 POINT pt;
                 pt.x = LOWORD(lParam);
                 pt.y = HIWORD(lParam);
                 videodata->CoordTransform(data->window, &pt);
-                    SDL_SendMouseMotion(data->window, 0, pt.x, pt.y);
+                SDL_SendMouseMotion(data->window, 0, pt.x, pt.y);
                 break;
             }
         }
@@ -503,25 +501,6 @@
         }
         break;
 
-        /* We are about to get palette focus! */
-    case WM_QUERYNEWPALETTE:
-        {
-            /*
-                WIN_RealizePalette(current_video);
-                returnCode = TRUE;
-             */
-        }
-        break;
-
-        /* Another application changed the palette */
-    case WM_PALETTECHANGED:
-        {
-            /*
-               WIN_PaletteChanged(current_video, (HWND) wParam);
-             */
-        }
-        break;
-
         /* We were occluded, refresh our display */
     case WM_PAINT:
         {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windows/SDL_windowsframebuffer.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,125 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_windowsvideo.h"
+
+#ifndef _WIN32_WCE
+#define HAVE_GETDIBITS
+#endif
+
+int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
+{
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+    size_t size;
+    LPBITMAPINFO info;
+#ifdef HAVE_GETDIBITS
+    HBITMAP hbm;
+#endif
+
+    /* Free the old framebuffer surface */
+    if (data->mdc) {
+        DeleteDC(data->mdc);
+    }
+    if (data->hbm) {
+        DeleteObject(data->hbm);
+    }
+
+    /* Find out the format of the screen */
+    size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD);
+    info = (LPBITMAPINFO)SDL_stack_alloc(Uint8, size);
+
+#ifdef HAVE_GETDIBITS
+    SDL_memset(info, 0, size);
+    info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+
+    /* The second call to GetDIBits() fills in the bitfields */
+    hbm = CreateCompatibleBitmap(data->hdc, 1, 1);
+    GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS);
+    GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS);
+    DeleteObject(hbm);
+
+    *format = SDL_PIXELFORMAT_UNKNOWN;
+    if (info->bmiHeader.biCompression == BI_BITFIELDS) {
+        int bpp;
+        Uint32 *masks;
+
+        bpp = info->bmiHeader.biPlanes * info->bmiHeader.biBitCount;
+        masks = (Uint32*)((Uint8*)info + info->bmiHeader.biSize);
+        *format = SDL_MasksToPixelFormatEnum(bpp, masks[0], masks[1], masks[2], 0);
+    }
+    if (*format == SDL_PIXELFORMAT_UNKNOWN)
+#endif
+    {
+        /* We'll use RGB format for now */
+        *format = SDL_PIXELFORMAT_RGB888;
+
+        /* Create a new one */
+        SDL_memset(info, 0, size);
+        info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+        info->bmiHeader.biPlanes = 1;
+        info->bmiHeader.biBitCount = 32;
+        info->bmiHeader.biCompression = BI_RGB;
+    }
+
+    /* Fill in the size information */
+    *pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
+    info->bmiHeader.biWidth = window->w;
+    info->bmiHeader.biHeight = -window->h;	/* negative for topdown bitmap */
+    info->bmiHeader.biSizeImage = window->h * (*pitch);
+
+    data->mdc = CreateCompatibleDC(data->hdc);
+    data->hbm = CreateDIBSection(data->hdc, info, DIB_RGB_COLORS, pixels, NULL, 0);
+    SDL_stack_free(info);
+
+    if (!data->hbm) {
+        WIN_SetError("Unable to create DIB");
+        return -1;
+    }
+    SelectObject(data->mdc, data->hbm);
+
+    return 0;
+}
+
+int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, int numrects, SDL_Rect * rects)
+{
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+
+    BitBlt(data->hdc, 0, 0, window->w, window->h, data->mdc, 0, 0, SRCCOPY);
+    return 0;
+}
+
+void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
+{
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+
+    if (data->mdc) {
+        DeleteDC(data->mdc);
+        data->mdc = NULL;
+    }
+    if (data->hbm) {
+        DeleteObject(data->hbm);
+        data->hbm = NULL;
+    }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windows/SDL_windowsframebuffer.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,28 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+extern int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
+extern int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, int numrects, SDL_Rect * rects);
+extern void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_windowskeyboard.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/windows/SDL_windowskeyboard.c	Sun Feb 06 21:23:32 2011 -0800
@@ -116,7 +116,6 @@
     data->ime_candlistindexbase = 0;
     data->ime_candvertical = SDL_TRUE;
 
-    data->ime_candtex = NULL;
     data->ime_dirty = SDL_FALSE;
     SDL_memset(&data->ime_rect, 0, sizeof(data->ime_rect));
     SDL_memset(&data->ime_candlistrect, 0, sizeof(data->ime_candlistrect));
@@ -1274,36 +1273,6 @@
     }
 }
 
-static void
-BitmapToTexture(HBITMAP hbm, BYTE *bits, int width, int height, SDL_Texture **texture)
-{
-    SDL_Surface *surface = NULL;
-    BITMAP bm = {0};
-
-    if (GetObject(hbm, sizeof(bm), &bm) == 0)
-        return;
-
-    if (bits && texture) {
-        /*
-            For transparency:
-
-            const Uint8 alpha = 130;
-            unsigned long *p = (unsigned long *)bits;
-            unsigned long *end = (unsigned long *)(bits + (bm.bmWidthBytes * bm.bmHeight));
-            while (p < end) {
-                *p = RGB(GetRValue(*p), GetGValue(*p), GetBValue(*p)) | (alpha << 24);
-                ++p;
-            }
-            surface = SDL_CreateRGBSurfaceFrom(bits, width, height, bm.bmBitsPixel, bm.bmWidthBytes, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
-        */
-        surface = SDL_CreateRGBSurfaceFrom(bits, width, height, bm.bmBitsPixel, bm.bmWidthBytes, 0x00ff0000, 0x0000ff00, 0x000000ff, 0);
-        if (surface) {
-            *texture = SDL_CreateTextureFromSurface(0, surface);
-            SDL_FreeSurface(surface);
-        }
-    }
-}
-
 /* This draws only within the specified area and fills the entire region. */
 static void
 DrawRect(HDC hdc, int left, int top, int right, int bottom, int pensize)
@@ -1318,18 +1287,8 @@
 }
 
 static void
-DestroyTexture(SDL_Texture **texture)
-{
-    if (texture && *texture) {
-        SDL_DestroyTexture(*texture);
-        *texture = NULL;
-    }
-}
-
-static void
 IME_DestroyTextures(SDL_VideoData *videodata)
 {
-    DestroyTexture(&videodata->ime_candtex);
 }
 
 #define SDL_swap(a,b) { \
@@ -1544,7 +1503,6 @@
         DrawRect(hdc, left, top, right, bottom, candborder);
         ExtTextOutW(hdc, left + candborder + candpadding, top + candborder + candpadding, 0, NULL, s, SDL_wcslen(s), NULL);
     }
-    BitmapToTexture(hbm, bits, size.cx, size.cy, &videodata->ime_candtex);
     StopDrawToBitmap(hdc, &hbm);
 
     DeleteObject(listpen);
@@ -1576,7 +1534,7 @@
     if (videodata->ime_dirty)
         IME_Render(videodata);
 
-    SDL_RenderCopy(videodata->ime_candtex, NULL, &videodata->ime_candlistrect);
+    // FIXME: Need to show the IME bitmap
 }
 
 #endif /* SDL_DISABLE_WINDOWS_IME */
--- a/src/video/windows/SDL_windowsmodes.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/windows/SDL_windowsmodes.c	Sun Feb 06 21:23:32 2011 -0800
@@ -131,6 +131,10 @@
             }
         }
     }
+    if (SDL_ISPIXELFORMAT_INDEXED(mode->format)) {
+        /* We don't support palettized modes now */
+        return SDL_FALSE;
+    }
     return SDL_TRUE;
 }
 
--- a/src/video/windows/SDL_windowsvideo.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/windows/SDL_windowsvideo.c	Sun Feb 06 21:23:32 2011 -0800
@@ -28,10 +28,8 @@
 #include "../SDL_pixels_c.h"
 
 #include "SDL_windowsvideo.h"
+#include "SDL_windowsframebuffer.h"
 #include "SDL_windowsshape.h"
-#include "SDL_d3drender.h"
-#include "SDL_gdirender.h"
-#include "SDL_gapirender.h"
 
 /* Initialization/Query functions */
 static int WIN_VideoInit(_THIS);
@@ -52,18 +50,6 @@
     SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
 
     SDL_UnregisterApp();
-#if SDL_VIDEO_RENDER_D3D
-    if (data->d3d) {
-        IDirect3D9_Release(data->d3d);
-        SDL_UnloadObject(data->d3dDLL);
-    }
-#endif
-#if SDL_VIDEO_RENDER_DDRAW
-    if (data->ddraw) {
-        data->ddraw->lpVtbl->Release(data->ddraw);
-        SDL_UnloadObject(data->ddrawDLL);
-    }
-#endif
 #ifdef _WIN32_WCE
     if(data->hAygShell) {
        SDL_UnloadObject(data->hAygShell);
@@ -101,42 +87,6 @@
     }
     device->driverdata = data;
 
-#if SDL_VIDEO_RENDER_D3D
-    data->d3dDLL = SDL_LoadObject("D3D9.DLL");
-    if (data->d3dDLL) {
-        IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);
-
-        D3DCreate =
-            (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(data->d3dDLL,
-                                                            "Direct3DCreate9");
-        if (D3DCreate) {
-            data->d3d = D3DCreate(D3D_SDK_VERSION);
-        }
-        if (!data->d3d) {
-            SDL_UnloadObject(data->d3dDLL);
-            data->d3dDLL = NULL;
-        }
-    }
-#endif /* SDL_VIDEO_RENDER_D3D */
-#if SDL_VIDEO_RENDER_DDRAW
-    data->ddrawDLL = SDL_LoadObject("ddraw.dll");
-    if (data->ddrawDLL) {
-        IDirectDraw *(WINAPI * DDCreate) (GUID FAR * lpGUID,
-                                          LPDIRECTDRAW FAR * lplpDD,
-                                          IUnknown FAR * pUnkOuter);
-
-        DDCreate =
-            (IDirectDraw *
-             (WINAPI *) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *))
-            SDL_LoadFunction(data->ddrawDLL, "DirectDrawCreate");
-        if (!DDCreate || DDCreate(NULL, &data->ddraw, NULL) != DD_OK) {
-            SDL_UnloadObject(data->ddrawDLL);
-            data->ddrawDLL = NULL;
-            data->ddraw = NULL;
-        }
-    }
-#endif /* SDL_VIDEO_RENDER_DDRAW */
-
 #ifdef _WIN32_WCE
     data->hAygShell = SDL_LoadObject("\\windows\\aygshell.dll");
     if(0 == data->hAygShell)
@@ -179,6 +129,9 @@
     device->SetWindowGrab = WIN_SetWindowGrab;
     device->DestroyWindow = WIN_DestroyWindow;
     device->GetWindowWMInfo = WIN_GetWindowWMInfo;
+    device->CreateWindowFramebuffer = WIN_CreateWindowFramebuffer;
+    device->UpdateWindowFramebuffer = WIN_UpdateWindowFramebuffer;
+    device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer;
     
     device->shape_driver.CreateShaper = Win32_CreateShaper;
     device->shape_driver.SetWindowShape = Win32_SetWindowShape;
@@ -219,19 +172,6 @@
         return -1;
     }
 
-#if SDL_VIDEO_RENDER_D3D
-    D3D_AddRenderDriver(_this);
-#endif
-#if SDL_VIDEO_RENDER_DDRAW
-    DDRAW_AddRenderDriver(_this);
-#endif
-#if SDL_VIDEO_RENDER_GDI
-    GDI_AddRenderDriver(_this);
-#endif
-#if SDL_VIDEO_RENDER_GAPI
-    WINCE_AddRenderDriver(_this);
-#endif
-
     WIN_InitKeyboard(_this);
     WIN_InitMouse(_this);
 
--- a/src/video/windows/SDL_windowsvideo.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/windows/SDL_windowsvideo.h	Sun Feb 06 21:23:32 2011 -0800
@@ -39,18 +39,6 @@
 #define MAX_CANDLIST    10
 #define MAX_CANDLENGTH  256
 
-#if SDL_VIDEO_RENDER_D3D
-//#include <d3d9.h>
-#define D3D_DEBUG_INFO
-#include "d3d9.h"
-#endif
-
-#if SDL_VIDEO_RENDER_DDRAW
-/* WIN32_LEAN_AND_MEAN was defined, so we have to include this by hand */
-#include <objbase.h>
-#include "ddraw.h"
-#endif
-
 #include "SDL_windowsclipboard.h"
 #include "SDL_windowsevents.h"
 #include "SDL_windowsgamma.h"
@@ -63,8 +51,6 @@
 #include "SDL_loadso.h"
 
 
-enum { RENDER_NONE, RENDER_D3D, RENDER_DDRAW, RENDER_GDI, RENDER_GAPI, RENDER_RAW };
-
 #if WINVER < 0x0601
 /* Touch input definitions */
 #define TWF_FINETOUCH	1
@@ -131,14 +117,6 @@
 {
     int render;
 
-#if SDL_VIDEO_RENDER_D3D
-    void* d3dDLL;
-    IDirect3D9 *d3d;
-#endif
-#if SDL_VIDEO_RENDER_DDRAW
-    void* ddrawDLL;
-    IDirectDraw *ddraw;
-#endif
 #ifdef _WIN32_WCE
     void* hAygShell;
     PFNSHFullScreen SHFullScreen;
@@ -176,7 +154,6 @@
     int ime_candlistindexbase;
     SDL_bool ime_candvertical;
 
-    SDL_Texture *ime_candtex;
     SDL_bool ime_dirty;
     SDL_Rect ime_rect;
     SDL_Rect ime_candlistrect;
--- a/src/video/windows/SDL_windowswindow.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/windows/SDL_windowswindow.c	Sun Feb 06 21:23:32 2011 -0800
@@ -30,7 +30,6 @@
 
 /* This is included after SDL_windowsvideo.h, which includes windows.h */
 #include "SDL_syswm.h"
-#include "SDL_gapirender.h"
 
 /* Windows CE compatibility */
 #ifndef SWP_NOCOPYBITS
@@ -453,7 +452,37 @@
     h = (rect.bottom - rect.top);
 
     SetWindowPos(hwnd, top, 0, 0, w, h, (SWP_NOCOPYBITS | SWP_NOMOVE));
+}
+
+#ifdef _WIN32_WCE
+void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible)
+{
+    SDL_WindowData* windowdata = (SDL_WindowData*) window->driverdata;
+    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
+
+    if(visible) {
+        if(window->flags & SDL_WINDOW_FULLSCREEN) {
+            if(videodata->SHFullScreen)
+                videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
+
+            ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE);
+        }
+
+        ShowWindow(windowdata->hwnd, SW_SHOW);
+        SetForegroundWindow(windowdata->hwnd);
+    } else {
+        ShowWindow(windowdata->hwnd, SW_HIDE);
+
+        if(window->flags & SDL_WINDOW_FULLSCREEN) {
+            if(videodata->SHFullScreen)
+                videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
+
+            ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW);
+
+        }
+    }
 }
+#endif /* _WIN32_WCE */
 
 void
 WIN_ShowWindow(_THIS, SDL_Window * window)
--- a/src/video/windows/SDL_windowswindow.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/windows/SDL_windowswindow.h	Sun Feb 06 21:23:32 2011 -0800
@@ -38,6 +38,8 @@
     SDL_Window *window;
     HWND hwnd;
     HDC hdc;
+    HDC mdc;
+    HBITMAP hbm;
     WNDPROC wndproc;
     SDL_bool created;
     int mouse_pressed;
--- a/src/video/x11/SDL_x11dyn.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/x11/SDL_x11dyn.h	Sun Feb 06 21:23:32 2011 -0800
@@ -52,18 +52,6 @@
 #include <X11/extensions/XInput.h>
 #endif
 
-#if SDL_VIDEO_DRIVER_X11_XRENDER
-#include <X11/extensions/Xrender.h>
-#endif
-
-#if SDL_VIDEO_DRIVER_X11_XDAMAGE
-#include <X11/extensions/Xdamage.h>
-#endif
-
-#if SDL_VIDEO_DRIVER_X11_XFIXES
-#include <X11/extensions/Xfixes.h>
-#endif
-
 /*
  * When using the "dynamic X11" functionality, we duplicate all the Xlib
  *  symbols that would be referenced by SDL inside of SDL itself.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11framebuffer.c	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,214 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2009 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_x11video.h"
+#include "SDL_x11framebuffer.h"
+
+
+#ifndef NO_SHARED_MEMORY
+
+/* Shared memory error handler routine */
+static int shm_error;
+static int (*X_handler)(Display *, XErrorEvent *) = NULL;
+static int shm_errhandler(Display *d, XErrorEvent *e)
+{
+        if ( e->error_code == BadAccess ) {
+            shm_error = True;
+            return(0);
+        } else
+        return(X_handler(d,e));
+}
+
+static SDL_bool have_mitshm(void)
+{
+    /* Only use shared memory on local X servers */
+    if ( (SDL_strncmp(XDisplayName(NULL), ":", 1) == 0) ||
+         (SDL_strncmp(XDisplayName(NULL), "unix:", 5) == 0) ) {
+        return SDL_X11_HAVE_SHM;
+    }
+    return SDL_FALSE;
+}
+
+#endif /* !NO_SHARED_MEMORY */
+
+int
+X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format,
+                            void ** pixels, int *pitch)
+{
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+    Display *display = data->videodata->display;
+    XGCValues gcv;
+    XVisualInfo vinfo;
+
+    /* Free the old framebuffer surface */
+    X11_DestroyWindowFramebuffer(_this, window);
+
+    /* Create the graphics context for drawing */
+    gcv.graphics_exposures = False;
+    data->gc = XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv);
+    if (!data->gc) {
+        SDL_SetError("Couldn't create graphics context");
+        return -1;
+    }
+
+    /* Find out the pixel format and depth */
+    if (X11_GetVisualInfoFromVisual(display, data->visual, &vinfo) < 0) {
+        SDL_SetError("Couldn't get window visual information");
+        return -1;
+    }
+
+    *format = X11_GetPixelFormatFromVisualInfo(display, &vinfo);
+    if (*format == SDL_PIXELFORMAT_UNKNOWN) {
+        SDL_SetError("Unknown window pixel format");
+        return -1;
+    }
+
+    /* Calculate pitch */
+    *pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
+
+    /* Create the actual image */
+#ifndef NO_SHARED_MEMORY
+    if (have_mitshm()) {
+        XShmSegmentInfo *shminfo = &data->shminfo;
+
+        shminfo->shmid = shmget(IPC_PRIVATE, window->h*(*pitch), IPC_CREAT | 0777);
+        if ( shminfo->shmid >= 0 ) {
+            shminfo->shmaddr = (char *)shmat(shminfo->shmid, 0, 0);
+            shminfo->readOnly = False;
+            if ( shminfo->shmaddr != (char *)-1 ) {
+                shm_error = False;
+                X_handler = XSetErrorHandler(shm_errhandler);
+                XShmAttach(display, shminfo);
+                XSync(display, True);
+                XSetErrorHandler(X_handler);
+                if ( shm_error )
+                    shmdt(shminfo->shmaddr);
+            } else {
+                shm_error = True;
+            }
+            shmctl(shminfo->shmid, IPC_RMID, NULL);
+        } else {
+            shm_error = True;
+        }
+        if (!shm_error) {
+            data->ximage = XShmCreateImage(display, data->visual,
+                             vinfo.depth, ZPixmap,
+                             shminfo->shmaddr, shminfo, 
+                             window->w, window->h);
+            if (!data->ximage) {
+                XShmDetach(display, shminfo);
+                XSync(display, False);
+                shmdt(shminfo->shmaddr);
+            } else {
+                /* Done! */
+                data->use_mitshm = SDL_TRUE;
+                *pixels = shminfo->shmaddr;
+                return 0;
+            }
+        }
+    }
+#endif /* not NO_SHARED_MEMORY */
+
+    *pixels = SDL_malloc(window->h*(*pitch));
+    if (*pixels == NULL) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+
+    data->ximage = XCreateImage(display, data->visual,
+                      vinfo.depth, ZPixmap, 0, (char *)(*pixels), 
+                      window->w, window->h, 32, 0);
+    if (!data->ximage) {
+        SDL_free(*pixels);
+        SDL_SetError("Couldn't create XImage");
+        return -1;
+    }
+    return 0;
+}
+
+int
+X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
+                            int numrects, SDL_Rect * rects)
+{
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+    Display *display = data->videodata->display;
+    int i;
+    SDL_Rect *rect;
+
+#ifndef NO_SHARED_MEMORY
+    if (data->use_mitshm) {
+        for (i = 0; i < numrects; ++i) {
+            rect = &rects[i];
+
+            if (rect->w == 0 || rect->h == 0) { /* Clipped? */
+                continue;
+            }
+            XShmPutImage(display, data->xwindow, data->gc, data->ximage,
+                    rect->x, rect->y,
+                    rect->x, rect->y, rect->w, rect->h, False);
+        }
+    }
+    else
+#endif /* !NO_SHARED_MEMORY */
+    {
+        for (i = 0; i < numrects; ++i) {
+            rect = &rects[i];
+
+            if (rect->w == 0 || rect->h == 0) { /* Clipped? */
+                continue;
+            }
+            XPutImage(display, data->xwindow, data->gc, data->ximage,
+                  rect->x, rect->y,
+                  rect->x, rect->y, rect->w, rect->h);
+        }
+    }
+    XSync(display, False);
+}
+
+void
+X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
+{
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+    Display *display = data->videodata->display;
+
+    if (data->ximage) {
+        XDestroyImage(data->ximage);
+
+#ifndef NO_SHARED_MEMORY
+        if (data->use_mitshm) {
+            XShmDetach(display, &data->shminfo);
+            XSync(display, False);
+            shmdt(data->shminfo.shmaddr);
+            data->use_mitshm = SDL_FALSE;
+        }
+#endif /* !NO_SHARED_MEMORY */
+
+        data->ximage = NULL;
+    }
+    if (data->gc) {
+        XFreeGC(display, data->gc);
+        data->gc = NULL;
+    }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11framebuffer.h	Sun Feb 06 21:23:32 2011 -0800
@@ -0,0 +1,32 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2009 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+
+extern int X11_CreateWindowFramebuffer(_THIS, SDL_Window * window,
+                                       Uint32 * format,
+                                       void ** pixels, int *pitch);
+extern int X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
+                                       int numrects, SDL_Rect * rects);
+extern void X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/x11/SDL_x11modes.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/x11/SDL_x11modes.c	Sun Feb 06 21:23:32 2011 -0800
@@ -57,7 +57,23 @@
     return -1;
 }
 
-static Uint32
+int
+X11_GetVisualInfoFromVisual(Display * display, Visual * visual, XVisualInfo * vinfo)
+{
+    XVisualInfo *vi;
+    int nvis;
+
+    vinfo->visualid = XVisualIDFromVisual(visual);
+    vi = XGetVisualInfo(display, VisualIDMask, vinfo, &nvis);
+    if (vi) {
+        *vinfo = *vi;
+        XFree(vi);
+        return 0;
+    }
+    return -1;
+}
+
+Uint32
 X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo)
 {
     if (vinfo->class == DirectColor || vinfo->class == TrueColor) {
@@ -134,6 +150,10 @@
         }
 
         mode.format = X11_GetPixelFormatFromVisualInfo(data->display, &vinfo);
+        if (SDL_ISPIXELFORMAT_INDEXED(mode.format)) {
+            /* We don't support palettized modes now */
+            continue;
+        }
         mode.w = DisplayWidth(data->display, screen);
         mode.h = DisplayHeight(data->display, screen);
         mode.refresh_rate = 0;
--- a/src/video/x11/SDL_x11modes.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/x11/SDL_x11modes.h	Sun Feb 06 21:23:32 2011 -0800
@@ -59,6 +59,12 @@
 extern int X11_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
 extern void X11_QuitModes(_THIS);
 
+/* Some utility functions for working with visuals */
+extern int X11_GetVisualInfoFromVisual(Display * display, Visual * visual,
+                                       XVisualInfo * vinfo);
+extern Uint32 X11_GetPixelFormatFromVisualInfo(Display * display,
+                                               XVisualInfo * vinfo);
+
 #endif /* _SDL_x11modes_h */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/x11/SDL_x11render.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2360 +0,0 @@
-/*
-
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_X11
-
-#include <limits.h> /* For INT_MIN and INT_MAX */
-
-#include "SDL_x11video.h"
-#include "SDL_x11render.h"
-#include "../SDL_rect_c.h"
-#include "../SDL_pixels_c.h"
-#include "../SDL_yuv_sw_c.h"
-
-/* X11 renderer implementation */
-
-static SDL_Renderer *X11_CreateRenderer(SDL_Window * window, Uint32 flags);
-static int X11_DisplayModeChanged(SDL_Renderer * renderer);
-static int X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int X11_QueryTexturePixels(SDL_Renderer * renderer,
-                                  SDL_Texture * texture, void **pixels,
-                                  int *pitch);
-static int X11_SetTextureRGBAMod(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
-static int X11_SetTextureBlendMode(SDL_Renderer * renderer,
-                                   SDL_Texture * texture);
-static int X11_SetTextureScaleMode(SDL_Renderer * renderer,
-                                   SDL_Texture * texture);
-static int X11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                             const SDL_Rect * rect, const void *pixels,
-                             int pitch);
-static int X11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                           const SDL_Rect * rect, int markDirty,
-                           void **pixels, int *pitch);
-static void X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int X11_SetDrawBlendMode(SDL_Renderer * renderer);
-static int X11_RenderDrawPoints(SDL_Renderer * renderer,
-                                const SDL_Point * points, int count);
-static int X11_RenderDrawLines(SDL_Renderer * renderer,
-                               const SDL_Point * points, int count);
-static int X11_RenderDrawRects(SDL_Renderer * renderer,
-                               const SDL_Rect ** rects, int count);
-static int X11_RenderFillRects(SDL_Renderer * renderer,
-                               const SDL_Rect ** rects, int count);
-static int X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * srcrect, const SDL_Rect * dstrect);
-static int X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                Uint32 format, void * pixels, int pitch);
-static int X11_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                 Uint32 format, const void * pixels, int pitch);
-static void X11_RenderPresent(SDL_Renderer * renderer);
-static void X11_DestroyTexture(SDL_Renderer * renderer,
-                               SDL_Texture * texture);
-static void X11_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver X11_RenderDriver = {
-    X11_CreateRenderer,
-    {
-     "x11",
-     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
-      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
-      SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
-     SDL_TEXTUREMODULATE_NONE,
-     SDL_BLENDMODE_NONE,
-     SDL_SCALEMODE_NONE,
-     0,
-     {0},
-     0,
-     0}
-};
-
-typedef struct
-{
-    Display *display;
-    int screen;
-    Visual *visual;
-    int depth;
-    int scanline_pad;
-    Window xwindow;
-    Pixmap pixmaps[3];
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    Pixmap stencil;
-    Pixmap brush;
-    Picture brush_pict;
-    Picture xwindow_pict;
-    Picture pixmap_picts[3];
-    Picture drawable_pict;
-    Picture stencil_pict;
-    int blend_op;
-    XRenderPictFormat *xwindow_pict_fmt;
-    XRenderPictFormat *drawable_pict_fmt;
-    GC stencil_gc;
-    SDL_bool use_xrender;
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-    SDL_bool use_xdamage;
-    Damage stencil_damage;
-    XserverRegion stencil_parts;
-#endif
-#endif
-    int current_pixmap;
-    Drawable drawable;
-    SDL_PixelFormat format;
-    GC gc;
-    SDL_DirtyRectList dirty;
-    SDL_bool makedirty;
-} X11_RenderData;
-
-typedef struct
-{
-    SDL_SW_YUVTexture *yuv;
-    Uint32 format;
-    Pixmap pixmap;
-    int depth;
-    Visual *visual;
-    GC gc;
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    Picture picture;
-    Pixmap modulated_pixmap;
-    Picture modulated_picture;
-    XRenderPictFormat* picture_fmt;
-    int blend_op;
-    const char* filter;
-#endif
-    XImage *image;
-#ifndef NO_SHARED_MEMORY
-    /* MIT shared memory extension information */
-    XShmSegmentInfo shminfo;
-#endif
-    XImage *scaling_image;
-    void *pixels;
-    int pitch;
-} X11_TextureData;
-
-#ifndef NO_SHARED_MEMORY
-/* Shared memory error handler routine */
-static int shm_error;
-static int (*X_handler) (Display *, XErrorEvent *) = NULL;
-static int
-shm_errhandler(Display * d, XErrorEvent * e)
-{
-    if (e->error_code == BadAccess) {
-        shm_error = True;
-        return (0);
-    } else {
-        return (X_handler(d, e));
-    }
-}
-#endif /* ! NO_SHARED_MEMORY */
-
-static void
-UpdateYUVTextureData(SDL_Texture * texture)
-{
-    X11_TextureData *data = (X11_TextureData *) texture->driverdata;
-    SDL_Rect rect;
-
-    rect.x = 0;
-    rect.y = 0;
-    rect.w = texture->w;
-    rect.h = texture->h;
-    SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w,
-                        texture->h, data->pixels, data->pitch);
-}
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-static SDL_bool
-CheckXRender(Display *display, int *major, int *minor)
-{
-    const char *env;
-
-    *major = *minor = 0;
-
-    env = SDL_getenv("SDL_VIDEO_X11_XRENDER");
-
-    if (env && !SDL_atoi(env)) {
-        return SDL_FALSE;
-    }
-
-    if (!SDL_X11_HAVE_XRENDER) {
-        return SDL_FALSE;
-    }
-
-    if (!XRenderQueryVersion(display, major, minor)) {
-        return SDL_FALSE;
-    }
-
-    if (*major != 0 || *minor < 10) {
-        return SDL_FALSE;
-    }
-
-    return SDL_TRUE;
-}
-#endif
-
-#ifdef SDL_VIDEO_DRIVER_X11_XFIXES
-static SDL_bool
-CheckXFixes(Display *display, int *major, int *minor)
-{
-    const char *env;
-
-    *major = *minor = 0;
-
-    env = SDL_getenv("SDL_VIDEO_X11_XFIXES");
-
-    if (env && !SDL_atoi(env)) {
-        return SDL_FALSE;
-    }
-
-    if (!SDL_X11_HAVE_XFIXES) {
-        return SDL_FALSE;
-    }
-
-    if (!XFixesQueryVersion(display, major, minor)) {
-        return SDL_FALSE;
-    }
-
-    if (*major < 2) {
-        return SDL_FALSE;
-    }
-
-    return SDL_TRUE;
-}
-#endif
-
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-static SDL_bool
-CheckXDamage(Display *display, int *major, int *minor)
-{
-    const char *env;
-
-    *major = *minor = 0;
-
-    env = SDL_getenv("SDL_VIDEO_X11_XDAMAGE");
-
-    if (env && !SDL_atoi(env)) {
-        return SDL_FALSE;
-    }
-
-    if (!SDL_X11_HAVE_XDAMAGE) {
-        return SDL_FALSE;
-    }
-
-    if (!XDamageQueryVersion(display, major, minor)) {
-        return SDL_FALSE;
-    }
-
-    return SDL_TRUE;
-}
-#endif
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-static Uint32
-XRenderPictFormatToSDLPixelFormatEnum(XRenderPictFormat *pict_format)
-{
-    if (pict_format->type != PictTypeDirect) {
-        SDL_SetError("Indexed pict formats not supported ATM");
-        return 0;
-    }
-    Uint32 Amask, Rmask, Gmask, Bmask;
-    int bpp;
-
-    Rmask = pict_format->direct.redMask << pict_format->direct.red;
-    Gmask = pict_format->direct.greenMask << pict_format->direct.green;
-    Bmask = pict_format->direct.blueMask << pict_format->direct.blue;
-    Amask = pict_format->direct.alphaMask << pict_format->direct.alpha;
-    bpp = pict_format->depth;
-
-    Uint32 format;
-    format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
-    return format;
-}
-#endif
-
-void
-X11_AddRenderDriver(_THIS)
-{
-    SDL_RendererInfo *info = &X11_RenderDriver.info;
-    SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode;
-    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    int i;
-
-    info->texture_formats[info->num_texture_formats++] = mode->format;
-    info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YV12;
-    info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
-    info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2;
-    info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY;
-    info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU;
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    int major, minor;
-    if (CheckXRender(data->display, &major, &minor)) {
-        XRenderPictFormat templ;
-        templ.type = PictTypeDirect;
-        XRenderPictFormat *pict_format;
-        Uint32 format;
-        int i = 0;
-        /* Convert each XRenderPictFormat into appropriate
-         * SDLPixelFormatEnum. */
-        while (info->num_texture_formats < 50) {
-            pict_format =
-                XRenderFindFormat(data->display, PictFormatType, &templ, i++);
-            if (pict_format) {
-                format = XRenderPictFormatToSDLPixelFormatEnum(pict_format);
-                if (format != SDL_PIXELTYPE_UNKNOWN) {
-                    info->texture_formats[info->num_texture_formats++] = format;
-                }
-            }
-            else
-                break;
-        }
-        /* Update the capabilities of the renderer. */
-        info->blend_modes |= (SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD |
-                             SDL_BLENDMODE_MOD | SDL_BLENDMODE_MASK);
-        info->scale_modes |= (SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW |
-                             SDL_SCALEMODE_BEST);
-        info->mod_modes |= (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA);
-    }
-#endif
-
-    for (i = 0; i < _this->num_displays; ++i) {
-        SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver);
-    }
-}
-
-SDL_Renderer *
-X11_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_VideoDisplay *display = window->display;
-    SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
-    SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
-    SDL_Renderer *renderer;
-    X11_RenderData *data;
-    XGCValues gcv;
-    gcv.graphics_exposures = False;
-    int i, n;
-    int bpp;
-    Uint32 Rmask, Gmask, Bmask, Amask;
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (X11_RenderData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        X11_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-    data->display = windowdata->videodata->display;
-    data->screen = displaydata->screen;
-    data->visual = displaydata->visual;
-    data->depth = displaydata->depth;
-    data->scanline_pad = displaydata->scanline_pad;
-    data->xwindow = windowdata->xwindow;
-    
-    renderer->DisplayModeChanged = X11_DisplayModeChanged;
-    renderer->CreateTexture = X11_CreateTexture;
-    renderer->QueryTexturePixels = X11_QueryTexturePixels;
-    renderer->SetTextureAlphaMod = X11_SetTextureRGBAMod;
-    renderer->SetTextureColorMod = X11_SetTextureRGBAMod;
-    renderer->SetTextureBlendMode = X11_SetTextureBlendMode;
-    renderer->SetTextureScaleMode = X11_SetTextureScaleMode;
-    renderer->UpdateTexture = X11_UpdateTexture;
-    renderer->LockTexture = X11_LockTexture;
-    renderer->UnlockTexture = X11_UnlockTexture;
-    renderer->SetDrawBlendMode = X11_SetDrawBlendMode;
-    renderer->RenderDrawPoints = X11_RenderDrawPoints;
-    renderer->RenderDrawLines = X11_RenderDrawLines;
-    renderer->RenderDrawRects = X11_RenderDrawRects;
-    renderer->RenderFillRects = X11_RenderFillRects;
-    renderer->RenderCopy = X11_RenderCopy;
-    renderer->RenderReadPixels = X11_RenderReadPixels;
-    renderer->RenderWritePixels = X11_RenderWritePixels;
-    renderer->RenderPresent = X11_RenderPresent;
-    renderer->DestroyTexture = X11_DestroyTexture;
-    renderer->DestroyRenderer = X11_DestroyRenderer;
-    renderer->info = X11_RenderDriver.info;
-    renderer->window = window;
-    renderer->driverdata = data;
-
-    renderer->info.flags = SDL_RENDERER_ACCELERATED;
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    int major, minor;
-    data->use_xrender = CheckXRender(data->display, &major, &minor);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-    if (CheckXDamage(data->display, &major, &minor)) {
-        if (CheckXFixes(data->display, &major, &minor)) {
-            data->use_xdamage = SDL_TRUE;
-        }
-    }
-#endif
-    if (data->use_xrender) {
-        /* Find the PictFormat from the visual.
-         * Should be an RGB PictFormat most of the time. */
-        data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display,
-                                                         data->visual);
-        if (!data->xwindow_pict_fmt) {
-            SDL_SetError("XRenderFindVisualFormat() failed");
-            return NULL;
-        }
-        data->xwindow_pict = XRenderCreatePicture(data->display,
-                                                  data->xwindow,
-                                                  data->xwindow_pict_fmt,
-                                                  0, NULL);
-        if (!data->xwindow_pict) {
-            SDL_SetError("XRenderCreatePicture() failed");
-            return NULL;
-        }
-        // FIXME: Clear the window. Is this required?
-        XRenderComposite(data->display,
-                         PictOpClear,
-                         data->xwindow_pict,
-                         None,
-                         data->xwindow_pict,
-                         0, 0,
-                         0, 0,
-                         0, 0,
-                         window->w, window->h);
-        /* Create a clip mask that is used for rendering primitives. */
-        data->stencil = XCreatePixmap(data->display, data->xwindow,
-                                   window->w, window->h, 32);
-        if (!data->stencil) {
-            SDL_SetError("XCreatePixmap() failed.");
-            return NULL;
-        }
-        
-        /* Create the GC for the clip mask. */
-        data->stencil_gc = XCreateGC(data->display, data->stencil,
-                                  GCGraphicsExposures, &gcv);
-        /* Set the GC parameters. */
-        XSetBackground(data->display, data->stencil_gc, 0);
-        XSetForeground(data->display, data->stencil_gc, 0);
-        XFillRectangle(data->display, data->stencil, data->stencil_gc,
-                       0, 0, window->w, window->h);
-        XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF);
-
-        /* Create an XRender Picture for the clip mask. */
-        data->stencil_pict =
-            XRenderCreatePicture(data->display, data->stencil,
-                                 XRenderFindStandardFormat(data->display,
-                                                           PictStandardARGB32),
-                                 0, NULL);
-        if (!data->stencil_pict) {
-            SDL_SetError("XRenderCreatePicture() failed.");
-            return NULL;
-        }
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-        if (data->use_xdamage) {
-            data->stencil_damage =
-                XDamageCreate(data->display, data->stencil, XDamageReportNonEmpty);
-            if (!data->stencil_damage) {
-                SDL_SetError("XDamageCreate() failed.");
-                return NULL;
-            }
-            XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts);
-        }
-#endif
-        /* Create a brush pixmap for the color being
-         * drawn at any given time. */
-        data->brush =
-            XCreatePixmap(data->display, data->xwindow, 1, 1, 32);
-        if (!data->brush) {
-            SDL_SetError("XCreatePixmap() failed.");
-            return NULL;
-        }
-
-        /* Set some parameters for the brush. */
-        XRenderPictureAttributes brush_attr;
-        brush_attr.repeat = RepeatNormal;
-        /* Create an XRender Picture for the brush
-         * with the above parameters. */
-        data->brush_pict =
-            XRenderCreatePicture(data->display, data->brush,
-                                 XRenderFindStandardFormat(data->display,
-                                                           PictStandardARGB32),
-                                 CPRepeat, &brush_attr);
-        if (!data->brush_pict) {
-            SDL_SetError("XRenderCreatePicture() failed.");
-            return NULL;
-        }
-        // FIXME: Is the following necessary?
-        /* Set the default blending mode. */
-        renderer->blendMode = SDL_BLENDMODE_BLEND;
-        data->blend_op = PictOpOver;
-    }
-#endif
-    if (flags & SDL_RENDERER_SINGLEBUFFER) {
-        renderer->info.flags |=
-            (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY);
-        n = 0;
-    } else if (flags & SDL_RENDERER_PRESENTFLIP2) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
-        n = 2;
-    } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
-        n = 3;
-    } else {
-        renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
-        n = 1;
-    }
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    if (data->use_xrender) {
-        if (n > 0)
-            data->drawable_pict_fmt =
-                XRenderFindStandardFormat(data->display, PictStandardARGB32);
-        else
-            data->drawable_pict_fmt = data->xwindow_pict_fmt;
-    }
-#endif
-    for (i = 0; i < n; ++i) {
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (data->use_xrender) {
-            data->pixmaps[i] = XCreatePixmap(data->display,
-                                             data->xwindow,
-                                             window->w,
-                                             window->h,
-                                             32);
-        }
-        else
-#endif
-        {
-            data->pixmaps[i] =
-                XCreatePixmap(data->display, data->xwindow, window->w, window->h,
-                              displaydata->depth);
-        }
-        if (!data->pixmaps[i]) {
-            X11_DestroyRenderer(renderer);
-            SDL_SetError("XCreatePixmap() failed");
-            return NULL;
-        }
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (data->use_xrender) {
-            /* Create XRender pictures for each of the pixmaps
-             * and clear the pixmaps. */
-            data->pixmap_picts[i] = 
-                XRenderCreatePicture(data->display,
-                                     data->pixmaps[i],
-                                     XRenderFindStandardFormat(data->display,
-                                                               PictStandardARGB32),
-                                     0, None);
-            if (!data->pixmap_picts[i]) {
-                SDL_SetError("XRenderCreatePicture() failed");
-                return NULL;
-            }
-
-            XRenderComposite(data->display,
-                             PictOpClear,
-                             data->pixmap_picts[i],
-                             None,
-                             data->pixmap_picts[i],
-                             0, 0,
-                             0, 0,
-                             0, 0,
-                             window->w, window->h);
-        }
-#endif
-    }
-    if (n > 0) {
-        data->drawable = data->pixmaps[0];
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if(data->use_xrender == SDL_TRUE)
-            data->drawable_pict = data->pixmap_picts[0];
-#endif
-        data->makedirty = SDL_TRUE;
-    } else {
-        data->drawable = data->xwindow;
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if(data->use_xrender == SDL_TRUE)
-            data->drawable_pict = data->xwindow_pict;
-#endif
-        data->makedirty = SDL_FALSE;
-    }
-    data->current_pixmap = 0;
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    /* When using XRender the drawable format
-     * is not the same as the screen format. */
-    if (data->use_xrender) {
-        bpp = data->drawable_pict_fmt->depth;
-        Rmask = ((data->drawable_pict_fmt->direct.redMask)
-                    << (data->drawable_pict_fmt->direct.red));
-        Gmask = ((data->drawable_pict_fmt->direct.greenMask)
-                    << (data->drawable_pict_fmt->direct.green));
-        Bmask = ((data->drawable_pict_fmt->direct.blueMask)
-                    << (data->drawable_pict_fmt->direct.blue));
-        Amask = ((data->drawable_pict_fmt->direct.alphaMask)
-                    << (data->drawable_pict_fmt->direct.alpha));
-    }
-    else
-#endif
-    {
-        /* Get the format of the window */
-        if (!SDL_PixelFormatEnumToMasks
-            (display->current_mode.format, &bpp, &Rmask, &Gmask, &Bmask,
-             &Amask)) {
-            SDL_SetError("Unknown display format");
-            X11_DestroyRenderer(renderer);
-            return NULL;
-        }
-    }
-    SDL_InitFormat(&data->format, bpp, Rmask, Gmask, Bmask, Amask);
-
-    /* Create the drawing context */
-    gcv.graphics_exposures = False;
-    data->gc =
-        XCreateGC(data->display, data->drawable, GCGraphicsExposures, &gcv);
-    if (!data->gc) {
-        X11_DestroyRenderer(renderer);
-        SDL_SetError("XCreateGC() failed");
-        return NULL;
-    }
-
-    return renderer;
-}
-
-static int
-X11_DisplayModeChanged(SDL_Renderer * renderer)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    int i, n;
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    if (data->use_xrender) {
-        XRenderFreePicture(data->display, data->xwindow_pict);
-        
-        data->xwindow_pict_fmt =
-            XRenderFindVisualFormat(data->display, data->visual);
-        if (!data->xwindow_pict_fmt) {
-            SDL_SetError("XRenderFindVisualFormat() failed.");
-            return -1;
-        }
-
-        data->xwindow_pict =
-            XRenderCreatePicture(data->display, data->xwindow,
-                                 data->xwindow_pict_fmt, 0, NULL);
-        if (!data->xwindow_pict) {
-            SDL_SetError("XRenderCreatePicture() failed.");
-            return -1;
-        }
-
-        XRenderComposite(data->display,
-                         PictOpClear,
-                         data->xwindow_pict,
-                         None,
-                         data->xwindow_pict,
-                         0, 0,
-                         0, 0,
-                         0, 0,
-                         window->w, window->h);
-        
-        XFreePixmap(data->display, data->stencil);
-        data->stencil = XCreatePixmap(data->display, data->xwindow,
-                                   window->w, window->h, 32);
-        if (!data->stencil) {
-            SDL_SetError("XCreatePixmap() failed.");
-            return -1;
-        }
-
-        XRenderFreePicture(data->display, data->stencil_pict);
-        data->stencil_pict =
-            XRenderCreatePicture(data->display, data->stencil,
-                                 XRenderFindStandardFormat(data->display,
-                                                           PictStandardARGB32),
-                                 0, NULL);
-        if (!data->stencil_pict) {
-            SDL_SetError("XRenderCreatePicture() failed.");
-            return -1;
-        }
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-        if (data->use_xdamage) {
-            XDamageDestroy(data->display, data->stencil_damage);
-            data->stencil_damage =
-                XDamageCreate(data->display, data->stencil, XDamageReportNonEmpty);
-            if (!data->stencil_damage) {
-                SDL_SetError("XDamageCreate() failed.");
-                return -1;
-            }
-            XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts);
-        }
-#endif
-    }
-#endif
-    if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) {
-        n = 0;
-    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
-        n = 2;
-    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
-        n = 3;
-    } else {
-        n = 1;
-    }
-    for (i = 0; i < n; ++i) {
-        if (data->pixmaps[i] != None) {
-            XFreePixmap(data->display, data->pixmaps[i]);
-            data->pixmaps[i] = None;
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-            XRenderFreePicture(data->display, data->pixmap_picts[i]);
-            data->pixmap_picts[i] = None;
-#endif
-        }
-    }
-    for (i = 0; i < n; ++i) {
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (data->use_xrender) {
-            data->pixmaps[i] =
-                XCreatePixmap(data->display,
-                              data->xwindow,
-                              window->w,
-                              window->h,
-                              32);
-        }
-        else
-#endif
-        {
-            data->pixmaps[i] =
-                XCreatePixmap(data->display, data->xwindow, window->w, window->h,
-                              data->depth);
-        }
-        if (data->pixmaps[i] == None) {
-            SDL_SetError("XCreatePixmap() failed");
-            return -1;
-        }
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (data->use_xrender) {
-            data->pixmap_picts[i] = 
-                XRenderCreatePicture(data->display,
-                                     data->pixmaps[i],
-                                     XRenderFindStandardFormat(data->display,
-                                                               PictStandardARGB32),
-                                     0, None);
-            if (!data->pixmap_picts[i]) {
-                SDL_SetError("XRenderCreatePicture() failed");
-                return -1;
-            }
-            XRenderComposite(data->display,
-                             PictOpClear,
-                             data->pixmap_picts[i],
-                             None,
-                             data->pixmap_picts[i],
-                             0, 0,
-                             0, 0,
-                             0, 0,
-                             window->w, window->h);
-
-       }
-#endif
-    }
-    if (n > 0) {
-        data->drawable = data->pixmaps[0];
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        data->drawable_pict = data->pixmap_picts[0];
-#endif
-    }
-    data->current_pixmap = 0;
-
-    return 0;
-}
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-static void
-SDLMaskToXRenderMask(Uint32 sdl_mask, short *comp, short *compMask)
-{
-    if (sdl_mask == 0) {
-        *comp = 0;
-        *compMask = 0;
-    } else {
-        (*comp) = 0;
-        (*compMask) = 0;
-        while(!(sdl_mask & 1)) {
-            (*comp)++;
-            sdl_mask >>= 1;
-        }
-        while(sdl_mask & 1) {
-            (*compMask) = ((*compMask) << 1) | 1;
-            sdl_mask >>= 1;
-        }
-    }
-}
-
-static XRenderPictFormat*
-PixelFormatEnumToXRenderPictFormat(SDL_Renderer * renderer, Uint32 format)
-{
-    XRenderPictFormat* pict_fmt = NULL;
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    
-    if (data->use_xrender) {
-
-        int bpp;
-        Uint32 Amask, Rmask, Gmask, Bmask;
-        if(!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-            SDL_SetError("Unknown pixel format");
-            return NULL;
-        }
-        XRenderPictFormat templ;
-        unsigned long mask = (PictFormatType | PictFormatDepth | PictFormatRed |
-                              PictFormatRedMask | PictFormatGreen | PictFormatGreenMask |
-                              PictFormatBlue | PictFormatBlueMask | PictFormatAlpha |
-                              PictFormatAlphaMask);
-
-        templ.type = PictTypeDirect;
-        templ.depth = bpp;
-        SDLMaskToXRenderMask(Amask, &(templ.direct.alpha), &(templ.direct.alphaMask));
-        SDLMaskToXRenderMask(Rmask, &(templ.direct.red), &(templ.direct.redMask));
-        SDLMaskToXRenderMask(Gmask, &(templ.direct.green), &(templ.direct.greenMask));
-        SDLMaskToXRenderMask(Bmask, &(templ.direct.blue), &(templ.direct.blueMask));
-        pict_fmt = XRenderFindFormat(data->display, mask, &templ, 0);
-    }
-    
-    return pict_fmt;
-}
-
-static Visual*
-PixelFormatEnumToVisual(SDL_Renderer * renderer, Uint32 format)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-
-    if (data->use_xrender) {
-        int bpp;
-        Uint32 Amask, Rmask, Gmask, Bmask;
-        SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
-
-        XVisualInfo vinfo_templ;
-        long vinfo_mask;
-        int nitems_return;
-
-        vinfo_mask = (VisualDepthMask | VisualRedMaskMask |
-                      VisualGreenMaskMask | VisualBlueMaskMask);
-        vinfo_templ.depth = bpp;
-        vinfo_templ.red_mask = Rmask;
-        vinfo_templ.green_mask = Gmask;
-        vinfo_templ.blue_mask = Bmask;
-
-        XVisualInfo * ret = XGetVisualInfo(data->display, vinfo_mask,
-                                           &vinfo_templ, &nitems_return);
-        
-        if (nitems_return) {
-            return ret[0].visual;
-        }
-    }
-
-    return NULL;
-}
-
-static XRenderColor
-SDLColorToXRenderColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    double rd, gd, bd, ad;
-    XRenderColor ret;
-    rd = r / 255.0;
-    gd = g / 255.0;
-    bd = b / 255.0;
-    ad = a / 255.0;
-    
-    ret.red = (unsigned short) (rd * ad * 0xFFFF);
-    ret.green = (unsigned short) (gd * ad * 0xFFFF);
-    ret.blue = (unsigned short) (bd * ad * 0xFFFF);
-    ret.alpha = (unsigned short) (ad * 0xFFFF);
-
-    return ret;
-}
-#endif
-
-static int
-X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    X11_TextureData *data;
-    int pitch_alignmask = ((renderdata->scanline_pad / 8) - 1);
-    XGCValues gcv;
-    
-    data = (X11_TextureData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-    data->depth = renderdata->depth;
-    data->visual = renderdata->visual;
-    data->gc = renderdata->gc;
-
-    texture->driverdata = data;
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        data->yuv =
-            SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
-        if (!data->yuv) {
-            return -1;
-        }
-        data->format = display->current_mode.format;
-    } else {
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (renderdata->use_xrender)
-        {
-            Uint32 Amask, Rmask, Gmask, Bmask;
-            SDL_PixelFormatEnumToMasks(texture->format, &(data->depth),
-                                       &Rmask, &Gmask, &Bmask, &Amask);
-            data->visual = PixelFormatEnumToVisual(renderer, texture->format);
-        }
-        else
-#endif
-        {
-            if (texture->format != display->current_mode.format)
-            {
-                SDL_SetError("Texture format doesn't match window format");
-                return -1;
-            }
-        }
-        data->format = texture->format;
-    }
-    
-    if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) {
-#ifndef NO_SHARED_MEMORY
-        XShmSegmentInfo *shminfo = &data->shminfo;
-
-        shm_error = True;
-
-        if (SDL_X11_HAVE_SHM) {
-            data->image =
-                XShmCreateImage(renderdata->display, data->visual,
-                                data->depth, ZPixmap, NULL,
-                                shminfo, texture->w, texture->h);
-            if (data->image) {
-                shminfo->shmid =
-                    shmget(IPC_PRIVATE, texture->h * data->image->bytes_per_line,
-                           IPC_CREAT | 0777);
-                if (shminfo->shmid >= 0) {
-                    shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0);
-                    shminfo->readOnly = False;
-                    if (shminfo->shmaddr != (char *) -1) {
-                        shm_error = False;
-                        X_handler = XSetErrorHandler(shm_errhandler);
-                        XShmAttach(renderdata->display, shminfo);
-                        XSync(renderdata->display, False);
-                        XSetErrorHandler(X_handler);
-                        if (shm_error) {
-                            XShmDetach(renderdata->display, shminfo);
-                            shmdt(shminfo->shmaddr);
-                            XDestroyImage(data->image);
-                            XSync(renderdata->display, False);
-                        }
-                        else {
-                            data->pixels = data->image->data = shminfo->shmaddr;
-                            shmctl(shminfo->shmid, IPC_RMID, NULL);
-                            data->pixmap =
-                                XCreatePixmap(renderdata->display, renderdata->xwindow,
-                                              texture->w, texture->h, data->depth);
-                            if (!data->pixmap) {
-                                SDL_SetError("XCreatePixmap() failed");
-                                return -1;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        if (shm_error) {
-            shminfo->shmaddr = NULL;
-        }
-        if (!data->image)
-#endif /* not NO_SHARED_MEMORY */
-        {
-            data->image =
-                XCreateImage(renderdata->display, data->visual,
-                             data->depth, ZPixmap, 0, NULL,
-                             texture->w, texture->h,
-                             SDL_BYTESPERPIXEL(data->format) * 8,
-                             0);
-            if (!data->image) {
-                X11_DestroyTexture(renderer, texture);
-                SDL_SetError("XCreateImage() failed");
-                return -1;
-            }
-            data->pixels = SDL_malloc(texture->h * data->image->bytes_per_line);
-            if (!data->pixels) {
-                X11_DestroyTexture(renderer, texture);
-                SDL_OutOfMemory();
-                return -1;
-            }
-            data->image->data = data->pixels;
-            data->pixmap =
-                XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w,
-                              texture->h, data->depth);
-            if (data->pixmap == None) {
-                X11_DestroyTexture(renderer, texture);
-                SDL_SetError("XCreatePixmap() failed");
-                return -1;
-            }
-        }
-    } else {
-        data->image =
-            XCreateImage(renderdata->display, data->visual,
-                         data->depth, ZPixmap, 0, NULL,
-                         texture->w, texture->h,
-                         SDL_BYTESPERPIXEL(data->format) * 8,
-                         0);
-        if (!data->image) {
-            X11_DestroyTexture(renderer, texture);
-            SDL_SetError("XCreateImage() failed");
-            return -1;
-        }
-        data->pixmap =
-            XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w,
-                          texture->h, data->depth);
-        if (data->pixmap == None) {
-            X11_DestroyTexture(renderer, texture);
-            SDL_SetError("XCreatePixmap() failed");
-            return -1;
-        }
-    }
-
-    data->pitch = data->image->bytes_per_line;
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    if(renderdata->use_xrender && !data->yuv) {
-        gcv.graphics_exposures = False;
-        data->gc =
-            XCreateGC(renderdata->display, data->pixmap, GCGraphicsExposures, &gcv);
-        if (!data->gc) {
-            SDL_SetError("XCreateGC() failed");
-            return -1;
-        }
-        data->picture_fmt =
-            PixelFormatEnumToXRenderPictFormat(renderer, texture->format);
-        if (data->picture_fmt == NULL) {
-            X11_DestroyTexture(renderer, texture);
-            SDL_SetError("Texture format not supported by driver");
-            return -1;
-        }
-        data->picture =
-            XRenderCreatePicture(renderdata->display, data->pixmap,
-                                 data->picture_fmt, 0, NULL);
-        if (!data->picture) {
-            X11_DestroyTexture(renderer, texture);
-            SDL_SetError("XRenderCreatePicture() failed");
-            return -1;
-        }
-        data->modulated_pixmap =
-            XCreatePixmap(renderdata->display, renderdata->xwindow,
-                          texture->w, texture->h, data->depth);
-        if (!data->modulated_pixmap) {
-            X11_DestroyTexture(renderer, texture);
-            SDL_SetError("XCreatePixmap() failed");
-            return -1;
-        }
-        data->modulated_picture =
-            XRenderCreatePicture(renderdata->display, data->modulated_pixmap,
-                                 data->picture_fmt, 0, NULL);
-        if (!data->modulated_picture) {
-            X11_DestroyTexture(renderer, texture);
-            SDL_SetError("XRenderCreatePicture() failed");
-            return -1;
-        }
-        // FIXME: Is the following required?
-        /* Set the default blending and scaling modes. */
-        texture->blendMode = SDL_BLENDMODE_NONE;
-        texture->scaleMode = SDL_SCALEMODE_NONE;
-        data->blend_op = PictOpSrc;
-        data->filter = NULL;
-    }
-#endif
-    return 0;
-}
-
-static int
-X11_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                       void **pixels, int *pitch)
-{
-    X11_TextureData *data = (X11_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
-    } else {
-        *pixels = data->pixels;
-        *pitch = data->pitch;
-        return 0;
-    }
-}
-
-static int
-X11_SetTextureRGBAMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    X11_TextureData *data = (X11_TextureData *) texture->driverdata;
-    X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata;
-
-    if (renderdata->use_xrender) {
-
-        Uint8 r = 0xFF, g = 0xFF, b = 0xFF, a = 0xFF;
-
-        /* Check if alpha modulation is required. */
-        if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
-            a = texture->a;
-        }
-
-        /* Check if color modulation is required. */
-        if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
-            r = texture->r;
-            g = texture->g;
-            b = texture->b;
-        }
-
-        /* We can save some labour if no modulation is required. */
-        if (texture->modMode != SDL_TEXTUREMODULATE_NONE) {
-            XRenderColor mod_color =
-                SDLColorToXRenderColor(r, g, b, a);
-            XRenderFillRectangle(renderdata->display, PictOpSrc,
-                                 renderdata->brush_pict, &mod_color,
-                                 0, 0, 1, 1);
-        }
-
-        /* We can save some labour dealing with component alpha
-         * if color modulation is not required. */
-        XRenderPictureAttributes attr;
-        if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
-            attr.component_alpha = True;
-            XRenderChangePicture(renderdata->display, renderdata->brush_pict,
-                                 CPComponentAlpha, &attr);
-        }
-
-        /* Again none of this is necessary is no modulation
-         * is required. */
-        if (texture->modMode != SDL_TEXTUREMODULATE_NONE) {
-            XRenderComposite(renderdata->display, PictOpSrc,
-                             data->picture, renderdata->brush_pict,
-                             data->modulated_picture,
-                             0, 0, 0, 0, 0, 0, texture->w, texture->h);
-        }
-
-        /* We only need to reset the component alpha
-         * attribute if color modulation is required. */
-        if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { 
-            attr.component_alpha = False;
-            XRenderChangePicture(renderdata->display, renderdata->brush_pict,
-                                 CPComponentAlpha, &attr);
-        }
-
-        return 0;
-    } else {
-        SDL_Unsupported();
-        return -1;
-    }
-#else
-    SDL_Unsupported();
-    return -1;
-#endif
-}
-
-static int
-X11_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    X11_TextureData *data = (X11_TextureData *) texture->driverdata;
-    X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata;
-    switch (texture->blendMode) {
-    case SDL_BLENDMODE_NONE:
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (renderdata->use_xrender) {
-            data->blend_op = PictOpSrc;
-            return 0;
-        }
-    case SDL_BLENDMODE_MOD:
-    case SDL_BLENDMODE_MASK:
-    case SDL_BLENDMODE_BLEND:
-        if (renderdata->use_xrender) {
-            data->blend_op = PictOpOver;
-            return 0;
-        }
-    case SDL_BLENDMODE_ADD:
-        if (renderdata->use_xrender) {
-            data->blend_op = PictOpAdd;
-            return 0;
-        }
-#endif
-        return 0;
-    default:
-        SDL_Unsupported();
-        texture->blendMode = SDL_BLENDMODE_NONE;
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (renderdata->use_xrender) {
-            texture->blendMode = SDL_BLENDMODE_BLEND;
-            data->blend_op = PictOpOver;
-        }
-#endif
-        return -1;
-    }
-}
-
-static int
-X11_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    X11_TextureData *data = (X11_TextureData *) texture->driverdata;
-    X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata;
-
-    switch (texture->scaleMode) {
-    case SDL_SCALEMODE_NONE:
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (renderdata->use_xrender) {
-            data->filter = NULL;
-        }
-#endif
-        return 0;
-    case SDL_SCALEMODE_FAST:
-        /* We can sort of fake it for streaming textures */
-        if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) {
-            return 0;
-        }
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (renderdata->use_xrender) {
-            data->filter = FilterFast;
-            return 0;
-        }
-    case SDL_SCALEMODE_SLOW:
-        if (renderdata->use_xrender) {
-            data->filter = FilterGood;
-            return 0;
-        }
-    case SDL_SCALEMODE_BEST:
-        if (renderdata->use_xrender) {
-            data->filter = FilterBest;
-            return 0;
-        }
-#endif
-    /* Fall through to unsupported case */
-    default:
-        SDL_Unsupported();
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (renderdata->use_xrender) {
-            texture->scaleMode = SDL_SCALEMODE_NONE;
-            data->filter = NULL;
-        }
-        else
-#endif
-            texture->scaleMode = SDL_SCALEMODE_NONE;
-        return -1;
-    }
-    return 0;
-}
-
-static int
-X11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                  const SDL_Rect * rect, const void *pixels, int pitch)
-{
-    X11_TextureData *data = (X11_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
-            return -1;
-        }
-        UpdateYUVTextureData(texture);
-        return 0;
-    } else {
-        X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata;
-
-        if (data->pixels) {
-            Uint8 *src, *dst;
-            int row;
-            size_t length;
-
-            src = (Uint8 *) pixels;
-            dst =
-                (Uint8 *) data->pixels + rect->y * data->pitch +
-                rect->x * SDL_BYTESPERPIXEL(texture->format);
-            length = rect->w * SDL_BYTESPERPIXEL(texture->format);
-            for (row = 0; row < rect->h; ++row) {
-                SDL_memcpy(dst, src, length);
-                src += pitch;
-                dst += data->pitch;
-            }
-        } else {
-            data->image->width = rect->w;
-            data->image->height = rect->h;
-            data->image->data = (char *) pixels;
-            data->image->bytes_per_line = pitch;
-            XPutImage(renderdata->display, data->pixmap, data->gc,
-                      data->image, 0, 0, rect->x, rect->y, rect->w, rect->h);
-        }
-        return 0;
-    }
-}
-
-static int
-X11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                const SDL_Rect * rect, int markDirty, void **pixels,
-                int *pitch)
-{
-    X11_TextureData *data = (X11_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
-                                     pitch);
-    } else if (data->pixels) {
-        *pixels =
-            (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
-                      rect->x * SDL_BYTESPERPIXEL(texture->format));
-        *pitch = data->pitch;
-        return 0;
-    } else {
-        SDL_SetError("No pixels available");
-        return -1;
-    }
-}
-
-static void
-X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    X11_TextureData *data = (X11_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        SDL_SW_UnlockYUVTexture(data->yuv);
-        UpdateYUVTextureData(texture);
-    }
-}
-
-static int
-X11_SetDrawBlendMode(SDL_Renderer * renderer)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    switch (renderer->blendMode) {
-    case SDL_BLENDMODE_NONE:
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        //PictOpSrc
-        data->blend_op = PictOpSrc;
-        return 0;
-    case SDL_BLENDMODE_MOD:
-    case SDL_BLENDMODE_MASK:
-    case SDL_BLENDMODE_BLEND: // PictOpOver
-        data->blend_op = PictOpOver;
-        return 0;
-    case SDL_BLENDMODE_ADD: // PictOpAdd
-        data->blend_op = PictOpAdd;
-        return 0;
-    /* FIXME case SDL_BLENDMODE_MOD: */
-#endif
-        return 0;
-    default:
-        SDL_Unsupported();
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if(data->use_xrender) {
-            renderer->blendMode = SDL_BLENDMODE_BLEND;
-            data->blend_op = PictOpOver;
-        }
-        else
-#endif
-        {
-            renderer->blendMode = SDL_BLENDMODE_NONE;
-        }
-        return -1;
-    }
-}
-
-static Uint32
-renderdrawcolor(SDL_Renderer * renderer, int premult)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    Uint8 r = renderer->r;
-    Uint8 g = renderer->g;
-    Uint8 b = renderer->b;
-    Uint8 a = renderer->a;
-    if (premult)
-        return SDL_MapRGBA(&data->format, ((int) r * (int) a) / 255,
-                           ((int) g * (int) a) / 255,
-                           ((int) b * (int) a) / 255, 255);
-    else
-        return SDL_MapRGBA(&data->format, r, g, b, a);
-}
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-static XRenderColor
-xrenderdrawcolor(SDL_Renderer *renderer)
-{
-    XRenderColor xrender_color;
-    if(renderer->blendMode == SDL_BLENDMODE_NONE) {
-        xrender_color =
-            SDLColorToXRenderColor(renderer->r, renderer->g, renderer->b, 0xFF);
-    }
-    else {
-        xrender_color =
-            SDLColorToXRenderColor(renderer->r, renderer->g, renderer->b, renderer->a);
-    }
-    return xrender_color;
-}
-#endif
-
-static int
-X11_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
-                     int count)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    XPoint *xpoints, *xpoint;
-    int i, xcount;
-    SDL_Rect clip;
-
-    clip.x = 0;
-    clip.y = 0;
-    clip.w = window->w;
-    clip.h = window->h;
-    if (data->makedirty) {
-        SDL_Rect rect;
-
-        /* Get the smallest rectangle that contains everything */
-        rect.x = 0;
-        rect.y = 0;
-        rect.w = window->w;
-        rect.h = window->h;
-        if (!SDL_EnclosePoints(points, count, &rect, &rect)) {
-            /* Nothing to draw */
-            return 0;
-        }
-        SDL_AddDirtyRect(&data->dirty, &rect);
-    }
-    {
-        xpoint = xpoints = SDL_stack_alloc(XPoint, count);
-        xcount = 0;
-        for (i = 0; i < count; ++i) {
-            int x = points[i].x;
-            int y = points[i].y;
-            if (x < 0 || x >= window->w || y < 0 || y >= window->h) {
-                continue;
-            }
-            xpoint->x = (short)x;
-            xpoint->y = (short)y;
-            ++xpoint;
-            ++xcount;
-        }
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (data->use_xrender &&
-            (renderer->blendMode != SDL_BLENDMODE_NONE) &&
-            !(renderer->a == 0xFF &&
-              renderer->blendMode != SDL_BLENDMODE_ADD &&
-              renderer->blendMode != SDL_BLENDMODE_MOD))
-        {
-            XSetForeground(data->display, data->stencil_gc, 0);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-            if (data->use_xdamage)
-            {
-                /* Update only those parts which were changed
-                * in the previous drawing operation */
-                XFixesSetGCClipRegion(data->display, data->stencil_gc,
-                                      0, 0, data->stencil_parts);
-            }
-#endif
-            XFillRectangle(data->display, data->stencil, data->stencil_gc,
-                           0, 0, window->w, window->h);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-            if (data->use_xdamage)
-            {
-                XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, None);
-            }
-#endif
-            XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF);
-
-            XDrawPoints(data->display, data->stencil, data->stencil_gc, xpoints, xcount,
-                        CoordModeOrigin);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-            if (data->use_xdamage)
-            {
-                /* Store the damaged region in stencil_parts */
-                XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts);
-            }
-#endif
-        }
-#endif
-    }
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    if (data->use_xrender &&
-            (renderer->blendMode != SDL_BLENDMODE_NONE) &&
-            !(renderer->a == 0xFF &&
-              renderer->blendMode != SDL_BLENDMODE_ADD &&
-              renderer->blendMode != SDL_BLENDMODE_MOD))
-    {
-        XRenderColor foreground;
-        foreground = xrenderdrawcolor(renderer);
-
-        XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict,
-                             &foreground, 0, 0, 1, 1);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-        if (data->use_xdamage)
-        {
-            /* Update only those parts which drawn
-             * to in the current drawing operation */
-            XFixesSetPictureClipRegion(data->display, data->drawable_pict,
-                                       0, 0, data->stencil_parts);
-        }
-#endif
-        XRenderComposite(data->display, data->blend_op, data->brush_pict,
-                         data->stencil_pict, data->drawable_pict,
-                         0, 0, 0, 0, 0, 0, window->w, window->h);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-        if (data->use_xdamage)
-        {
-            XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, None);
-        }
-#endif
-    }
-    else
-#endif
-    {
-        unsigned long foreground = renderdrawcolor(renderer, 1);
-        XSetForeground(data->display, data->gc, foreground);
-
-
-        if (xcount > 0) {
-            XDrawPoints(data->display, data->drawable, data->gc, xpoints, xcount,
-                        CoordModeOrigin);
-        }
-    }
-
-    SDL_stack_free(xpoints);
-
-    return 0;
-}
-
-static int
-X11_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
-                    int count)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_Rect clip;
-    unsigned long foreground;
-    XPoint *xpoints, *xpoint;
-    int i, xcount;
-    int minx, miny;
-    int maxx, maxy;
-
-    clip.x = 0;
-    clip.y = 0;
-    clip.w = window->w;
-    clip.h = window->h;
-    {
-        Pixmap drawable;
-        GC gc;
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-       if (data->use_xrender &&
-            (renderer->blendMode != SDL_BLENDMODE_NONE) &&
-            !(renderer->a == 0xFF &&
-              renderer->blendMode != SDL_BLENDMODE_ADD &&
-              renderer->blendMode != SDL_BLENDMODE_MOD))
-       { 
-            drawable = data->stencil;
-            gc = data->stencil_gc;
-
-            XSetForeground(data->display, data->stencil_gc, 0);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-            if (data->use_xdamage)
-                XFixesSetGCClipRegion(data->display, data->stencil_gc,
-                                      0, 0, data->stencil_parts);
-#endif
-            XFillRectangle(data->display, data->stencil, data->stencil_gc,
-                           0, 0, window->w, window->h);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-            if (data->use_xdamage)
-                XFixesSetGCClipRegion(data->display, data->stencil_gc,
-                                      0, 0, None);
-#endif
-            XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF);
-        }
-        else
-#endif
-        {
-            drawable = data->drawable;
-            gc = data->gc;
-        }
-
-        foreground = renderdrawcolor(renderer, 1);
-        XSetForeground(data->display, data->gc, foreground);
-
-        xpoint = xpoints = SDL_stack_alloc(XPoint, count);
-        xcount = 0;
-        minx = INT_MAX;
-        miny = INT_MAX;
-        maxx = INT_MIN;
-        maxy = INT_MIN;
-        for (i = 0; i < count; ++i) {
-            int x = points[i].x;
-            int y = points[i].y;
-
-            /* If the point is inside the window, add it to the list */
-            if (x >= 0 && x < window->w && y >= 0 && y < window->h) {
-                if (x < minx) {
-                    minx = x;
-                } else if (x > maxx) {
-                    maxx = x;
-                }
-                if (y < miny) {
-                    miny = y;
-                } else if (y > maxy) {
-                    maxy = y;
-                }
-                xpoint->x = (short)x;
-                xpoint->y = (short)y;
-                ++xpoint;
-                ++xcount;
-                continue;
-            }
-
-            /* We need to clip the line segments joined by this point */
-            if (xcount > 0) {
-                int x1 = xpoint[-1].x;
-                int y1 = xpoint[-1].y;
-                int x2 = x;
-                int y2 = y;
-                if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) {
-                    if (x2 < minx) {
-                        minx = x2;
-                    } else if (x2 > maxx) {
-                        maxx = x2;
-                    }
-                    if (y2 < miny) {
-                        miny = y2;
-                    } else if (y2 > maxy) {
-                        maxy = y2;
-                    }
-                    xpoint->x = (short)x2;
-                    xpoint->y = (short)y2;
-                    ++xpoint;
-                    ++xcount;
-                }
-                XDrawLines(data->display, drawable, gc,
-                           xpoints, xcount, CoordModeOrigin);
-                if (xpoints[0].x != x2 || xpoints[0].y != y2) {
-                    XDrawPoint(data->display, drawable, gc, x2, y2);
-                }
-                if (data->makedirty) {
-                    SDL_Rect rect;
-
-                    rect.x = minx;
-                    rect.y = miny;
-                    rect.w = (maxx - minx) + 1;
-                    rect.h = (maxy - miny) + 1;
-                    SDL_AddDirtyRect(&data->dirty, &rect);
-                }
-                xpoint = xpoints;
-                xcount = 0;
-                minx = INT_MAX;
-                miny = INT_MAX;
-                maxx = INT_MIN;
-                maxy = INT_MIN;
-            }
-            if (i < (count-1)) {
-                int x1 = x;
-                int y1 = y;
-                int x2 = points[i+1].x;
-                int y2 = points[i+1].y;
-                if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) {
-                    if (x1 < minx) {
-                        minx = x1;
-                    } else if (x1 > maxx) {
-                        maxx = x1;
-                    }
-                    if (y1 < miny) {
-                        miny = y1;
-                    } else if (y1 > maxy) {
-                        maxy = y1;
-                    }
-                    xpoint->x = (short)x1;
-                    xpoint->y = (short)y1;
-                    ++xpoint;
-                    ++xcount;
-                }
-            }
-        }
-        if (xcount > 1) {
-            int x2 = xpoint[-1].x;
-            int y2 = xpoint[-1].y;
-            XDrawLines(data->display, drawable, gc, xpoints, xcount,
-                       CoordModeOrigin);
-            if (xpoints[0].x != x2 || xpoints[0].y != y2) {
-                XDrawPoint(data->display, drawable, gc, x2, y2);
-            }
-            if (data->makedirty) {
-                SDL_Rect rect;
-
-                rect.x = minx;
-                rect.y = miny;
-                rect.w = (maxx - minx) + 1;
-                rect.h = (maxy - miny) + 1;
-                SDL_AddDirtyRect(&data->dirty, &rect);
-            }
-        }
-    }
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    if (data->use_xrender &&
-            (renderer->blendMode != SDL_BLENDMODE_NONE) &&
-            !(renderer->a == 0xFF &&
-              renderer->blendMode != SDL_BLENDMODE_ADD &&
-              renderer->blendMode != SDL_BLENDMODE_MOD))
-    {
-        XRenderColor xrforeground = xrenderdrawcolor(renderer);
-        XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict,
-                             &xrforeground, 0, 0, 1, 1);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-        if (data->use_xdamage)
-        {
-            XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts);
-
-            XFixesSetPictureClipRegion(data->display, data->drawable_pict,
-                                       0, 0, data->stencil_parts);
-        }
-#endif
-        XRenderComposite(data->display, data->blend_op, data->brush_pict,
-                         data->stencil_pict, data->drawable_pict,
-                         0, 0, 0, 0, 0, 0, window->w, window->h);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-        if (data->use_xdamage)
-            XFixesSetPictureClipRegion(data->display, data->drawable_pict,
-                                       0, 0, None);
-#endif
-    }
-#endif
-    SDL_stack_free(xpoints);
-
-    return 0;
-}
-
-static int
-X11_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_Rect clip, rect;
-    int i, xcount;
-    XRectangle *xrects, *xrect;
-    xrect = xrects = SDL_stack_alloc(XRectangle, count);
-    xcount = 0;
-    
-    clip.x = 0;
-    clip.y = 0;
-    clip.w = window->w;
-    clip.h = window->h;
-    {
-
-        for (i = 0; i < count; ++i) {
-            if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
-                continue;
-            }
-
-            xrect->x = (short)rect.x;
-            xrect->y = (short)rect.y;
-            xrect->width = (unsigned short)rect.w - 1;
-            xrect->height = (unsigned short)rect.h - 1;
-            ++xrect;
-            ++xcount;
-
-            if (data->makedirty) {
-                SDL_AddDirtyRect(&data->dirty, &rect);
-            }
-        }
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (data->use_xrender &&
-            (renderer->blendMode != SDL_BLENDMODE_NONE) &&
-            !(renderer->a == 0xFF &&
-              renderer->blendMode != SDL_BLENDMODE_ADD &&
-              renderer->blendMode != SDL_BLENDMODE_MOD))
-        {
-            XSetForeground(data->display, data->stencil_gc, 0);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-            if (data->use_xdamage)
-                XFixesSetGCClipRegion(data->display, data->stencil_gc,
-                                      0, 0, data->stencil_parts);
-#endif
-            XFillRectangle(data->display, data->stencil, data->stencil_gc,
-                           0, 0, window->w, window->h);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-            if (data->use_xdamage)
-                XFixesSetGCClipRegion(data->display, data->stencil_gc,
-                                      0, 0, None);
-#endif
-            XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF);
-
-            XDrawRectangles(data->display, data->stencil, data->stencil_gc, xrects, xcount);
-
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-            if (data->use_xdamage)
-                XDamageSubtract(data->display, data->stencil_damage,
-                                None, data->stencil_parts);
-#endif
-        }
-#endif
-    }
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    if (data->use_xrender &&
-            (renderer->blendMode != SDL_BLENDMODE_NONE) &&
-            !(renderer->a == 0xFF &&
-              renderer->blendMode != SDL_BLENDMODE_ADD &&
-              renderer->blendMode != SDL_BLENDMODE_MOD))
-    {
-        XRenderColor foreground;
-        foreground = xrenderdrawcolor(renderer);
-        XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict,
-                             &foreground, 0, 0, 1, 1);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-        if (data->use_xdamage)
-            XFixesSetPictureClipRegion(data->display, data->drawable_pict,
-                                       0, 0, data->stencil_parts);
-#endif
-        XRenderComposite(data->display, data->blend_op, data->brush_pict,
-                         data->stencil_pict, data->drawable_pict,
-                         0, 0, 0, 0, 0, 0, window->w, window->h);
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-        if (data->use_xdamage)
-            XFixesSetPictureClipRegion(data->display, data->drawable_pict,
-                                       0, 0, None);
-#endif
-    }
-    else
-#endif
-    {
-        unsigned long foreground;
-        
-        foreground = renderdrawcolor(renderer, 1);
-        XSetForeground(data->display, data->gc, foreground);
-    
-        if (xcount > 0) {
-            XDrawRectangles(data->display, data->drawable, data->gc,
-                            xrects, xcount);
-        }
-    }
-    SDL_stack_free(xrects);
-
-    return 0;
-}
-
-static int
-X11_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_Rect clip, rect;
-    
-    clip.x = 0;
-    clip.y = 0;
-    clip.w = window->w;
-    clip.h = window->h;
-    
-    int i, xcount;
-    XRectangle *xrects, *xrect;
-    xrect = xrects = SDL_stack_alloc(XRectangle, count);
-    xcount = 0;
-    for (i = 0; i < count; ++i) {
-        if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
-            continue;
-        }
-
-        xrect->x = (short)rect.x;
-        xrect->y = (short)rect.y;
-        xrect->width = (unsigned short)rect.w;
-        xrect->height = (unsigned short)rect.h;
-        ++xrect;
-        ++xcount;
-
-        if (data->makedirty) {
-            SDL_AddDirtyRect(&data->dirty, &rect);
-        }
-    }
-
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    if (data->use_xrender) {
-        XRenderColor foreground;
-        foreground = xrenderdrawcolor(renderer);
-        if (xcount == 1) {
-            XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict,
-                                 &foreground, xrects[0].x, xrects[0].y,
-                                 xrects[0].width, xrects[0].height);
-        }
-        else if (xcount > 1) {
-            XRenderFillRectangles(data->display, data->blend_op, data->drawable_pict,
-                                  &foreground, xrects, xcount);
-        }
-    }
-    else
-#endif
-    {
-        unsigned long foreground;
-        
-        foreground = renderdrawcolor(renderer, 1);
-        XSetForeground(data->display, data->gc, foreground);
- 
-        XFillRectangles(data->display, data->drawable, data->gc,
-                        xrects, xcount);
-    }
-
-    SDL_stack_free(xrects);
-    return 0;
-}
-
-static int
-X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    X11_TextureData *texturedata = (X11_TextureData *) texture->driverdata;
-
-    if (data->makedirty) {
-        SDL_AddDirtyRect(&data->dirty, dstrect);
-    }
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    if (data->use_xrender && !texturedata->yuv) {
-        if(texture->access == SDL_TEXTUREACCESS_STREAMING) {
-#ifndef NO_SHARED_MEMORY
-            if(texturedata->shminfo.shmaddr) {
-                XShmPutImage(data->display, texturedata->pixmap, texturedata->gc,
-                             texturedata->image, srcrect->x, srcrect->y,
-                             srcrect->x, srcrect->y, srcrect->w, srcrect->h,
-                             False);
-            }
-            else
-#endif
-            if (texturedata->pixels) {
-                XPutImage(data->display, texturedata->pixmap, texturedata->gc,
-                          texturedata->image, srcrect->x, srcrect->y, srcrect->x,
-                          srcrect->y, srcrect->w, srcrect->h);
-            }
-            XSync(data->display, False);
-        }
-        Picture src, mask;
-        XRenderPictureAttributes attr;
-        const SDL_Rect *mrect;
-        /* mrect is the rectangular area of the mask
-         * picture that is aligned with the source. */
-
-        if (texture->modMode == SDL_TEXTUREMODULATE_NONE) {
-            src = texturedata->picture;
-        }
-        else {
-            src = texturedata->modulated_picture;
-        }
-
-        if(texture->blendMode == SDL_BLENDMODE_NONE) 
-        {
-            mask = None;
-            mrect = srcrect;
-        }
-        else if (texture->blendMode == SDL_BLENDMODE_MOD)
-        {
-            /* SDL_BLENDMODE_MOD requires a temporary buffer
-             * i.e. stencil_pict */
-            mask = data->stencil_pict;
-            mrect = dstrect;
-        }
-        else
-        {
-            /* This trick allows on-the-fly multiplication
-             * of the src color channels with it's alpha
-             * channel. */
-            mask = src;
-            mrect = srcrect;
-        }
-
-        if(srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
-            if (texture->blendMode == SDL_BLENDMODE_MOD) {
-                XRenderComposite(data->display, PictOpSrc, data->drawable_pict,
-                             src, data->stencil_pict,
-                             dstrect->x, dstrect->y, srcrect->x, srcrect->y,
-                             dstrect->x, dstrect->y, dstrect->w, dstrect->h);
-                attr.component_alpha = True;
-                XRenderChangePicture(data->display, data->stencil_pict,
-                                     CPComponentAlpha, &attr);
-            }
-            XRenderComposite(data->display, texturedata->blend_op,
-                            src, mask, data->drawable_pict, srcrect->x, srcrect->y,
-                            mrect->x, mrect->y, dstrect->x, dstrect->y,
-                            dstrect->w, dstrect->h);
-        } else {
-            /* The transformation is from the dst to src picture. */
-            double xscale = ((double) srcrect->w) / dstrect->w;
-            double yscale = ((double) srcrect->h) / dstrect->h;
-            XTransform xform = {{
-                    {XDoubleToFixed(xscale), XDoubleToFixed(0), XDoubleToFixed(0)},
-                    {XDoubleToFixed(0), XDoubleToFixed(yscale), XDoubleToFixed(0)},
-                    {XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(1)}}};
-            XRenderSetPictureTransform(data->display, src, &xform);
-            
-            /* Black magic follows. */
-            if (texture->blendMode == SDL_BLENDMODE_MOD) {
-                /* Copy the dst to a temp buffer. */
-                XRenderComposite(data->display, PictOpSrc, data->drawable_pict,
-                             src, data->stencil_pict,
-                             dstrect->x, dstrect->y, srcrect->x, srcrect->y,
-                             dstrect->x, dstrect->y, dstrect->w, dstrect->h);
-                /* Set the compnent alpha flag on the temp buffer. */
-                attr.component_alpha = True;
-                XRenderChangePicture(data->display, data->stencil_pict,
-                                     CPComponentAlpha, &attr);
-            }
-
-            /* Set the picture filter only if a scaling mode is set. */
-            if (texture->scaleMode != SDL_SCALEMODE_NONE) {
-                XRenderSetPictureFilter(data->display, src,
-                                        texturedata->filter, 0, 0);
-            }
-
-            XRenderComposite(data->display, texturedata->blend_op,
-                             src, mask, data->drawable_pict,
-                             srcrect->x, srcrect->y, mrect->x, mrect->y,
-                             dstrect->x, dstrect->y, dstrect->w, dstrect->h);
-           /* Set the texture transformation back to the identity matrix. */ 
-            XTransform identity = {{
-                    {XDoubleToFixed(1), XDoubleToFixed(0), XDoubleToFixed(0)},
-                    {XDoubleToFixed(0), XDoubleToFixed(1), XDoubleToFixed(0)},
-                    {XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(1)}}};
-            XRenderSetPictureTransform(data->display, src, &identity);
-        }
-        
-        /* Reset the component alpha flag only when
-         * the blending mode is SDL_BLENDMODE_MOD. */
-        if (renderer->blendMode == SDL_BLENDMODE_MOD) {
-            attr.component_alpha = False;
-            XRenderChangePicture(data->display, data->stencil_pict,
-                                 CPComponentAlpha, &attr);
-        }
-    }
-    else
-#endif
-    {
-        if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
-#ifndef NO_SHARED_MEMORY
-            if (texturedata->shminfo.shmaddr) {
-                XShmPutImage(data->display, data->drawable, data->gc,
-                             texturedata->image, srcrect->x, srcrect->y,
-                             dstrect->x, dstrect->y, srcrect->w, srcrect->h,
-                             False);
-            } else
-#endif
-            if (texturedata->pixels) {
-                XPutImage(data->display, data->drawable, data->gc,
-                          texturedata->image, srcrect->x, srcrect->y, dstrect->x,
-                          dstrect->y, srcrect->w, srcrect->h);
-            } else {
-                XCopyArea(data->display, texturedata->pixmap, data->drawable,
-                          data->gc, srcrect->x, srcrect->y, dstrect->w,
-                          dstrect->h, dstrect->x, dstrect->y);
-            }
-        } else if (texturedata->yuv
-                   || texture->access == SDL_TEXTUREACCESS_STREAMING) {
-            SDL_Surface src, dst;
-            SDL_PixelFormat fmt;
-            SDL_Rect rect;
-            XImage *image = texturedata->scaling_image;
-
-            if (!image) {
-                void *pixels;
-                int pitch;
-
-                pitch = dstrect->w * SDL_BYTESPERPIXEL(texturedata->format);
-                pixels = SDL_malloc(dstrect->h * pitch);
-                if (!pixels) {
-                    SDL_OutOfMemory();
-                    return -1;
-                }
-
-                image =
-                    XCreateImage(data->display, data->visual, data->depth,
-                                 ZPixmap, 0, pixels, dstrect->w, dstrect->h,
-                                 SDL_BYTESPERPIXEL(texturedata->format) * 8,
-                                 pitch);
-                if (!image) {
-                    SDL_SetError("XCreateImage() failed");
-                    return -1;
-                }
-                texturedata->scaling_image = image;
-
-            } else if (image->width != dstrect->w || image->height != dstrect->h
-                       || !image->data) {
-                image->width = dstrect->w;
-                image->height = dstrect->h;
-                image->bytes_per_line =
-                    image->width * SDL_BYTESPERPIXEL(texturedata->format);
-                image->data =
-                    (char *) SDL_realloc(image->data,
-                                         image->height * image->bytes_per_line);
-                if (!image->data) {
-                    SDL_OutOfMemory();
-                    return -1;
-                }
-            }
-
-            /* Set up fake surfaces for SDL_SoftStretch() */
-            SDL_zero(src);
-            src.format = &fmt;
-            src.w = texture->w;
-            src.h = texture->h;
-#ifndef NO_SHARED_MEMORY
-            if (texturedata->shminfo.shmaddr) {
-                src.pixels = texturedata->shminfo.shmaddr;
-            } else
-#endif
-                src.pixels = texturedata->pixels;
-            src.pitch = texturedata->pitch;
-
-            SDL_zero(dst);
-            dst.format = &fmt;
-            dst.w = image->width;
-            dst.h = image->height;
-            dst.pixels = image->data;
-            dst.pitch = image->bytes_per_line;
-
-            fmt.BytesPerPixel = SDL_BYTESPERPIXEL(texturedata->format);
-
-            rect.x = 0;
-            rect.y = 0;
-            rect.w = dstrect->w;
-            rect.h = dstrect->h;
-            if (SDL_SoftStretch(&src, srcrect, &dst, &rect) < 0) {
-                return -1;
-            }
-            XPutImage(data->display, data->drawable, data->gc, image, 0, 0,
-                      dstrect->x, dstrect->y, dstrect->w, dstrect->h);
-        } else {
-            XCopyArea(data->display, texturedata->pixmap, data->drawable,
-                      data->gc, srcrect->x, srcrect->y, dstrect->w, dstrect->h,
-                      srcrect->x, srcrect->y);
-        }
-    }
-    return 0;
-}
-
-static int
-X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                     Uint32 format, void * pixels, int pitch)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    Uint32 screen_format = display->current_mode.format;
-    XImage *image;
-
-    image = XGetImage(data->display, data->drawable, rect->x, rect->y,
-                      rect->w, rect->h, AllPlanes, ZPixmap);
-
-    SDL_ConvertPixels(rect->w, rect->h,
-                      screen_format, image->data, image->bytes_per_line,
-                      format, pixels, pitch);
-
-    XDestroyImage(image);
-    return 0;
-}
-
-static int
-X11_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                      Uint32 format, const void * pixels, int pitch)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    Uint32 screen_format = display->current_mode.format;
-    XImage *image;
-    void *image_pixels;
-    int image_pitch;
-
-    image_pitch = rect->w * SDL_BYTESPERPIXEL(screen_format);
-    image_pixels = SDL_malloc(rect->h * image_pitch);
-    if (!image_pixels) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    image = XCreateImage(data->display, data->visual,
-                         data->depth, ZPixmap, 0, image_pixels,
-                         rect->w, rect->h,
-                         SDL_BYTESPERPIXEL(screen_format) * 8,
-                         image_pitch);
-    if (!image) {
-        SDL_SetError("XCreateImage() failed");
-        return -1;
-    }
-
-    SDL_ConvertPixels(rect->w, rect->h,
-                      format, pixels, pitch,
-                      screen_format, image->data, image->bytes_per_line);
-
-    XPutImage(data->display, data->drawable, data->gc,
-              image, 0, 0, rect->x, rect->y, rect->w, rect->h);
-
-    image->data = NULL;
-    XDestroyImage(image);
-
-    SDL_free(image_pixels);
-    return 0;
-}
-
-static void
-X11_RenderPresent(SDL_Renderer * renderer)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    SDL_DirtyRect *dirty;
-
-    /* Send the data to the display */
-    if (!(renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)) {
-        for (dirty = data->dirty.list; dirty; dirty = dirty->next) {
-            const SDL_Rect *rect = &dirty->rect;
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-            if (data->use_xrender)
-            {
-                XRenderComposite(data->display,
-                                 data->blend_op,
-                                 data->drawable_pict,
-                                 None,
-                                 data->xwindow_pict,
-                                 rect->x, rect->y,
-                                 0, 0,
-                                 rect->x, rect->y,
-                                 rect->w, rect->h);
-            }
-            else
-#endif
-            {
-            XCopyArea(data->display, data->drawable, data->xwindow,
-                      data->gc, rect->x, rect->y, rect->w, rect->h,
-                      rect->x, rect->y);
-            }
-        }
-        SDL_ClearDirtyRects(&data->dirty);
-    }
-    XSync(data->display, False);
-
-    /* Update the flipping chain, if any */
-    if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
-        data->current_pixmap = (data->current_pixmap + 1) % 2;
-        data->drawable = data->pixmaps[data->current_pixmap];
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        data->drawable_pict = data->pixmap_picts[data->current_pixmap];
-#endif
-    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
-        data->current_pixmap = (data->current_pixmap + 1) % 3;
-        data->drawable = data->pixmaps[data->current_pixmap];
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        data->drawable_pict = data->pixmap_picts[data->current_pixmap];
-#endif
-    }
-}
-
-static void
-X11_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata;
-    X11_TextureData *data = (X11_TextureData *) texture->driverdata;
-
-    if (!data) {
-        return;
-    }
-    if (data->yuv) {
-        SDL_SW_DestroyYUVTexture(data->yuv);
-    }
-    if (data->pixmap != None) {
-        XFreePixmap(renderdata->display, data->pixmap);
-    }
-    if (data->image) {
-        data->image->data = NULL;
-        XDestroyImage(data->image);
-    }
-#ifndef NO_SHARED_MEMORY
-    if (data->shminfo.shmaddr) {
-        XShmDetach(renderdata->display, &data->shminfo);
-        XSync(renderdata->display, False);
-        shmdt(data->shminfo.shmaddr);
-        data->pixels = NULL;
-    }
-#endif
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-    if (renderdata->use_xrender) {
-        if (data->picture) {
-            XRenderFreePicture(renderdata->display, data->picture);
-        }
-        if (data->modulated_pixmap) {
-            XFreePixmap(renderdata->display, data->modulated_pixmap);
-        }
-        if (data->modulated_picture) {
-            XRenderFreePicture(renderdata->display, data->modulated_picture);
-        }
-    }
-#endif
-    if (data->scaling_image) {
-        SDL_free(data->scaling_image->data);
-        data->scaling_image->data = NULL;
-        XDestroyImage(data->scaling_image);
-    }
-    if (data->pixels) {
-        SDL_free(data->pixels);
-    }
-    SDL_free(data);
-    texture->driverdata = NULL;
-}
-
-static void
-X11_DestroyRenderer(SDL_Renderer * renderer)
-{
-    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
-    int i;
-
-    if (data) {
-        for (i = 0; i < SDL_arraysize(data->pixmaps); ++i) {
-            if (data->pixmaps[i] != None) {
-                XFreePixmap(data->display, data->pixmaps[i]);
-            }
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-            if (data->use_xrender && data->pixmap_picts[i]) {
-                XRenderFreePicture(data->display, data->pixmap_picts[i]);
-            }
-#endif
-        }
-        if (data->gc) {
-            XFreeGC(data->display, data->gc);
-        }
-#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
-        if (data->use_xrender) {
-            if (data->stencil_gc) {
-                XFreeGC(data->display, data->stencil_gc);
-            }
-            if (data->stencil) {
-                XFreePixmap(data->display, data->stencil);
-            }
-            if (data->stencil_pict) {
-                XRenderFreePicture(data->display, data->stencil_pict);
-            }
-            if (data->xwindow_pict) {
-                XRenderFreePicture(data->display, data->xwindow_pict);
-            }
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-            if (data->use_xdamage && data->stencil_damage) {
-                XDamageDestroy(data->display, data->stencil_damage);
-            }
-#endif
-        }
-#endif
-        SDL_FreeDirtyRects(&data->dirty);
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-#endif /* SDL_VIDEO_RENDER_X11 */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/x11/SDL_x11render.h	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* SDL surface based renderer implementation */
-
-#if SDL_VIDEO_RENDER_X11
-extern void X11_AddRenderDriver(_THIS);
-#endif
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/x11/SDL_x11sym.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/x11/SDL_x11sym.h	Sun Feb 06 21:23:32 2011 -0800
@@ -24,58 +24,38 @@
 
 SDL_X11_MODULE(BASEXLIB)
 SDL_X11_SYM(XClassHint*,XAllocClassHint,(void),(),return)
-SDL_X11_SYM(Status,XAllocColor,(Display* a,Colormap b,XColor* c),(a,b,c),return)
-SDL_X11_SYM(Status,XAllocColorCells,(Display *a,Colormap b,Bool c,unsigned long d[],unsigned int e,unsigned long f[],unsigned int g),(a,b,c,d,e,f,g),return)
 SDL_X11_SYM(XSizeHints*,XAllocSizeHints,(void),(),return)
-SDL_X11_SYM(XStandardColormap *,XAllocStandardColormap,(void),(),return)
 SDL_X11_SYM(XWMHints*,XAllocWMHints,(void),(),return)
 SDL_X11_SYM(int,XAutoRepeatOn,(Display* a),(a),return)
 SDL_X11_SYM(int,XAutoRepeatOff,(Display* a),(a),return)
 SDL_X11_SYM(int,XChangePointerControl,(Display* a,Bool b,Bool c,int d,int e,int f),(a,b,c,d,e,f),return)
 SDL_X11_SYM(int,XChangeProperty,(Display* a,Window b,Atom c,Atom d,int e,int f,_Xconst unsigned char* g,int h),(a,b,c,d,e,f,g,h),return)
-SDL_X11_SYM(int,XChangeWindowAttributes,(Display* a,Window b,unsigned long c,XSetWindowAttributes* d),(a,b,c,d),return)
-SDL_X11_SYM(Bool,XCheckWindowEvent,(Display* a,Window b,long c,XEvent* d),(a,b,c,d),return)
-SDL_X11_SYM(int,XClearWindow,(Display* a,Window b),(a,b),return)
 SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return)
 SDL_X11_SYM(int,XConvertSelection,(Display* a,Atom b,Atom c,Atom d,Window e,Time f),(a,b,c,d,e,f),return)
-SDL_X11_SYM(int,XCopyArea,(Display* a,Drawable b,Drawable c,GC d,int e,int f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return)
 SDL_X11_SYM(Pixmap,XCreateBitmapFromData,(Display *dpy,Drawable d,_Xconst char *data,unsigned int width,unsigned int height),(dpy,d,data,width,height),return)
 SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return)
 SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return)
 SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return)
 SDL_X11_SYM(XImage*,XCreateImage,(Display* a,Visual* b,unsigned int c,int d,int e,char* f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return)
-SDL_X11_SYM(Pixmap,XCreatePixmap,(Display* a,Drawable b,unsigned int c,unsigned int d,unsigned int e),(a,b,c,d,e),return)
-SDL_X11_SYM(Pixmap,XCreatePixmapFromBitmapData,(Display* a,Drawable b,char* c,unsigned int d,unsigned int e,unsigned long f,unsigned long g,unsigned int h),(a,b,c,d,e,f,g,h),return)
-SDL_X11_SYM(Window,XCreateSimpleWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,unsigned long h,unsigned long i),(a,b,c,d,e,f,g,h,i),return)
 SDL_X11_SYM(Window,XCreateWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,int h,unsigned int i,Visual* j,unsigned long k,XSetWindowAttributes* l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
 SDL_X11_SYM(int,XDefineCursor,(Display* a,Window b,Cursor c),(a,b,c),return)
 SDL_X11_SYM(int,XDeleteProperty,(Display* a,Window b,Atom c),(a,b,c),return)
 SDL_X11_SYM(int,XDestroyWindow,(Display* a,Window b),(a,b),return)
 SDL_X11_SYM(int,XDisplayKeycodes,(Display* a,int* b,int* c),(a,b,c),return)
-SDL_X11_SYM(int,XDrawLines,(Display* a, Drawable b, GC c, XPoint* d, int e, int f),(a,b,c,d,e,f),return)
-SDL_X11_SYM(int,XDrawPoint,(Display* a, Drawable b, GC c, int d, int e),(a,b,c,d,e),return)
-SDL_X11_SYM(int,XDrawPoints,(Display* a, Drawable b, GC c, XPoint* d, int e, int f),(a,b,c,d,e,f),return)
-SDL_X11_SYM(int,XDrawRectangles,(Display* a,Drawable b,GC c,XRectangle* d,int e),(a,b,c,d,e),return)
-SDL_X11_SYM(int,XFillRectangles,(Display* a,Drawable b,GC c,XRectangle* d,int e),(a,b,c,d,e),return)
 SDL_X11_SYM(char*,XDisplayName,(_Xconst char* a),(a),return)
 SDL_X11_SYM(int,XEventsQueued,(Display* a,int b),(a,b),return)
 SDL_X11_SYM(Bool,XFilterEvent,(XEvent *event,Window w),(event,w),return)
 SDL_X11_SYM(int,XFlush,(Display* a),(a),return)
 SDL_X11_SYM(int,XFree,(void*a),(a),return)
-SDL_X11_SYM(int,XFreeColormap,(Display* a,Colormap b),(a,b),return)
-SDL_X11_SYM(int,XFreeColors,(Display* a,Colormap b,unsigned long* c,int d,unsigned long e),(a,b,c,d,e),return)
 SDL_X11_SYM(int,XFreeCursor,(Display* a,Cursor b),(a,b),return)
 SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return)
 SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return)
 SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return)
 SDL_X11_SYM(char*,XGetAtomName,(Display *a,Atom b),(a,b),return)
 SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return)
-SDL_X11_SYM(XImage*,XGetImage,(Display* a,Drawable b,int c,int d,unsigned int e,unsigned int f,unsigned long g, int h),(a,b,c,d,e,f,g,h),return)
 SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return)
 SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return)
-SDL_X11_SYM(int,XGetRGBColormaps,(Display* a,Window b,XStandardColormap **c,int *d,Atom e),(a,b,c,d,e),return)
 SDL_X11_SYM(Window,XGetSelectionOwner,(Display* a,Atom b),(a,b),return)
-SDL_X11_SYM(Status,XGetTextProperty,(Display *a,Window b,XTextProperty *c,Atom d),(a,b,c,d),return)
 SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return)
 SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return)
 SDL_X11_SYM(int,XGetWindowProperty,(Display* a,Window b,Atom c,long d,long e,Bool f,Atom g,Atom* h,int* i,unsigned long* j,unsigned long *k,unsigned char **l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
@@ -84,47 +64,34 @@
 SDL_X11_SYM(int,XGrabPointer,(Display* a,Window b,Bool c,unsigned int d,int e,int f,Window g,Cursor h,Time i),(a,b,c,d,e,f,g,h,i),return)
 SDL_X11_SYM(int,XGrabServer,(Display* a),(a),return)
 SDL_X11_SYM(Status,XIconifyWindow,(Display* a,Window b,int c),(a,b,c),return)
-SDL_X11_SYM(int,XInstallColormap,(Display* a,Colormap b),(a,b),return)
 SDL_X11_SYM(KeyCode,XKeysymToKeycode,(Display* a,KeySym b),(a,b),return)
 SDL_X11_SYM(char*,XKeysymToString,(KeySym a),(a),return)
-SDL_X11_SYM(int,XKillClient,(Display* a,XID b),(a,b),return)
 SDL_X11_SYM(Atom,XInternAtom,(Display* a,_Xconst char* b,Bool c),(a,b,c),return)
 SDL_X11_SYM(XPixmapFormatValues*,XListPixmapFormats,(Display* a,int* b),(a,b),return)
 SDL_X11_SYM(KeySym,XLookupKeysym,(XKeyEvent* a,int b),(a,b),return)
 SDL_X11_SYM(int,XLookupString,(XKeyEvent* a,char* b,int c,KeySym* d,XComposeStatus* e),(a,b,c,d,e),return)
 SDL_X11_SYM(int,XMapRaised,(Display* a,Window b),(a,b),return)
-SDL_X11_SYM(int,XMapWindow,(Display* a,Window b),(a,b),return)
-SDL_X11_SYM(int,XMaskEvent,(Display* a,long b,XEvent* c),(a,b,c),return)
 SDL_X11_SYM(Status,XMatchVisualInfo,(Display* a,int b,int c,int d,XVisualInfo* e),(a,b,c,d,e),return)
 SDL_X11_SYM(int,XMissingExtension,(Display* a,_Xconst char* b),(a,b),return)
-SDL_X11_SYM(int,XMoveResizeWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f),(a,b,c,d,e,f),return)
 SDL_X11_SYM(int,XMoveWindow,(Display* a,Window b,int c,int d),(a,b,c,d),return)
 SDL_X11_SYM(int,XNextEvent,(Display* a,XEvent* b),(a,b),return)
 SDL_X11_SYM(Display*,XOpenDisplay,(_Xconst char* a),(a),return)
 SDL_X11_SYM(int,XPeekEvent,(Display* a,XEvent* b),(a,b),return)
 SDL_X11_SYM(int,XPending,(Display* a),(a),return)
 SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j),(a,b,c,d,e,f,g,h,i,j),return)
-SDL_X11_SYM(int,XQueryColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return)
 SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return)
 SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return)
 SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return)
-SDL_X11_SYM(int,XReparentWindow,(Display* a,Window b,Window c,int d,int e),(a,b,c,d,e),return)
 SDL_X11_SYM(int,XResetScreenSaver,(Display* a),(a),return)
 SDL_X11_SYM(int,XResizeWindow,(Display* a,Window b,unsigned int c,unsigned int d),(a,b,c,d),return)
 SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return)
 SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return)
 SDL_X11_SYM(int,XSetClassHint,(Display* a,Window b,XClassHint* c),(a,b,c),return)
-SDL_X11_SYM(int,XSetCloseDownMode,(Display *a, int b),(a,b),return)
-SDL_X11_SYM(int,XSetForeground,(Display* a,GC b,unsigned long c),(a,b,c),return)
 SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return)
 SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return)
-SDL_X11_SYM(void,XSetRGBColormaps,( Display *a,Window b,XStandardColormap *c,int d,Atom e),(a,b,c,d,e),return)
 SDL_X11_SYM(int,XSetSelectionOwner,(Display* a,Atom b,Window c,Time d),(a,b,c,d),return)
 SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return)
 SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),)
-SDL_X11_SYM(int,XSetWindowBackground,(Display* a,Window b,unsigned long c),(a,b,c),return)
-SDL_X11_SYM(int,XSetWindowBackgroundPixmap,(Display* a,Window b,Pixmap c),(a,b,c),return)
-SDL_X11_SYM(int,XSetWindowColormap,(Display* a,Window b,Colormap c),(a,b,c),return)
 SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return)
 SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),)
 SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return)
@@ -157,10 +124,6 @@
 SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display* a,int b,SDL_X11_XESetWireToEventRetType c),(a,b,c),return)
 SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,SDL_X11_XESetEventToWireRetType c),(a,b,c),return)
 SDL_X11_SYM(XExtensionErrorHandler,XSetExtensionErrorHandler,(XExtensionErrorHandler a),(a),return)
-SDL_X11_SYM(int,XFillRectangle,(Display *dpy,Drawable d,GC gc,int x,int y,unsigned int width,unsigned int height),(dpy,d,gc,x,y,width,height),return)
-SDL_X11_SYM(int,XSetBackground,(Display *dpy,GC gc,unsigned long background),(dpy,gc,background),return)
-SDL_X11_SYM(Status,XInitImage,(XImage *image),(image),return)
-SDL_X11_SYM(int,XSetClipMask,(Display *dpy,GC gc,Pixmap pixmap),(dpy,gc,pixmap),return)
 
 #if NeedWidePrototypes
 SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,unsigned int b,int c),(a,b,c),return)
@@ -243,42 +206,6 @@
 SDL_X11_SYM(void,XScreenSaverSuspend,(Display *dpy,Bool suspend),(dpy,suspend),return)
 #endif
 
-/* XRender support */
-#if SDL_VIDEO_DRIVER_X11_XRENDER
-SDL_X11_MODULE(XRENDER)
-SDL_X11_SYM(Bool,XRenderQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return)
-SDL_X11_SYM(Bool,XRenderQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
-SDL_X11_SYM(XRenderPictFormat*,XRenderFindVisualFormat,(Display *dpy,_Xconst Visual *visual),(dpy,visual),return)
-SDL_X11_SYM(XRenderPictFormat*,XRenderFindStandardFormat,(Display *dpy,int format),(dpy,format),return)
-SDL_X11_SYM(XRenderPictFormat*,XRenderFindFormat,(Display *dpy,unsigned long mask,_Xconst XRenderPictFormat* templ,int count),(dpy,mask,templ,count),return)
-SDL_X11_SYM(Picture,XRenderCreatePicture,(Display *dpy,Drawable drawable,_Xconst XRenderPictFormat* format,unsigned long valuemask,_Xconst XRenderPictureAttributes* attributes),(dpy,drawable,format,valuemask,attributes),return)
-SDL_X11_SYM(void,XRenderFreePicture,(Display *dpy,Picture picture),(dpy,picture),return)
-SDL_X11_SYM(void,XRenderChangePicture,(Display *dpy,Picture picture,unsigned long valuemask,_Xconst XRenderPictureAttributes* attributes),(dpy,picture,valuemask,attributes),return)
-SDL_X11_SYM(void,XRenderComposite,(Display *dpy,int op,Picture src,Picture mask,Picture dst,int src_x,int src_y,int mask_x,int mask_y,int dst_x,int dst_y,unsigned int width,unsigned int height),(dpy,op,src,mask,dst,src_x,src_y,mask_x,mask_y,dst_x,dst_y,width,height),return)
-SDL_X11_SYM(Picture,XRenderCreateSolidFill,(Display *dpy,const XRenderColor *color),(dpy,color),return)
-SDL_X11_SYM(void,XRenderSetPictureTransform,(Display *dpy,Picture picture,XTransform *transform),(dpy,picture,transform),return)
-SDL_X11_SYM(void,XRenderFillRectangle,(Display *dpy,int op,Picture dst,_Xconst XRenderColor *color,int x,int y,unsigned int width,unsigned int height),(dpy,op,dst,color,x,y,width,height),return)
-SDL_X11_SYM(void,XRenderFillRectangles,(Display *dpy,int op,Picture dst,_Xconst XRenderColor *color,_Xconst XRectangle *rectangles,int n_rects),(dpy,op,dst,color,rectangles,n_rects),return)
-SDL_X11_SYM(void,XRenderSetPictureFilter,(Display *dpy,Picture picture,const char *filter,XFixed *params,int nparams),(dpy,picture,filter,params,nparams),return)
-#endif
-
-#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
-SDL_X11_MODULE(XDAMAGE)
-SDL_X11_SYM(Bool,XDamageQueryExtension,(Display *dpy,int *event_base_return,int *error_base_return),(dpy,event_base_return,error_base_return),return)
-SDL_X11_SYM(Status,XDamageQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
-SDL_X11_SYM(Damage,XDamageCreate,(Display *dpy,Drawable d,int level),(dpy,d,level),return)
-SDL_X11_SYM(void,XDamageSubtract,(Display *dpy,Damage damage,XserverRegion repair,XserverRegion parts),(dpy,damage,repair,parts),return)
-SDL_X11_SYM(void,XDamageDestroy,(Display *dpy,Damage damage),(dpy,damage),return)
-#endif
-
-#ifdef SDL_VIDEO_DRIVER_X11_XFIXES
-SDL_X11_MODULE(XFIXES)
-SDL_X11_SYM(Bool,XFixesQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return)
-SDL_X11_SYM(Status,XFixesQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
-SDL_X11_SYM(void,XFixesSetGCClipRegion,(Display *dpy,GC gc,int clip_x,int clip_y,XserverRegion region),(dpy,gc,clip_x,clip_y,region),return)
-SDL_X11_SYM(void,XFixesSetPictureClipRegion,(Display *dpy,XID picture,int clip_x,int clip_y,XserverRegion region),(dpy,picture,clip_x,clip_y,region),return)
-#endif
-
 #if SDL_VIDEO_DRIVER_X11_XSHAPE
 SDL_X11_MODULE(XSHAPE)
 SDL_X11_SYM(void,XShapeCombineMask,(Display *dpy,Window dest,int dest_kind,int x_off,int y_off,Pixmap src,int op),(dpy,dest,dest_kind,x_off,y_off,src,op),)
--- a/src/video/x11/SDL_x11video.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/x11/SDL_x11video.c	Sun Feb 06 21:23:32 2011 -0800
@@ -29,7 +29,7 @@
 #include "../SDL_pixels_c.h"
 
 #include "SDL_x11video.h"
-#include "SDL_x11render.h"
+#include "SDL_x11framebuffer.h"
 #include "SDL_x11shape.h"
 #include "SDL_x11touch.h" 
 
@@ -205,10 +205,15 @@
     device->RestoreWindow = X11_RestoreWindow;
     device->SetWindowGrab = X11_SetWindowGrab;
     device->DestroyWindow = X11_DestroyWindow;
+    device->CreateWindowFramebuffer = X11_CreateWindowFramebuffer;
+    device->UpdateWindowFramebuffer = X11_UpdateWindowFramebuffer;
+    device->DestroyWindowFramebuffer = X11_DestroyWindowFramebuffer;
     device->GetWindowWMInfo = X11_GetWindowWMInfo;
+
     device->shape_driver.CreateShaper = X11_CreateShaper;
     device->shape_driver.SetWindowShape = X11_SetWindowShape;
     device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;
+
 #if SDL_VIDEO_OPENGL_GLX
     device->GL_LoadLibrary = X11_GL_LoadLibrary;
     device->GL_GetProcAddress = X11_GL_GetProcAddress;
@@ -350,10 +355,6 @@
         return -1;
     }
 
-#if SDL_VIDEO_RENDER_X11
-    X11_AddRenderDriver(_this);
-#endif
-
     if (X11_InitKeyboard(_this) != 0) {
         return -1;
     }
--- a/src/video/x11/SDL_x11video.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/x11/SDL_x11video.h	Sun Feb 06 21:23:32 2011 -0800
@@ -24,6 +24,8 @@
 #ifndef _SDL_x11video_h
 #define _SDL_x11video_h
 
+#include "SDL_keysym.h"
+
 #include "../SDL_sysvideo.h"
 
 #include <X11/Xlib.h>
@@ -45,15 +47,6 @@
 #if SDL_VIDEO_DRIVER_X11_SCRNSAVER
 #include <X11/extensions/scrnsaver.h>
 #endif
-#if SDL_VIDEO_DRIVER_X11_XRENDER
-#include <X11/extensions/Xrender.h>
-#endif
-#if SDL_VIDEO_DRIVER_X11_XDAMAGE
-#include <X11/extensions/Xdamage.h>
-#endif
-#if SDL_VIDEO_DRIVER_X11_XFIXES
-#include <X11/extensions/Xfixes.h>
-#endif
 #if SDL_VIDEO_DRIVER_X11_XSHAPE
 #include <X11/extensions/shape.h>
 #endif
--- a/src/video/x11/SDL_x11window.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/x11/SDL_x11window.c	Sun Feb 06 21:23:32 2011 -0800
@@ -30,7 +30,6 @@
 #include "SDL_x11mouse.h"
 #include "SDL_x11gamma.h"
 #include "SDL_x11shape.h"
-#include "../Xext/extensions/StdCmap.h"
 
 #ifdef SDL_VIDEO_DRIVER_PANDORA
 #include "SDL_x11opengles.h"
@@ -176,6 +175,7 @@
         } else {
             window->flags &= ~SDL_WINDOW_SHOWN;
         }
+        data->visual = attrib.visual;
     }
 
     {
--- a/src/video/x11/SDL_x11window.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/src/video/x11/SDL_x11window.h	Sun Feb 06 21:23:32 2011 -0800
@@ -28,6 +28,14 @@
 {
     SDL_Window *window;
     Window xwindow;
+    Visual *visual;
+#ifndef NO_SHARED_MEMORY
+    /* MIT shared memory extension information */
+    SDL_bool use_mitshm;
+    XShmSegmentInfo shminfo;
+#endif
+    XImage *ximage;
+    GC gc;
     XIC ic;
     SDL_bool created;
     struct SDL_VideoData *videodata;
--- a/test/Makefile.in	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/Makefile.in	Sun Feb 06 21:23:32 2011 -0800
@@ -7,7 +7,7 @@
 CFLAGS  = @CFLAGS@
 LIBS	= @LIBS@
 
-TARGETS = checkkeys$(EXE) graywin$(EXE) loopwave$(EXE) testalpha$(EXE) testatomic$(EXE) testaudioinfo$(EXE) testbitmap$(EXE) testblitspeed$(EXE) testcursor$(EXE) testdraw2$(EXE) testdyngles$(EXE) testdyngl$(EXE) testerror$(EXE) testfile$(EXE) testfill$(EXE) testgamma$(EXE) testgl2$(EXE) testgles$(EXE) testgl$(EXE) testhaptic$(EXE) testhread$(EXE) testiconv$(EXE) testime$(EXE) testintersections$(EXE) testjoystick$(EXE) testkeys$(EXE) testloadso$(EXE) testlock$(EXE) testmultiaudio$(EXE) testoverlay2$(EXE) testoverlay$(EXE) testpalette$(EXE) testplatform$(EXE) testpower$(EXE) testresample$(EXE) testsem$(EXE) testshape$(EXE) testsprite2$(EXE) testsprite$(EXE) testspriteminimal$(EXE) testtimer$(EXE) testver$(EXE) testvidinfo$(EXE) testwin$(EXE) testwm2$(EXE) testwm$(EXE) threadwin$(EXE) torturethread$(EXE) testgesture$(EXE)
+TARGETS = checkkeys$(EXE) graywin$(EXE) loopwave$(EXE) testalpha$(EXE) testatomic$(EXE) testaudioinfo$(EXE) testbitmap$(EXE) testblitspeed$(EXE) testcursor$(EXE) testdraw2$(EXE) testdyngles$(EXE) testdyngl$(EXE) testerror$(EXE) testfile$(EXE) testfill$(EXE) testgamma$(EXE) testgl2$(EXE) testgles$(EXE) testgl$(EXE) testhaptic$(EXE) testhread$(EXE) testiconv$(EXE) testime$(EXE) testintersections$(EXE) testjoystick$(EXE) testkeys$(EXE) testloadso$(EXE) testlock$(EXE) testmultiaudio$(EXE) testoverlay2$(EXE) testoverlay$(EXE) testplatform$(EXE) testpower$(EXE) testresample$(EXE) testsem$(EXE) testshape$(EXE) testsprite2$(EXE) testsprite$(EXE) testspriteminimal$(EXE) testtimer$(EXE) testver$(EXE) testvidinfo$(EXE) testwin$(EXE) testwm2$(EXE) testwm$(EXE) threadwin$(EXE) torturethread$(EXE) testgesture$(EXE)
 
 all: Makefile $(TARGETS)
 
@@ -101,9 +101,6 @@
 testoverlay$(EXE): $(srcdir)/testoverlay.c
 	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
 
-testpalette$(EXE): $(srcdir)/testpalette.c
-	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
-
 testplatform$(EXE): $(srcdir)/testplatform.c
 	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
 
--- a/test/automated/Makefile	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/automated/Makefile	Sun Feb 06 21:23:32 2011 -0800
@@ -9,8 +9,6 @@
 
 SRC         	:= testsdl.c \
 						platform/platform.c \
-						rwops/rwops.c \
-						rwops/TestSupportRWops.c \
 						rect/rect.c \
 						surface/surface.c \
 						render/render.c \
@@ -18,6 +16,8 @@
 COMMON_SRC     := SDL_at.c common/common.c
 COMMON_INCLUDE := SDL_at.h
 
+RWOPS_SRC      := rwops/rwops.c rwops/TestSupportRWops_Generic.c
+
 TESTS_ALL := testsdl \
 	platform/platform \
 	rwops/rwops \
@@ -35,14 +35,14 @@
 test: all
 	@./testsdl
 
-testsdl: $(SRC) $(COMMON_SRC)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(SRC) $(COMMON_SRC)
+testsdl: $(SRC) $(RWOPS_SRC) $(COMMON_SRC)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(SRC) $(RWOPS_SRC) $(COMMON_SRC)
 
 platform/platform: platform/platform.c $(COMMON_INCLUDE) $(COMMON_SRC)
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ platform/platform.c $(COMMON_SRC) -DTEST_STANDALONE
 
-rwops/rwops: rwops/rwops.c $(COMMON_INCLUDE) $(COMMON_SRC)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ rwops/rwops.c $(COMMON_SRC) -DTEST_STANDALONE
+rwops/rwops: $(RWOPS_SRC) $(COMMON_INCLUDE) $(COMMON_SRC)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(RWOPS_SRC) $(COMMON_SRC) -DTEST_STANDALONE
 
 rect/rect: rect/rect.c $(COMMON_INCLUDE) $(COMMON_SRC)
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ rect/rect.c $(COMMON_SRC) -DTEST_STANDALONE
--- a/test/automated/common/img_blitblend.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/automated/common/img_blitblend.c	Sun Feb 06 21:23:32 2011 -0800
@@ -1055,517 +1055,6 @@
   "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
 };
 
-static const SurfaceImage_t img_blendMask = {
-  80, 60, 3,
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377"
-  "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0"
-  "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0"
-  "\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0"
-  "\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0"
-  "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0"
-  "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0"
-  "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0"
-  "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0"
-  "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0"
-  "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0"
-  "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0"
-  "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0"
-  "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0"
-  "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0"
-  "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0"
-  "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0"
-  "\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\0\0\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377"
-  "\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377"
-  "\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377"
-  "\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0"
-  "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377"
-  "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0"
-  "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0"
-  "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0"
-  "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0"
-  "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0"
-  "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0"
-  "\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\377\377"
-  "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-  "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-  "\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377"
-  "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0"
-  "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0"
-  "\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377"
-  "\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377"
-  "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0"
-  "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0"
-  "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0"
-  "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0"
-  "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0"
-  "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\377\377\0\377\377\0"
-  "\377\377\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377"
-  "\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0"
-  "\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0"
-  "\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377"
-  "\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377"
-  "\0\0\0\0\0\0\0\377\377\0\377\377\0\0\0\0\0\0\0\377\377\0\377\377\0\377\377"
-  "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-  "\0\0",
-};
-
 static const SurfaceImage_t img_blendMod = {
   80, 60, 3,
   "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
--- a/test/automated/render/render.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/automated/render/render.c	Sun Feb 06 21:23:32 2011 -0800
@@ -25,6 +25,7 @@
 #define FACE_W       img_face.width
 #define FACE_H       img_face.height
 
+static SDL_Renderer *renderer;
 
 /*
  * Prototypes.
@@ -37,7 +38,6 @@
 static int render_hasTexAlpha (void);
 static int render_clearScreen (void);
 /* Testcases. */
-static int render_testReadWrite (void);
 static int render_testPrimitives (void);
 static int render_testPrimitivesBlend (void);
 static int render_testBlit (void);
@@ -67,7 +67,7 @@
    rect.y = 0;
    rect.w = 80;
    rect.h = 60;
-   ret = SDL_RenderReadPixels( &rect, FORMAT, pix, 80*4 );
+   ret = SDL_RenderReadPixels(renderer, &rect, FORMAT, pix, 80*4 );
    if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) )
       return 1;
 
@@ -98,7 +98,7 @@
    SDL_RendererInfo info;
 
    /* Read pixels. */
-   ret = SDL_RenderReadPixels( NULL, FORMAT, pix, 80*4 );
+   ret = SDL_RenderReadPixels(renderer, NULL, FORMAT, pix, 80*4 );
    if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) )
       return 1;
 
@@ -109,7 +109,7 @@
       return 1;
 
    /* Dump surface. */
-   SDL_GetRendererInfo(&info);
+   SDL_GetRendererInfo(renderer,&info);
    sprintf(name, "%s-%s-%d.bmp", SDL_GetCurrentVideoDriver(), info.name, index);
    SDL_SaveBMP(testsur, name);
 
@@ -140,14 +140,14 @@
    fail = 0;
 
    /* Set colour. */
-   ret = SDL_SetRenderDrawColor( 100, 100, 100, 100 );
+   ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100 );
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_GetRenderDrawColor( &r, &g, &b, &a );
+   ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a );
    if (!render_isSupported(ret))
       fail = 1;
    /* Restore natural. */
-   ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
    if (!render_isSupported(ret))
       fail = 1;
 
@@ -172,46 +172,37 @@
 
    fail = 0;
 
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND );
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_GetRenderDrawBlendMode( &mode );
+   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
    if (!render_isSupported(ret))
       fail = 1;
    ret = (mode != SDL_BLENDMODE_BLEND);
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD );
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_GetRenderDrawBlendMode( &mode );
+   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
    if (!render_isSupported(ret))
       fail = 1;
    ret = (mode != SDL_BLENDMODE_ADD);
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_MOD );
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_GetRenderDrawBlendMode( &mode );
+   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
    if (!render_isSupported(ret))
       fail = 1;
    ret = (mode != SDL_BLENDMODE_MOD);
    if (!render_isSupported(ret))
       fail = 1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MASK );
-   if (!render_isSupported(ret))
-      fail = 1;
-   ret = SDL_GetRenderDrawBlendMode( &mode );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
    if (!render_isSupported(ret))
       fail = 1;
-   ret = (mode != SDL_BLENDMODE_MASK);
-   if (!render_isSupported(ret))
-      fail = 1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
-   if (!render_isSupported(ret))
-      fail = 1;
-   ret = SDL_GetRenderDrawBlendMode( &mode );
+   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
    if (!render_isSupported(ret))
       fail = 1;
    ret = (mode != SDL_BLENDMODE_NONE);
@@ -247,7 +238,7 @@
          );
    if (face == NULL)
       return 0;
-   tface = SDL_CreateTextureFromSurface( 0, face );
+   tface = SDL_CreateTextureFromSurface(renderer, face);
    SDL_FreeSurface(face);
 
    return tface;
@@ -334,26 +325,26 @@
    int ret;
 
    /* Set colour. */
-   ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
    /*
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
    */
 
    /* Clear screen. */
-   ret = SDL_RenderFillRect( NULL );
+   ret = SDL_RenderFillRect(renderer, NULL );
    /*
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
    */
 
    /* Set defaults. */
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
    /*
    if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
       return -1;
    */
-   ret = SDL_SetRenderDrawColor( 255, 255, 255, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE );
    /*
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
@@ -364,31 +355,6 @@
 
 
 /**
- * @brief Test reading and writing framebuffer
- */
-static int render_testReadWrite (void)
-{
-   int ret;
-   SDL_Rect rect;
-
-   /* Write pixels. */
-   rect.x = 0;
-   rect.y = 0;
-   rect.w = 80;
-   rect.h = 60;
-   ret = SDL_RenderWritePixels( &rect, SDL_PIXELFORMAT_RGB24, img_primitives.pixel_data, img_primitives.width*img_primitives.bytes_per_pixel );
-   if (SDL_ATassert( "SDL_RenderWritePixels", ret==0) )
-      return 1;
-
-   /* See if it's the same. */
-   if (render_compare( "Read/write output not the same.", &img_primitives, ALLOWABLE_ERROR_OPAQUE ))
-      return -1;
-
-   return 0;
-}
-
-
-/**
  * @brief Tests the SDL primitives for rendering.
  */
 static int render_testPrimitives (void)
@@ -410,10 +376,10 @@
    rect.y = 0;
    rect.w = 40;
    rect.h = 80;
-   ret = SDL_SetRenderDrawColor( 13, 73, 200, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 13, 73, 200, SDL_ALPHA_OPAQUE );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( &rect );
+   ret = SDL_RenderFillRect(renderer, &rect );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
 
@@ -422,10 +388,10 @@
    rect.y = 10;
    rect.w = 60;
    rect.h = 40;
-   ret = SDL_SetRenderDrawColor( 200, 0, 100, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 200, 0, 100, SDL_ALPHA_OPAQUE );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( &rect );
+   ret = SDL_RenderFillRect(renderer, &rect );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
 
@@ -436,41 +402,41 @@
    for (y=0; y<3; y++) {
       x = y % 2;
       for (; x<80; x+=2) {
-         ret = SDL_SetRenderDrawColor( x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE );
+         ret = SDL_SetRenderDrawColor(renderer, x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE );
          if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
             return -1;
-         ret = SDL_RenderDrawPoint( x, y );
+         ret = SDL_RenderDrawPoint(renderer, x, y );
          if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0))
             return -1;
       }
    }
 
    /* Draw some lines. */
-   ret = SDL_SetRenderDrawColor( 0, 255, 0, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 0, 30, 80, 30 );
+   ret = SDL_RenderDrawLine(renderer, 0, 30, 80, 30 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawColor( 55, 55, 5, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 55, 55, 5, SDL_ALPHA_OPAQUE );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 40, 30, 40, 60 );
+   ret = SDL_RenderDrawLine(renderer, 40, 30, 40, 60 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawColor( 5, 105, 105, SDL_ALPHA_OPAQUE );
+   ret = SDL_SetRenderDrawColor(renderer, 5, 105, 105, SDL_ALPHA_OPAQUE );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 0, 0, 29, 29 );
+   ret = SDL_RenderDrawLine(renderer, 0, 0, 29, 29 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 29, 30, 0, 59 );
+   ret = SDL_RenderDrawLine(renderer, 29, 30, 0, 59 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 79, 0, 50, 29 );
+   ret = SDL_RenderDrawLine(renderer, 79, 0, 50, 29 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
-   ret = SDL_RenderDrawLine( 79, 59, 50, 30 );
+   ret = SDL_RenderDrawLine(renderer, 79, 59, 50, 30 );
    if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
       return -1;
 
@@ -500,77 +466,77 @@
       return 0;
 
    /* Create some rectangles for each blend mode. */
-   ret = SDL_SetRenderDrawColor( 255, 255, 255, 0 );
+   ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0 );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
    if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( NULL );
+   ret = SDL_RenderFillRect(renderer, NULL );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
    rect.x = 10;
    rect.y = 25;
    rect.w = 40;
    rect.h = 25;
-   ret = SDL_SetRenderDrawColor( 240, 10, 10, 75 );
+   ret = SDL_SetRenderDrawColor(renderer, 240, 10, 10, 75 );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD );
    if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( &rect );
+   ret = SDL_RenderFillRect(renderer, &rect );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
    rect.x = 30;
    rect.y = 40;
    rect.w = 45;
    rect.h = 15;
-   ret = SDL_SetRenderDrawColor( 10, 240, 10, 100 );
+   ret = SDL_SetRenderDrawColor(renderer, 10, 240, 10, 100 );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND );
    if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( &rect );
+   ret = SDL_RenderFillRect(renderer, &rect );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
    rect.x = 25;
    rect.y = 25;
    rect.w = 25;
    rect.h = 25;
-   ret = SDL_SetRenderDrawColor( 10, 10, 240, 125 );
+   ret = SDL_SetRenderDrawColor(renderer, 10, 10, 240, 125 );
    if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
       return -1;
-   ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
    if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
       return -1;
-   ret = SDL_RenderFillRect( &rect );
+   ret = SDL_RenderFillRect(renderer, &rect );
    if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
       return -1;
 
    /* Draw blended lines, lines for everyone. */
    for (i=0; i<SCREEN_W; i+=2)  {
-      ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i );
+      ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i );
       if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
          return -1;
-      ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
-            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
+      ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
+            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
       if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
          return -1;
-      ret = SDL_RenderDrawLine( 0, 0, i, 59 );
+      ret = SDL_RenderDrawLine(renderer, 0, 0, i, 59 );
       if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
          return -1;
    }
    for (i=0; i<SCREEN_H; i+=2)  {
-      ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i );
+      ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i );
       if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
          return -1;
-      ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
-            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
+      ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
+            (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
       if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
          return -1;
-      ret = SDL_RenderDrawLine( 0, 0, 79, i );
+      ret = SDL_RenderDrawLine(renderer, 0, 0, 79, i );
       if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
          return -1;
    }
@@ -578,14 +544,14 @@
    /* Draw points. */
    for (j=0; j<SCREEN_H; j+=3) {
       for (i=0; i<SCREEN_W; i+=3) {
-         ret = SDL_SetRenderDrawColor( j*4, i*3, j*4, i*3 );
+         ret = SDL_SetRenderDrawColor(renderer, j*4, i*3, j*4, i*3 );
          if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
             return -1;
-         ret = SDL_SetRenderDrawBlendMode( ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND :
-               ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
+         ret = SDL_SetRenderDrawBlendMode(renderer, ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND :
+               ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE );
          if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
             return -1;
-         ret = SDL_RenderDrawPoint( i, j );
+         ret = SDL_RenderDrawPoint(renderer, i, j );
          if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0))
             return -1;
       }
@@ -634,7 +600,7 @@
          /* Blitting. */
          rect.x = i;
          rect.y = j;
-         ret = SDL_RenderCopy( tface, NULL, &rect );
+         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
          if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
             return -1;
       }
@@ -691,7 +657,7 @@
          /* Blitting. */
          rect.x = i;
          rect.y = j;
-         ret = SDL_RenderCopy( tface, NULL, &rect );
+         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
          if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
             return -1;
       }
@@ -753,7 +719,7 @@
          /* Blitting. */
          rect.x = i;
          rect.y = j;
-         ret = SDL_RenderCopy( tface, NULL, &rect );
+         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
          if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
             return -1;
       }
@@ -803,7 +769,7 @@
          /* Blitting. */
          rect.x = i;
          rect.y = j;
-         ret = SDL_RenderCopy( tface, NULL, &rect );
+         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
          if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
             return -1;
       }
@@ -858,13 +824,6 @@
             &img_blendNone, ALLOWABLE_ERROR_OPAQUE ))
       return -1;
 
-   /* Test Mask. */
-   if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MASK ))
-      return -1;
-   if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MASK).",
-            &img_blendMask, ALLOWABLE_ERROR_OPAQUE ))
-      return -1;
-
    /* Test Blend. */
    if (render_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ))
       return -1;
@@ -906,7 +865,7 @@
 
          /* Crazy blending mode magic. */
          mode = (i/4*j/4) % 4;
-         if (mode==0) mode = SDL_BLENDMODE_MASK;
+         if (mode==0) mode = SDL_BLENDMODE_NONE;
          else if (mode==1) mode = SDL_BLENDMODE_BLEND;
          else if (mode==2) mode = SDL_BLENDMODE_ADD;
          else if (mode==3) mode = SDL_BLENDMODE_MOD;
@@ -917,7 +876,7 @@
          /* Blitting. */
          rect.x = i;
          rect.y = j;
-         ret = SDL_RenderCopy( tface, NULL, &rect );
+         ret = SDL_RenderCopy(renderer, tface, NULL, &rect );
          if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
             return -1;
       }
@@ -958,9 +917,6 @@
       SDL_ATprintVerbose( 1, "      Texture Alpha Mod supported\n" );
 
    /* Software surface blitting. */
-   ret = render_testReadWrite();
-   if (ret)
-      return -1;
    ret = render_testPrimitives();
    if (ret)
       return -1;
@@ -1005,7 +961,7 @@
    const char *driver, *str;
    char msg[256];
    SDL_Window *w;
-   SDL_RendererInfo renderer;
+   SDL_RendererInfo info;
 
    /* Initializes the SDL subsystems. */
    ret = SDL_Init(0);
@@ -1046,7 +1002,7 @@
        */
       SDL_ATbegin( "Initializing video mode" );
       /* Initialize video mode. */
-      ret = SDL_VideoInit( driver, 0 );
+      ret = SDL_VideoInit( driver );
       if (SDL_ATvassert( ret==0, "SDL_VideoInit( %s, 0 )", driver ))
          goto err_cleanup;
       /* Check to see if it's the one we want. */
@@ -1079,18 +1035,18 @@
             goto err_cleanup;
 
          /* Get renderer info. */
-         ret = SDL_GetRenderDriverInfo( j, &renderer );
+         ret = SDL_GetRenderDriverInfo( j, &info );
          if (ret != 0)
             goto err_cleanup;
 
          /* Set testcase name. */
-         SDL_snprintf( msg, sizeof(msg), "Renderer %s", renderer.name );
-         SDL_ATprintVerbose( 1, "    %d) %s\n", j+1, renderer.name );
+         SDL_snprintf( msg, sizeof(msg), "Renderer %s", info.name );
+         SDL_ATprintVerbose( 1, "    %d) %s\n", j+1, info.name );
          SDL_ATbegin( msg );
 
          /* Set renderer. */
-         ret = SDL_CreateRenderer( w, j, 0 );
-         if (SDL_ATassert( "SDL_CreateRenderer", ret==0 ))
+         renderer = SDL_CreateRenderer( w, j, 0 );
+         if (SDL_ATassert( "SDL_CreateRenderer", renderer!=0 ))
             goto err_cleanup;
 
          /*
--- a/test/automated/surface/surface.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/automated/surface/surface.c	Sun Feb 06 21:23:32 2011 -0800
@@ -26,8 +26,6 @@
  */
 /* Testcases. */
 static void surface_testLoad( SDL_Surface *testsur );
-static void surface_testPrimitives( SDL_Surface *testsur );
-static void surface_testPrimitivesBlend( SDL_Surface *testsur );
 static void surface_testBlit( SDL_Surface *testsur );
 static int surface_testBlitBlendMode( SDL_Surface *testsur, SDL_Surface *face, int mode );
 static void surface_testBlitBlend( SDL_Surface *testsur );
@@ -85,174 +83,6 @@
 
 
 /**
- * @brief Tests the SDL primitives for rendering.
- */
-static void surface_testPrimitives( SDL_Surface *testsur )
-{
-   int ret;
-   int x, y;
-   SDL_Rect rect;
-
-   SDL_ATbegin( "Primitives Test" );
-
-   /* Clear surface. */
-   ret = SDL_FillRect( testsur, NULL,
-         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
-   if (SDL_ATassert( "SDL_FillRect", ret == 0))
-      return;
-
-   /* Draw a rectangle. */
-   rect.x = 40;
-   rect.y = 0;
-   rect.w = 40;
-   rect.h = 80;
-   ret = SDL_FillRect( testsur, &rect,
-         SDL_MapRGB( testsur->format, 13, 73, 200 ) );
-   if (SDL_ATassert( "SDL_FillRect", ret == 0))
-      return;
-
-   /* Draw a rectangle. */
-   rect.x = 10;
-   rect.y = 10;
-   rect.w = 60;
-   rect.h = 40;
-   ret = SDL_FillRect( testsur, &rect,
-         SDL_MapRGB( testsur->format, 200, 0, 100 ) );
-   if (SDL_ATassert( "SDL_FillRect", ret == 0))
-      return;
-
-   /* Draw some points like so:
-    * X.X.X.X..
-    * .X.X.X.X.
-    * X.X.X.X.. */
-   for (y=0; y<3; y++) {
-      x = y % 2;
-      for (; x<80; x+=2) {
-         ret = SDL_DrawPoint( testsur, x, y,
-               SDL_MapRGB( testsur->format, x*y, x*y/2, x*y/3 ) );
-         if (SDL_ATassert( "SDL_DrawPoint", ret == 0))
-            return;
-      }
-   }
-
-   /* Draw some lines. */
-   ret = SDL_DrawLine( testsur, 0, 30, 80, 30,
-         SDL_MapRGB( testsur->format, 0, 255, 0 ) );
-   if (SDL_ATassert( "SDL_DrawLine", ret == 0))
-      return;
-   ret = SDL_DrawLine( testsur, 40, 30, 40, 60,
-         SDL_MapRGB( testsur->format, 55, 55, 5 ) );
-   if (SDL_ATassert( "SDL_DrawLine", ret == 0))
-      return;
-   ret = SDL_DrawLine( testsur, 0, 0, 29, 29,
-         SDL_MapRGB( testsur->format, 5, 105, 105 ) );
-   if (SDL_ATassert( "SDL_DrawLine", ret == 0))
-      return;
-   ret = SDL_DrawLine( testsur, 29, 30, 0, 59,
-         SDL_MapRGB( testsur->format, 5, 105, 105 ) );
-   if (SDL_ATassert( "SDL_DrawLine", ret == 0))
-      return;
-   ret = SDL_DrawLine( testsur, 79, 0, 50, 29,
-         SDL_MapRGB( testsur->format, 5, 105, 105 ) );
-   if (SDL_ATassert( "SDL_DrawLine", ret == 0))
-      return;
-   ret = SDL_DrawLine( testsur, 79, 59, 50, 30,
-         SDL_MapRGB( testsur->format, 5, 105, 105 ) );
-   if (SDL_ATassert( "SDL_DrawLine", ret == 0))
-      return;
-
-   /* See if it's the same. */
-   if (SDL_ATassert( "Primitives output not the same.",
-            surface_compare( testsur, &img_primitives, 0 )==0 ))
-      return;
-
-   SDL_ATend();
-}
-
-
-/**
- * @brief Tests the SDL primitives with alpha for rendering.
- */
-static void surface_testPrimitivesBlend( SDL_Surface *testsur )
-{
-   int ret;
-   int i, j;
-   SDL_Rect rect;
-
-   SDL_ATbegin( "Primitives Blend Test" );
-
-   /* Clear surface. */
-   ret = SDL_FillRect( testsur, NULL,
-         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
-   if (SDL_ATassert( "SDL_FillRect", ret == 0))
-      return;
-
-   /* Create some rectangles for each blend mode. */
-   ret = SDL_BlendFillRect( testsur, NULL, SDL_BLENDMODE_NONE, 255, 255, 255, 0 );
-   if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
-      return;
-   rect.x = 10;
-   rect.y = 25;
-   rect.w = 40;
-   rect.h = 25;
-   ret = SDL_BlendFillRect( testsur, &rect, SDL_BLENDMODE_ADD, 240, 10, 10, 75 );
-   if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
-      return;
-   rect.x = 30;
-   rect.y = 40;
-   rect.w = 45;
-   rect.h = 15;
-   ret = SDL_BlendFillRect( testsur, &rect, SDL_BLENDMODE_BLEND, 10, 240, 10, 100 );
-   if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
-      return;
-   rect.x = 25;
-   rect.y = 25;
-   rect.w = 25;
-   rect.h = 25;
-   ret = SDL_BlendFillRect( testsur, &rect, SDL_BLENDMODE_MOD, 10, 10, 240, 125 );
-   if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
-      return;
-
-   /* Draw blended lines, lines for everyone. */
-   for (i=0; i<testsur->w; i+=2)  {
-      ret = SDL_BlendLine( testsur, 0, 0, i, 59,
-            (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
-               (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD,
-            60+2*i, 240-2*i, 50, 3*i );
-      if (SDL_ATassert( "SDL_BlendLine", ret == 0))
-         return;
-   }
-   for (i=0; i<testsur->h; i+=2)  {
-      ret = SDL_BlendLine( testsur, 0, 0, 79, i,
-            (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
-               (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD,
-            60+2*i, 240-2*i, 50, 3*i );
-      if (SDL_ATassert( "SDL_BlendLine", ret == 0))
-         return;
-   }
-
-   /* Draw points. */
-   for (j=0; j<testsur->h; j+=3) {
-      for (i=0; i<testsur->w; i+=3) {
-      ret = SDL_BlendPoint( testsur, i, j,
-            ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND :
-               ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD,
-            j*4, i*3, j*4, i*3 );
-      if (SDL_ATassert( "SDL_BlendPoint", ret == 0))
-         return;
-      }
-   }
-
-   /* See if it's the same. */
-   if (SDL_ATassert( "Primitives output not the same.",
-            surface_compare( testsur, &img_blend, 0 )==0 ))
-      return;
-
-   SDL_ATend();
-}
-
-
-/**
  * @brief Tests some blitting routines.
  */
 static void surface_testBlit( SDL_Surface *testsur )
@@ -480,13 +310,6 @@
             surface_compare( testsur, &img_blendNone, 0 )==0 ))
       return;
 
-   /* Test Mask. */
-   if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MASK ))
-      return;
-   if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_MASK).",
-            surface_compare( testsur, &img_blendMask, 0 )==0 ))
-      return;
-
    /* Test Blend. */
    if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND ))
       return;
@@ -530,7 +353,7 @@
 
          /* Crazy blending mode magic. */
          mode = (i/4*j/4) % 4;
-         if (mode==0) mode = SDL_BLENDMODE_MASK;
+         if (mode==0) mode = SDL_BLENDMODE_NONE;
          else if (mode==1) mode = SDL_BLENDMODE_BLEND;
          else if (mode==2) mode = SDL_BLENDMODE_ADD;
          else if (mode==3) mode = SDL_BLENDMODE_MOD;
@@ -567,8 +390,6 @@
 void surface_runTests( SDL_Surface *testsur )
 {
    /* Software surface blitting. */
-   surface_testPrimitives( testsur );
-   surface_testPrimitivesBlend( testsur );
    surface_testBlit( testsur );
    surface_testBlitBlend( testsur );
 }
--- a/test/common.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/common.c	Sun Feb 06 21:23:32 2011 -0800
@@ -6,7 +6,7 @@
 #include "common.h"
 
 #define VIDEO_USAGE \
-"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display N] [--fullscreen | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab] [--double] [--triple]"
+"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display N] [--fullscreen | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab]"
 
 #define AUDIO_USAGE \
 "[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
@@ -211,14 +211,6 @@
         state->render_flags |= SDL_RENDERER_PRESENTVSYNC;
         return 1;
     }
-    if (SDL_strcasecmp(argv[index], "--double") == 0) {
-        state->render_flags |= SDL_RENDERER_PRESENTFLIP2;
-        return 1;
-    }
-    if (SDL_strcasecmp(argv[index], "--triple") == 0) {
-        state->render_flags |= SDL_RENDERER_PRESENTFLIP3;
-        return 1;
-    }
     if (SDL_strcasecmp(argv[index], "--noframe") == 0) {
         state->window_flags |= SDL_WINDOW_BORDERLESS;
         return 1;
@@ -329,21 +321,6 @@
 PrintRendererFlag(Uint32 flag)
 {
     switch (flag) {
-    case SDL_RENDERER_SINGLEBUFFER:
-        fprintf(stderr, "SingleBuffer");
-        break;
-    case SDL_RENDERER_PRESENTCOPY:
-        fprintf(stderr, "PresentCopy");
-        break;
-    case SDL_RENDERER_PRESENTFLIP2:
-        fprintf(stderr, "PresentFlip2");
-        break;
-    case SDL_RENDERER_PRESENTFLIP3:
-        fprintf(stderr, "PresentFlip3");
-        break;
-    case SDL_RENDERER_PRESENTDISCARD:
-        fprintf(stderr, "PresentDiscard");
-        break;
     case SDL_RENDERER_PRESENTVSYNC:
         fprintf(stderr, "PresentVSync");
         break;
@@ -357,53 +334,6 @@
 }
 
 static void
-PrintBlendMode(Uint32 flag)
-{
-    switch (flag) {
-    case SDL_BLENDMODE_NONE:
-        fprintf(stderr, "None");
-        break;
-    case SDL_BLENDMODE_MASK:
-        fprintf(stderr, "Mask");
-        break;
-    case SDL_BLENDMODE_BLEND:
-        fprintf(stderr, "Blend");
-        break;
-    case SDL_BLENDMODE_ADD:
-        fprintf(stderr, "Add");
-        break;
-    case SDL_BLENDMODE_MOD:
-        fprintf(stderr, "Mod");
-        break;
-    default:
-        fprintf(stderr, "0x%8.8x", flag);
-        break;
-    }
-}
-
-static void
-PrintScaleMode(Uint32 flag)
-{
-    switch (flag) {
-    case SDL_SCALEMODE_NONE:
-        fprintf(stderr, "None");
-        break;
-    case SDL_SCALEMODE_FAST:
-        fprintf(stderr, "Fast");
-        break;
-    case SDL_SCALEMODE_SLOW:
-        fprintf(stderr, "Slow");
-        break;
-    case SDL_SCALEMODE_BEST:
-        fprintf(stderr, "Best");
-        break;
-    default:
-        fprintf(stderr, "0x%8.8x", flag);
-        break;
-    }
-}
-
-static void
 PrintPixelFormat(Uint32 format)
 {
     switch (format) {
@@ -525,36 +455,6 @@
     }
     fprintf(stderr, ")\n");
 
-    fprintf(stderr, "    Blend: 0x%8.8X", info->blend_modes);
-    fprintf(stderr, " (");
-    count = 0;
-    for (i = 0; i < sizeof(info->blend_modes) * 8; ++i) {
-        Uint32 flag = (1 << i);
-        if (info->blend_modes & flag) {
-            if (count > 0) {
-                fprintf(stderr, " | ");
-            }
-            PrintBlendMode(flag);
-            ++count;
-        }
-    }
-    fprintf(stderr, ")\n");
-
-    fprintf(stderr, "    Scale: 0x%8.8X", info->scale_modes);
-    fprintf(stderr, " (");
-    count = 0;
-    for (i = 0; i < sizeof(info->scale_modes) * 8; ++i) {
-        Uint32 flag = (1 << i);
-        if (info->scale_modes & flag) {
-            if (count > 0) {
-                fprintf(stderr, " | ");
-            }
-            PrintScaleMode(flag);
-            ++count;
-        }
-    }
-    fprintf(stderr, ")\n");
-
     fprintf(stderr, "    Texture formats (%d): ", info->num_texture_formats);
     for (i = 0; i < (int) info->num_texture_formats; ++i) {
         if (i > 0) {
@@ -746,7 +646,10 @@
         state->windows =
             (SDL_Window **) SDL_malloc(state->num_windows *
                                         sizeof(*state->windows));
-        if (!state->windows) {
+        state->renderers =
+            (SDL_Renderer **) SDL_malloc(state->num_windows *
+                                        sizeof(*state->renderers));
+        if (!state->windows || !state->renderers) {
             fprintf(stderr, "Out of memory!\n");
             return SDL_FALSE;
         }
@@ -785,6 +688,8 @@
 
             SDL_ShowWindow(state->windows[i]);
 
+            state->renderers[i] = NULL;
+
             if (!state->skip_renderer
                 && (state->renderdriver
                     || !(state->window_flags & SDL_WINDOW_OPENGL))) {
@@ -807,8 +712,9 @@
                         return SDL_FALSE;
                     }
                 }
-                if (SDL_CreateRenderer
-                    (state->windows[i], m, state->render_flags) < 0) {
+                state->renderers[i] = SDL_CreateRenderer(state->windows[i],
+                                            m, state->render_flags);
+                if (!state->renderers[i]) {
                     fprintf(stderr, "Couldn't create renderer: %s\n",
                             SDL_GetError());
                     return SDL_FALSE;
@@ -817,12 +723,11 @@
                     SDL_RendererInfo info;
 
                     fprintf(stderr, "Current renderer:\n");
-                    SDL_GetRendererInfo(&info);
+                    SDL_GetRendererInfo(state->renderers[i], &info);
                     PrintRenderer(&info);
                 }
             }
         }
-        SDL_SelectRenderer(state->windows[0]);
     }
 
     if (state->flags & SDL_INIT_AUDIO) {
@@ -1112,15 +1017,25 @@
 void
 CommonQuit(CommonState * state)
 {
+    int i;
+
+    if (state->windows) {
+        SDL_free(state->windows);
+    }
+    if (state->renderers) {
+        for (i = 0; i < state->num_windows; ++i) {
+            if (state->renderers[i]) {
+                SDL_DestroyRenderer(state->renderers[i]);
+            }
+        }
+        SDL_free(state->renderers);
+    }
     if (state->flags & SDL_INIT_VIDEO) {
         SDL_VideoQuit();
     }
     if (state->flags & SDL_INIT_AUDIO) {
         SDL_AudioQuit();
     }
-    if (state->windows) {
-        SDL_free(state->windows);
-    }
     SDL_free(state);
 }
 
--- a/test/common.h	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/common.h	Sun Feb 06 21:23:32 2011 -0800
@@ -39,6 +39,7 @@
     const char *renderdriver;
     Uint32 render_flags;
     SDL_bool skip_renderer;
+    SDL_Renderer **renderers;
 
     /* Audio info */
     const char *audiodriver;
Binary file test/sail.bmp has changed
--- a/test/testdraw2.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/testdraw2.c	Sun Feb 06 21:23:32 2011 -0800
@@ -19,7 +19,7 @@
 static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
 
 void
-DrawPoints(SDL_Window * window)
+DrawPoints(SDL_Window * window, SDL_Renderer * renderer)
 {
     int i;
     int x, y;
@@ -28,7 +28,6 @@
     /* Query the sizes */
     SDL_GetWindowSize(window, &window_w, &window_h);
 
-    SDL_SetRenderDrawBlendMode(blendMode);
     for (i = 0; i < num_objects * 4; ++i) {
         /* Cycle the color and alpha, if desired */
         if (cycle_color) {
@@ -53,18 +52,17 @@
                 cycle_direction = -cycle_direction;
             }
         }
-        SDL_SetRenderDrawColor(255, (Uint8) current_color,
+        SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color,
                                (Uint8) current_color, (Uint8) current_alpha);
 
         x = rand() % window_w;
         y = rand() % window_h;
-        SDL_RenderDrawPoint(x, y);
+        SDL_RenderDrawPoint(renderer, x, y);
     }
-    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
 }
 
 void
-DrawLines(SDL_Window * window)
+DrawLines(SDL_Window * window, SDL_Renderer * renderer)
 {
     int i;
     int x1, y1, x2, y2;
@@ -73,7 +71,6 @@
     /* Query the sizes */
     SDL_GetWindowSize(window, &window_w, &window_h);
 
-    SDL_SetRenderDrawBlendMode(blendMode);
     for (i = 0; i < num_objects; ++i) {
         /* Cycle the color and alpha, if desired */
         if (cycle_color) {
@@ -98,27 +95,26 @@
                 cycle_direction = -cycle_direction;
             }
         }
-        SDL_SetRenderDrawColor(255, (Uint8) current_color,
+        SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color,
                                (Uint8) current_color, (Uint8) current_alpha);
 
         if (i == 0) {
-            SDL_RenderDrawLine(0, 0, window_w - 1, window_h - 1);
-            SDL_RenderDrawLine(0, window_h - 1, window_w - 1, 0);
-            SDL_RenderDrawLine(0, window_h / 2, window_w - 1, window_h / 2);
-            SDL_RenderDrawLine(window_w / 2, 0, window_w / 2, window_h - 1);
+            SDL_RenderDrawLine(renderer, 0, 0, window_w - 1, window_h - 1);
+            SDL_RenderDrawLine(renderer, 0, window_h - 1, window_w - 1, 0);
+            SDL_RenderDrawLine(renderer, 0, window_h / 2, window_w - 1, window_h / 2);
+            SDL_RenderDrawLine(renderer, window_w / 2, 0, window_w / 2, window_h - 1);
         } else {
             x1 = (rand() % (window_w*2)) - window_w;
             x2 = (rand() % (window_w*2)) - window_w;
             y1 = (rand() % (window_h*2)) - window_h;
             y2 = (rand() % (window_h*2)) - window_h;
-            SDL_RenderDrawLine(x1, y1, x2, y2);
+            SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
         }
     }
-    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
 }
 
 void
-DrawRects(SDL_Window * window)
+DrawRects(SDL_Window * window, SDL_Renderer * renderer)
 {
     int i;
     SDL_Rect rect;
@@ -127,7 +123,6 @@
     /* Query the sizes */
     SDL_GetWindowSize(window, &window_w, &window_h);
 
-    SDL_SetRenderDrawBlendMode(blendMode);
     for (i = 0; i < num_objects / 4; ++i) {
         /* Cycle the color and alpha, if desired */
         if (cycle_color) {
@@ -152,16 +147,15 @@
                 cycle_direction = -cycle_direction;
             }
         }
-        SDL_SetRenderDrawColor(255, (Uint8) current_color,
+        SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color,
                                (Uint8) current_color, (Uint8) current_alpha);
 
         rect.w = rand() % (window_h / 2);
         rect.h = rand() % (window_h / 2);
         rect.x = (rand() % (window_w*2) - window_w) - (rect.w / 2);
         rect.y = (rand() % (window_h*2) - window_h) - (rect.h / 2);
-        SDL_RenderFillRect(&rect);
+        SDL_RenderFillRect(renderer, &rect);
     }
-    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
 }
 
 int
@@ -190,9 +184,6 @@
                     if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
                         blendMode = SDL_BLENDMODE_NONE;
                         consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
-                        blendMode = SDL_BLENDMODE_MASK;
-                        consumed = 2;
                     } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
                         blendMode = SDL_BLENDMODE_BLEND;
                         consumed = 2;
@@ -217,7 +208,7 @@
         }
         if (consumed < 0) {
             fprintf(stderr,
-                    "Usage: %s %s [--blend none|mask|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
+                    "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
                     argv[0], CommonUsage(state));
             return 1;
         }
@@ -229,9 +220,10 @@
 
     /* Create the windows and initialize the renderers */
     for (i = 0; i < state->num_windows; ++i) {
-        SDL_SelectRenderer(state->windows[i]);
-        SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-        SDL_RenderClear();
+        SDL_Renderer *renderer = state->renderers[i];
+        SDL_SetRenderDrawBlendMode(renderer, blendMode);
+        SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
+        SDL_RenderClear(renderer);
     }
 
     srand((unsigned int)time(NULL));
@@ -245,30 +237,17 @@
         ++frames;
         while (SDL_PollEvent(&event)) {
             CommonEvent(state, &event, &done);
-            switch (event.type) {
-            case SDL_WINDOWEVENT:
-                switch (event.window.event) {
-                case SDL_WINDOWEVENT_EXPOSED:
-                    SDL_SelectRenderer(SDL_GetWindowFromID(event.window.windowID));
-                    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-                    SDL_RenderClear();
-                    break;
-                }
-                break;
-            default:
-                break;
-            }
         }
         for (i = 0; i < state->num_windows; ++i) {
-            SDL_SelectRenderer(state->windows[i]);
-            SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-            SDL_RenderClear();
+            SDL_Renderer *renderer = state->renderers[i];
+            SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
+            SDL_RenderClear(renderer);
 
-            DrawRects(state->windows[i]);
-            DrawLines(state->windows[i]);
-            DrawPoints(state->windows[i]);
+            DrawRects(state->windows[i], renderer);
+            DrawLines(state->windows[i], renderer);
+            DrawPoints(state->windows[i], renderer);
 
-            SDL_RenderPresent();
+            SDL_RenderPresent(renderer);
         }
     }
 
--- a/test/testdyngles.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/testdyngles.c	Sun Feb 06 21:23:32 2011 -0800
@@ -116,10 +116,6 @@
     /* you may want to change these according to the platform */
     video_w = 320;
     video_h = 480;
-#ifdef __QNXNTO__
-    video_w = 480;
-    video_h = 640;
-#endif /* __QNXNTO__ */
 
     if (argv[1]) {
         gl_library = argv[1];
@@ -151,12 +147,7 @@
         pixels[3 * i + 2] = rand() % 250 - 125;
     }
 
-#ifdef __QNXNTO__
-    f.glViewport(0, 0, video_h, video_w);
-#else
     f.glViewport(0, 0, video_w, video_h);
-#endif /* __QNXNTO__ */
-
     f.glMatrixMode(GL_PROJECTION);
     f.glLoadIdentity();
     f.glOrthof(-100, 100, -100, 100, -500, 500);
--- a/test/testime.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/testime.c	Sun Feb 06 21:23:32 2011 -0800
@@ -10,11 +10,7 @@
 #endif
 
 #define DEFAULT_PTSIZE  30
-#ifdef __QNXNTO__
-    #define DEFAULT_FONT    "/usr/photon/font_repository/tt0003m_.ttf"
-#else
-    #define DEFAULT_FONT    "/System/Library/Fonts/华文细黑.ttf"
-#endif
+#define DEFAULT_FONT    "/System/Library/Fonts/华文细黑.ttf"
 #define MAX_TEXT_LENGTH 256
 
 SDL_Surface *screen;
@@ -28,36 +24,36 @@
 char text[MAX_TEXT_LENGTH], markedText[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
 int cursor = 0;
 
-size_t utf8_length(unsigned char c)
-{
-    c = (unsigned char)(0xff & c);
-    if (c < 0x80)
-        return 1;
-    else if ((c >> 5) ==0x6)
-        return 2;
-    else if ((c >> 4) == 0xe)
-        return 3;
-    else if ((c >> 3) == 0x1e)
-        return 4;
-    else
-        return 0;
-}
-
-char *utf8_next(char *p)
-{
-    size_t len = utf8_length(*p);
-    size_t i = 0;
-    if (!len)
-        return 0;
-
-    for (; i < len; ++i)
-    {
-        ++p;
-        if (!*p)
-            return 0;
-    }
-    return p;
-}
+size_t utf8_length(unsigned char c)
+{
+    c = (unsigned char)(0xff & c);
+    if (c < 0x80)
+        return 1;
+    else if ((c >> 5) ==0x6)
+        return 2;
+    else if ((c >> 4) == 0xe)
+        return 3;
+    else if ((c >> 3) == 0x1e)
+        return 4;
+    else
+        return 0;
+}
+
+char *utf8_next(char *p)
+{
+    size_t len = utf8_length(*p);
+    size_t i = 0;
+    if (!len)
+        return 0;
+
+    for (; i < len; ++i)
+    {
+        ++p;
+        if (!*p)
+            return 0;
+    }
+    return p;
+}
 
 char *utf8_advance(char *p, size_t distance)
 {
--- a/test/testintersections.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/testintersections.c	Sun Feb 06 21:23:32 2011 -0800
@@ -20,7 +20,7 @@
 static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
 
 void
-DrawPoints(SDL_Window * window)
+DrawPoints(SDL_Window * window, SDL_Renderer * renderer)
 {
     int i;
     int x, y;
@@ -29,7 +29,6 @@
     /* Query the sizes */
     SDL_GetWindowSize(window, &window_w, &window_h);
 
-    SDL_SetRenderDrawBlendMode(blendMode);
     for (i = 0; i < num_objects * 4; ++i) {
         /* Cycle the color and alpha, if desired */
         if (cycle_color) {
@@ -54,14 +53,13 @@
                 cycle_direction = -cycle_direction;
             }
         }
-        SDL_SetRenderDrawColor(255, (Uint8) current_color,
+        SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color,
                                (Uint8) current_color, (Uint8) current_alpha);
 
         x = rand() % window_w;
         y = rand() % window_h;
-        SDL_RenderDrawPoint(x, y);
+        SDL_RenderDrawPoint(renderer, x, y);
     }
-    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
 }
 
 #define MAX_LINES 16
@@ -86,7 +84,7 @@
 
 
 void
-DrawLines(SDL_Window * window)
+DrawLines(SDL_Window * window, SDL_Renderer * renderer)
 {
     int i;
     int x1, y1, x2, y2;
@@ -95,20 +93,18 @@
     /* Query the sizes */
     SDL_GetWindowSize(window, &window_w, &window_h);
 
-    SDL_SetRenderDrawBlendMode(blendMode);
     for (i = 0; i < num_lines; ++i) {
-        SDL_SetRenderDrawColor(255, 255, 255, 255);
+        SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
 
         if (i == -1) {
-            SDL_RenderDrawLine(0, 0, window_w - 1, window_h - 1);
-            SDL_RenderDrawLine(0, window_h - 1, window_w - 1, 0);
-            SDL_RenderDrawLine(0, window_h / 2, window_w - 1, window_h / 2);
-            SDL_RenderDrawLine(window_w / 2, 0, window_w / 2, window_h - 1);
+            SDL_RenderDrawLine(renderer, 0, 0, window_w - 1, window_h - 1);
+            SDL_RenderDrawLine(renderer, 0, window_h - 1, window_w - 1, 0);
+            SDL_RenderDrawLine(renderer, 0, window_h / 2, window_w - 1, window_h / 2);
+            SDL_RenderDrawLine(renderer, window_w / 2, 0, window_w / 2, window_h - 1);
         } else {
-            SDL_RenderDrawLine(lines[i].x, lines[i].y, lines[i].w, lines[i].h);
+            SDL_RenderDrawLine(renderer, lines[i].x, lines[i].y, lines[i].w, lines[i].h);
         }
     }
-    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
 }
 
 #define MAX_RECTS 16
@@ -139,7 +135,7 @@
 }
 
 static void
-DrawRects(SDL_Window * window)
+DrawRects(SDL_Window * window, SDL_Renderer * renderer)
 {
     int i;
     int window_w, window_h;
@@ -147,24 +143,20 @@
     /* Query the sizes */
     SDL_GetWindowSize(window, &window_w, &window_h);
 
-    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
     for (i = 0; i < num_rects; ++i) {
-        SDL_SetRenderDrawColor(255, 127, 0, 255);
-        SDL_RenderFillRect(&rects[i]);
+        SDL_SetRenderDrawColor(renderer, 255, 127, 0, 255);
+        SDL_RenderFillRect(renderer, &rects[i]);
     }
-    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
 }
 
 static void
-DrawRectLineIntersections(SDL_Window * window)
+DrawRectLineIntersections(SDL_Window * window, SDL_Renderer * renderer)
 {
     int i, j, window_w, window_h;
 
     /* Query the sizes */
     SDL_GetWindowSize(window, &window_w, &window_h);
 
-    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
-
     for (i = 0; i < num_rects; i++)
         for (j = 0; j < num_lines; j++) {
             int x1, y1, x2, y2;
@@ -177,31 +169,25 @@
             y2 = lines[j].h;
 
             if (SDL_IntersectRectAndLine(&r, &x1, &y1, &x2, &y2)) {
-                SDL_SetRenderDrawColor(0, 255, 55, 255);
-                SDL_RenderDrawLine(x1, y1, x2, y2);
+                SDL_SetRenderDrawColor(renderer, 0, 255, 55, 255);
+                SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
             }
         }
-
-    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
 }
 
 static void
-DrawRectRectIntersections(SDL_Window * window)
+DrawRectRectIntersections(SDL_Window * window, SDL_Renderer * renderer)
 {
     int i, j;
 
-    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
-
     for (i = 0; i < num_rects; i++)
         for (j = i + 1; j < num_rects; j++) {
             SDL_Rect r;
             if (SDL_IntersectRect(&rects[i], &rects[j], &r)) {
-                SDL_SetRenderDrawColor(255, 200, 0, 255);
-                SDL_RenderFillRect(&r);
+                SDL_SetRenderDrawColor(renderer, 255, 200, 0, 255);
+                SDL_RenderFillRect(renderer, &r);
             }
         }
-
-    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
 }
 
 int
@@ -231,9 +217,6 @@
                     if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
                         blendMode = SDL_BLENDMODE_NONE;
                         consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
-                        blendMode = SDL_BLENDMODE_MASK;
-                        consumed = 2;
                     } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
                         blendMode = SDL_BLENDMODE_BLEND;
                         consumed = 2;
@@ -258,7 +241,7 @@
         }
         if (consumed < 0) {
             fprintf(stderr,
-                    "Usage: %s %s [--blend none|mask|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
+                    "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
                     argv[0], CommonUsage(state));
             return 1;
         }
@@ -270,9 +253,10 @@
 
     /* Create the windows and initialize the renderers */
     for (i = 0; i < state->num_windows; ++i) {
-        SDL_SelectRenderer(state->windows[i]);
-        SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-        SDL_RenderClear();
+        SDL_Renderer *renderer = state->renderers[i];
+        SDL_SetRenderDrawBlendMode(renderer, blendMode);
+        SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
+        SDL_RenderClear(renderer);
     }
 
     srand(time(NULL));
@@ -317,31 +301,22 @@
                     break;
                 }
                 break;
-            case SDL_WINDOWEVENT:
-                switch (event.window.event) {
-                case SDL_WINDOWEVENT_EXPOSED:
-                    SDL_SelectRenderer(SDL_GetWindowFromID(event.window.windowID));
-                    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-                    SDL_RenderClear();
-                    break;
-                }
-                break;
             default:
                 break;
             }
         }
         for (i = 0; i < state->num_windows; ++i) {
-            SDL_SelectRenderer(state->windows[i]);
-            SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-            SDL_RenderClear();
+            SDL_Renderer *renderer = state->renderers[i];
+            SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
+            SDL_RenderClear(renderer);
 
-            DrawRects(state->windows[i]);
-            DrawPoints(state->windows[i]);
-            DrawRectRectIntersections(state->windows[i]);
-            DrawLines(state->windows[i]);
-            DrawRectLineIntersections(state->windows[i]);
+            DrawRects(state->windows[i], renderer);
+            DrawPoints(state->windows[i], renderer);
+            DrawRectRectIntersections(state->windows[i], renderer);
+            DrawLines(state->windows[i], renderer);
+            DrawRectLineIntersections(state->windows[i], renderer);
 
-            SDL_RenderPresent();
+            SDL_RenderPresent(renderer);
         }
     }
 
--- a/test/testpalette.c	Tue Feb 01 00:37:02 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,347 +0,0 @@
-/*
- * testpalette.c
- *
- * A simple test of runtime palette modification for animation
- * (using the SDL_SetPalette() API). 
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "SDL.h"
-
-/* screen size */
-#define SCRW 640
-#define SCRH 480
-
-#define NBOATS 5
-#define SPEED 2
-
-#ifndef MIN
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
-#ifndef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
-/*
- * wave colours: Made by taking a narrow cross-section of a wave picture
- * in Gimp, saving in PPM ascii format and formatting with Emacs macros.
- */
-static SDL_Color wavemap[] = {
-    {0, 2, 103}, {0, 7, 110}, {0, 13, 117}, {0, 19, 125},
-    {0, 25, 133}, {0, 31, 141}, {0, 37, 150}, {0, 43, 158},
-    {0, 49, 166}, {0, 55, 174}, {0, 61, 182}, {0, 67, 190},
-    {0, 73, 198}, {0, 79, 206}, {0, 86, 214}, {0, 96, 220},
-    {5, 105, 224}, {12, 112, 226}, {19, 120, 227}, {26, 128, 229},
-    {33, 135, 230}, {40, 143, 232}, {47, 150, 234}, {54, 158, 236},
-    {61, 165, 238}, {68, 173, 239}, {75, 180, 241}, {82, 188, 242},
-    {89, 195, 244}, {96, 203, 246}, {103, 210, 248}, {112, 218, 250},
-    {124, 224, 250}, {135, 226, 251}, {146, 229, 251}, {156, 231, 252},
-    {167, 233, 252}, {178, 236, 252}, {189, 238, 252}, {200, 240, 252},
-    {211, 242, 252}, {222, 244, 252}, {233, 247, 252}, {242, 249, 252},
-    {237, 250, 252}, {209, 251, 252}, {174, 251, 252}, {138, 252, 252},
-    {102, 251, 252}, {63, 250, 252}, {24, 243, 252}, {7, 225, 252},
-    {4, 203, 252}, {3, 181, 252}, {2, 158, 252}, {1, 136, 251},
-    {0, 111, 248}, {0, 82, 234}, {0, 63, 213}, {0, 50, 192},
-    {0, 39, 172}, {0, 28, 152}, {0, 17, 132}, {0, 7, 114}
-};
-
-/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
-static void
-quit(int rc)
-{
-    SDL_Quit();
-    exit(rc);
-}
-
-static void
-sdlerr(char *when)
-{
-    fprintf(stderr, "SDL error: %s: %s\n", when, SDL_GetError());
-    quit(1);
-}
-
-/* create a background surface */
-static SDL_Surface *
-make_bg(SDL_Surface * screen, int startcol)
-{
-    int i;
-    SDL_Surface *bg =
-        SDL_CreateRGBSurface(SDL_SWSURFACE, screen->w, screen->h,
-                             8, 0, 0, 0, 0);
-    if (!bg)
-        sdlerr("creating background surface");
-
-    /* set the palette to the logical screen palette so that blits
-       won't be translated */
-    SDL_SetSurfacePalette(bg, screen->format->palette);
-
-    /* Make a wavy background pattern using colours 0-63 */
-    if (SDL_LockSurface(bg) < 0)
-        sdlerr("locking background");
-    for (i = 0; i < SCRH; i++) {
-        Uint8 *p = (Uint8 *) bg->pixels + i * bg->pitch;
-        int j, d;
-        d = 0;
-        for (j = 0; j < SCRW; j++) {
-            int v = MAX(d, -2);
-            v = MIN(v, 2);
-            if (i > 0)
-                v += p[-bg->pitch] + 65 - startcol;
-            p[j] = startcol + (v & 63);
-            d += ((rand() >> 3) % 3) - 1;
-        }
-    }
-    SDL_UnlockSurface(bg);
-    return (bg);
-}
-
-/*
- * Return a surface flipped horisontally. Only works for 8bpp;
- * extension to arbitrary bitness is left as an exercise for the reader.
- */
-static SDL_Surface *
-hflip(SDL_Surface * s)
-{
-    int i;
-    SDL_Surface *z = SDL_CreateRGBSurface(SDL_SWSURFACE, s->w, s->h, 8,
-                                          0, 0, 0, 0);
-    /* copy palette */
-    SDL_SetColors(z, s->format->palette->colors,
-                  0, s->format->palette->ncolors);
-    if (SDL_LockSurface(s) < 0 || SDL_LockSurface(z) < 0)
-        sdlerr("locking flip images");
-
-    for (i = 0; i < s->h; i++) {
-        int j;
-        Uint8 *from = (Uint8 *) s->pixels + i * s->pitch;
-        Uint8 *to = (Uint8 *) z->pixels + i * z->pitch + s->w - 1;
-        for (j = 0; j < s->w; j++)
-            to[-j] = from[j];
-    }
-
-    SDL_UnlockSurface(z);
-    SDL_UnlockSurface(s);
-    return z;
-}
-
-int
-main(int argc, char **argv)
-{
-    SDL_Color cmap[256];
-    SDL_Surface *screen;
-    SDL_Surface *bg;
-    SDL_Surface *boat[2];
-    unsigned vidflags = 0;
-    unsigned start;
-    int fade_max = 400;
-    int fade_level, fade_dir;
-    int boatcols, frames, i, red;
-    int boatx[NBOATS], boaty[NBOATS], boatdir[NBOATS];
-    int gamma_fade = 0;
-    int gamma_ramp = 0;
-
-    if (SDL_Init(SDL_INIT_VIDEO) < 0)
-        sdlerr("initialising SDL");
-
-    while (--argc) {
-        ++argv;
-        if (strcmp(*argv, "-hw") == 0)
-            vidflags |= SDL_HWSURFACE;
-        else if (strcmp(*argv, "-fullscreen") == 0)
-            vidflags |= SDL_FULLSCREEN;
-        else if (strcmp(*argv, "-nofade") == 0)
-            fade_max = 1;
-        else if (strcmp(*argv, "-gamma") == 0)
-            gamma_fade = 1;
-        else if (strcmp(*argv, "-gammaramp") == 0)
-            gamma_ramp = 1;
-        else {
-            fprintf(stderr,
-                    "usage: testpalette "
-                    " [-hw] [-fullscreen] [-nofade] [-gamma] [-gammaramp]\n");
-            quit(1);
-        }
-    }
-
-    /* Ask explicitly for 8bpp and a hardware palette */
-    if ((screen =
-         SDL_SetVideoMode(SCRW, SCRH, 8, vidflags | SDL_HWPALETTE)) == NULL) {
-        fprintf(stderr, "error setting %dx%d 8bpp indexed mode: %s\n",
-                SCRW, SCRH, SDL_GetError());
-        quit(1);
-    }
-
-    if (vidflags & SDL_FULLSCREEN)
-        SDL_ShowCursor(SDL_FALSE);
-
-    if ((boat[0] = SDL_LoadBMP("sail.bmp")) == NULL)
-        sdlerr("loading sail.bmp");
-    /* We've chosen magenta (#ff00ff) as colour key for the boat */
-    SDL_SetColorKey(boat[0], SDL_SRCCOLORKEY | SDL_RLEACCEL,
-                    SDL_MapRGB(boat[0]->format, 0xff, 0x00, 0xff));
-    boatcols = boat[0]->format->palette->ncolors;
-    if (boatcols >= 256)
-        sdlerr("too many colors in sail.bmp");
-    boat[1] = hflip(boat[0]);
-    SDL_SetColorKey(boat[1], SDL_SRCCOLORKEY | SDL_RLEACCEL,
-                    SDL_MapRGB(boat[1]->format, 0xff, 0x00, 0xff));
-
-    /*
-     * First set the physical screen palette to black, so the user won't
-     * see our initial drawing on the screen.
-     */
-    memset(cmap, 0, sizeof(cmap));
-    SDL_SetPalette(screen, SDL_PHYSPAL, cmap, 0, 256);
-
-    /*
-     * Proper palette management is important when playing games with the
-     * colormap. We have divided the palette as follows:
-     *
-     * index 0..(boatcols-1):           used for the boat
-     * index boatcols..(boatcols+63):   used for the waves
-     */
-    SDL_SetPalette(screen, SDL_LOGPAL,
-                   boat[0]->format->palette->colors, 0, boatcols);
-    SDL_SetPalette(screen, SDL_LOGPAL, wavemap, boatcols, 64);
-
-    /*
-     * Now the logical screen palette is set, and will remain unchanged.
-     * The boats already have the same palette so fast blits can be used.
-     */
-    memcpy(cmap, screen->format->palette->colors, 256 * sizeof(SDL_Color));
-
-    /* save the index of the red colour for later */
-    red = SDL_MapRGB(screen->format, 0xff, 0x00, 0x00);
-
-    bg = make_bg(screen, boatcols);     /* make a nice wavy background surface */
-
-    /* initial screen contents */
-    if (SDL_BlitSurface(bg, NULL, screen, NULL) < 0)
-        sdlerr("blitting background to screen");
-    SDL_Flip(screen);           /* actually put the background on screen */
-
-    /* determine initial boat placements */
-    for (i = 0; i < NBOATS; i++) {
-        boatx[i] = (rand() % (SCRW + boat[0]->w)) - boat[0]->w;
-        boaty[i] = i * (SCRH - boat[0]->h) / (NBOATS - 1);
-        boatdir[i] = ((rand() >> 5) & 1) * 2 - 1;
-    }
-
-    start = SDL_GetTicks();
-    frames = 0;
-    fade_dir = 1;
-    fade_level = 0;
-    do {
-        SDL_Event e;
-        SDL_Rect updates[NBOATS];
-        SDL_Rect r;
-        int redphase;
-
-        /* A small event loop: just exit on any key or mouse button event */
-        while (SDL_PollEvent(&e)) {
-            if (e.type == SDL_KEYDOWN || e.type == SDL_QUIT
-                || e.type == SDL_MOUSEBUTTONDOWN) {
-                if (fade_dir < 0)
-                    fade_level = 0;
-                fade_dir = -1;
-            }
-        }
-
-        /* move boats */
-        for (i = 0; i < NBOATS; i++) {
-            int old_x = boatx[i];
-            /* update boat position */
-            boatx[i] += boatdir[i] * SPEED;
-            if (boatx[i] <= -boat[0]->w || boatx[i] >= SCRW)
-                boatdir[i] = -boatdir[i];
-
-            /* paint over the old boat position */
-            r.x = old_x;
-            r.y = boaty[i];
-            r.w = boat[0]->w;
-            r.h = boat[0]->h;
-            if (SDL_BlitSurface(bg, &r, screen, &r) < 0)
-                sdlerr("blitting background");
-
-            /* construct update rectangle (bounding box of old and new pos) */
-            updates[i].x = MIN(old_x, boatx[i]);
-            updates[i].y = boaty[i];
-            updates[i].w = boat[0]->w + SPEED;
-            updates[i].h = boat[0]->h;
-            /* clip update rectangle to screen */
-            if (updates[i].x < 0) {
-                updates[i].w += updates[i].x;
-                updates[i].x = 0;
-            }
-            if (updates[i].x + updates[i].w > SCRW)
-                updates[i].w = SCRW - updates[i].x;
-        }
-
-        for (i = 0; i < NBOATS; i++) {
-            /* paint boat on new position */
-            r.x = boatx[i];
-            r.y = boaty[i];
-            if (SDL_BlitSurface(boat[(boatdir[i] + 1) / 2], NULL,
-                                screen, &r) < 0)
-                sdlerr("blitting boat");
-        }
-
-        /* cycle wave palette */
-        for (i = 0; i < 64; i++)
-            cmap[boatcols + ((i + frames) & 63)] = wavemap[i];
-
-        if (fade_dir) {
-            /* Fade the entire palette in/out */
-            fade_level += fade_dir;
-
-            if (gamma_fade) {
-                /* Fade linearly in gamma level (lousy) */
-                float level = (float) fade_level / fade_max;
-                if (SDL_SetGamma(level, level, level) < 0)
-                    sdlerr("setting gamma");
-
-            } else if (gamma_ramp) {
-                /* Fade using gamma ramp (better) */
-                Uint16 ramp[256];
-                for (i = 0; i < 256; i++)
-                    ramp[i] = (i * fade_level / fade_max) << 8;
-                if (SDL_SetGammaRamp(ramp, ramp, ramp) < 0)
-                    sdlerr("setting gamma ramp");
-
-            } else {
-                /* Fade using direct palette manipulation (best) */
-                memcpy(cmap, screen->format->palette->colors,
-                       boatcols * sizeof(SDL_Color));
-                for (i = 0; i < boatcols + 64; i++) {
-                    cmap[i].r = cmap[i].r * fade_level / fade_max;
-                    cmap[i].g = cmap[i].g * fade_level / fade_max;
-                    cmap[i].b = cmap[i].b * fade_level / fade_max;
-                }
-            }
-            if (fade_level == fade_max)
-                fade_dir = 0;
-        }
-
-        /* pulse the red colour (done after the fade, for a night effect) */
-        redphase = frames % 64;
-        cmap[red].r = (int) (255 * sin(redphase * M_PI / 63));
-
-        SDL_SetPalette(screen, SDL_PHYSPAL, cmap, 0, boatcols + 64);
-
-        /* update changed areas of the screen */
-        SDL_UpdateRects(screen, NBOATS, updates);
-        frames++;
-    } while (fade_level > 0);
-
-    printf("%d frames, %.2f fps\n",
-           frames, 1000.0 * frames / (SDL_GetTicks() - start));
-
-    if (vidflags & SDL_FULLSCREEN)
-        SDL_ShowCursor(SDL_TRUE);
-    SDL_Quit();
-    return 0;
-}
--- a/test/testshape.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/testshape.c	Sun Feb 06 21:23:32 2011 -0800
@@ -11,177 +11,183 @@
 #define TICK_INTERVAL 1000/10
 
 typedef struct LoadedPicture {
-	SDL_Surface *surface;
-	SDL_Texture *texture;
-	SDL_WindowShapeMode mode;
+    SDL_Surface *surface;
+    SDL_Texture *texture;
+    SDL_WindowShapeMode mode;
 } LoadedPicture;
 
-void render(SDL_Window* window,SDL_Texture *texture,SDL_Rect texture_dimensions) {
-	SDL_SelectRenderer(window);
-	
-	//Clear render-target to blue.
-	SDL_SetRenderDrawColor(0x00,0x00,0xff,0xff);
-	SDL_RenderClear();
-	
-	//Render the texture.
-	SDL_RenderCopy(texture,&texture_dimensions,&texture_dimensions);
-	
-	SDL_RenderPresent();
+void render(SDL_Renderer *renderer,SDL_Texture *texture,SDL_Rect texture_dimensions)
+{
+    //Clear render-target to blue.
+    SDL_SetRenderDrawColor(renderer,0x00,0x00,0xff,0xff);
+    SDL_RenderClear(renderer);
+    
+    //Render the texture.
+    SDL_RenderCopy(renderer,texture,&texture_dimensions,&texture_dimensions);
+    
+    SDL_RenderPresent(renderer);
 }
 
 static Uint32 next_time;
 
-Uint32 time_left() {
+Uint32 time_left()
+{
     Uint32 now = SDL_GetTicks();
     if(next_time <= now)
         return 0;
-	else
+    else
         return next_time - now;
 }
 
-int main(int argc,char** argv) {
-	Uint8 num_pictures;
-	LoadedPicture* pictures;
-	int i, j;
-	SDL_PixelFormat* format = NULL;
-	SDL_Window *window;
-	SDL_Color black = {0,0,0,0xff};
-	SDL_Event event;
-	int event_pending = 0;
-	int should_exit = 0;
-	unsigned int current_picture;
-	int button_down;
-	Uint32 pixelFormat = 0;
-	int access = 0;
-	SDL_Rect texture_dimensions;;
+int main(int argc,char** argv)
+{
+    Uint8 num_pictures;
+    LoadedPicture* pictures;
+    int i, j;
+    SDL_PixelFormat* format = NULL;
+    SDL_Window *window;
+    SDL_Renderer *renderer;
+    SDL_Color black = {0,0,0,0xff};
+    SDL_Event event;
+    int event_pending = 0;
+    int should_exit = 0;
+    unsigned int current_picture;
+    int button_down;
+    Uint32 pixelFormat = 0;
+    int access = 0;
+    SDL_Rect texture_dimensions;;
 
-	if(argc < 2) {
-    	printf("SDL_Shape requires at least one bitmap file as argument.\n");
-    	exit(-1);
+    if(argc < 2) {
+        printf("SDL_Shape requires at least one bitmap file as argument.\n");
+        exit(-1);
     }
-	
-	if(SDL_VideoInit(NULL) == -1) {
-		printf("Could not initialize SDL video.\n");
-		exit(-2);
-	}
-	
-	num_pictures = argc - 1;
-	pictures = (LoadedPicture *)malloc(sizeof(LoadedPicture)*num_pictures);
-	for(i=0;i<num_pictures;i++)
-		pictures[i].surface = NULL;
-	for(i=0;i<num_pictures;i++) {
-		pictures[i].surface = SDL_LoadBMP(argv[i+1]);
-		if(pictures[i].surface == NULL) {
-			j = 0;
-			for(j=0;j<num_pictures;j++)
-				if(pictures[j].surface != NULL)
-					SDL_FreeSurface(pictures[j].surface);
-			free(pictures);
-			SDL_VideoQuit();
-			printf("Could not load surface from named bitmap file.\n");
-			exit(-3);
-		}
+    
+    if(SDL_VideoInit(NULL) == -1) {
+        printf("Could not initialize SDL video.\n");
+        exit(-2);
+    }
+    
+    num_pictures = argc - 1;
+    pictures = (LoadedPicture *)malloc(sizeof(LoadedPicture)*num_pictures);
+    for(i=0;i<num_pictures;i++)
+        pictures[i].surface = NULL;
+    for(i=0;i<num_pictures;i++) {
+        pictures[i].surface = SDL_LoadBMP(argv[i+1]);
+        if(pictures[i].surface == NULL) {
+            j = 0;
+            for(j=0;j<num_pictures;j++)
+                if(pictures[j].surface != NULL)
+                    SDL_FreeSurface(pictures[j].surface);
+            free(pictures);
+            SDL_VideoQuit();
+            printf("Could not load surface from named bitmap file.\n");
+            exit(-3);
+        }
 
-		format = pictures[i].surface->format;
-		if(format->Amask != 0) {
-			pictures[i].mode.mode = ShapeModeBinarizeAlpha;
-			pictures[i].mode.parameters.binarizationCutoff = 255;
-		}
-		else {
-			pictures[i].mode.mode = ShapeModeColorKey;
-			pictures[i].mode.parameters.colorKey = black;
-		}
-	}
-	
-	window = SDL_CreateShapedWindow("SDL_Shape test",SHAPED_WINDOW_X,SHAPED_WINDOW_Y,SHAPED_WINDOW_DIMENSION,SHAPED_WINDOW_DIMENSION,SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN);
-	if(window == NULL) {
-		for(i=0;i<num_pictures;i++)
-			SDL_FreeSurface(pictures[i].surface);
-		free(pictures);
-		SDL_VideoQuit();
-		printf("Could not create shaped window for SDL_Shape.\n");
-		exit(-4);
-	}
-	if(SDL_CreateRenderer(window,-1,SDL_RENDERER_PRESENTFLIP2) == -1) {
-		SDL_DestroyWindow(window);
-		for(i=0;i<num_pictures;i++)
-			SDL_FreeSurface(pictures[i].surface);
-		free(pictures);
-		SDL_VideoQuit();
-		printf("Could not create rendering context for SDL_Shape window.\n");
-		exit(-5);
-	}
-	
-	for(i=0;i<num_pictures;i++)
-		pictures[i].texture = NULL;
-	for(i=0;i<num_pictures;i++) {
-		pictures[i].texture = SDL_CreateTextureFromSurface(0,pictures[i].surface);
-		if(pictures[i].texture == NULL) {
-			j = 0;
-			for(j=0;j<num_pictures;i++)
-				if(pictures[i].texture != NULL)
-					SDL_DestroyTexture(pictures[i].texture);
-			for(i=0;i<num_pictures;i++)
-				SDL_FreeSurface(pictures[i].surface);
-			free(pictures);
-			SDL_DestroyRenderer(window);
-			SDL_DestroyWindow(window);
-			SDL_VideoQuit();
-			printf("Could not create texture for SDL_shape.\n");
-			exit(-6);
-		}
-	}
-	
-	event_pending = 0;
-	should_exit = 0;
-	event_pending = SDL_PollEvent(&event);
-	current_picture = 0;
-	button_down = 0;
-	texture_dimensions.h = 0;
-	texture_dimensions.w = 0;
-	texture_dimensions.x = 0;
-	texture_dimensions.y = 0;
-	SDL_QueryTexture(pictures[current_picture].texture,(Uint32 *)&pixelFormat,(int *)&access,&texture_dimensions.w,&texture_dimensions.h);
-	SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h);
-	SDL_SetWindowShape(window,pictures[current_picture].surface,&pictures[current_picture].mode);
-	next_time = SDL_GetTicks() + TICK_INTERVAL;
-	while(should_exit == 0) {
-		event_pending = SDL_PollEvent(&event);
-		if(event_pending == 1) {
-			if(event.type == SDL_KEYDOWN) {
-				button_down = 1;
-				if(event.key.keysym.sym == SDLK_ESCAPE)
-					should_exit = 1;
-			}
-			if(button_down && event.type == SDL_KEYUP) {
-				button_down = 0;
-				current_picture += 1;
-				if(current_picture >= num_pictures)
-					current_picture = 0;
-				SDL_QueryTexture(pictures[current_picture].texture,(Uint32 *)&pixelFormat,(int *)&access,&texture_dimensions.w,&texture_dimensions.h);
-				SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h);
-				SDL_SetWindowShape(window,pictures[current_picture].surface,&pictures[current_picture].mode);
-			}
-			if(event.type == SDL_QUIT)
-				should_exit = 1;
-			event_pending = 0;
-		}
-		render(window,pictures[current_picture].texture,texture_dimensions);
-		SDL_Delay(time_left());
-		next_time += TICK_INTERVAL;
-	}
-	
-	//Free the textures.
-	for(i=0;i<num_pictures;i++)
-		SDL_DestroyTexture(pictures[i].texture);
-	//Destroy the window.
-	SDL_DestroyWindow(window);
-	//Free the original surfaces backing the textures.
-	for(i=0;i<num_pictures;i++)
-		SDL_FreeSurface(pictures[i].surface);
-	free(pictures);
-	//Call SDL_VideoQuit() before quitting.
-	SDL_VideoQuit();
+        format = pictures[i].surface->format;
+        if(format->Amask != 0) {
+            pictures[i].mode.mode = ShapeModeBinarizeAlpha;
+            pictures[i].mode.parameters.binarizationCutoff = 255;
+        }
+        else {
+            pictures[i].mode.mode = ShapeModeColorKey;
+            pictures[i].mode.parameters.colorKey = black;
+        }
+    }
+    
+    window = SDL_CreateShapedWindow("SDL_Shape test",SHAPED_WINDOW_X,SHAPED_WINDOW_Y,SHAPED_WINDOW_DIMENSION,SHAPED_WINDOW_DIMENSION,SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN);
+    if(window == NULL) {
+        for(i=0;i<num_pictures;i++)
+            SDL_FreeSurface(pictures[i].surface);
+        free(pictures);
+        SDL_VideoQuit();
+        printf("Could not create shaped window for SDL_Shape.\n");
+        exit(-4);
+    }
+    renderer = SDL_CreateRenderer(window,-1,0);
+    if (!renderer) {
+        SDL_DestroyWindow(window);
+        for(i=0;i<num_pictures;i++)
+            SDL_FreeSurface(pictures[i].surface);
+        free(pictures);
+        SDL_VideoQuit();
+        printf("Could not create rendering context for SDL_Shape window.\n");
+        exit(-5);
+    }
+    
+    for(i=0;i<num_pictures;i++)
+        pictures[i].texture = NULL;
+    for(i=0;i<num_pictures;i++) {
+        pictures[i].texture = SDL_CreateTextureFromSurface(renderer,pictures[i].surface);
+        if(pictures[i].texture == NULL) {
+            j = 0;
+            for(j=0;j<num_pictures;i++)
+                if(pictures[i].texture != NULL)
+                    SDL_DestroyTexture(pictures[i].texture);
+            for(i=0;i<num_pictures;i++)
+                SDL_FreeSurface(pictures[i].surface);
+            free(pictures);
+            SDL_DestroyRenderer(renderer);
+            SDL_DestroyWindow(window);
+            SDL_VideoQuit();
+            printf("Could not create texture for SDL_shape.\n");
+            exit(-6);
+        }
+    }
+    
+    event_pending = 0;
+    should_exit = 0;
+    event_pending = SDL_PollEvent(&event);
+    current_picture = 0;
+    button_down = 0;
+    texture_dimensions.h = 0;
+    texture_dimensions.w = 0;
+    texture_dimensions.x = 0;
+    texture_dimensions.y = 0;
+    SDL_QueryTexture(pictures[current_picture].texture,(Uint32 *)&pixelFormat,(int *)&access,&texture_dimensions.w,&texture_dimensions.h);
+    SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h);
+    SDL_SetWindowShape(window,pictures[current_picture].surface,&pictures[current_picture].mode);
+    next_time = SDL_GetTicks() + TICK_INTERVAL;
+    while(should_exit == 0) {
+        event_pending = SDL_PollEvent(&event);
+        if(event_pending == 1) {
+            if(event.type == SDL_KEYDOWN) {
+                button_down = 1;
+                if(event.key.keysym.sym == SDLK_ESCAPE)
+                    should_exit = 1;
+            }
+            if(button_down && event.type == SDL_KEYUP) {
+                button_down = 0;
+                current_picture += 1;
+                if(current_picture >= num_pictures)
+                    current_picture = 0;
+                SDL_QueryTexture(pictures[current_picture].texture,(Uint32 *)&pixelFormat,(int *)&access,&texture_dimensions.w,&texture_dimensions.h);
+                SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h);
+                SDL_SetWindowShape(window,pictures[current_picture].surface,&pictures[current_picture].mode);
+            }
+            if(event.type == SDL_QUIT)
+                should_exit = 1;
+            event_pending = 0;
+        }
+        render(renderer,pictures[current_picture].texture,texture_dimensions);
+        SDL_Delay(time_left());
+        next_time += TICK_INTERVAL;
+    }
+    
+    //Free the textures.
+    for(i=0;i<num_pictures;i++)
+        SDL_DestroyTexture(pictures[i].texture);
+    SDL_DestroyRenderer(renderer);
+    //Destroy the window.
+    SDL_DestroyWindow(window);
+    //Free the original surfaces backing the textures.
+    for(i=0;i<num_pictures;i++)
+        SDL_FreeSurface(pictures[i].surface);
+    free(pictures);
+    //Call SDL_VideoQuit() before quitting.
+    SDL_VideoQuit();
 
-	return 0;
+    return 0;
 }
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/test/testsprite.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/testsprite.c	Sun Feb 06 21:23:32 2011 -0800
@@ -172,7 +172,7 @@
     }
 
     numsprites = NUM_SPRITES;
-    videoflags = SDL_SWSURFACE | SDL_ANYFORMAT;
+    videoflags = SDL_SWSURFACE | SDL_ANYFORMAT | SDL_RESIZABLE;
     width = 640;
     height = 480;
     video_bpp = 8;
@@ -297,6 +297,9 @@
         ++frames;
         while (SDL_PollEvent(&event)) {
             switch (event.type) {
+            case SDL_VIDEORESIZE:
+                screen = SDL_SetVideoMode(event.resize.w, event.resize.h, video_bpp, videoflags);
+                break;
             case SDL_MOUSEBUTTONDOWN:
                 SDL_WarpMouse(screen->w / 2, screen->h / 2);
                 break;
--- a/test/testsprite2.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/testsprite2.c	Sun Feb 06 21:23:32 2011 -0800
@@ -6,8 +6,8 @@
 
 #include "common.h"
 
-#define NUM_SPRITES	100
-#define MAX_SPEED 	1
+#define NUM_SPRITES    100
+#define MAX_SPEED     1
 
 static CommonState *state;
 static int num_sprites;
@@ -20,8 +20,7 @@
 static SDL_Rect *positions;
 static SDL_Rect *velocities;
 static int sprite_w, sprite_h;
-static SDL_BlendMode blendMode = SDL_BLENDMODE_MASK;
-static SDL_ScaleMode scaleMode = SDL_SCALEMODE_NONE;
+static SDL_BlendMode blendMode = SDL_BLENDMODE_BLEND;
 
 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
 static void
@@ -77,19 +76,14 @@
 
     /* Create textures from the image */
     for (i = 0; i < state->num_windows; ++i) {
-        SDL_SelectRenderer(state->windows[i]);
-        sprites[i] = SDL_CreateTextureFromSurface(0, temp);
-        if (!sprites[i]) {
-		SDL_SetColorKey(temp, 0, 0);
-		sprites[i] = SDL_CreateTextureFromSurface(0, temp);
-	}
+        SDL_Renderer *renderer = state->renderers[i];
+        sprites[i] = SDL_CreateTextureFromSurface(renderer, temp);
         if (!sprites[i]) {
             fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
             SDL_FreeSurface(temp);
             return (-1);
         }
         SDL_SetTextureBlendMode(sprites[i], blendMode);
-        SDL_SetTextureScaleMode(sprites[i], scaleMode);
     }
     SDL_FreeSurface(temp);
 
@@ -98,15 +92,13 @@
 }
 
 void
-MoveSprites(SDL_Window * window, SDL_Texture * sprite)
+MoveSprites(SDL_Window * window, SDL_Renderer * renderer, SDL_Texture * sprite)
 {
     int i, n;
     int window_w, window_h;
     SDL_Rect temp;
     SDL_Rect *position, *velocity;
 
-    SDL_SelectRenderer(window);
-
     /* Query the sizes */
     SDL_GetWindowSize(window, &window_w, &window_h);
 
@@ -138,55 +130,55 @@
     }
 
     /* Draw a gray background */
-    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-    SDL_RenderClear();
+    SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
+    SDL_RenderClear(renderer);
 
     /* Test points */
-    SDL_SetRenderDrawColor(0xFF, 0x00, 0x00, 0xFF);
-    SDL_RenderDrawPoint(0, 0);
-    SDL_RenderDrawPoint(window_w-1, 0);
-    SDL_RenderDrawPoint(0, window_h-1);
-    SDL_RenderDrawPoint(window_w-1, window_h-1);
+    SDL_SetRenderDrawColor(renderer, 0xFF, 0x00, 0x00, 0xFF);
+    SDL_RenderDrawPoint(renderer, 0, 0);
+    SDL_RenderDrawPoint(renderer, window_w-1, 0);
+    SDL_RenderDrawPoint(renderer, 0, window_h-1);
+    SDL_RenderDrawPoint(renderer, window_w-1, window_h-1);
 
     /* Test horizontal and vertical lines */
-    SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF);
-    SDL_RenderDrawLine(1, 0, window_w-2, 0);
-    SDL_RenderDrawLine(1, window_h-1, window_w-2, window_h-1);
-    SDL_RenderDrawLine(0, 1, 0, window_h-2);
-    SDL_RenderDrawLine(window_w-1, 1, window_w-1, window_h-2);
+    SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF);
+    SDL_RenderDrawLine(renderer, 1, 0, window_w-2, 0);
+    SDL_RenderDrawLine(renderer, 1, window_h-1, window_w-2, window_h-1);
+    SDL_RenderDrawLine(renderer, 0, 1, 0, window_h-2);
+    SDL_RenderDrawLine(renderer, window_w-1, 1, window_w-1, window_h-2);
 
     /* Test fill and copy */
-    SDL_SetRenderDrawColor(0xFF, 0xFF, 0xFF, 0xFF);
+    SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
     temp.x = 1;
     temp.y = 1;
     temp.w = sprite_w;
     temp.h = sprite_h;
-    SDL_RenderFillRect(&temp);
-    SDL_RenderCopy(sprite, NULL, &temp);
+    SDL_RenderFillRect(renderer, &temp);
+    SDL_RenderCopy(renderer, sprite, NULL, &temp);
     temp.x = window_w-sprite_w-1;
     temp.y = 1;
     temp.w = sprite_w;
     temp.h = sprite_h;
-    SDL_RenderFillRect(&temp);
-    SDL_RenderCopy(sprite, NULL, &temp);
+    SDL_RenderFillRect(renderer, &temp);
+    SDL_RenderCopy(renderer, sprite, NULL, &temp);
     temp.x = 1;
     temp.y = window_h-sprite_h-1;
     temp.w = sprite_w;
     temp.h = sprite_h;
-    SDL_RenderFillRect(&temp);
-    SDL_RenderCopy(sprite, NULL, &temp);
+    SDL_RenderFillRect(renderer, &temp);
+    SDL_RenderCopy(renderer, sprite, NULL, &temp);
     temp.x = window_w-sprite_w-1;
     temp.y = window_h-sprite_h-1;
     temp.w = sprite_w;
     temp.h = sprite_h;
-    SDL_RenderFillRect(&temp);
-    SDL_RenderCopy(sprite, NULL, &temp);
+    SDL_RenderFillRect(renderer, &temp);
+    SDL_RenderCopy(renderer, sprite, NULL, &temp);
 
     /* Test diagonal lines */
-    SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF);
-    SDL_RenderDrawLine(sprite_w, sprite_h,
+    SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF);
+    SDL_RenderDrawLine(renderer, sprite_w, sprite_h,
                        window_w-sprite_w-2, window_h-sprite_h-2);
-    SDL_RenderDrawLine(window_w-sprite_w-2, sprite_h,
+    SDL_RenderDrawLine(renderer, window_w-sprite_w-2, sprite_h,
                        sprite_w, window_h-sprite_h-2);
 
     /* Move the sprite, bounce at the wall, and draw */
@@ -206,11 +198,11 @@
         }
 
         /* Blit the sprite onto the screen */
-        SDL_RenderCopy(sprite, NULL, position);
+        SDL_RenderCopy(renderer, sprite, NULL, position);
     }
 
     /* Update the screen! */
-    SDL_RenderPresent();
+    SDL_RenderPresent(renderer);
 }
 
 int
@@ -239,9 +231,6 @@
                     if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
                         blendMode = SDL_BLENDMODE_NONE;
                         consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
-                        blendMode = SDL_BLENDMODE_MASK;
-                        consumed = 2;
                     } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
                         blendMode = SDL_BLENDMODE_BLEND;
                         consumed = 2;
@@ -253,22 +242,6 @@
                         consumed = 2;
                     }
                 }
-            } else if (SDL_strcasecmp(argv[i], "--scale") == 0) {
-                if (argv[i + 1]) {
-                    if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
-                        scaleMode = SDL_SCALEMODE_NONE;
-                        consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "fast") == 0) {
-                        scaleMode = SDL_SCALEMODE_FAST;
-                        consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "slow") == 0) {
-                        scaleMode = SDL_SCALEMODE_SLOW;
-                        consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "best") == 0) {
-                        scaleMode = SDL_SCALEMODE_BEST;
-                        consumed = 2;
-                    }
-                }
             } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) {
                 cycle_color = SDL_TRUE;
                 consumed = 1;
@@ -282,7 +255,7 @@
         }
         if (consumed < 0) {
             fprintf(stderr,
-                    "Usage: %s %s [--blend none|mask|blend|add|mod] [--scale none|fast|slow|best] [--cyclecolor] [--cyclealpha]\n",
+                    "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
                     argv[0], CommonUsage(state));
             quit(1);
         }
@@ -300,9 +273,9 @@
         quit(2);
     }
     for (i = 0; i < state->num_windows; ++i) {
-        SDL_SelectRenderer(state->windows[i]);
-        SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-        SDL_RenderClear();
+        SDL_Renderer *renderer = state->renderers[i];
+        SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
+        SDL_RenderClear(renderer);
     }
     if (LoadSprite("icon.bmp") < 0) {
         quit(2);
@@ -316,10 +289,6 @@
         quit(2);
     }
     srand((unsigned int)time(NULL));
-    if (scaleMode != SDL_SCALEMODE_NONE) {
-        sprite_w += sprite_w / 2;
-        sprite_h += sprite_h / 2;
-    }
     for (i = 0; i < num_sprites; ++i) {
         positions[i].x = rand() % (state->window_w - sprite_w);
         positions[i].y = rand() % (state->window_h - sprite_h);
@@ -342,22 +311,9 @@
         ++frames;
         while (SDL_PollEvent(&event)) {
             CommonEvent(state, &event, &done);
-            switch (event.type) {
-            case SDL_WINDOWEVENT:
-                switch (event.window.event) {
-                case SDL_WINDOWEVENT_EXPOSED:
-                    SDL_SelectRenderer(SDL_GetWindowFromID(event.window.windowID));
-                    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-                    SDL_RenderClear();
-                    break;
-                }
-                break;
-            default:
-                break;
-            }
         }
         for (i = 0; i < state->num_windows; ++i) {
-            MoveSprites(state->windows[i], sprites[i]);
+            MoveSprites(state->windows[i], state->renderers[i], sprites[i]);
         }
     }
 
@@ -368,7 +324,7 @@
         printf("%2.2f frames per second\n", fps);
     }
     quit(0);
-	return 0;
+    return 0;
 }
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/test/testspriteminimal.c	Tue Feb 01 00:37:02 2011 -0800
+++ b/test/testspriteminimal.c	Sun Feb 06 21:23:32 2011 -0800
@@ -24,7 +24,7 @@
 }
 
 int
-LoadSprite(char *file)
+LoadSprite(char *file, SDL_Renderer *renderer)
 {
     SDL_Surface *temp;
 
@@ -60,11 +60,7 @@
     }
 
     /* Create textures from the image */
-    sprite = SDL_CreateTextureFromSurface(0, temp);
-    if (!sprite) {
-        SDL_SetColorKey(temp, 0, 0);
-        sprite = SDL_CreateTextureFromSurface(0, temp);
-    }
+    sprite = SDL_CreateTextureFromSurface(renderer, temp);
     if (!sprite) {
         fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
         SDL_FreeSurface(temp);
@@ -77,7 +73,7 @@
 }
 
 void
-MoveSprites(SDL_Window * window, SDL_Texture * sprite)
+MoveSprites(SDL_Window * window, SDL_Renderer * renderer, SDL_Texture * sprite)
 {
     int i;
     int window_w = WINDOW_WIDTH;
@@ -85,8 +81,8 @@
     SDL_Rect *position, *velocity;
 
     /* Draw a gray background */
-    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-    SDL_RenderClear();
+    SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
+    SDL_RenderClear(renderer);
 
     /* Move the sprite, bounce at the wall, and draw */
     for (i = 0; i < NUM_SPRITES; ++i) {
@@ -104,17 +100,18 @@
         }
 
         /* Blit the sprite onto the screen */
-        SDL_RenderCopy(sprite, NULL, position);
+        SDL_RenderCopy(renderer, sprite, NULL, position);
     }
 
     /* Update the screen! */
-    SDL_RenderPresent();
+    SDL_RenderPresent(renderer);
 }
 
 int
 main(int argc, char *argv[])
 {
     SDL_Window *window;
+    SDL_Renderer *renderer;
     int i, done;
     SDL_Event event;
 
@@ -127,7 +124,12 @@
         quit(2);
     }
 
-    if (LoadSprite("icon.bmp") < 0) {
+    renderer = SDL_CreateRenderer(window, -1, 0);
+    if (!renderer) {
+        quit(2);
+    }
+
+    if (LoadSprite("icon.bmp", renderer) < 0) {
         quit(2);
     }
 
@@ -155,7 +157,7 @@
                 done = 1;
             }
         }
-        MoveSprites(window, sprite);
+        MoveSprites(window, renderer, sprite);
     }
 
     quit(0);