The test programs compile again. SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Mon, 29 May 2006 05:08:33 +0000
branchSDL-1.3
changeset 16699857d21967bb
parent 1668 4da1ee79c9af
child 1670 eef792d31de8
The test programs compile again.
The dummy video driver is partially functional now.
include/SDL_compat.h
include/SDL_events.h
include/SDL_video.h
src/SDL_compat.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/dummy/SDL_nullvideo.c
     1.1 --- a/include/SDL_compat.h	Mon May 29 04:04:35 2006 +0000
     1.2 +++ b/include/SDL_compat.h	Mon May 29 05:08:33 2006 +0000
     1.3 @@ -25,6 +25,7 @@
     1.4  #ifndef _SDL_compat_h
     1.5  #define _SDL_compat_h
     1.6  
     1.7 +#include "SDL_video.h"
     1.8  #include "SDL_syswm.h"
     1.9  
    1.10  #include "begin_code.h"
    1.11 @@ -59,6 +60,10 @@
    1.12  #define SDL_LOGPAL 0x01
    1.13  #define SDL_PHYSPAL 0x02
    1.14  
    1.15 +#define SDL_ACTIVEEVENT	SDL_EVENT_RESERVED1
    1.16 +#define SDL_VIDEORESIZE	SDL_EVENT_RESERVED2
    1.17 +#define SDL_VIDEOEXPOSE	SDL_EVENT_RESERVED3
    1.18 +
    1.19  typedef enum
    1.20  {
    1.21      SDL_GRAB_QUERY = -1,
     2.1 --- a/include/SDL_events.h	Mon May 29 04:04:35 2006 +0000
     2.2 +++ b/include/SDL_events.h	Mon May 29 05:08:33 2006 +0000
     2.3 @@ -269,6 +269,20 @@
     2.4      SDL_SysWMmsg *msg;  /**< driver dependent data, defined in SDL_syswm.h */
     2.5  } SDL_SysWMEvent;
     2.6  
     2.7 +/* Typedefs for backwards compatibility */
     2.8 +typedef struct SDL_ActiveEvent
     2.9 +{
    2.10 +    Uint8 type;
    2.11 +    Uint8 gain;
    2.12 +    Uint8 state;
    2.13 +} SDL_ActiveEvent;
    2.14 +typedef struct SDL_ResizeEvent
    2.15 +{
    2.16 +    Uint8 type;
    2.17 +    int w;
    2.18 +    int h;
    2.19 +} SDL_ResizeEvent;
    2.20 +
    2.21  /**
    2.22   * \union SDL_Event
    2.23   *
    2.24 @@ -288,6 +302,10 @@
    2.25      SDL_QuitEvent quit;             /**< Quit request event data */
    2.26      SDL_UserEvent user;             /**< Custom event data */
    2.27      SDL_SysWMEvent syswm;           /**< System dependent window event data */
    2.28 +
    2.29 +    /* Temporarily here for backwards compatibility */
    2.30 +    SDL_ActiveEvent active;
    2.31 +    SDL_ResizeEvent resize;
    2.32  } SDL_Event;
    2.33  
    2.34  
     3.1 --- a/include/SDL_video.h	Mon May 29 04:04:35 2006 +0000
     3.2 +++ b/include/SDL_video.h	Mon May 29 05:08:33 2006 +0000
     3.3 @@ -126,22 +126,29 @@
     3.4                           struct SDL_Surface * dst, SDL_Rect * dstrect);
     3.5  
     3.6  
     3.7 -/* Useful for determining the video hardware capabilities */
     3.8 +/**
     3.9 + * \struct SDL_VideoInfo
    3.10 + *
    3.11 + * \brief Useful for determining the video hardware capabilities
    3.12 + */
    3.13  typedef struct SDL_VideoInfo
    3.14  {
    3.15 -    Uint32 hw_available:1;      /* Flag: Can you create hardware surfaces? */
    3.16 -    Uint32 wm_available:1;      /* Flag: Can you talk to a window manager? */
    3.17 +    Uint32 hw_available:1;  /**< Flag: Can you create hardware surfaces? */
    3.18 +    Uint32 wm_available:1;  /**< Flag: Can you talk to a window manager? */
    3.19      Uint32 UnusedBits1:6;
    3.20      Uint32 UnusedBits2:1;
    3.21 -    Uint32 blit_hw:1;           /* Flag: Accelerated blits HW --> HW */
    3.22 -    Uint32 blit_hw_CC:1;        /* Flag: Accelerated blits with Colorkey */
    3.23 -    Uint32 blit_hw_A:1;         /* Flag: Accelerated blits with Alpha */
    3.24 -    Uint32 blit_sw:1;           /* Flag: Accelerated blits SW --> HW */
    3.25 -    Uint32 blit_sw_CC:1;        /* Flag: Accelerated blits with Colorkey */
    3.26 -    Uint32 blit_sw_A:1;         /* Flag: Accelerated blits with Alpha */
    3.27 -    Uint32 blit_fill:1;         /* Flag: Accelerated color fill */
    3.28 +    Uint32 blit_hw:1;       /**< Flag: Accelerated blits HW --> HW */
    3.29 +    Uint32 blit_hw_CC:1;    /**< Flag: Accelerated blits with Colorkey */
    3.30 +    Uint32 blit_hw_A:1;     /**< Flag: Accelerated blits with Alpha */
    3.31 +    Uint32 blit_sw:1;       /**< Flag: Accelerated blits SW --> HW */
    3.32 +    Uint32 blit_sw_CC:1;    /**< Flag: Accelerated blits with Colorkey */
    3.33 +    Uint32 blit_sw_A:1;     /**< Flag: Accelerated blits with Alpha */
    3.34 +    Uint32 blit_fill:1;     /**< Flag: Accelerated color fill */
    3.35      Uint32 UnusedBits3:16;
    3.36      Uint32 video_mem;           /* The total amount of video memory (in K) */
    3.37 +
    3.38 +    /* Here for backwards compatibility */
    3.39 +    SDL_PixelFormat *vfmt;
    3.40  } SDL_VideoInfo;
    3.41  
    3.42  /**
     4.1 --- a/src/SDL_compat.c	Mon May 29 04:04:35 2006 +0000
     4.2 +++ b/src/SDL_compat.c	Mon May 29 05:08:33 2006 +0000
     4.3 @@ -129,9 +129,68 @@
     4.4      return modes;
     4.5  }
     4.6  
     4.7 +static int (*orig_eventfilter) (const SDL_Event * event);
     4.8 +
     4.9 +static int
    4.10 +SDL_CompatEventFilter(const SDL_Event * event)
    4.11 +{
    4.12 +    SDL_Event fake;
    4.13 +
    4.14 +    switch (event->type) {
    4.15 +    case SDL_WINDOWEVENT:
    4.16 +        switch (event->window.event) {
    4.17 +        case SDL_WINDOWEVENT_RESIZED:
    4.18 +            fake.type = SDL_VIDEORESIZE;
    4.19 +            fake.resize.w = event->window.data1;
    4.20 +            fake.resize.h = event->window.data2;
    4.21 +            SDL_PushEvent(&fake);
    4.22 +            break;
    4.23 +        case SDL_WINDOWEVENT_MINIMIZED:
    4.24 +            fake.type = SDL_ACTIVEEVENT;
    4.25 +            fake.active.gain = 0;
    4.26 +            fake.active.state = SDL_APPACTIVE;
    4.27 +            SDL_PushEvent(&fake);
    4.28 +            break;
    4.29 +        case SDL_WINDOWEVENT_RESTORED:
    4.30 +            fake.type = SDL_ACTIVEEVENT;
    4.31 +            fake.active.gain = 1;
    4.32 +            fake.active.state = SDL_APPACTIVE;
    4.33 +            SDL_PushEvent(&fake);
    4.34 +            break;
    4.35 +        case SDL_WINDOWEVENT_ENTER:
    4.36 +            fake.type = SDL_ACTIVEEVENT;
    4.37 +            fake.active.gain = 1;
    4.38 +            fake.active.state = SDL_APPMOUSEFOCUS;
    4.39 +            SDL_PushEvent(&fake);
    4.40 +            break;
    4.41 +        case SDL_WINDOWEVENT_LEAVE:
    4.42 +            fake.type = SDL_ACTIVEEVENT;
    4.43 +            fake.active.gain = 0;
    4.44 +            fake.active.state = SDL_APPMOUSEFOCUS;
    4.45 +            SDL_PushEvent(&fake);
    4.46 +            break;
    4.47 +        case SDL_WINDOWEVENT_FOCUS_GAINED:
    4.48 +            fake.type = SDL_ACTIVEEVENT;
    4.49 +            fake.active.gain = 1;
    4.50 +            fake.active.state = SDL_APPINPUTFOCUS;
    4.51 +            SDL_PushEvent(&fake);
    4.52 +            break;
    4.53 +        case SDL_WINDOWEVENT_FOCUS_LOST:
    4.54 +            fake.type = SDL_ACTIVEEVENT;
    4.55 +            fake.active.gain = 1;
    4.56 +            fake.active.state = SDL_APPINPUTFOCUS;
    4.57 +            SDL_PushEvent(&fake);
    4.58 +            break;
    4.59 +        }
    4.60 +    }
    4.61 +    return orig_eventfilter(event);
    4.62 +}
    4.63 +
    4.64  SDL_Surface *
    4.65  SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
    4.66  {
    4.67 +    int (*filter) (const SDL_Event * event);
    4.68 +    const SDL_DisplayMode *desktop_mode;
    4.69      SDL_DisplayMode mode;
    4.70      int i;
    4.71      Uint32 window_flags;
    4.72 @@ -147,6 +206,13 @@
    4.73      /* Destroy existing window */
    4.74      SDL_DestroyWindow(window);
    4.75  
    4.76 +    /* Set up the event filter */
    4.77 +    filter = SDL_GetEventFilter();
    4.78 +    if (filter != SDL_CompatEventFilter) {
    4.79 +        orig_eventfilter = filter;
    4.80 +    }
    4.81 +    SDL_SetEventFilter(SDL_CompatEventFilter);
    4.82 +
    4.83      /* Create a new window */
    4.84      window_flags = SDL_WINDOW_SHOWN;
    4.85      if (flags & SDL_FULLSCREEN) {
    4.86 @@ -167,12 +233,20 @@
    4.87      }
    4.88  
    4.89      /* Set up the desired display mode */
    4.90 -    desktop_format = SDL_GetDesktopDisplayMode()->format;
    4.91 -    if ((bpp == SDL_BITSPERPIXEL(desktop_format)) ||
    4.92 -        (desktop_format && (flags & SDL_ANYFORMAT))) {
    4.93 +    desktop_mode = SDL_GetDesktopDisplayMode();
    4.94 +    desktop_format = desktop_mode->format;
    4.95 +    if (desktop_format && ((flags & SDL_ANYFORMAT)
    4.96 +                           || (bpp == SDL_BITSPERPIXEL(desktop_format)))) {
    4.97          desired_format = desktop_format;
    4.98      } else {
    4.99          switch (bpp) {
   4.100 +        case 0:
   4.101 +            if (desktop_format) {
   4.102 +                desired_format = desktop_format;
   4.103 +            } else {
   4.104 +                desired_format = SDL_PixelFormat_RGB888;
   4.105 +            }
   4.106 +            break;
   4.107          case 8:
   4.108              desired_format = SDL_PixelFormat_Index8;
   4.109              break;
   4.110 @@ -204,7 +278,14 @@
   4.111              return NULL;
   4.112          }
   4.113      } else {
   4.114 -        mode = *SDL_GetDesktopDisplayMode();
   4.115 +        if (desktop_format) {
   4.116 +            mode.format = desktop_format;
   4.117 +        }
   4.118 +        if (desktop_mode->w && desktop_mode->h) {
   4.119 +            mode.w = desktop_mode->w;
   4.120 +            mode.h = desktop_mode->h;
   4.121 +        }
   4.122 +        mode.refresh_rate = desktop_mode->refresh_rate;
   4.123      }
   4.124      if (SDL_SetDisplayMode(&mode) < 0) {
   4.125          return NULL;
     5.1 --- a/src/video/SDL_sysvideo.h	Mon May 29 04:04:35 2006 +0000
     5.2 +++ b/src/video/SDL_sysvideo.h	Mon May 29 05:08:33 2006 +0000
     5.3 @@ -434,7 +434,7 @@
     5.4  
     5.5  extern SDL_VideoDevice *SDL_GetVideoDevice();
     5.6  extern void SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
     5.7 -extern void SDL_AddVideoDisplay(SDL_VideoDisplay * display);
     5.8 +extern void SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
     5.9  extern void SDL_AddDisplayMode(int display, const SDL_DisplayMode * mode);
    5.10  extern SDL_Window *SDL_GetWindowFromSurface(SDL_Surface * surface);
    5.11  
     6.1 --- a/src/video/SDL_video.c	Mon May 29 04:04:35 2006 +0000
     6.2 +++ b/src/video/SDL_video.c	Mon May 29 05:08:33 2006 +0000
     6.3 @@ -233,6 +233,7 @@
     6.4      _this->name = bootstrap[i]->name;
     6.5      _this->next_window_id = 1;
     6.6  
     6.7 +
     6.8      /* Set some very sane GL defaults */
     6.9      _this->gl_config.driver_loaded = 0;
    6.10      _this->gl_config.dll_handle = NULL;
    6.11 @@ -267,6 +268,16 @@
    6.12          return (-1);
    6.13      }
    6.14  
    6.15 +    /* Temporarily here for backwards compatibility */
    6.16 +    {
    6.17 +        int bpp;
    6.18 +        Uint32 Rmask, Gmask, Bmask, Amask;
    6.19 +
    6.20 +        SDL_PixelFormatEnumToMasks(SDL_GetDesktopDisplayMode()->format, &bpp,
    6.21 +                                   &Rmask, &Gmask, &Bmask, &Amask);
    6.22 +        _this->info.vfmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
    6.23 +    }
    6.24 +
    6.25      /* Sort the video modes */
    6.26      for (i = 0; i < _this->num_displays; ++i) {
    6.27          SDL_qsort(_this->displays[i].display_modes,
    6.28 @@ -325,7 +336,7 @@
    6.29  }
    6.30  
    6.31  void
    6.32 -SDL_AddVideoDisplay(SDL_VideoDisplay * display)
    6.33 +SDL_AddVideoDisplay(const SDL_VideoDisplay * display)
    6.34  {
    6.35      SDL_VideoDisplay *displays;
    6.36  
    6.37 @@ -1034,6 +1045,14 @@
    6.38              return NULL;
    6.39          }
    6.40          window->surface->flags |= SDL_SCREEN_SURFACE;
    6.41 +
    6.42 +        /* If we have a palettized surface, create a default palette */
    6.43 +        if (window->surface->format->palette) {
    6.44 +            SDL_Color colors[256];
    6.45 +            SDL_PixelFormat *vf = window->surface->format;
    6.46 +            SDL_DitherColors(colors, vf->BitsPerPixel);
    6.47 +            SDL_SetColors(window->surface, colors, 0, vf->palette->ncolors);
    6.48 +        }
    6.49      }
    6.50      surface = window->surface;
    6.51  
    6.52 @@ -1059,6 +1078,7 @@
    6.53              return NULL;
    6.54          }
    6.55          window->shadow->flags |= SDL_SHADOW_SURFACE;
    6.56 +
    6.57          surface = window->shadow;
    6.58  
    6.59          /* 8-bit shadow surfaces report that they have exclusive palette */
    6.60 @@ -1401,6 +1421,7 @@
    6.61      if (_this->displays) {
    6.62          SDL_free(_this->displays);
    6.63      }
    6.64 +    SDL_free(_this->info.vfmt);
    6.65      _this->free(_this);
    6.66      _this = NULL;
    6.67  }
     7.1 --- a/src/video/dummy/SDL_nullvideo.c	Mon May 29 04:04:35 2006 +0000
     7.2 +++ b/src/video/dummy/SDL_nullvideo.c	Mon May 29 05:08:33 2006 +0000
     7.3 @@ -53,6 +53,8 @@
     7.4  static int DUMMY_SetDisplayMode(_THIS, const SDL_DisplayMode * mode);
     7.5  static void DUMMY_CreateWindowSurface(_THIS, SDL_Window * window,
     7.6                                        Uint32 flags);
     7.7 +static void DUMMY_UpdateWindowSurface(_THIS, SDL_Window * window,
     7.8 +                                      int numrects, SDL_Rect * rects);
     7.9  static void DUMMY_VideoQuit(_THIS);
    7.10  
    7.11  /* DUMMY driver bootstrap functions */
    7.12 @@ -100,6 +102,7 @@
    7.13      device->VideoInit = DUMMY_VideoInit;
    7.14      device->SetDisplayMode = DUMMY_SetDisplayMode;
    7.15      device->CreateWindowSurface = DUMMY_CreateWindowSurface;
    7.16 +    device->UpdateWindowSurface = DUMMY_UpdateWindowSurface;
    7.17      device->VideoQuit = DUMMY_VideoQuit;
    7.18      device->InitOSKeymap = DUMMY_InitOSKeymap;
    7.19      device->PumpEvents = DUMMY_PumpEvents;
    7.20 @@ -132,6 +135,7 @@
    7.21  static int
    7.22  DUMMY_SetDisplayMode(_THIS, const SDL_DisplayMode * mode)
    7.23  {
    7.24 +    SDL_CurrentDisplay.current_mode = *mode;
    7.25      return 0;
    7.26  }
    7.27  
    7.28 @@ -148,6 +152,19 @@
    7.29                               Bmask, Amask);
    7.30  }
    7.31  
    7.32 +static void
    7.33 +DUMMY_UpdateWindowSurface(_THIS, SDL_Window * window, int numrects,
    7.34 +                          SDL_Rect * rects)
    7.35 +{
    7.36 +    static int frame_number;
    7.37 +    if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
    7.38 +        char file[128];
    7.39 +        SDL_snprintf(file, sizeof(file), "SDL_screen-%8.8d.bmp",
    7.40 +                     ++frame_number);
    7.41 +        SDL_SaveBMP(window->surface, file);
    7.42 +    }
    7.43 +}
    7.44 +
    7.45  /* Note:  If we are terminated, this could be called in the middle of
    7.46     another SDL video routine -- notably UpdateRects.
    7.47  */