Commit d0b1ee8e authored by Sam Lantinga's avatar Sam Lantinga

indent

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403516
parent 9bb60da0
...@@ -97,21 +97,21 @@ X11_TrackColormap(Display * display, int scrNum, Colormap colormap, ...@@ -97,21 +97,21 @@ X11_TrackColormap(Display * display, int scrNum, Colormap colormap,
cmapTable[numCmaps].ramp = NULL; cmapTable[numCmaps].ramp = NULL;
if (ramp != NULL) { if (ramp != NULL) {
newramp = SDL_malloc(SDL_GammaRampSize); newramp = SDL_malloc(SDL_GammaRampSize);
if (NULL == newramp) { if (NULL == newramp) {
SDL_SetError("Out of memory in X11_TrackColormap()"); SDL_SetError("Out of memory in X11_TrackColormap()");
return; return;
} }
SDL_memset(newramp, 0, SDL_GammaRampSize); SDL_memset(newramp, 0, SDL_GammaRampSize);
cmapTable[numCmaps].ramp = newramp; cmapTable[numCmaps].ramp = newramp;
ncolors = cmapTable[numCmaps].visual.map_entries; ncolors = cmapTable[numCmaps].visual.map_entries;
for (i = 0; i < ncolors; i++) { for (i = 0; i < ncolors; i++) {
newramp[(0 * 256) + i] = ramp[i].red; newramp[(0 * 256) + i] = ramp[i].red;
newramp[(1 * 256) + i] = ramp[i].green; newramp[(1 * 256) + i] = ramp[i].green;
newramp[(2 * 256) + i] = ramp[i].blue; newramp[(2 * 256) + i] = ramp[i].blue;
} }
} }
numCmaps++; numCmaps++;
...@@ -149,14 +149,14 @@ X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp) ...@@ -149,14 +149,14 @@ X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
return -1; return -1;
} }
/* remember the new ramp */ /* remember the new ramp */
if (cmapTable[j].ramp == NULL) { if (cmapTable[j].ramp == NULL) {
Uint16 * newramp = SDL_malloc(SDL_GammaRampSize); Uint16 *newramp = SDL_malloc(SDL_GammaRampSize);
if (NULL == newramp) { if (NULL == newramp) {
SDL_SetError("Out of memory in X11_TrackColormap()"); SDL_SetError("Out of memory in X11_TrackColormap()");
return -1; return -1;
} }
cmapTable[j].ramp = newramp; cmapTable[j].ramp = newramp;
} }
SDL_memcpy(cmapTable[j].ramp, ramp, SDL_GammaRampSize); SDL_memcpy(cmapTable[j].ramp, ramp, SDL_GammaRampSize);
rshift = 0; rshift = 0;
......
...@@ -220,14 +220,14 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -220,14 +220,14 @@ X11_CreateWindow(_THIS, SDL_Window * window)
XStandardColormap cmap; XStandardColormap cmap;
XColor *colorcells; XColor *colorcells;
Colormap colormap; Colormap colormap;
Sint32 pix; Sint32 pix;
Sint32 ncolors; Sint32 ncolors;
Sint32 nbits; Sint32 nbits;
Sint32 rmax, gmax, bmax; Sint32 rmax, gmax, bmax;
Sint32 rwidth, gwidth, bwidth; Sint32 rwidth, gwidth, bwidth;
Sint32 rmask, gmask, bmask; Sint32 rmask, gmask, bmask;
Sint32 rshift, gshift, bshift; Sint32 rshift, gshift, bshift;
Sint32 r, g, b; Sint32 r, g, b;
/* Is the colormap we need already registered in SDL? */ /* Is the colormap we need already registered in SDL? */
if (colormap = if (colormap =
...@@ -259,26 +259,26 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -259,26 +259,26 @@ X11_CreateWindow(_THIS, SDL_Window * window)
} }
ncolors = visual->map_entries; ncolors = visual->map_entries;
nbits = visual->bits_per_rgb; nbits = visual->bits_per_rgb;
/* printf("ncolors = %d nbits = %d\n", ncolors, nbits); */ /* printf("ncolors = %d nbits = %d\n", ncolors, nbits); */
/* what if ncolors != (1 << nbits)? That can happen on a /* what if ncolors != (1 << nbits)? That can happen on a
true PseudoColor display. I'm assuming that we will true PseudoColor display. I'm assuming that we will
always have ncolors == (1 << nbits)*/ always have ncolors == (1 << nbits) */
/* I'm making a lot of assumptions here. */ /* I'm making a lot of assumptions here. */
/* Compute the width of each field. If there is one extra
bit, give it to green. If there are two extra bits give
them to red and greed. We can get extra bits when the
number of bits per pixel is not a multiple of 3. For
example when we have 16 bits per pixel and need a 5/6/5
layout for the RGB fields */
rwidth = (nbits / 3) + (((nbits % 3) == 2) ? 1 : 0); /* Compute the width of each field. If there is one extra
gwidth = (nbits / 3) + (((nbits % 3) >= 1) ? 1 : 0); bit, give it to green. If there are two extra bits give
bwidth = (nbits / 3); them to red and greed. We can get extra bits when the
number of bits per pixel is not a multiple of 3. For
example when we have 16 bits per pixel and need a 5/6/5
layout for the RGB fields */
rwidth = (nbits / 3) + (((nbits % 3) == 2) ? 1 : 0);
gwidth = (nbits / 3) + (((nbits % 3) >= 1) ? 1 : 0);
bwidth = (nbits / 3);
rshift = gwidth + bwidth; rshift = gwidth + bwidth;
gshift = bwidth; gshift = bwidth;
...@@ -297,24 +297,25 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -297,24 +297,25 @@ X11_CreateWindow(_THIS, SDL_Window * window)
/* printf("blue mask = %4x shift = %4d width = %d\n", bmask, bshift, bwidth); */ /* printf("blue mask = %4x shift = %4d width = %d\n", bmask, bshift, bwidth); */
/* build the color table pixel values */ /* build the color table pixel values */
pix = 0; pix = 0;
for (r = 0; r < rmax; r++) { for (r = 0; r < rmax; r++) {
for (g = 0; g < gmax; g++) { for (g = 0; g < gmax; g++) {
for (b = 0; b < bmax; b++) { for (b = 0; b < bmax; b++) {
colorcells[pix].pixel = (r << rshift) | (g << gshift) | (b << bshift); colorcells[pix].pixel =
colorcells[pix].red = (0xffff * r) / rmask; (r << rshift) | (g << gshift) | (b << bshift);
colorcells[pix].green = (0xffff * g) / gmask; colorcells[pix].red = (0xffff * r) / rmask;
colorcells[pix].blue = (0xffff * b) / bmask; colorcells[pix].green = (0xffff * g) / gmask;
colorcells[pix].blue = (0xffff * b) / bmask;
/* printf("%4x:%4x [%4x %4x %4x]\n", */ /* printf("%4x:%4x [%4x %4x %4x]\n", */
/* pix, */ /* pix, */
/* colorcells[pix].pixel, */ /* colorcells[pix].pixel, */
/* colorcells[pix].red, */ /* colorcells[pix].red, */
/* colorcells[pix].green, */ /* colorcells[pix].green, */
/* colorcells[pix].blue); */ /* colorcells[pix].blue); */
pix++; pix++;
} }
} }
} }
/* status = */ /* status = */
/* XStoreColors(data->display, colormap, colorcells, ncolors); */ /* XStoreColors(data->display, colormap, colorcells, ncolors); */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment