X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvideo%2Fomapdss%2Fsdlif.c;h=b5cadbe4cc9542b5126a3bce10a5f6794fc6258c;hb=ee7e6b2d8bc82029aac405d13f719f4532851224;hp=27a730fe6c00df7a89c13bef50612f6a4713e625;hpb=5cc6dcb71c2f2f24e54bf1ab9f09d8e560e8e4d9;p=sdl_omap.git diff --git a/src/video/omapdss/sdlif.c b/src/video/omapdss/sdlif.c index 27a730f..b5cadbe 100644 --- a/src/video/omapdss/sdlif.c +++ b/src/video/omapdss/sdlif.c @@ -13,6 +13,7 @@ #include "../SDL_pixels_c.h" #include "../../events/SDL_events_c.h" +#include "SDL_x11reuse.h" #include "linux/xenv.h" #include "osdl.h" @@ -31,6 +32,7 @@ static void omap_free(SDL_VideoDevice *device) static int omap_VideoInit(SDL_VideoDevice *this, SDL_PixelFormat *vformat) { + struct SDL_PrivateVideoData *pdata = this->hidden; const char *tmp; int w, h, ret; @@ -40,21 +42,23 @@ static int omap_VideoInit(SDL_VideoDevice *this, SDL_PixelFormat *vformat) vformat->BitsPerPixel = 16; omapsdl_input_init(); - omapsdl_config(this->hidden); + omapsdl_config(pdata); tmp = getenv("SDL_OMAP_DEFAULT_MODE"); if (tmp != NULL && sscanf(tmp, "%dx%d", &w, &h) == 2) { this->info.current_w = w; this->info.current_h = h; } - else if (osdl_video_detect_screen(this->hidden) == 0) { - this->info.current_w = this->hidden->phys_w; - this->info.current_h = this->hidden->phys_h; + else if (osdl_video_detect_screen(pdata) == 0) { + this->info.current_w = pdata->phys_w; + this->info.current_h = pdata->phys_h; } this->handles_any_size = 1; this->info.hw_available = 1; + pdata->x11reuse_context = x11reuse_init(); + return 0; } @@ -185,6 +189,17 @@ static SDL_Surface *omap_SetVideoMode(SDL_VideoDevice *this, SDL_Surface *curren pdata->ts_ymul = (v_height << 16) / pdata->layer_h; } + if (pdata->delayed_icon != NULL) { + this->SetIcon(this, pdata->delayed_icon, + pdata->delayed_icon_mask); + SDL_FreeSurface(pdata->delayed_icon); + pdata->delayed_icon = NULL; + if (pdata->delayed_icon_mask) { + free(pdata->delayed_icon_mask); + pdata->delayed_icon_mask = NULL; + } + } + return current; } @@ -251,19 +266,20 @@ static void omap_UpdateRects(SDL_VideoDevice *this, int nrects, SDL_Rect *rects) { struct SDL_PrivateVideoData *pdata = this->hidden; SDL_Surface *screen = this->screen; - Uint16 *src, *dst; - int i, x, y, w, h; + int fullscreen_blit = 0; + int i, Bpp, x, y, w, h; + char *src, *dst; trace("%d, %p", nrects, rects); - if (screen->flags & SDL_DOUBLEBUF) { - if (nrects == 1 && rects->x == 0 && rects->y == 0 + fullscreen_blit = + nrects == 1 && rects->x == 0 && rects->y == 0 && (rects->w == screen->w || rects->w == 0) - && (rects->h == screen->h || rects->h == 0) - && !pdata->app_uses_flip) - { + && (rects->h == screen->h || rects->h == 0); + + if (screen->flags & SDL_DOUBLEBUF) { + if (fullscreen_blit && !pdata->app_uses_flip) screen->pixels = osdl_video_flip(pdata); - } return; } @@ -272,7 +288,12 @@ static void omap_UpdateRects(SDL_VideoDevice *this, int nrects, SDL_Rect *rects) if (src == dst) return; - for (i = 0; i < nrects; i++) { + if (fullscreen_blit) { + memcpy(dst, src, screen->pitch * screen->h); + return; + } + + for (i = 0, Bpp = screen->format->BytesPerPixel; i < nrects; i++) { /* this supposedly has no clipping, but we'll do it anyway */ x = rects[i].x, y = rects[i].y, w = rects[i].w, h = rects[i].h; if (x < 0) @@ -288,9 +309,9 @@ static void omap_UpdateRects(SDL_VideoDevice *this, int nrects, SDL_Rect *rects) h = screen->h - y; for (; h > 0; y++, h--) - memcpy(dst + y * screen->pitch / 2 + x, - src + y * screen->pitch / 2 + x, - w * 2); + memcpy(dst + y * screen->pitch + x * Bpp, + src + y * screen->pitch + x * Bpp, + w * Bpp); } } @@ -435,6 +456,55 @@ static void omap_PumpEvents(SDL_VideoDevice *this) read_tslib ? ts_event_cb : NULL, this); } +static void omap_SetCaption(SDL_VideoDevice *this, const char *title, const char *icon) +{ + void *display = NULL, *window = NULL; + int screen = 0; + int ret; + + ret = osdl_video_get_window(&display, &screen, &window); + if (ret == 0) { + x11reuse_SetCaption(this->hidden->x11reuse_context, + display, screen, window, title, icon); + } +} + +static void omap_SetIcon(SDL_VideoDevice *this, SDL_Surface *icon, Uint8 *mask) +{ + struct SDL_PrivateVideoData *pdata = this->hidden; + void *display = NULL, *window = NULL; + int screen = 0; + int ret; + + ret = osdl_video_get_window(&display, &screen, &window); + if (ret == 0) { + x11reuse_SetIcon(pdata->x11reuse_context, + display, screen, window, icon, mask); + } + else { + SDL_Surface *old_icon = pdata->delayed_icon; + void *old_icon_mask = pdata->delayed_icon_mask; + int mask_size = ((icon->w + 7) / 8) * icon->h; + + pdata->delayed_icon = SDL_ConvertSurface(icon, + icon->format, icon->flags); + if (pdata->delayed_icon != NULL) { + memcpy(pdata->delayed_icon->pixels, icon->pixels, + icon->pitch * icon->h); + } + if (mask != NULL) { + pdata->delayed_icon_mask = malloc(mask_size); + if (pdata->delayed_icon_mask) + memcpy(pdata->delayed_icon_mask, mask, mask_size); + } + + if (old_icon != NULL) + SDL_FreeSurface(old_icon); + if (old_icon_mask) + free(old_icon_mask); + } +} + static SDL_VideoDevice *omap_create(int devindex) { SDL_VideoDevice *this; @@ -458,6 +528,8 @@ static SDL_VideoDevice *omap_create(int devindex) this->VideoQuit = omap_VideoQuit; this->InitOSKeymap = omap_InitOSKeymap; this->PumpEvents = omap_PumpEvents; + this->SetCaption = omap_SetCaption; + this->SetIcon = omap_SetIcon; this->free = omap_free; return this;