indent
authorSam Lantinga <slouken@libsdl.org>
Fri, 30 Jan 2009 06:38:44 +0000
changeset 3052b7197d7e8566
parent 3051 1a45bc89db0c
child 3053 aa34d1180d30
indent
src/video/x11/SDL_x11gamma.c
src/video/x11/SDL_x11window.c
     1.1 --- a/src/video/x11/SDL_x11gamma.c	Thu Jan 29 13:25:08 2009 +0000
     1.2 +++ b/src/video/x11/SDL_x11gamma.c	Fri Jan 30 06:38:44 2009 +0000
     1.3 @@ -97,21 +97,21 @@
     1.4      cmapTable[numCmaps].ramp = NULL;
     1.5  
     1.6      if (ramp != NULL) {
     1.7 -      newramp = SDL_malloc(SDL_GammaRampSize);
     1.8 -      if (NULL == newramp) {
     1.9 -        SDL_SetError("Out of memory in X11_TrackColormap()");
    1.10 -        return;
    1.11 -      }
    1.12 -      SDL_memset(newramp, 0, SDL_GammaRampSize);
    1.13 -      cmapTable[numCmaps].ramp = newramp;
    1.14 +        newramp = SDL_malloc(SDL_GammaRampSize);
    1.15 +        if (NULL == newramp) {
    1.16 +            SDL_SetError("Out of memory in X11_TrackColormap()");
    1.17 +            return;
    1.18 +        }
    1.19 +        SDL_memset(newramp, 0, SDL_GammaRampSize);
    1.20 +        cmapTable[numCmaps].ramp = newramp;
    1.21  
    1.22 -      ncolors = cmapTable[numCmaps].visual.map_entries;
    1.23 +        ncolors = cmapTable[numCmaps].visual.map_entries;
    1.24  
    1.25 -      for (i = 0; i < ncolors; i++) {
    1.26 -        newramp[(0 * 256) + i] = ramp[i].red;
    1.27 -        newramp[(1 * 256) + i] = ramp[i].green;
    1.28 -        newramp[(2 * 256) + i] = ramp[i].blue;
    1.29 -      }
    1.30 +        for (i = 0; i < ncolors; i++) {
    1.31 +            newramp[(0 * 256) + i] = ramp[i].red;
    1.32 +            newramp[(1 * 256) + i] = ramp[i].green;
    1.33 +            newramp[(2 * 256) + i] = ramp[i].blue;
    1.34 +        }
    1.35      }
    1.36  
    1.37      numCmaps++;
    1.38 @@ -149,14 +149,14 @@
    1.39                  return -1;
    1.40              }
    1.41              /* remember the new ramp */
    1.42 -	    if (cmapTable[j].ramp == NULL) {
    1.43 -	      Uint16 * newramp = SDL_malloc(SDL_GammaRampSize);
    1.44 -	      if (NULL == newramp) {
    1.45 -		SDL_SetError("Out of memory in X11_TrackColormap()");
    1.46 -		return -1;
    1.47 -	      }
    1.48 -	      cmapTable[j].ramp = newramp;
    1.49 -	    }
    1.50 +            if (cmapTable[j].ramp == NULL) {
    1.51 +                Uint16 *newramp = SDL_malloc(SDL_GammaRampSize);
    1.52 +                if (NULL == newramp) {
    1.53 +                    SDL_SetError("Out of memory in X11_TrackColormap()");
    1.54 +                    return -1;
    1.55 +                }
    1.56 +                cmapTable[j].ramp = newramp;
    1.57 +            }
    1.58              SDL_memcpy(cmapTable[j].ramp, ramp, SDL_GammaRampSize);
    1.59  
    1.60              rshift = 0;
     2.1 --- a/src/video/x11/SDL_x11window.c	Thu Jan 29 13:25:08 2009 +0000
     2.2 +++ b/src/video/x11/SDL_x11window.c	Fri Jan 30 06:38:44 2009 +0000
     2.3 @@ -220,14 +220,14 @@
     2.4          XStandardColormap cmap;
     2.5          XColor *colorcells;
     2.6          Colormap colormap;
     2.7 -	Sint32 pix;
     2.8 +        Sint32 pix;
     2.9          Sint32 ncolors;
    2.10          Sint32 nbits;
    2.11          Sint32 rmax, gmax, bmax;
    2.12 -	Sint32 rwidth, gwidth, bwidth;
    2.13 +        Sint32 rwidth, gwidth, bwidth;
    2.14          Sint32 rmask, gmask, bmask;
    2.15          Sint32 rshift, gshift, bshift;
    2.16 -	Sint32 r, g, b;
    2.17 +        Sint32 r, g, b;
    2.18  
    2.19          /* Is the colormap we need already registered in SDL? */
    2.20          if (colormap =
    2.21 @@ -259,26 +259,26 @@
    2.22              }
    2.23  
    2.24              ncolors = visual->map_entries;
    2.25 -	    nbits = visual->bits_per_rgb;
    2.26 +            nbits = visual->bits_per_rgb;
    2.27  
    2.28  /* 	    printf("ncolors = %d nbits = %d\n", ncolors, nbits); */
    2.29  
    2.30 -	    /* what if ncolors != (1 << nbits)? That can happen on a
    2.31 -	       true PseudoColor display.  I'm assuming that we will
    2.32 -	       always have ncolors == (1 << nbits)*/
    2.33 +            /* what if ncolors != (1 << nbits)? That can happen on a
    2.34 +               true PseudoColor display.  I'm assuming that we will
    2.35 +               always have ncolors == (1 << nbits) */
    2.36  
    2.37 -	    /* I'm making a lot of assumptions here. */
    2.38 -	    
    2.39 -	    /* Compute the width of each field. If there is one extra
    2.40 -	       bit, give it to green. If there are two extra bits give
    2.41 -	       them to red and greed.  We can get extra bits when the
    2.42 -	       number of bits per pixel is not a multiple of 3. For
    2.43 -	       example when we have 16 bits per pixel and need a 5/6/5
    2.44 -	       layout for the RGB fields */
    2.45 +            /* I'm making a lot of assumptions here. */
    2.46  
    2.47 -	    rwidth = (nbits / 3) + (((nbits % 3) == 2) ? 1 : 0);
    2.48 -	    gwidth = (nbits / 3) + (((nbits % 3) >= 1) ? 1 : 0);
    2.49 -	    bwidth = (nbits / 3);
    2.50 +            /* Compute the width of each field. If there is one extra
    2.51 +               bit, give it to green. If there are two extra bits give
    2.52 +               them to red and greed.  We can get extra bits when the
    2.53 +               number of bits per pixel is not a multiple of 3. For
    2.54 +               example when we have 16 bits per pixel and need a 5/6/5
    2.55 +               layout for the RGB fields */
    2.56 +
    2.57 +            rwidth = (nbits / 3) + (((nbits % 3) == 2) ? 1 : 0);
    2.58 +            gwidth = (nbits / 3) + (((nbits % 3) >= 1) ? 1 : 0);
    2.59 +            bwidth = (nbits / 3);
    2.60  
    2.61              rshift = gwidth + bwidth;
    2.62              gshift = bwidth;
    2.63 @@ -297,24 +297,25 @@
    2.64  /*             printf("blue  mask = %4x shift = %4d width = %d\n", bmask, bshift, bwidth); */
    2.65  
    2.66              /* build the color table pixel values */
    2.67 -	    pix = 0;
    2.68 -	    for (r = 0; r < rmax; r++) {
    2.69 -	      for (g = 0; g < gmax; g++) {
    2.70 -		for (b = 0; b < bmax; b++) {
    2.71 -		  colorcells[pix].pixel = (r << rshift) | (g << gshift) | (b << bshift);
    2.72 -		  colorcells[pix].red   = (0xffff * r) / rmask;
    2.73 -		  colorcells[pix].green = (0xffff * g) / gmask;
    2.74 -		  colorcells[pix].blue  = (0xffff * b) / bmask;
    2.75 +            pix = 0;
    2.76 +            for (r = 0; r < rmax; r++) {
    2.77 +                for (g = 0; g < gmax; g++) {
    2.78 +                    for (b = 0; b < bmax; b++) {
    2.79 +                        colorcells[pix].pixel =
    2.80 +                            (r << rshift) | (g << gshift) | (b << bshift);
    2.81 +                        colorcells[pix].red = (0xffff * r) / rmask;
    2.82 +                        colorcells[pix].green = (0xffff * g) / gmask;
    2.83 +                        colorcells[pix].blue = (0xffff * b) / bmask;
    2.84  /* 		  printf("%4x:%4x [%4x %4x %4x]\n",  */
    2.85  /* 			 pix,  */
    2.86  /* 			 colorcells[pix].pixel, */
    2.87  /* 			 colorcells[pix].red, */
    2.88  /* 			 colorcells[pix].green, */
    2.89  /* 			 colorcells[pix].blue); */
    2.90 -		  pix++;
    2.91 -		}
    2.92 -	      }
    2.93 -	    }
    2.94 +                        pix++;
    2.95 +                    }
    2.96 +                }
    2.97 +            }
    2.98  
    2.99  /*             status = */
   2.100  /*                 XStoreColors(data->display, colormap, colorcells, ncolors); */