Mercurial > sdl-ios-xcode
comparison src/SDL_compat.c @ 5152:be02be2ea897
Making the API simpler, removed support for palettized video modes and textures.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Feb 2011 21:23:43 -0800 |
parents | ad50b3db78bd |
children | 307ccc9c135e |
comparison
equal
deleted
inserted
replaced
5151:5429daf5e3f9 | 5152:be02be2ea897 |
---|---|
318 | 318 |
319 } | 319 } |
320 return 1; | 320 return 1; |
321 } | 321 } |
322 | 322 |
323 static int | |
324 SDL_VideoPaletteChanged(void *userdata, SDL_Palette * palette) | |
325 { | |
326 if (userdata == SDL_ShadowSurface) { | |
327 /* If the shadow palette changed, make the changes visible */ | |
328 if (!SDL_VideoSurface->format->palette) { | |
329 SDL_UpdateRect(SDL_ShadowSurface, 0, 0, 0, 0); | |
330 } | |
331 } | |
332 if (userdata == SDL_VideoSurface) { | |
333 /* The display may not have a palette, but always set texture palette */ | |
334 SDL_SetDisplayPalette(palette->colors, 0, palette->ncolors); | |
335 | |
336 if (SDL_SetTexturePalette | |
337 (SDL_VideoTexture, palette->colors, 0, palette->ncolors) < 0) { | |
338 return -1; | |
339 } | |
340 } | |
341 return 0; | |
342 } | |
343 | |
344 static void | 323 static void |
345 GetEnvironmentWindowPosition(int w, int h, int *x, int *y) | 324 GetEnvironmentWindowPosition(int w, int h, int *x, int *y) |
346 { | 325 { |
347 const char *window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); | 326 const char *window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); |
348 const char *center = SDL_getenv("SDL_VIDEO_CENTERED"); | 327 const char *center = SDL_getenv("SDL_VIDEO_CENTERED"); |
541 if (SDL_ShadowSurface) { | 520 if (SDL_ShadowSurface) { |
542 SDL_FreeSurface(SDL_ShadowSurface); | 521 SDL_FreeSurface(SDL_ShadowSurface); |
543 SDL_ShadowSurface = NULL; | 522 SDL_ShadowSurface = NULL; |
544 } | 523 } |
545 if (SDL_VideoSurface) { | 524 if (SDL_VideoSurface) { |
546 SDL_DelPaletteWatch(SDL_VideoSurface->format->palette, | |
547 SDL_VideoPaletteChanged, NULL); | |
548 SDL_FreeSurface(SDL_VideoSurface); | 525 SDL_FreeSurface(SDL_VideoSurface); |
549 SDL_VideoSurface = NULL; | 526 SDL_VideoSurface = NULL; |
550 } | 527 } |
551 if (SDL_VideoContext) { | 528 if (SDL_VideoContext) { |
552 /* SDL_GL_MakeCurrent(0, NULL); *//* Doesn't do anything */ | 529 /* SDL_GL_MakeCurrent(0, NULL); *//* Doesn't do anything */ |
692 if (!SDL_VideoSurface) { | 669 if (!SDL_VideoSurface) { |
693 return NULL; | 670 return NULL; |
694 } | 671 } |
695 SDL_VideoSurface->flags |= surface_flags; | 672 SDL_VideoSurface->flags |= surface_flags; |
696 | 673 |
697 /* Set a default screen palette */ | |
698 if (SDL_VideoSurface->format->palette) { | |
699 SDL_VideoSurface->flags |= SDL_HWPALETTE; | |
700 SDL_DitherColors(SDL_VideoSurface->format->palette->colors, | |
701 SDL_VideoSurface->format->BitsPerPixel); | |
702 SDL_AddPaletteWatch(SDL_VideoSurface->format->palette, | |
703 SDL_VideoPaletteChanged, SDL_VideoSurface); | |
704 SDL_SetPaletteColors(SDL_VideoSurface->format->palette, | |
705 SDL_VideoSurface->format->palette->colors, 0, | |
706 SDL_VideoSurface->format->palette->ncolors); | |
707 } | |
708 | |
709 /* Create a shadow surface if necessary */ | 674 /* Create a shadow surface if necessary */ |
710 if ((bpp != SDL_VideoSurface->format->BitsPerPixel) | 675 if ((bpp != SDL_VideoSurface->format->BitsPerPixel) |
711 && !(flags & SDL_ANYFORMAT)) { | 676 && !(flags & SDL_ANYFORMAT)) { |
712 SDL_ShadowSurface = | 677 SDL_ShadowSurface = |
713 SDL_CreateRGBSurface(0, width, height, bpp, 0, 0, 0, 0); | 678 SDL_CreateRGBSurface(0, width, height, bpp, 0, 0, 0, 0); |
717 SDL_ShadowSurface->flags |= surface_flags; | 682 SDL_ShadowSurface->flags |= surface_flags; |
718 | 683 |
719 /* 8-bit SDL_ShadowSurface surfaces report that they have exclusive palette */ | 684 /* 8-bit SDL_ShadowSurface surfaces report that they have exclusive palette */ |
720 if (SDL_ShadowSurface->format->palette) { | 685 if (SDL_ShadowSurface->format->palette) { |
721 SDL_ShadowSurface->flags |= SDL_HWPALETTE; | 686 SDL_ShadowSurface->flags |= SDL_HWPALETTE; |
722 if (SDL_VideoSurface->format->palette) { | 687 SDL_DitherColors(SDL_ShadowSurface->format->palette->colors, |
723 SDL_SetSurfacePalette(SDL_ShadowSurface, | 688 SDL_ShadowSurface->format->BitsPerPixel); |
724 SDL_VideoSurface->format->palette); | |
725 } else { | |
726 SDL_DitherColors(SDL_ShadowSurface->format->palette->colors, | |
727 SDL_ShadowSurface->format->BitsPerPixel); | |
728 } | |
729 SDL_AddPaletteWatch(SDL_ShadowSurface->format->palette, | |
730 SDL_VideoPaletteChanged, SDL_ShadowSurface); | |
731 } | 689 } |
732 } | 690 } |
733 SDL_PublicSurface = | 691 SDL_PublicSurface = |
734 (SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface); | 692 (SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface); |
735 | 693 |