src/video/x11/SDL_x11image.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/video/x11/SDL_x11image.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/video/x11/SDL_x11image.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -34,17 +34,17 @@
     1.4  static int shm_error;
     1.5  static int (*X_handler) (Display *, XErrorEvent *) = NULL;
     1.6  static int
     1.7 -shm_errhandler (Display * d, XErrorEvent * e)
     1.8 +shm_errhandler(Display * d, XErrorEvent * e)
     1.9  {
    1.10      if (e->error_code == BadAccess) {
    1.11          shm_error = True;
    1.12          return (0);
    1.13      } else
    1.14 -        return (X_handler (d, e));
    1.15 +        return (X_handler(d, e));
    1.16  }
    1.17  
    1.18  static void
    1.19 -try_mitshm (_THIS, SDL_Surface * screen)
    1.20 +try_mitshm(_THIS, SDL_Surface * screen)
    1.21  {
    1.22      /* Dynamic X11 may not have SHM entry points on this box. */
    1.23      if ((use_mitshm) && (!SDL_X11_HAVE_SHM))
    1.24 @@ -52,23 +52,23 @@
    1.25  
    1.26      if (!use_mitshm)
    1.27          return;
    1.28 -    shminfo.shmid = shmget (IPC_PRIVATE, screen->h * screen->pitch,
    1.29 -                            IPC_CREAT | 0777);
    1.30 +    shminfo.shmid = shmget(IPC_PRIVATE, screen->h * screen->pitch,
    1.31 +                           IPC_CREAT | 0777);
    1.32      if (shminfo.shmid >= 0) {
    1.33 -        shminfo.shmaddr = (char *) shmat (shminfo.shmid, 0, 0);
    1.34 +        shminfo.shmaddr = (char *) shmat(shminfo.shmid, 0, 0);
    1.35          shminfo.readOnly = False;
    1.36          if (shminfo.shmaddr != (char *) -1) {
    1.37              shm_error = False;
    1.38 -            X_handler = XSetErrorHandler (shm_errhandler);
    1.39 -            XShmAttach (SDL_Display, &shminfo);
    1.40 -            XSync (SDL_Display, True);
    1.41 -            XSetErrorHandler (X_handler);
    1.42 +            X_handler = XSetErrorHandler(shm_errhandler);
    1.43 +            XShmAttach(SDL_Display, &shminfo);
    1.44 +            XSync(SDL_Display, True);
    1.45 +            XSetErrorHandler(X_handler);
    1.46              if (shm_error)
    1.47 -                shmdt (shminfo.shmaddr);
    1.48 +                shmdt(shminfo.shmaddr);
    1.49          } else {
    1.50              shm_error = True;
    1.51          }
    1.52 -        shmctl (shminfo.shmid, IPC_RMID, NULL);
    1.53 +        shmctl(shminfo.shmid, IPC_RMID, NULL);
    1.54      } else {
    1.55          shm_error = True;
    1.56      }
    1.57 @@ -80,23 +80,23 @@
    1.58  #endif /* ! NO_SHARED_MEMORY */
    1.59  
    1.60  /* Various screen update functions available */
    1.61 -static void X11_NormalUpdate (_THIS, int numrects, SDL_Rect * rects);
    1.62 -static void X11_MITSHMUpdate (_THIS, int numrects, SDL_Rect * rects);
    1.63 +static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect * rects);
    1.64 +static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect * rects);
    1.65  
    1.66  int
    1.67 -X11_SetupImage (_THIS, SDL_Surface * screen)
    1.68 +X11_SetupImage(_THIS, SDL_Surface * screen)
    1.69  {
    1.70  #ifndef NO_SHARED_MEMORY
    1.71 -    try_mitshm (this, screen);
    1.72 +    try_mitshm(this, screen);
    1.73      if (use_mitshm) {
    1.74 -        SDL_Ximage = XShmCreateImage (SDL_Display, SDL_Visual,
    1.75 -                                      this->hidden->depth, ZPixmap,
    1.76 -                                      shminfo.shmaddr, &shminfo,
    1.77 -                                      screen->w, screen->h);
    1.78 +        SDL_Ximage = XShmCreateImage(SDL_Display, SDL_Visual,
    1.79 +                                     this->hidden->depth, ZPixmap,
    1.80 +                                     shminfo.shmaddr, &shminfo,
    1.81 +                                     screen->w, screen->h);
    1.82          if (!SDL_Ximage) {
    1.83 -            XShmDetach (SDL_Display, &shminfo);
    1.84 -            XSync (SDL_Display, False);
    1.85 -            shmdt (shminfo.shmaddr);
    1.86 +            XShmDetach(SDL_Display, &shminfo);
    1.87 +            XSync(SDL_Display, False);
    1.88 +            shmdt(shminfo.shmaddr);
    1.89              screen->pixels = NULL;
    1.90              goto error;
    1.91          }
    1.92 @@ -106,16 +106,16 @@
    1.93  #endif /* not NO_SHARED_MEMORY */
    1.94      {
    1.95          int bpp;
    1.96 -        screen->pixels = SDL_malloc (screen->h * screen->pitch);
    1.97 +        screen->pixels = SDL_malloc(screen->h * screen->pitch);
    1.98          if (screen->pixels == NULL) {
    1.99 -            SDL_OutOfMemory ();
   1.100 +            SDL_OutOfMemory();
   1.101              return -1;
   1.102          }
   1.103          bpp = screen->format->BytesPerPixel;
   1.104 -        SDL_Ximage = XCreateImage (SDL_Display, SDL_Visual,
   1.105 -                                   this->hidden->depth, ZPixmap, 0,
   1.106 -                                   (char *) screen->pixels,
   1.107 -                                   screen->w, screen->h, 32, 0);
   1.108 +        SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual,
   1.109 +                                  this->hidden->depth, ZPixmap, 0,
   1.110 +                                  (char *) screen->pixels,
   1.111 +                                  screen->w, screen->h, 32, 0);
   1.112          if (SDL_Ximage == NULL)
   1.113              goto error;
   1.114          /* XPutImage will convert byte sex automatically */
   1.115 @@ -127,20 +127,20 @@
   1.116      return (0);
   1.117  
   1.118    error:
   1.119 -    SDL_SetError ("Couldn't create XImage");
   1.120 +    SDL_SetError("Couldn't create XImage");
   1.121      return 1;
   1.122  }
   1.123  
   1.124  void
   1.125 -X11_DestroyImage (_THIS, SDL_Surface * screen)
   1.126 +X11_DestroyImage(_THIS, SDL_Surface * screen)
   1.127  {
   1.128      if (SDL_Ximage) {
   1.129 -        XDestroyImage (SDL_Ximage);
   1.130 +        XDestroyImage(SDL_Ximage);
   1.131  #ifndef NO_SHARED_MEMORY
   1.132          if (use_mitshm) {
   1.133 -            XShmDetach (SDL_Display, &shminfo);
   1.134 -            XSync (SDL_Display, False);
   1.135 -            shmdt (shminfo.shmaddr);
   1.136 +            XShmDetach(SDL_Display, &shminfo);
   1.137 +            XSync(SDL_Display, False);
   1.138 +            shmdt(shminfo.shmaddr);
   1.139          }
   1.140  #endif /* ! NO_SHARED_MEMORY */
   1.141          SDL_Ximage = NULL;
   1.142 @@ -152,30 +152,30 @@
   1.143  
   1.144  /* Determine the number of CPUs in the system */
   1.145  static int
   1.146 -num_CPU (void)
   1.147 +num_CPU(void)
   1.148  {
   1.149      static int num_cpus = 0;
   1.150  
   1.151      if (!num_cpus) {
   1.152  #if defined(__LINUX__)
   1.153          char line[BUFSIZ];
   1.154 -        FILE *pstat = fopen ("/proc/stat", "r");
   1.155 +        FILE *pstat = fopen("/proc/stat", "r");
   1.156          if (pstat) {
   1.157 -            while (fgets (line, sizeof (line), pstat)) {
   1.158 -                if (SDL_memcmp (line, "cpu", 3) == 0 && line[3] != ' ') {
   1.159 +            while (fgets(line, sizeof(line), pstat)) {
   1.160 +                if (SDL_memcmp(line, "cpu", 3) == 0 && line[3] != ' ') {
   1.161                      ++num_cpus;
   1.162                  }
   1.163              }
   1.164 -            fclose (pstat);
   1.165 +            fclose(pstat);
   1.166          }
   1.167  #elif defined(__IRIX__)
   1.168 -        num_cpus = sysconf (_SC_NPROC_ONLN);
   1.169 +        num_cpus = sysconf(_SC_NPROC_ONLN);
   1.170  #elif defined(_SC_NPROCESSORS_ONLN)
   1.171          /* number of processors online (SVR4.0MP compliant machines) */
   1.172 -        num_cpus = sysconf (_SC_NPROCESSORS_ONLN);
   1.173 +        num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
   1.174  #elif defined(_SC_NPROCESSORS_CONF)
   1.175          /* number of processors configured (SVR4.0MP compliant machines) */
   1.176 -        num_cpus = sysconf (_SC_NPROCESSORS_CONF);
   1.177 +        num_cpus = sysconf(_SC_NPROCESSORS_CONF);
   1.178  #endif
   1.179          if (num_cpus <= 0) {
   1.180              num_cpus = 1;
   1.181 @@ -185,15 +185,15 @@
   1.182  }
   1.183  
   1.184  int
   1.185 -X11_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags)
   1.186 +X11_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags)
   1.187  {
   1.188      int retval;
   1.189  
   1.190 -    X11_DestroyImage (this, screen);
   1.191 +    X11_DestroyImage(this, screen);
   1.192      if (flags & SDL_INTERNALOPENGL) {   /* No image when using GL */
   1.193          retval = 0;
   1.194      } else {
   1.195 -        retval = X11_SetupImage (this, screen);
   1.196 +        retval = X11_SetupImage(this, screen);
   1.197          /* We support asynchronous blitting on the display */
   1.198          if (flags & SDL_ASYNCBLIT) {
   1.199              /* This is actually slower on single-CPU systems,
   1.200 @@ -201,7 +201,7 @@
   1.201                 X server and the application.
   1.202                 Note: Is this still true with XFree86 4.0?
   1.203               */
   1.204 -            if (num_CPU () > 1) {
   1.205 +            if (num_CPU() > 1) {
   1.206                  screen->flags |= SDL_ASYNCBLIT;
   1.207              }
   1.208          }
   1.209 @@ -211,41 +211,41 @@
   1.210  
   1.211  /* We don't actually allow hardware surfaces other than the main one */
   1.212  int
   1.213 -X11_AllocHWSurface (_THIS, SDL_Surface * surface)
   1.214 +X11_AllocHWSurface(_THIS, SDL_Surface * surface)
   1.215  {
   1.216      return (-1);
   1.217  }
   1.218  
   1.219  void
   1.220 -X11_FreeHWSurface (_THIS, SDL_Surface * surface)
   1.221 +X11_FreeHWSurface(_THIS, SDL_Surface * surface)
   1.222  {
   1.223      return;
   1.224  }
   1.225  
   1.226  int
   1.227 -X11_LockHWSurface (_THIS, SDL_Surface * surface)
   1.228 +X11_LockHWSurface(_THIS, SDL_Surface * surface)
   1.229  {
   1.230      if ((surface == SDL_VideoSurface) && blit_queued) {
   1.231 -        XSync (GFX_Display, False);
   1.232 +        XSync(GFX_Display, False);
   1.233          blit_queued = 0;
   1.234      }
   1.235      return (0);
   1.236  }
   1.237  
   1.238  void
   1.239 -X11_UnlockHWSurface (_THIS, SDL_Surface * surface)
   1.240 +X11_UnlockHWSurface(_THIS, SDL_Surface * surface)
   1.241  {
   1.242      return;
   1.243  }
   1.244  
   1.245  int
   1.246 -X11_FlipHWSurface (_THIS, SDL_Surface * surface)
   1.247 +X11_FlipHWSurface(_THIS, SDL_Surface * surface)
   1.248  {
   1.249      return (0);
   1.250  }
   1.251  
   1.252  static void
   1.253 -X11_NormalUpdate (_THIS, int numrects, SDL_Rect * rects)
   1.254 +X11_NormalUpdate(_THIS, int numrects, SDL_Rect * rects)
   1.255  {
   1.256      int i;
   1.257  
   1.258 @@ -253,20 +253,20 @@
   1.259          if (rects[i].w == 0 || rects[i].h == 0) {       /* Clipped? */
   1.260              continue;
   1.261          }
   1.262 -        XPutImage (GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
   1.263 -                   rects[i].x, rects[i].y,
   1.264 -                   rects[i].x, rects[i].y, rects[i].w, rects[i].h);
   1.265 +        XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
   1.266 +                  rects[i].x, rects[i].y,
   1.267 +                  rects[i].x, rects[i].y, rects[i].w, rects[i].h);
   1.268      }
   1.269      if (SDL_VideoSurface->flags & SDL_ASYNCBLIT) {
   1.270 -        XFlush (GFX_Display);
   1.271 +        XFlush(GFX_Display);
   1.272          blit_queued = 1;
   1.273      } else {
   1.274 -        XSync (GFX_Display, False);
   1.275 +        XSync(GFX_Display, False);
   1.276      }
   1.277  }
   1.278  
   1.279  static void
   1.280 -X11_MITSHMUpdate (_THIS, int numrects, SDL_Rect * rects)
   1.281 +X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect * rects)
   1.282  {
   1.283  #ifndef NO_SHARED_MEMORY
   1.284      int i;
   1.285 @@ -275,15 +275,15 @@
   1.286          if (rects[i].w == 0 || rects[i].h == 0) {       /* Clipped? */
   1.287              continue;
   1.288          }
   1.289 -        XShmPutImage (GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
   1.290 -                      rects[i].x, rects[i].y,
   1.291 -                      rects[i].x, rects[i].y, rects[i].w, rects[i].h, False);
   1.292 +        XShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
   1.293 +                     rects[i].x, rects[i].y,
   1.294 +                     rects[i].x, rects[i].y, rects[i].w, rects[i].h, False);
   1.295      }
   1.296      if (SDL_VideoSurface->flags & SDL_ASYNCBLIT) {
   1.297 -        XFlush (GFX_Display);
   1.298 +        XFlush(GFX_Display);
   1.299          blit_queued = 1;
   1.300      } else {
   1.301 -        XSync (GFX_Display, False);
   1.302 +        XSync(GFX_Display, False);
   1.303      }
   1.304  #endif /* ! NO_SHARED_MEMORY */
   1.305  }
   1.306 @@ -297,44 +297,44 @@
   1.307  static int enable_autorefresh = 1;
   1.308  
   1.309  void
   1.310 -X11_DisableAutoRefresh (_THIS)
   1.311 +X11_DisableAutoRefresh(_THIS)
   1.312  {
   1.313      --enable_autorefresh;
   1.314  }
   1.315  
   1.316  void
   1.317 -X11_EnableAutoRefresh (_THIS)
   1.318 +X11_EnableAutoRefresh(_THIS)
   1.319  {
   1.320      ++enable_autorefresh;
   1.321  }
   1.322  
   1.323  void
   1.324 -X11_RefreshDisplay (_THIS)
   1.325 +X11_RefreshDisplay(_THIS)
   1.326  {
   1.327      /* Don't refresh a display that doesn't have an image (like GL)
   1.328         Instead, post an expose event so the application can refresh.
   1.329       */
   1.330      if (!SDL_Ximage || (enable_autorefresh <= 0)) {
   1.331 -        SDL_PrivateExpose ();
   1.332 +        SDL_PrivateExpose();
   1.333          return;
   1.334      }
   1.335  #ifndef NO_SHARED_MEMORY
   1.336      if (this->UpdateRects == X11_MITSHMUpdate) {
   1.337 -        XShmPutImage (SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
   1.338 -                      0, 0, SDL_CurrentWindow.offset_x,
   1.339 -                      SDL_CurrentWindow.offset_y,
   1.340 -                      SDL_CurrentDisplay.current_mode.w,
   1.341 -                      SDL_CurrentDisplay.current_mode.h, False);
   1.342 +        XShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
   1.343 +                     0, 0, SDL_CurrentWindow.offset_x,
   1.344 +                     SDL_CurrentWindow.offset_y,
   1.345 +                     SDL_CurrentDisplay.current_mode.w,
   1.346 +                     SDL_CurrentDisplay.current_mode.h, False);
   1.347      } else
   1.348  #endif /* ! NO_SHARED_MEMORY */
   1.349      {
   1.350 -        XPutImage (SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
   1.351 -                   0, 0, SDL_CurrentWindow.offset_x,
   1.352 -                   SDL_CurrentWindow.offset_y,
   1.353 -                   SDL_CurrentDisplay.current_mode.w,
   1.354 -                   SDL_CurrentDisplay.current_mode.h);
   1.355 +        XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
   1.356 +                  0, 0, SDL_CurrentWindow.offset_x,
   1.357 +                  SDL_CurrentWindow.offset_y,
   1.358 +                  SDL_CurrentDisplay.current_mode.w,
   1.359 +                  SDL_CurrentDisplay.current_mode.h);
   1.360      }
   1.361 -    XSync (SDL_Display, False);
   1.362 +    XSync(SDL_Display, False);
   1.363  }
   1.364  
   1.365  /* vi: set ts=4 sw=4 expandtab: */