From 41893a9cdaf99b84509ade8f9e23fd1c95b2defa Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Sun, 15 Oct 2017 11:02:51 -0700 Subject: [PATCH] indent pixels.c pixels.h Note - no change to pixels.h --- src/pixels.c | 156 ++++++++++++++++++++++++--------------------------- 1 file changed, 74 insertions(+), 82 deletions(-) diff --git a/src/pixels.c b/src/pixels.c index a3737d6e9..5602b2fd7 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -37,21 +37,19 @@ static void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel) Uint8 *p; /* Assuming the X/Y values are within the bounds of this surface... */ - if (likely - (likely((unsigned) x < (unsigned) surface->w) - && likely((unsigned) y < (unsigned) surface->h))) - { - // Set a pointer to the exact location in memory of the pixel - p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ - (y * surface->pitch) + /* Go down Y lines */ - x); /* Go in X pixels */ + if (likely(likely((unsigned)x < (unsigned)surface->w) && likely((unsigned)y < (unsigned)surface->h))) + { + // Set a pointer to the exact location in memory of the pixel + p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ + (y * surface->pitch) + /* Go down Y lines */ + x); /* Go in X pixels */ - /* Set the (correctly-sized) piece of data in the surface's RAM - * to the pixel value sent in: */ + /* Set the (correctly-sized) piece of data in the surface's RAM + * to the pixel value sent in: */ - *p = pixel; - } + *p = pixel; + } } /* Draw a single pixel into the surface: */ @@ -60,21 +58,19 @@ static void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel) Uint8 *p; /* Assuming the X/Y values are within the bounds of this surface... */ - if (likely - (likely((unsigned) x < (unsigned) surface->w) - && likely((unsigned) y < (unsigned) surface->h))) - { - // Set a pointer to the exact location in memory of the pixel - p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ - (y * surface->pitch) + /* Go down Y lines */ - (x * 2)); /* Go in X pixels */ + if (likely(likely((unsigned)x < (unsigned)surface->w) && likely((unsigned)y < (unsigned)surface->h))) + { + // Set a pointer to the exact location in memory of the pixel + p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ + (y * surface->pitch) + /* Go down Y lines */ + (x * 2)); /* Go in X pixels */ - /* Set the (correctly-sized) piece of data in the surface's RAM - * to the pixel value sent in: */ + /* Set the (correctly-sized) piece of data in the surface's RAM + * to the pixel value sent in: */ - *(Uint16 *) p = pixel; - } + *(Uint16 *) p = pixel; + } } /* Draw a single pixel into the surface: */ @@ -83,33 +79,31 @@ static void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel) Uint8 *p; /* Assuming the X/Y values are within the bounds of this surface... */ - if (likely - (likely((unsigned) x < (unsigned) surface->w) - && likely((unsigned) y < (unsigned) surface->h))) - { - // Set a pointer to the exact location in memory of the pixel - p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ - (y * surface->pitch) + /* Go down Y lines */ - (x * 3)); /* Go in X pixels */ - - - /* Set the (correctly-sized) piece of data in the surface's RAM - * to the pixel value sent in: */ - - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + if (likely(likely((unsigned)x < (unsigned)surface->w) && likely((unsigned)y < (unsigned)surface->h))) { - p[0] = (pixel >> 16) & 0xff; - p[1] = (pixel >> 8) & 0xff; - p[2] = pixel & 0xff; - } - else - { - p[0] = pixel & 0xff; - p[1] = (pixel >> 8) & 0xff; - p[2] = (pixel >> 16) & 0xff; - } + // Set a pointer to the exact location in memory of the pixel + p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ + (y * surface->pitch) + /* Go down Y lines */ + (x * 3)); /* Go in X pixels */ - } + + /* Set the (correctly-sized) piece of data in the surface's RAM + * to the pixel value sent in: */ + + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + { + p[0] = (pixel >> 16) & 0xff; + p[1] = (pixel >> 8) & 0xff; + p[2] = pixel & 0xff; + } + else + { + p[0] = pixel & 0xff; + p[1] = (pixel >> 8) & 0xff; + p[2] = (pixel >> 16) & 0xff; + } + + } } /* Draw a single pixel into the surface: */ @@ -118,21 +112,19 @@ static void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel) Uint8 *p; /* Assuming the X/Y values are within the bounds of this surface... */ - if (likely - (likely((unsigned) x < (unsigned) surface->w) - && likely((unsigned) y < (unsigned) surface->h))) - { - // Set a pointer to the exact location in memory of the pixel - p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ - (y * surface->pitch) + /* Go down Y lines */ - (x * 4)); /* Go in X pixels */ + if (likely(likely((unsigned)x < (unsigned)surface->w) && likely((unsigned)y < (unsigned)surface->h))) + { + // Set a pointer to the exact location in memory of the pixel + p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ + (y * surface->pitch) + /* Go down Y lines */ + (x * 4)); /* Go in X pixels */ - /* Set the (correctly-sized) piece of data in the surface's RAM - * to the pixel value sent in: */ + /* Set the (correctly-sized) piece of data in the surface's RAM + * to the pixel value sent in: */ - *(Uint32 *) p = pixel; // 32-bit display - } + *(Uint32 *) p = pixel; // 32-bit display + } } /* Get a pixel: */ @@ -141,17 +133,17 @@ static Uint32 getpixel8(SDL_Surface * surface, int x, int y) Uint8 *p; /* get the X/Y values within the bounds of this surface */ - if (unlikely((unsigned) x > (unsigned) surface->w - 1u)) + if (unlikely((unsigned)x > (unsigned)surface->w - 1u)) x = (x < 0) ? 0 : surface->w - 1; - if (unlikely((unsigned) y > (unsigned) surface->h - 1u)) + if (unlikely((unsigned)y > (unsigned)surface->h - 1u)) y = (y < 0) ? 0 : surface->h - 1; /* Set a pointer to the exact location in memory of the pixel in question: */ - p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */ - (y * surface->pitch) + /* Go down Y lines */ - x); /* Go in X pixels */ + p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */ + (y * surface->pitch) + /* Go down Y lines */ + x); /* Go in X pixels */ /* Return the correctly-sized piece of data containing the @@ -167,17 +159,17 @@ static Uint32 getpixel16(SDL_Surface * surface, int x, int y) Uint8 *p; /* get the X/Y values within the bounds of this surface */ - if (unlikely((unsigned) x > (unsigned) surface->w - 1u)) + if (unlikely((unsigned)x > (unsigned)surface->w - 1u)) x = (x < 0) ? 0 : surface->w - 1; - if (unlikely((unsigned) y > (unsigned) surface->h - 1u)) + if (unlikely((unsigned)y > (unsigned)surface->h - 1u)) y = (y < 0) ? 0 : surface->h - 1; /* Set a pointer to the exact location in memory of the pixel in question: */ - p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */ - (y * surface->pitch) + /* Go down Y lines */ - (x * 2)); /* Go in X pixels */ + p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */ + (y * surface->pitch) + /* Go down Y lines */ + (x * 2)); /* Go in X pixels */ /* Return the correctly-sized piece of data containing the @@ -194,17 +186,17 @@ static Uint32 getpixel24(SDL_Surface * surface, int x, int y) Uint32 pixel; /* get the X/Y values within the bounds of this surface */ - if (unlikely((unsigned) x > (unsigned) surface->w - 1u)) + if (unlikely((unsigned)x > (unsigned)surface->w - 1u)) x = (x < 0) ? 0 : surface->w - 1; - if (unlikely((unsigned) y > (unsigned) surface->h - 1u)) + if (unlikely((unsigned)y > (unsigned)surface->h - 1u)) y = (y < 0) ? 0 : surface->h - 1; /* Set a pointer to the exact location in memory of the pixel in question: */ - p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */ - (y * surface->pitch) + /* Go down Y lines */ - (x * 3)); /* Go in X pixels */ + p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */ + (y * surface->pitch) + /* Go down Y lines */ + (x * 3)); /* Go in X pixels */ /* Return the correctly-sized piece of data containing the @@ -227,24 +219,24 @@ static Uint32 getpixel32(SDL_Surface * surface, int x, int y) Uint8 *p; /* get the X/Y values within the bounds of this surface */ - if (unlikely((unsigned) x > (unsigned) surface->w - 1u)) + if (unlikely((unsigned)x > (unsigned)surface->w - 1u)) x = (x < 0) ? 0 : surface->w - 1; - if (unlikely((unsigned) y > (unsigned) surface->h - 1u)) + if (unlikely((unsigned)y > (unsigned)surface->h - 1u)) y = (y < 0) ? 0 : surface->h - 1; /* Set a pointer to the exact location in memory of the pixel in question: */ - p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */ - (y * surface->pitch) + /* Go down Y lines */ - (x * 4)); /* Go in X pixels */ + p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */ + (y * surface->pitch) + /* Go down Y lines */ + (x * 4)); /* Go in X pixels */ /* Return the correctly-sized piece of data containing the * pixel's value (an 8-bit palette value, or a 16-, 24- or 32-bit * RGB value) */ - return *(Uint32 *) p; // 32-bit display + return *(Uint32 *) p; // 32-bit display } void (*putpixels[]) (SDL_Surface *, int, int, Uint32) =