comparison src/video/gapi/SDL_gapivideo.c @ 1497:420b3f47806d

Fixes from Dmitry Yakimov: fixed bugs 159 and 160: + added threaded timers support ! fixed restoring sdl window focus (AV in windows message handler) ! disabled forgotten cdrom and joystick in config file. * disabled minimizing sdl window while loosing focus. PocketPC does not have a task bar, so it is an inconvenient and unusual behaviour for PPC users. + added WIN_Paint handler for GAPI ! fixed loosing focus while using GAPI videi driver + added TestTimer project * removed unnecessary macros (ENABLE_WINDIB ...) from projects
author Sam Lantinga <slouken@libsdl.org>
date Sat, 11 Mar 2006 23:46:45 +0000
parents 0a2bd6507477
children 21b1fbb53f4a
comparison
equal deleted inserted replaced
1496:405e20dc004c 1497:420b3f47806d
1086 } 1086 }
1087 1087
1088 1088
1089 static void GAPI_UpdateRects(_THIS, int numrects, SDL_Rect *rects) 1089 static void GAPI_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
1090 { 1090 {
1091 // we do not want to corrupt video memory
1092 if( gapi->suspended ) return;
1093
1091 if( gapi->needUpdate ) 1094 if( gapi->needUpdate )
1092 gapi->videoMem = gapi->gxFunc.GXBeginDraw(); 1095 gapi->videoMem = gapi->gxFunc.GXBeginDraw();
1093 1096
1094 if( gapi->gxProperties.cBPP < 8 ) 1097 if( gapi->gxProperties.cBPP < 8 )
1095 GAPI_UpdateRectsMono(this, numrects, rects); 1098 GAPI_UpdateRectsMono(this, numrects, rects);
1170 static void GAPI_PaletteChanged(_THIS, HWND window) 1173 static void GAPI_PaletteChanged(_THIS, HWND window)
1171 { 1174 {
1172 OutputDebugString(TEXT("GAPI_PaletteChanged NOT IMPLEMENTED !\r\n")); 1175 OutputDebugString(TEXT("GAPI_PaletteChanged NOT IMPLEMENTED !\r\n"));
1173 } 1176 }
1174 1177
1175 /* Exported for the windows message loop only */
1176 static void GAPI_WinPAINT(_THIS, HDC hdc) 1178 static void GAPI_WinPAINT(_THIS, HDC hdc)
1177 { 1179 {
1178 OutputDebugString(TEXT("GAPI_WinPAINT NOT IMPLEMENTED !\r\n")); 1180 // draw current offscreen buffer on hdc
1181
1182 int bpp = 16; // we always use either 8 or 16 bpp internally
1183
1184 unsigned short *bitmapData;
1185 HBITMAP hb;
1186 HDC srcDC;
1187
1188 // Create a DIB
1189 BYTE buffer[sizeof(BITMAPINFOHEADER) + 3 * sizeof(RGBQUAD)] = {0};
1190 BITMAPINFO* pBMI = (BITMAPINFO*)buffer;
1191 BITMAPINFOHEADER* pHeader = &pBMI->bmiHeader;
1192 DWORD* pColors = (DWORD*)&pBMI->bmiColors;
1193
1194 // CreateDIBSection does not support 332 pixel format on wce
1195 if( gapi->gxProperties.cBPP == 8 ) return;
1196
1197 // DIB Header
1198 pHeader->biSize = sizeof(BITMAPINFOHEADER);
1199 pHeader->biWidth = this->hidden->w;
1200 pHeader->biHeight = -this->hidden->h;
1201 pHeader->biPlanes = 1;
1202 pHeader->biBitCount = bpp;
1203 pHeader->biCompression = BI_RGB;
1204 pHeader->biSizeImage = (this->hidden->w * this->hidden->h * bpp) / 8;
1205
1206 // Color masks
1207 if( bpp == 16 )
1208 {
1209 pColors[0] = REDMASK;
1210 pColors[1] = GREENMASK;
1211 pColors[2] = BLUEMASK;
1212 pHeader->biCompression = BI_BITFIELDS;
1213 }
1214 // Create the DIB
1215 hb = CreateDIBSection( 0, pBMI, DIB_RGB_COLORS, (void**)&bitmapData, 0, 0 );
1216
1217 // copy data
1218 // FIXME: prevent misalignment, but I've never seen non aligned width of screen
1219 memcpy(bitmapData, this->hidden->buffer, pHeader->biSizeImage);
1220 srcDC = CreateCompatibleDC(hdc);
1221 SelectObject(srcDC, hb);
1222
1223 BitBlt(hdc, 0, 0, this->hidden->w, this->hidden->h, srcDC, 0, 0, SRCCOPY);
1224
1225 DeleteObject(hb);
1226 DeleteDC(srcDC);
1179 } 1227 }
1180 1228
1181 int GAPI_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) 1229 int GAPI_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
1182 { 1230 {
1183 GAPI_CreatePalette(ncolors, colors); 1231 GAPI_CreatePalette(ncolors, colors);