21 #include "../SDL_internal.h"
36 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
40 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 255
44 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246, 250, 255
48 0, 8, 16, 24, 32, 41, 49, 57, 65, 74, 82, 90, 98, 106, 115, 123, 131, 139, 148, 156, 164, 172, 180, 189, 197, 205, 213, 222, 230, 238, 246, 255
52 0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255
56 0, 36, 72, 109, 145, 182, 218, 255
89 #define CASE(X) case X: return #X;
130 return "SDL_PIXELFORMAT_UNKNOWN";
152 *Rmask = *Gmask = *Bmask = *Amask = 0;
155 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
168 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
189 masks[0] = 0x00000000;
190 masks[1] = 0x000000E0;
191 masks[2] = 0x0000001C;
192 masks[3] = 0x00000003;
195 masks[0] = 0x0000F000;
196 masks[1] = 0x00000F00;
197 masks[2] = 0x000000F0;
198 masks[3] = 0x0000000F;
201 masks[0] = 0x00008000;
202 masks[1] = 0x00007C00;
203 masks[2] = 0x000003E0;
204 masks[3] = 0x0000001F;
207 masks[0] = 0x0000F800;
208 masks[1] = 0x000007C0;
209 masks[2] = 0x0000003E;
210 masks[3] = 0x00000001;
213 masks[0] = 0x00000000;
214 masks[1] = 0x0000F800;
215 masks[2] = 0x000007E0;
216 masks[3] = 0x0000001F;
219 masks[0] = 0xFF000000;
220 masks[1] = 0x00FF0000;
221 masks[2] = 0x0000FF00;
222 masks[3] = 0x000000FF;
225 masks[0] = 0xC0000000;
226 masks[1] = 0x3FF00000;
227 masks[2] = 0x000FFC00;
228 masks[3] = 0x000003FF;
231 masks[0] = 0xFFC00000;
232 masks[1] = 0x003FF000;
233 masks[2] = 0x00000FFC;
234 masks[3] = 0x00000003;
319 if (Rmask == 0x0F00 &&
325 if (Rmask == 0x000F &&
341 if (Rmask == 0x7C00 &&
347 if (Rmask == 0x001F &&
353 if (Rmask == 0x0F00 &&
359 if (Rmask == 0xF000 &&
365 if (Rmask == 0x000F &&
371 if (Rmask == 0x00F0 &&
377 if (Rmask == 0x7C00 &&
383 if (Rmask == 0xF800 &&
389 if (Rmask == 0x001F &&
395 if (Rmask == 0x003E &&
401 if (Rmask == 0xF800 &&
407 if (Rmask == 0x001F &&
413 if (Rmask == 0x003F &&
425 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
431 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
441 if (Rmask == 0x00FF0000 &&
442 Gmask == 0x0000FF00 &&
443 Bmask == 0x000000FF &&
444 Amask == 0x00000000) {
447 if (Rmask == 0xFF000000 &&
448 Gmask == 0x00FF0000 &&
449 Bmask == 0x0000FF00 &&
450 Amask == 0x00000000) {
453 if (Rmask == 0x000000FF &&
454 Gmask == 0x0000FF00 &&
455 Bmask == 0x00FF0000 &&
456 Amask == 0x00000000) {
459 if (Rmask == 0x0000FF00 &&
460 Gmask == 0x00FF0000 &&
461 Bmask == 0xFF000000 &&
462 Amask == 0x00000000) {
465 if (Rmask == 0x00FF0000 &&
466 Gmask == 0x0000FF00 &&
467 Bmask == 0x000000FF &&
468 Amask == 0xFF000000) {
471 if (Rmask == 0xFF000000 &&
472 Gmask == 0x00FF0000 &&
473 Bmask == 0x0000FF00 &&
474 Amask == 0x000000FF) {
477 if (Rmask == 0x000000FF &&
478 Gmask == 0x0000FF00 &&
479 Bmask == 0x00FF0000 &&
480 Amask == 0xFF000000) {
483 if (Rmask == 0x0000FF00 &&
484 Gmask == 0x00FF0000 &&
485 Bmask == 0xFF000000 &&
486 Amask == 0x000000FF) {
489 if (Rmask == 0x3FF00000 &&
490 Gmask == 0x000FFC00 &&
491 Bmask == 0x000003FF &&
492 Amask == 0xC0000000) {
547 Uint32 Rmask, Gmask, Bmask, Amask;
551 &Rmask, &Gmask, &Bmask, &Amask)) {
620 if (--
format->refcount > 0) {
680 return SDL_SetError(
"SDL_SetPixelFormatPalette() passed NULL format");
683 if (palette && palette->
ncolors > (1 <<
format->BitsPerPixel)) {
684 return SDL_SetError(
"SDL_SetPixelFormatPalette() passed a palette that doesn't match the format");
687 if (
format->palette == palette) {
695 format->palette = palette;
706 int firstcolor,
int ncolors)
714 if (ncolors > (palette->
ncolors - firstcolor)) {
715 ncolors = (palette->
ncolors - firstcolor);
721 ncolors *
sizeof(*
colors));
755 for (
i = 0;
i < 256;
i++) {
760 r |=
r >> 3 |
r >> 6;
763 g |=
g >> 3 |
g >> 6;
780 unsigned int smallest;
792 distance = (rd * rd) + (gd * gd) + (bd * bd) + (ad * ad);
838 if (all_transparent) {
893 if (pixel < (
unsigned)
format->palette->ncolors) {
894 *
r =
format->palette->colors[pixel].r;
895 *
g =
format->palette->colors[pixel].g;
896 *
b =
format->palette->colors[pixel].b;
918 if (pixel < (
unsigned)
format->palette->ncolors) {
919 *
r =
format->palette->colors[pixel].r;
920 *
g =
format->palette->colors[pixel].g;
921 *
b =
format->palette->colors[pixel].b;
922 *
a =
format->palette->colors[pixel].a;
924 *
r = *
g = *
b = *
a = 0;
937 if (
src->ncolors <=
dst->ncolors) {
942 (
src->colors,
dst->colors,
955 for (
i = 0;
i <
src->ncolors; ++
i) {
958 src->colors[
i].b,
src->colors[
i].a);
973 bpp = ((
dst->BytesPerPixel == 3) ? 4 :
dst->BytesPerPixel);
1003 return (
Map1to1(&dithered, pal, identical));
1072 if ((*ptr)->entry == ent) {
1074 *
ptr = (*ptr)->next;
1078 ptr = &(*ptr)->next;
1093 map->src_palette_version = 0;
1094 map->dst_palette_version = 0;
1124 if (!
map->identity) {
1125 if (
map->info.table ==
NULL) {
1135 src->map->info.b,
src->map->info.a, dstfmt);
1136 if (
map->info.table ==
NULL) {
1144 if (!
map->identity) {
1145 if (
map->info.table ==
NULL) {
1152 if (srcfmt == dstfmt) {
1168 map->dst_palette_version = 0;
1174 map->src_palette_version = 0;
1196 if (gamma < 0.0f ) {
1206 if (gamma == 0.0f) {
1209 }
else if (gamma == 1.0f) {
1211 for (
i = 0;
i < 256; ++
i) {
1212 ramp[
i] = (
i << 8) |
i;
1218 gamma = 1.0f / gamma;
1219 for (
i = 0;
i < 256; ++
i) {
1221 (
int) (
SDL_pow((
double)
i / 256.0, gamma) * 65535.0 + 0.5);
1222 if (
value > 65535) {
void SDL_UnRLESurface(SDL_Surface *surface, int recode)
int SDL_CalculateBlit(SDL_Surface *surface)
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
#define SDL_OutOfMemory()
#define SDL_InvalidParamError(param)
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLint j2 GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLfloat *params GLenum GLint GLenum GLenum GLvoid *pixels GLenum GLint GLenum GLint *params GLenum GLenum GLint *params GLenum GLsizei const GLvoid *pointer GLenum GLenum const GLint *params GLenum GLfloat GLfloat GLint GLint const GLfloat *points GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat *points GLint GLfloat GLfloat GLint GLfloat GLfloat v2 GLenum GLenum const GLint *params GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum map
int uint32_t uint32_t uint32_t pixel_format
GLdouble GLdouble GLdouble r
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLsizei GLfloat distance
GLsizei const GLfloat * value
int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors)
Set a range of colors in a palette.
static SDL_PixelFormat * formats
void SDL_DitherColors(SDL_Color *colors, int bpp)
int SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette)
Set the palette for a pixel format structure.
static SDL_SpinLock formats_lock
void SDL_CalculateGammaRamp(float gamma, Uint16 *ramp)
Calculate a 256 entry gamma ramp for a gamma value.
void SDL_FreeFormat(SDL_PixelFormat *format)
Free an SDL_PixelFormat structure.
SDL_bool SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask)
Convert one of the enumerated pixel formats to a bpp and RGBA masks.
void SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel)
static Uint8 * Map1toN(SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, SDL_PixelFormat *dst)
static Uint8 * Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical)
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Maps an RGBA quadruple to a pixel value for a given pixel format.
Uint32 SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
Convert a bpp and RGBA masks to an enumerated pixel format.
Uint32 SDL_MapRGB(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b)
Maps an RGB triple to an opaque pixel value for a given pixel format.
void SDL_FreeBlitMap(SDL_BlitMap *map)
static void SDL_ListRemove(SDL_ListNode **head, void *ent)
void SDL_InvalidateMap(SDL_BlitMap *map)
Uint8 * SDL_expand_byte[9]
void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get the RGBA components from a pixel of the specified format.
static void SDL_ListAdd(SDL_ListNode **head, void *ent)
int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
const char * SDL_GetPixelFormatName(Uint32 format)
Get the human readable name of a pixel format.
void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b)
Get the RGB components from a pixel of the specified format.
static Uint8 * MapNto1(SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical)
SDL_Palette * SDL_AllocPalette(int ncolors)
Create a palette structure with the specified number of color entries.
SDL_PixelFormat * SDL_AllocFormat(Uint32 pixel_format)
Create an SDL_PixelFormat structure from a pixel format enum.
void SDL_FreePalette(SDL_Palette *palette)
Free a palette created with SDL_AllocPalette().
SDL_BlitMap * SDL_AllocBlitMap(void)
void SDL_InvalidateAllBlitMap(SDL_Surface *surface)
Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
#define SDL_BYTESPERPIXEL(X)
#define SDL_PIXELORDER(X)
#define SDL_BITSPERPIXEL(X)
@ SDL_PACKEDLAYOUT_1010102
@ SDL_PACKEDLAYOUT_2101010
#define SDL_ALPHA_TRANSPARENT
#define SDL_PIXELLAYOUT(X)
#define SDL_ISPIXELFORMAT_INDEXED(format)
@ SDL_PIXELFORMAT_INDEX1LSB
@ SDL_PIXELFORMAT_ABGR4444
@ SDL_PIXELFORMAT_BGRA4444
@ SDL_PIXELFORMAT_INDEX4MSB
@ SDL_PIXELFORMAT_RGBA8888
@ SDL_PIXELFORMAT_RGBA5551
@ SDL_PIXELFORMAT_ARGB1555
@ SDL_PIXELFORMAT_BGRX8888
@ SDL_PIXELFORMAT_ABGR8888
@ SDL_PIXELFORMAT_BGRA8888
@ SDL_PIXELFORMAT_ABGR1555
@ SDL_PIXELFORMAT_ARGB8888
@ SDL_PIXELFORMAT_ARGB4444
@ SDL_PIXELFORMAT_INDEX1MSB
@ SDL_PIXELFORMAT_INDEX4LSB
@ SDL_PIXELFORMAT_RGBX8888
@ SDL_PIXELFORMAT_BGRA5551
@ SDL_PIXELFORMAT_ARGB2101010
@ SDL_PIXELFORMAT_UNKNOWN
@ SDL_PIXELFORMAT_RGBA4444
#define SDL_ISPIXELFORMAT_FOURCC(format)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display int int int return Display long XVisualInfo int return Display Window Atom long long Bool Atom Atom int unsigned long unsigned long unsigned char * l)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr
struct SDL_ListNode * next
A collection of pixels used in software blitting.
typedef int(__stdcall *FARPROC)()