diff src/video/win32/SDL_gdirender.c @ 3097:0d12e8f1de3c

Date: Thu, 05 Feb 2009 18:07:35 +0100 From: Stefan Klug Subject: [SDL] SDL 1.3 WinCE backend as promised, I've started to work on the WinCE backend of SDL 1.3 I've modified the win32 video backend and the gdi renderer, to work properly in WinCE. The results till now are great, but there is still some work to do. Attached are two patches with my changes. I would be happy if someone could review and propably commit them. The first one (configure.in.patch) should be straight forward without any side effects. The second one does the necessary changes to the win32 backend. I was really unhappy to start slicing this shiny new backend with #ifdef/#endif but I saw no other option. The most problematic issues are: - WinCe has no GetDIBits, so its practically impossible to fill a BITMAPINFO with correct values. I therefore removed the bmi member from the GDI_RenderData in SDL_gdirender.c to prevent usage of a not or not properly initialized bmi. - In SDL_win32window.c I exchanged some ASCII function by their general counterparts, (In CE only the Unicode versions are available). I don't know if this has a negative effect when running in win32 Cheers Stefan
author Sam Lantinga <slouken@libsdl.org>
date Mon, 23 Mar 2009 05:35:21 +0000
parents a434fe6360df
children 7f684f249ec9
line wrap: on
line diff
--- a/src/video/win32/SDL_gdirender.c	Mon Mar 23 05:21:40 2009 +0000
+++ b/src/video/win32/SDL_gdirender.c	Mon Mar 23 05:35:21 2009 +0000
@@ -28,6 +28,10 @@
 #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);
@@ -106,7 +110,9 @@
     HDC render_hdc;
     HDC memory_hdc;
     HDC current_hdc;
+#ifndef NO_GETDIBBITS
     LPBITMAPINFO bmi;
+#endif
     HBITMAP hbm[3];
     int current_hbm;
     SDL_DirtyRectList dirty;
@@ -197,6 +203,7 @@
     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);
@@ -211,6 +218,7 @@
     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 |=
@@ -473,6 +481,7 @@
             /* 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) {
@@ -504,6 +513,7 @@
             }
         }
         return 0;
+#endif
     default:
         SDL_Unsupported();
         texture->blendMode = SDL_BLENDMODE_NONE;
@@ -585,12 +595,17 @@
                 }
             }
         } 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");
@@ -611,7 +626,10 @@
         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));
@@ -760,6 +778,10 @@
         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,
@@ -773,6 +795,7 @@
             WIN_SetError("AlphaBlend()");
             return -1;
         }
+#endif
     } else {
         if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
             if (!BitBlt
@@ -851,9 +874,11 @@
     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]);