comparison src/video/windib/SDL_dibvideo.c @ 1704:03fb364e3283 SDL-1.3

Merged memory leak fix from SDL 1.2
author Sam Lantinga <slouken@libsdl.org>
date Sat, 24 Jun 2006 03:43:21 +0000
parents 4da1ee79c9af
children fc731a7d83ed
comparison
equal deleted inserted replaced
1703:a51dfda0ff33 1704:03fb364e3283
424 hdc = GetDC(SDL_Window); 424 hdc = GetDC(SDL_Window);
425 depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL); 425 depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL);
426 ReleaseDC(SDL_Window, hdc); 426 ReleaseDC(SDL_Window, hdc);
427 return (depth); 427 return (depth);
428 #else 428 #else
429 int depth;
429 int dib_size; 430 int dib_size;
430 LPBITMAPINFOHEADER dib_hdr; 431 LPBITMAPINFOHEADER dib_hdr;
431 HDC hdc; 432 HDC hdc;
432 HBITMAP hbm; 433 HBITMAP hbm;
433 434
452 GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS); 453 GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS);
453 GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS); 454 GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS);
454 DeleteObject(hbm); 455 DeleteObject(hbm);
455 ReleaseDC(NULL, hdc); 456 ReleaseDC(NULL, hdc);
456 457
458 depth = 0;
457 switch (dib_hdr->biBitCount) { 459 switch (dib_hdr->biBitCount) {
458 case 8: 460 case 8:
459 return 8; 461 depth = 8;
462 break;
460 case 24: 463 case 24:
461 return 24; 464 depth = 24;
465 break;
462 case 32: 466 case 32:
463 return 32; 467 depth = 32;
468 break;
464 case 16: 469 case 16:
465 if (dib_hdr->biCompression == BI_BITFIELDS) { 470 if (dib_hdr->biCompression == BI_BITFIELDS) {
466 /* check the red mask */ 471 /* check the red mask */
467 switch (((DWORD *) ((char *) dib_hdr + dib_hdr->biSize))[0]) { 472 switch (((DWORD *) ((char *) dib_hdr + dib_hdr->biSize))[0]) {
468 case 0xf800: 473 case 0xf800:
469 return 16; /* 565 */ 474 depth = 16;
475 break; /* 565 */
470 case 0x7c00: 476 case 0x7c00:
471 return 15; /* 555 */ 477 depth = 15;
478 break; /* 555 */
472 } 479 }
473 } 480 }
474 } 481 }
475 return 0; /* poo. */ 482 SDL_free(dib_hdr);
483 return depth;
476 #endif /* NO_GETDIBITS */ 484 #endif /* NO_GETDIBITS */
477 } 485 }
478 486
479 487
480 /* Various screen update functions available */ 488 /* Various screen update functions available */
593 break; 601 break;
594 } 602 }
595 if (settings.dmDisplayOrientation != rotation) { 603 if (settings.dmDisplayOrientation != rotation) {
596 // go to landscape 604 // go to landscape
597 this->hidden->origRotation = rotation; 605 this->hidden->origRotation = rotation;
598 ChangeDisplaySettingsEx(NULL, &settings, NULL, 606 ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_RESET,
599 CDS_RESET, NULL); 607 NULL);
600 } 608 }
601 } 609 }
602 if ((width < GetDeviceCaps(GetDC(NULL), HORZRES)) 610 if ((width < GetDeviceCaps(GetDC(NULL), HORZRES))
603 && (height > GetDeviceCaps(GetDC(NULL), VERTRES))) { 611 && (height > GetDeviceCaps(GetDC(NULL), VERTRES))) {
604 switch (rotation) { 612 switch (rotation) {
610 break; 618 break;
611 } 619 }
612 if (settings.dmDisplayOrientation != rotation) { 620 if (settings.dmDisplayOrientation != rotation) {
613 // go to portrait 621 // go to portrait
614 this->hidden->origRotation = rotation; 622 this->hidden->origRotation = rotation;
615 ChangeDisplaySettingsEx(NULL, &settings, NULL, 623 ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_RESET,
616 CDS_RESET, NULL); 624 NULL);
617 } 625 }
618 } 626 }
619 627
620 } 628 }
621 #endif 629 #endif
1048 } 1056 }
1049 1057
1050 void 1058 void
1051 DIB_VideoQuit(_THIS) 1059 DIB_VideoQuit(_THIS)
1052 { 1060 {
1061 int i, j;
1062
1053 /* Destroy the window and everything associated with it */ 1063 /* Destroy the window and everything associated with it */
1054 if (SDL_Window) { 1064 if (SDL_Window) {
1055 /* Delete the screen bitmap (also frees screen->pixels) */ 1065 /* Delete the screen bitmap (also frees screen->pixels) */
1056 if (this->screen) { 1066 if (this->screen) {
1057 #ifndef NO_CHANGEDISPLAYSETTINGS 1067 #ifndef NO_CHANGEDISPLAYSETTINGS
1058 if (this->screen->flags & SDL_FULLSCREEN) { 1068 if (this->screen->flags & SDL_FULLSCREEN) {
1059 ChangeDisplaySettings(NULL, 0); 1069 ChangeDisplaySettings(NULL, 0);
1060 ShowWindow(SDL_Window, SW_HIDE); 1070 ShowWindow(SDL_Window, SW_HIDE);
1061 } 1071 }
1062 #endif 1072 #endif
1063 if (this->screen->flags & SDL_INTERNALOPENGL) { 1073 if (this->screen->flags & SDL_OPENGL) {
1064 WIN_GL_ShutDown(this); 1074 WIN_GL_ShutDown(this);
1065 } 1075 }
1066 this->screen->pixels = NULL; 1076 this->screen->pixels = NULL;
1067 } 1077 }
1068 if (screen_bmp) { 1078 if (screen_bmp) {
1084 if (aygshell) { 1094 if (aygshell) {
1085 FreeLibrary(aygshell); 1095 FreeLibrary(aygshell);
1086 aygshell = NULL; 1096 aygshell = NULL;
1087 } 1097 }
1088 #endif 1098 #endif
1089 1099 }
1100
1101 for (i = 0; i < SDL_arraysize(SDL_modelist); ++i) {
1102 if (!SDL_modelist[i]) {
1103 continue;
1104 }
1105 for (j = 0; SDL_modelist[i][j]; ++j) {
1106 SDL_free(SDL_modelist[i][j]);
1107 }
1108 SDL_free(SDL_modelist[i]);
1109 SDL_modelist[i] = NULL;
1110 SDL_nummodes[i] = 0;
1090 } 1111 }
1091 } 1112 }
1092 1113
1093 /* Exported for the windows message loop only */ 1114 /* Exported for the windows message loop only */
1094 static void 1115 static void