src/video/directfb/SDL_DirectFB_video.c
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1659 14717b52abc0
child 1668 4da1ee79c9af
     1.1 --- a/src/video/directfb/SDL_DirectFB_video.c	Sun May 21 17:27:13 2006 +0000
     1.2 +++ b/src/video/directfb/SDL_DirectFB_video.c	Sun May 28 13:04:16 2006 +0000
     1.3 @@ -45,41 +45,47 @@
     1.4  #include "SDL_DirectFB_yuv.h"
     1.5  
     1.6  /* The implementation dependent data for the window manager cursor */
     1.7 -struct WMcursor {
     1.8 -	int unused;
     1.9 +struct WMcursor
    1.10 +{
    1.11 +    int unused;
    1.12  };
    1.13  
    1.14  
    1.15  /* Initialization/Query functions */
    1.16 -static int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat);
    1.17 -static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
    1.18 -static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
    1.19 -static int DirectFB_SetColors(_THIS, int firstcolor, int ncolors,
    1.20 -			 SDL_Color *colors);
    1.21 -static void DirectFB_VideoQuit(_THIS);
    1.22 +static int DirectFB_VideoInit (_THIS, SDL_PixelFormat * vformat);
    1.23 +static SDL_Rect **DirectFB_ListModes (_THIS, SDL_PixelFormat * format,
    1.24 +                                      Uint32 flags);
    1.25 +static SDL_Surface *DirectFB_SetVideoMode (_THIS, SDL_Surface * current,
    1.26 +                                           int width, int height, int bpp,
    1.27 +                                           Uint32 flags);
    1.28 +static int DirectFB_SetColors (_THIS, int firstcolor, int ncolors,
    1.29 +                               SDL_Color * colors);
    1.30 +static void DirectFB_VideoQuit (_THIS);
    1.31  
    1.32  /* Hardware surface functions */
    1.33 -static int DirectFB_AllocHWSurface(_THIS, SDL_Surface *surface);
    1.34 -static int DirectFB_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
    1.35 -static int DirectFB_LockHWSurface(_THIS, SDL_Surface *surface);
    1.36 -static void DirectFB_UnlockHWSurface(_THIS, SDL_Surface *surface);
    1.37 -static void DirectFB_FreeHWSurface(_THIS, SDL_Surface *surface);
    1.38 -static int DirectFB_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst);
    1.39 -static int DirectFB_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
    1.40 -                                SDL_Surface *dst, SDL_Rect *dstrect);
    1.41 -static int DirectFB_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key);
    1.42 -static int DirectFB_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha);
    1.43 -static int DirectFB_FlipHWSurface(_THIS, SDL_Surface *surface);
    1.44 -static int DirectFB_ShowWMCursor(_THIS, WMcursor *cursor);
    1.45 +static int DirectFB_AllocHWSurface (_THIS, SDL_Surface * surface);
    1.46 +static int DirectFB_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * dstrect,
    1.47 +                                Uint32 color);
    1.48 +static int DirectFB_LockHWSurface (_THIS, SDL_Surface * surface);
    1.49 +static void DirectFB_UnlockHWSurface (_THIS, SDL_Surface * surface);
    1.50 +static void DirectFB_FreeHWSurface (_THIS, SDL_Surface * surface);
    1.51 +static int DirectFB_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst);
    1.52 +static int DirectFB_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect,
    1.53 +                                 SDL_Surface * dst, SDL_Rect * dstrect);
    1.54 +static int DirectFB_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key);
    1.55 +static int DirectFB_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha);
    1.56 +static int DirectFB_FlipHWSurface (_THIS, SDL_Surface * surface);
    1.57 +static int DirectFB_ShowWMCursor (_THIS, WMcursor * cursor);
    1.58  
    1.59  /* Various screen update functions available */
    1.60 -static void DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
    1.61 -static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect *rects);
    1.62 +static void DirectFB_DirectUpdate (_THIS, int numrects, SDL_Rect * rects);
    1.63 +static void DirectFB_WindowedUpdate (_THIS, int numrects, SDL_Rect * rects);
    1.64  
    1.65  /* This is the rect EnumModes2 uses */
    1.66 -struct DirectFBEnumRect {
    1.67 -	SDL_Rect r;
    1.68 -	struct DirectFBEnumRect* next;
    1.69 +struct DirectFBEnumRect
    1.70 +{
    1.71 +    SDL_Rect r;
    1.72 +    struct DirectFBEnumRect *next;
    1.73  };
    1.74  
    1.75  static struct DirectFBEnumRect *enumlist = NULL;
    1.76 @@ -87,943 +93,955 @@
    1.77  
    1.78  /* DirectFB driver bootstrap functions */
    1.79  
    1.80 -static int DirectFB_Available(void)
    1.81 +static int
    1.82 +DirectFB_Available (void)
    1.83  {
    1.84 -  return 1;
    1.85 +    return 1;
    1.86  }
    1.87  
    1.88 -static void DirectFB_DeleteDevice(SDL_VideoDevice *device)
    1.89 +static void
    1.90 +DirectFB_DeleteDevice (SDL_VideoDevice * device)
    1.91  {
    1.92 -  SDL_free(device->hidden);
    1.93 -  SDL_free(device);
    1.94 +    SDL_free (device->hidden);
    1.95 +    SDL_free (device);
    1.96  }
    1.97  
    1.98 -static SDL_VideoDevice *DirectFB_CreateDevice(int devindex)
    1.99 +static SDL_VideoDevice *
   1.100 +DirectFB_CreateDevice (int devindex)
   1.101  {
   1.102 -  SDL_VideoDevice *device;
   1.103 +    SDL_VideoDevice *device;
   1.104  
   1.105 -  /* Initialize all variables that we clean on shutdown */
   1.106 -  device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
   1.107 -  if (device)
   1.108 -    {
   1.109 -      SDL_memset (device, 0, (sizeof *device));
   1.110 -      device->hidden = (struct SDL_PrivateVideoData *) malloc (sizeof (*device->hidden));
   1.111 +    /* Initialize all variables that we clean on shutdown */
   1.112 +    device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice));
   1.113 +    if (device) {
   1.114 +        SDL_memset (device, 0, (sizeof *device));
   1.115 +        device->hidden = (struct SDL_PrivateVideoData *)
   1.116 +            malloc (sizeof (*device->hidden));
   1.117      }
   1.118 -  if (device == NULL  ||  device->hidden == NULL)
   1.119 -    {
   1.120 -      SDL_OutOfMemory();
   1.121 -      if (device)
   1.122 -        {
   1.123 -          free (device);
   1.124 +    if (device == NULL || device->hidden == NULL) {
   1.125 +        SDL_OutOfMemory ();
   1.126 +        if (device) {
   1.127 +            free (device);
   1.128          }
   1.129 -      return(0);
   1.130 +        return (0);
   1.131      }
   1.132 -  SDL_memset (device->hidden, 0, sizeof (*device->hidden));
   1.133 +    SDL_memset (device->hidden, 0, sizeof (*device->hidden));
   1.134  
   1.135 -  /* Set the function pointers */
   1.136 -  device->VideoInit = DirectFB_VideoInit;
   1.137 -  device->ListModes = DirectFB_ListModes;
   1.138 -  device->SetVideoMode = DirectFB_SetVideoMode;
   1.139 -  device->SetColors = DirectFB_SetColors;
   1.140 -  device->UpdateRects = NULL;
   1.141 -  device->CreateYUVOverlay = DirectFB_CreateYUVOverlay;
   1.142 -  device->VideoQuit = DirectFB_VideoQuit;
   1.143 -  device->AllocHWSurface = DirectFB_AllocHWSurface;
   1.144 -  device->CheckHWBlit = DirectFB_CheckHWBlit;
   1.145 -  device->FillHWRect = DirectFB_FillHWRect;
   1.146 -  device->SetHWColorKey = DirectFB_SetHWColorKey;
   1.147 -  device->SetHWAlpha = DirectFB_SetHWAlpha;
   1.148 -  device->LockHWSurface = DirectFB_LockHWSurface;
   1.149 -  device->UnlockHWSurface = DirectFB_UnlockHWSurface;
   1.150 -  device->FlipHWSurface = DirectFB_FlipHWSurface;
   1.151 -  device->FreeHWSurface = DirectFB_FreeHWSurface;
   1.152 -  device->ShowWMCursor = DirectFB_ShowWMCursor;
   1.153 -  device->SetCaption = NULL;
   1.154 -  device->SetIcon = NULL;
   1.155 -  device->IconifyWindow = NULL;
   1.156 -  device->GrabInput = NULL;
   1.157 -  device->GetWMInfo = NULL;
   1.158 -  device->InitOSKeymap = DirectFB_InitOSKeymap;
   1.159 -  device->PumpEvents = DirectFB_PumpEvents;
   1.160 +    /* Set the function pointers */
   1.161 +    device->VideoInit = DirectFB_VideoInit;
   1.162 +    device->ListModes = DirectFB_ListModes;
   1.163 +    device->SetVideoMode = DirectFB_SetVideoMode;
   1.164 +    device->SetColors = DirectFB_SetColors;
   1.165 +    device->UpdateRects = NULL;
   1.166 +    device->CreateYUVOverlay = DirectFB_CreateYUVOverlay;
   1.167 +    device->VideoQuit = DirectFB_VideoQuit;
   1.168 +    device->AllocHWSurface = DirectFB_AllocHWSurface;
   1.169 +    device->CheckHWBlit = DirectFB_CheckHWBlit;
   1.170 +    device->FillHWRect = DirectFB_FillHWRect;
   1.171 +    device->SetHWColorKey = DirectFB_SetHWColorKey;
   1.172 +    device->SetHWAlpha = DirectFB_SetHWAlpha;
   1.173 +    device->LockHWSurface = DirectFB_LockHWSurface;
   1.174 +    device->UnlockHWSurface = DirectFB_UnlockHWSurface;
   1.175 +    device->FlipHWSurface = DirectFB_FlipHWSurface;
   1.176 +    device->FreeHWSurface = DirectFB_FreeHWSurface;
   1.177 +    device->ShowWMCursor = DirectFB_ShowWMCursor;
   1.178 +    device->SetCaption = NULL;
   1.179 +    device->SetIcon = NULL;
   1.180 +    device->IconifyWindow = NULL;
   1.181 +    device->GrabInput = NULL;
   1.182 +    device->GetWMInfo = NULL;
   1.183 +    device->InitOSKeymap = DirectFB_InitOSKeymap;
   1.184 +    device->PumpEvents = DirectFB_PumpEvents;
   1.185  
   1.186 -  device->free = DirectFB_DeleteDevice;
   1.187 +    device->free = DirectFB_DeleteDevice;
   1.188  
   1.189 -  return device;
   1.190 +    return device;
   1.191  }
   1.192  
   1.193  VideoBootStrap DirectFB_bootstrap = {
   1.194 -  "directfb", "DirectFB",
   1.195 -  DirectFB_Available, DirectFB_CreateDevice
   1.196 +    "directfb", "DirectFB",
   1.197 +    DirectFB_Available, DirectFB_CreateDevice
   1.198  };
   1.199  
   1.200 -static DFBSurfacePixelFormat GetFormatForBpp (int bpp, IDirectFBDisplayLayer *layer)
   1.201 +static DFBSurfacePixelFormat
   1.202 +GetFormatForBpp (int bpp, IDirectFBDisplayLayer * layer)
   1.203  {
   1.204 -  DFBDisplayLayerConfig dlc;
   1.205 -  int                   bytes = (bpp + 7) / 8;
   1.206 +    DFBDisplayLayerConfig dlc;
   1.207 +    int bytes = (bpp + 7) / 8;
   1.208  
   1.209 -  layer->GetConfiguration (layer, &dlc);
   1.210 -
   1.211 -  if (bytes == DFB_BYTES_PER_PIXEL(dlc.pixelformat) && bytes > 1)
   1.212 -    return dlc.pixelformat;
   1.213 +    layer->GetConfiguration (layer, &dlc);
   1.214  
   1.215 -  switch (bytes)
   1.216 -    {
   1.217 +    if (bytes == DFB_BYTES_PER_PIXEL (dlc.pixelformat) && bytes > 1)
   1.218 +        return dlc.pixelformat;
   1.219 +
   1.220 +    switch (bytes) {
   1.221      case 1:
   1.222 -      return DSPF_LUT8;
   1.223 +        return DSPF_LUT8;
   1.224      case 2:
   1.225 -      return DSPF_RGB16;
   1.226 +        return DSPF_RGB16;
   1.227      case 3:
   1.228 -      return DSPF_RGB24;
   1.229 +        return DSPF_RGB24;
   1.230      case 4:
   1.231 -      return DSPF_RGB32;
   1.232 +        return DSPF_RGB32;
   1.233      }
   1.234  
   1.235 -  return DSPF_UNKNOWN;
   1.236 +    return DSPF_UNKNOWN;
   1.237  }
   1.238  
   1.239 -static DFBEnumerationResult EnumModesCallback (int  width,
   1.240 -                                               int  height,
   1.241 -                                               int  bpp,
   1.242 -                                               void *data)
   1.243 +static DFBEnumerationResult
   1.244 +EnumModesCallback (int width, int height, int bpp, void *data)
   1.245  {
   1.246 -  SDL_VideoDevice *this = (SDL_VideoDevice *)data;
   1.247 -  struct DirectFBEnumRect *enumrect;
   1.248 +    SDL_VideoDevice *this = (SDL_VideoDevice *) data;
   1.249 +    struct DirectFBEnumRect *enumrect;
   1.250 +
   1.251 +    HIDDEN->nummodes++;
   1.252  
   1.253 -  HIDDEN->nummodes++;
   1.254 -
   1.255 -  if (enumlist && enumlist->r.w == width && enumlist->r.h == height)
   1.256 -    return DFENUM_OK;
   1.257 +    if (enumlist && enumlist->r.w == width && enumlist->r.h == height)
   1.258 +        return DFENUM_OK;
   1.259  
   1.260 -  enumrect = SDL_calloc(1, sizeof(struct DirectFBEnumRect));
   1.261 -  if (!enumrect)
   1.262 -    {
   1.263 -      SDL_OutOfMemory();
   1.264 -      return DFENUM_CANCEL;
   1.265 +    enumrect = SDL_calloc (1, sizeof (struct DirectFBEnumRect));
   1.266 +    if (!enumrect) {
   1.267 +        SDL_OutOfMemory ();
   1.268 +        return DFENUM_CANCEL;
   1.269      }
   1.270  
   1.271 -  enumrect->r.w  = (Uint16)width;
   1.272 -  enumrect->r.h  = (Uint16)height;
   1.273 -  enumrect->next = enumlist;
   1.274 +    enumrect->r.w = (Uint16) width;
   1.275 +    enumrect->r.h = (Uint16) height;
   1.276 +    enumrect->next = enumlist;
   1.277  
   1.278 -  enumlist = enumrect;
   1.279 +    enumlist = enumrect;
   1.280  
   1.281 -  return DFENUM_OK;
   1.282 +    return DFENUM_OK;
   1.283  }
   1.284  
   1.285 -struct private_hwdata {
   1.286 -  IDirectFBSurface *surface;
   1.287 -  IDirectFBPalette *palette;
   1.288 +struct private_hwdata
   1.289 +{
   1.290 +    IDirectFBSurface *surface;
   1.291 +    IDirectFBPalette *palette;
   1.292  };
   1.293  
   1.294 -void SetDirectFBerror (const char *function, DFBResult code)
   1.295 +void
   1.296 +SetDirectFBerror (const char *function, DFBResult code)
   1.297  {
   1.298 -  const char *error = DirectFBErrorString (code);
   1.299 +    const char *error = DirectFBErrorString (code);
   1.300  
   1.301 -  if (error)
   1.302 -    SDL_SetError("%s: %s", function, error);
   1.303 -  else
   1.304 -    SDL_SetError("Unknown error code from %s", function);
   1.305 +    if (error)
   1.306 +        SDL_SetError ("%s: %s", function, error);
   1.307 +    else
   1.308 +        SDL_SetError ("Unknown error code from %s", function);
   1.309  }
   1.310  
   1.311 -static DFBSurfacePixelFormat SDLToDFBPixelFormat (SDL_PixelFormat *format)
   1.312 +static DFBSurfacePixelFormat
   1.313 +SDLToDFBPixelFormat (SDL_PixelFormat * format)
   1.314  {
   1.315 -  if (format->Rmask && format->Gmask && format->Bmask)
   1.316 -    {
   1.317 -      switch (format->BitsPerPixel)
   1.318 -        {
   1.319 +    if (format->Rmask && format->Gmask && format->Bmask) {
   1.320 +        switch (format->BitsPerPixel) {
   1.321          case 8:
   1.322 -          return DSPF_LUT8;
   1.323 -          
   1.324 +            return DSPF_LUT8;
   1.325 +
   1.326          case 16:
   1.327 -          if (format->Rmask == 0xF800 &&
   1.328 -              format->Gmask == 0x07E0 &&
   1.329 -              format->Bmask == 0x001F)
   1.330 -            return DSPF_RGB16;
   1.331 -          /* fall through */
   1.332 -          
   1.333 +            if (format->Rmask == 0xF800 &&
   1.334 +                format->Gmask == 0x07E0 && format->Bmask == 0x001F)
   1.335 +                return DSPF_RGB16;
   1.336 +            /* fall through */
   1.337 +
   1.338          case 15:
   1.339 -          if (format->Rmask == 0x7C00 &&
   1.340 -              format->Gmask == 0x03E0 &&
   1.341 -              format->Bmask == 0x001F)
   1.342 -            return DSPF_ARGB1555;
   1.343 -          break;
   1.344 -          
   1.345 +            if (format->Rmask == 0x7C00 &&
   1.346 +                format->Gmask == 0x03E0 && format->Bmask == 0x001F)
   1.347 +                return DSPF_ARGB1555;
   1.348 +            break;
   1.349 +
   1.350          case 24:
   1.351 -          if (format->Rmask == 0xFF0000 &&
   1.352 -              format->Gmask == 0x00FF00 &&
   1.353 -              format->Bmask == 0x0000FF)
   1.354 -            return DSPF_RGB24;
   1.355 -          break;
   1.356 +            if (format->Rmask == 0xFF0000 &&
   1.357 +                format->Gmask == 0x00FF00 && format->Bmask == 0x0000FF)
   1.358 +                return DSPF_RGB24;
   1.359 +            break;
   1.360  
   1.361          case 32:
   1.362 -          if (format->Rmask == 0xFF0000 &&
   1.363 -              format->Gmask == 0x00FF00 &&
   1.364 -              format->Bmask == 0x0000FF)
   1.365 -            {
   1.366 -              if (format->Amask == 0xFF000000)
   1.367 -                return DSPF_ARGB;
   1.368 -              else
   1.369 -                return DSPF_RGB32;
   1.370 +            if (format->Rmask == 0xFF0000 &&
   1.371 +                format->Gmask == 0x00FF00 && format->Bmask == 0x0000FF) {
   1.372 +                if (format->Amask == 0xFF000000)
   1.373 +                    return DSPF_ARGB;
   1.374 +                else
   1.375 +                    return DSPF_RGB32;
   1.376              }
   1.377 -          break;
   1.378 +            break;
   1.379 +        }
   1.380 +    } else {
   1.381 +        switch (format->BitsPerPixel) {
   1.382 +        case 8:
   1.383 +            return DSPF_LUT8;
   1.384 +        case 15:
   1.385 +            return DSPF_ARGB1555;
   1.386 +        case 16:
   1.387 +            return DSPF_RGB16;
   1.388 +        case 24:
   1.389 +            return DSPF_RGB24;
   1.390 +        case 32:
   1.391 +            return DSPF_RGB32;
   1.392          }
   1.393      }
   1.394 -  else
   1.395 -    {
   1.396 -      switch (format->BitsPerPixel)
   1.397 -	{
   1.398 -        case 8:
   1.399 -          return DSPF_LUT8;
   1.400 -	case 15:
   1.401 -	  return DSPF_ARGB1555;
   1.402 -	case 16:
   1.403 -	  return DSPF_RGB16;
   1.404 -	case 24:
   1.405 -	  return DSPF_RGB24;
   1.406 -	case 32:
   1.407 -	  return DSPF_RGB32;
   1.408 -	}
   1.409 +
   1.410 +    return DSPF_UNKNOWN;
   1.411 +}
   1.412 +
   1.413 +static SDL_Palette *
   1.414 +AllocatePalette (int size)
   1.415 +{
   1.416 +    SDL_Palette *palette;
   1.417 +    SDL_Color *colors;
   1.418 +
   1.419 +    palette = SDL_calloc (1, sizeof (SDL_Palette));
   1.420 +    if (!palette) {
   1.421 +        SDL_OutOfMemory ();
   1.422 +        return NULL;
   1.423      }
   1.424  
   1.425 -  return DSPF_UNKNOWN;
   1.426 -}
   1.427 -
   1.428 -static SDL_Palette *AllocatePalette(int size)
   1.429 -{
   1.430 -  SDL_Palette *palette;
   1.431 -  SDL_Color   *colors;
   1.432 -
   1.433 -  palette = SDL_calloc (1, sizeof(SDL_Palette));
   1.434 -  if (!palette)
   1.435 -    {
   1.436 -      SDL_OutOfMemory();
   1.437 -      return NULL;
   1.438 -    }
   1.439 -
   1.440 -  colors = SDL_calloc (size, sizeof(SDL_Color));
   1.441 -  if (!colors)
   1.442 -    {
   1.443 -      SDL_OutOfMemory();
   1.444 -      return NULL;
   1.445 +    colors = SDL_calloc (size, sizeof (SDL_Color));
   1.446 +    if (!colors) {
   1.447 +        SDL_OutOfMemory ();
   1.448 +        return NULL;
   1.449      }
   1.450  
   1.451 -  palette->ncolors = size;
   1.452 -  palette->colors  = colors;
   1.453 +    palette->ncolors = size;
   1.454 +    palette->colors = colors;
   1.455  
   1.456 -  return palette;
   1.457 +    return palette;
   1.458  }
   1.459  
   1.460 -static int DFBToSDLPixelFormat (DFBSurfacePixelFormat pixelformat, SDL_PixelFormat *format)
   1.461 +static int
   1.462 +DFBToSDLPixelFormat (DFBSurfacePixelFormat pixelformat,
   1.463 +                     SDL_PixelFormat * format)
   1.464  {
   1.465 -  format->Amask = format->Rmask = format->Gmask = format->Bmask = 0;
   1.466 -  format->BitsPerPixel = format->BytesPerPixel = 0;
   1.467 +    format->Amask = format->Rmask = format->Gmask = format->Bmask = 0;
   1.468 +    format->BitsPerPixel = format->BytesPerPixel = 0;
   1.469  
   1.470 -  switch (pixelformat)
   1.471 -    {
   1.472 +    switch (pixelformat) {
   1.473      case DSPF_A8:
   1.474 -      format->Amask = 0x000000FF;
   1.475 -      break;
   1.476 +        format->Amask = 0x000000FF;
   1.477 +        break;
   1.478  
   1.479      case DSPF_ARGB1555:
   1.480 -      format->Rmask = 0x00007C00;
   1.481 -      format->Gmask = 0x000003E0;
   1.482 -      format->Bmask = 0x0000001F;
   1.483 -      break;
   1.484 +        format->Rmask = 0x00007C00;
   1.485 +        format->Gmask = 0x000003E0;
   1.486 +        format->Bmask = 0x0000001F;
   1.487 +        break;
   1.488  
   1.489      case DSPF_RGB16:
   1.490 -      format->Rmask = 0x0000F800;
   1.491 -      format->Gmask = 0x000007E0;
   1.492 -      format->Bmask = 0x0000001F;
   1.493 -      break;
   1.494 +        format->Rmask = 0x0000F800;
   1.495 +        format->Gmask = 0x000007E0;
   1.496 +        format->Bmask = 0x0000001F;
   1.497 +        break;
   1.498  
   1.499      case DSPF_ARGB:
   1.500 -      format->Amask = 0; /* apps don't seem to like that:  0xFF000000; */
   1.501 -      /* fall through */
   1.502 +        format->Amask = 0;      /* apps don't seem to like that:  0xFF000000; */
   1.503 +        /* fall through */
   1.504      case DSPF_RGB24:
   1.505      case DSPF_RGB32:
   1.506 -      format->Rmask = 0x00FF0000;
   1.507 -      format->Gmask = 0x0000FF00;
   1.508 -      format->Bmask = 0x000000FF;
   1.509 -      break;
   1.510 +        format->Rmask = 0x00FF0000;
   1.511 +        format->Gmask = 0x0000FF00;
   1.512 +        format->Bmask = 0x000000FF;
   1.513 +        break;
   1.514  
   1.515      case DSPF_LUT8:
   1.516 -      format->Rmask = 0x000000FF;
   1.517 -      format->Gmask = 0x000000FF;
   1.518 -      format->Bmask = 0x000000FF;
   1.519 +        format->Rmask = 0x000000FF;
   1.520 +        format->Gmask = 0x000000FF;
   1.521 +        format->Bmask = 0x000000FF;
   1.522  
   1.523 -      if (!format->palette)
   1.524 -        format->palette = AllocatePalette(256);
   1.525 -      break;
   1.526 +        if (!format->palette)
   1.527 +            format->palette = AllocatePalette (256);
   1.528 +        break;
   1.529  
   1.530      default:
   1.531 -      fprintf (stderr, "SDL_DirectFB: Unsupported pixelformat (0x%08x)!\n", pixelformat);
   1.532 -      return -1;
   1.533 +        fprintf (stderr,
   1.534 +                 "SDL_DirectFB: Unsupported pixelformat (0x%08x)!\n",
   1.535 +                 pixelformat);
   1.536 +        return -1;
   1.537      }
   1.538  
   1.539 -  format->BitsPerPixel  = DFB_BYTES_PER_PIXEL(pixelformat) * 8;
   1.540 -  format->BytesPerPixel = DFB_BYTES_PER_PIXEL(pixelformat);
   1.541 +    format->BitsPerPixel = DFB_BYTES_PER_PIXEL (pixelformat) * 8;
   1.542 +    format->BytesPerPixel = DFB_BYTES_PER_PIXEL (pixelformat);
   1.543  
   1.544 -  return 0;
   1.545 +    return 0;
   1.546  }
   1.547  
   1.548  
   1.549 -int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat)
   1.550 +int
   1.551 +DirectFB_VideoInit (_THIS, SDL_PixelFormat * vformat)
   1.552  {
   1.553 -  int                      i;
   1.554 -  DFBResult                ret;
   1.555 +    int i;
   1.556 +    DFBResult ret;
   1.557  #if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
   1.558 -  DFBCardCapabilities      caps;
   1.559 +    DFBCardCapabilities caps;
   1.560  #else
   1.561 -  DFBGraphicsDeviceDescription caps;
   1.562 +    DFBGraphicsDeviceDescription caps;
   1.563  #endif
   1.564 -  DFBDisplayLayerConfig    dlc;
   1.565 -  struct DirectFBEnumRect *rect;
   1.566 -  IDirectFB               *dfb    = NULL;
   1.567 -  IDirectFBDisplayLayer   *layer  = NULL;
   1.568 -  IDirectFBEventBuffer    *events = NULL;
   1.569 +    DFBDisplayLayerConfig dlc;
   1.570 +    struct DirectFBEnumRect *rect;
   1.571 +    IDirectFB *dfb = NULL;
   1.572 +    IDirectFBDisplayLayer *layer = NULL;
   1.573 +    IDirectFBEventBuffer *events = NULL;
   1.574  
   1.575 -  HIDDEN->c2layer = NULL, HIDDEN->c2frame = NULL;
   1.576 -  HIDDEN->enable_mga_crtc2 = 0;
   1.577 -  HIDDEN->mga_crtc2_stretch_overscan = 1;
   1.578 +    HIDDEN->c2layer = NULL, HIDDEN->c2frame = NULL;
   1.579 +    HIDDEN->enable_mga_crtc2 = 0;
   1.580 +    HIDDEN->mga_crtc2_stretch_overscan = 1;
   1.581  
   1.582 -  ret = DirectFBInit (NULL, NULL);
   1.583 -  if (ret)
   1.584 -    {
   1.585 -      SetDirectFBerror ("DirectFBInit", ret);
   1.586 -      goto error;
   1.587 +    ret = DirectFBInit (NULL, NULL);
   1.588 +    if (ret) {
   1.589 +        SetDirectFBerror ("DirectFBInit", ret);
   1.590 +        goto error;
   1.591      }
   1.592  
   1.593 -  ret = DirectFBCreate (&dfb);
   1.594 -  if (ret)
   1.595 -    {
   1.596 -      SetDirectFBerror ("DirectFBCreate", ret);
   1.597 -      goto error;
   1.598 +    ret = DirectFBCreate (&dfb);
   1.599 +    if (ret) {
   1.600 +        SetDirectFBerror ("DirectFBCreate", ret);
   1.601 +        goto error;
   1.602 +    }
   1.603 +
   1.604 +    ret = dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer);
   1.605 +    if (ret) {
   1.606 +        SetDirectFBerror ("dfb->GetDisplayLayer", ret);
   1.607 +        goto error;
   1.608      }
   1.609  
   1.610 -  ret = dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer);
   1.611 -  if (ret)
   1.612 -    {
   1.613 -      SetDirectFBerror ("dfb->GetDisplayLayer", ret);
   1.614 -      goto error;
   1.615 +    ret = dfb->CreateInputEventBuffer (dfb, DICAPS_ALL, DFB_FALSE, &events);
   1.616 +    if (ret) {
   1.617 +        SetDirectFBerror ("dfb->CreateEventBuffer", ret);
   1.618 +        goto error;
   1.619 +    }
   1.620 +
   1.621 +    layer->EnableCursor (layer, 1);
   1.622 +
   1.623 +    /* Query layer configuration to determine the current mode and pixelformat */
   1.624 +    layer->GetConfiguration (layer, &dlc);
   1.625 +
   1.626 +    /* If current format is not supported use LUT8 as the default */
   1.627 +    if (DFBToSDLPixelFormat (dlc.pixelformat, vformat))
   1.628 +        DFBToSDLPixelFormat (DSPF_LUT8, vformat);
   1.629 +
   1.630 +    /* Enumerate the available fullscreen modes */
   1.631 +    ret = dfb->EnumVideoModes (dfb, EnumModesCallback, this);
   1.632 +    if (ret) {
   1.633 +        SetDirectFBerror ("dfb->EnumVideoModes", ret);
   1.634 +        goto error;
   1.635      }
   1.636  
   1.637 -  ret = dfb->CreateInputEventBuffer (dfb, DICAPS_ALL, DFB_FALSE, &events);
   1.638 -  if (ret)
   1.639 -    {
   1.640 -      SetDirectFBerror ("dfb->CreateEventBuffer", ret);
   1.641 -      goto error;
   1.642 -    }
   1.643 -  
   1.644 -  layer->EnableCursor (layer, 1);
   1.645 -
   1.646 -  /* Query layer configuration to determine the current mode and pixelformat */
   1.647 -  layer->GetConfiguration (layer, &dlc);
   1.648 -
   1.649 -  /* If current format is not supported use LUT8 as the default */
   1.650 -  if (DFBToSDLPixelFormat (dlc.pixelformat, vformat))
   1.651 -    DFBToSDLPixelFormat (DSPF_LUT8, vformat);
   1.652 -
   1.653 -  /* Enumerate the available fullscreen modes */
   1.654 -  ret = dfb->EnumVideoModes (dfb, EnumModesCallback, this);
   1.655 -  if (ret)
   1.656 -    {
   1.657 -      SetDirectFBerror ("dfb->EnumVideoModes", ret);
   1.658 -      goto error;
   1.659 +    HIDDEN->modelist = SDL_calloc (HIDDEN->nummodes + 1, sizeof (SDL_Rect *));
   1.660 +    if (!HIDDEN->modelist) {
   1.661 +        SDL_OutOfMemory ();
   1.662 +        goto error;
   1.663      }
   1.664  
   1.665 -  HIDDEN->modelist = SDL_calloc (HIDDEN->nummodes + 1, sizeof(SDL_Rect *));
   1.666 -  if (!HIDDEN->modelist)
   1.667 -    {
   1.668 -      SDL_OutOfMemory();
   1.669 -      goto error;
   1.670 +    for (i = 0, rect = enumlist; rect; ++i, rect = rect->next) {
   1.671 +        HIDDEN->modelist[i] = &rect->r;
   1.672      }
   1.673  
   1.674 -  for (i = 0, rect = enumlist; rect; ++i, rect = rect->next )
   1.675 -    {
   1.676 -      HIDDEN->modelist[i] = &rect->r;
   1.677 -    }
   1.678 -
   1.679 -  HIDDEN->modelist[i] = NULL;
   1.680 +    HIDDEN->modelist[i] = NULL;
   1.681  
   1.682  
   1.683 -  /* Query card capabilities to get the video memory size */
   1.684 +    /* Query card capabilities to get the video memory size */
   1.685  #if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
   1.686 -  dfb->GetCardCapabilities (dfb, &caps);
   1.687 +    dfb->GetCardCapabilities (dfb, &caps);
   1.688  #else
   1.689 -  dfb->GetDeviceDescription (dfb, &caps);
   1.690 +    dfb->GetDeviceDescription (dfb, &caps);
   1.691  #endif
   1.692  
   1.693 -  this->info.wm_available = 1;
   1.694 -  this->info.hw_available = 1;
   1.695 -  this->info.blit_hw      = 1;
   1.696 -  this->info.blit_hw_CC   = 1;
   1.697 -  this->info.blit_hw_A    = 1;
   1.698 -  this->info.blit_fill    = 1;
   1.699 -  this->info.video_mem    = caps.video_memory / 1024;
   1.700 -
   1.701 -  HIDDEN->initialized = 1;
   1.702 -  HIDDEN->dfb         = dfb;
   1.703 -  HIDDEN->layer       = layer;
   1.704 -  HIDDEN->eventbuffer = events;
   1.705 +    this->info.wm_available = 1;
   1.706 +    this->info.hw_available = 1;
   1.707 +    this->info.blit_hw = 1;
   1.708 +    this->info.blit_hw_CC = 1;
   1.709 +    this->info.blit_hw_A = 1;
   1.710 +    this->info.blit_fill = 1;
   1.711 +    this->info.video_mem = caps.video_memory / 1024;
   1.712  
   1.713 -  if (SDL_getenv("SDL_DIRECTFB_MGA_CRTC2") != NULL)
   1.714 -    HIDDEN->enable_mga_crtc2 = 1;
   1.715 -  
   1.716 -  if (HIDDEN->enable_mga_crtc2)
   1.717 -    {
   1.718 -      DFBDisplayLayerConfig      dlc;
   1.719 -      DFBDisplayLayerConfigFlags failed;
   1.720 +    HIDDEN->initialized = 1;
   1.721 +    HIDDEN->dfb = dfb;
   1.722 +    HIDDEN->layer = layer;
   1.723 +    HIDDEN->eventbuffer = events;
   1.724 +
   1.725 +    if (SDL_getenv ("SDL_DIRECTFB_MGA_CRTC2") != NULL)
   1.726 +        HIDDEN->enable_mga_crtc2 = 1;
   1.727  
   1.728 -      ret = dfb->GetDisplayLayer (dfb, 2, &HIDDEN->c2layer);
   1.729 -      if (ret)
   1.730 -        {
   1.731 -          SetDirectFBerror ("dfb->GetDisplayLayer(CRTC2)", ret);
   1.732 -          goto error;
   1.733 +    if (HIDDEN->enable_mga_crtc2) {
   1.734 +        DFBDisplayLayerConfig dlc;
   1.735 +        DFBDisplayLayerConfigFlags failed;
   1.736 +
   1.737 +        ret = dfb->GetDisplayLayer (dfb, 2, &HIDDEN->c2layer);
   1.738 +        if (ret) {
   1.739 +            SetDirectFBerror ("dfb->GetDisplayLayer(CRTC2)", ret);
   1.740 +            goto error;
   1.741          }
   1.742  
   1.743 -      ret = HIDDEN->layer->SetCooperativeLevel(HIDDEN->layer, DLSCL_EXCLUSIVE);
   1.744 -      if (ret)
   1.745 -        {
   1.746 -          SetDirectFBerror ("layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
   1.747 -          goto error;
   1.748 +        ret =
   1.749 +            HIDDEN->layer->SetCooperativeLevel (HIDDEN->layer,
   1.750 +                                                DLSCL_EXCLUSIVE);
   1.751 +        if (ret) {
   1.752 +            SetDirectFBerror
   1.753 +                ("layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
   1.754 +            goto error;
   1.755          }
   1.756 - 
   1.757 -      ret = HIDDEN->c2layer->SetCooperativeLevel(HIDDEN->c2layer, DLSCL_EXCLUSIVE);
   1.758 -      if (ret)
   1.759 -        {
   1.760 -          SetDirectFBerror ("c2layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
   1.761 -          goto error;
   1.762 +
   1.763 +        ret =
   1.764 +            HIDDEN->c2layer->SetCooperativeLevel (HIDDEN->c2layer,
   1.765 +                                                  DLSCL_EXCLUSIVE);
   1.766 +        if (ret) {
   1.767 +            SetDirectFBerror
   1.768 +                ("c2layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
   1.769 +            goto error;
   1.770          }
   1.771  
   1.772 -      HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0x0);
   1.773 +        HIDDEN->c2layer->SetOpacity (HIDDEN->c2layer, 0x0);
   1.774 +
   1.775 +        /* Init the surface here as it got a fixed size */
   1.776 +        dlc.flags = DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE;
   1.777 +        dlc.buffermode = DLBM_BACKVIDEO;
   1.778 +        dlc.pixelformat = DSPF_RGB32;
   1.779  
   1.780 -      /* Init the surface here as it got a fixed size */
   1.781 -      dlc.flags      = DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE;
   1.782 -      dlc.buffermode = DLBM_BACKVIDEO;
   1.783 -      dlc.pixelformat = DSPF_RGB32;
   1.784 -      
   1.785 -      ret = HIDDEN->c2layer->TestConfiguration( HIDDEN->c2layer, &dlc, &failed );
   1.786 -      if (ret)
   1.787 -        {
   1.788 -          SetDirectFBerror ("c2layer->TestConfiguration", ret);
   1.789 -          goto error;
   1.790 +        ret =
   1.791 +            HIDDEN->c2layer->TestConfiguration (HIDDEN->c2layer, &dlc,
   1.792 +                                                &failed);
   1.793 +        if (ret) {
   1.794 +            SetDirectFBerror ("c2layer->TestConfiguration", ret);
   1.795 +            goto error;
   1.796          }
   1.797 -    
   1.798 -      ret = HIDDEN->c2layer->SetConfiguration( HIDDEN->c2layer, &dlc );
   1.799 -      if (ret)
   1.800 -        {
   1.801 -          SetDirectFBerror ("c2layer->SetConfiguration", ret);
   1.802 -          goto error;
   1.803 +
   1.804 +        ret = HIDDEN->c2layer->SetConfiguration (HIDDEN->c2layer, &dlc);
   1.805 +        if (ret) {
   1.806 +            SetDirectFBerror ("c2layer->SetConfiguration", ret);
   1.807 +            goto error;
   1.808          }
   1.809 -    
   1.810 -      ret = HIDDEN->c2layer->GetSurface( HIDDEN->c2layer, &HIDDEN->c2frame );
   1.811 -      if (ret)
   1.812 -        {
   1.813 -          SetDirectFBerror ("c2layer->GetSurface", ret);
   1.814 -          goto error;
   1.815 +
   1.816 +        ret = HIDDEN->c2layer->GetSurface (HIDDEN->c2layer, &HIDDEN->c2frame);
   1.817 +        if (ret) {
   1.818 +            SetDirectFBerror ("c2layer->GetSurface", ret);
   1.819 +            goto error;
   1.820          }
   1.821  
   1.822 -      HIDDEN->c2framesize.x = 0;
   1.823 -      HIDDEN->c2framesize.y = 0;
   1.824 -      HIDDEN->c2frame->GetSize( HIDDEN->c2frame, &HIDDEN->c2framesize.w, &HIDDEN->c2framesize.h);
   1.825 +        HIDDEN->c2framesize.x = 0;
   1.826 +        HIDDEN->c2framesize.y = 0;
   1.827 +        HIDDEN->c2frame->GetSize (HIDDEN->c2frame, &HIDDEN->c2framesize.w,
   1.828 +                                  &HIDDEN->c2framesize.h);
   1.829  
   1.830 -      HIDDEN->c2frame->SetBlittingFlags( HIDDEN->c2frame, DSBLIT_NOFX );
   1.831 -      HIDDEN->c2frame->SetColor( HIDDEN->c2frame, 0, 0, 0, 0xff );
   1.832 -    
   1.833 -      /* Clear CRTC2 */
   1.834 -      HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff );
   1.835 -      HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0 );
   1.836 -      HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff );
   1.837 -      HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0 );
   1.838 -      HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff );
   1.839 +        HIDDEN->c2frame->SetBlittingFlags (HIDDEN->c2frame, DSBLIT_NOFX);
   1.840 +        HIDDEN->c2frame->SetColor (HIDDEN->c2frame, 0, 0, 0, 0xff);
   1.841 +
   1.842 +        /* Clear CRTC2 */
   1.843 +        HIDDEN->c2frame->Clear (HIDDEN->c2frame, 0, 0, 0, 0xff);
   1.844 +        HIDDEN->c2frame->Flip (HIDDEN->c2frame, NULL, 0);
   1.845 +        HIDDEN->c2frame->Clear (HIDDEN->c2frame, 0, 0, 0, 0xff);
   1.846 +        HIDDEN->c2frame->Flip (HIDDEN->c2frame, NULL, 0);
   1.847 +        HIDDEN->c2frame->Clear (HIDDEN->c2frame, 0, 0, 0, 0xff);
   1.848  
   1.849 -      HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0xFF );
   1.850 -    
   1.851 -      /* Check if overscan is possibly set */
   1.852 -      if (SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN") != NULL)
   1.853 -        {
   1.854 -	    float overscan = 0;
   1.855 -	    if (SDL_sscanf(SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN"), "%f", &overscan) == 1)
   1.856 -               if (overscan > 0 && overscan < 2)
   1.857 -		  HIDDEN->mga_crtc2_stretch_overscan = overscan;
   1.858 -	}
   1.859 +        HIDDEN->c2layer->SetOpacity (HIDDEN->c2layer, 0xFF);
   1.860  
   1.861 -      #ifdef DIRECTFB_CRTC2_DEBUG
   1.862 -      printf("CRTC2 overscan: %f\n", HIDDEN->mga_crtc2_stretch_overscan);
   1.863 -      #endif
   1.864 +        /* Check if overscan is possibly set */
   1.865 +        if (SDL_getenv ("SDL_DIRECTFB_MGA_OVERSCAN") != NULL) {
   1.866 +            float overscan = 0;
   1.867 +            if (SDL_sscanf
   1.868 +                (SDL_getenv ("SDL_DIRECTFB_MGA_OVERSCAN"), "%f",
   1.869 +                 &overscan) == 1)
   1.870 +                if (overscan > 0 && overscan < 2)
   1.871 +                    HIDDEN->mga_crtc2_stretch_overscan = overscan;
   1.872 +        }
   1.873 +#ifdef DIRECTFB_CRTC2_DEBUG
   1.874 +        printf ("CRTC2 overscan: %f\n", HIDDEN->mga_crtc2_stretch_overscan);
   1.875 +#endif
   1.876      }
   1.877  
   1.878 -  return 0;
   1.879 +    return 0;
   1.880  
   1.881 - error:
   1.882 -  if (events)
   1.883 -    events->Release (events);
   1.884 -  
   1.885 -  if (HIDDEN->c2frame)
   1.886 -    HIDDEN->c2frame->Release (HIDDEN->c2frame);
   1.887 +  error:
   1.888 +    if (events)
   1.889 +        events->Release (events);
   1.890 +
   1.891 +    if (HIDDEN->c2frame)
   1.892 +        HIDDEN->c2frame->Release (HIDDEN->c2frame);
   1.893  
   1.894 -  if (HIDDEN->c2layer)
   1.895 -    HIDDEN->c2layer->Release (HIDDEN->c2layer);
   1.896 +    if (HIDDEN->c2layer)
   1.897 +        HIDDEN->c2layer->Release (HIDDEN->c2layer);
   1.898  
   1.899 -  if (layer)
   1.900 -    layer->Release (layer);
   1.901 +    if (layer)
   1.902 +        layer->Release (layer);
   1.903  
   1.904 -  if (dfb)
   1.905 -    dfb->Release (dfb);
   1.906 +    if (dfb)
   1.907 +        dfb->Release (dfb);
   1.908  
   1.909 -  return -1;
   1.910 +    return -1;
   1.911  }
   1.912  
   1.913 -static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
   1.914 +static SDL_Rect **
   1.915 +DirectFB_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags)
   1.916  {
   1.917 -  if (flags & SDL_FULLSCREEN)
   1.918 -    return HIDDEN->modelist;
   1.919 -  else
   1.920 -    if (SDLToDFBPixelFormat (format) != DSPF_UNKNOWN)
   1.921 -      return (SDL_Rect**) -1;
   1.922 +    if (flags & SDL_FULLSCREEN)
   1.923 +        return HIDDEN->modelist;
   1.924 +    else if (SDLToDFBPixelFormat (format) != DSPF_UNKNOWN)
   1.925 +        return (SDL_Rect **) - 1;
   1.926  
   1.927 -  return NULL;
   1.928 +    return NULL;
   1.929  }
   1.930  
   1.931 -static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
   1.932 +static SDL_Surface *
   1.933 +DirectFB_SetVideoMode (_THIS, SDL_Surface * current, int width, int height,
   1.934 +                       int bpp, Uint32 flags)
   1.935  {
   1.936 -  DFBResult              ret;
   1.937 -  DFBSurfaceDescription  dsc;
   1.938 -  DFBSurfacePixelFormat  pixelformat;
   1.939 -  IDirectFBSurface      *surface;
   1.940 +    DFBResult ret;
   1.941 +    DFBSurfaceDescription dsc;
   1.942 +    DFBSurfacePixelFormat pixelformat;
   1.943 +    IDirectFBSurface *surface;
   1.944  
   1.945 -  fprintf (stderr, "SDL DirectFB_SetVideoMode: %dx%d@%d, flags: 0x%08x\n",
   1.946 -           width, height, bpp, flags);
   1.947 +    fprintf (stderr, "SDL DirectFB_SetVideoMode: %dx%d@%d, flags: 0x%08x\n",
   1.948 +             width, height, bpp, flags);
   1.949  
   1.950 -  flags |= SDL_FULLSCREEN;
   1.951 +    flags |= SDL_FULLSCREEN;
   1.952  
   1.953 -  /* Release previous primary surface */
   1.954 -  if (current->hwdata && current->hwdata->surface)
   1.955 -    {
   1.956 -      current->hwdata->surface->Release (current->hwdata->surface);
   1.957 -      current->hwdata->surface = NULL;
   1.958 +    /* Release previous primary surface */
   1.959 +    if (current->hwdata && current->hwdata->surface) {
   1.960 +        current->hwdata->surface->Release (current->hwdata->surface);
   1.961 +        current->hwdata->surface = NULL;
   1.962  
   1.963 -      /* And its palette if present */
   1.964 -      if (current->hwdata->palette)
   1.965 -        {
   1.966 -          current->hwdata->palette->Release (current->hwdata->palette);
   1.967 -          current->hwdata->palette = NULL;
   1.968 +        /* And its palette if present */
   1.969 +        if (current->hwdata->palette) {
   1.970 +            current->hwdata->palette->Release (current->hwdata->palette);
   1.971 +            current->hwdata->palette = NULL;
   1.972 +        }
   1.973 +    } else if (!current->hwdata) {
   1.974 +        /* Allocate the hardware acceleration data */
   1.975 +        current->hwdata =
   1.976 +            (struct private_hwdata *) SDL_calloc (1,
   1.977 +                                                  sizeof (*current->hwdata));
   1.978 +        if (!current->hwdata) {
   1.979 +            SDL_OutOfMemory ();
   1.980 +            return NULL;
   1.981          }
   1.982      }
   1.983 -  else if (!current->hwdata)
   1.984 -    {
   1.985 -      /* Allocate the hardware acceleration data */
   1.986 -      current->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*current->hwdata));
   1.987 -      if (!current->hwdata)
   1.988 -        {
   1.989 -          SDL_OutOfMemory();
   1.990 -          return NULL;
   1.991 -	}
   1.992 -    }
   1.993  
   1.994 -  /* Set cooperative level depending on flag SDL_FULLSCREEN */
   1.995 -  if (flags & SDL_FULLSCREEN)
   1.996 -    {
   1.997 -      ret = HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_FULLSCREEN);
   1.998 -      if (ret && !HIDDEN->enable_mga_crtc2)
   1.999 -        {
  1.1000 -          DirectFBError ("dfb->SetCooperativeLevel", ret);
  1.1001 -          flags &= ~SDL_FULLSCREEN;
  1.1002 +    /* Set cooperative level depending on flag SDL_FULLSCREEN */
  1.1003 +    if (flags & SDL_FULLSCREEN) {
  1.1004 +        ret =
  1.1005 +            HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_FULLSCREEN);
  1.1006 +        if (ret && !HIDDEN->enable_mga_crtc2) {
  1.1007 +            DirectFBError ("dfb->SetCooperativeLevel", ret);
  1.1008 +            flags &= ~SDL_FULLSCREEN;
  1.1009          }
  1.1010 -    }
  1.1011 -  else
  1.1012 -    HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL);
  1.1013 +    } else
  1.1014 +        HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL);
  1.1015  
  1.1016 -  /* Set video mode */
  1.1017 -  ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp);
  1.1018 -  if (ret)
  1.1019 -    {
  1.1020 -      if (flags & SDL_FULLSCREEN)
  1.1021 -        {
  1.1022 -          flags &= ~SDL_FULLSCREEN;
  1.1023 -          HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL);
  1.1024 -          ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp);
  1.1025 +    /* Set video mode */
  1.1026 +    ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp);
  1.1027 +    if (ret) {
  1.1028 +        if (flags & SDL_FULLSCREEN) {
  1.1029 +            flags &= ~SDL_FULLSCREEN;
  1.1030 +            HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL);
  1.1031 +            ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp);
  1.1032          }
  1.1033  
  1.1034 -      if (ret)
  1.1035 -        {
  1.1036 -          SetDirectFBerror ("dfb->SetVideoMode", ret);
  1.1037 -          return NULL;
  1.1038 +        if (ret) {
  1.1039 +            SetDirectFBerror ("dfb->SetVideoMode", ret);
  1.1040 +            return NULL;
  1.1041          }
  1.1042      }
  1.1043  
  1.1044 -  /* Create primary surface */
  1.1045 -  dsc.flags       = DSDESC_CAPS | DSDESC_PIXELFORMAT;
  1.1046 -  dsc.caps        = DSCAPS_PRIMARY | ((flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0);
  1.1047 -  dsc.pixelformat = GetFormatForBpp (bpp, HIDDEN->layer);
  1.1048 +    /* Create primary surface */
  1.1049 +    dsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT;
  1.1050 +    dsc.caps =
  1.1051 +        DSCAPS_PRIMARY | ((flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0);
  1.1052 +    dsc.pixelformat = GetFormatForBpp (bpp, HIDDEN->layer);
  1.1053  
  1.1054 -  ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface);
  1.1055 -  if (ret && (flags & SDL_DOUBLEBUF))
  1.1056 -    {
  1.1057 -      /* Try without double buffering */
  1.1058 -      dsc.caps &= ~DSCAPS_FLIPPING;
  1.1059 -      ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface);
  1.1060 +    ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface);
  1.1061 +    if (ret && (flags & SDL_DOUBLEBUF)) {
  1.1062 +        /* Try without double buffering */
  1.1063 +        dsc.caps &= ~DSCAPS_FLIPPING;
  1.1064 +        ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface);
  1.1065      }
  1.1066 -  if (ret)
  1.1067 -    {
  1.1068 -      SetDirectFBerror ("dfb->CreateSurface", ret);
  1.1069 -      return NULL;
  1.1070 +    if (ret) {
  1.1071 +        SetDirectFBerror ("dfb->CreateSurface", ret);
  1.1072 +        return NULL;
  1.1073      }
  1.1074  
  1.1075 -  current->w     = width;
  1.1076 -  current->h     = height;
  1.1077 -  current->flags = SDL_HWSURFACE | SDL_PREALLOC;
  1.1078 +    current->w = width;
  1.1079 +    current->h = height;
  1.1080 +    current->flags = SDL_HWSURFACE | SDL_PREALLOC;
  1.1081  
  1.1082 -  if (flags & SDL_FULLSCREEN)
  1.1083 -    {
  1.1084 -      current->flags |= SDL_FULLSCREEN;
  1.1085 -      this->UpdateRects = DirectFB_DirectUpdate;
  1.1086 -    }
  1.1087 -  else
  1.1088 -    this->UpdateRects = DirectFB_WindowedUpdate;
  1.1089 +    if (flags & SDL_FULLSCREEN) {
  1.1090 +        current->flags |= SDL_FULLSCREEN;
  1.1091 +        this->UpdateRects = DirectFB_DirectUpdate;
  1.1092 +    } else
  1.1093 +        this->UpdateRects = DirectFB_WindowedUpdate;
  1.1094  
  1.1095 -  if (dsc.caps & DSCAPS_FLIPPING)
  1.1096 -    current->flags |= SDL_DOUBLEBUF;
  1.1097 +    if (dsc.caps & DSCAPS_FLIPPING)
  1.1098 +        current->flags |= SDL_DOUBLEBUF;
  1.1099  
  1.1100 -  surface->GetPixelFormat (surface, &pixelformat);
  1.1101 -
  1.1102 -  DFBToSDLPixelFormat (pixelformat, current->format);
  1.1103 +    surface->GetPixelFormat (surface, &pixelformat);
  1.1104  
  1.1105 -  /* Get the surface palette (if supported) */
  1.1106 -  if (DFB_PIXELFORMAT_IS_INDEXED( pixelformat ))
  1.1107 -    {
  1.1108 -      surface->GetPalette (surface, &current->hwdata->palette);
  1.1109 +    DFBToSDLPixelFormat (pixelformat, current->format);
  1.1110  
  1.1111 -      current->flags |= SDL_HWPALETTE;
  1.1112 +    /* Get the surface palette (if supported) */
  1.1113 +    if (DFB_PIXELFORMAT_IS_INDEXED (pixelformat)) {
  1.1114 +        surface->GetPalette (surface, &current->hwdata->palette);
  1.1115 +
  1.1116 +        current->flags |= SDL_HWPALETTE;
  1.1117      }
  1.1118  
  1.1119 -  current->hwdata->surface = surface;
  1.1120 +    current->hwdata->surface = surface;
  1.1121  
  1.1122 -  /* MGA CRTC2 stuff */
  1.1123 -  if (HIDDEN->enable_mga_crtc2)
  1.1124 -    {
  1.1125 -      /* no stretching if c2ssize == c2framesize */
  1.1126 -      HIDDEN->c2ssize.x = 0, HIDDEN->c2ssize.y = 0;
  1.1127 -      HIDDEN->c2ssize.w = width;
  1.1128 -      HIDDEN->c2ssize.h = height;
  1.1129 +    /* MGA CRTC2 stuff */
  1.1130 +    if (HIDDEN->enable_mga_crtc2) {
  1.1131 +        /* no stretching if c2ssize == c2framesize */
  1.1132 +        HIDDEN->c2ssize.x = 0, HIDDEN->c2ssize.y = 0;
  1.1133 +        HIDDEN->c2ssize.w = width;
  1.1134 +        HIDDEN->c2ssize.h = height;
  1.1135  
  1.1136 -      HIDDEN->c2dsize.x = 0, HIDDEN->c2dsize.y = 0;
  1.1137 -      HIDDEN->c2dsize.w = width;
  1.1138 -      HIDDEN->c2dsize.h = height;
  1.1139 +        HIDDEN->c2dsize.x = 0, HIDDEN->c2dsize.y = 0;
  1.1140 +        HIDDEN->c2dsize.w = width;
  1.1141 +        HIDDEN->c2dsize.h = height;
  1.1142 +
  1.1143 +        HIDDEN->mga_crtc2_stretch = 0;
  1.1144  
  1.1145 -      HIDDEN->mga_crtc2_stretch = 0;
  1.1146 +        if (SDL_getenv ("SDL_DIRECTFB_MGA_STRETCH") != NULL) {
  1.1147 +            /* Normally assume a picture aspect ratio of 4:3 */
  1.1148 +            int zoom_aspect_x = 4, zoom_aspect_y = 3, i, j;
  1.1149  
  1.1150 -      if (SDL_getenv("SDL_DIRECTFB_MGA_STRETCH") != NULL)
  1.1151 -        {
  1.1152 -	    /* Normally assume a picture aspect ratio of 4:3 */
  1.1153 -	    int zoom_aspect_x = 4, zoom_aspect_y = 3, i, j;
  1.1154 +            for (i = 1; i < 20; i++) {
  1.1155 +                for (j = 1; j < 10; j++) {
  1.1156 +                    if ((float) width / (float) i * (float) j == height) {
  1.1157 +                        zoom_aspect_x = i;
  1.1158 +                        zoom_aspect_y = j;
  1.1159  
  1.1160 -	    for (i = 1; i < 20; i++)
  1.1161 -	      {
  1.1162 -		for (j = 1; j < 10; j++)
  1.1163 -		  {
  1.1164 -		    if ((float)width/(float)i*(float)j == height) 
  1.1165 -		      {
  1.1166 -			zoom_aspect_x = i;
  1.1167 -			zoom_aspect_y = j;
  1.1168 -			
  1.1169 -			/* break the loop */
  1.1170 -			i = 21;
  1.1171 -			break;
  1.1172 -		      }
  1.1173 -		  }
  1.1174 -	      }
  1.1175 -	
  1.1176 -            #ifdef DIRECTFB_CRTC2_DEBUG
  1.1177 -            printf("Source resolution: X: %d, Y: %d, Aspect ratio: %d:%d\n", width, height, zoom_aspect_x, zoom_aspect_y);
  1.1178 -            printf("CRTC2 resolution: X: %d, Y: %d\n", HIDDEN->c2framesize.w, HIDDEN->c2framesize.h);
  1.1179 -            #endif
  1.1180 -	
  1.1181 -          /* don't stretch only slightly smaller/larger images */
  1.1182 -          if ((float)width < (float)HIDDEN->c2framesize.w*0.95 || (float)height < (float)HIDDEN->c2framesize.h*0.95)
  1.1183 -            {
  1.1184 -              while ((float)HIDDEN->c2dsize.w < (float)HIDDEN->c2framesize.w*HIDDEN->mga_crtc2_stretch_overscan && (float)HIDDEN->c2dsize.h < (float)HIDDEN->c2framesize.h*HIDDEN->mga_crtc2_stretch_overscan)
  1.1185 -                {
  1.1186 -                   HIDDEN->c2dsize.w+=zoom_aspect_x;
  1.1187 -                   HIDDEN->c2dsize.h+=zoom_aspect_y;
  1.1188 +                        /* break the loop */
  1.1189 +                        i = 21;
  1.1190 +                        break;
  1.1191 +                    }
  1.1192 +                }
  1.1193 +            }
  1.1194 +
  1.1195 +#ifdef DIRECTFB_CRTC2_DEBUG
  1.1196 +            printf
  1.1197 +                ("Source resolution: X: %d, Y: %d, Aspect ratio: %d:%d\n",
  1.1198 +                 width, height, zoom_aspect_x, zoom_aspect_y);
  1.1199 +            printf ("CRTC2 resolution: X: %d, Y: %d\n",
  1.1200 +                    HIDDEN->c2framesize.w, HIDDEN->c2framesize.h);
  1.1201 +#endif
  1.1202 +
  1.1203 +            /* don't stretch only slightly smaller/larger images */
  1.1204 +            if ((float) width < (float) HIDDEN->c2framesize.w * 0.95
  1.1205 +                || (float) height < (float) HIDDEN->c2framesize.h * 0.95) {
  1.1206 +                while ((float) HIDDEN->c2dsize.w <
  1.1207 +                       (float) HIDDEN->c2framesize.w *
  1.1208 +                       HIDDEN->mga_crtc2_stretch_overscan
  1.1209 +                       && (float) HIDDEN->c2dsize.h <
  1.1210 +                       (float) HIDDEN->c2framesize.h *
  1.1211 +                       HIDDEN->mga_crtc2_stretch_overscan) {
  1.1212 +                    HIDDEN->c2dsize.w += zoom_aspect_x;
  1.1213 +                    HIDDEN->c2dsize.h += zoom_aspect_y;
  1.1214                  }
  1.1215  
  1.1216 -              /* one step down */
  1.1217 -                HIDDEN->c2dsize.w-=zoom_aspect_x;
  1.1218 -                HIDDEN->c2dsize.h-=zoom_aspect_y;
  1.1219 +                /* one step down */
  1.1220 +                HIDDEN->c2dsize.w -= zoom_aspect_x;
  1.1221 +                HIDDEN->c2dsize.h -= zoom_aspect_y;
  1.1222  
  1.1223 -              #ifdef DIRECTFB_CRTC2_DEBUG
  1.1224 -              printf("Stretched resolution: X: %d, Y: %d\n", HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
  1.1225 -              #endif
  1.1226 +#ifdef DIRECTFB_CRTC2_DEBUG
  1.1227 +                printf ("Stretched resolution: X: %d, Y: %d\n",
  1.1228 +                        HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
  1.1229 +#endif
  1.1230  
  1.1231 -              HIDDEN->mga_crtc2_stretch = 1;
  1.1232 -            } 
  1.1233 -          else if ((float)width > (float)HIDDEN->c2framesize.w*0.95 || (float)height > (float)HIDDEN->c2framesize.h*0.95)
  1.1234 -            {
  1.1235 -               while ((float)HIDDEN->c2dsize.w > (float)HIDDEN->c2framesize.w*HIDDEN->mga_crtc2_stretch_overscan || (float)HIDDEN->c2dsize.h > (float)HIDDEN->c2framesize.h*HIDDEN->mga_crtc2_stretch_overscan)
  1.1236 -                {
  1.1237 -              HIDDEN->c2dsize.w-=zoom_aspect_x;
  1.1238 -              HIDDEN->c2dsize.h-=zoom_aspect_y;
  1.1239 +                HIDDEN->mga_crtc2_stretch = 1;
  1.1240 +            } else if ((float) width > (float) HIDDEN->c2framesize.w * 0.95
  1.1241 +                       || (float) height >
  1.1242 +                       (float) HIDDEN->c2framesize.h * 0.95) {
  1.1243 +                while ((float) HIDDEN->c2dsize.w >
  1.1244 +                       (float) HIDDEN->c2framesize.w *
  1.1245 +                       HIDDEN->mga_crtc2_stretch_overscan
  1.1246 +                       || (float) HIDDEN->c2dsize.h >
  1.1247 +                       (float) HIDDEN->c2framesize.h *
  1.1248 +                       HIDDEN->mga_crtc2_stretch_overscan) {
  1.1249 +                    HIDDEN->c2dsize.w -= zoom_aspect_x;
  1.1250 +                    HIDDEN->c2dsize.h -= zoom_aspect_y;
  1.1251                  }
  1.1252 -              
  1.1253 -              #ifdef DIRECTFB_CRTC2_DEBUG
  1.1254 -              printf("Down-Stretched resolution: X: %d, Y: %d\n", HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
  1.1255 -              #endif
  1.1256 +
  1.1257 +#ifdef DIRECTFB_CRTC2_DEBUG
  1.1258 +                printf ("Down-Stretched resolution: X: %d, Y: %d\n",
  1.1259 +                        HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
  1.1260 +#endif
  1.1261  
  1.1262 -              HIDDEN->mga_crtc2_stretch = 1;
  1.1263 -             } else {
  1.1264 -          #ifdef DIRECTFB_CRTC2_DEBUG
  1.1265 -          printf("Not stretching image\n");
  1.1266 -          #endif
  1.1267 -        }
  1.1268 +                HIDDEN->mga_crtc2_stretch = 1;
  1.1269 +            } else {
  1.1270 +#ifdef DIRECTFB_CRTC2_DEBUG
  1.1271 +                printf ("Not stretching image\n");
  1.1272 +#endif
  1.1273 +            }
  1.1274  
  1.1275 -      /* Panning */
  1.1276 -      if (HIDDEN->c2framesize.w > HIDDEN->c2dsize.w)
  1.1277 -        HIDDEN->c2dsize.x = (HIDDEN->c2framesize.w - HIDDEN->c2dsize.w)  / 2;
  1.1278 -      else
  1.1279 -        HIDDEN->c2dsize.x = (HIDDEN->c2dsize.w - HIDDEN->c2framesize.w)  / 2;
  1.1280 +            /* Panning */
  1.1281 +            if (HIDDEN->c2framesize.w > HIDDEN->c2dsize.w)
  1.1282 +                HIDDEN->c2dsize.x =
  1.1283 +                    (HIDDEN->c2framesize.w - HIDDEN->c2dsize.w) / 2;
  1.1284 +            else
  1.1285 +                HIDDEN->c2dsize.x =
  1.1286 +                    (HIDDEN->c2dsize.w - HIDDEN->c2framesize.w) / 2;
  1.1287  
  1.1288 -      if (HIDDEN->c2framesize.h > HIDDEN->c2dsize.h)
  1.1289 -        HIDDEN->c2dsize.y = (HIDDEN->c2framesize.h - HIDDEN->c2dsize.h)  / 2;
  1.1290 -      else
  1.1291 -        HIDDEN->c2dsize.y = (HIDDEN->c2dsize.h - HIDDEN->c2framesize.h)  / 2;
  1.1292 +            if (HIDDEN->c2framesize.h > HIDDEN->c2dsize.h)
  1.1293 +                HIDDEN->c2dsize.y =
  1.1294 +                    (HIDDEN->c2framesize.h - HIDDEN->c2dsize.h) / 2;
  1.1295 +            else
  1.1296 +                HIDDEN->c2dsize.y =
  1.1297 +                    (HIDDEN->c2dsize.h - HIDDEN->c2framesize.h) / 2;
  1.1298  
  1.1299 -      #ifdef DIRECTFB_CRTC2_DEBUG
  1.1300 -    printf("CRTC2 position X: %d, Y: %d\n", HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
  1.1301 -      #endif
  1.1302 -   }
  1.1303 -  }
  1.1304 +#ifdef DIRECTFB_CRTC2_DEBUG
  1.1305 +            printf ("CRTC2 position X: %d, Y: %d\n", HIDDEN->c2dsize.x,
  1.1306 +                    HIDDEN->c2dsize.y);
  1.1307 +#endif
  1.1308 +        }
  1.1309 +    }
  1.1310  
  1.1311 -  return current;
  1.1312 +    return current;
  1.1313  }
  1.1314  
  1.1315 -static int DirectFB_AllocHWSurface(_THIS, SDL_Surface *surface)
  1.1316 +static int
  1.1317 +DirectFB_AllocHWSurface (_THIS, SDL_Surface * surface)
  1.1318  {
  1.1319 -  DFBResult             ret;
  1.1320 -  DFBSurfaceDescription dsc;
  1.1321 +    DFBResult ret;
  1.1322 +    DFBSurfaceDescription dsc;
  1.1323  
  1.1324 -  /*  fprintf(stderr, "SDL: DirectFB_AllocHWSurface (%dx%d@%d, flags: 0x%08x)\n",
  1.1325 -      surface->w, surface->h, surface->format->BitsPerPixel, surface->flags);*/
  1.1326 +    /*  fprintf(stderr, "SDL: DirectFB_AllocHWSurface (%dx%d@%d, flags: 0x%08x)\n",
  1.1327 +       surface->w, surface->h, surface->format->BitsPerPixel, surface->flags); */
  1.1328  
  1.1329 -  if (surface->w < 8 || surface->h < 8)
  1.1330 -    return -1;
  1.1331 +    if (surface->w < 8 || surface->h < 8)
  1.1332 +        return -1;
  1.1333  
  1.1334 -  /* fill surface description */
  1.1335 -  dsc.flags  = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
  1.1336 -  dsc.width  = surface->w;
  1.1337 -  dsc.height = surface->h;
  1.1338 -  dsc.caps   = (surface->flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0;
  1.1339 +    /* fill surface description */
  1.1340 +    dsc.flags =
  1.1341 +        DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
  1.1342 +    dsc.width = surface->w;
  1.1343 +    dsc.height = surface->h;
  1.1344 +    dsc.caps = (surface->flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0;
  1.1345  
  1.1346 -  /* find the right pixelformat */
  1.1347 -  dsc.pixelformat = SDLToDFBPixelFormat (surface->format);
  1.1348 -  if (dsc.pixelformat == DSPF_UNKNOWN)
  1.1349 -    return -1;
  1.1350 +    /* find the right pixelformat */
  1.1351 +    dsc.pixelformat = SDLToDFBPixelFormat (surface->format);
  1.1352 +    if (dsc.pixelformat == DSPF_UNKNOWN)
  1.1353 +        return -1;
  1.1354  
  1.1355 -  /* Allocate the hardware acceleration data */
  1.1356 -  surface->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*surface->hwdata));
  1.1357 -  if (surface->hwdata == NULL)
  1.1358 -    {
  1.1359 -      SDL_OutOfMemory();
  1.1360 -      return -1;
  1.1361 +    /* Allocate the hardware acceleration data */
  1.1362 +    surface->hwdata =
  1.1363 +        (struct private_hwdata *) SDL_calloc (1, sizeof (*surface->hwdata));
  1.1364 +    if (surface->hwdata == NULL) {
  1.1365 +        SDL_OutOfMemory ();
  1.1366 +        return -1;
  1.1367      }
  1.1368  
  1.1369 -  /* Create the surface */
  1.1370 -  ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface->hwdata->surface);
  1.1371 -  if (ret)
  1.1372 -    {
  1.1373 -      SetDirectFBerror ("dfb->CreateSurface", ret);
  1.1374 -      free (surface->hwdata);
  1.1375 -      surface->hwdata = NULL;
  1.1376 -      return -1;
  1.1377 +    /* Create the surface */
  1.1378 +    ret =
  1.1379 +        HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc,
  1.1380 +                                    &surface->hwdata->surface);
  1.1381 +    if (ret) {
  1.1382 +        SetDirectFBerror ("dfb->CreateSurface", ret);
  1.1383 +        free (surface->hwdata);
  1.1384 +        surface->hwdata = NULL;
  1.1385 +        return -1;
  1.1386      }
  1.1387  
  1.1388 -  surface->flags |= SDL_HWSURFACE | SDL_PREALLOC;
  1.1389 +    surface->flags |= SDL_HWSURFACE | SDL_PREALLOC;
  1.1390  
  1.1391 -  return 0;
  1.1392 +    return 0;
  1.1393  }
  1.1394  
  1.1395 -static void DirectFB_FreeHWSurface(_THIS, SDL_Surface *surface)
  1.1396 +static void
  1.1397 +DirectFB_FreeHWSurface (_THIS, SDL_Surface * surface)
  1.1398  {
  1.1399 -  if (surface->hwdata && HIDDEN->initialized)
  1.1400 -    {
  1.1401 -      surface->hwdata->surface->Release (surface->hwdata->surface);
  1.1402 -      free (surface->hwdata);
  1.1403 -      surface->hwdata = NULL;
  1.1404 +    if (surface->hwdata && HIDDEN->initialized) {
  1.1405 +        surface->hwdata->surface->Release (surface->hwdata->surface);
  1.1406 +        free (surface->hwdata);
  1.1407 +        surface->hwdata = NULL;
  1.1408      }
  1.1409  }
  1.1410  
  1.1411 -static int DirectFB_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
  1.1412 +static int
  1.1413 +DirectFB_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst)
  1.1414  {
  1.1415 -  /*  fprintf(stderr, "SDL: DirectFB_CheckHWBlit (src->hwdata: %p, dst->hwdata: %p)\n",
  1.1416 -      src->hwdata, dst->hwdata);*/
  1.1417 +    /*  fprintf(stderr, "SDL: DirectFB_CheckHWBlit (src->hwdata: %p, dst->hwdata: %p)\n",
  1.1418 +       src->hwdata, dst->hwdata); */
  1.1419  
  1.1420 -  if (!src->hwdata || !dst->hwdata)
  1.1421 -    return 0;
  1.1422 +    if (!src->hwdata || !dst->hwdata)
  1.1423 +        return 0;
  1.1424  
  1.1425 -  src->flags |= SDL_HWACCEL;
  1.1426 -  src->map->hw_blit = DirectFB_HWAccelBlit;
  1.1427 +    src->flags |= SDL_HWACCEL;
  1.1428 +    src->map->hw_blit = DirectFB_HWAccelBlit;
  1.1429  
  1.1430 -  return 1;
  1.1431 +    return 1;
  1.1432  }
  1.1433  
  1.1434 -static int DirectFB_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
  1.1435 -                                SDL_Surface *dst, SDL_Rect *dstrect)
  1.1436 +static int
  1.1437 +DirectFB_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect,
  1.1438 +                      SDL_Surface * dst, SDL_Rect * dstrect)
  1.1439  {
  1.1440 -  DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
  1.1441 +    DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
  1.1442  
  1.1443 -  DFBRectangle sr = { srcrect->x, srcrect->y, srcrect->w, srcrect->h };
  1.1444 -  DFBRectangle dr = { dstrect->x, dstrect->y, dstrect->w, dstrect->h };
  1.1445 -
  1.1446 -  IDirectFBSurface *surface = dst->hwdata->surface;
  1.1447 +    DFBRectangle sr = { srcrect->x, srcrect->y, srcrect->w, srcrect->h };
  1.1448 +    DFBRectangle dr = { dstrect->x, dstrect->y, dstrect->w, dstrect->h };
  1.1449  
  1.1450 -  if (src->flags & SDL_SRCCOLORKEY)
  1.1451 -    {
  1.1452 -      flags |= DSBLIT_SRC_COLORKEY;
  1.1453 -      DirectFB_SetHWColorKey (NULL, src, src->format->colorkey);
  1.1454 +    IDirectFBSurface *surface = dst->hwdata->surface;
  1.1455 +
  1.1456 +    if (src->flags & SDL_SRCCOLORKEY) {
  1.1457 +        flags |= DSBLIT_SRC_COLORKEY;
  1.1458 +        DirectFB_SetHWColorKey (NULL, src, src->format->colorkey);
  1.1459      }
  1.1460  
  1.1461 -  if (src->flags & SDL_SRCALPHA)
  1.1462 -    {
  1.1463 -      flags |= DSBLIT_BLEND_COLORALPHA;
  1.1464 -      surface->SetColor (surface, 0xff, 0xff, 0xff, src->format->alpha);
  1.1465 +    if (src->flags & SDL_SRCALPHA) {
  1.1466 +        flags |= DSBLIT_BLEND_COLORALPHA;
  1.1467 +        surface->SetColor (surface, 0xff, 0xff, 0xff, src->format->alpha);
  1.1468      }
  1.1469  
  1.1470 -  surface->SetBlittingFlags (surface, flags);
  1.1471 +    surface->SetBlittingFlags (surface, flags);
  1.1472  
  1.1473 -  if (sr.w == dr.w && sr.h == dr.h)
  1.1474 -    surface->Blit (surface, src->hwdata->surface, &sr, dr.x, dr.y);
  1.1475 -  else
  1.1476 -    surface->StretchBlit (surface, src->hwdata->surface, &sr, &dr);
  1.1477 +    if (sr.w == dr.w && sr.h == dr.h)
  1.1478 +        surface->Blit (surface, src->hwdata->surface, &sr, dr.x, dr.y);
  1.1479 +    else
  1.1480 +        surface->StretchBlit (surface, src->hwdata->surface, &sr, &dr);
  1.1481  
  1.1482 -  return 0;
  1.1483 +    return 0;
  1.1484  }
  1.1485  
  1.1486 -static int DirectFB_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
  1.1487 +static int
  1.1488 +DirectFB_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * dstrect,
  1.1489 +                     Uint32 color)
  1.1490  {
  1.1491 -  SDL_PixelFormat  *fmt     = dst->format;
  1.1492 -  IDirectFBSurface *surface = dst->hwdata->surface;
  1.1493 +    SDL_PixelFormat *fmt = dst->format;
  1.1494 +    IDirectFBSurface *surface = dst->hwdata->surface;
  1.1495  
  1.1496 -  /* ugly */
  1.1497 -  surface->SetColor (surface,
  1.1498 -                     (color & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss),
  1.1499 -                     (color & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss),
  1.1500 -                     (color & fmt->Bmask) << (fmt->Bloss - fmt->Bshift), 0xFF);
  1.1501 -  surface->FillRectangle (surface, dstrect->x, dstrect->y, dstrect->w, dstrect->h);
  1.1502 +    /* ugly */
  1.1503 +    surface->SetColor (surface,
  1.1504 +                       (color & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss),
  1.1505 +                       (color & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss),
  1.1506 +                       (color & fmt->Bmask) << (fmt->Bloss - fmt->Bshift),
  1.1507 +                       0xFF);
  1.1508 +    surface->FillRectangle (surface, dstrect->x, dstrect->y, dstrect->w,
  1.1509 +                            dstrect->h);
  1.1510  
  1.1511 -  return 0;
  1.1512 +    return 0;
  1.1513  }
  1.1514  
  1.1515 -static int DirectFB_SetHWColorKey(_THIS, SDL_Surface *src, Uint32 key)
  1.1516 +static int
  1.1517 +DirectFB_SetHWColorKey (_THIS, SDL_Surface * src, Uint32 key)
  1.1518  {
  1.1519 -  SDL_PixelFormat  *fmt     = src->format;
  1.1520 -  IDirectFBSurface *surface = src->hwdata->surface;
  1.1521 +    SDL_PixelFormat *fmt = src->format;
  1.1522 +    IDirectFBSurface *surface = src->hwdata->surface;
  1.1523  
  1.1524 -  if (fmt->BitsPerPixel == 8)
  1.1525 -    surface->SetSrcColorKeyIndex (surface, key);
  1.1526 -  else
  1.1527 -    /* ugly */
  1.1528 -    surface->SetSrcColorKey (surface,
  1.1529 -                             (key & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss),
  1.1530 -                             (key & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss),
  1.1531 -                             (key & fmt->Bmask) << (fmt->Bloss - fmt->Bshift));
  1.1532 +    if (fmt->BitsPerPixel == 8)
  1.1533 +        surface->SetSrcColorKeyIndex (surface, key);
  1.1534 +    else
  1.1535 +        /* ugly */
  1.1536 +        surface->SetSrcColorKey (surface,
  1.1537 +                                 (key & fmt->Rmask) >> (fmt->Rshift -
  1.1538 +                                                        fmt->Rloss),
  1.1539 +                                 (key & fmt->Gmask) >> (fmt->Gshift -
  1.1540 +                                                        fmt->Gloss),
  1.1541 +                                 (key & fmt->Bmask) << (fmt->Bloss -
  1.1542 +                                                        fmt->Bshift));
  1.1543  
  1.1544 -  return 0;
  1.1545 +    return 0;
  1.1546  }
  1.1547  
  1.1548 -static int DirectFB_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha)
  1.1549 +static int
  1.1550 +DirectFB_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha)
  1.1551  {
  1.1552 -  return 0;
  1.1553 +    return 0;
  1.1554  }
  1.1555  
  1.1556 -static int DirectFB_FlipHWSurface(_THIS, SDL_Surface *surface)
  1.1557 +static int
  1.1558 +DirectFB_FlipHWSurface (_THIS, SDL_Surface * surface)
  1.1559  {
  1.1560 -  if (HIDDEN->enable_mga_crtc2)
  1.1561 -    {
  1.1562 -       int rtn = surface->hwdata->surface->Flip (surface->hwdata->surface, NULL, 0);
  1.1563 -       if (HIDDEN->mga_crtc2_stretch)
  1.1564 -         HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, surface->hwdata->surface, &HIDDEN->c2ssize, &HIDDEN->c2dsize);
  1.1565 -       else
  1.1566 -         HIDDEN->c2frame->Blit(HIDDEN->c2frame, surface->hwdata->surface, NULL, HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
  1.1567 -     
  1.1568 -       HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1569 -       return rtn;
  1.1570 -    } 
  1.1571 -  else 
  1.1572 -     return surface->hwdata->surface->Flip (surface->hwdata->surface, NULL, DSFLIP_WAITFORSYNC);
  1.1573 +    if (HIDDEN->enable_mga_crtc2) {
  1.1574 +        int rtn =
  1.1575 +            surface->hwdata->surface->Flip (surface->hwdata->surface, NULL,
  1.1576 +                                            0);
  1.1577 +        if (HIDDEN->mga_crtc2_stretch)
  1.1578 +            HIDDEN->c2frame->StretchBlit (HIDDEN->c2frame,
  1.1579 +                                          surface->hwdata->surface,
  1.1580 +                                          &HIDDEN->c2ssize, &HIDDEN->c2dsize);
  1.1581 +        else
  1.1582 +            HIDDEN->c2frame->Blit (HIDDEN->c2frame,
  1.1583 +                                   surface->hwdata->surface, NULL,
  1.1584 +                                   HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
  1.1585 +
  1.1586 +        HIDDEN->c2frame->Flip (HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1587 +        return rtn;
  1.1588 +    } else
  1.1589 +        return surface->hwdata->surface->Flip (surface->hwdata->surface, NULL,
  1.1590 +                                               DSFLIP_WAITFORSYNC);
  1.1591  }
  1.1592  
  1.1593 -static int DirectFB_LockHWSurface(_THIS, SDL_Surface *surface)
  1.1594 +static int
  1.1595 +DirectFB_LockHWSurface (_THIS, SDL_Surface * surface)
  1.1596  {
  1.1597 -  DFBResult  ret;
  1.1598 -  void      *data;
  1.1599 -  int        pitch;
  1.1600 +    DFBResult ret;
  1.1601 +    void *data;
  1.1602 +    int pitch;
  1.1603  
  1.1604 -  ret = surface->hwdata->surface->Lock (surface->hwdata->surface,
  1.1605 -                                        DSLF_WRITE, &data, &pitch);
  1.1606 -  if (ret)
  1.1607 -    {
  1.1608 -      SetDirectFBerror ("surface->Lock", ret);
  1.1609 -      return -1;
  1.1610 +    ret = surface->hwdata->surface->Lock (surface->hwdata->surface,
  1.1611 +                                          DSLF_WRITE, &data, &pitch);
  1.1612 +    if (ret) {
  1.1613 +        SetDirectFBerror ("surface->Lock", ret);
  1.1614 +        return -1;
  1.1615      }
  1.1616  
  1.1617 -  surface->pixels = data;
  1.1618 -  surface->pitch  = pitch;
  1.1619 +    surface->pixels = data;
  1.1620 +    surface->pitch = pitch;
  1.1621 +
  1.1622 +    return 0;
  1.1623 +}
  1.1624  
  1.1625 -  return 0;
  1.1626 +static void
  1.1627 +DirectFB_UnlockHWSurface (_THIS, SDL_Surface * surface)
  1.1628 +{
  1.1629 +    surface->hwdata->surface->Unlock (surface->hwdata->surface);
  1.1630 +    surface->pixels = NULL;
  1.1631  }
  1.1632  
  1.1633 -static void DirectFB_UnlockHWSurface(_THIS, SDL_Surface *surface)
  1.1634 -{
  1.1635 -  surface->hwdata->surface->Unlock (surface->hwdata->surface);
  1.1636 -  surface->pixels = NULL;
  1.1637 -}
  1.1638 -
  1.1639 -static void DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
  1.1640 +static void
  1.1641 +DirectFB_DirectUpdate (_THIS, int numrects, SDL_Rect * rects)
  1.1642  {
  1.1643 -  if (HIDDEN->enable_mga_crtc2)
  1.1644 -    {
  1.1645 -       if (HIDDEN->mga_crtc2_stretch)
  1.1646 -         HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, this->screen->hwdata->surface, &HIDDEN->c2ssize, &HIDDEN->c2dsize); 
  1.1647 -       else
  1.1648 -         HIDDEN->c2frame->Blit(HIDDEN->c2frame, this->screen->hwdata->surface, NULL, HIDDEN->c2dsize.x, HIDDEN->c2dsize.y); 
  1.1649 +    if (HIDDEN->enable_mga_crtc2) {
  1.1650 +        if (HIDDEN->mga_crtc2_stretch)
  1.1651 +            HIDDEN->c2frame->StretchBlit (HIDDEN->c2frame,
  1.1652 +                                          this->screen->hwdata->surface,
  1.1653 +                                          &HIDDEN->c2ssize, &HIDDEN->c2dsize);
  1.1654 +        else
  1.1655 +            HIDDEN->c2frame->Blit (HIDDEN->c2frame,
  1.1656 +                                   this->screen->hwdata->surface, NULL,
  1.1657 +                                   HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
  1.1658  
  1.1659 -       HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1660 +        HIDDEN->c2frame->Flip (HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1661      }
  1.1662  }
  1.1663  
  1.1664 -static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect *rects)
  1.1665 +static void
  1.1666 +DirectFB_WindowedUpdate (_THIS, int numrects, SDL_Rect * rects)
  1.1667  {
  1.1668 -  DFBRegion         region;
  1.1669 -  int               i;
  1.1670 -  int               region_valid = 0;
  1.1671 -  IDirectFBSurface *surface = this->screen->hwdata->surface;
  1.1672 +    DFBRegion region;
  1.1673 +    int i;
  1.1674 +    int region_valid = 0;
  1.1675 +    IDirectFBSurface *surface = this->screen->hwdata->surface;
  1.1676  
  1.1677 -  for (i=0; i<numrects; ++i)
  1.1678 -    {
  1.1679 -      int x2, y2;
  1.1680 +    for (i = 0; i < numrects; ++i) {
  1.1681 +        int x2, y2;
  1.1682  
  1.1683 -      if ( ! rects[i].w ) /* Clipped? */
  1.1684 -        continue;
  1.1685 -
  1.1686 -      x2 = rects[i].x + rects[i].w - 1;
  1.1687 -      y2 = rects[i].y + rects[i].h - 1;
  1.1688 +        if (!rects[i].w)        /* Clipped? */
  1.1689 +            continue;
  1.1690  
  1.1691 -      if (region_valid)
  1.1692 -        {
  1.1693 -          if (rects[i].x < region.x1)
  1.1694 -            region.x1 = rects[i].x;
  1.1695 +        x2 = rects[i].x + rects[i].w - 1;
  1.1696 +        y2 = rects[i].y + rects[i].h - 1;
  1.1697  
  1.1698 -          if (rects[i].y < region.y1)
  1.1699 -            region.y1 = rects[i].y;
  1.1700 +        if (region_valid) {
  1.1701 +            if (rects[i].x < region.x1)
  1.1702 +                region.x1 = rects[i].x;
  1.1703  
  1.1704 -          if (x2 > region.x2)
  1.1705 -            region.x2 = x2;
  1.1706 +            if (rects[i].y < region.y1)
  1.1707 +                region.y1 = rects[i].y;
  1.1708  
  1.1709 -          if (y2 > region.y2)
  1.1710 -            region.y2 = y2;
  1.1711 -        }
  1.1712 -      else
  1.1713 -        {
  1.1714 +            if (x2 > region.x2)
  1.1715 +                region.x2 = x2;
  1.1716 +
  1.1717 +            if (y2 > region.y2)
  1.1718 +                region.y2 = y2;
  1.1719 +        } else {
  1.1720              region.x1 = rects[i].x;
  1.1721              region.y1 = rects[i].y;
  1.1722              region.x2 = x2;
  1.1723 @@ -1033,137 +1051,130 @@
  1.1724          }
  1.1725      }
  1.1726  
  1.1727 -  if (region_valid)
  1.1728 -    {
  1.1729 -      if (HIDDEN->enable_mga_crtc2)
  1.1730 -        {
  1.1731 -          if (HIDDEN->mga_crtc2_stretch)
  1.1732 -            HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, surface, &HIDDEN->c2ssize, &HIDDEN->c2dsize);
  1.1733 -          else
  1.1734 -            HIDDEN->c2frame->Blit(HIDDEN->c2frame, surface, NULL, HIDDEN->c2dsize.x, HIDDEN->c2dsize.y); 
  1.1735 -      
  1.1736 -          HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1737 -        }
  1.1738 -      else 
  1.1739 -        surface->Flip (surface, &region, DSFLIP_WAITFORSYNC);
  1.1740 +    if (region_valid) {
  1.1741 +        if (HIDDEN->enable_mga_crtc2) {
  1.1742 +            if (HIDDEN->mga_crtc2_stretch)
  1.1743 +                HIDDEN->c2frame->StretchBlit (HIDDEN->c2frame, surface,
  1.1744 +                                              &HIDDEN->c2ssize,
  1.1745 +                                              &HIDDEN->c2dsize);
  1.1746 +            else
  1.1747 +                HIDDEN->c2frame->Blit (HIDDEN->c2frame, surface, NULL,
  1.1748 +                                       HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
  1.1749 +
  1.1750 +            HIDDEN->c2frame->Flip (HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1751 +        } else
  1.1752 +            surface->Flip (surface, &region, DSFLIP_WAITFORSYNC);
  1.1753      }
  1.1754  }
  1.1755  
  1.1756 -int DirectFB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
  1.1757 +int
  1.1758 +DirectFB_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  1.1759  {
  1.1760 -  IDirectFBPalette *palette = this->screen->hwdata->palette;
  1.1761 +    IDirectFBPalette *palette = this->screen->hwdata->palette;
  1.1762  
  1.1763 -  if (!palette)
  1.1764 -    return 0;
  1.1765 +    if (!palette)
  1.1766 +        return 0;
  1.1767  
  1.1768 -  if (firstcolor > 255)
  1.1769 -    return 0;
  1.1770 +    if (firstcolor > 255)
  1.1771 +        return 0;
  1.1772  
  1.1773 -  if (firstcolor + ncolors > 256)
  1.1774 -    ncolors = 256 - firstcolor;
  1.1775 +    if (firstcolor + ncolors > 256)
  1.1776 +        ncolors = 256 - firstcolor;
  1.1777  
  1.1778 -  if (ncolors > 0)
  1.1779 -    {
  1.1780 -      int      i;
  1.1781 -      DFBColor entries[ncolors];
  1.1782 +    if (ncolors > 0) {
  1.1783 +        int i;
  1.1784 +        DFBColor entries[ncolors];
  1.1785  
  1.1786 -      for (i=0; i<ncolors; i++)
  1.1787 -        {
  1.1788 -          entries[i].a = 0xff;
  1.1789 -          entries[i].r = colors[i].r;
  1.1790 -          entries[i].g = colors[i].g;
  1.1791 -          entries[i].b = colors[i].b;
  1.1792 +        for (i = 0; i < ncolors; i++) {
  1.1793 +            entries[i].a = 0xff;
  1.1794 +            entries[i].r = colors[i].r;
  1.1795 +            entries[i].g = colors[i].g;
  1.1796 +            entries[i].b = colors[i].b;
  1.1797          }
  1.1798  
  1.1799 -      palette->SetEntries (palette, entries, ncolors, firstcolor);
  1.1800 +        palette->SetEntries (palette, entries, ncolors, firstcolor);
  1.1801      }
  1.1802  
  1.1803 -  return 1;
  1.1804 +    return 1;
  1.1805  }
  1.1806 -	
  1.1807 -void DirectFB_VideoQuit(_THIS)
  1.1808 +
  1.1809 +void
  1.1810 +DirectFB_VideoQuit (_THIS)
  1.1811  {
  1.1812 -  struct DirectFBEnumRect *rect    = enumlist;
  1.1813 +    struct DirectFBEnumRect *rect = enumlist;
  1.1814  
  1.1815 -  if (this->screen && this->screen->hwdata)
  1.1816 -    {
  1.1817 -      IDirectFBSurface        *surface = this->screen->hwdata->surface;
  1.1818 -      IDirectFBPalette        *palette = this->screen->hwdata->palette;
  1.1819 +    if (this->screen && this->screen->hwdata) {
  1.1820 +        IDirectFBSurface *surface = this->screen->hwdata->surface;
  1.1821 +        IDirectFBPalette *palette = this->screen->hwdata->palette;
  1.1822  
  1.1823 -      if (palette)
  1.1824 -        palette->Release (palette);
  1.1825 +        if (palette)
  1.1826 +            palette->Release (palette);
  1.1827  
  1.1828 -      if (surface)
  1.1829 -        surface->Release (surface);
  1.1830 +        if (surface)
  1.1831 +            surface->Release (surface);
  1.1832  
  1.1833 -      this->screen->hwdata->surface = NULL;
  1.1834 -      this->screen->hwdata->palette = NULL;
  1.1835 +        this->screen->hwdata->surface = NULL;
  1.1836 +        this->screen->hwdata->palette = NULL;
  1.1837      }
  1.1838  
  1.1839 -  if (HIDDEN->c2frame)
  1.1840 -    {
  1.1841 -      HIDDEN->c2frame->Release (HIDDEN->c2frame);
  1.1842 -      HIDDEN->c2frame = NULL;
  1.1843 -    }
  1.1844 -
  1.1845 -  if (HIDDEN->eventbuffer)
  1.1846 -    {
  1.1847 -      HIDDEN->eventbuffer->Release (HIDDEN->eventbuffer);
  1.1848 -      HIDDEN->eventbuffer = NULL;
  1.1849 +    if (HIDDEN->c2frame) {
  1.1850 +        HIDDEN->c2frame->Release (HIDDEN->c2frame);
  1.1851 +        HIDDEN->c2frame = NULL;
  1.1852      }
  1.1853  
  1.1854 -  if (HIDDEN->c2layer)
  1.1855 -    {
  1.1856 -      HIDDEN->c2layer->Release (HIDDEN->c2layer);
  1.1857 -      HIDDEN->c2layer = NULL;
  1.1858 +    if (HIDDEN->eventbuffer) {
  1.1859 +        HIDDEN->eventbuffer->Release (HIDDEN->eventbuffer);
  1.1860 +        HIDDEN->eventbuffer = NULL;
  1.1861      }
  1.1862  
  1.1863 -  if (HIDDEN->layer)
  1.1864 -    {
  1.1865 -      HIDDEN->layer->Release (HIDDEN->layer);
  1.1866 -      HIDDEN->layer = NULL;
  1.1867 +    if (HIDDEN->c2layer) {
  1.1868 +        HIDDEN->c2layer->Release (HIDDEN->c2layer);
  1.1869 +        HIDDEN->c2layer = NULL;
  1.1870      }
  1.1871  
  1.1872 -  if (HIDDEN->dfb)
  1.1873 -    {
  1.1874 -      HIDDEN->dfb->Release (HIDDEN->dfb);
  1.1875 -      HIDDEN->dfb = NULL;
  1.1876 +    if (HIDDEN->layer) {
  1.1877 +        HIDDEN->layer->Release (HIDDEN->layer);
  1.1878 +        HIDDEN->layer = NULL;
  1.1879      }
  1.1880  
  1.1881 -  /* Free video mode list */
  1.1882 -  if (HIDDEN->modelist)
  1.1883 -    {
  1.1884 -      free (HIDDEN->modelist);
  1.1885 -      HIDDEN->modelist = NULL;
  1.1886 +    if (HIDDEN->dfb) {
  1.1887 +        HIDDEN->dfb->Release (HIDDEN->dfb);
  1.1888 +        HIDDEN->dfb = NULL;
  1.1889      }
  1.1890  
  1.1891 -  /* Free mode enumeration list */
  1.1892 -  while (rect)
  1.1893 -    {
  1.1894 -      struct DirectFBEnumRect *next = rect->next;
  1.1895 -      free (rect);
  1.1896 -      rect = next;
  1.1897 +    /* Free video mode list */
  1.1898 +    if (HIDDEN->modelist) {
  1.1899 +        free (HIDDEN->modelist);
  1.1900 +        HIDDEN->modelist = NULL;
  1.1901      }
  1.1902 -  enumlist = NULL;
  1.1903  
  1.1904 -  HIDDEN->initialized = 0;
  1.1905 +    /* Free mode enumeration list */
  1.1906 +    while (rect) {
  1.1907 +        struct DirectFBEnumRect *next = rect->next;
  1.1908 +        free (rect);
  1.1909 +        rect = next;
  1.1910 +    }
  1.1911 +    enumlist = NULL;
  1.1912 +
  1.1913 +    HIDDEN->initialized = 0;
  1.1914  }
  1.1915  
  1.1916  
  1.1917 -int DirectFB_ShowWMCursor(_THIS, WMcursor *cursor)
  1.1918 +int
  1.1919 +DirectFB_ShowWMCursor (_THIS, WMcursor * cursor)
  1.1920  {
  1.1921 -  /* We can only hide or show the default cursor */
  1.1922 -  if ( cursor == NULL )
  1.1923 -    {
  1.1924 -      HIDDEN->layer->SetCursorOpacity(HIDDEN->layer, 0x00);
  1.1925 +    /* We can only hide or show the default cursor */
  1.1926 +    if (cursor == NULL) {
  1.1927 +        HIDDEN->layer->SetCursorOpacity (HIDDEN->layer, 0x00);
  1.1928 +    } else {
  1.1929 +        HIDDEN->layer->SetCursorOpacity (HIDDEN->layer, 0xFF);
  1.1930      }
  1.1931 -    else
  1.1932 -    {
  1.1933 -      HIDDEN->layer->SetCursorOpacity(HIDDEN->layer, 0xFF);
  1.1934 -    }
  1.1935 -  return 1;
  1.1936 +    return 1;
  1.1937  }
  1.1938  
  1.1939 -void DirectFB_FinalQuit(void) 
  1.1940 +void
  1.1941 +DirectFB_FinalQuit (void)
  1.1942  {
  1.1943  }
  1.1944 +
  1.1945 +/* vi: set ts=4 sw=4 expandtab: */