The dummy video driver compiles. :) SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Sun, 28 May 2006 21:56:07 +0000
branchSDL-1.3
changeset 16666e7ec5cb83c3
parent 1665 28193f833b2b
child 1667 1fddae038bc8
The dummy video driver compiles. :)
src/events/SDL_events.c
src/video/SDL_surface.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/dummy/SDL_nullvideo.c
test/testsprite.c
     1.1 --- a/src/events/SDL_events.c	Sun May 28 18:18:30 2006 +0000
     1.2 +++ b/src/events/SDL_events.c	Sun May 28 21:56:07 2006 +0000
     1.3 @@ -219,7 +219,6 @@
     1.4      SDL_StopEventThread ();
     1.5  
     1.6      /* Shutdown event handlers */
     1.7 -    SDL_AppActiveQuit ();
     1.8      SDL_KeyboardQuit ();
     1.9      SDL_MouseQuit ();
    1.10      SDL_QuitQuit ();
    1.11 @@ -251,7 +250,6 @@
    1.12  
    1.13      /* Initialize event handlers */
    1.14      retcode = 0;
    1.15 -    retcode += SDL_AppActiveInit ();
    1.16      retcode += SDL_KeyboardInit ();
    1.17      retcode += SDL_MouseInit ();
    1.18      retcode += SDL_QuitInit ();
     2.1 --- a/src/video/SDL_surface.c	Sun May 28 18:18:30 2006 +0000
     2.2 +++ b/src/video/SDL_surface.c	Sun May 28 21:56:07 2006 +0000
     2.3 @@ -896,12 +896,7 @@
     2.4  void
     2.5  SDL_FreeSurface (SDL_Surface * surface)
     2.6  {
     2.7 -    SDL_VideoDevice *_this = SDL_GetVideoDevice ();
     2.8 -
     2.9 -    /* Free anything that's not NULL, and not the screen surface */
    2.10 -    if ((surface == NULL) ||
    2.11 -        (_this &&
    2.12 -         ((surface == SDL_ShadowSurface) || (surface == SDL_VideoSurface)))) {
    2.13 +    if (surface == NULL) {
    2.14          return;
    2.15      }
    2.16      if (--surface->refcount > 0) {
     3.1 --- a/src/video/SDL_sysvideo.h	Sun May 28 18:18:30 2006 +0000
     3.2 +++ b/src/video/SDL_sysvideo.h	Sun May 28 21:56:07 2006 +0000
     3.3 @@ -122,7 +122,7 @@
     3.4      void (*SetWindowGrab) (_THIS, SDL_Window * window);
     3.5      void (*DestroyWindow) (_THIS, SDL_Window * window);
     3.6  
     3.7 -    SDL_Surface *(*CreateWindowSurface) (_THIS, SDL_Window * window);
     3.8 +    void (*CreateWindowSurface) (_THIS, SDL_Window * window, Uint32 flags);
     3.9      void (*UpdateWindowSurface) (_THIS, SDL_Window * window, int numrects,
    3.10                                   SDL_Rect * rects);
    3.11      void (*FlipWindowSurface) (_THIS, SDL_Window * window);
     4.1 --- a/src/video/SDL_video.c	Sun May 28 18:18:30 2006 +0000
     4.2 +++ b/src/video/SDL_video.c	Sun May 28 21:56:07 2006 +0000
     4.3 @@ -997,10 +997,8 @@
     4.4  SDL_CreateWindowSurface (SDL_WindowID windowID, Uint32 format, Uint32 flags)
     4.5  {
     4.6      SDL_Window *window = SDL_GetWindowFromID (windowID);
     4.7 +    Uint32 black;
     4.8      SDL_Surface *surface;
     4.9 -    SDL_Surface *shadow;
    4.10 -    Uint32 surface_format;
    4.11 -    Uint32 black;
    4.12  
    4.13      if (!window) {
    4.14          return NULL;
    4.15 @@ -1011,54 +1009,50 @@
    4.16      }
    4.17  
    4.18      if (!window->surface) {
    4.19 -        window->surface = _this->CreateWindowSurface (_this, window);
    4.20 +        _this->CreateWindowSurface (_this, window, flags);
    4.21          if (!window->surface) {
    4.22              return NULL;
    4.23          }
    4.24 +        window->surface->flags |= SDL_SCREEN_SURFACE;
    4.25      }
    4.26 +    surface = window->surface;
    4.27  
    4.28      if (window->shadow) {
    4.29          SDL_FreeSurface (window->shadow);
    4.30          window->shadow = NULL;
    4.31      }
    4.32  
    4.33 -    surface = window->surface;
    4.34 -    surface_format =
    4.35 -        SDL_MasksToPixelFormatEnum (surface->format->BitsPerPixel,
    4.36 -                                    surface->format->Rmask,
    4.37 -                                    surface->format->Gmask,
    4.38 -                                    surface->format->Bmask,
    4.39 -                                    surface->format->Amask);
    4.40 -
    4.41      /* Create a shadow surface if necessary */
    4.42 -    if ((!(flags & SDL_ANYFORMAT) && (surface_format != format)) ||
    4.43 -        ((flags & SDL_HWPALETTE)
    4.44 -         && !(window->surface->flags & SDL_HWPALETTE))) {
    4.45 +    if ((!(flags & SDL_ANYFORMAT)
    4.46 +         && (format != SDL_GetCurrentDisplayMode ()->format))
    4.47 +        || ((flags & SDL_HWPALETTE)
    4.48 +            && !(window->surface->flags & SDL_HWPALETTE))) {
    4.49          int bpp;
    4.50          Uint32 Rmask, Gmask, Bmask, Amask;
    4.51  
    4.52 -        SDL_PixelFormatEnumToMasks (format, &bpp, &Rmask, &Gmask, &Bmask,
    4.53 +        SDL_PixelFormatEnumToMasks (format, &bpp, &Amask, &Gmask, &Bmask,
    4.54                                      &Amask);
    4.55 -        shadow =
    4.56 -            SDL_CreateRGBSurface (SDL_SWSURFACE, surface->w, surface->h,
    4.57 -                                  bpp, Rmask, Gmask, Bmask, Amask);
    4.58 -        if (shadow == NULL) {
    4.59 +        window->shadow =
    4.60 +            SDL_CreateRGBSurface (SDL_SWSURFACE, surface->w, surface->h, bpp,
    4.61 +                                  Rmask, Gmask, Bmask, Amask);
    4.62 +        if (window->shadow == NULL) {
    4.63              return NULL;
    4.64          }
    4.65 +        window->shadow->flags |= SDL_SHADOW_SURFACE;
    4.66 +        surface = window->shadow;
    4.67  
    4.68          /* 8-bit shadow surfaces report that they have exclusive palette */
    4.69 -        if (shadow->format->palette) {
    4.70 -            shadow->flags |= SDL_HWPALETTE;
    4.71 -            if (format == surface_format) {
    4.72 -                SDL_memcpy (shadow->format->palette->colors,
    4.73 -                            surface->format->palette->colors,
    4.74 -                            surface->format->palette->ncolors *
    4.75 +        if (surface->format->palette) {
    4.76 +            surface->flags |= SDL_HWPALETTE;
    4.77 +            if (format == SDL_GetCurrentDisplayMode ()->format) {
    4.78 +                SDL_memcpy (surface->format->palette->colors,
    4.79 +                            window->surface->format->palette->colors,
    4.80 +                            window->surface->format->palette->ncolors *
    4.81                              sizeof (SDL_Color));
    4.82              } else {
    4.83 -                SDL_DitherColors (shadow->format->palette->colors, bpp);
    4.84 +                SDL_DitherColors (surface->format->palette->colors, bpp);
    4.85              }
    4.86          }
    4.87 -        surface = window->shadow = shadow;
    4.88      }
    4.89  
    4.90      /* Clear the surface for display */
     5.1 --- a/src/video/dummy/SDL_nullvideo.c	Sun May 28 18:18:30 2006 +0000
     5.2 +++ b/src/video/dummy/SDL_nullvideo.c	Sun May 28 21:56:07 2006 +0000
     5.3 @@ -51,7 +51,8 @@
     5.4  /* Initialization/Query functions */
     5.5  static int DUMMY_VideoInit (_THIS);
     5.6  static int DUMMY_SetDisplayMode (_THIS, const SDL_DisplayMode * mode);
     5.7 -static SDL_Surface *DUMMY_CreateWindowSurface (_THIS, SDL_Window * window);
     5.8 +static void DUMMY_CreateWindowSurface (_THIS, SDL_Window * window,
     5.9 +                                       Uint32 flags);
    5.10  static void DUMMY_VideoQuit (_THIS);
    5.11  
    5.12  /* DUMMY driver bootstrap functions */
    5.13 @@ -98,6 +99,7 @@
    5.14      /* Set the function pointers */
    5.15      device->VideoInit = DUMMY_VideoInit;
    5.16      device->SetDisplayMode = DUMMY_SetDisplayMode;
    5.17 +    device->CreateWindowSurface = DUMMY_CreateWindowSurface;
    5.18      device->VideoQuit = DUMMY_VideoQuit;
    5.19      device->InitOSKeymap = DUMMY_InitOSKeymap;
    5.20      device->PumpEvents = DUMMY_PumpEvents;
    5.21 @@ -128,93 +130,17 @@
    5.22      return 0;
    5.23  }
    5.24  
    5.25 -static SDL_Surface *
    5.26 -DUMMY_CreateWindowSurface (_THIS, SDL_Window * window)
    5.27 +static void
    5.28 +DUMMY_CreateWindowSurface (_THIS, SDL_Window * window, Uint32 flags)
    5.29  {
    5.30      int bpp;
    5.31      Uint32 Rmask, Gmask, Bmask, Amask;
    5.32  
    5.33 -    if (_this->hidden->buffer) {
    5.34 -        SDL_free (_this->hidden->buffer);
    5.35 -    }
    5.36 -
    5.37 -    _this->hidden->buffer =
    5.38 -        SDL_malloc (mode->w * mode->h * SDL_BYTESPERPIXEL (mode->format));
    5.39 -    if (!_this->hidden->buffer) {
    5.40 -        SDL_SetError ("Couldn't allocate buffer for requested mode");
    5.41 -        return (NULL);
    5.42 -    }
    5.43 -
    5.44 -/* 	printf("Setting mode %dx%d\n", width, height); */
    5.45 -
    5.46 -    SDL_memset (_this->hidden->buffer, 0,
    5.47 -                mode->w * mode->h * SDL_BYTESPERPIXEL (mode->format));
    5.48 -
    5.49 -    /* Allocate the new pixel format for the screen */
    5.50 -    SDL_PixelFormatEnumToMasks (mode->format, &bpp, &Rmask, &Gmask, &Bmask,
    5.51 -                                &Amask);
    5.52 -    if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, Amask)) {
    5.53 -        SDL_free (_this->hidden->buffer);
    5.54 -        _this->hidden->buffer = NULL;
    5.55 -        SDL_SetError
    5.56 -            ("Couldn't allocate new pixel format for requested mode");
    5.57 -        return (NULL);
    5.58 -    }
    5.59 -
    5.60 -    /* Set up the new mode framebuffer */
    5.61 -    current->flags = flags & SDL_FULLSCREEN;
    5.62 -    _this->hidden->w = current->w = mode->w;
    5.63 -    _this->hidden->h = current->h = mode->h;
    5.64 -    current->pitch = current->w * SDL_BYTESPERPIXEL (mode->format);
    5.65 -    current->pixels = _this->hidden->buffer;
    5.66 -
    5.67 -    /* We're done */
    5.68 -    return (current);
    5.69 -}
    5.70 -
    5.71 -SDL_Surface *
    5.72 -DUMMY_SetVideoMode (_THIS, SDL_Surface * current,
    5.73 -                    const SDL_DisplayMode * mode, Uint32 flags)
    5.74 -{
    5.75 -    int bpp;
    5.76 -    Uint32 Rmask, Gmask, Bmask, Amask;
    5.77 -
    5.78 -    if (_this->hidden->buffer) {
    5.79 -        SDL_free (_this->hidden->buffer);
    5.80 -    }
    5.81 -
    5.82 -    _this->hidden->buffer =
    5.83 -        SDL_malloc (mode->w * mode->h * SDL_BYTESPERPIXEL (mode->format));
    5.84 -    if (!_this->hidden->buffer) {
    5.85 -        SDL_SetError ("Couldn't allocate buffer for requested mode");
    5.86 -        return (NULL);
    5.87 -    }
    5.88 -
    5.89 -/* 	printf("Setting mode %dx%d\n", width, height); */
    5.90 -
    5.91 -    SDL_memset (_this->hidden->buffer, 0,
    5.92 -                mode->w * mode->h * SDL_BYTESPERPIXEL (mode->format));
    5.93 -
    5.94 -    /* Allocate the new pixel format for the screen */
    5.95 -    SDL_PixelFormatEnumToMasks (mode->format, &bpp, &Rmask, &Gmask, &Bmask,
    5.96 -                                &Amask);
    5.97 -    if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, Amask)) {
    5.98 -        SDL_free (_this->hidden->buffer);
    5.99 -        _this->hidden->buffer = NULL;
   5.100 -        SDL_SetError
   5.101 -            ("Couldn't allocate new pixel format for requested mode");
   5.102 -        return (NULL);
   5.103 -    }
   5.104 -
   5.105 -    /* Set up the new mode framebuffer */
   5.106 -    current->flags = flags & SDL_FULLSCREEN;
   5.107 -    _this->hidden->w = current->w = mode->w;
   5.108 -    _this->hidden->h = current->h = mode->h;
   5.109 -    current->pitch = current->w * SDL_BYTESPERPIXEL (mode->format);
   5.110 -    current->pixels = _this->hidden->buffer;
   5.111 -
   5.112 -    /* We're done */
   5.113 -    return (current);
   5.114 +    SDL_PixelFormatEnumToMasks (SDL_GetCurrentDisplayMode ()->format, &bpp,
   5.115 +                                &Rmask, &Gmask, &Bmask, &Amask);
   5.116 +    window->surface =
   5.117 +        SDL_CreateRGBSurface (flags, window->w, window->h, bpp, Rmask, Gmask,
   5.118 +                              Bmask, Amask);
   5.119  }
   5.120  
   5.121  /* Note:  If we are terminated, this could be called in the middle of
   5.122 @@ -223,9 +149,6 @@
   5.123  void
   5.124  DUMMY_VideoQuit (_THIS)
   5.125  {
   5.126 -    if (_this->hidden->buffer) {
   5.127 -        SDL_free (_this->hidden->buffer);
   5.128 -    }
   5.129  }
   5.130  
   5.131  /* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/test/testsprite.c	Sun May 28 18:18:30 2006 +0000
     6.2 +++ b/test/testsprite.c	Sun May 28 21:56:07 2006 +0000
     6.3 @@ -156,7 +156,6 @@
     6.4  int
     6.5  main (int argc, char *argv[])
     6.6  {
     6.7 -    SDL_DisplayMode mode;
     6.8      SDL_Surface *screen;
     6.9      Uint8 *mem;
    6.10      int width, height;
    6.11 @@ -212,11 +211,7 @@
    6.12      }
    6.13  
    6.14      /* Set video mode */
    6.15 -    mode.format = 0;            /* FIXME */
    6.16 -    mode.w = width;
    6.17 -    mode.h = height;
    6.18 -    mode.refresh_rate = 0;
    6.19 -    screen = SDL_SetDisplayMode (&mode, videoflags);
    6.20 +    screen = SDL_SetVideoMode (width, height, video_bpp, videoflags);
    6.21      if (!screen) {
    6.22          fprintf (stderr, "Couldn't set %dx%d video mode: %s\n",
    6.23                   width, height, SDL_GetError ());