Split out some compiler-version-specific definitions into "compiler.h".

Split out 'getpixel' and 'putpixel' family of functions into "pixels.c" and "pixels.h" source files.
This commit is contained in:
William Kendrick 2006-02-18 08:42:23 +00:00
parent 410c156d16
commit 3b5f10c4fe
6 changed files with 374 additions and 284 deletions

View file

@ -950,11 +950,14 @@ install-man:
# Build the program!
tuxpaint: obj/tuxpaint.o obj/i18n.o obj/cursor.o $(HQXX_O) $(ARCH_LIBS)
tuxpaint: obj/tuxpaint.o obj/i18n.o obj/cursor.o obj/pixels.o \
$(HQXX_O) $(ARCH_LIBS)
@echo
@echo "...Linking Tux Paint..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-o tuxpaint obj/tuxpaint.o obj/i18n.o obj/cursor.o $(HQXX_O) \
-o tuxpaint \
obj/tuxpaint.o obj/i18n.o obj/cursor.o obj/pixels.o \
$(HQXX_O) \
$(ARCH_LIBS) $(SDL_LIBS) \
-lm $(ARCH_LINKS)
@$(RSRC_CMD)
@ -964,7 +967,8 @@ tuxpaint: obj/tuxpaint.o obj/i18n.o obj/cursor.o $(HQXX_O) $(ARCH_LIBS)
# Build the object for the program!
obj/tuxpaint.o: src/tuxpaint.c obj \
src/i18n.h src/cursor.h \
src/i18n.h src/cursor.h src/pixels.h \
src/compiler.h \
src/tools.h src/titles.h src/colors.h src/shapes.h \
src/magic.h src/sounds.h src/tip_tux.h src/great.h \
$(HQXX_H) \
@ -999,6 +1003,12 @@ obj/cursor.o: src/cursor.c src/cursor.h
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(MOUSE_CFLAGS) $(DEFS) \
-c src/cursor.c -o obj/cursor.o
obj/pixels.o: src/pixels.c src/pixels.h src/compiler.h
@echo
@echo "...Compiling pixel functions..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/pixels.c -o obj/pixels.o
obj/BeOS_Print.o: src/BeOS_Print.cpp obj src/BeOS_print.h
@echo

View file

@ -55,6 +55,11 @@ $Id$
* Split XBM cursor #includes and set/free functions into "cursor.h" and
"cursor.c" source files.
* Split out some compiler-version-specific definitions into "compiler.h".
* Split out 'getpixel' and 'putpixel' family of functions into
"pixels.c" and "pixels.h" source files.
* Made sure GPL notice was included in all other source files.
* Added script to create "locale" during Build process in Xcode on

57
src/compiler.h Normal file
View file

@ -0,0 +1,57 @@
#ifdef __GNUC__
// This version has strict type checking for safety.
// See the "unnecessary" pointer comparison. (from Linux)
#define min(x,y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x < _y ? _x : _y; })
#define max(x,y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x > _y ? _x : _y; })
#else
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#define clamp(lo,value,hi) (min(max(value,lo),hi))
// since gcc-2.5
#ifdef __GNUC__
#define NORETURN __attribute__((__noreturn__))
#define FUNCTION __attribute__((__const__)) // no access to global mem, even via ptr, and no side effect
#else
#define NORETURN
#define FUNCTION
#endif
#if !defined(restrict) && __STDC_VERSION__ < 199901
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 92
#define restrict __restrict__
#else
#warning No restrict keyword?
#define restrict
#endif
#endif
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
// won't alias anything, and aligned enough for anything
#define MALLOC __attribute__ ((__malloc__))
// no side effect, may read globals
#define PURE __attribute__ ((__pure__))
// tell gcc what to expect: if(unlikely(err)) die(err);
#define likely(x) __builtin_expect(!!(x),1)
#define unlikely(x) __builtin_expect(!!(x),0)
#define expected(x,y) __builtin_expect((x),(y))
#else
#define MALLOC
#define PURE
#define likely(x) (x)
#define unlikely(x) (x)
#define expected(x,y) (x)
#endif

247
src/pixels.c Normal file
View file

@ -0,0 +1,247 @@
/*
pixels.c
For Tux Paint
Pixel read/write functions
Copyright (c) 2002-2006 by Bill Kendrick and others
bill@newbreedsoftware.com
http://www.newbreedsoftware.com/tuxpaint/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - February 17, 2006
$Id$
*/
#include "pixels.h"
#include "compiler.h"
/* Draw a single pixel into the surface: */
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 */
/* Set the (correctly-sized) piece of data in the surface's RAM
* to the pixel value sent in: */
*p = pixel;
}
}
/* Draw a single pixel into the surface: */
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 */
/* Set the (correctly-sized) piece of data in the surface's RAM
* to the pixel value sent in: */
*(Uint16 *)p = pixel;
}
}
/* Draw a single pixel into the surface: */
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)
{
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: */
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 */
/* Set the (correctly-sized) piece of data in the surface's RAM
* to the pixel value sent in: */
*(Uint32 *)p = pixel; // 32-bit display
}
}
/* Get a pixel: */
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 ))
x = (x<0) ? 0 : surface->w - 1;
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 */
/* 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(*p);
}
/* Get a pixel: */
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 ))
x = (x<0) ? 0 : surface->w - 1;
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 */
/* 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(*(Uint16 *)p);
}
/* Get a pixel: */
Uint32 getpixel24(SDL_Surface * surface, int x, int y)
{
Uint8 * p;
Uint32 pixel;
/* get the X/Y values within the bounds of this surface */
if (unlikely( (unsigned)x > (unsigned)surface->w - 1u ))
x = (x<0) ? 0 : surface->w - 1;
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 */
/* 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) */
/* Depending on the byte-order, it could be stored RGB or BGR! */
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
pixel = p[0] << 16 | p[1] << 8 | p[2];
else
pixel = p[0] | p[1] << 8 | p[2] << 16;
return pixel;
}
/* Get a pixel: */
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 ))
x = (x<0) ? 0 : surface->w - 1;
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 */
/* 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
}
void (*putpixels[])(SDL_Surface *, int, int, Uint32) = {
putpixel8, putpixel8, putpixel16, putpixel24, putpixel32 };
Uint32 (*getpixels[])(SDL_Surface *, int, int) = {
getpixel8, getpixel8, getpixel16, getpixel24, getpixel32 };

50
src/pixels.h Normal file
View file

@ -0,0 +1,50 @@
/*
pixels.h
For Tux Paint
Pixel read/write functions
Copyright (c) 2002-2006 by Bill Kendrick and others
bill@newbreedsoftware.com
http://www.newbreedsoftware.com/tuxpaint/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - February 17, 2006
$Id$
*/
#ifndef PIXELS_H
#define PIXELS_H
#include "SDL.h"
void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel);
void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel);
void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel);
void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel);
extern void (*putpixels[])(SDL_Surface *, int, int, Uint32);
Uint32 getpixel8(SDL_Surface * surface, int x, int y);
Uint32 getpixel16(SDL_Surface * surface, int x, int y);
Uint32 getpixel24(SDL_Surface * surface, int x, int y);
Uint32 getpixel32(SDL_Surface * surface, int x, int y);
extern Uint32 (*getpixels[])(SDL_Surface *, int, int);
#endif

View file

@ -338,6 +338,7 @@ static int font_socket_fd;
#include "i18n.h"
#include "cursor.h"
#include "pixels.h"
#include "tools.h"
#include "titles.h"
@ -388,61 +389,7 @@ static int win32_isspace(int c)
#endif /* WIN32 */
#ifdef __GNUC__
// This version has strict type checking for safety.
// See the "unnecessary" pointer comparison. (from Linux)
#define min(x,y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x < _y ? _x : _y; })
#define max(x,y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x > _y ? _x : _y; })
#else
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#define clamp(lo,value,hi) (min(max(value,lo),hi))
// since gcc-2.5
#ifdef __GNUC__
#define NORETURN __attribute__((__noreturn__))
#define FUNCTION __attribute__((__const__)) // no access to global mem, even via ptr, and no side effect
#else
#define NORETURN
#define FUNCTION
#endif
#if !defined(restrict) && __STDC_VERSION__ < 199901
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 92
#define restrict __restrict__
#else
#warning No restrict keyword?
#define restrict
#endif
#endif
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
// won't alias anything, and aligned enough for anything
#define MALLOC __attribute__ ((__malloc__))
// no side effect, may read globals
#define PURE __attribute__ ((__pure__))
// tell gcc what to expect: if(unlikely(err)) die(err);
#define likely(x) __builtin_expect(!!(x),1)
#define unlikely(x) __builtin_expect(!!(x),0)
#define expected(x,y) __builtin_expect((x),(y))
#else
#define MALLOC
#define PURE
#define likely(x) (x)
#define unlikely(x) (x)
#define expected(x,y) (x)
#endif
#include "compiler.h"
/* Unfortunately, there is a bug in SDL_ttf-2.0.6, the current version
@ -1749,22 +1696,6 @@ static void draw_erasers(void);
static void draw_fonts(void);
static void draw_none(void);
static void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel);
static void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel);
static void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel);
static void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel);
static void (*putpixels[])(SDL_Surface *, int, int, Uint32) = {
putpixel8, putpixel8, putpixel16, putpixel24, putpixel32 };
static Uint32 getpixel8(SDL_Surface * surface, int x, int y);
static Uint32 getpixel16(SDL_Surface * surface, int x, int y);
static Uint32 getpixel24(SDL_Surface * surface, int x, int y);
static Uint32 getpixel32(SDL_Surface * surface, int x, int y);
static Uint32 (*getpixels[])(SDL_Surface *, int, int) = {
getpixel8, getpixel8, getpixel16, getpixel24, getpixel32 };
static void do_undo(void);
static void do_redo(void);
static void render_brush(void);
@ -9859,216 +9790,6 @@ static SDL_Surface * thumbnail2(SDL_Surface * src, int max_x, int max_y,
}
/* Get a pixel: */
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 ))
x = (x<0) ? 0 : surface->w - 1;
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 */
/* 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(*p);
}
/* Get a pixel: */
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 ))
x = (x<0) ? 0 : surface->w - 1;
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 */
/* 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(*(Uint16 *)p);
}
/* Get a pixel: */
static Uint32 getpixel24(SDL_Surface * surface, int x, int y)
{
Uint8 * p;
Uint32 pixel;
/* get the X/Y values within the bounds of this surface */
if (unlikely( (unsigned)x > (unsigned)surface->w - 1u ))
x = (x<0) ? 0 : surface->w - 1;
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 */
/* 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) */
/* Depending on the byte-order, it could be stored RGB or BGR! */
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
pixel = p[0] << 16 | p[1] << 8 | p[2];
else
pixel = p[0] | p[1] << 8 | p[2] << 16;
return pixel;
}
/* Get a pixel: */
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 ))
x = (x<0) ? 0 : surface->w - 1;
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 */
/* 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
}
/* Draw a single pixel into the surface: */
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 */
/* Set the (correctly-sized) piece of data in the surface's RAM
* to the pixel value sent in: */
*p = pixel;
}
}
/* Draw a single pixel into the surface: */
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 */
/* Set the (correctly-sized) piece of data in the surface's RAM
* to the pixel value sent in: */
*(Uint16 *)p = pixel;
}
}
/* Draw a single pixel into the surface: */
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)
{
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: */
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 */
/* Set the (correctly-sized) piece of data in the surface's RAM
* to the pixel value sent in: */
*(Uint32 *)p = pixel; // 32-bit display
}
}
// XOR must show up on black, white, 0x7f grey, and 0x80 grey.
// XOR must be exactly 100% perfectly reversable.