Mercurial > sdl-ios-xcode
diff src/video/SDL_video.c @ 1706:1577404809f0 SDL-1.3
Added a multi-window version of testsprite using the new API.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 24 Jun 2006 16:51:01 +0000 |
parents | c4aa1a2f48f1 |
children | 57ce47f033a5 |
line wrap: on
line diff
--- a/src/video/SDL_video.c Sat Jun 24 04:31:42 2006 +0000 +++ b/src/video/SDL_video.c Sat Jun 24 16:51:01 2006 +0000 @@ -507,6 +507,16 @@ } else { closest->refresh_rate = mode->refresh_rate; } + /* Pick some reasonable defaults if the app and driver don't care */ + if (!closest->format) { + closest->format = SDL_PixelFormat_RGB888; + } + if (!closest->w) { + closest->w = 640; + } + if (!closest->h) { + closest->h = 480; + } return closest; } return NULL; @@ -577,6 +587,8 @@ if (!display->palette) { return -1; } + SDL_DitherColors(display->palette->colors, + SDL_BITSPERPIXEL(display_mode.format)); } } @@ -664,7 +676,7 @@ window.w = w; window.h = h; window.flags = (flags & allowed_flags); - window.display = &SDL_CurrentDisplay; + window.display = _this->current_display; if (_this->CreateWindow && _this->CreateWindow(_this, &window) < 0) { if (window.title) { @@ -707,7 +719,7 @@ SDL_zero(window); window.id = _this->next_object_id++; - window.display = &SDL_CurrentDisplay; + window.display = _this->current_display; if (!_this->CreateWindowFrom || _this->CreateWindowFrom(_this, &window, data) < 0) { @@ -734,7 +746,7 @@ return window.id; } -static __inline__ SDL_Window * +SDL_Window * SDL_GetWindowFromID(SDL_WindowID windowID) { int i, j; @@ -755,6 +767,15 @@ return NULL; } +SDL_VideoDisplay * +SDL_GetDisplayFromWindow(SDL_Window * window) +{ + if (!_this) { + return NULL; + } + return &_this->displays[window->display]; +} + Uint32 SDL_GetWindowFlags(SDL_WindowID windowID) { @@ -1221,11 +1242,20 @@ return 0; } } else { - bpp = fmt->BitsPerPixel; - Rmask = fmt->Rmask; - Gmask = fmt->Gmask; - Bmask = fmt->Bmask; - Amask = fmt->Amask; + if (fmt->Amask || !(surface_flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA))) { + bpp = fmt->BitsPerPixel; + Rmask = fmt->Rmask; + Gmask = fmt->Gmask; + Bmask = fmt->Bmask; + Amask = fmt->Amask; + } else { + /* Need a format with alpha */ + 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"); @@ -1261,14 +1291,10 @@ } /* Copy the palette if any */ - if (fmt->palette && dst.format->palette) { + if (fmt->palette) { SDL_SetTexturePalette(textureID, fmt->palette->colors, 0, fmt->palette->ncolors); - - SDL_memcpy(dst.format->palette->colors, - fmt->palette->colors, - fmt->palette->ncolors * sizeof(SDL_Color)); - dst.format->palette->ncolors = fmt->palette->ncolors; + SDL_SetSurfacePalette(&dst, fmt->palette); } /* Make the texture transparent if the surface has colorkey */ @@ -1552,10 +1578,11 @@ } if (!rect) { + SDL_Window *window = SDL_GetWindowFromID(renderer->window); full_rect.x = 0; full_rect.y = 0; - full_rect.w = renderer->window->w; - full_rect.h = renderer->window->h; + full_rect.w = window->w; + full_rect.h = window->h; rect = &full_rect; } @@ -1588,10 +1615,11 @@ srcrect = &full_srcrect; } if (!dstrect) { + SDL_Window *window = SDL_GetWindowFromID(renderer->window); full_dstrect.x = 0; full_dstrect.y = 0; - full_dstrect.w = renderer->window->w; - full_dstrect.h = renderer->window->h; + full_dstrect.w = window->w; + full_dstrect.h = window->h; dstrect = &full_dstrect; } @@ -1615,10 +1643,11 @@ } if (!rect) { + SDL_Window *window = SDL_GetWindowFromID(renderer->window); full_rect.x = 0; full_rect.y = 0; - full_rect.w = renderer->window->w; - full_rect.h = renderer->window->h; + full_rect.w = window->w; + full_rect.h = window->h; rect = &full_rect; } @@ -1641,10 +1670,11 @@ } if (!rect) { + SDL_Window *window = SDL_GetWindowFromID(renderer->window); full_rect.x = 0; full_rect.y = 0; - full_rect.w = renderer->window->w; - full_rect.h = renderer->window->h; + full_rect.w = window->w; + full_rect.h = window->h; rect = &full_rect; }